Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QMessageManager Class Reference

The QMessageManager class represents the main interface for storage and retrieval of messages, folders and accounts in the system message store. More...

 #include <QMessageManager>

Inherits QObject.

Public Types

enum Error { NoError, InvalidId, ConstraintFailure, ContentInaccessible, ..., RequestIncomplete }
typedef NotificationFilterId
typedef NotificationFilterIdSet
enum RemovalOption { RemoveLocalCopyOnly, RemoveOnOriginatingServer }

Public Functions

QMessageManager ( QObject * parent = 0 )
~QMessageManager ()
QMessageAccount account ( const QMessageAccountId & id ) const
bool addMessage ( QMessage * message )
int countAccounts ( const QMessageAccountFilter & filter = QMessageAccountFilter() ) const
int countFolders ( const QMessageFolderFilter & filter = QMessageFolderFilter() ) const
int countMessages ( const QMessageFilter & filter = QMessageFilter() ) const
QMessageManager::Error error () const
QMessageFolder folder ( const QMessageFolderId & id ) const
QMessage message ( const QMessageId & id ) const
QMessageAccountIdList queryAccounts ( const QMessageAccountFilter & filter = QMessageAccountFilter(), const QMessageAccountSortOrder & sortOrder = QMessageAccountSortOrder(), uint limit = 0, uint offset = 0 ) const
QMessageAccountIdList queryAccounts ( const QMessageAccountFilter & filter, const QList<QMessageAccountSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const
QMessageFolderIdList queryFolders ( const QMessageFolderFilter & filter = QMessageFolderFilter(), const QMessageFolderSortOrder & sortOrder = QMessageFolderSortOrder(), uint limit = 0, uint offset = 0 ) const
QMessageFolderIdList queryFolders ( const QMessageFolderFilter & filter, const QList<QMessageFolderSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const
QMessageIdList queryMessages ( const QMessageFilter & filter = QMessageFilter(), const QMessageSortOrder & sortOrder = QMessageSortOrder(), uint limit = 0, uint offset = 0 ) const
QMessageIdList queryMessages ( const QMessageFilter & filter, const QList<QMessageSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const
QMessageIdList queryMessages ( const QMessageFilter & filter, const QString & body, QMessageDataComparator::MatchFlags matchFlags = 0, const QMessageSortOrder & sortOrder = QMessageSortOrder(), uint limit = 0, uint offset = 0 ) const
QMessageIdList queryMessages ( const QMessageFilter & filter, const QString & body, QMessageDataComparator::MatchFlags matchFlags, const QList<QMessageSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const
NotificationFilterId registerNotificationFilter ( const QMessageFilter & filter )
bool removeMessage ( const QMessageId & id, RemovalOption option = RemoveOnOriginatingServer )
bool removeMessages ( const QMessageFilter & filter, RemovalOption option = RemoveOnOriginatingServer )
void unregisterNotificationFilter ( NotificationFilterId notificationFilterId )
bool updateMessage ( QMessage * message )
  • 29 public functions inherited from QObject

Signals

void messageAdded ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds )
void messageRemoved ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds )
void messageUpdated ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QMessageManager class represents the main interface for storage and retrieval of messages, folders and accounts in the system message store.

The system contains a single store for messages, which is accessed via the handle class QMessageManager. QMessageManager provides the interface for adding, updating and deleting messages in the system's message store.

QMessageManager provides the countFolders() and queryFolders() functions for counting and listing the folders contained by the messaging store, and the countAccounts() and queryAccounts() functions for counting and listing the accounts contained by the store. These functions use the QMessageFolderFilter and QMessageFolderSortOrder classes, and the QMessageAccountFilter and QMessageAccountSortOrder classes to constrain their searches.

QMessageManager also implements functionality allowing the messages contained by the store to be counted or listed, using various filtering and sortOrder constraints. Clients can access this functionality via the countMessages and queryMessages functions of the QMessageService class.

With the exception of Windows mobile and desktop platforms, QMessageManager functions should not initiate network activity. Instead functions are restricted to operating on data already on the device. See QMessageService for functions related to initiating network activity.

If a QMessageManager operation fails, the error() function will return an error code value indicating the failure mode encountered. A successful operation will set the error() result to QMessageManager::NoError.

Messages in the messaging store are identified by QMessageId objects. The data associated with a message is retrieved in the form of a QMessage object using message(). Likewise a folder is retrieved in the form of a QMessageFolder object using folder(), and an account is retrieved in the form of a QMessageAccount object using account().

Messages can be inserted into the store using the addMessage() function, messages in the store can be manipulated via the updateMessage() function, and removed by the removeMessage() functions.

Messaging store manipulations involving messages are reported via the messagesAdded(), messagesUpdated() and messagesRemoved() signals.

See also QMessage, QMessageId, QMessageContentContainerId, and QMessageService.

Member Type Documentation

enum QMessageManager::Error

Defines the result of attempting to perform a messaging store operation.

ConstantValueDescription
QMessageManager::NoError0The operation was successfully performed.
QMessageManager::InvalidId1The operation failed due to the specification of an invalid identifier.
QMessageManager::ConstraintFailure2The operation failed due to a constraint violation.
QMessageManager::ContentInaccessible3The operation failed because the content data cannot be accessed by the messaging store.
QMessageManager::NotYetImplemented4The operation failed because the messaging store does not yet implement the operation.
QMessageManager::FrameworkFault5The operation failed because the messaging store encountered an error in performing the operation.
QMessageManager::WorkingMemoryOverflow6The operation failed because the messaging store exhausted all memory available for evaluating queries.
QMessageManager::Busy7The operation failed because the messaging store is being used by another thread.
QMessageManager::RequestIncomplete8The operation failed to report successful completion, although no specific error was reported.

typedef QMessageManager::NotificationFilterId

This type contains a value identifying a registered message filter.

typedef QMessageManager::NotificationFilterIdSet

This type contains a set of values identifying registered message filters.

enum QMessageManager::RemovalOption

Defines whether or not a message will be removed from the originating server.

ConstantValueDescription
QMessageManager::RemoveLocalCopyOnly1Do not remove the message from the originating server.
QMessageManager::RemoveOnOriginatingServer2Remove the message both from the local store and from the originating server if any.

Member Function Documentation

QMessageManager::QMessageManager ( QObject * parent = 0 )

Constructs a handle to the message store.

If parent is not 0 then the handle will be deleted when parent is deleted.

QMessageManager::~QMessageManager ()

Destroys the handle to the message store.

QMessageAccount QMessageManager::account ( const QMessageAccountId & id ) const

Returns the QMessageAccount identified by id from the store.

bool QMessageManager::addMessage ( QMessage * message )

Adds a copy of the message indicated by message to the messaging store and modifies the message indicated by message to contain the identifier of the created message.

Returns true if the operation successfully updates the store; otherwise returns false.

To ensure the change is propagated to any affected external server QMessageService::exportUpdates() should be subsequently called.

On the Maemo 5 (Fremantle) platform for SMS type messages this function is not yet supported.

Using this function to explicitly set a size or date is not currently supported on some platforms.

See also message(), updateMessage(), removeMessage(), and QMessageService::exportUpdates().

int QMessageManager::countAccounts ( const QMessageAccountFilter & filter = QMessageAccountFilter() ) const

Returns the number of messages which match the filtering criteria defined in QMessageAccountFilter filter. If filter is empty the count of all available accounts is returned.

See also error() and queryAccounts().

int QMessageManager::countFolders ( const QMessageFolderFilter & filter = QMessageFolderFilter() ) const

Returns the number of folders which match the filtering criteria defined in QMessageFolderFilter filter. If filter is empty the count of all available folders is returned.

See also error() and queryFolders().

int QMessageManager::countMessages ( const QMessageFilter & filter = QMessageFilter() ) const

Returns the number of messages which match the filtering criteria defined in QMessageFilter filter. If filter is empty the count of all available messages is returned.

The performance of counting messages is currently significantly less than optimal for some filters on some platforms.

See also error() and queryMessages().

QMessageManager::Error QMessageManager::error () const

Returns the code of the last error condition reported by the messaging store.

QMessageFolder QMessageManager::folder ( const QMessageFolderId & id ) const

Returns the QMessageFolder identified by id from the store.

QMessage QMessageManager::message ( const QMessageId & id ) const

Returns the QMessage identified by id from the store.

void QMessageManager::messageAdded ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds ) [signal]

Signal that is emitted when the message identified by id is added to the message store. matchingFilterIds contains a set of values identifiying registered notification filters that matched the message.

See also messageRemoved(), messageUpdated(), and registerNotificationFilter().

void QMessageManager::messageRemoved ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds ) [signal]

