| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 | #ifndef CTKEVENTHANDLERWRAPPER_P_H#define CTKEVENTHANDLERWRAPPER_P_H#include <QStringList>#include <EventBus/ctkEventBus.h>#include <EventBus/ctkEventConstants.h>#include <ctkLDAPSearchFilter.h>#include <iostream>class ctkEventHandlerWrapper : public QObject {  Q_OBJECTprivate:  ctkEventBus::Properties properties;  QStringList topicList;  ctkLDAPSearchFilter filter;public:  ctkEventHandlerWrapper(const QObject* subscriber, const char* handler, const ctkEventBus::Properties& properties)    : properties(properties)  {    connect(this, SIGNAL(notifySubscriber(Event)), subscriber, handler);  }  QStringList topics() const  {    return topicList;  }  bool init()  {    topicList.clear();    // Get topic names    QVariant v = properties[EventConstants::EVENT_TOPIC];    topicList = v.toStringList();    if (topicList.empty())    {      return false;    }    v = properties[EventConstants::EVENT_FILTER];    filter = ctkLDAPSearchFilter(v.toString());    return true;  }  void handleEvent(const ctkEvent& event /*, const Permission& perm */)  {    if (!event.matches(filter)) return;    // should do permissions checks now somehow    // ...    try {      emit notifySubscriber(event);    }    catch (const std::exception& e)    {      // TODO logging      std::cerr << "Exception occured during publishing " << qPrintable(event.topic()) << ": " << e.what() << std::endl;    }  }signals:  void notifySubscriber(const ctkEvent&);};#endif // CTKEVENTHANDLERWRAPPER_P_H
 |