equal
deleted
inserted
replaced
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include "emailtrace.h" |
18 |
19 |
19 #include <nmapicommonheader.h> |
20 #include <nmapicommonheader.h> |
20 |
21 |
21 #include "nmapitypesconverter.h" |
22 #include "nmapitypesconverter.h" |
22 #include "nmdataplugininterface.h" |
23 #include "nmdataplugininterface.h" |
41 Private constructor |
42 Private constructor |
42 */ |
43 */ |
43 NmApiEngine::NmApiEngine() : |
44 NmApiEngine::NmApiEngine() : |
44 mFactory(NULL) |
45 mFactory(NULL) |
45 { |
46 { |
|
47 NM_FUNCTION; |
|
48 |
46 mFactory = NmApiDataPluginFactory::instance(); |
49 mFactory = NmApiDataPluginFactory::instance(); |
47 } |
50 } |
48 |
51 |
49 /*! |
52 /*! |
50 Destructor |
53 Destructor |
51 */ |
54 */ |
52 NmApiEngine::~NmApiEngine() |
55 NmApiEngine::~NmApiEngine() |
53 { |
56 { |
|
57 NM_FUNCTION; |
|
58 |
54 NmApiDataPluginFactory::releaseInstance(mFactory); |
59 NmApiDataPluginFactory::releaseInstance(mFactory); |
55 } |
60 } |
56 |
61 |
57 /*! |
62 /*! |
58 Creates instance of NmApiEngine and provide pointer to it. |
63 Creates instance of NmApiEngine and provide pointer to it. |
61 |
66 |
62 \return Instance of engine |
67 \return Instance of engine |
63 */ |
68 */ |
64 NmApiEngine *NmApiEngine::instance() |
69 NmApiEngine *NmApiEngine::instance() |
65 { |
70 { |
|
71 NM_FUNCTION; |
|
72 |
66 if (!mInstance) { |
73 if (!mInstance) { |
67 mInstance = new NmApiEngine(); |
74 mInstance = new NmApiEngine(); |
68 } |
75 } |
69 mReferenceCount++; |
76 mReferenceCount++; |
70 return mInstance; |
77 return mInstance; |
73 /*! |
80 /*! |
74 Creates connections for events from email store. |
81 Creates connections for events from email store. |
75 */ |
82 */ |
76 void NmApiEngine::startCollectingEvents() |
83 void NmApiEngine::startCollectingEvents() |
77 { |
84 { |
|
85 NM_FUNCTION; |
|
86 |
78 QObject *plugin = mFactory->plugin(); |
87 QObject *plugin = mFactory->plugin(); |
79 if(plugin){ |
88 if(plugin){ |
80 connect(plugin, SIGNAL(messageEvent(NmMessageEvent, NmId, QList<NmId> , NmId)), this, |
89 connect(plugin, SIGNAL(messageEvent(NmMessageEvent, NmId, QList<NmId> , NmId)), this, |
81 SLOT(messageChangedArrived(NmMessageEvent, NmId, QList<NmId> , NmId)), Qt::UniqueConnection); |
90 SLOT(messageChangedArrived(NmMessageEvent, NmId, QList<NmId> , NmId)), Qt::UniqueConnection); |
82 |
91 |
92 \arg Event of mailbox change |
101 \arg Event of mailbox change |
93 \arg List of mailbox ids for that event |
102 \arg List of mailbox ids for that event |
94 */ |
103 */ |
95 void NmApiEngine::mailboxChangedArrived(NmMailboxEvent mailboxEvent, const QList<NmId> &mailboxIds) |
104 void NmApiEngine::mailboxChangedArrived(NmMailboxEvent mailboxEvent, const QList<NmId> &mailboxIds) |
96 { |
105 { |
|
106 NM_FUNCTION; |
|
107 |
97 NmApiMessage message; |
108 NmApiMessage message; |
98 message.objectType = EMailbox; |
109 message.objectType = EMailbox; |
99 switch (mailboxEvent) { |
110 switch (mailboxEvent) { |
100 case NmMailboxCreated: { |
111 case NmMailboxCreated: { |
101 message.action = ENew; |
112 message.action = ENew; |
136 NmMessageEvent messageEvent, |
147 NmMessageEvent messageEvent, |
137 const NmId &folderId, |
148 const NmId &folderId, |
138 const QList<NmId> &messageIds, |
149 const QList<NmId> &messageIds, |
139 const NmId &mailboxId) |
150 const NmId &mailboxId) |
140 { |
151 { |
|
152 NM_FUNCTION; |
|
153 |
141 NmApiMessage message; |
154 NmApiMessage message; |
142 message.objectType = EMessage; |
155 message.objectType = EMessage; |
143 switch (messageEvent) { |
156 switch (messageEvent) { |
144 case NmMessageCreated: { |
157 case NmMessageCreated: { |
145 message.action = ENew; |
158 message.action = ENew; |
173 |
186 |
174 \param instance Instance of engine |
187 \param instance Instance of engine |
175 */ |
188 */ |
176 void NmApiEngine::releaseInstance(NmApiEngine *&instance) |
189 void NmApiEngine::releaseInstance(NmApiEngine *&instance) |
177 { |
190 { |
|
191 NM_FUNCTION; |
|
192 |
178 //can't have passed out instances if we don't have any |
193 //can't have passed out instances if we don't have any |
179 if (mInstance) { |
194 if (mInstance) { |
180 if (instance == mInstance) { |
195 if (instance == mInstance) { |
181 instance = NULL; |
196 instance = NULL; |
182 mReferenceCount--; |
197 mReferenceCount--; |
194 \sa EmailClientApi::NmMailbox |
209 \sa EmailClientApi::NmMailbox |
195 \param mailboxList List of mailboxes to be filled. |
210 \param mailboxList List of mailboxes to be filled. |
196 */ |
211 */ |
197 void NmApiEngine::listMailboxes(QList<EmailClientApi::NmApiMailbox> &mailboxList) |
212 void NmApiEngine::listMailboxes(QList<EmailClientApi::NmApiMailbox> &mailboxList) |
198 { |
213 { |
|
214 NM_FUNCTION; |
|
215 |
199 QList<NmMailbox*> mailboxFromPlugin; |
216 QList<NmMailbox*> mailboxFromPlugin; |
200 |
217 |
201 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
218 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
202 if (instance) { |
219 if (instance) { |
203 instance->listMailboxes(mailboxFromPlugin); |
220 instance->listMailboxes(mailboxFromPlugin); |
217 \param mailboxId Mailbox id from where folders should be returned |
234 \param mailboxId Mailbox id from where folders should be returned |
218 \param folderList of folders to be filled. |
235 \param folderList of folders to be filled. |
219 */ |
236 */ |
220 void NmApiEngine::listFolders(const quint64 mailboxId, QList<EmailClientApi::NmApiFolder> &folderList) |
237 void NmApiEngine::listFolders(const quint64 mailboxId, QList<EmailClientApi::NmApiFolder> &folderList) |
221 { |
238 { |
|
239 NM_FUNCTION; |
|
240 |
222 QList<NmFolder*> folderFromPlugin; |
241 QList<NmFolder*> folderFromPlugin; |
223 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
242 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
224 if (instance) { |
243 if (instance) { |
225 instance->listFolders(mailboxId, folderFromPlugin); |
244 instance->listFolders(mailboxId, folderFromPlugin); |
226 } |
245 } |
241 \param messageEnvelopeList List of envelopes to be filled. |
260 \param messageEnvelopeList List of envelopes to be filled. |
242 */ |
261 */ |
243 void NmApiEngine::listEnvelopes(const quint64 mailboxId, const quint64 folderId, |
262 void NmApiEngine::listEnvelopes(const quint64 mailboxId, const quint64 folderId, |
244 QList<EmailClientApi::NmApiMessageEnvelope> &messageEnvelopeList) |
263 QList<EmailClientApi::NmApiMessageEnvelope> &messageEnvelopeList) |
245 { |
264 { |
|
265 NM_FUNCTION; |
|
266 |
246 QList<NmMessage*> messages; |
267 QList<NmMessage*> messages; |
247 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
268 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
248 if (instance) { |
269 if (instance) { |
249 instance->listMessages(mailboxId, folderId, messages); |
270 instance->listMessages(mailboxId, folderId, messages); |
250 } |
271 } |
285 const quint64 mailboxId, |
306 const quint64 mailboxId, |
286 const quint64 folderId, |
307 const quint64 folderId, |
287 const quint64 envelopeId, |
308 const quint64 envelopeId, |
288 EmailClientApi::NmApiMessageEnvelope &envelope) |
309 EmailClientApi::NmApiMessageEnvelope &envelope) |
289 { |
310 { |
|
311 NM_FUNCTION; |
|
312 |
290 //flag indicating that envelope with given id was found |
313 //flag indicating that envelope with given id was found |
291 bool found = false; |
314 bool found = false; |
292 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
315 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
293 if (instance) { |
316 if (instance) { |
294 NmMessage *message(NULL); |
317 NmMessage *message(NULL); |
325 |
348 |
326 \return Return true if it will find any envelope |
349 \return Return true if it will find any envelope |
327 */ |
350 */ |
328 bool NmApiEngine::getMailboxById(const quint64 mailboxId, EmailClientApi::NmApiMailbox &mailbox) |
351 bool NmApiEngine::getMailboxById(const quint64 mailboxId, EmailClientApi::NmApiMailbox &mailbox) |
329 { |
352 { |
|
353 NM_FUNCTION; |
|
354 |
330 //flag indicating that mailbox with given id was found |
355 //flag indicating that mailbox with given id was found |
331 bool found = false; |
356 bool found = false; |
332 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
357 NmDataPluginInterface *instance = mFactory->interfaceInstance(); |
333 |
358 |
334 if (instance) { |
359 if (instance) { |