-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.cpp | 9 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/mailtypes.h | 1 | ||||
-rw-r--r-- | noncore/net/mail/libmailwrapper/statusmail.cpp | 8 | ||||
-rw-r--r-- | noncore/net/mail/taskbarapplet/mailapplet.cpp | 2 |
4 files changed, 16 insertions, 4 deletions
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp index d8a36e7..bf91c63 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.cpp +++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp | |||
@@ -304,32 +304,41 @@ void encodedString::copy_old(const encodedString&old) | |||
304 | clean(); | 304 | clean(); |
305 | if (old.size>0 && old.content) { | 305 | if (old.size>0 && old.content) { |
306 | content = (char*)malloc(old.size*sizeof(char)); | 306 | content = (char*)malloc(old.size*sizeof(char)); |
307 | memcpy(content,old.content,size); | 307 | memcpy(content,old.content,size); |
308 | size = old.size; | 308 | size = old.size; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | const char*encodedString::Content()const | 312 | const char*encodedString::Content()const |
313 | { | 313 | { |
314 | return content; | 314 | return content; |
315 | } | 315 | } |
316 | 316 | ||
317 | const int encodedString::Length()const | 317 | const int encodedString::Length()const |
318 | { | 318 | { |
319 | return size; | 319 | return size; |
320 | } | 320 | } |
321 | 321 | ||
322 | void encodedString::setContent(const char*nContent,int nSize) | 322 | void encodedString::setContent(const char*nContent,int nSize) |
323 | { | 323 | { |
324 | if (nSize>0 && nContent) { | 324 | if (nSize>0 && nContent) { |
325 | content = (char*)malloc(nSize*sizeof(char)); | 325 | content = (char*)malloc(nSize*sizeof(char)); |
326 | memcpy(content,nContent,nSize); | 326 | memcpy(content,nContent,nSize); |
327 | size = nSize; | 327 | size = nSize; |
328 | } | 328 | } |
329 | } | 329 | } |
330 | 330 | ||
331 | void encodedString::setContent(char*nContent,int nSize) | 331 | void encodedString::setContent(char*nContent,int nSize) |
332 | { | 332 | { |
333 | content = nContent; | 333 | content = nContent; |
334 | size = nSize; | 334 | size = nSize; |
335 | } | 335 | } |
336 | |||
337 | folderStat&folderStat::operator=(const folderStat&old) | ||
338 | { | ||
339 | message_count = old.message_count; | ||
340 | message_unseen = old.message_unseen; | ||
341 | message_recent = old.message_recent; | ||
342 | return *this; | ||
343 | } | ||
344 | |||
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h index 05c4816..b2047cb 100644 --- a/noncore/net/mail/libmailwrapper/mailtypes.h +++ b/noncore/net/mail/libmailwrapper/mailtypes.h | |||
@@ -158,35 +158,36 @@ public: | |||
158 | virtual ~encodedString(); | 158 | virtual ~encodedString(); |
159 | 159 | ||
160 | /* returns a pointer to the content - do not delete yoursel! */ | 160 | /* returns a pointer to the content - do not delete yoursel! */ |
161 | const char*Content()const; | 161 | const char*Content()const; |
162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ | 162 | /* returns the lengths of the content 'cause it must not be a null-terminated string! */ |
163 | const int Length()const; | 163 | const int Length()const; |
164 | 164 | ||
165 | /* | 165 | /* |
166 | makes a deep copy of nContent! | 166 | makes a deep copy of nContent! |
167 | */ | 167 | */ |
168 | void setContent(const char*nContent,int nSize); | 168 | void setContent(const char*nContent,int nSize); |
169 | /* | 169 | /* |
170 | Take over the nContent. Means: it will just copy the pointer, not the content. | 170 | Take over the nContent. Means: it will just copy the pointer, not the content. |
171 | so make sure: No one else frees the string, the string has allocated with | 171 | so make sure: No one else frees the string, the string has allocated with |
172 | malloc for compatibility with c-based libs | 172 | malloc for compatibility with c-based libs |
173 | */ | 173 | */ |
174 | void setContent(char*nContent,int nSize); | 174 | void setContent(char*nContent,int nSize); |
175 | 175 | ||
176 | protected: | 176 | protected: |
177 | char * content; | 177 | char * content; |
178 | unsigned int size; | 178 | unsigned int size; |
179 | 179 | ||
180 | void init(); | 180 | void init(); |
181 | void copy_old(const encodedString&old); | 181 | void copy_old(const encodedString&old); |
182 | void clean(); | 182 | void clean(); |
183 | }; | 183 | }; |
184 | 184 | ||
185 | struct folderStat | 185 | struct folderStat |
186 | { | 186 | { |
187 | unsigned int message_count; | 187 | unsigned int message_count; |
188 | unsigned int message_unseen; | 188 | unsigned int message_unseen; |
189 | unsigned int message_recent; | 189 | unsigned int message_recent; |
190 | folderStat&operator=(const folderStat&old); | ||
190 | }; | 191 | }; |
191 | 192 | ||
192 | #endif | 193 | #endif |
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 98f6204..1d7d559 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp | |||
@@ -11,71 +11,73 @@ StatusMail::StatusMail(QList<Account>&list) | |||
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; | 26 | currentPop3Stat.message_count=0; |
27 | currentPop3Stat.message_recent=0; | 27 | currentPop3Stat.message_recent=0; |
28 | currentPop3Stat.message_unseen=0; | 28 | currentPop3Stat.message_unseen=0; |
29 | for ( it = accounts.first(); it; it = accounts.next() ) { | 29 | for ( it = accounts.first(); it; it = accounts.next() ) { |
30 | if ( it->getType().compare( "IMAP" ) == 0 ) { | 30 | if ( it->getType().compare( "IMAP" ) == 0 ) { |
31 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); | 31 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); |
32 | current = AbstractMail::getWrapper(ima); | 32 | current = AbstractMail::getWrapper(ima); |
33 | connectionList.append(current); | 33 | connectionList.append(current); |
34 | current->statusFolder(currentStat); | 34 | current->statusFolder(currentStat); |
35 | currentImapStat.message_count+=currentStat.message_unseen; | 35 | currentImapStat.message_count+=currentStat.message_unseen; |
36 | currentImapStat.message_count+=currentStat.message_recent; | 36 | currentImapStat.message_count+=currentStat.message_recent; |
37 | currentImapStat.message_count+=currentStat.message_count; | 37 | currentImapStat.message_count+=currentStat.message_count; |
38 | } else if ( it->getType().compare( "POP3" ) == 0 ) { | 38 | } else if ( it->getType().compare( "POP3" ) == 0 ) { |
39 | POP3account *pop3 = static_cast<POP3account *>(it); | 39 | POP3account *pop3 = static_cast<POP3account *>(it); |
40 | current = AbstractMail::getWrapper(pop3); | 40 | current = AbstractMail::getWrapper(pop3); |
41 | connectionList.append(current); | 41 | connectionList.append(current); |
42 | current->statusFolder(currentStat); | 42 | current->statusFolder(currentStat); |
43 | currentPop3Stat.message_count+=currentStat.message_unseen; | ||
44 | currentPop3Stat.message_count+=currentStat.message_recent; | ||
45 | currentPop3Stat.message_count+=currentStat.message_count; | 43 | currentPop3Stat.message_count+=currentStat.message_count; |
46 | } | 44 | } |
47 | current->logout(); | 45 | current->logout(); |
48 | } | 46 | } |
49 | lastPop3Stat = currentPop3Stat; | 47 | qDebug("Pop3 init count: %i",currentPop3Stat.message_count); |
48 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | ||
49 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; | ||
50 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; | ||
51 | lastPop3Stat.message_count = currentPop3Stat.message_count; | ||
50 | } | 52 | } |
51 | 53 | ||
52 | void StatusMail::reset_status() | 54 | void StatusMail::reset_status() |
53 | { | 55 | { |
54 | lastPop3Stat = currentPop3Stat; | 56 | lastPop3Stat = currentPop3Stat; |
55 | } | 57 | } |
56 | 58 | ||
57 | void StatusMail::check_current_stat(folderStat&targetStat) | 59 | void StatusMail::check_current_stat(folderStat&targetStat) |
58 | { | 60 | { |
59 | AbstractMail*it = 0; | 61 | AbstractMail*it = 0; |
60 | folderStat currentStat; | 62 | folderStat currentStat; |
61 | currentPop3Stat.message_recent = 0; | 63 | currentPop3Stat.message_recent = 0; |
62 | currentPop3Stat.message_count = 0; | 64 | currentPop3Stat.message_count = 0; |
63 | currentPop3Stat.message_unseen = 0; | 65 | currentPop3Stat.message_unseen = 0; |
64 | currentImapStat = currentPop3Stat; | 66 | currentImapStat = currentPop3Stat; |
65 | for ( it = connectionList.first(); it; it = connectionList.next() ) { | 67 | for ( it = connectionList.first(); it; it = connectionList.next() ) { |
66 | it->statusFolder(currentStat); | 68 | it->statusFolder(currentStat); |
67 | it->logout(); | 69 | it->logout(); |
68 | if (it->getType().lower()=="imap") { | 70 | if (it->getType().lower()=="imap") { |
69 | currentImapStat.message_unseen+=currentStat.message_unseen; | 71 | currentImapStat.message_unseen+=currentStat.message_unseen; |
70 | currentImapStat.message_recent+=currentStat.message_recent; | 72 | currentImapStat.message_recent+=currentStat.message_recent; |
71 | currentImapStat.message_count+=currentStat.message_count; | 73 | currentImapStat.message_count+=currentStat.message_count; |
72 | } else if (it->getType().lower()=="pop3") { | 74 | } else if (it->getType().lower()=="pop3") { |
73 | currentPop3Stat.message_count+=currentStat.message_count; | 75 | currentPop3Stat.message_count+=currentStat.message_count; |
74 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); | 76 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); |
75 | } | 77 | } |
76 | } | 78 | } |
77 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); | 79 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); |
78 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { | 80 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { |
79 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; | 81 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; |
80 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; | 82 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; |
81 | } else { | 83 | } else { |
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp index 991b5fb..6078013 100644 --- a/noncore/net/mail/taskbarapplet/mailapplet.cpp +++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp | |||
@@ -41,65 +41,65 @@ MailApplet::~MailApplet() { | |||
41 | delete m_statusMail; | 41 | delete m_statusMail; |
42 | if ( m_config ) | 42 | if ( m_config ) |
43 | delete m_config; | 43 | delete m_config; |
44 | } | 44 | } |
45 | 45 | ||
46 | void MailApplet::paintEvent( QPaintEvent* ) { | 46 | void MailApplet::paintEvent( QPaintEvent* ) { |
47 | QPainter p( this ); | 47 | QPainter p( this ); |
48 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); | 48 | p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); |
49 | QFont f( "vera", AppLnk::smallIconSize() ); | 49 | QFont f( "vera", AppLnk::smallIconSize() ); |
50 | QFontMetrics fm( f ); | 50 | QFontMetrics fm( f ); |
51 | p.setFont( f ); | 51 | p.setFont( f ); |
52 | p.setPen( Qt::blue ); | 52 | p.setPen( Qt::blue ); |
53 | p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); | 53 | p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); |
54 | return; | 54 | return; |
55 | 55 | ||
56 | } | 56 | } |
57 | 57 | ||
58 | void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { | 58 | void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { |
59 | slotClicked(); | 59 | slotClicked(); |
60 | } | 60 | } |
61 | 61 | ||
62 | void MailApplet::slotClicked() { | 62 | void MailApplet::slotClicked() { |
63 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 63 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
64 | e << QString( "opiemail" ); | 64 | e << QString( "opiemail" ); |
65 | 65 | ||
66 | ODevice *device = ODevice::inst(); | 66 | ODevice *device = ODevice::inst(); |
67 | if ( !device-> ledList().isEmpty() ) { | 67 | if ( !device-> ledList().isEmpty() ) { |
68 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; | 68 | OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; |
69 | 69 | ||
70 | device->setLedState( led, Led_Off ); | 70 | device->setLedState( led, Led_Off ); |
71 | } | 71 | } |
72 | 72 | ||
73 | // m_statusMails->reset_status(); | 73 | if (m_statusMail) m_statusMail->reset_status(); |
74 | } | 74 | } |
75 | 75 | ||
76 | void MailApplet::startup() { | 76 | void MailApplet::startup() { |
77 | Settings *settings = new Settings(); | 77 | Settings *settings = new Settings(); |
78 | QList<Account> ma = settings->getAccounts(); | 78 | QList<Account> ma = settings->getAccounts(); |
79 | m_statusMail = new StatusMail( ma ); | 79 | m_statusMail = new StatusMail( ma ); |
80 | delete settings; | 80 | delete settings; |
81 | 81 | ||
82 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | 82 | m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; |
83 | m_intervalTimer = new QTimer(); | 83 | m_intervalTimer = new QTimer(); |
84 | m_intervalTimer->start( m_intervalMs ); | 84 | m_intervalTimer->start( m_intervalMs ); |
85 | connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); | 85 | connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); |
86 | } | 86 | } |
87 | 87 | ||
88 | void MailApplet::slotCheck() { | 88 | void MailApplet::slotCheck() { |
89 | // Check wether the check interval has been changed. | 89 | // Check wether the check interval has been changed. |
90 | int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; | 90 | int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; |
91 | if ( newIntervalMs != m_intervalMs ) { | 91 | if ( newIntervalMs != m_intervalMs ) { |
92 | m_intervalTimer->changeInterval( newIntervalMs ); | 92 | m_intervalTimer->changeInterval( newIntervalMs ); |
93 | m_intervalMs = newIntervalMs; | 93 | m_intervalMs = newIntervalMs; |
94 | } | 94 | } |
95 | 95 | ||
96 | if (m_statusMail == 0) { | 96 | if (m_statusMail == 0) { |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | 99 | ||
100 | folderStat stat; | 100 | folderStat stat; |
101 | m_statusMail->check_current_stat( stat ); | 101 | m_statusMail->check_current_stat( stat ); |
102 | m_newMails = stat.message_unseen; | 102 | m_newMails = stat.message_unseen; |
103 | qDebug( QString( "test %1" ).arg( m_newMails ) ); | 103 | qDebug( QString( "test %1" ).arg( m_newMails ) ); |
104 | if ( m_newMails > 0 ) { | 104 | if ( m_newMails > 0 ) { |
105 | ODevice *device = ODevice::inst(); | 105 | ODevice *device = ODevice::inst(); |