33 |
31 |
34 Example of use: |
32 Example of use: |
35 \code |
33 \code |
36 NmApiEventNotifier *notifier = new NmApiEventNotifier(this); |
34 NmApiEventNotifier *notifier = new NmApiEventNotifier(this); |
37 notifier->start(); |
35 notifier->start(); |
38 connect(notifier,SIGNAL(messageEvent(MessageEvent,quint64,quint64,QList<quint64>)),this, |
36 connect(notifier,SIGNAL(messageEvent(EmailClientApi::MessageEvent,quint64,quint64,QList<quint64>)),this, |
39 SLOT(processMessage(MessageEvent,quint64,quint64,QList<quint64>)),Qt::QueuedConnection); |
37 SLOT(processMessage(EmailClientApi::MessageEvent,quint64,quint64,QList<quint64>)),Qt::QueuedConnection); |
40 \endcode |
38 \endcode |
41 And then when want to end need to do: |
39 And then when want to end need to do: |
42 \code |
40 \code |
43 notifier->cancel(); |
41 notifier->cancel(); |
44 delete notifier; // or notifier->deleteLater(); |
42 delete notifier; // or notifier->deleteLater(); |
46 */ |
44 */ |
47 class NMAPI_EXPORT NmApiEventNotifier : public NmApiMessageTask |
45 class NMAPI_EXPORT NmApiEventNotifier : public NmApiMessageTask |
48 { |
46 { |
49 Q_OBJECT |
47 Q_OBJECT |
50 public: |
48 public: |
51 /*! |
49 |
52 Constructor |
|
53 */ |
|
54 NmApiEventNotifier(QObject *parent); |
50 NmApiEventNotifier(QObject *parent); |
55 |
|
56 /*! |
|
57 Destructor |
|
58 */ |
|
59 virtual ~NmApiEventNotifier(); |
51 virtual ~NmApiEventNotifier(); |
60 |
|
61 /*! |
|
62 Start monitoring email events |
|
63 |
|
64 Return value informs if monitoring system is up |
|
65 */ |
|
66 virtual bool start(); |
52 virtual bool start(); |
67 |
|
68 /*! |
|
69 Cancels monitoring. |
|
70 |
|
71 In user responsibility is to cancel monitoring. |
|
72 On end it clear buffer events and emits \sa NmApiMessageTask::canceled() signal. |
|
73 */ |
|
74 virtual void cancel(); |
53 virtual void cancel(); |
75 |
|
76 /*! |
|
77 Checks if event notifier is running. |
|
78 */ |
|
79 bool isRunning() const; |
54 bool isRunning() const; |
80 |
55 |
81 signals: |
56 signals: |
82 /*! |
57 |
83 This signal is emited when buffer of mailbox events is ready to send. Buffer is list of mailbox events with id. |
|
84 |
|
85 |
|
86 It emits signals grouped by events. So there will be as much signals as much there are events. |
|
87 For safety when connect it need to use \sa Qt::QueuedConnection. |
|
88 After that use \sa EmailClientApi::NmEmailService::getMailbox to get object. |
|
89 \param event Event of mailbox |
|
90 \param id List of mailbox ids where event occur. |
|
91 */ |
|
92 void mailboxEvent(EmailClientApi::NmApiMailboxEvent event, QList<quint64> id); |
58 void mailboxEvent(EmailClientApi::NmApiMailboxEvent event, QList<quint64> id); |
93 |
|
94 /*! |
|
95 This signal is emited when buffer of messages events is ready to send. Buffer is list of messages events with id. |
|
96 * |
|
97 It emits signals grouped by events, mailbox and folder. So there will be as much signals as much there are events. |
|
98 For safety when connect it need to use \sa Qt::QueuedConnection. |
|
99 After that use \sa EmailClientApi::NmApiEmailService::getEnvelope to get object. |
|
100 |
|
101 \param event Event of messages |
|
102 \param mailboxId Message mailbox |
|
103 \param folderId Message folder |
|
104 \param envelopeIdList List of messages ids where event occur |
|
105 */ |
|
106 void messageEvent(EmailClientApi::NmApiMessageEvent event, quint64 mailboxId, quint64 folderId, QList<quint64> envelopeIdList); |
59 void messageEvent(EmailClientApi::NmApiMessageEvent event, quint64 mailboxId, quint64 folderId, QList<quint64> envelopeIdList); |
107 |
60 |
108 public slots: |
61 public slots: |
109 /*! |
62 |
110 It check each object in buffer and emit signal with it. |
|
111 |
|
112 After end of work of this function buffer is empty. |
|
113 It is called by timeout signal from timer. |
|
114 */ |
|
115 void sendEventsFromBuffer(); |
63 void sendEventsFromBuffer(); |
116 |
64 |
117 private: |
65 private: |
118 NmApiEventNotifierPrivate *mNmApiEventNotifierPrivate; |
66 NmApiEventNotifierPrivate *mNmApiEventNotifierPrivate; |
119 }; |
67 }; |