Signal that is emitted when the message identified by id is removed from the message store. matchingFilterIds contains a set of values identifiying registered notification filters that matched the message.

Since the filters apply to the state of the data after the message removal, the only data item that may be subject to filtration is the identifier of the removed message.

See also messageAdded(), messageUpdated(), and registerNotificationFilter().

void QMessageManager::messageUpdated ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds ) [signal]

Signal that is emitted when the message identified by id is updated in the message store. matchingFilterIds contains a set of values identifiying registered notification filters that matched the message.

Since the filters apply to the state of the data after the message modification, updates to messages which matched a given filter prior to modification but not afterwards will not result in the emission of the messageUpdated signal.

See also messageAdded(), messageRemoved(), and registerNotificationFilter().

QMessageAccountIdList QMessageManager::queryAccounts ( const QMessageAccountFilter & filter = QMessageAccountFilter(), const QMessageAccountSortOrder & sortOrder = QMessageAccountSortOrder(), uint limit = 0, uint offset = 0 ) const

Returns the QMessageAccountIds of accounts in the messaging store. If filter is not empty only accounts matching the parameters set by filter will be returned, otherwise identifiers for all accounts will be returned. If sortOrder is not empty, then the identifiers will be sorted by the parameters set by sortOrder. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned.

See also error() and countAccounts().

