19 #define NMMAILAGENT_H |
19 #define NMMAILAGENT_H |
20 |
20 |
21 #include <nmcommon.h> |
21 #include <nmcommon.h> |
22 |
22 |
23 class NmMailbox; |
23 class NmMailbox; |
24 class NmFrameworkAdapter; |
24 class NmDataPluginFactory; |
|
25 class NmDataPluginInterface; |
25 |
26 |
26 class NmMailboxInfo |
27 class NmMailboxInfo |
27 { |
28 { |
28 public: |
29 public: |
29 NmId mId; |
30 NmId mId; |
|
31 int mIndicatorIndex; |
30 QString mName; |
32 QString mName; |
|
33 NmId mInboxFolderId; |
|
34 NmId mOutboxFolderId; |
31 NmSyncState mSyncState; |
35 NmSyncState mSyncState; |
32 NmConnectState mConnectState; |
36 NmConnectState mConnectState; |
|
37 int mInboxCreatedMessages; |
|
38 int mInboxChangedMessages; |
|
39 int mInboxDeletedMessages; |
33 int mUnreadMails; |
40 int mUnreadMails; |
|
41 int mOutboxMails; |
34 bool mActive; |
42 bool mActive; |
35 |
43 |
36 NmMailboxInfo(); |
44 NmMailboxInfo(); |
37 }; |
45 }; |
38 |
46 |
39 class NmMailAgent : public QObject |
47 class NmMailAgent : public QObject |
40 { |
48 { |
59 const QList<NmId> &messageIds, |
67 const QList<NmId> &messageIds, |
60 const NmId& mailboxId); |
68 const NmId& mailboxId); |
61 |
69 |
62 void handleSyncStateEvent( |
70 void handleSyncStateEvent( |
63 NmSyncState state, |
71 NmSyncState state, |
64 const NmId mailboxId); |
72 const NmOperationCompletionEvent &event); |
65 |
73 |
66 void handleConnectionEvent(NmConnectState state, const NmId mailboxId); |
74 void handleConnectionEvent(NmConnectState state, const NmId mailboxId); |
67 |
75 |
|
76 void delayedStart(); |
|
77 |
68 private: |
78 private: |
69 |
79 |
70 bool loadAdapter(); |
|
71 |
|
72 void initMailboxStatus(); |
80 void initMailboxStatus(); |
73 |
81 |
74 int getUnreadCount(const NmId& mailboxId, int maxCount); |
82 int getUnreadCount(const NmId& mailboxId, int maxCount); |
75 |
83 |
76 void updateStatus(); |
84 int getOutboxCount(const NmId& mailboxId); |
|
85 |
|
86 int getIndicatorIndex(); |
77 |
87 |
78 bool isMailboxActive(const NmMailboxInfo& mailboxInfo); |
88 bool isMailboxActive(const NmMailboxInfo& mailboxInfo); |
79 |
89 |
80 bool updateIndicator(int mailboxIndex, |
90 bool updateIndicator(bool active, |
81 bool active, |
|
82 const NmMailboxInfo& mailboxInfo); |
91 const NmMailboxInfo& mailboxInfo); |
83 |
92 |
84 NmMailboxInfo* getMailboxInfo(const NmId &id); |
93 NmMailboxInfo* getMailboxInfo(const NmId &id); |
85 |
94 |
86 NmMailboxInfo* createMailboxInfo(const NmId &id); |
95 NmMailboxInfo* createMailboxInfo(const NmId &id); |
87 |
96 |
88 NmMailboxInfo* createMailboxInfo(const NmMailbox &mailbox); |
97 NmMailboxInfo* createMailboxInfo(const NmMailbox &mailbox, |
89 |
98 NmDataPluginInterface *plugin); |
|
99 |
90 bool removeMailboxInfo(const NmId &id); |
100 bool removeMailboxInfo(const NmId &id); |
91 |
101 |
92 bool updateMailboxActivity(const NmId &mailboxId, bool active); |
102 bool updateMailboxState(const NmId &mailboxId, |
93 |
103 bool active, bool refreshAlways); |
|
104 |
94 static QStringList pluginFolders(); |
105 static QStringList pluginFolders(); |
95 |
106 |
96 private: // data |
107 private: // data |
97 |
108 |
98 NmFrameworkAdapter *mAdapter; // Owned |
109 NmDataPluginFactory *mPluginFactory; |
99 QList<NmMailboxInfo*> mMailboxes; |
110 QList<NmMailboxInfo*> mMailboxes; |
100 int mActiveIndicators; |
111 bool mSendingState; |
101 }; |
112 }; |
102 |
113 |
103 |
114 |
104 #endif // NMMAILAGENT_H |
115 #endif // NMMAILAGENT_H |