|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef NMAPIEVENTNOTIFIER_H |
|
19 #define NMAPIEVENTNOTIFIER_H |
|
20 |
|
21 #include <nmapimessagetask.h> |
|
22 #include <nmapidef.h> |
|
23 #include <nmapicommon.h> |
|
24 |
|
25 struct NmApiEvent; |
|
26 |
|
27 namespace EmailClientApi |
|
28 { |
|
29 class NmApiEventNotifierPrivate; |
|
30 |
|
31 /*! |
|
32 Notifier for mailbox and message events |
|
33 |
|
34 Example of use: |
|
35 \code |
|
36 NmApiEventNotifier *notifier = new NmApiEventNotifier(this); |
|
37 notifier->start(); |
|
38 connect(notifier,SIGNAL(messageEvent(MessageEvent,quint64,quint64,QList<quint64>)),this, |
|
39 SLOT(processMessage(MessageEvent,quint64,quint64,QList<quint64>)),Qt::QueuedConnection); |
|
40 \endcode |
|
41 And then when want to end need to do: |
|
42 \code |
|
43 notifier->cancel(); |
|
44 delete notifier; // or notifier->deleteLater(); |
|
45 \endcode |
|
46 */ |
|
47 class NMAPI_EXPORT NmApiEventNotifier : public NmApiMessageTask |
|
48 { |
|
49 Q_OBJECT |
|
50 public: |
|
51 /*! |
|
52 Constructor |
|
53 */ |
|
54 NmApiEventNotifier(QObject *parent); |
|
55 |
|
56 /*! |
|
57 Destructor |
|
58 */ |
|
59 virtual ~NmApiEventNotifier(); |
|
60 |
|
61 /*! |
|
62 Start monitoring email events |
|
63 |
|
64 Return value informs if monitoring system is up |
|
65 */ |
|
66 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(); |
|
75 |
|
76 /*! |
|
77 Checks if event notifier is running. |
|
78 */ |
|
79 bool isRunning() const; |
|
80 |
|
81 signals: |
|
82 /*! |
|
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); |
|
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); |
|
107 |
|
108 public slots: |
|
109 /*! |
|
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(); |
|
116 |
|
117 private: |
|
118 NmApiEventNotifierPrivate *mNmApiEventNotifierPrivate; |
|
119 }; |
|
120 |
|
121 } |
|
122 |
|
123 Q_DECLARE_METATYPE(QList<quint64>) |
|
124 |
|
125 #endif |