|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 #include "qmessagemanager.h" |
|
42 #include "qmessagestore_p.h" |
|
43 #include "qmessage_p.h" |
|
44 #include "qmessageid_p.h" |
|
45 #include "qmessagefolderid_p.h" |
|
46 #include "qmessageaccountid_p.h" |
|
47 #include "qmessageaccount_p.h" |
|
48 #include "qmessagecontentcontainer.h" |
|
49 #include "winhelpers_p.h" |
|
50 #include <QCoreApplication> |
|
51 #include <QMutex> |
|
52 #include <qdebug.h> |
|
53 #include <QThread> |
|
54 |
|
55 QTM_BEGIN_NAMESPACE |
|
56 |
|
57 namespace { |
|
58 |
|
59 class MutexTryLocker |
|
60 { |
|
61 QMutex *_mutex; |
|
62 QString _location; |
|
63 |
|
64 public: |
|
65 MutexTryLocker(QMutex *mutex) |
|
66 : _mutex(0) |
|
67 { |
|
68 if (mutex->tryLock()) { |
|
69 _mutex = mutex; |
|
70 } |
|
71 } |
|
72 |
|
73 ~MutexTryLocker() |
|
74 { |
|
75 if (_mutex) { |
|
76 |
|
77 _mutex->unlock(); |
|
78 |
|
79 QMessageManager::Error le = QMessageManager::NoError; |
|
80 MapiSessionPtr p = MapiSession::createSession(&le); |
|
81 if(le == QMessageManager::NoError) |
|
82 p->flushNotifyQueue(); |
|
83 |
|
84 } |
|
85 } |
|
86 |
|
87 operator bool() const |
|
88 { |
|
89 return (_mutex != 0); |
|
90 } |
|
91 }; |
|
92 |
|
93 } |
|
94 |
|
95 class QMessageStorePrivatePlatform : public QObject |
|
96 { |
|
97 Q_OBJECT |
|
98 |
|
99 public: |
|
100 QMessageStorePrivatePlatform(QMessageStorePrivate *d, QMessageStore *q); |
|
101 ~QMessageStorePrivatePlatform(); |
|
102 |
|
103 QMessageStorePrivate *d_ptr; |
|
104 QMessageStore *q_ptr; |
|
105 QMessageManager::Error error; |
|
106 |
|
107 MapiSessionPtr session; |
|
108 QMutex mutex; |
|
109 |
|
110 private slots: |
|
111 void appDestroyed(); |
|
112 }; |
|
113 |
|
114 QMessageStorePrivatePlatform::QMessageStorePrivatePlatform(QMessageStorePrivate *d, QMessageStore *q) |
|
115 :d_ptr(d), |
|
116 q_ptr(q), |
|
117 error(QMessageManager::NoError), |
|
118 session(MapiSession::createSession(&error)), |
|
119 mutex(QMutex::Recursive) |
|
120 { |
|
121 connect(QCoreApplication::instance(), SIGNAL(destroyed()), this, SLOT(appDestroyed())); |
|
122 |
|
123 if (session && (error == QMessageManager::NoError)) { |
|
124 MapiSession *o(session.data()); |
|
125 connect(o, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)), q, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet))); |
|
126 connect(o, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)), q, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet))); |
|
127 connect(o, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)), q, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet))); |
|
128 } |
|
129 } |
|
130 |
|
131 QMessageStorePrivatePlatform::~QMessageStorePrivatePlatform() |
|
132 { |
|
133 } |
|
134 |
|
135 void QMessageStorePrivatePlatform::appDestroyed() |
|
136 { |
|
137 // We need to terminate our session before main finishes |
|
138 session.clear(); |
|
139 } |
|
140 |
|
141 QMessageStorePrivate::QMessageStorePrivate() |
|
142 :p_ptr(0), |
|
143 q_ptr(0) |
|
144 { |
|
145 } |
|
146 |
|
147 QMessageStorePrivate::~QMessageStorePrivate() |
|
148 { |
|
149 delete p_ptr; |
|
150 } |
|
151 |
|
152 void QMessageStorePrivate::initialize(QMessageStore *store) |
|
153 { |
|
154 q_ptr = store; |
|
155 p_ptr = new QMessageStorePrivatePlatform(this, store); |
|
156 } |
|
157 |
|
158 #ifdef Q_OS_WIN |
|
159 QMutex* QMessageStorePrivate::mutex(QMessageStore* store) |
|
160 { |
|
161 return &(store->d_ptr->p_ptr->mutex); |
|
162 } |
|
163 |
|
164 QMutex* QMessageStorePrivate::mutex(QMessageManager& manager) |
|
165 { |
|
166 return &(manager.store->d_ptr->p_ptr->mutex); |
|
167 } |
|
168 #endif |
|
169 |
|
170 Q_GLOBAL_STATIC(QMessageStorePrivate,data); |
|
171 |
|
172 QMessageStore::QMessageStore(QObject *parent) |
|
173 : QObject(parent), |
|
174 d_ptr(data()) |
|
175 { |
|
176 Q_ASSERT(d_ptr != 0); |
|
177 Q_ASSERT(d_ptr->q_ptr == 0); // QMessageStore should be singleton |
|
178 } |
|
179 |
|
180 QMessageStore::~QMessageStore() |
|
181 { |
|
182 d_ptr = 0; // should be cleaned up by automatically |
|
183 } |
|
184 |
|
185 QMessageStore* QMessageStore::instance() |
|
186 { |
|
187 QMessageStorePrivate *d = data(); |
|
188 Q_ASSERT(d != 0); |
|
189 if (!d->q_ptr) { |
|
190 d->initialize(new QMessageStore()); |
|
191 } |
|
192 return d->q_ptr; |
|
193 } |
|
194 |
|
195 QMessageManager::Error QMessageStore::error() const |
|
196 { |
|
197 return d_ptr->p_ptr->error; |
|
198 } |
|
199 |
|
200 QMessageIdList QMessageStore::queryMessages(const QMessageFilter &filter, const QMessageSortOrder &sortOrder, uint limit, uint offset) const |
|
201 { |
|
202 QMessageIdList result; |
|
203 |
|
204 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
205 |
|
206 if (!locker) { |
|
207 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
208 return result; |
|
209 } |
|
210 |
|
211 if (!d_ptr->p_ptr->session) { |
|
212 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
213 return result; |
|
214 } else { |
|
215 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
216 result = d_ptr->p_ptr->session->queryMessages(&d_ptr->p_ptr->error, filter, sortOrder, limit, offset); |
|
217 } |
|
218 |
|
219 return result; |
|
220 } |
|
221 |
|
222 QMessageIdList QMessageStore::queryMessages(const QMessageFilter &filter, const QString &body, QMessageDataComparator::MatchFlags matchFlags, const QMessageSortOrder &sortOrder, uint limit, uint offset) const |
|
223 { |
|
224 QMessageIdList result; |
|
225 |
|
226 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
227 if (!locker) { |
|
228 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
229 return result; |
|
230 } |
|
231 |
|
232 if (matchFlags & QMessageDataComparator::MatchFullWord) { |
|
233 d_ptr->p_ptr->error = QMessageManager::NotYetImplemented; |
|
234 return result; |
|
235 } |
|
236 |
|
237 if (!d_ptr->p_ptr->session) { |
|
238 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
239 return result; |
|
240 } else { |
|
241 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
242 result = d_ptr->p_ptr->session->queryMessages(&d_ptr->p_ptr->error, filter, sortOrder, limit, offset, body, matchFlags); |
|
243 } |
|
244 |
|
245 return result; |
|
246 } |
|
247 |
|
248 QMessageFolderIdList QMessageStore::queryFolders(const QMessageFolderFilter &filter, const QMessageFolderSortOrder &sortOrder, uint limit, uint offset) const |
|
249 { |
|
250 QMessageFolderIdList result; |
|
251 |
|
252 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
253 if (!locker) { |
|
254 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
255 return result; |
|
256 } |
|
257 |
|
258 if (!d_ptr->p_ptr->session) { |
|
259 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
260 return result; |
|
261 } |
|
262 |
|
263 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
264 foreach (const MapiFolderPtr &folder, d_ptr->p_ptr->session->filterFolders(&d_ptr->p_ptr->error, filter, sortOrder, limit, offset)) { |
|
265 result.append(folder->id()); |
|
266 } |
|
267 |
|
268 return result; |
|
269 } |
|
270 |
|
271 QMessageAccountIdList QMessageStore::queryAccounts(const QMessageAccountFilter &filter, const QMessageAccountSortOrder &sortOrder, uint limit, uint offset) const |
|
272 { |
|
273 QMessageAccountIdList result; |
|
274 |
|
275 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
276 if (!locker) { |
|
277 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
278 return result; |
|
279 } |
|
280 |
|
281 if (!d_ptr->p_ptr->session) { |
|
282 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
283 return result; |
|
284 } |
|
285 |
|
286 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
287 foreach (const MapiStorePtr &store, d_ptr->p_ptr->session->filterStores(&d_ptr->p_ptr->error, filter, sortOrder, limit, offset)) { |
|
288 result.append(store->id()); |
|
289 } |
|
290 |
|
291 return result; |
|
292 } |
|
293 |
|
294 int QMessageStore::countMessages(const QMessageFilter& filter) const |
|
295 { |
|
296 return queryMessages(filter).count(); |
|
297 } |
|
298 |
|
299 int QMessageStore::countFolders(const QMessageFolderFilter& filter) const |
|
300 { |
|
301 return queryFolders(filter).count(); |
|
302 } |
|
303 |
|
304 int QMessageStore::countAccounts(const QMessageAccountFilter& filter) const |
|
305 { |
|
306 return queryAccounts(filter).count(); |
|
307 } |
|
308 |
|
309 bool QMessageStore::removeMessage(const QMessageId& id, QMessageManager::RemovalOption option) |
|
310 { |
|
311 // TODO: implement option |
|
312 Q_UNUSED(option) |
|
313 |
|
314 bool result(false); |
|
315 |
|
316 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
317 if (!locker) { |
|
318 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
319 return result; |
|
320 } |
|
321 |
|
322 if (!d_ptr->p_ptr->session) { |
|
323 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
324 } else { |
|
325 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
326 |
|
327 QMessageIdList ids; |
|
328 ids.append(id); |
|
329 d_ptr->p_ptr->session->removeMessages(&d_ptr->p_ptr->error, ids); |
|
330 |
|
331 result = (d_ptr->p_ptr->error == QMessageManager::NoError); |
|
332 } |
|
333 |
|
334 return result; |
|
335 } |
|
336 |
|
337 bool QMessageStore::removeMessages(const QMessageFilter& filter, QMessageManager::RemovalOption option) |
|
338 { |
|
339 // TODO: implement option |
|
340 Q_UNUSED(option) |
|
341 |
|
342 bool result(false); |
|
343 |
|
344 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
345 if (!locker) { |
|
346 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
347 return result; |
|
348 } |
|
349 |
|
350 if (!d_ptr->p_ptr->session) { |
|
351 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
352 } else { |
|
353 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
354 |
|
355 QMessageIdList ids = queryMessages(filter, QMessageSortOrder(), 0, 0); |
|
356 if (d_ptr->p_ptr->error == QMessageManager::NoError) { |
|
357 d_ptr->p_ptr->session->removeMessages(&d_ptr->p_ptr->error, ids); |
|
358 } |
|
359 |
|
360 result = (d_ptr->p_ptr->error == QMessageManager::NoError); |
|
361 } |
|
362 |
|
363 return result; |
|
364 } |
|
365 |
|
366 bool QMessageStore::addMessage(QMessage *message) |
|
367 { |
|
368 bool result(false); |
|
369 |
|
370 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
371 if (!locker) { |
|
372 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
373 return result; |
|
374 } |
|
375 |
|
376 if (!d_ptr->p_ptr->session) { |
|
377 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
378 return result; |
|
379 } else { |
|
380 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
381 } |
|
382 |
|
383 if (message && !message->id().isValid()) { |
|
384 QMessageManager::Error* lError = &d_ptr->p_ptr->error; |
|
385 |
|
386 MapiStorePtr mapiStore = d_ptr->p_ptr->session->findStore(lError,message->parentAccountId(),false); |
|
387 if (*lError == QMessageManager::NoError && !mapiStore.isNull()) { |
|
388 |
|
389 //check store/message type compatibility |
|
390 if(!(mapiStore->types() & message->type())) |
|
391 { |
|
392 *lError = QMessageManager::ConstraintFailure; |
|
393 return false; |
|
394 } |
|
395 |
|
396 MapiFolderPtr mapiFolder; |
|
397 |
|
398 // Find the parent folder for this message |
|
399 QMessageFolderId folderId(message->parentFolderId()); |
|
400 if (folderId.isValid()) { |
|
401 #ifdef _WIN32_WCE |
|
402 mapiFolder = mapiStore->openFolder(lError,QMessageFolderIdPrivate::entryId(folderId)); |
|
403 #else |
|
404 mapiFolder = mapiStore->openFolderWithKey(lError, QMessageFolderIdPrivate::folderRecordKey(folderId)); |
|
405 #endif |
|
406 } else { |
|
407 mapiFolder = mapiStore->findFolder(lError, message->standardFolder()); |
|
408 } |
|
409 |
|
410 if (*lError == QMessageManager::NoError && !mapiFolder.isNull()) { |
|
411 IMessage* mapiMessage = mapiFolder->createMessage(lError, *message, d_ptr->p_ptr->session); |
|
412 if (*lError == QMessageManager::NoError) { |
|
413 //set the new QMessageId |
|
414 //we can only be guaranteed of an entry id after IMessage->SaveChanges has been called |
|
415 #ifdef _WIN32_WCE |
|
416 SizedSPropTagArray(1, columns) = {1, {PR_ENTRYID}}; |
|
417 #else |
|
418 SizedSPropTagArray(2, columns) = {2, {PR_RECORD_KEY, PR_ENTRYID}}; |
|
419 #endif |
|
420 SPropValue *properties(0); |
|
421 ULONG count; |
|
422 HRESULT rv = mapiMessage->GetProps(reinterpret_cast<LPSPropTagArray>(&columns), 0, &count, &properties); |
|
423 #ifdef _WIN32_WCE |
|
424 if (HR_SUCCEEDED(rv) && (properties[0].ulPropTag == PR_ENTRYID)) { |
|
425 #else |
|
426 if (HR_SUCCEEDED(rv) && (properties[0].ulPropTag == PR_RECORD_KEY) && (properties[1].ulPropTag == PR_ENTRYID)) { |
|
427 #endif |
|
428 #ifdef _WIN32_WCE |
|
429 MapiRecordKey recordKey; |
|
430 MapiEntryId entryId(properties[0].Value.bin.lpb, properties[0].Value.bin.cb); |
|
431 message->d_ptr->_id = QMessageIdPrivate::from(mapiFolder->storeEntryId(), entryId, recordKey, mapiFolder->entryId()); |
|
432 #else |
|
433 MapiRecordKey recordKey(properties[0].Value.bin.lpb, properties[0].Value.bin.cb); |
|
434 MapiEntryId entryId(properties[1].Value.bin.lpb, properties[1].Value.bin.cb); |
|
435 message->d_ptr->_id = QMessageIdPrivate::from(mapiFolder->storeKey(), entryId, recordKey, mapiFolder->recordKey()); |
|
436 #endif |
|
437 message->d_ptr->_modified = false; |
|
438 |
|
439 MAPIFreeBuffer(properties); |
|
440 } else { |
|
441 qWarning() << "Unable to set the new ID in message."; |
|
442 result = false; |
|
443 } |
|
444 |
|
445 mapiMessage->Release(); |
|
446 result = true; |
|
447 } else { |
|
448 qWarning() << "Cannot createMessage"; |
|
449 } |
|
450 } else { |
|
451 qWarning() << "Cannot get MAPI folder from store"; |
|
452 } |
|
453 } else { |
|
454 qWarning() << "Cannot get default store"; |
|
455 } |
|
456 } else { |
|
457 qWarning() << "Valid message ID at addition"; |
|
458 } |
|
459 return result; |
|
460 } |
|
461 |
|
462 bool QMessageStore::updateMessage(QMessage *message) |
|
463 { |
|
464 bool result(false); |
|
465 |
|
466 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
467 if (!locker) { |
|
468 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
469 return result; |
|
470 } |
|
471 |
|
472 if (!d_ptr->p_ptr->session) { |
|
473 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
474 return result; |
|
475 } else { |
|
476 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
477 } |
|
478 |
|
479 //check store/message type compatibility |
|
480 if(MapiStorePtr mapiStore = d_ptr->p_ptr->session->findStore(&d_ptr->p_ptr->error,message->parentAccountId())) |
|
481 { |
|
482 if(!(mapiStore->types() & message->type())) |
|
483 { |
|
484 d_ptr->p_ptr->error = QMessageManager::ConstraintFailure; |
|
485 return false; |
|
486 } |
|
487 } |
|
488 else{ |
|
489 qWarning() << "Unable to retrieve MAPI store for message at update"; |
|
490 return false; |
|
491 } |
|
492 |
|
493 |
|
494 if (message && message->id().isValid()) { |
|
495 QMessageManager::Error* lError = &d_ptr->p_ptr->error; |
|
496 |
|
497 d_ptr->p_ptr->session->updateMessage(lError, *message); |
|
498 if (*lError == QMessageManager::NoError) { |
|
499 result = true; |
|
500 } else { |
|
501 qWarning() << "Cannot updateMessage"; |
|
502 } |
|
503 } else { |
|
504 qWarning() << "Invalid message ID at update"; |
|
505 } |
|
506 |
|
507 return result; |
|
508 } |
|
509 |
|
510 QMessage QMessageStore::message(const QMessageId& id) const |
|
511 { |
|
512 QMessage result; |
|
513 |
|
514 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
515 if (!locker) { |
|
516 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
517 return result; |
|
518 } |
|
519 |
|
520 if (!d_ptr->p_ptr->session) { |
|
521 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
522 return result; |
|
523 } else { |
|
524 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
525 } |
|
526 |
|
527 return d_ptr->p_ptr->session->message(&d_ptr->p_ptr->error, id); |
|
528 } |
|
529 |
|
530 QMessageFolder QMessageStore::folder(const QMessageFolderId& id) const |
|
531 { |
|
532 QMessageFolder result; |
|
533 |
|
534 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
535 if (!locker) { |
|
536 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
537 return result; |
|
538 } |
|
539 |
|
540 if (!d_ptr->p_ptr->session) { |
|
541 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
542 return result; |
|
543 } else { |
|
544 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
545 } |
|
546 |
|
547 return d_ptr->p_ptr->session->folder(&d_ptr->p_ptr->error, id); |
|
548 } |
|
549 |
|
550 QMessageAccount QMessageStore::account(const QMessageAccountId& id) const |
|
551 { |
|
552 QMessageAccount result; |
|
553 |
|
554 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
555 if (!locker) { |
|
556 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
557 return result; |
|
558 } |
|
559 |
|
560 if (!d_ptr->p_ptr->session) { |
|
561 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
562 return result; |
|
563 } else { |
|
564 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
565 } |
|
566 |
|
567 MapiStorePtr mapiStore(d_ptr->p_ptr->session->findStore(&d_ptr->p_ptr->error, id)); |
|
568 if (mapiStore && mapiStore->isValid()) { |
|
569 result = QMessageAccountPrivate::from(mapiStore->id(), mapiStore->name(), mapiStore->address(), mapiStore->types()); |
|
570 } |
|
571 |
|
572 return result; |
|
573 } |
|
574 |
|
575 QMessageManager::NotificationFilterId QMessageStore::registerNotificationFilter(const QMessageFilter &filter) |
|
576 { |
|
577 QMessageManager::NotificationFilterId result(0); |
|
578 |
|
579 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
580 if (!locker) { |
|
581 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
582 return result; |
|
583 } |
|
584 |
|
585 if (!d_ptr->p_ptr->session) { |
|
586 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
587 return result; |
|
588 } else { |
|
589 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
590 } |
|
591 |
|
592 return d_ptr->p_ptr->session->registerNotificationFilter(&d_ptr->p_ptr->error, filter); |
|
593 } |
|
594 |
|
595 void QMessageStore::unregisterNotificationFilter(QMessageManager::NotificationFilterId notificationFilterId) |
|
596 { |
|
597 MutexTryLocker locker(&d_ptr->p_ptr->mutex); |
|
598 if (!locker) { |
|
599 d_ptr->p_ptr->error = QMessageManager::Busy; |
|
600 return; |
|
601 } |
|
602 |
|
603 if (!d_ptr->p_ptr->session) { |
|
604 d_ptr->p_ptr->error = QMessageManager::ContentInaccessible; |
|
605 } else { |
|
606 d_ptr->p_ptr->error = QMessageManager::NoError; |
|
607 d_ptr->p_ptr->session->unregisterNotificationFilter(&d_ptr->p_ptr->error, notificationFilterId); |
|
608 } |
|
609 } |
|
610 |
|
611 #include "qmessagestore_win.moc" |
|
612 |
|
613 QTM_END_NAMESPACE |