Skip to content
CLControlPanel.h 2.25 KiB
Newer Older
Nicolas Metts's avatar
Nicolas Metts committed
#ifndef _CLCONTROLPANEL_H_
#define _CLCONTROLPANEL_H_

#include <Thread.h>
#include <signal.h>

#include <string>
#include <map>
#include <list>

// Copied from ControlPanelControllerSample.cc
#include <alljoyn/notification/NotificationService.h>
#include <alljoyn/controlpanel/ControlPanelService.h>
#include <alljoyn/controlpanel/ControlPanelController.h>
#include "AnnounceHandlerCL.h"
#include "ControlPanelListenerCL.h"
#include "ControllerNotificationReceiver.h"
#include <SrpKeyXListener.h>
#include <CommonSampleUtil.h>
#include <alljoyn/services_common/LogModulesNames.h>

using namespace std;
using namespace ajn;
using namespace services;
using namespace qcc;

namespace lsf {

class CLProxyManager;

// The ControlPanel class actually has nothing to to with a real Control Panel!
// The name is taken from the allseenalliance ControlPanelController sample application
// It's the code that allows controlling devices like the Smart Plug etc.

class CLControlPanel : public lsf::Thread {
public:
/**
 * CLControlPanel constructor
 */
    CLControlPanel(CLProxyManager *theProxyManager);

/**
 * CLControlPanel destructor
 */
    ~CLControlPanel();

    void Run();

    void Stop();

    QStatus Start();

    void Join();

    bool SetState(qcc::String szObjID, bool onOff);

    void announceHandlerCallback(qcc::String const& busName, unsigned short version,
                                 unsigned short port, ajn::AboutObjectDescription& objectDescription,
                                 ajn::AboutData& aboutData, qcc::String szArgsXMLarray);

    void changeHandleCallback(ajn::services::ControlPanelDevice* device, ajn::services::Property* property);

private:

    bool Init();

    bool bInitialized; // = false;
    volatile sig_atomic_t isRunning; // = false;

    CLProxyManager *myProxyManager;

// Copied from ControlPanelControllerSample.cc
    BusAttachment* bus; // = 0;
    ControlPanelService* controlPanelService; // = 0;
    ControlPanelController* controlPanelController; // = 0;
    ControlPanelListenerCL* controlPanelListener; // = 0;
    SrpKeyXListener* srpKeyXListener; // = 0;
    AnnounceHandlerCL* announceHandler; // = 0;
    NotificationService* conService; // = 0;
    ControllerNotificationReceiver* receiver; // = 0;

};

}

#endif // _CLCONTROLPANEL_H_