author | alwin <alwin> | 2004-01-05 02:01:53 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-01-05 02:01:53 (UTC) |
commit | 2c2b23f3627321126cb329b2a1665795f82a35a5 (patch) (unidiff) | |
tree | 9a88f55a44e049e5a9fab06d5e0094f6ff5e0c23 /noncore/net/mail/libmailwrapper/statusmail.cpp | |
parent | 3d0cb890b496c7b9fd16e300d5456233dbad0077 (diff) | |
download | opie-2c2b23f3627321126cb329b2a1665795f82a35a5.zip opie-2c2b23f3627321126cb329b2a1665795f82a35a5.tar.gz opie-2c2b23f3627321126cb329b2a1665795f82a35a5.tar.bz2 |
ups - forgot to add the files
simple check if inboxes (and only INBOX) implemented.
Diffstat (limited to 'noncore/net/mail/libmailwrapper/statusmail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mail/libmailwrapper/statusmail.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp new file mode 100644 index 0000000..3e1d8d1 --- a/dev/null +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp | |||
@@ -0,0 +1,83 @@ | |||
1 | #include "statusmail.h" | ||
2 | #include "mailtypes.h" | ||
3 | #include "abstractmail.h" | ||
4 | #include <qlist.h> | ||
5 | |||
6 | StatusMail::StatusMail(QList<Account>*list) | ||
7 | { | ||
8 | currentImapStat.message_count=0; | ||
9 | currentImapStat.message_unseen=0; | ||
10 | currentImapStat.message_recent=0; | ||
11 | lastPop3Stat = currentImapStat; | ||
12 | currentPop3Stat = currentImapStat; | ||
13 | connectionList.setAutoDelete(true); | ||
14 | connectionList.clear(); | ||
15 | initAccounts(list); | ||
16 | } | ||
17 | |||
18 | StatusMail::~StatusMail() | ||
19 | { | ||
20 | } | ||
21 | |||
22 | void StatusMail::initAccounts(QList<Account>*accounts) | ||
23 | { | ||
24 | if (!accounts) return; | ||
25 | Account *it; | ||
26 | folderStat currentStat; | ||
27 | AbstractMail * current = 0; | ||
28 | for ( it = accounts->first(); it; it = accounts->next() ) { | ||
29 | if ( it->getType().compare( "IMAP" ) == 0 ) { | ||
30 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); | ||
31 | current = AbstractMail::getWrapper(ima); | ||
32 | connectionList.append(current); | ||
33 | current->statusFolder(currentStat); | ||
34 | currentImapStat.message_count+=currentStat.message_unseen; | ||
35 | currentImapStat.message_count+=currentStat.message_recent; | ||
36 | currentImapStat.message_count+=currentStat.message_count; | ||
37 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | ||
38 | POP3account *pop3 = static_cast<POP3account *>(it); | ||
39 | current = AbstractMail::getWrapper(pop3); | ||
40 | connectionList.append(current); | ||
41 | current->statusFolder(currentStat); | ||
42 | currentPop3Stat.message_count+=currentStat.message_unseen; | ||
43 | currentPop3Stat.message_count+=currentStat.message_recent; | ||
44 | currentPop3Stat.message_count+=currentStat.message_count; | ||
45 | } | ||
46 | current->logout(); | ||
47 | } | ||
48 | lastPop3Stat = currentPop3Stat; | ||
49 | } | ||
50 | |||
51 | void StatusMail::reset_status() | ||
52 | { | ||
53 | lastPop3Stat = currentPop3Stat; | ||
54 | } | ||
55 | |||
56 | void StatusMail::check_current_stat(folderStat&targetStat) | ||
57 | { | ||
58 | AbstractMail*it = 0; | ||
59 | folderStat currentStat; | ||
60 | currentPop3Stat.message_recent = 0; | ||
61 | currentPop3Stat.message_count = 0; | ||
62 | currentPop3Stat.message_unseen = 0; | ||
63 | currentImapStat = currentPop3Stat; | ||
64 | for ( it = connectionList.first(); it; it = connectionList.next() ) { | ||
65 | it->statusFolder(currentStat); | ||
66 | it->logout(); | ||
67 | if (it->getType().lower()=="imap") { | ||
68 | currentImapStat.message_unseen+=currentStat.message_unseen; | ||
69 | currentImapStat.message_recent+=currentStat.message_recent; | ||
70 | currentImapStat.message_count+=currentStat.message_count; | ||
71 | } else if (it->getType().lower()=="pop3") { | ||
72 | currentPop3Stat.message_count+=currentStat.message_count; | ||
73 | } | ||
74 | } | ||
75 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { | ||
76 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; | ||
77 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; | ||
78 | } | ||
79 | targetStat = currentImapStat; | ||
80 | targetStat.message_unseen+=currentPop3Stat.message_unseen; | ||
81 | targetStat.message_recent+=currentPop3Stat.message_recent; | ||
82 | targetStat.message_count+=currentPop3Stat.message_count; | ||
83 | } | ||