emailservices/nmailagent/inc/nmmailagent.h
changeset 18 578830873419
child 20 ecc8def7944a
equal deleted inserted replaced
4:e7aa27f58ae1 18:578830873419
       
     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 NMMAILAGENT_H
       
    19 #define NMMAILAGENT_H
       
    20 
       
    21 #include <nmcommon.h>
       
    22 
       
    23 class NmMailbox;
       
    24 class NmFrameworkAdapter;
       
    25 
       
    26 class NmMailboxInfo 
       
    27 {
       
    28 public:    
       
    29     NmId mId;
       
    30     QString mName;
       
    31     NmSyncState mSyncState;
       
    32     NmConnectState mConnectState;
       
    33     int mUnreadMails;
       
    34     bool mActive;
       
    35     
       
    36     NmMailboxInfo();
       
    37 };
       
    38 
       
    39 class NmMailAgent : public QObject
       
    40 {
       
    41     Q_OBJECT
       
    42 
       
    43 public:
       
    44 
       
    45     NmMailAgent();
       
    46 
       
    47     ~NmMailAgent();
       
    48     
       
    49     bool init();
       
    50 
       
    51 public slots:
       
    52 
       
    53     void handleMailboxEvent(NmMailboxEvent event,
       
    54             const QList<NmId> &mailboxIds);
       
    55 
       
    56     void handleMessageEvent(
       
    57             NmMessageEvent event,
       
    58             const NmId &folderId,
       
    59             const QList<NmId> &messageIds,
       
    60             const NmId& mailboxId);
       
    61 
       
    62     void handleSyncStateEvent(
       
    63             NmSyncState state,
       
    64             const NmId mailboxId);
       
    65 
       
    66     void handleConnectionEvent(NmConnectState state, const NmId mailboxId);
       
    67     
       
    68 private:
       
    69     
       
    70     bool loadAdapter();
       
    71     
       
    72     void initMailboxStatus();
       
    73     
       
    74     int getUnreadCount(const NmId& mailboxId, int maxCount);
       
    75     
       
    76     void updateStatus();
       
    77 
       
    78     bool isMailboxActive(const NmMailboxInfo& mailboxInfo);
       
    79     
       
    80     bool updateIndicator(int mailboxIndex, 
       
    81         bool active,
       
    82         const NmMailboxInfo& mailboxInfo);
       
    83     
       
    84     NmMailboxInfo* getMailboxInfo(const NmId &id);
       
    85     
       
    86     NmMailboxInfo* createMailboxInfo(const NmId &id);
       
    87 
       
    88     NmMailboxInfo* createMailboxInfo(const NmMailbox &mailbox);
       
    89     
       
    90     bool removeMailboxInfo(const NmId &id);
       
    91     
       
    92     bool updateMailboxActivity(const NmId &mailboxId, bool active);
       
    93     
       
    94     static QStringList pluginFolders();
       
    95     
       
    96 private: // data
       
    97     
       
    98     NmFrameworkAdapter *mAdapter; // Owned
       
    99     QList<NmMailboxInfo*> mMailboxes;
       
   100     int mActiveIndicators;
       
   101 };
       
   102 
       
   103 
       
   104 #endif // NMMAILAGENT_H