-rw-r--r-- | noncore/net/mail/libmailwrapper/statusmail.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 9f4c47c..98f6204 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp | |||
@@ -1,81 +1,89 @@ | |||
1 | #include "statusmail.h" | 1 | #include "statusmail.h" |
2 | #include <qlist.h> | 2 | #include <qlist.h> |
3 | 3 | ||
4 | StatusMail::StatusMail(QList<Account>&list) | 4 | StatusMail::StatusMail(QList<Account>&list) |
5 | { | 5 | { |
6 | currentImapStat.message_count=0; | 6 | currentImapStat.message_count=0; |
7 | currentImapStat.message_unseen=0; | 7 | currentImapStat.message_unseen=0; |
8 | currentImapStat.message_recent=0; | 8 | currentImapStat.message_recent=0; |
9 | lastPop3Stat = currentImapStat; | 9 | lastPop3Stat = currentImapStat; |
10 | currentPop3Stat = currentImapStat; | 10 | currentPop3Stat = currentImapStat; |
11 | connectionList.setAutoDelete(true); | 11 | connectionList.setAutoDelete(true); |
12 | connectionList.clear(); | 12 | connectionList.clear(); |
13 | initAccounts(list); | 13 | initAccounts(list); |
14 | } | 14 | } |
15 | 15 | ||
16 | StatusMail::~StatusMail() | 16 | StatusMail::~StatusMail() |
17 | { | 17 | { |
18 | } | 18 | } |
19 | 19 | ||
20 | void StatusMail::initAccounts(QList<Account>&accounts) | 20 | void StatusMail::initAccounts(QList<Account>&accounts) |
21 | { | 21 | { |
22 | 22 | ||
23 | Account *it; | 23 | Account *it; |
24 | folderStat currentStat; | 24 | folderStat currentStat; |
25 | AbstractMail * current = 0; | 25 | AbstractMail * current = 0; |
26 | currentPop3Stat.message_count=0; | ||
27 | currentPop3Stat.message_recent=0; | ||
28 | currentPop3Stat.message_unseen=0; | ||
26 | for ( it = accounts.first(); it; it = accounts.next() ) { | 29 | for ( it = accounts.first(); it; it = accounts.next() ) { |
27 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 30 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
28 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); | 31 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); |
29 | current = AbstractMail::getWrapper(ima); | 32 | current = AbstractMail::getWrapper(ima); |
30 | connectionList.append(current); | 33 | connectionList.append(current); |
31 | current->statusFolder(currentStat); | 34 | current->statusFolder(currentStat); |
32 | currentImapStat.message_count+=currentStat.message_unseen; | 35 | currentImapStat.message_count+=currentStat.message_unseen; |
33 | currentImapStat.message_count+=currentStat.message_recent; | 36 | currentImapStat.message_count+=currentStat.message_recent; |
34 | currentImapStat.message_count+=currentStat.message_count; | 37 | currentImapStat.message_count+=currentStat.message_count; |
35 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 38 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
36 | POP3account *pop3 = static_cast<POP3account *>(it); | 39 | POP3account *pop3 = static_cast<POP3account *>(it); |
37 | current = AbstractMail::getWrapper(pop3); | 40 | current = AbstractMail::getWrapper(pop3); |
38 | connectionList.append(current); | 41 | connectionList.append(current); |
39 | current->statusFolder(currentStat); | 42 | current->statusFolder(currentStat); |
40 | currentPop3Stat.message_count+=currentStat.message_unseen; | 43 | currentPop3Stat.message_count+=currentStat.message_unseen; |
41 | currentPop3Stat.message_count+=currentStat.message_recent; | 44 | currentPop3Stat.message_count+=currentStat.message_recent; |
42 | currentPop3Stat.message_count+=currentStat.message_count; | 45 | currentPop3Stat.message_count+=currentStat.message_count; |
43 | } | 46 | } |
44 | current->logout(); | 47 | current->logout(); |
45 | } | 48 | } |
46 | lastPop3Stat = currentPop3Stat; | 49 | lastPop3Stat = currentPop3Stat; |
47 | } | 50 | } |
48 | 51 | ||
49 | void StatusMail::reset_status() | 52 | void StatusMail::reset_status() |
50 | { | 53 | { |
51 | lastPop3Stat = currentPop3Stat; | 54 | lastPop3Stat = currentPop3Stat; |
52 | } | 55 | } |
53 | 56 | ||
54 | void StatusMail::check_current_stat(folderStat&targetStat) | 57 | void StatusMail::check_current_stat(folderStat&targetStat) |
55 | { | 58 | { |
56 | AbstractMail*it = 0; | 59 | AbstractMail*it = 0; |
57 | folderStat currentStat; | 60 | folderStat currentStat; |
58 | currentPop3Stat.message_recent = 0; | 61 | currentPop3Stat.message_recent = 0; |
59 | currentPop3Stat.message_count = 0; | 62 | currentPop3Stat.message_count = 0; |
60 | currentPop3Stat.message_unseen = 0; | 63 | currentPop3Stat.message_unseen = 0; |
61 | currentImapStat = currentPop3Stat; | 64 | currentImapStat = currentPop3Stat; |
62 | for ( it = connectionList.first(); it; it = connectionList.next() ) { | 65 | for ( it = connectionList.first(); it; it = connectionList.next() ) { |
63 | it->statusFolder(currentStat); | 66 | it->statusFolder(currentStat); |
64 | it->logout(); | 67 | it->logout(); |
65 | if (it->getType().lower()=="imap") { | 68 | if (it->getType().lower()=="imap") { |
66 | currentImapStat.message_unseen+=currentStat.message_unseen; | 69 | currentImapStat.message_unseen+=currentStat.message_unseen; |
67 | currentImapStat.message_recent+=currentStat.message_recent; | 70 | currentImapStat.message_recent+=currentStat.message_recent; |
68 | currentImapStat.message_count+=currentStat.message_count; | 71 | currentImapStat.message_count+=currentStat.message_count; |
69 | } else if (it->getType().lower()=="pop3") { | 72 | } else if (it->getType().lower()=="pop3") { |
70 | currentPop3Stat.message_count+=currentStat.message_count; | 73 | currentPop3Stat.message_count+=currentStat.message_count; |
74 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); | ||
71 | } | 75 | } |
72 | } | 76 | } |
77 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); | ||
73 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { | 78 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { |
74 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; | 79 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; |
75 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; | 80 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; |
81 | } else { | ||
82 | lastPop3Stat.message_count = currentPop3Stat.message_count; | ||
83 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | ||
76 | } | 84 | } |
77 | targetStat = currentImapStat; | 85 | targetStat = currentImapStat; |
78 | targetStat.message_unseen+=currentPop3Stat.message_unseen; | 86 | targetStat.message_unseen+=currentPop3Stat.message_unseen; |
79 | targetStat.message_recent+=currentPop3Stat.message_recent; | 87 | targetStat.message_recent+=currentPop3Stat.message_recent; |
80 | targetStat.message_count+=currentPop3Stat.message_count; | 88 | targetStat.message_count+=currentPop3Stat.message_count; |
81 | } | 89 | } |