summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp9
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h1
-rw-r--r--noncore/net/mail/libmailwrapper/statusmail.cpp8
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.cpp2
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
@@ -208,128 +208,137 @@ RecBody::RecBody()
208 208
209RecBody::~RecBody() 209RecBody::~RecBody()
210{ 210{
211} 211}
212 212
213void RecBody::setBodytext(const QString&bodyText) 213void RecBody::setBodytext(const QString&bodyText)
214{ 214{
215 m_BodyText = bodyText; 215 m_BodyText = bodyText;
216} 216}
217 217
218const QString& RecBody::Bodytext()const 218const QString& RecBody::Bodytext()const
219{ 219{
220 return m_BodyText; 220 return m_BodyText;
221} 221}
222 222
223void RecBody::setParts(const QValueList<RecPart>&parts) 223void RecBody::setParts(const QValueList<RecPart>&parts)
224{ 224{
225 m_PartsList.clear(); 225 m_PartsList.clear();
226 m_PartsList = parts; 226 m_PartsList = parts;
227} 227}
228 228
229const QValueList<RecPart>& RecBody::Parts()const 229const QValueList<RecPart>& RecBody::Parts()const
230{ 230{
231 return m_PartsList; 231 return m_PartsList;
232} 232}
233 233
234void RecBody::addPart(const RecPart& part) 234void RecBody::addPart(const RecPart& part)
235{ 235{
236 m_PartsList.append(part); 236 m_PartsList.append(part);
237} 237}
238 238
239void RecBody::setDescription(const RecPart&des) 239void RecBody::setDescription(const RecPart&des)
240{ 240{
241 m_description = des; 241 m_description = des;
242} 242}
243 243
244const RecPart& RecBody::Description()const 244const RecPart& RecBody::Description()const
245{ 245{
246 return m_description; 246 return m_description;
247} 247}
248 248
249/* handling encoded content */ 249/* handling encoded content */
250encodedString::encodedString() 250encodedString::encodedString()
251{ 251{
252 init(); 252 init();
253} 253}
254 254
255encodedString::encodedString(const char*nContent,unsigned int nSize) 255encodedString::encodedString(const char*nContent,unsigned int nSize)
256{ 256{
257 init(); 257 init();
258 setContent(nContent,nSize); 258 setContent(nContent,nSize);
259} 259}
260 260
261encodedString::encodedString(char*nContent,unsigned int nSize) 261encodedString::encodedString(char*nContent,unsigned int nSize)
262{ 262{
263 init(); 263 init();
264 setContent(nContent,nSize); 264 setContent(nContent,nSize);
265} 265}
266 266
267encodedString::encodedString(const encodedString&old) 267encodedString::encodedString(const encodedString&old)
268{ 268{
269 init(); 269 init();
270 copy_old(old); 270 copy_old(old);
271 qDebug("encodedeString: copy constructor!"); 271 qDebug("encodedeString: copy constructor!");
272} 272}
273 273
274encodedString& encodedString::operator=(const encodedString&old) 274encodedString& encodedString::operator=(const encodedString&old)
275{ 275{
276 init(); 276 init();
277 copy_old(old); 277 copy_old(old);
278 qDebug("encodedString: assign operator!"); 278 qDebug("encodedString: assign operator!");
279 return *this; 279 return *this;
280} 280}
281 281
282encodedString::~encodedString() 282encodedString::~encodedString()
283{ 283{
284 clean(); 284 clean();
285} 285}
286 286
287void encodedString::init() 287void encodedString::init()
288{ 288{
289 content = 0; 289 content = 0;
290 size = 0; 290 size = 0;
291} 291}
292 292
293void encodedString::clean() 293void encodedString::clean()
294{ 294{
295 if (content) { 295 if (content) {
296 free(content); 296 free(content);
297 } 297 }
298 content = 0; 298 content = 0;
299 size = 0; 299 size = 0;
300} 300}
301 301
302void encodedString::copy_old(const encodedString&old) 302void encodedString::copy_old(const encodedString&old)
303{ 303{
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
312const char*encodedString::Content()const 312const char*encodedString::Content()const
313{ 313{
314 return content; 314 return content;
315} 315}
316 316
317const int encodedString::Length()const 317const int encodedString::Length()const
318{ 318{
319 return size; 319 return size;
320} 320}
321 321
322void encodedString::setContent(const char*nContent,int nSize) 322void 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
331void encodedString::setContent(char*nContent,int nSize) 331void encodedString::setContent(char*nContent,int nSize)
332{ 332{
333 content = nContent; 333 content = nContent;
334 size = nSize; 334 size = nSize;
335} 335}
336
337folderStat&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
@@ -62,131 +62,132 @@ public:
62 const QBitArray&getFlags()const{return msg_flags;} 62 const QBitArray&getFlags()const{return msg_flags;}
63 void setFlags(const QBitArray&flags){msg_flags = flags;} 63 void setFlags(const QBitArray&flags){msg_flags = flags;}
64 64
65 void setWrapper(AbstractMail*wrapper); 65 void setWrapper(AbstractMail*wrapper);
66 AbstractMail* Wrapper(); 66 AbstractMail* Wrapper();
67 67
68protected: 68protected:
69 QString subject,date,from,mbox,msg_id,replyto; 69 QString subject,date,from,mbox,msg_id,replyto;
70 int msg_number,msg_size; 70 int msg_number,msg_size;
71 QBitArray msg_flags; 71 QBitArray msg_flags;
72 QStringList to,cc,bcc; 72 QStringList to,cc,bcc;
73 AbstractMail*wrapper; 73 AbstractMail*wrapper;
74 void init(); 74 void init();
75 void copy_old(const RecMail&old); 75 void copy_old(const RecMail&old);
76}; 76};
77 77
78typedef QMap<QString,QString> part_plist_t; 78typedef QMap<QString,QString> part_plist_t;
79 79
80class RecPart 80class RecPart
81{ 81{
82protected: 82protected:
83 QString m_type,m_subtype,m_identifier,m_encoding,m_description; 83 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
84 unsigned int m_lines,m_size; 84 unsigned int m_lines,m_size;
85 part_plist_t m_Parameters; 85 part_plist_t m_Parameters;
86 /* describes the position in the mail */ 86 /* describes the position in the mail */
87 QValueList<int> m_poslist; 87 QValueList<int> m_poslist;
88 88
89public: 89public:
90 RecPart(); 90 RecPart();
91 virtual ~RecPart(); 91 virtual ~RecPart();
92 92
93 const QString&Type()const; 93 const QString&Type()const;
94 void setType(const QString&type); 94 void setType(const QString&type);
95 const QString&Subtype()const; 95 const QString&Subtype()const;
96 void setSubtype(const QString&subtype); 96 void setSubtype(const QString&subtype);
97 const QString&Identifier()const; 97 const QString&Identifier()const;
98 void setIdentifier(const QString&identifier); 98 void setIdentifier(const QString&identifier);
99 const QString&Encoding()const; 99 const QString&Encoding()const;
100 void setEncoding(const QString&encoding); 100 void setEncoding(const QString&encoding);
101 const QString&Description()const; 101 const QString&Description()const;
102 void setDescription(const QString&desc); 102 void setDescription(const QString&desc);
103 void setLines(unsigned int lines); 103 void setLines(unsigned int lines);
104 const unsigned int Lines()const; 104 const unsigned int Lines()const;
105 void setSize(unsigned int size); 105 void setSize(unsigned int size);
106 const unsigned int Size()const; 106 const unsigned int Size()const;
107 107
108 108
109 void setParameters(const part_plist_t&list); 109 void setParameters(const part_plist_t&list);
110 const part_plist_t&Parameters()const; 110 const part_plist_t&Parameters()const;
111 void addParameter(const QString&key,const QString&value); 111 void addParameter(const QString&key,const QString&value);
112 const QString searchParamter(const QString&key)const; 112 const QString searchParamter(const QString&key)const;
113 void setPositionlist(const QValueList<int>&poslist); 113 void setPositionlist(const QValueList<int>&poslist);
114 const QValueList<int>& Positionlist()const; 114 const QValueList<int>& Positionlist()const;
115}; 115};
116 116
117class RecBody 117class RecBody
118{ 118{
119protected: 119protected:
120 QString m_BodyText; 120 QString m_BodyText;
121 QValueList<RecPart> m_PartsList; 121 QValueList<RecPart> m_PartsList;
122 RecPart m_description; 122 RecPart m_description;
123 123
124public: 124public:
125 RecBody(); 125 RecBody();
126 virtual ~RecBody(); 126 virtual ~RecBody();
127 void setBodytext(const QString&); 127 void setBodytext(const QString&);
128 const QString& Bodytext()const; 128 const QString& Bodytext()const;
129 129
130 void setDescription(const RecPart&des); 130 void setDescription(const RecPart&des);
131 const RecPart& Description()const; 131 const RecPart& Description()const;
132 132
133 void setParts(const QValueList<RecPart>&parts); 133 void setParts(const QValueList<RecPart>&parts);
134 const QValueList<RecPart>& Parts()const; 134 const QValueList<RecPart>& Parts()const;
135 void addPart(const RecPart&part); 135 void addPart(const RecPart&part);
136}; 136};
137 137
138class encodedString 138class encodedString
139{ 139{
140public: 140public:
141 encodedString(); 141 encodedString();
142 /* 142 /*
143 creates an new content string. 143 creates an new content string.
144 it makes a deep copy of it! 144 it makes a deep copy of it!
145 */ 145 */
146 encodedString(const char*nContent,unsigned int length); 146 encodedString(const char*nContent,unsigned int length);
147 /* 147 /*
148 Take over the nContent. Means: it will just copy the pointer, not the content. 148 Take over the nContent. Means: it will just copy the pointer, not the content.
149 so make sure: No one else frees the string, the string has allocated with 149 so make sure: No one else frees the string, the string has allocated with
150 malloc for compatibility with c-based libs 150 malloc for compatibility with c-based libs
151 */ 151 */
152 encodedString(char*nContent,unsigned int nSize); 152 encodedString(char*nContent,unsigned int nSize);
153 /* copy construkor - makes ALWAYS a deep copy!!!! */ 153 /* copy construkor - makes ALWAYS a deep copy!!!! */
154 encodedString(const encodedString&old); 154 encodedString(const encodedString&old);
155 /* assign operator - makes ALWAYS a deep copy!!!! */ 155 /* assign operator - makes ALWAYS a deep copy!!!! */
156 encodedString& operator=(const encodedString&old); 156 encodedString& operator=(const encodedString&old);
157 /* destructor - cleans the content */ 157 /* destructor - cleans the content */
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
176protected: 176protected:
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
185struct folderStat 185struct 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
@@ -1,89 +1,91 @@
1#include "statusmail.h" 1#include "statusmail.h"
2#include <qlist.h> 2#include <qlist.h>
3 3
4StatusMail::StatusMail(QList<Account>&list) 4StatusMail::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
16StatusMail::~StatusMail() 16StatusMail::~StatusMail()
17{ 17{
18} 18}
19 19
20void StatusMail::initAccounts(QList<Account>&accounts) 20void 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
52void StatusMail::reset_status() 54void StatusMail::reset_status()
53{ 55{
54 lastPop3Stat = currentPop3Stat; 56 lastPop3Stat = currentPop3Stat;
55} 57}
56 58
57void StatusMail::check_current_stat(folderStat&targetStat) 59void 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 {
82 lastPop3Stat.message_count = currentPop3Stat.message_count; 84 lastPop3Stat.message_count = currentPop3Stat.message_count;
83 currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; 85 currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0;
84 } 86 }
85 targetStat = currentImapStat; 87 targetStat = currentImapStat;
86 targetStat.message_unseen+=currentPop3Stat.message_unseen; 88 targetStat.message_unseen+=currentPop3Stat.message_unseen;
87 targetStat.message_recent+=currentPop3Stat.message_recent; 89 targetStat.message_recent+=currentPop3Stat.message_recent;
88 targetStat.message_count+=currentPop3Stat.message_count; 90 targetStat.message_count+=currentPop3Stat.message_count;
89} 91}
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
@@ -1,139 +1,139 @@
1#include <qpainter.h> 1#include <qpainter.h>
2#include <qtimer.h> 2#include <qtimer.h>
3 3
4#include <qpe/qcopenvelope_qws.h> 4#include <qpe/qcopenvelope_qws.h>
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qpe/applnk.h> 7#include <qpe/applnk.h>
8 8
9#include <opie/odevice.h> 9#include <opie/odevice.h>
10 10
11#include <libmailwrapper/settings.h> 11#include <libmailwrapper/settings.h>
12 12
13#include "mailapplet.h" 13#include "mailapplet.h"
14 14
15using namespace Opie; 15using namespace Opie;
16 16
17MailApplet::MailApplet( QWidget *parent ) 17MailApplet::MailApplet( QWidget *parent )
18: QWidget( parent ) { 18: QWidget( parent ) {
19 19
20 m_config = new Config( "mail" ); 20 m_config = new Config( "mail" );
21 m_config->setGroup( "Applet" ); 21 m_config->setGroup( "Applet" );
22 22
23 setFixedWidth( AppLnk::smallIconSize() ); 23 setFixedWidth( AppLnk::smallIconSize() );
24 setFixedHeight( AppLnk::smallIconSize() ); 24 setFixedHeight( AppLnk::smallIconSize() );
25 25
26 hide(); 26 hide();
27 27
28 m_newMails = 0; 28 m_newMails = 0;
29 m_statusMail = 0l; 29 m_statusMail = 0l;
30 30
31 if ( !m_config->readBoolEntry( "Disabled", false ) ) { 31 if ( !m_config->readBoolEntry( "Disabled", false ) ) {
32 // delay 5 sec until the whole mail backend gets started .-) 32 // delay 5 sec until the whole mail backend gets started .-)
33 QTimer::singleShot( 5000, this, SLOT( startup() ) ); 33 QTimer::singleShot( 5000, this, SLOT( startup() ) );
34 } 34 }
35 repaint( true ); 35 repaint( true );
36} 36}
37 37
38 38
39MailApplet::~MailApplet() { 39MailApplet::~MailApplet() {
40 if ( m_statusMail ) 40 if ( m_statusMail )
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
46void MailApplet::paintEvent( QPaintEvent* ) { 46void 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
58void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { 58void MailApplet::mouseReleaseEvent( QMouseEvent* e ) {
59 slotClicked(); 59 slotClicked();
60} 60}
61 61
62void MailApplet::slotClicked() { 62void 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
76void MailApplet::startup() { 76void 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
88void MailApplet::slotCheck() { 88void 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();
106 if ( isHidden() ) 106 if ( isHidden() )
107 show(); 107 show();
108 if ( m_config->readBoolEntry( "BlinkLed", true ) ) { 108 if ( m_config->readBoolEntry( "BlinkLed", true ) ) {
109 if ( !device->ledList().isEmpty() ) { 109 if ( !device->ledList().isEmpty() ) {
110 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 110 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
111 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); 111 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On );
112 } 112 }
113 } 113 }
114 if ( m_config->readBoolEntry( "PlaySound", false ) ) 114 if ( m_config->readBoolEntry( "PlaySound", false ) )
115 device->alarmSound(); 115 device->alarmSound();
116 116
117 Config cfg( "mail" ); 117 Config cfg( "mail" );
118 cfg.setGroup( "Status" ); 118 cfg.setGroup( "Status" );
119 cfg.writeEntry( "newMails", m_newMails ); 119 cfg.writeEntry( "newMails", m_newMails );
120 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 120 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
121 env << m_newMails; 121 env << m_newMails;
122 repaint( true ); 122 repaint( true );
123 123
124 } else { 124 } else {
125 ODevice *device = ODevice::inst(); 125 ODevice *device = ODevice::inst();
126 if ( !isHidden() ) 126 if ( !isHidden() )
127 hide(); 127 hide();
128 if ( !device->ledList().isEmpty() ) { 128 if ( !device->ledList().isEmpty() ) {
129 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 129 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
130 device->setLedState( led, Led_Off ); 130 device->setLedState( led, Led_Off );
131 } 131 }
132 132
133 Config cfg( "mail" ); 133 Config cfg( "mail" );
134 cfg.setGroup( "Status" ); 134 cfg.setGroup( "Status" );
135 cfg.writeEntry( "newMails", m_newMails ); 135 cfg.writeEntry( "newMails", m_newMails );
136 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 136 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
137 env << m_newMails; 137 env << m_newMails;
138 } 138 }
139} 139}