/***************************** 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 *************************************/

#ifndef MvQService_H
#define MvQService_H

#include <QObject>
#include <QMainWindow>

#include "MvRequest.h"
#include "MvProtocol.h"
#include "MvService.h"

class QSocketNotifier;
class QMainWindow;

class MvQService : public QObject, public MvService
{
    Q_OBJECT

public:
    MvQService(const char* name = NULL);
    virtual ~MvQService();

public slots:
    void slotDataReceived(int);

protected:
    void registerToDesktop(QMainWindow* win);
    void setupSocketNotifier();
    virtual void messageCallback(svcid* id, request* r);

private:
    static void messageCallbackCore(svcid* id, request* r, void* obj);

    // No copy allowed
    MvQService(const MvQService&);
    MvQService& operator=(const MvQService&) { return *this; }

    QSocketNotifier* socketNotifier_;
    QMainWindow* win_;
};

#endif
