emailuis/nmhswidget/inc/nmhswidgetemailengine.h
branchRCL_3
changeset 24 d189ee25cf9d
equal deleted inserted replaced
23:dcf0eedfc1a3 24:d189ee25cf9d
       
     1 /*
       
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: 
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef NMHSWIDGETEMAILENGINE_H_
       
    19 #define NMHSWIDGETEMAILENGINE_H_
       
    20 
       
    21 #include <QObject>
       
    22 #include "nmcommon.h"
       
    23 
       
    24 class NmMessageEnvelope;
       
    25 class NmDataPluginFactory;
       
    26 class NmDataPluginInterface;
       
    27 class QPluginLoader;
       
    28 class QTimer;
       
    29 class XQAiwRequest;
       
    30 
       
    31 //Three seconds
       
    32 const int NmHsWidgetEmailEngineUpdateTimerValue = 3000;
       
    33 
       
    34 enum NmHsWidgetEmailEngineExceptionCode
       
    35     {
       
    36     NmEngineExcFailure,
       
    37     NmEngineExcAccountDeleted
       
    38     };
       
    39 
       
    40 class NmHsWidgetEmailEngine : public QObject
       
    41     {
       
    42     Q_OBJECT
       
    43     
       
    44 public:
       
    45     NmHsWidgetEmailEngine( const NmId& monitoredMailboxId );
       
    46     bool initialize(); 
       
    47     ~NmHsWidgetEmailEngine();
       
    48 
       
    49     int getEnvelopes(QList<NmMessageEnvelope> &list, int maxEnvelopeAmount);
       
    50     int unreadCount();
       
    51     QString accountName();
       
    52     void deleteAiwRequest();
       
    53         
       
    54 public slots:
       
    55     void handleMessageEvent( 
       
    56             NmMessageEvent event,
       
    57             const NmId &folderId,
       
    58             const QList<NmId> &messageIds,
       
    59             const NmId& mailboxId);
       
    60 
       
    61     void handleMailboxEvent(NmMailboxEvent event, const QList<NmId> &mailboxIds);
       
    62    
       
    63     //Activity control
       
    64     void suspend();
       
    65     void activate();
       
    66     void launchMailAppInboxView();
       
    67     void launchMailAppMailViewer(const NmId &messageId);
       
    68     void handleUpdateTimeout();
       
    69     
       
    70     void aiwRequestOk(const QVariant& result);
       
    71     void aiwRequestError(int errorCode, const QString& errorMessage);
       
    72     
       
    73 signals:
       
    74     void mailDataChanged();    
       
    75     void accountNameChanged(const QString& accountName);
       
    76     void unreadCountChanged(const int& unreadCount);
       
    77     void exceptionOccured(const int& err);
       
    78     
       
    79 private:
       
    80     bool constructNmPlugin();
       
    81     bool updateData(); 
       
    82     bool updateAccount();
       
    83     void resetEnvelopeList();
       
    84     
       
    85 private:
       
    86     NmId mMailboxId;
       
    87     NmId mFolderId;
       
    88     QString mAccountName;
       
    89     int mUnreadCount;
       
    90     QList<NmMessageEnvelope*> mEnvelopeList;
       
    91     NmDataPluginInterface *mEmailInterface;
       
    92     NmDataPluginFactory* mFactory;
       
    93     //suspension variables
       
    94     bool mAccountEventReceivedWhenSuspended;
       
    95     bool mMessageEventReceivedWhenSuspended;
       
    96     bool mSuspended; 
       
    97     QTimer* mUpdateTimer;
       
    98     XQAiwRequest* mAiwRequest;
       
    99     };
       
   100 
       
   101 #endif /* NMHSWIDGETEMAILENGINE_H_ */