email_plat/nmail_client_api/nmapieventnotifier.h
changeset 23 2dc6caa42ec3
parent 18 578830873419
child 68 83cc6bae1de8
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    16  */
    16  */
    17 
    17 
    18 #ifndef NMAPIEVENTNOTIFIER_H
    18 #ifndef NMAPIEVENTNOTIFIER_H
    19 #define NMAPIEVENTNOTIFIER_H
    19 #define NMAPIEVENTNOTIFIER_H
    20 
    20 
    21 #include <QtCore>
    21 #include <nmapimessagetask.h>
    22 #include "nmapimessagetask.h"
    22 #include <nmapidef.h>
    23 #include "nmenginedef.h"
    23 #include <nmapicommon.h>
    24 #include "nmcommon_api.h"
       
    25 
    24 
    26 struct NmApiMessage;
    25 struct NmApiMessage;
    27 
    26 
    28 namespace EmailClientApi
    27 namespace EmailClientApi
    29 {
    28 {
    30 class NmEventNotifierPrivate;
    29 class NmApiEventNotifierPrivate;
    31 
    30 
    32 /*
    31 /*!
    33  * Notifier for mailbox and message events
    32    Notifier for mailbox and message events
    34  * 
    33    
    35  * Example of use:
    34    Example of use:
    36  * NmEventNotifier *notifier = new NmEventNotifier(this);
    35    \code
    37  * notifier->start();
    36    NmApiEventNotifier *notifier = new NmApiEventNotifier(this);
    38  * connect(notifier,SIGNAL(messageEvent(MessageEvent,quint64,quint64,QList<quint64>)),this,
    37    notifier->start();
    39  *                  SLOT(processMessage(MessageEvent,quint64,quint64,QList<quint64>)),Qt::QueuedConnection);
    38    connect(notifier,SIGNAL(messageEvent(MessageEvent,quint64,quint64,QList<quint64>)),this,
    40  * 
    39                     SLOT(processMessage(MessageEvent,quint64,quint64,QList<quint64>)),Qt::QueuedConnection);
    41  * And then when want to end need to do:
    40    \endcode
    42  * notifier->cancel();
    41    And then when want to end need to do:
    43  * delete notifier; // or notifier->deleteLater();
    42    \code
       
    43    notifier->cancel();
       
    44    delete notifier; // or notifier->deleteLater();
       
    45    \endcode
    44  */
    46  */
    45 class NMENGINE_EXPORT NmEventNotifier : public NmMessageTask
    47 class NMAPI_EXPORT NmApiEventNotifier : public NmApiMessageTask
    46 {
    48 {
    47     Q_OBJECT
    49     Q_OBJECT
    48 public:
    50 public:
    49     /*!
    51     /*!
    50      * Constructor
    52        Constructor
    51      */
    53      */
    52     NmEventNotifier(QObject *parent);
    54     NmApiEventNotifier(QObject *parent);
    53 
    55 
    54     /*!
    56     /*!
    55      * Destructor
    57        Destructor
    56      */
    58      */
    57     virtual ~NmEventNotifier();
    59     virtual ~NmApiEventNotifier();
    58 
    60 
    59     /*!
    61     /*!
    60      * Start monitoring email events
    62        Start monitoring email events
    61      * 
    63        
    62      * Return value tells about monitoring system running
    64        Return value informs if monitoring system is up
    63      */
    65      */
    64     virtual bool start();
    66     virtual bool start();
    65 
    67 
    66     /*!
    68     /*!
    67      * Cancels monitoring.
    69        Cancels monitoring.
    68      * 
    70        
    69      * In user responsibility is to cancel monitoring.
    71        In user responsibility is to cancel monitoring.
    70      * On end it clear buffer events and emits \sa NmMessageTask::canceled() signal.
    72        On end it clear buffer events and emits \sa NmApiMessageTask::canceled() signal.
    71      */
    73      */
    72     virtual void cancel();
    74     virtual void cancel();
    73 
    75 
    74     /*!
    76     /*!
    75      * It check if if event notifier is running.
    77        Checks if event notifier is running.
    76      */
    78      */
    77     bool isRunning() const;
    79     bool isRunning() const;
    78 
    80 
    79     signals:
    81     signals:
    80     /*!
    82     /*!
    81      * This signal is emited when buffer of maiblox events is ready to send. Buffer is list of mailbox events with id.
    83        This signal is emited when buffer of mailbox events is ready to send. Buffer is list of mailbox events with id.
    82      * 
    84        
    83      * 
    85        
    84      * It emits signals grouped by events. So there will be as much signals as much there are events.
    86        It emits signals grouped by events. So there will be as much signals as much there are events.
    85      * For safety when connect it need to use \sa Qt::QueuedConnection.
    87        For safety when connect it need to use \sa Qt::QueuedConnection.
    86      * After that use \sa EmailClientApi::NmEmailService::getMailbox to get object.
    88        After that use \sa EmailClientApi::NmEmailService::getMailbox to get object.
    87      * \arg Event of mailbox
    89        \param event Event of mailbox
    88      * \arg List of mailbox ids where event occur.
    90        \param id List of mailbox ids where event occur.
    89      */
    91      */
    90     void mailboxEvent(MailboxEvent event,QList<quint64> id);
    92     void mailboxEvent(EmailClientApi::NmApiMailboxEvent event, QList<quint64> id);
    91 
    93 
    92     /*!
    94     /*!
    93      * This signal is emited when buffer of messages events is ready to send. Buffer is list of messages events with id.
    95        This signal is emited when buffer of messages events is ready to send. Buffer is list of messages events with id.
    94      *
    96      *
    95      * It emits signals grouped by events, mailbox and folder. So there will be as much signals as much there are events.
    97        It emits signals grouped by events, mailbox and folder. So there will be as much signals as much there are events.
    96      * For safety when connect it need to use \sa Qt::QueuedConnection.
    98        For safety when connect it need to use \sa Qt::QueuedConnection.
    97      * After that use \sa EmailClientApi::NmEmailService::getEnvelope to get object.
    99        After that use \sa EmailClientApi::NmApiEmailService::getEnvelope to get object.
    98      * 
   100        
    99      * \arg Event of messages
   101        \param event Event of messages
   100      * \arg Message mailbox
   102        \param mailboxId Message mailbox
   101      * \arg Message folder
   103        \param folderId Message folder
   102      * \arg List of messages ids where event occur
   104        \param envelopeIdList List of messages ids where event occur
   103      */
   105      */
   104     void messageEvent(MessageEvent event,quint64 mailboxId,quint64 folderId,QList<quint64> envelopeIdList);
   106     void messageEvent(EmailClientApi::NmApiMessageEvent event, quint64 mailboxId, quint64 folderId, QList<quint64> envelopeIdList);
   105 
   107 
   106 public slots:
   108 public slots:
   107     /*!
   109     /*!
   108      * It check each object in buffer and emit signal with it.
   110        It check each object in buffer and emit signal with it.
   109      * 
   111        
   110      * After end of work of this function buffer is empty.
   112        After end of work of this function buffer is empty.
   111      * It is called by timeout signal from timer.
   113        It is called by timeout signal from timer.
   112      */
   114      */
   113     void sendEventsFromBuffer();
   115     void sendEventsFromBuffer();
   114 
   116 
   115 private:
   117 private:
   116     NmEventNotifierPrivate *mNmEventNotifierPrivate;
   118     NmApiEventNotifierPrivate *mNmApiEventNotifierPrivate;
   117 };
   119 };
   118 
   120 
   119 }
   121 }
   120 
   122 
   121 Q_DECLARE_METATYPE(QList<quint64>)
   123 Q_DECLARE_METATYPE(QList<quint64>)