QMessageAccountIdList QMessageManager::queryAccounts ( const QMessageAccountFilter & filter, const QList<QMessageAccountSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const

Returns the QMessageAccountIds of accounts in the messaging store. If filter is not empty only accounts matching the parameters set by filter will be returned, otherwise identifiers for all accounts will be returned. If sortOrders is not empty, then the identifiers will be sorted by applying each sort order element in sequence. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned.

See also error() and countAccounts().

QMessageFolderIdList QMessageManager::queryFolders ( const QMessageFolderFilter & filter = QMessageFolderFilter(), const QMessageFolderSortOrder & sortOrder = QMessageFolderSortOrder(), uint limit = 0, uint offset = 0 ) const

Returns the QMessageFolderIds of folders in the messaging store. If filter is not empty only folders matching the parameters set by filter will be returned, otherwise identifiers for all folders will be returned. If sortOrder is not empty, then the identifiers will be sorted by the parameters set by sortOrder. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned.

See also error() and countFolders().

QMessageFolderIdList QMessageManager::queryFolders ( const QMessageFolderFilter & filter, const QList<QMessageFolderSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const

Returns the QMessageFolderIds of folders in the messaging store. If filter is not empty only folders matching the parameters set by filter will be returned, otherwise identifiers for all folders will be returned. If sortOrders is not empty, then the identifiers will be sorted by applying each sort order element in sequence. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned.

See also error() and countFolders().

QMessageIdList QMessageManager::queryMessages ( const QMessageFilter & filter = QMessageFilter(), const QMessageSortOrder & sortOrder = QMessageSortOrder(), uint limit = 0, uint offset = 0 ) const

Returns the QMessageIds of messages in the messaging store. If filter is not empty only messages matching the parameters set by filter will be returned, otherwise identifiers for all messages will be returned. If sortOrder is not empty, then the identifiers will be sorted by the parameters set by sortOrder. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned.

The performance of querying messages is currently significantly less than optimal for some querying criteria on some platforms.

See also error() and countMessages().

QMessageIdList QMessageManager::queryMessages ( const QMessageFilter & filter, const QList<QMessageSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const

Returns the QMessageIds of messages in the messaging store. If filter is not empty only messages matching the parameters set by filter will be returned, otherwise identifiers for all messages will be returned. If sortOrders is not empty, then the identifiers will be sorted by applying each sort order element in sequence. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned.

The performance of querying messages is currently significantly less than optimal for some querying criteria on some platforms.

See also error() and countMessages().

QMessageIdList QMessageManager::queryMessages ( const QMessageFilter & filter, const QString & body, QMessageDataComparator::MatchFlags matchFlags = 0, const QMessageSortOrder & sortOrder = QMessageSortOrder(), uint limit = 0, uint offset = 0 ) const

Returns the QMessageIds of messages in the messaging store. If filter is not empty only messages matching the parameters set by filter and with a body containing the string body will be returned, otherwise identifiers for all messages with a body containing body will be returned. If sortOrder is not empty, then the identifiers will be sorted by the parameters set by sortOrder. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned. matchFlags specifies the matching method to use.

The performance of querying messages is currently significantly less than optimal for some querying criteria on some platforms.

See also error() and countMessages().

QMessageIdList QMessageManager::queryMessages ( const QMessageFilter & filter, const QString & body, QMessageDataComparator::MatchFlags matchFlags, const QList<QMessageSortOrder> & sortOrders, uint limit = 0, uint offset = 0 ) const

Returns the QMessageIds of messages in the messaging store. If filter is not empty only messages matching the parameters set by filter and with a body containing the string body will be returned, otherwise identifiers for all messages with a body containing body will be returned. If sortOrders is not empty, then the identifiers will be sorted by applying each sort order element in sequence. If limit is not zero, then limit places an upper bound on the number of ids in the list returned. offset specifies how many ids to skip at the beginning of the list returned. matchFlags specifies the matching method to use.

The performance of querying messages is currently significantly less than optimal for some querying criteria on some platforms.

See also error() and countMessages().

NotificationFilterId QMessageManager::registerNotificationFilter ( const QMessageFilter & filter )

Registers a message filter that will be used to generate messageAdded(), messageRemoved() and messageUpdated() signals. Returns an identifier value that can be used to identify the reason that a signal was emitted, and to unregister the filter at a later time.

The filter is applied to the state of the data after the occurrence of the event for which a notification may be emitted.

See also unregisterNotificationFilter(), messageAdded(), messageRemoved(), and messageUpdated().

bool QMessageManager::removeMessage ( const QMessageId & id, RemovalOption option = RemoveOnOriginatingServer )

Removes the message with QMessageId id from the messaging store. If option is QMessageManager::RemoveOnOriginatingServer then when synchronization is performed the message should be removed from both the local message store and the originating server if any.

Returns true if the operation successfully updates the store; otherwise returns false.

To ensure the change is propagated to any affected external server QMessageService::exportUpdates() should be subsequently called.

option is ignored on Windows mobile and desktop platforms.

See also removeMessages(), addMessage(), updateMessage(), and QMessageService::exportUpdates().

bool QMessageManager::removeMessages ( const QMessageFilter & filter, RemovalOption option = RemoveOnOriginatingServer )

Removes all messages identified by the filter filter from the messaging store. If option is QMessageManager::RemoveOnOriginatingServer then when synchronization is performed the messages should be removed from both the local message store and the originating server if any.

Returns true if the operation successfully updates the store; otherwise returns false.

To ensure the change is propagated to any affected external server QMessageService::exportUpdates() should be subsequently called.

option is ignored on Windows mobile and desktop platforms.

For example:

To implement a function to remove a list messages identified by QMessageIds from the messaging store.

 bool removeMessages(const QMessageIdList& ids)
 {
     QMessageFilter idsFilter(ids);
     return QMessageManager().removeMessages(idsFilter);
 }

See also removeMessage(), addMessage(), updateMessage(), and QMessageService::exportUpdates().

void QMessageManager::unregisterNotificationFilter ( NotificationFilterId notificationFilterId )

Removes the message filter associated with notificationFilterId from the set used to generate message event signals.

See also registerNotificationFilter(), messageAdded(), messageRemoved(), and messageUpdated().

bool QMessageManager::updateMessage ( QMessage * message )

Updates the messaging store so that the message whose identifier is contained by the message at message contains the content at message. If message does not contain a valid identifier, no changes will result. Internal data of the QMessage object at message can be modified by this operation.

Returns true if the operation successfully updates the store; otherwise returns false.

To ensure the change is propagated to any affected external server QMessageService::exportUpdates() should be subsequently called.

Using this function to explicitly set a size or date is not currently supported on some platforms.

On the Maemo 5 (Fremantle) platform this function may only be used to update the priority and status of email type messages.

See also addMessage(), removeMessage(), and QMessageService::exportUpdates().

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 44
  2. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le Qt Quarterly au hasard

Logo

XQuery et la météo

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtmobility-1.1
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web