qtmobility/src/messaging/winhelpers_p.h
changeset 1 2b40d63a9c3d
child 5 453da2cfceef
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     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 #ifndef QMESSAGEWINHELPERPRIVATE_H
       
    42 #define QMESSAGEWINHELPERPRIVATE_H
       
    43 
       
    44 #include <QHash>
       
    45 #include <QMap>
       
    46 #include <QPair>
       
    47 #include <QSharedPointer>
       
    48 #include <QString>
       
    49 #include <QByteArray>
       
    50 #include <MAPIUtil.h>
       
    51 #include <qmessagemanager.h>
       
    52 #include <QVector>
       
    53 #include <QQueue>
       
    54 #include <QEvent>
       
    55 
       
    56 #ifndef _WIN32_WCE
       
    57 
       
    58 #define USES_IID_IMAPIForm
       
    59 #define USES_IID_IMAPIMessageSite
       
    60 #define USES_IID_IPersistMessage
       
    61 
       
    62 #include <initguid.h>
       
    63 #include <mapiguid.h>
       
    64 #include <mapiform.h>
       
    65 
       
    66 #endif
       
    67 
       
    68 
       
    69 // As per http://support.microsoft.com/kb/816477
       
    70 #ifndef PR_MSG_EDITOR_FORMAT
       
    71 #define PR_MSG_EDITOR_FORMAT PROP_TAG( PT_LONG, 0x5909 )
       
    72 #define EDITOR_FORMAT_DONTKNOW ((ULONG)0)
       
    73 #define EDITOR_FORMAT_PLAINTEXT ((ULONG)1)
       
    74 #define EDITOR_FORMAT_HTML ((ULONG)2)
       
    75 #ifndef _WIN32_WCE
       
    76 #define EDITOR_FORMAT_RTF ((ULONG)3)
       
    77 #else
       
    78 // Not a real definition, but useful for us:
       
    79 #define EDITOR_FORMAT_MIME ((ULONG)3)
       
    80 #endif
       
    81 #endif
       
    82 
       
    83 #ifndef PR_ATTACH_CONTENT_ID
       
    84 // This is not available in my SDK version...
       
    85 #define PR_ATTACH_CONTENT_ID PROP_TAG( PT_UNICODE, 0x3712 )
       
    86 #endif
       
    87 
       
    88 #ifndef PR_BODY_HTML
       
    89 #define PR_BODY_HTML PROP_TAG( PT_TSTRING, 0x1013 )
       
    90 #endif
       
    91 
       
    92 #define mapiRelease(a) if(a){a->Release();a=0;}
       
    93 
       
    94 
       
    95 QTM_BEGIN_NAMESPACE
       
    96 
       
    97 class MapiEntryId : public QByteArray
       
    98 {
       
    99 public:
       
   100     MapiEntryId():QByteArray(){}
       
   101     MapiEntryId(LPENTRYID mapiEntryId, ULONG entryIdLength)
       
   102     :
       
   103     QByteArray(reinterpret_cast<const char*>(mapiEntryId),entryIdLength){}
       
   104 
       
   105     MapiEntryId(LPBYTE mapiEntryId, ULONG entryIdLength)
       
   106     :
       
   107     QByteArray(reinterpret_cast<const char*>(mapiEntryId),entryIdLength){}
       
   108 };
       
   109 
       
   110 class MapiRecordKey : public QByteArray
       
   111 {
       
   112 public:
       
   113     MapiRecordKey():QByteArray(){}
       
   114     MapiRecordKey(LPENTRYID mapiRecordKey, ULONG entryIdLength)
       
   115     :
       
   116     QByteArray(reinterpret_cast<const char*>(mapiRecordKey),entryIdLength){}
       
   117 
       
   118     MapiRecordKey(LPBYTE mapiRecordKey, ULONG entryIdLength)
       
   119     :
       
   120     QByteArray(reinterpret_cast<const char*>(mapiRecordKey),entryIdLength){}
       
   121 };
       
   122 
       
   123 class MapiFolder;
       
   124 class MapiStore;
       
   125 class MapiSession;
       
   126 typedef QSharedPointer<MapiFolder> MapiFolderPtr;
       
   127 typedef QSharedPointer<MapiStore> MapiStorePtr;
       
   128 typedef QSharedPointer<MapiSession> MapiSessionPtr;
       
   129 
       
   130 namespace WinHelpers {
       
   131 
       
   132 enum SavePropertyOption { DontSavePropertyChanges = 0, SavePropertyChanges };
       
   133 
       
   134 QString QStringFromLpctstr(LPCTSTR lpszValue);
       
   135 void LptstrFromQString(const QString &value, LPTSTR *lpsz);
       
   136 
       
   137 typedef QPair<QMessageId, ULONG> AttachmentLocator;
       
   138 QMessageContentContainer fromLocator(const WinHelpers::AttachmentLocator &l);
       
   139 
       
   140 ULONG createNamedProperty(IMAPIProp *object, const QString &name);
       
   141 ULONG getNamedPropertyTag(IMAPIProp *object, const QString &name);
       
   142 
       
   143 bool setNamedProperty(IMAPIProp *object, ULONG tag, const QString &value);
       
   144 QString getNamedProperty(IMAPIProp *object, ULONG tag);
       
   145 
       
   146 QByteArray contentTypeFromExtension(const QString &extension);
       
   147 
       
   148 class Lptstr : public QVector<TCHAR>
       
   149 {
       
   150 public:
       
   151     Lptstr():QVector<TCHAR>(){}
       
   152     Lptstr(int length) : QVector<TCHAR>(length){}
       
   153     operator TCHAR* (){ return QVector<TCHAR>::data(); }
       
   154 };
       
   155 
       
   156 Lptstr LptstrFromQString(const QString &src);
       
   157 
       
   158 class MapiInitializer;
       
   159 
       
   160 typedef QSharedPointer<MapiInitializer> MapiInitializationToken;
       
   161 
       
   162 MapiInitializationToken initializeMapi();
       
   163 
       
   164 class MapiInitializer
       
   165 {
       
   166     friend MapiInitializationToken WinHelpers::initializeMapi();
       
   167 
       
   168 private:
       
   169     MapiInitializer();
       
   170     MapiInitializer &operator=(const MapiInitializer &);
       
   171 
       
   172 public:
       
   173     ~MapiInitializer();
       
   174 
       
   175     bool _initialized;
       
   176 };
       
   177 
       
   178 bool getMapiProperty(IMAPIProp *object, ULONG tag, ULONG *value);
       
   179 bool getMapiProperty(IMAPIProp *object, ULONG tag, LONG *value);
       
   180 bool getMapiProperty(IMAPIProp *object, ULONG tag, QByteArray *value);
       
   181 bool getMapiProperty(IMAPIProp *object, ULONG tag, QString value);
       
   182 
       
   183 bool setMapiProperty(IMAPIProp *object, ULONG tag, const QString &value);
       
   184 bool setMapiProperty(IMAPIProp *object, ULONG tag, LONG value);
       
   185 bool setMapiProperty(IMAPIProp *object, ULONG tag, ULONG value);
       
   186 bool setMapiProperty(IMAPIProp *object, ULONG tag, bool value);
       
   187 bool setMapiProperty(IMAPIProp *object, ULONG tag, FILETIME value);
       
   188 bool setMapiProperty(IMAPIProp *object, ULONG tag, MapiEntryId value);
       
   189 
       
   190 }
       
   191 
       
   192 /* Note on links:
       
   193     - Session must close at exit for correct cleanup
       
   194         Session must be a singleton
       
   195         Stores must have weak ref to session
       
   196     - Stores must remain open after opening to enable notifications
       
   197         Session holds strong ref to stores
       
   198     - Folders should not remain open
       
   199         Store holds weak ref to folders
       
   200         Folder can have strong ref to store
       
   201 
       
   202     * Session keeps stores open
       
   203     * Folders keep store open
       
   204 */
       
   205 
       
   206 class MapiFolder {
       
   207 
       
   208 public:
       
   209     static MapiFolderPtr createFolder(QMessageManager::Error *error, const MapiStorePtr &store, IMAPIFolder *folder, const MapiRecordKey &recordKey, const QString &name, const MapiEntryId &entryId, bool hasSubFolders, uint messageCount);
       
   210 
       
   211     ~MapiFolder();
       
   212 
       
   213     MapiFolderPtr nextSubFolder(QMessageManager::Error *error);
       
   214 
       
   215     LPMAPITABLE queryBegin(QMessageManager::Error *error, const QMessageFilter &filter, const QMessageSortOrder &sortOrder);
       
   216     QMessageIdList queryNext(QMessageManager::Error *error, LPMAPITABLE messagesTable, const QMessageFilter &filter);
       
   217     void queryEnd(LPMAPITABLE messagesTable);
       
   218 
       
   219     uint countMessages(QMessageManager::Error *error, const QMessageFilter &filter = QMessageFilter()) const;
       
   220 
       
   221     void removeMessages(QMessageManager::Error *error, const QMessageIdList &ids);
       
   222 
       
   223     MapiEntryId messageEntryId(QMessageManager::Error *error, const MapiRecordKey &messagekey);
       
   224 
       
   225     QMessageFolderId id() const;
       
   226 
       
   227     QMessageAccountId accountId() const;
       
   228     QMessageFolderId parentId() const;
       
   229     QList<QMessageFolderId> ancestorIds() const;
       
   230 
       
   231     bool isValid() const { return _valid; }
       
   232     IMAPIFolder* folder() const { return _folder; }
       
   233     MapiRecordKey recordKey() const { return _key; }
       
   234     MapiRecordKey storeKey() const;
       
   235 #ifdef _WIN32_WCE
       
   236     MapiEntryId storeEntryId() const;
       
   237 #endif
       
   238     QString name() const { return _name; }
       
   239     MapiEntryId entryId() const { return _entryId; }
       
   240     bool hasSubFolders() const { return _hasSubFolders; }
       
   241     uint messageCount() const { return _messageCount; }
       
   242 
       
   243     IMessage *createMessage(QMessageManager::Error* error);
       
   244     IMessage *createMessage(QMessageManager::Error* error, const QMessage& source, const MapiSessionPtr &session, WinHelpers::SavePropertyOption saveOption = WinHelpers::SavePropertyChanges );
       
   245 
       
   246     IMessage *openMessage(QMessageManager::Error *error, const MapiEntryId &entryId);
       
   247 
       
   248     QMessageFolder folder(QMessageManager::Error *error, const QMessageFolderId& id) const;
       
   249     QMessage message(QMessageManager::Error *error, const QMessageId& id) const;
       
   250 
       
   251     QMessage::StandardFolder standardFolder() const;
       
   252 
       
   253 private:
       
   254     MapiFolder();
       
   255     MapiFolder(const MapiStorePtr &store, IMAPIFolder *folder, const MapiRecordKey &recordKey, const QString &name, const MapiEntryId &entryId, bool hasSubFolders, uint messageCount);
       
   256 
       
   257     void findSubFolders(QMessageManager::Error *error);
       
   258 
       
   259     friend class MapiStore;
       
   260 
       
   261     QWeakPointer<MapiFolder> _self;
       
   262     MapiStorePtr _store;
       
   263     bool _valid;
       
   264     IMAPIFolder* _folder;
       
   265     MapiRecordKey _key;
       
   266     QString _name;
       
   267     MapiEntryId _entryId;
       
   268     bool _hasSubFolders;
       
   269     uint _messageCount;
       
   270     bool _init;
       
   271     QList<MapiEntryId> _subFolders;
       
   272 };
       
   273 
       
   274 class MapiStore {
       
   275 public:
       
   276     static MapiStorePtr createStore(QMessageManager::Error *error, const MapiSessionPtr &session, IMsgStore *store, const MapiRecordKey &key, const MapiEntryId &entryId, const QString &name, bool cachedMode);
       
   277 
       
   278     ~MapiStore();
       
   279 
       
   280     MapiFolderPtr findFolder(QMessageManager::Error *error, QMessage::StandardFolder sf);
       
   281 
       
   282     QMessageFolderIdList folderIds(QMessageManager::Error *error) const;
       
   283     QMessageFolder folderFromId(QMessageManager::Error *error, const QMessageFolderId &folderId);
       
   284 
       
   285     QList<MapiFolderPtr> filterFolders(QMessageManager::Error *error, const QMessageFolderFilter &filter) const;
       
   286 
       
   287     MapiEntryId messageEntryId(QMessageManager::Error *error, const MapiRecordKey &folderKey, const MapiRecordKey &messageKey);
       
   288 
       
   289     MapiFolderPtr openFolder(QMessageManager::Error *error, const MapiEntryId& id) const;
       
   290     MapiFolderPtr openFolderWithKey(QMessageManager::Error *error, const MapiRecordKey& key) const;
       
   291 
       
   292     bool supports(ULONG featureFlag) const;
       
   293 
       
   294     bool isValid() const { return _valid; }
       
   295     QMessageAccountId id() const;
       
   296     MapiEntryId entryId() const { return _entryId; }
       
   297     QString name() const { return _name; }
       
   298     IMsgStore* store() const { return _store; }
       
   299     MapiRecordKey recordKey() const { return _key; }
       
   300     QMessage::TypeFlags types() const;
       
   301     QMessageAddress address() const;
       
   302 
       
   303     MapiSessionPtr session() const;
       
   304 
       
   305     MapiFolderPtr rootFolder(QMessageManager::Error *error) const;
       
   306     MapiFolderPtr receiveFolder(QMessageManager::Error *error) const;
       
   307 
       
   308     IMessage *openMessage(QMessageManager::Error *error, const MapiEntryId &entryId);
       
   309 
       
   310     QMessageFolder folder(QMessageManager::Error *error, const QMessageFolderId& id) const;
       
   311     QMessage message(QMessageManager::Error *error, const QMessageId& id) const;
       
   312 
       
   313     QMessage::StandardFolder standardFolder(const MapiEntryId &entryId) const;
       
   314 
       
   315     void notifyEvents(ULONG mask);
       
   316 
       
   317 #ifdef _WIN32_WCE
       
   318     QString transportName() const;
       
   319 #endif
       
   320 
       
   321 private:
       
   322     MapiStore();
       
   323     MapiStore(const MapiSessionPtr &session, IMsgStore *store, const MapiRecordKey &key, const MapiEntryId &entryId, const QString &name, bool cachedMode);
       
   324 
       
   325     MapiEntryId standardFolderId(QMessageManager::Error *error, QMessage::StandardFolder sf) const;
       
   326     MapiEntryId rootFolderId(QMessageManager::Error *error) const;
       
   327     MapiEntryId receiveFolderId(QMessageManager::Error *error) const;
       
   328 
       
   329     IMAPIFolder *openMapiFolder(QMessageManager::Error *error, const MapiEntryId &entryId) const;
       
   330 
       
   331     bool setAdviseSink(ULONG mask, IMAPIAdviseSink *sink);
       
   332 
       
   333     class AdviseSink : public IMAPIAdviseSink
       
   334     {
       
   335         MapiStore *_store;
       
   336         LONG _refCount;
       
   337 
       
   338     public:
       
   339         AdviseSink(MapiStore *store) : _store(store), _refCount(0) {}
       
   340 
       
   341         STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppvObj);
       
   342         STDMETHOD_(ULONG, AddRef)();
       
   343         STDMETHOD_(ULONG, Release)();
       
   344 
       
   345         STDMETHOD_(ULONG, OnNotify)(ULONG cNotification, LPNOTIFICATION lpNotifications);
       
   346     };
       
   347 
       
   348     QWeakPointer<MapiStore> _self;
       
   349     QWeakPointer<MapiSession> _session;
       
   350     bool _valid;
       
   351     IMsgStore* _store;
       
   352     MapiRecordKey _key;
       
   353     MapiEntryId _entryId;
       
   354     QString _name;
       
   355     bool _cachedMode;
       
   356     ULONG _adviseConnection;
       
   357     QMap<QMessage::StandardFolder, MapiEntryId> _standardFolderId;
       
   358 
       
   359     mutable QHash<MapiEntryId, QWeakPointer<MapiFolder> > _folderMap;
       
   360 };
       
   361 
       
   362 class MapiSession : public QObject
       
   363 {
       
   364     Q_OBJECT
       
   365 
       
   366 public:
       
   367     enum NotifyType { Added = 1, Removed, Updated };
       
   368 
       
   369     class NotifyEvent : public QEvent
       
   370     {
       
   371     public:
       
   372         static QEvent::Type eventType();
       
   373 
       
   374         NotifyEvent(MapiStore *store, const QMessageId &id, MapiSession::NotifyType type);
       
   375 
       
   376         virtual Type type();
       
   377 
       
   378         MapiStore *_store;
       
   379         QMessageId _id;
       
   380         NotifyType _notifyType;
       
   381     };
       
   382 
       
   383     static MapiSessionPtr createSession(QMessageManager::Error *error);
       
   384 
       
   385     ~MapiSession();
       
   386 
       
   387     bool isValid() const { return (_mapiSession != 0); }
       
   388 
       
   389     MapiStorePtr findStore(QMessageManager::Error *error, const QMessageAccountId &id = QMessageAccountId(), bool cachedMode = true) const;
       
   390     MapiStorePtr defaultStore(QMessageManager::Error *error, bool cachedMode = true) const { return findStore(error,QMessageAccountId(),cachedMode); }
       
   391 
       
   392     QList<MapiStorePtr> filterStores(QMessageManager::Error *error, const QMessageAccountFilter &filter, const QMessageAccountSortOrder &sortOrder = QMessageAccountSortOrder(), uint limit = 0, uint offset = 0, bool cachedMode = true) const;
       
   393 
       
   394     QList<MapiStorePtr> allStores(QMessageManager::Error *error, bool cachedMode = true) const;
       
   395 
       
   396     QList<MapiFolderPtr> filterFolders(QMessageManager::Error *error, const QMessageFolderFilter &filter, const QMessageFolderSortOrder &sortOrder = QMessageFolderSortOrder(), uint limit = 0, uint offset = 0, bool cachedMode = true) const;
       
   397 
       
   398     MapiStorePtr openStore(QMessageManager::Error *error, const MapiEntryId& id, bool cachedMode = true) const;
       
   399     MapiStorePtr openStoreWithKey(QMessageManager::Error *error, const MapiRecordKey& key, bool cachedMode = true) const;
       
   400 
       
   401     QMessageAccountId defaultAccountId(QMessageManager::Error *error, QMessage::Type type) const;
       
   402 
       
   403     MapiEntryId messageEntryId(QMessageManager::Error *error, const MapiRecordKey &storeKey, const MapiRecordKey &folderKey, const MapiRecordKey &messageKey);
       
   404 
       
   405     MapiRecordKey messageRecordKey(QMessageManager::Error *error, const QMessageId &id);
       
   406     MapiRecordKey folderRecordKey(QMessageManager::Error *error, const QMessageId &id);
       
   407 
       
   408 #ifdef _WIN32_WCE
       
   409     MapiEntryId folderEntryId(QMessageManager::Error *error, const QMessageId &id);
       
   410 #endif
       
   411 
       
   412     bool equal(const MapiEntryId &lhs, const MapiEntryId &rhs) const;
       
   413 
       
   414     QMessageFolder folder(QMessageManager::Error *error, const QMessageFolderId& id) const;
       
   415     QMessage message(QMessageManager::Error *error, const QMessageId& id) const;
       
   416 
       
   417     bool updateMessageProperties(QMessageManager::Error *error, QMessage *msg) const;
       
   418     bool updateMessageRecipients(QMessageManager::Error *error, QMessage *msg) const;
       
   419     bool updateMessageBody(QMessageManager::Error *error, QMessage *msg) const;
       
   420     bool updateMessageAttachments(QMessageManager::Error *error, QMessage *msg) const;
       
   421 
       
   422     bool haveAttachmentData(QMessageManager::Error* error, const QMessageId& id, ULONG number) const;
       
   423     QByteArray attachmentData(QMessageManager::Error *error, const QMessageId& id, ULONG number) const;
       
   424 
       
   425     QMessageIdList queryMessages(QMessageManager::Error *error, const QMessageFilter &filter, const QMessageSortOrder &sortOrder = QMessageSortOrder(), uint limit = 0, uint offset = 0, const QString &body = QString(), QMessageDataComparator::MatchFlags matchFlags = 0) const;
       
   426 
       
   427     void updateMessage(QMessageManager::Error* error, const QMessage& source);
       
   428 
       
   429     void removeMessages(QMessageManager::Error *error, const QMessageIdList &ids);
       
   430 
       
   431     IMAPISession* session() const { return _mapiSession; }
       
   432 
       
   433     QMessageManager::NotificationFilterId registerNotificationFilter(QMessageManager::Error *error, const QMessageFilter &filter);
       
   434     void unregisterNotificationFilter(QMessageManager::Error *error, QMessageManager::NotificationFilterId filterId);
       
   435 
       
   436     static QMessagePrivate *messageImpl(const QMessage &message);
       
   437     static QMessageContentContainerPrivate *containerImpl(const QMessageContentContainer &);
       
   438 
       
   439     void addToNotifyQueue(const NotifyEvent& e);
       
   440     void flushNotifyQueue();
       
   441 
       
   442 signals:
       
   443     void messageAdded(const QMessageId &id, const QMessageManager::NotificationFilterIdSet &matchingFilterIds);
       
   444     void messageRemoved(const QMessageId &id, const QMessageManager::NotificationFilterIdSet &matchingFilterIds);
       
   445     void messageUpdated(const QMessageId &id, const QMessageManager::NotificationFilterIdSet &matchingFilterIds);
       
   446 
       
   447 public slots:
       
   448     void dispatchNotifications();
       
   449     void processNotifyQueue();
       
   450 
       
   451 private:
       
   452     MapiSession();
       
   453     MapiSession(QMessageManager::Error *error);
       
   454 
       
   455     IMsgStore *openMapiStore(QMessageManager::Error *error, const MapiEntryId &entryId, bool cachedMode = true) const;
       
   456     IMessage *openMapiMessage(QMessageManager::Error *error, const QMessageId &id, MapiStorePtr *storePtr = 0) const;
       
   457 
       
   458     void addRecipients(LPMESSAGE message, const QMessageAddressList& addressList, unsigned long mapiAddressType);
       
   459     void addAttachment(LPMESSAGE message, const QMessageContentContainer& attachmentContainer);
       
   460 
       
   461     bool event(QEvent *e);
       
   462 
       
   463     void notify(MapiStore *store, const QMessageId &id, NotifyType notifyType);
       
   464 
       
   465     template<typename Predicate, typename Ordering>
       
   466     QList<MapiStorePtr> filterStores(QMessageManager::Error *error, Predicate predicate, Ordering sortOrder, uint limit, uint offset, bool cachedMode) const;
       
   467 
       
   468 private:
       
   469     friend class SessionManager;
       
   470 
       
   471     QWeakPointer<MapiSession> _self;
       
   472     WinHelpers::MapiInitializationToken _token;
       
   473     IMAPISession* _mapiSession;
       
   474     QMessageManager::NotificationFilterId _filterId;
       
   475     QMap<QMessageManager::NotificationFilterId, QMessageFilter> _filters;
       
   476     bool _registered;
       
   477     QQueue<NotifyEvent> _notifyEventQueue;
       
   478 
       
   479     mutable QHash<MapiEntryId, MapiStorePtr> _storeMap;
       
   480 };
       
   481 
       
   482 #ifndef _WIN32_WCE
       
   483 
       
   484 class MapiForm : public IMAPIMessageSite
       
   485 {
       
   486 public:
       
   487     MapiForm(IMsgStore* mapiStore,
       
   488              IMAPISession* mapiSession,
       
   489              IMAPIFolder* mapiFolder,
       
   490              IMessage* mapiMessage);
       
   491 
       
   492     virtual ~MapiForm();
       
   493 
       
   494     // IUnknown interface
       
   495     STDMETHODIMP QueryInterface (REFIID riid, void** ppvObj);
       
   496     STDMETHODIMP_(ULONG) AddRef();
       
   497     STDMETHODIMP_(ULONG) Release();
       
   498     STDMETHODIMP GetLastError(HRESULT hResult, ulong flags, LPMAPIERROR FAR * lppMAPIError);
       
   499 
       
   500     // IMAPIMessageSite interface
       
   501     STDMETHODIMP GetSession(IMAPISession* FAR * mapiSession);
       
   502     STDMETHODIMP GetStore(IMsgStore* FAR * mapiStore);
       
   503     STDMETHODIMP GetFolder(IMAPIFolder* FAR * mapiFolder);
       
   504     STDMETHODIMP GetMessage(IMessage* FAR * mapiMessage);
       
   505     STDMETHODIMP GetFormManager(IMAPIFormMgr* FAR * ppFormMgr);
       
   506     STDMETHODIMP NewMessage(ULONG fComposeInFolder,
       
   507                             IMAPIFolder* mapiFolder,
       
   508                             IPersistMessage* pPersistMessage,
       
   509                             IMessage* FAR * mapiMessage,
       
   510                             IMAPIMessageSite* FAR * ppMessageSite,
       
   511                             LPMAPIVIEWCONTEXT FAR * ppViewContext);
       
   512     STDMETHODIMP CopyMessage(IMAPIFolder* pFolderDestination);
       
   513     STDMETHODIMP MoveMessage(IMAPIFolder* pFolderDestination,
       
   514                              LPMAPIVIEWCONTEXT pViewContext,
       
   515                              LPCRECT prcPosRect);
       
   516     STDMETHODIMP DeleteMessage(LPMAPIVIEWCONTEXT pViewContext, LPCRECT prcPosRect);
       
   517     STDMETHODIMP SaveMessage();
       
   518     STDMETHODIMP SubmitMessage(ulong flags);
       
   519     STDMETHODIMP GetSiteStatus(ulong* status);
       
   520 
       
   521     bool show();
       
   522 
       
   523 private:
       
   524     HRESULT setPersistMessage(LPMAPIFORM lpForm, IPersistMessage* mapiPersistMessage);
       
   525     void releasePersistMessage();
       
   526     void releaseAll();
       
   527 
       
   528 private:
       
   529     long m_referenceCount;
       
   530     IMAPIFolder* m_mapiFolder;
       
   531     IMessage* m_mapiMessage;
       
   532     IMsgStore* m_mapiStore;
       
   533     IMAPISession* m_mapiSession;
       
   534     IPersistMessage* m_mapiPersistMessage;
       
   535 };
       
   536 
       
   537 #endif
       
   538 
       
   539 QTM_END_NAMESPACE
       
   540 
       
   541 #endif