13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 #include <xqservicerequest.h> |
18 #include <QDebug> |
19 #include <QDebug> |
19 #include <QTimer> |
20 #include <QTimer> |
20 #include <QDir> |
21 #include <QDir> |
21 #include <qpluginloader.h> |
22 #include <qpluginloader.h> |
22 #include <XQServiceRequest.h> |
|
23 #include "email_services_api.h" |
23 #include "email_services_api.h" |
24 #include "nmcommon.h" |
24 #include "nmcommon.h" |
25 #include "nmmessageenvelope.h" |
25 #include "nmmessageenvelope.h" |
26 #include "nmhswidgetemailengine.h" |
26 #include "nmhswidgetemailengine.h" |
27 #include "nmdataplugininterface.h" |
27 #include "nmdataplugininterface.h" |
28 #include "nmmailbox.h" |
28 #include "nmmailbox.h" |
29 #include "nmfolder.h" |
29 #include "nmfolder.h" |
30 #include "nmdatapluginfactory.h" |
30 #include "nmdatapluginfactory.h" |
|
31 #include "nmhswidgetconsts.h" |
31 |
32 |
32 /*! |
33 /*! |
33 Constructor |
34 Constructor |
34 */ |
35 */ |
35 NmHsWidgetEmailEngine::NmHsWidgetEmailEngine(const NmId& monitoredMailboxId) : |
36 NmHsWidgetEmailEngine::NmHsWidgetEmailEngine(const NmId& monitoredMailboxId) : |
36 mMailboxId(monitoredMailboxId), mAccountName(0), mUnreadCount(0), |
37 mMailboxId(monitoredMailboxId), |
37 mEmailInterface(0), mFactory(0), mAccountEventReceivedWhenSuspended(false), |
38 mFolderId(0), |
38 mMessageEventReceivedWhenSuspended(false), mSuspended(false) |
39 mAccountName(0), |
39 { |
40 mUnreadCount(-1), |
40 qDebug()<<"NmHsWidgetEmailEngine() -- START"; |
41 mEmailInterface(0), |
41 constructNmPlugin(); |
42 mFactory(0), |
|
43 mAccountEventReceivedWhenSuspended(false), |
|
44 mMessageEventReceivedWhenSuspended(false), |
|
45 mSuspended(false), |
|
46 mUpdateTimer(0) |
|
47 { |
|
48 qDebug() << "NmHsWidgetEmailEngine() -- START"; |
|
49 |
|
50 qDebug() << "NmHsWidgetEmailEngine() -- END"; |
|
51 } |
|
52 |
|
53 /*! |
|
54 initilaize - Initializes the engine |
|
55 Works as a second phase constructor. Must be called before any other operations. |
|
56 Client should connect to exceptionOccured signal before calling this method. |
|
57 /return true if initialize succeedes otherwise false. If false the object is unusable. |
|
58 */ |
|
59 bool NmHsWidgetEmailEngine::initialize() |
|
60 { |
|
61 qDebug() << "initialize() -- START"; |
|
62 |
|
63 if (!constructNmPlugin()) { |
|
64 //if plugin connection fails, there's no reason to proceed |
|
65 return false; |
|
66 } |
42 updateData(); |
67 updateData(); |
43 updateAccount(); |
68 updateAccount(); |
44 qDebug()<<"NmHsWidgetEmailEngine() -- END"; |
69 |
45 } |
70 mUpdateTimer = new QTimer(this); |
46 |
71 mUpdateTimer->setInterval(NmHsWidgetEmailEngineUpdateTimerValue); |
|
72 connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(handleUpdateTimeout()) ); |
|
73 |
|
74 qDebug() << "initialize() -- END"; |
|
75 return true; |
|
76 } |
47 |
77 |
48 /*! |
78 /*! |
49 constructNmPlugin |
79 constructNmPlugin |
50 */ |
80 /post Constructs a connection to an instance of NmDataPluginInterface |
51 void NmHsWidgetEmailEngine::constructNmPlugin() |
81 /return true if construction succeeded, otherwise false. |
52 { |
82 */ |
53 qDebug()<<"NmHsWidgetEmailEngine::constructNmPlugin() -- START"; |
83 bool NmHsWidgetEmailEngine::constructNmPlugin() |
54 |
84 { |
55 QObject* pluginInstance(0); |
85 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- START"; |
|
86 |
|
87 QObject* pluginInstance(0); |
56 //Get data plugin factory instance |
88 //Get data plugin factory instance |
57 mFactory = NmDataPluginFactory::instance(); |
89 mFactory = NmDataPluginFactory::instance(); |
58 |
90 if (!mFactory) { |
59 if(mFactory) |
91 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- mFactory FAILED"; |
60 { |
92 return false; |
61 pluginInstance = mFactory->pluginInstance(mMailboxId); |
93 } |
62 } |
94 |
63 |
95 //Get plugin instance |
64 if(pluginInstance) |
96 pluginInstance = mFactory->pluginInstance(mMailboxId); |
65 { |
97 if (!pluginInstance) { |
66 mEmailInterface = mFactory->interfaceInstance( pluginInstance ); |
98 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- pluginInstance FAILED"; |
67 mFolderId = mEmailInterface->getStandardFolderId(mMailboxId, NmFolderInbox); |
99 return false; |
68 //Subscription is needed - otherwise the signals will not be received |
100 } |
69 mEmailInterface->subscribeMailboxEvents(mMailboxId); |
101 |
70 |
102 //get interface instance |
71 //Connect to events |
103 mEmailInterface = mFactory->interfaceInstance(pluginInstance); |
72 connect(pluginInstance, |
104 |
73 SIGNAL( messageEvent(NmMessageEvent, const NmId&, |
105 if (!mEmailInterface) { |
74 const QList<NmId>&, const NmId&) ), |
106 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- mEmailInterface FAILED"; |
75 this, |
107 return false; |
76 SLOT( handleMessageEvent(NmMessageEvent, const NmId&, |
108 } |
77 const QList<NmId>&, const NmId&) )); |
109 //Verify that the mailbox we are interested actually exists. |
78 |
110 //Otherwise emit account deleted event (instead of just returning) |
79 connect(pluginInstance, |
111 QList<NmId> ids; |
80 SIGNAL( mailboxEvent(NmMailboxEvent, const QList<NmId>& ) ), |
112 mEmailInterface->listMailboxIds(ids); |
81 this, |
113 if(!ids.contains(mMailboxId)){ |
82 SLOT( handleMailboxEvent(NmMailboxEvent, const QList<NmId>&) )); |
114 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- !ids.contains(mMailboxId) FAILED"; |
83 |
115 emit exceptionOccured(NmEngineExcAccountDeleted); |
84 qDebug()<<"NmHsWidgetEmailEngine::constructNmPlugin() -- OK"; |
116 return false; |
85 } |
117 } |
86 else |
118 |
87 { |
119 //retrieve folderID for this mailbox's inbox |
88 emit errorOccured(NmEngineErrFailure); |
120 //If NmId equals zero, we don't have the Initial sync done for the account |
89 qDebug()<<"NmHsWidgetEmailEngine::constructNmPlugin() -- FAILED"; |
121 //This is valid at least for IMAP accounts. |
90 } |
122 //Folder ID is then retrieved later when first message event is received |
91 |
123 mFolderId = mEmailInterface->getStandardFolderId(mMailboxId, NmFolderInbox); |
92 qDebug()<<"NmHsWidgetEmailEngine::constructNmPlugin() -- END"; |
124 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- mFolderId==" << mFolderId.id(); |
93 } |
125 |
|
126 //Subscription is needed - otherwise the signals will not be received |
|
127 mEmailInterface->subscribeMailboxEvents(mMailboxId); |
|
128 |
|
129 //Connect to events |
|
130 connect(pluginInstance, SIGNAL( messageEvent(NmMessageEvent, const NmId&, |
|
131 const QList<NmId>&, const NmId&) ), this, |
|
132 SLOT( handleMessageEvent(NmMessageEvent, const NmId&, |
|
133 const QList<NmId>&, const NmId&) )); |
|
134 |
|
135 connect(pluginInstance, SIGNAL( mailboxEvent(NmMailboxEvent, const QList<NmId>& ) ), this, |
|
136 SLOT( handleMailboxEvent(NmMailboxEvent, const QList<NmId>&) )); |
|
137 |
|
138 qDebug() << "NmHsWidgetEmailEngine::constructNmPlugin() -- OK"; |
|
139 |
|
140 return true; |
|
141 } |
94 |
142 |
95 /*! |
143 /*! |
96 Reset envelope list |
144 Reset envelope list |
97 \post mEnvelopeList.isEmpty() == true && all contained objects are deleted |
145 \post mEnvelopeList.isEmpty() == true && all contained objects are deleted |
98 */ |
146 */ |
99 void NmHsWidgetEmailEngine::resetEnvelopeList() |
147 void NmHsWidgetEmailEngine::resetEnvelopeList() |
100 { |
148 { |
101 qDebug()<<"NmHsWidgetEmailEngine::resetEnvelopeList() -- START"; |
149 qDebug() << "NmHsWidgetEmailEngine::resetEnvelopeList() -- START"; |
102 |
150 |
103 while (!mEnvelopeList.isEmpty()) |
151 while (!mEnvelopeList.isEmpty()) { |
104 { |
|
105 delete mEnvelopeList.takeFirst(); |
152 delete mEnvelopeList.takeFirst(); |
106 } |
153 } |
107 |
154 |
108 qDebug()<<"NmHsWidgetEmailEngine::resetEnvelopeList() -- END"; |
155 qDebug() << "NmHsWidgetEmailEngine::resetEnvelopeList() -- END"; |
109 } |
156 } |
110 |
157 |
111 /*! |
158 /*! |
112 Destructor |
159 Destructor |
113 */ |
160 */ |
114 NmHsWidgetEmailEngine::~NmHsWidgetEmailEngine() |
161 NmHsWidgetEmailEngine::~NmHsWidgetEmailEngine() |
115 { |
162 { |
116 qDebug()<<"~NmHsWidgetEmailEngine -- START"; |
163 qDebug() << "~NmHsWidgetEmailEngine -- START"; |
117 |
164 |
118 resetEnvelopeList(); |
165 resetEnvelopeList(); |
119 if ( mFactory ) |
166 if (mFactory) { |
120 { |
|
121 NmDataPluginFactory::releaseInstance(mFactory); |
167 NmDataPluginFactory::releaseInstance(mFactory); |
122 } |
168 } |
123 qDebug()<<"~NmHsWidgetEmailEngine -- END"; |
169 |
124 } |
170 if (mUpdateTimer){ |
125 |
171 mUpdateTimer->stop(); |
|
172 delete mUpdateTimer; |
|
173 } |
|
174 |
|
175 qDebug() << "~NmHsWidgetEmailEngine -- END"; |
|
176 } |
126 |
177 |
127 /*! |
178 /*! |
128 getEnvelopes() provides message envelopes as a list of stack objects |
179 getEnvelopes() provides message envelopes as a list of stack objects |
129 Amount of message envelopes in the list parameter is the smallest of the following factors: |
180 Amount of message envelopes in the list parameter is the smallest of the following factors: |
130 'KMaxNumberOfEnvelopesProvided', 'maxEnvelopeAmount', 'amount of available envelopes'. |
181 'KMaxNumberOfEnvelopesProvided', 'maxEnvelopeAmount', 'amount of available envelopes'. |
131 |
182 |
132 \param list list to be filled with message envelopes |
183 \param list list to be filled with message envelopes |
133 \param maxEnvelopeAmount Client side limit for amount of message envelope count. |
184 \param maxEnvelopeAmount Client side limit for amount of message envelope count. |
134 \return count of envelopes added to list |
185 \return count of envelopes added to list |
135 */ |
186 */ |
136 int NmHsWidgetEmailEngine::getEnvelopes(QList<NmMessageEnvelope> &list, |
187 int NmHsWidgetEmailEngine::getEnvelopes(QList<NmMessageEnvelope> &list, int maxEnvelopeAmount) |
137 int maxEnvelopeAmount) |
188 { |
138 { |
189 qDebug() << "NmHsWidgetEmailEngine::getEnvelopes()"; |
139 qDebug()<<"NmHsWidgetEmailEngine::getEnvelopes()"; |
|
140 list.clear(); //Reset the parameter list to avoid side effects |
190 list.clear(); //Reset the parameter list to avoid side effects |
141 int i = 0; |
191 int i = 0; |
142 for (; i < mEnvelopeList.count() && i < maxEnvelopeAmount; i++) |
192 for (; i < mEnvelopeList.count() && i < maxEnvelopeAmount; i++) { |
143 { |
|
144 NmMessageEnvelope env(*mEnvelopeList[i]); |
193 NmMessageEnvelope env(*mEnvelopeList[i]); |
145 list.append(env); |
194 list.append(env); |
146 } |
195 } |
147 return i; |
196 return i; |
148 } |
197 } |
149 |
198 |
150 /*! |
199 /*! |
151 UnreadCount |
200 UnreadCount |
152 |
201 |
153 \return count of unread mails |
202 \return count of unread mails, or -1 if there are no mails at all in the mailbox. |
154 */ |
203 */ |
155 int NmHsWidgetEmailEngine::unreadCount() |
204 int NmHsWidgetEmailEngine::unreadCount() |
156 { |
205 { |
157 qDebug()<<"NmHsWidgetEmailEngine::unreadCount()"; |
206 qDebug() << "NmHsWidgetEmailEngine::unreadCount()"; |
158 return mUnreadCount; |
207 return mUnreadCount; |
159 } |
208 } |
160 |
209 |
161 /*! |
210 /*! |
162 accountName |
211 accountName |
163 |
212 |
164 \return name of the monitored account |
213 \return name of the monitored account |
165 */ |
214 */ |
166 QString NmHsWidgetEmailEngine::accountName() |
215 QString NmHsWidgetEmailEngine::accountName() |
167 { |
216 { |
168 qDebug()<<"NmHsWidgetEmailEngine::accountName()"; |
217 qDebug() << "NmHsWidgetEmailEngine::accountName()"; |
169 return mAccountName; |
218 return mAccountName; |
170 } |
219 } |
171 |
220 |
172 /*! |
221 /*! |
173 Refresh email data. |
222 Refresh email data. |
174 \post mEnvelopeList is refreshed with valid content so that it has |
223 \post mEnvelopeList is refreshed with valid content so that it has |
175 valid data with maximum of KMaxNumberOfEnvelopesProvided envelopes |
224 valid data with maximum of KMaxNumberOfEnvelopesProvided envelopes. |
|
225 |
|
226 - emits exceptionOccured(NmEngineExcFailure) if fatal error occurs. |
|
227 - emits mailDataChanged() if new mail data is set into mEnvelopeList |
|
228 - emits unreadCountChanged(mUnreadCount), if mUnreadCount is updated |
176 |
229 |
177 */ |
230 \return true if everything succeeded, otherwise false |
178 void NmHsWidgetEmailEngine::updateData() |
231 */ |
179 { |
232 bool NmHsWidgetEmailEngine::updateData() |
180 qDebug()<<"NmHsWidgetEmailEngine::updateData() -- START"; |
233 { |
181 if(!mEmailInterface) |
234 qDebug() << "NmHsWidgetEmailEngine::updateData() -- START"; |
182 { |
235 if (!mEmailInterface) { |
183 qDebug()<<"NmHsWidgetEmailEngine::updateData() -- Interface missing"; |
236 qDebug() << "NmHsWidgetEmailEngine::updateData() -- Interface missing"; |
184 return; //if interface is missing there's nothing to do |
237 emit exceptionOccured(NmEngineExcFailure); //fatal error |
185 } |
238 return false; //if interface is missing there's nothing to do |
|
239 } |
|
240 |
186 //reset envelope list before retrieving new items |
241 //reset envelope list before retrieving new items |
187 resetEnvelopeList(); |
242 resetEnvelopeList(); |
|
243 |
188 //get messages from inbox |
244 //get messages from inbox |
189 mEmailInterface->listMessages(mMailboxId, mFolderId, mEnvelopeList, KMaxNumberOfEnvelopesProvided); |
245 int msgErr = mEmailInterface->listMessages(mMailboxId, mFolderId, mEnvelopeList, |
190 Q_ASSERT_X(mEnvelopeList.count() <= KMaxNumberOfEnvelopesProvided, "nmhswidgetemailengine", "list max size exeeded"); |
246 KMaxNumberOfEnvelopesProvided); |
|
247 if (msgErr) { |
|
248 //retrieval of messages failed. |
|
249 return false; |
|
250 } |
191 //emit signal about new message data right away |
251 //emit signal about new message data right away |
192 emit mailDataChanged(); |
252 emit mailDataChanged(); |
193 //retrieve new unread count to mUnreadCount |
253 //retrieve new unread count to mUnreadCount |
194 NmFolder* folder = NULL; |
254 NmFolder* folder = NULL; |
195 int err = mEmailInterface->getFolderById(mMailboxId, mFolderId, folder); |
255 int folderErr = mEmailInterface->getFolderById(mMailboxId, mFolderId, folder); |
196 |
256 if (folderErr) { |
197 if(folder) |
257 //retrieval of valid folder failed. |
198 { |
258 return false; |
199 mUnreadCount = folder->unreadMessageCount(); |
259 } |
|
260 if (folder) { |
|
261 //If messageCount in the folder is zero we must indicate unread count to be -1 |
|
262 if (folder->messageCount() == 0) { |
|
263 mUnreadCount = -1; |
|
264 } |
|
265 else { |
|
266 mUnreadCount = folder->unreadMessageCount(); |
|
267 } |
200 delete folder; |
268 delete folder; |
201 folder = NULL; |
269 folder = NULL; |
202 //limit the unread count to KMaxUnreadCount |
270 //limit the unread count to KMaxUnreadCount |
203 if( mUnreadCount > KMaxUnreadCount) |
271 if (mUnreadCount > KMaxUnreadCount) { |
204 { |
|
205 mUnreadCount = KMaxUnreadCount; |
272 mUnreadCount = KMaxUnreadCount; |
206 } |
273 } |
207 //emit signal about changed unread count |
274 //emit signal about changed unread count |
208 emit unreadCountChanged(mUnreadCount); |
275 emit unreadCountChanged(mUnreadCount); |
209 } |
276 }else{ |
210 |
277 return false; |
211 |
278 } |
212 |
279 |
213 qDebug()<<"NmHsWidgetEmailEngine::updateData() -- END"; |
280 qDebug() << "NmHsWidgetEmailEngine::updateData() -- END"; |
214 } |
281 return true; |
|
282 } |
215 |
283 |
216 /*! |
284 /*! |
217 handleMessageEvent slot. |
285 handleMessageEvent slot. |
218 */ |
286 */ |
219 void NmHsWidgetEmailEngine::handleMessageEvent(NmMessageEvent event, |
287 void NmHsWidgetEmailEngine::handleMessageEvent( |
220 const NmId &folderId, const QList<NmId> &messageIds, const NmId& mailboxId) |
288 NmMessageEvent event, |
221 { |
289 const NmId &folderId, |
222 qDebug()<<"NmHsWidgetEmailEngine::handleMessageEvent() -- START"; |
290 const QList<NmId> &messageIds, |
|
291 const NmId& mailboxId) |
|
292 { |
|
293 qDebug() << "NmHsWidgetEmailEngine::handleMessageEvent() -- START"; |
223 Q_UNUSED(event); |
294 Q_UNUSED(event); |
224 Q_UNUSED(messageIds); |
295 Q_UNUSED(messageIds); |
225 if ( (folderId == mFolderId) && (mailboxId == mMailboxId) ) |
296 |
226 { |
297 if (!mEmailInterface) { |
|
298 qDebug() << "NmHsWidgetEmailEngine::handleMessageEvent() -- Interface missing"; |
|
299 emit exceptionOccured(NmEngineExcFailure); //fatal error |
|
300 return; //if interface is missing there's nothing to do |
|
301 } |
|
302 |
|
303 if (mFolderId == NmId(0)) { |
|
304 // inbox was not created in construction phase, so let's |
|
305 // get id now as received first mail event |
|
306 mFolderId = mEmailInterface->getStandardFolderId(mMailboxId, NmFolderInbox); |
|
307 } |
|
308 if ((folderId == mFolderId) && (mailboxId == mMailboxId)) { |
227 //Data is updated only if the engine is not suspended |
309 //Data is updated only if the engine is not suspended |
228 if( mSuspended ) |
310 if (mSuspended) { |
229 { |
|
230 mMessageEventReceivedWhenSuspended = true; |
311 mMessageEventReceivedWhenSuspended = true; |
|
312 } |
|
313 else { |
|
314 //start or restart the timer. Update is started when timer expires |
|
315 mUpdateTimer->start(); |
|
316 } |
|
317 } |
|
318 qDebug() << "NmHsWidgetEmailEngine::handleMessageEvent() -- END"; |
|
319 } |
|
320 |
|
321 /*! |
|
322 handleMailboxEvent slot. |
|
323 */ |
|
324 void NmHsWidgetEmailEngine::handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds) |
|
325 { |
|
326 qDebug() << "NmHsWidgetEmailEngine::handleMailboxEvent() -- START"; |
|
327 if (mailboxIds.contains(mMailboxId)) { |
|
328 switch (event) { |
|
329 case (NmMailboxChanged): { |
|
330 if (mSuspended) { |
|
331 mAccountEventReceivedWhenSuspended = true; |
|
332 } |
|
333 else { |
|
334 updateAccount(); |
|
335 } |
|
336 break; |
231 } |
337 } |
232 else |
338 case (NmMailboxDeleted): { |
233 { |
339 emit exceptionOccured(NmEngineExcAccountDeleted); |
234 updateData(); |
340 break; |
235 } |
|
236 } |
|
237 qDebug()<<"NmHsWidgetEmailEngine::handleMessageEvent() -- END"; |
|
238 } |
|
239 |
|
240 /*! |
|
241 handleMailboxEvent slot. |
|
242 */ |
|
243 void NmHsWidgetEmailEngine::handleMailboxEvent(NmMailboxEvent event, |
|
244 const QList<NmId> &mailboxIds) |
|
245 { |
|
246 qDebug()<<"NmHsWidgetEmailEngine::handleMailboxEvent() -- START"; |
|
247 Q_UNUSED(mailboxIds); |
|
248 //react only to NmMailboxChanged event |
|
249 if (event == NmMailboxChanged) |
|
250 { |
|
251 if ( mSuspended ) |
|
252 { |
|
253 mAccountEventReceivedWhenSuspended = true; |
|
254 } |
341 } |
255 else |
342 default: |
256 { |
343 //ignored |
257 updateAccount(); |
344 break; |
258 } |
345 } |
259 |
346 } |
260 } |
347 qDebug() << "NmHsWidgetEmailEngine::handleMailboxEvent() -- END"; |
261 qDebug()<<"NmHsWidgetEmailEngine::handleMailboxEvent() -- END"; |
348 } |
262 } |
349 |
|
350 /*! |
|
351 * handleUpdateTimeout slot |
|
352 */ |
|
353 void NmHsWidgetEmailEngine::handleUpdateTimeout() |
|
354 { |
|
355 qDebug() << "NmHsWidgetEmailEngine::handleUpdateTimeout() -- START"; |
|
356 if (mUpdateTimer){ |
|
357 mUpdateTimer->stop(); |
|
358 } |
|
359 updateData(); |
|
360 qDebug() << "NmHsWidgetEmailEngine::updateAccount() -- END"; |
|
361 } |
263 |
362 |
264 /*! |
363 /*! |
265 Update Account data |
364 Update Account data |
266 \post if mEmailInterface exists, the mAccountName is refreshed from adapter |
365 \post if mEmailInterface exists, the mAccountName is refreshed from adapter |
267 and accountNameChanged signal is emitted. |
366 and accountNameChanged signal is emitted. |
268 */ |
367 */ |
269 void NmHsWidgetEmailEngine::updateAccount() |
368 bool NmHsWidgetEmailEngine::updateAccount() |
270 { |
369 { |
271 qDebug()<<"NmHsWidgetEmailEngine::updateAccount() -- START"; |
370 qDebug() << "NmHsWidgetEmailEngine::updateAccount() -- START"; |
272 |
371 |
273 NmMailbox* box = NULL; |
372 NmMailbox* box = NULL; |
274 if(mEmailInterface) |
373 if (mEmailInterface) { |
275 { |
374 int err = mEmailInterface->getMailboxById(mMailboxId, box); |
276 mEmailInterface->getMailboxById(mMailboxId, box); |
375 if (err) { |
277 } |
376 //By specification return and wait another event |
278 if (box) |
377 return false; |
279 { |
378 } |
|
379 } |
|
380 if (box) { |
280 mAccountName = box->name(); |
381 mAccountName = box->name(); |
281 emit accountNameChanged(mAccountName); |
|
282 delete box; |
382 delete box; |
283 box = NULL; |
383 box = NULL; |
284 } |
384 emit accountNameChanged(mAccountName); |
285 qDebug()<<"NmHsWidgetEmailEngine::updateAccount() -- END"; |
385 } |
286 } |
386 qDebug() << "NmHsWidgetEmailEngine::updateAccount() -- END"; |
287 |
387 return true; |
288 /*! |
388 } |
289 suspend slot. |
389 |
290 \post engine will not emit signals or refresh its data during suspension. |
390 /*! |
|
391 suspend slot. |
|
392 \post engine will not emit signals or refresh its data during suspension. |
291 */ |
393 */ |
292 void NmHsWidgetEmailEngine::suspend() |
394 void NmHsWidgetEmailEngine::suspend() |
293 { |
395 { |
294 qDebug()<<"NmHsWidgetEmailEngine::suspend() -- START"; |
396 qDebug() << "NmHsWidgetEmailEngine::suspend() -- START"; |
295 mSuspended = true; |
397 mSuspended = true; |
296 qDebug()<<"NmHsWidgetEmailEngine::suspend() -- END"; |
398 qDebug() << "NmHsWidgetEmailEngine::suspend() -- END"; |
297 } |
399 } |
298 |
400 |
299 /*! |
401 /*! |
300 activate slot. |
402 activate slot. |
301 \post Engine will immediately refresh all the data that has been announced to |
403 \post Engine will immediately refresh all the data that has been announced to |
302 have changed during the suspension. Events are enabled. |
404 have changed during the suspension. Events are enabled. |
303 */ |
405 */ |
304 void NmHsWidgetEmailEngine::activate() |
406 void NmHsWidgetEmailEngine::activate() |
305 { |
407 { |
306 qDebug()<<"NmHsWidgetEmailEngine::activate() -- START"; |
408 qDebug() << "NmHsWidgetEmailEngine::activate() -- START"; |
307 mSuspended = false; |
409 mSuspended = false; |
308 if ( mAccountEventReceivedWhenSuspended ) |
410 if (mAccountEventReceivedWhenSuspended) { |
309 { |
|
310 mAccountEventReceivedWhenSuspended = false; |
411 mAccountEventReceivedWhenSuspended = false; |
311 updateAccount(); |
412 updateAccount(); |
312 } |
413 } |
313 if (mMessageEventReceivedWhenSuspended) |
414 if (mMessageEventReceivedWhenSuspended) { |
314 { |
|
315 mMessageEventReceivedWhenSuspended = false; |
415 mMessageEventReceivedWhenSuspended = false; |
316 updateData(); |
416 updateData(); |
317 } |
417 } |
318 qDebug()<<"NmHsWidgetEmailEngine::activate() -- END"; |
418 qDebug() << "NmHsWidgetEmailEngine::activate() -- END"; |
319 } |
419 } |
320 |
420 |
321 /*! |
421 /*! |
322 launchMailAppInboxView slot. |
422 launchMailAppInboxView slot. |
323 \post Mail application is launched to inbox view corresponding widget's mailbox id |
423 \post Mail application is launched to inbox view corresponding widget's mailbox id |
324 */ |
424 */ |
325 void NmHsWidgetEmailEngine::launchMailAppInboxView() |
425 void NmHsWidgetEmailEngine::launchMailAppInboxView() |
326 { |
426 { |
327 qDebug()<<"NmHsWidgetEmailEngine::launchMailAppInboxView() -- START"; |
427 qDebug() << "NmHsWidgetEmailEngine::launchMailAppInboxView() -- START"; |
328 |
428 |
329 XQServiceRequest request( |
429 XQServiceRequest request( |
330 emailInterfaceNameMailbox, |
430 emailFullServiceNameMailbox, |
331 emailOperationViewInbox, |
431 emailOperationViewInbox, |
332 false); |
432 false); |
333 |
433 |
334 QList<QVariant> list; |
434 QList<QVariant> list; |
335 list.append(QVariant(mMailboxId.id())); |
435 list.append(QVariant(mMailboxId.id())); |
336 |
436 |
337 request.setArguments(list); |
437 request.setArguments(list); |
338 QVariant returnValue; |
438 request.send(); |
339 bool rval = request.send(returnValue); |
439 |
340 |
440 qDebug() << "NmHsWidgetEmailEngine::launchMailAppInboxView() -- END"; |
341 qDebug()<<"NmHsWidgetEmailEngine::launchMailAppInboxView() -- END"; |
441 } |
342 } |
442 |
343 |
443 /*! |
344 /*! |
444 launchMailAppMailViewer slot. |
345 launchMailAppMailViewer slot. |
445 \param messageId Defines the message opened to viewer |
346 \param messageId Defines the message opened to viewer |
446 \post Mail application is launched and viewing mail specified by |
347 \post Mail application is launched and viewing mail specified by |
|
348 */ |
447 */ |
349 void NmHsWidgetEmailEngine::launchMailAppMailViewer(const NmId &messageId) |
448 void NmHsWidgetEmailEngine::launchMailAppMailViewer(const NmId &messageId) |
350 { |
449 { |
351 qDebug()<<"NmHsWidgetEmailEngine::launchMailAppMailViewer() -- START"; |
450 qDebug() << "NmHsWidgetEmailEngine::launchMailAppMailViewer() -- START"; |
352 |
451 |
353 XQServiceRequest request( |
452 XQServiceRequest request( |
354 emailInterfaceNameMessage, |
453 emailFullServiceNameMessage, |
355 emailOperationViewMessage, |
454 emailOperationViewMessage, |
356 false); |
455 false); |
357 |
456 |
358 QList<QVariant> list; |
457 QList<QVariant> list; |
359 list.append(QVariant(mMailboxId.id())); |
458 list.append(QVariant(mMailboxId.id())); |
360 list.append(QVariant(mFolderId.id())); |
459 list.append(QVariant(mFolderId.id())); |
361 list.append(QVariant(messageId.id())); |
460 list.append(QVariant(messageId.id())); |
362 |
461 |
363 request.setArguments(list); |
462 request.setArguments(list); |
364 QVariant returnValue; |
463 request.send(); |
365 bool rval = request.send(returnValue); |
464 |
366 |
465 qDebug() << "NmHsWidgetEmailEngine::launchMailAppMailViewer() -- END"; |
367 qDebug()<<"NmHsWidgetEmailEngine::launchMailAppMailViewer() -- END"; |
466 } |
368 } |
|