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

 Copyright 2014 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 "Metview.h"
#include "mars.h"
#include <iostream>

#include "MvQApplication.h"

#include "MvQMarsBrowser.h"

svc* s = NULL;
int ac;
char** av;


/*void browse_cb(svcid *id,request *r,void *)
{  
    	mon->input(id,r);
}*/

void dummy_cb(svcid* id, request* /*r*/, void*)
{
    send_reply(id, NULL);
}

void monitor()
{
    //request *t = empty_request("MONITOR");
    //call_switchboard(s,t);
    //free_all_requests(t);
}

int main(int argc, char** argv)
{
    MvQApplication app(argc, argv);

    //Initialise resorces from a static library (libMvQtGui)
    Q_INIT_RESOURCE(window);
    Q_INIT_RESOURCE(examiner);
    Q_INIT_RESOURCE(keyDialog);

    QApplication::setWindowIcon(
        QIcon(QPixmap(QString::fromUtf8(":/window/metview_logo"))));

    s = app.getService();
    add_service_callback(s, NULL, dummy_cb, NULL);
    //add_progress_callback(s,NULL,browse_cb,NULL);

    MvQMarsBrowser* browser = new MvQMarsBrowser;
    //browser->init();

    browser->show();

    return app.exec();
}


/*



#include <QApplication>

#include <iostream>
#include "Metview.h"

#include "MvQMarsBrowser.h"

using namespace std;

// Globals
int          ac;
char       **av;

class Base : public MvService
{
protected:
	Base(char* a) : MvService(a) {};
};

class MvMarsCatalog : public Base
{
public:
	MvMarsCatalog(char* a) : Base(a) {};
	void serve(MvRequest&,MvRequest&);
};

void MvMarsCatalog::serve( MvRequest& in, MvRequest& out)
{
  	cout << "--------------MvMarsCatalog::serve()--------------" << endl;
  	in.print();

	//Create the qt application
	QApplication app(ac, av);

	//Initialise resorces from a static library (libMvQtGui)
	Q_INIT_RESOURCE(examiner);
	Q_INIT_RESOURCE(keyDialog);
	Q_INIT_RESOURCE(window);

	MvQMarsBrowser *browser = new MvQMarsBrowser;
	//browser->init();
	
   	browser->show();
		
	//Enter the app loop
 	app.exec();
}

int main( int argc, char **argv )
{
	ac = argc;
  	av = argv;

	MvApplication theApp( argc, argv,"marscatalog");

    	MvMarsCatalog mc("MARSCATALOG");
	
    	theApp.run();
}
*/