CLControlPanel.h 2.25 KB
Newer Older
Nicolas Metts's avatar
Nicolas Metts committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
#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_