/***************************** LICENSE START ***********************************

 Copyright 2012 ECMWF and INPE. This software is distributed under the terms
 of the Apache License version 2.0. In applying this license, ECMWF does not
 waive the privileges and immunities granted to it by virtue of its status as
 an Intergovernmental Organization or submit itself to any jurisdiction.

 ***************************** LICENSE END *************************************/

#include <MvApplication.h>
#include "PlotModBatch.h"
#include "PlotModConst.h"

PlotModBatch::PlotModBatch()
{
	isInteractive_   = false;
	isWindow_        = false;
	plotDestination_ = MVFILE;
	printerName_     = "";
}

void
PlotModBatch::UserMessage( const string& message )
{
	cout << message.c_str() << endl;
}



// print a message to the log window or the output; if 'priority', then 
// it will be visible without '-slog'
void PlotModBatch::printMessage(const string& msg, bool priority)
{
    char c_msg[1024];
    strncpy (c_msg, msg.c_str(), 1023);

    if (priority)
    {
        svc *service = MvApplication::instance().getService();

        // copy the message into a C string and send it to the service

        if (service != NULL)
        {
            set_svc_msg(service->id,c_msg);
        }
    }
    else
    {
        marslog(LOG_INFO|LOG_PERR, c_msg);
    }
}



void
PlotModBatch::SystemError ( const string & message, const string & title )
{
	//cout << "PlotMod::SystemError -> IT NEEDS TO IMPLEMENT THIS METHOD" << endl;

    // call the MetviewError method to get some output to the user

    string fullMessage = title + ": " + message;
    MetviewError (fullMessage, "ERROR");


#if 0
      cout << ">>>>> " << title.c_str() << " <<<<<" << endl;
      cout << message.c_str() << endl << endl;

  MvRequest reqst("USER_MESSAGE");
  reqst("INFO") = message.c_str(); 
  send_message(PlotModApp::Instance().getService(),(request*)reqst);
#endif
}


#if 0
void
PlotMod::InternalError ( const string & message, const string & title )
{
      cout << ">>>>> " << title.c_str() << " <<<<<" << endl;
      cout << message.c_str() << endl << endl;

  MvRequest reqst("USER_MESSAGE");
  reqst("INFO") = message.c_str(); 

  send_message(PlotModApp::Instance().getService(),(request*)reqst);
}

#endif
