author | chicken <chicken> | 2004-03-02 16:24:30 (UTC) |
---|---|---|
committer | chicken <chicken> | 2004-03-02 16:24:30 (UTC) |
commit | 10d627d55eaab6cda26b03879f1b0fe31d1b273b (patch) (unidiff) | |
tree | eb04a35ba5e359eb808bf0bd85b1be51dcb4b0a9 | |
parent | 49bee7ab52b819a07e9b6de4576eda467d632a66 (diff) | |
download | opie-10d627d55eaab6cda26b03879f1b0fe31d1b273b.zip opie-10d627d55eaab6cda26b03879f1b0fe31d1b273b.tar.gz opie-10d627d55eaab6cda26b03879f1b0fe31d1b273b.tar.bz2 |
fix includes
23 files changed, 1 insertions, 51 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp index 32a96ff..e925d8d 100644 --- a/noncore/net/mail/accountitem.cpp +++ b/noncore/net/mail/accountitem.cpp | |||
@@ -1,1117 +1,1116 @@ | |||
1 | 1 | ||
2 | #include "accountitem.h" | 2 | #include "accountitem.h" |
3 | #include "accountview.h" | 3 | #include "accountview.h" |
4 | #include "selectstore.h" | ||
5 | #include "newmaildir.h" | 4 | #include "newmaildir.h" |
6 | #include "defines.h" | 5 | #include "defines.h" |
7 | 6 | ||
8 | /* OPIE */ | 7 | /* OPIE */ |
9 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
10 | #include <libmailwrapper/abstractmail.h> | 9 | #include <libmailwrapper/abstractmail.h> |
11 | #include <libmailwrapper/mailwrapper.h> | 10 | #include <libmailwrapper/mailwrapper.h> |
12 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
13 | 12 | ||
14 | /* QT */ | 13 | /* QT */ |
15 | #include <qpopupmenu.h> | 14 | #include <qpopupmenu.h> |
16 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
17 | 16 | ||
18 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} | 17 | #define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} |
19 | /** | 18 | /** |
20 | * POP3 Account stuff | 19 | * POP3 Account stuff |
21 | */ | 20 | */ |
22 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) | 21 | POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) |
23 | : AccountViewItem( parent ) | 22 | : AccountViewItem( parent ) |
24 | { | 23 | { |
25 | account = a; | 24 | account = a; |
26 | wrapper = AbstractMail::getWrapper( account ); | 25 | wrapper = AbstractMail::getWrapper( account ); |
27 | SETPIX(PIXMAP_POP3FOLDER); | 26 | SETPIX(PIXMAP_POP3FOLDER); |
28 | #if 0 | 27 | #if 0 |
29 | if (!account->getOffline()) | 28 | if (!account->getOffline()) |
30 | { | 29 | { |
31 | setPixmap( 0, ); | 30 | setPixmap( 0, ); |
32 | } | 31 | } |
33 | else | 32 | else |
34 | { | 33 | { |
35 | setPixmap( 0, PIXMAP_OFFLINE ); | 34 | setPixmap( 0, PIXMAP_OFFLINE ); |
36 | } | 35 | } |
37 | #endif | 36 | #endif |
38 | setText( 0, account->getAccountName() ); | 37 | setText( 0, account->getAccountName() ); |
39 | setOpen( true ); | 38 | setOpen( true ); |
40 | } | 39 | } |
41 | 40 | ||
42 | POP3viewItem::~POP3viewItem() | 41 | POP3viewItem::~POP3viewItem() |
43 | { | 42 | { |
44 | delete wrapper; | 43 | delete wrapper; |
45 | } | 44 | } |
46 | 45 | ||
47 | AbstractMail *POP3viewItem::getWrapper() | 46 | AbstractMail *POP3viewItem::getWrapper() |
48 | { | 47 | { |
49 | return wrapper; | 48 | return wrapper; |
50 | } | 49 | } |
51 | 50 | ||
52 | void POP3viewItem::refresh( QList<RecMail> & ) | 51 | void POP3viewItem::refresh( QList<RecMail> & ) |
53 | { | 52 | { |
54 | refresh(); | 53 | refresh(); |
55 | } | 54 | } |
56 | 55 | ||
57 | void POP3viewItem::refresh() | 56 | void POP3viewItem::refresh() |
58 | { | 57 | { |
59 | if (account->getOffline()) return; | 58 | if (account->getOffline()) return; |
60 | QList<Folder> *folders = wrapper->listFolders(); | 59 | QList<Folder> *folders = wrapper->listFolders(); |
61 | QListViewItem *child = firstChild(); | 60 | QListViewItem *child = firstChild(); |
62 | while ( child ) | 61 | while ( child ) |
63 | { | 62 | { |
64 | QListViewItem *tmp = child; | 63 | QListViewItem *tmp = child; |
65 | child = child->nextSibling(); | 64 | child = child->nextSibling(); |
66 | delete tmp; | 65 | delete tmp; |
67 | } | 66 | } |
68 | Folder *it; | 67 | Folder *it; |
69 | QListViewItem*item = 0; | 68 | QListViewItem*item = 0; |
70 | for ( it = folders->first(); it; it = folders->next() ) | 69 | for ( it = folders->first(); it; it = folders->next() ) |
71 | { | 70 | { |
72 | item = new POP3folderItem( it, this , item ); | 71 | item = new POP3folderItem( it, this , item ); |
73 | item->setSelectable(it->may_select()); | 72 | item->setSelectable(it->may_select()); |
74 | } | 73 | } |
75 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 74 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
76 | folders->setAutoDelete(false); | 75 | folders->setAutoDelete(false); |
77 | delete folders; | 76 | delete folders; |
78 | } | 77 | } |
79 | 78 | ||
80 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) | 79 | RecBody POP3viewItem::fetchBody( const RecMail &mail ) |
81 | { | 80 | { |
82 | qDebug( "POP3 fetchBody" ); | 81 | qDebug( "POP3 fetchBody" ); |
83 | return wrapper->fetchBody( mail ); | 82 | return wrapper->fetchBody( mail ); |
84 | } | 83 | } |
85 | 84 | ||
86 | QPopupMenu * POP3viewItem::getContextMenu() | 85 | QPopupMenu * POP3viewItem::getContextMenu() |
87 | { | 86 | { |
88 | QPopupMenu *m = new QPopupMenu(0); | 87 | QPopupMenu *m = new QPopupMenu(0); |
89 | if (m) | 88 | if (m) |
90 | { | 89 | { |
91 | if (!account->getOffline()) | 90 | if (!account->getOffline()) |
92 | { | 91 | { |
93 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 92 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
94 | m->insertItem(QObject::tr("Set offline",contextName),1); | 93 | m->insertItem(QObject::tr("Set offline",contextName),1); |
95 | } | 94 | } |
96 | else | 95 | else |
97 | { | 96 | { |
98 | m->insertItem(QObject::tr("Set online",contextName),1); | 97 | m->insertItem(QObject::tr("Set online",contextName),1); |
99 | } | 98 | } |
100 | } | 99 | } |
101 | return m; | 100 | return m; |
102 | } | 101 | } |
103 | 102 | ||
104 | void POP3viewItem::disconnect() | 103 | void POP3viewItem::disconnect() |
105 | { | 104 | { |
106 | QListViewItem *child = firstChild(); | 105 | QListViewItem *child = firstChild(); |
107 | while ( child ) | 106 | while ( child ) |
108 | { | 107 | { |
109 | QListViewItem *tmp = child; | 108 | QListViewItem *tmp = child; |
110 | child = child->nextSibling(); | 109 | child = child->nextSibling(); |
111 | delete tmp; | 110 | delete tmp; |
112 | } | 111 | } |
113 | wrapper->logout(); | 112 | wrapper->logout(); |
114 | } | 113 | } |
115 | 114 | ||
116 | void POP3viewItem::setOnOffline() | 115 | void POP3viewItem::setOnOffline() |
117 | { | 116 | { |
118 | if (!account->getOffline()) | 117 | if (!account->getOffline()) |
119 | { | 118 | { |
120 | disconnect(); | 119 | disconnect(); |
121 | } | 120 | } |
122 | account->setOffline(!account->getOffline()); | 121 | account->setOffline(!account->getOffline()); |
123 | account->save(); | 122 | account->save(); |
124 | SETPIX(PIXMAP_POP3FOLDER); | 123 | SETPIX(PIXMAP_POP3FOLDER); |
125 | refresh(); | 124 | refresh(); |
126 | } | 125 | } |
127 | 126 | ||
128 | void POP3viewItem::contextMenuSelected(int which) | 127 | void POP3viewItem::contextMenuSelected(int which) |
129 | { | 128 | { |
130 | switch (which) | 129 | switch (which) |
131 | { | 130 | { |
132 | case 0: | 131 | case 0: |
133 | disconnect(); | 132 | disconnect(); |
134 | break; | 133 | break; |
135 | case 1: | 134 | case 1: |
136 | setOnOffline(); | 135 | setOnOffline(); |
137 | break; | 136 | break; |
138 | } | 137 | } |
139 | } | 138 | } |
140 | 139 | ||
141 | POP3folderItem::~POP3folderItem() | 140 | POP3folderItem::~POP3folderItem() |
142 | {} | 141 | {} |
143 | 142 | ||
144 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) | 143 | POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) |
145 | : AccountViewItem( parent,after ) | 144 | : AccountViewItem( parent,after ) |
146 | { | 145 | { |
147 | folder = folderInit; | 146 | folder = folderInit; |
148 | pop3 = parent; | 147 | pop3 = parent; |
149 | if (folder->getDisplayName().lower()!="inbox") | 148 | if (folder->getDisplayName().lower()!="inbox") |
150 | { | 149 | { |
151 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 150 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
152 | } | 151 | } |
153 | else | 152 | else |
154 | { | 153 | { |
155 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 154 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
156 | } | 155 | } |
157 | setText( 0, folder->getDisplayName() ); | 156 | setText( 0, folder->getDisplayName() ); |
158 | } | 157 | } |
159 | 158 | ||
160 | void POP3folderItem::refresh(QList<RecMail>&target) | 159 | void POP3folderItem::refresh(QList<RecMail>&target) |
161 | { | 160 | { |
162 | if (folder->may_select()) | 161 | if (folder->may_select()) |
163 | pop3->getWrapper()->listMessages( folder->getName(),target ); | 162 | pop3->getWrapper()->listMessages( folder->getName(),target ); |
164 | } | 163 | } |
165 | 164 | ||
166 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) | 165 | RecBody POP3folderItem::fetchBody(const RecMail&aMail) |
167 | { | 166 | { |
168 | return pop3->getWrapper()->fetchBody(aMail); | 167 | return pop3->getWrapper()->fetchBody(aMail); |
169 | } | 168 | } |
170 | 169 | ||
171 | QPopupMenu * POP3folderItem::getContextMenu() | 170 | QPopupMenu * POP3folderItem::getContextMenu() |
172 | { | 171 | { |
173 | QPopupMenu *m = new QPopupMenu(0); | 172 | QPopupMenu *m = new QPopupMenu(0); |
174 | if (m) | 173 | if (m) |
175 | { | 174 | { |
176 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 175 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
177 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 176 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
178 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 177 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
179 | } | 178 | } |
180 | return m; | 179 | return m; |
181 | } | 180 | } |
182 | 181 | ||
183 | void POP3folderItem::downloadMails() | 182 | void POP3folderItem::downloadMails() |
184 | { | 183 | { |
185 | AccountView*bl = pop3->accountView(); | 184 | AccountView*bl = pop3->accountView(); |
186 | if (!bl) return; | 185 | if (!bl) return; |
187 | bl->downloadMails(folder,pop3->getWrapper()); | 186 | bl->downloadMails(folder,pop3->getWrapper()); |
188 | } | 187 | } |
189 | 188 | ||
190 | void POP3folderItem::contextMenuSelected(int which) | 189 | void POP3folderItem::contextMenuSelected(int which) |
191 | { | 190 | { |
192 | AccountView * view = (AccountView*)listView(); | 191 | AccountView * view = (AccountView*)listView(); |
193 | switch (which) | 192 | switch (which) |
194 | { | 193 | { |
195 | case 0: | 194 | case 0: |
196 | /* must be 'cause pop3 lists are cached */ | 195 | /* must be 'cause pop3 lists are cached */ |
197 | pop3->getWrapper()->logout(); | 196 | pop3->getWrapper()->logout(); |
198 | view->refreshCurrent(); | 197 | view->refreshCurrent(); |
199 | break; | 198 | break; |
200 | case 1: | 199 | case 1: |
201 | deleteAllMail(pop3->getWrapper(),folder); | 200 | deleteAllMail(pop3->getWrapper(),folder); |
202 | break; | 201 | break; |
203 | case 2: | 202 | case 2: |
204 | downloadMails(); | 203 | downloadMails(); |
205 | break; | 204 | break; |
206 | default: | 205 | default: |
207 | break; | 206 | break; |
208 | } | 207 | } |
209 | } | 208 | } |
210 | 209 | ||
211 | /** | 210 | /** |
212 | * NNTP Account stuff | 211 | * NNTP Account stuff |
213 | */ | 212 | */ |
214 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) | 213 | NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) |
215 | : AccountViewItem( parent ) | 214 | : AccountViewItem( parent ) |
216 | { | 215 | { |
217 | account = a; | 216 | account = a; |
218 | wrapper = AbstractMail::getWrapper( account ); | 217 | wrapper = AbstractMail::getWrapper( account ); |
219 | //FIXME | 218 | //FIXME |
220 | SETPIX(PIXMAP_POP3FOLDER); | 219 | SETPIX(PIXMAP_POP3FOLDER); |
221 | #if 0 | 220 | #if 0 |
222 | if (!account->getOffline()) | 221 | if (!account->getOffline()) |
223 | { | 222 | { |
224 | setPixmap( 0, ); | 223 | setPixmap( 0, ); |
225 | } | 224 | } |
226 | else | 225 | else |
227 | { | 226 | { |
228 | setPixmap( 0, PIXMAP_OFFLINE ); | 227 | setPixmap( 0, PIXMAP_OFFLINE ); |
229 | } | 228 | } |
230 | #endif | 229 | #endif |
231 | setText( 0, account->getAccountName() ); | 230 | setText( 0, account->getAccountName() ); |
232 | setOpen( true ); | 231 | setOpen( true ); |
233 | } | 232 | } |
234 | 233 | ||
235 | NNTPviewItem::~NNTPviewItem() | 234 | NNTPviewItem::~NNTPviewItem() |
236 | { | 235 | { |
237 | delete wrapper; | 236 | delete wrapper; |
238 | } | 237 | } |
239 | 238 | ||
240 | AbstractMail *NNTPviewItem::getWrapper() | 239 | AbstractMail *NNTPviewItem::getWrapper() |
241 | { | 240 | { |
242 | return wrapper; | 241 | return wrapper; |
243 | } | 242 | } |
244 | 243 | ||
245 | void NNTPviewItem::refresh( QList<RecMail> & ) | 244 | void NNTPviewItem::refresh( QList<RecMail> & ) |
246 | { | 245 | { |
247 | refresh(); | 246 | refresh(); |
248 | } | 247 | } |
249 | 248 | ||
250 | void NNTPviewItem::refresh() | 249 | void NNTPviewItem::refresh() |
251 | { | 250 | { |
252 | if (account->getOffline()) return; | 251 | if (account->getOffline()) return; |
253 | QList<Folder> *folders = wrapper->listFolders(); | 252 | QList<Folder> *folders = wrapper->listFolders(); |
254 | QListViewItem *child = firstChild(); | 253 | QListViewItem *child = firstChild(); |
255 | while ( child ) | 254 | while ( child ) |
256 | { | 255 | { |
257 | QListViewItem *tmp = child; | 256 | QListViewItem *tmp = child; |
258 | child = child->nextSibling(); | 257 | child = child->nextSibling(); |
259 | delete tmp; | 258 | delete tmp; |
260 | } | 259 | } |
261 | Folder *it; | 260 | Folder *it; |
262 | QListViewItem*item = 0; | 261 | QListViewItem*item = 0; |
263 | for ( it = folders->first(); it; it = folders->next() ) | 262 | for ( it = folders->first(); it; it = folders->next() ) |
264 | { | 263 | { |
265 | item = new NNTPfolderItem( it, this , item ); | 264 | item = new NNTPfolderItem( it, this , item ); |
266 | item->setSelectable(it->may_select()); | 265 | item->setSelectable(it->may_select()); |
267 | } | 266 | } |
268 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 267 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
269 | folders->setAutoDelete(false); | 268 | folders->setAutoDelete(false); |
270 | delete folders; | 269 | delete folders; |
271 | } | 270 | } |
272 | 271 | ||
273 | RecBody NNTPviewItem::fetchBody( const RecMail &mail ) | 272 | RecBody NNTPviewItem::fetchBody( const RecMail &mail ) |
274 | { | 273 | { |
275 | qDebug( "NNTP fetchBody" ); | 274 | qDebug( "NNTP fetchBody" ); |
276 | return wrapper->fetchBody( mail ); | 275 | return wrapper->fetchBody( mail ); |
277 | } | 276 | } |
278 | 277 | ||
279 | QPopupMenu * NNTPviewItem::getContextMenu() | 278 | QPopupMenu * NNTPviewItem::getContextMenu() |
280 | { | 279 | { |
281 | QPopupMenu *m = new QPopupMenu(0); | 280 | QPopupMenu *m = new QPopupMenu(0); |
282 | if (m) | 281 | if (m) |
283 | { | 282 | { |
284 | if (!account->getOffline()) | 283 | if (!account->getOffline()) |
285 | { | 284 | { |
286 | m->insertItem(QObject::tr("Disconnect",contextName),0); | 285 | m->insertItem(QObject::tr("Disconnect",contextName),0); |
287 | m->insertItem(QObject::tr("Set offline",contextName),1); | 286 | m->insertItem(QObject::tr("Set offline",contextName),1); |
288 | } | 287 | } |
289 | else | 288 | else |
290 | { | 289 | { |
291 | m->insertItem(QObject::tr("Set online",contextName),1); | 290 | m->insertItem(QObject::tr("Set online",contextName),1); |
292 | } | 291 | } |
293 | } | 292 | } |
294 | return m; | 293 | return m; |
295 | } | 294 | } |
296 | 295 | ||
297 | void NNTPviewItem::disconnect() | 296 | void NNTPviewItem::disconnect() |
298 | { | 297 | { |
299 | QListViewItem *child = firstChild(); | 298 | QListViewItem *child = firstChild(); |
300 | while ( child ) | 299 | while ( child ) |
301 | { | 300 | { |
302 | QListViewItem *tmp = child; | 301 | QListViewItem *tmp = child; |
303 | child = child->nextSibling(); | 302 | child = child->nextSibling(); |
304 | delete tmp; | 303 | delete tmp; |
305 | } | 304 | } |
306 | wrapper->logout(); | 305 | wrapper->logout(); |
307 | } | 306 | } |
308 | 307 | ||
309 | void NNTPviewItem::setOnOffline() | 308 | void NNTPviewItem::setOnOffline() |
310 | { | 309 | { |
311 | if (!account->getOffline()) | 310 | if (!account->getOffline()) |
312 | { | 311 | { |
313 | disconnect(); | 312 | disconnect(); |
314 | } | 313 | } |
315 | account->setOffline(!account->getOffline()); | 314 | account->setOffline(!account->getOffline()); |
316 | account->save(); | 315 | account->save(); |
317 | //FIXME | 316 | //FIXME |
318 | SETPIX(PIXMAP_POP3FOLDER); | 317 | SETPIX(PIXMAP_POP3FOLDER); |
319 | refresh(); | 318 | refresh(); |
320 | } | 319 | } |
321 | 320 | ||
322 | void NNTPviewItem::contextMenuSelected(int which) | 321 | void NNTPviewItem::contextMenuSelected(int which) |
323 | { | 322 | { |
324 | switch (which) | 323 | switch (which) |
325 | { | 324 | { |
326 | case 0: | 325 | case 0: |
327 | disconnect(); | 326 | disconnect(); |
328 | break; | 327 | break; |
329 | case 1: | 328 | case 1: |
330 | setOnOffline(); | 329 | setOnOffline(); |
331 | break; | 330 | break; |
332 | } | 331 | } |
333 | } | 332 | } |
334 | 333 | ||
335 | NNTPfolderItem::~NNTPfolderItem() | 334 | NNTPfolderItem::~NNTPfolderItem() |
336 | {} | 335 | {} |
337 | 336 | ||
338 | NNTPfolderItem::NNTPfolderItem( Folder *folderInit, NNTPviewItem *parent , QListViewItem*after ) | 337 | NNTPfolderItem::NNTPfolderItem( Folder *folderInit, NNTPviewItem *parent , QListViewItem*after ) |
339 | : AccountViewItem( parent,after ) | 338 | : AccountViewItem( parent,after ) |
340 | { | 339 | { |
341 | folder = folderInit; | 340 | folder = folderInit; |
342 | nntp = parent; | 341 | nntp = parent; |
343 | if (folder->getDisplayName().lower()!="inbox") | 342 | if (folder->getDisplayName().lower()!="inbox") |
344 | { | 343 | { |
345 | setPixmap( 0, PIXMAP_POP3FOLDER ); | 344 | setPixmap( 0, PIXMAP_POP3FOLDER ); |
346 | } | 345 | } |
347 | else | 346 | else |
348 | { | 347 | { |
349 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 348 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
350 | } | 349 | } |
351 | setText( 0, folder->getDisplayName() ); | 350 | setText( 0, folder->getDisplayName() ); |
352 | } | 351 | } |
353 | 352 | ||
354 | void NNTPfolderItem::refresh(QList<RecMail>&target) | 353 | void NNTPfolderItem::refresh(QList<RecMail>&target) |
355 | { | 354 | { |
356 | if (folder->may_select()) | 355 | if (folder->may_select()) |
357 | nntp->getWrapper()->listMessages( folder->getName(),target ); | 356 | nntp->getWrapper()->listMessages( folder->getName(),target ); |
358 | } | 357 | } |
359 | 358 | ||
360 | RecBody NNTPfolderItem::fetchBody(const RecMail&aMail) | 359 | RecBody NNTPfolderItem::fetchBody(const RecMail&aMail) |
361 | { | 360 | { |
362 | return nntp->getWrapper()->fetchBody(aMail); | 361 | return nntp->getWrapper()->fetchBody(aMail); |
363 | } | 362 | } |
364 | 363 | ||
365 | QPopupMenu * NNTPfolderItem::getContextMenu() | 364 | QPopupMenu * NNTPfolderItem::getContextMenu() |
366 | { | 365 | { |
367 | QPopupMenu *m = new QPopupMenu(0); | 366 | QPopupMenu *m = new QPopupMenu(0); |
368 | if (m) | 367 | if (m) |
369 | { | 368 | { |
370 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 369 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
371 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),1); | 370 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),1); |
372 | } | 371 | } |
373 | return m; | 372 | return m; |
374 | } | 373 | } |
375 | 374 | ||
376 | void NNTPfolderItem::downloadMails() | 375 | void NNTPfolderItem::downloadMails() |
377 | { | 376 | { |
378 | AccountView*bl = nntp->accountView(); | 377 | AccountView*bl = nntp->accountView(); |
379 | if (!bl) return; | 378 | if (!bl) return; |
380 | bl->downloadMails(folder,nntp->getWrapper()); | 379 | bl->downloadMails(folder,nntp->getWrapper()); |
381 | } | 380 | } |
382 | 381 | ||
383 | void NNTPfolderItem::contextMenuSelected(int which) | 382 | void NNTPfolderItem::contextMenuSelected(int which) |
384 | { | 383 | { |
385 | AccountView * view = (AccountView*)listView(); | 384 | AccountView * view = (AccountView*)listView(); |
386 | switch (which) | 385 | switch (which) |
387 | { | 386 | { |
388 | case 0: | 387 | case 0: |
389 | /* must be 'cause pop3 lists are cached */ | 388 | /* must be 'cause pop3 lists are cached */ |
390 | nntp->getWrapper()->logout(); | 389 | nntp->getWrapper()->logout(); |
391 | view->refreshCurrent(); | 390 | view->refreshCurrent(); |
392 | break; | 391 | break; |
393 | case 1: | 392 | case 1: |
394 | downloadMails(); | 393 | downloadMails(); |
395 | break; | 394 | break; |
396 | default: | 395 | default: |
397 | break; | 396 | break; |
398 | } | 397 | } |
399 | } | 398 | } |
400 | 399 | ||
401 | /** | 400 | /** |
402 | * IMAP Account stuff | 401 | * IMAP Account stuff |
403 | */ | 402 | */ |
404 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) | 403 | IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) |
405 | : AccountViewItem( parent ) | 404 | : AccountViewItem( parent ) |
406 | { | 405 | { |
407 | account = a; | 406 | account = a; |
408 | wrapper = AbstractMail::getWrapper( account ); | 407 | wrapper = AbstractMail::getWrapper( account ); |
409 | SETPIX(PIXMAP_IMAPFOLDER); | 408 | SETPIX(PIXMAP_IMAPFOLDER); |
410 | setText( 0, account->getAccountName() ); | 409 | setText( 0, account->getAccountName() ); |
411 | setOpen( true ); | 410 | setOpen( true ); |
412 | } | 411 | } |
413 | 412 | ||
414 | IMAPviewItem::~IMAPviewItem() | 413 | IMAPviewItem::~IMAPviewItem() |
415 | { | 414 | { |
416 | delete wrapper; | 415 | delete wrapper; |
417 | } | 416 | } |
418 | 417 | ||
419 | AbstractMail *IMAPviewItem::getWrapper() | 418 | AbstractMail *IMAPviewItem::getWrapper() |
420 | { | 419 | { |
421 | return wrapper; | 420 | return wrapper; |
422 | } | 421 | } |
423 | 422 | ||
424 | void IMAPviewItem::refresh(QList<RecMail>&) | 423 | void IMAPviewItem::refresh(QList<RecMail>&) |
425 | { | 424 | { |
426 | refreshFolders(false); | 425 | refreshFolders(false); |
427 | } | 426 | } |
428 | 427 | ||
429 | const QStringList&IMAPviewItem::subFolders() | 428 | const QStringList&IMAPviewItem::subFolders() |
430 | { | 429 | { |
431 | return currentFolders; | 430 | return currentFolders; |
432 | } | 431 | } |
433 | 432 | ||
434 | void IMAPviewItem::refreshFolders(bool force) | 433 | void IMAPviewItem::refreshFolders(bool force) |
435 | { | 434 | { |
436 | if (childCount()>0 && force==false) return; | 435 | if (childCount()>0 && force==false) return; |
437 | if (account->getOffline()) return; | 436 | if (account->getOffline()) return; |
438 | 437 | ||
439 | removeChilds(); | 438 | removeChilds(); |
440 | currentFolders.clear(); | 439 | currentFolders.clear(); |
441 | QList<Folder> *folders = wrapper->listFolders(); | 440 | QList<Folder> *folders = wrapper->listFolders(); |
442 | 441 | ||
443 | Folder *it; | 442 | Folder *it; |
444 | QListViewItem*item = 0; | 443 | QListViewItem*item = 0; |
445 | QListViewItem*titem = 0; | 444 | QListViewItem*titem = 0; |
446 | QString fname,del,search; | 445 | QString fname,del,search; |
447 | int pos; | 446 | int pos; |
448 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 447 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
449 | folders->setAutoDelete(false); | 448 | folders->setAutoDelete(false); |
450 | 449 | ||
451 | for ( it = folders->first(); it; it = folders->next() ) | 450 | for ( it = folders->first(); it; it = folders->next() ) |
452 | { | 451 | { |
453 | if (it->getDisplayName().lower()=="inbox") | 452 | if (it->getDisplayName().lower()=="inbox") |
454 | { | 453 | { |
455 | item = new IMAPfolderItem( it, this , item ); | 454 | item = new IMAPfolderItem( it, this , item ); |
456 | folders->remove(it); | 455 | folders->remove(it); |
457 | qDebug("inbox found"); | 456 | qDebug("inbox found"); |
458 | break; | 457 | break; |
459 | } | 458 | } |
460 | } | 459 | } |
461 | for ( it = folders->first(); it; it = folders->next() ) | 460 | for ( it = folders->first(); it; it = folders->next() ) |
462 | { | 461 | { |
463 | fname = it->getDisplayName(); | 462 | fname = it->getDisplayName(); |
464 | currentFolders.append(it->getName()); | 463 | currentFolders.append(it->getName()); |
465 | pos = fname.findRev(it->Separator()); | 464 | pos = fname.findRev(it->Separator()); |
466 | if (pos != -1) | 465 | if (pos != -1) |
467 | { | 466 | { |
468 | fname = fname.left(pos); | 467 | fname = fname.left(pos); |
469 | } | 468 | } |
470 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); | 469 | IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); |
471 | if (pitem) | 470 | if (pitem) |
472 | { | 471 | { |
473 | titem = item; | 472 | titem = item; |
474 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); | 473 | item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); |
475 | /* setup the short name */ | 474 | /* setup the short name */ |
476 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); | 475 | item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); |
477 | item = titem; | 476 | item = titem; |
478 | } | 477 | } |
479 | else | 478 | else |
480 | { | 479 | { |
481 | item = new IMAPfolderItem( it, this , item ); | 480 | item = new IMAPfolderItem( it, this , item ); |
482 | } | 481 | } |
483 | } | 482 | } |
484 | delete folders; | 483 | delete folders; |
485 | } | 484 | } |
486 | 485 | ||
487 | QPopupMenu * IMAPviewItem::getContextMenu() | 486 | QPopupMenu * IMAPviewItem::getContextMenu() |
488 | { | 487 | { |
489 | QPopupMenu *m = new QPopupMenu(0); | 488 | QPopupMenu *m = new QPopupMenu(0); |
490 | if (m) | 489 | if (m) |
491 | { | 490 | { |
492 | if (!account->getOffline()) | 491 | if (!account->getOffline()) |
493 | { | 492 | { |
494 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 493 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
495 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 494 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
496 | m->insertSeparator(); | 495 | m->insertSeparator(); |
497 | m->insertItem(QObject::tr("Disconnect",contextName),2); | 496 | m->insertItem(QObject::tr("Disconnect",contextName),2); |
498 | m->insertItem(QObject::tr("Set offline",contextName),3); | 497 | m->insertItem(QObject::tr("Set offline",contextName),3); |
499 | } | 498 | } |
500 | else | 499 | else |
501 | { | 500 | { |
502 | m->insertItem(QObject::tr("Set online",contextName),3); | 501 | m->insertItem(QObject::tr("Set online",contextName),3); |
503 | } | 502 | } |
504 | } | 503 | } |
505 | return m; | 504 | return m; |
506 | } | 505 | } |
507 | 506 | ||
508 | void IMAPviewItem::createNewFolder() | 507 | void IMAPviewItem::createNewFolder() |
509 | { | 508 | { |
510 | Newmdirdlg ndirdlg; | 509 | Newmdirdlg ndirdlg; |
511 | if ( QPEApplication::execDialog( &ndirdlg )) | 510 | if ( QPEApplication::execDialog( &ndirdlg )) |
512 | { | 511 | { |
513 | QString ndir = ndirdlg.Newdir(); | 512 | QString ndir = ndirdlg.Newdir(); |
514 | bool makesubs = ndirdlg.subpossible(); | 513 | bool makesubs = ndirdlg.subpossible(); |
515 | QString delemiter = "/"; | 514 | QString delemiter = "/"; |
516 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); | 515 | IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); |
517 | if (item) | 516 | if (item) |
518 | { | 517 | { |
519 | delemiter = item->Delemiter(); | 518 | delemiter = item->Delemiter(); |
520 | } | 519 | } |
521 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) | 520 | if (wrapper->createMbox(ndir,0,delemiter,makesubs)) |
522 | { | 521 | { |
523 | refreshFolders(true); | 522 | refreshFolders(true); |
524 | } | 523 | } |
525 | } | 524 | } |
526 | } | 525 | } |
527 | 526 | ||
528 | void IMAPviewItem::contextMenuSelected(int id) | 527 | void IMAPviewItem::contextMenuSelected(int id) |
529 | { | 528 | { |
530 | qDebug("Id selected: %i",id); | 529 | qDebug("Id selected: %i",id); |
531 | switch (id) | 530 | switch (id) |
532 | { | 531 | { |
533 | case 0: | 532 | case 0: |
534 | refreshFolders(true); | 533 | refreshFolders(true); |
535 | break; | 534 | break; |
536 | case 1: | 535 | case 1: |
537 | createNewFolder(); | 536 | createNewFolder(); |
538 | break; | 537 | break; |
539 | case 2: | 538 | case 2: |
540 | removeChilds(); | 539 | removeChilds(); |
541 | wrapper->logout(); | 540 | wrapper->logout(); |
542 | break; | 541 | break; |
543 | case 3: | 542 | case 3: |
544 | if (account->getOffline()==false) | 543 | if (account->getOffline()==false) |
545 | { | 544 | { |
546 | removeChilds(); | 545 | removeChilds(); |
547 | wrapper->logout(); | 546 | wrapper->logout(); |
548 | } | 547 | } |
549 | account->setOffline(!account->getOffline()); | 548 | account->setOffline(!account->getOffline()); |
550 | account->save(); | 549 | account->save(); |
551 | SETPIX(PIXMAP_IMAPFOLDER); | 550 | SETPIX(PIXMAP_IMAPFOLDER); |
552 | refreshFolders(false); | 551 | refreshFolders(false); |
553 | break; | 552 | break; |
554 | default: | 553 | default: |
555 | break; | 554 | break; |
556 | } | 555 | } |
557 | } | 556 | } |
558 | 557 | ||
559 | RecBody IMAPviewItem::fetchBody(const RecMail&) | 558 | RecBody IMAPviewItem::fetchBody(const RecMail&) |
560 | { | 559 | { |
561 | return RecBody(); | 560 | return RecBody(); |
562 | } | 561 | } |
563 | 562 | ||
564 | bool IMAPviewItem::offline() | 563 | bool IMAPviewItem::offline() |
565 | { | 564 | { |
566 | return account->getOffline(); | 565 | return account->getOffline(); |
567 | } | 566 | } |
568 | 567 | ||
569 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) | 568 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) |
570 | : AccountViewItem( parent , after ) | 569 | : AccountViewItem( parent , after ) |
571 | { | 570 | { |
572 | folder = folderInit; | 571 | folder = folderInit; |
573 | imap = parent; | 572 | imap = parent; |
574 | if (folder->getDisplayName().lower()!="inbox") | 573 | if (folder->getDisplayName().lower()!="inbox") |
575 | { | 574 | { |
576 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 575 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
577 | } | 576 | } |
578 | else | 577 | else |
579 | { | 578 | { |
580 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 579 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
581 | } | 580 | } |
582 | setText( 0, folder->getDisplayName() ); | 581 | setText( 0, folder->getDisplayName() ); |
583 | } | 582 | } |
584 | 583 | ||
585 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) | 584 | IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) |
586 | : AccountViewItem( parent,after ) | 585 | : AccountViewItem( parent,after ) |
587 | { | 586 | { |
588 | folder = folderInit; | 587 | folder = folderInit; |
589 | imap = master; | 588 | imap = master; |
590 | if (folder->getDisplayName().lower()!="inbox") | 589 | if (folder->getDisplayName().lower()!="inbox") |
591 | { | 590 | { |
592 | setPixmap( 0, PIXMAP_IMAPFOLDER ); | 591 | setPixmap( 0, PIXMAP_IMAPFOLDER ); |
593 | } | 592 | } |
594 | else | 593 | else |
595 | { | 594 | { |
596 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 595 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
597 | } | 596 | } |
598 | setText( 0, folder->getDisplayName() ); | 597 | setText( 0, folder->getDisplayName() ); |
599 | } | 598 | } |
600 | 599 | ||
601 | IMAPfolderItem::~IMAPfolderItem() | 600 | IMAPfolderItem::~IMAPfolderItem() |
602 | {} | 601 | {} |
603 | 602 | ||
604 | const QString& IMAPfolderItem::Delemiter()const | 603 | const QString& IMAPfolderItem::Delemiter()const |
605 | { | 604 | { |
606 | return folder->Separator(); | 605 | return folder->Separator(); |
607 | } | 606 | } |
608 | 607 | ||
609 | void IMAPfolderItem::refresh(QList<RecMail>&target) | 608 | void IMAPfolderItem::refresh(QList<RecMail>&target) |
610 | { | 609 | { |
611 | if (folder->may_select()) | 610 | if (folder->may_select()) |
612 | { | 611 | { |
613 | imap->getWrapper()->listMessages( folder->getName(),target ); | 612 | imap->getWrapper()->listMessages( folder->getName(),target ); |
614 | } | 613 | } |
615 | else | 614 | else |
616 | { | 615 | { |
617 | target.clear(); | 616 | target.clear(); |
618 | } | 617 | } |
619 | } | 618 | } |
620 | 619 | ||
621 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) | 620 | RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) |
622 | { | 621 | { |
623 | return imap->getWrapper()->fetchBody(aMail); | 622 | return imap->getWrapper()->fetchBody(aMail); |
624 | } | 623 | } |
625 | 624 | ||
626 | QPopupMenu * IMAPfolderItem::getContextMenu() | 625 | QPopupMenu * IMAPfolderItem::getContextMenu() |
627 | { | 626 | { |
628 | QPopupMenu *m = new QPopupMenu(0); | 627 | QPopupMenu *m = new QPopupMenu(0); |
629 | if (m) | 628 | if (m) |
630 | { | 629 | { |
631 | if (folder->may_select()) | 630 | if (folder->may_select()) |
632 | { | 631 | { |
633 | m->insertItem(QObject::tr("Refresh header list",contextName),0); | 632 | m->insertItem(QObject::tr("Refresh header list",contextName),0); |
634 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); | 633 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); |
635 | m->insertItem(QObject::tr("Delete all mails",contextName),1); | 634 | m->insertItem(QObject::tr("Delete all mails",contextName),1); |
636 | } | 635 | } |
637 | if (folder->no_inferior()==false) | 636 | if (folder->no_inferior()==false) |
638 | { | 637 | { |
639 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); | 638 | m->insertItem(QObject::tr("Create new subfolder",contextName),2); |
640 | } | 639 | } |
641 | if (folder->getDisplayName().lower()!="inbox") | 640 | if (folder->getDisplayName().lower()!="inbox") |
642 | { | 641 | { |
643 | m->insertItem(QObject::tr("Delete folder",contextName),3); | 642 | m->insertItem(QObject::tr("Delete folder",contextName),3); |
644 | } | 643 | } |
645 | } | 644 | } |
646 | return m; | 645 | return m; |
647 | } | 646 | } |
648 | 647 | ||
649 | void IMAPfolderItem::createNewFolder() | 648 | void IMAPfolderItem::createNewFolder() |
650 | { | 649 | { |
651 | Newmdirdlg ndirdlg; | 650 | Newmdirdlg ndirdlg; |
652 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 651 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
653 | { | 652 | { |
654 | QString ndir = ndirdlg.Newdir(); | 653 | QString ndir = ndirdlg.Newdir(); |
655 | bool makesubs = ndirdlg.subpossible(); | 654 | bool makesubs = ndirdlg.subpossible(); |
656 | QString delemiter = Delemiter(); | 655 | QString delemiter = Delemiter(); |
657 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) | 656 | if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) |
658 | { | 657 | { |
659 | imap->refreshFolders(true); | 658 | imap->refreshFolders(true); |
660 | } | 659 | } |
661 | } | 660 | } |
662 | } | 661 | } |
663 | 662 | ||
664 | void IMAPfolderItem::deleteFolder() | 663 | void IMAPfolderItem::deleteFolder() |
665 | { | 664 | { |
666 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 665 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
667 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 666 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
668 | QObject::tr("Yes",contextName), | 667 | QObject::tr("Yes",contextName), |
669 | QObject::tr("No",contextName),QString::null,1,1); | 668 | QObject::tr("No",contextName),QString::null,1,1); |
670 | qDebug("Auswahl: %i",yesno); | 669 | qDebug("Auswahl: %i",yesno); |
671 | if (yesno == 0) | 670 | if (yesno == 0) |
672 | { | 671 | { |
673 | if (imap->getWrapper()->deleteMbox(folder)) | 672 | if (imap->getWrapper()->deleteMbox(folder)) |
674 | { | 673 | { |
675 | QListView*v=listView(); | 674 | QListView*v=listView(); |
676 | IMAPviewItem * box = imap; | 675 | IMAPviewItem * box = imap; |
677 | /* be carefull - after that this object is destroyd so don't use | 676 | /* be carefull - after that this object is destroyd so don't use |
678 | * any member of it after that call!!*/ | 677 | * any member of it after that call!!*/ |
679 | imap->refreshFolders(true); | 678 | imap->refreshFolders(true); |
680 | if (v) | 679 | if (v) |
681 | { | 680 | { |
682 | v->setSelected(box,true); | 681 | v->setSelected(box,true); |
683 | } | 682 | } |
684 | } | 683 | } |
685 | } | 684 | } |
686 | } | 685 | } |
687 | 686 | ||
688 | void IMAPfolderItem::downloadMails() | 687 | void IMAPfolderItem::downloadMails() |
689 | { | 688 | { |
690 | AccountView*bl = imap->accountView(); | 689 | AccountView*bl = imap->accountView(); |
691 | if (!bl) return; | 690 | if (!bl) return; |
692 | bl->downloadMails(folder,imap->getWrapper()); | 691 | bl->downloadMails(folder,imap->getWrapper()); |
693 | } | 692 | } |
694 | 693 | ||
695 | void IMAPfolderItem::contextMenuSelected(int id) | 694 | void IMAPfolderItem::contextMenuSelected(int id) |
696 | { | 695 | { |
697 | qDebug("Selected id: %i",id); | 696 | qDebug("Selected id: %i",id); |
698 | AccountView * view = (AccountView*)listView(); | 697 | AccountView * view = (AccountView*)listView(); |
699 | switch(id) | 698 | switch(id) |
700 | { | 699 | { |
701 | case 0: | 700 | case 0: |
702 | view->refreshCurrent(); | 701 | view->refreshCurrent(); |
703 | break; | 702 | break; |
704 | case 1: | 703 | case 1: |
705 | deleteAllMail(imap->getWrapper(),folder); | 704 | deleteAllMail(imap->getWrapper(),folder); |
706 | break; | 705 | break; |
707 | case 2: | 706 | case 2: |
708 | createNewFolder(); | 707 | createNewFolder(); |
709 | break; | 708 | break; |
710 | case 3: | 709 | case 3: |
711 | deleteFolder(); | 710 | deleteFolder(); |
712 | break; | 711 | break; |
713 | case 4: | 712 | case 4: |
714 | downloadMails(); | 713 | downloadMails(); |
715 | break; | 714 | break; |
716 | default: | 715 | default: |
717 | break; | 716 | break; |
718 | } | 717 | } |
719 | } | 718 | } |
720 | 719 | ||
721 | /** | 720 | /** |
722 | * MH Account stuff | 721 | * MH Account stuff |
723 | */ | 722 | */ |
724 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and | 723 | /* MH is a little bit different - the top folder can contains messages other than in IMAP and |
725 | POP3 and MBOX */ | 724 | POP3 and MBOX */ |
726 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) | 725 | MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) |
727 | : AccountViewItem( parent ) | 726 | : AccountViewItem( parent ) |
728 | { | 727 | { |
729 | m_Path = aPath; | 728 | m_Path = aPath; |
730 | /* be carefull - the space within settext is wanted - thats why the string twice */ | 729 | /* be carefull - the space within settext is wanted - thats why the string twice */ |
731 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); | 730 | wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); |
732 | setPixmap( 0, PIXMAP_LOCALFOLDER ); | 731 | setPixmap( 0, PIXMAP_LOCALFOLDER ); |
733 | setText( 0, " Local Folders" ); | 732 | setText( 0, " Local Folders" ); |
734 | setOpen( true ); | 733 | setOpen( true ); |
735 | folder = 0; | 734 | folder = 0; |
736 | } | 735 | } |
737 | 736 | ||
738 | MHviewItem::~MHviewItem() | 737 | MHviewItem::~MHviewItem() |
739 | { | 738 | { |
740 | delete wrapper; | 739 | delete wrapper; |
741 | } | 740 | } |
742 | 741 | ||
743 | AbstractMail *MHviewItem::getWrapper() | 742 | AbstractMail *MHviewItem::getWrapper() |
744 | { | 743 | { |
745 | return wrapper; | 744 | return wrapper; |
746 | } | 745 | } |
747 | 746 | ||
748 | void MHviewItem::refresh( QList<RecMail> & target) | 747 | void MHviewItem::refresh( QList<RecMail> & target) |
749 | { | 748 | { |
750 | refresh(false); | 749 | refresh(false); |
751 | getWrapper()->listMessages( "",target ); | 750 | getWrapper()->listMessages( "",target ); |
752 | } | 751 | } |
753 | 752 | ||
754 | void MHviewItem::refresh(bool force) | 753 | void MHviewItem::refresh(bool force) |
755 | { | 754 | { |
756 | if (childCount()>0 && force==false) return; | 755 | if (childCount()>0 && force==false) return; |
757 | removeChilds(); | 756 | removeChilds(); |
758 | currentFolders.clear(); | 757 | currentFolders.clear(); |
759 | QList<Folder> *folders = wrapper->listFolders(); | 758 | QList<Folder> *folders = wrapper->listFolders(); |
760 | Folder *it; | 759 | Folder *it; |
761 | MHfolderItem*item = 0; | 760 | MHfolderItem*item = 0; |
762 | MHfolderItem*pmaster = 0; | 761 | MHfolderItem*pmaster = 0; |
763 | QString fname = ""; | 762 | QString fname = ""; |
764 | int pos; | 763 | int pos; |
765 | for ( it = folders->first(); it; it = folders->next() ) | 764 | for ( it = folders->first(); it; it = folders->next() ) |
766 | { | 765 | { |
767 | fname = it->getDisplayName(); | 766 | fname = it->getDisplayName(); |
768 | /* this folder itself */ | 767 | /* this folder itself */ |
769 | if (fname=="/") | 768 | if (fname=="/") |
770 | { | 769 | { |
771 | currentFolders.append(fname); | 770 | currentFolders.append(fname); |
772 | folder = it; | 771 | folder = it; |
773 | continue; | 772 | continue; |
774 | } | 773 | } |
775 | currentFolders.append(fname); | 774 | currentFolders.append(fname); |
776 | pos = fname.findRev("/"); | 775 | pos = fname.findRev("/"); |
777 | if (pos > 0) | 776 | if (pos > 0) |
778 | { | 777 | { |
779 | fname = fname.left(pos); | 778 | fname = fname.left(pos); |
780 | pmaster = (MHfolderItem*)findSubItem(fname); | 779 | pmaster = (MHfolderItem*)findSubItem(fname); |
781 | } | 780 | } |
782 | else | 781 | else |
783 | { | 782 | { |
784 | pmaster = 0; | 783 | pmaster = 0; |
785 | } | 784 | } |
786 | if (pmaster) | 785 | if (pmaster) |
787 | { | 786 | { |
788 | item = new MHfolderItem( it, pmaster, item, this ); | 787 | item = new MHfolderItem( it, pmaster, item, this ); |
789 | } | 788 | } |
790 | else | 789 | else |
791 | { | 790 | { |
792 | item = new MHfolderItem( it, this , item ); | 791 | item = new MHfolderItem( it, this , item ); |
793 | } | 792 | } |
794 | item->setSelectable(it->may_select()); | 793 | item->setSelectable(it->may_select()); |
795 | } | 794 | } |
796 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | 795 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
797 | folders->setAutoDelete(false); | 796 | folders->setAutoDelete(false); |
798 | delete folders; | 797 | delete folders; |
799 | } | 798 | } |
800 | 799 | ||
801 | RecBody MHviewItem::fetchBody( const RecMail &mail ) | 800 | RecBody MHviewItem::fetchBody( const RecMail &mail ) |
802 | { | 801 | { |
803 | qDebug( "MH fetchBody" ); | 802 | qDebug( "MH fetchBody" ); |
804 | return wrapper->fetchBody( mail ); | 803 | return wrapper->fetchBody( mail ); |
805 | } | 804 | } |
806 | 805 | ||
807 | QPopupMenu * MHviewItem::getContextMenu() | 806 | QPopupMenu * MHviewItem::getContextMenu() |
808 | { | 807 | { |
809 | QPopupMenu *m = new QPopupMenu(0); | 808 | QPopupMenu *m = new QPopupMenu(0); |
810 | if (m) | 809 | if (m) |
811 | { | 810 | { |
812 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); | 811 | m->insertItem(QObject::tr("Refresh folder list",contextName),0); |
813 | m->insertItem(QObject::tr("Create new folder",contextName),1); | 812 | m->insertItem(QObject::tr("Create new folder",contextName),1); |
814 | m->insertItem(QObject::tr("Delete all mails",contextName),2); | 813 | m->insertItem(QObject::tr("Delete all mails",contextName),2); |
815 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); | 814 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); |
816 | } | 815 | } |
817 | return m; | 816 | return m; |
818 | } | 817 | } |
819 | 818 | ||
820 | void MHviewItem::createFolder() | 819 | void MHviewItem::createFolder() |
821 | { | 820 | { |
822 | Newmdirdlg ndirdlg(0,0,true); | 821 | Newmdirdlg ndirdlg(0,0,true); |
823 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 822 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
824 | { | 823 | { |
825 | QString ndir = ndirdlg.Newdir(); | 824 | QString ndir = ndirdlg.Newdir(); |
826 | if (wrapper->createMbox(ndir)) | 825 | if (wrapper->createMbox(ndir)) |
827 | { | 826 | { |
828 | refresh(true); | 827 | refresh(true); |
829 | } | 828 | } |
830 | } | 829 | } |
831 | } | 830 | } |
832 | 831 | ||
833 | void MHviewItem::downloadMails() | 832 | void MHviewItem::downloadMails() |
834 | { | 833 | { |
835 | AccountView*bl = accountView(); | 834 | AccountView*bl = accountView(); |
836 | if (!bl) return; | 835 | if (!bl) return; |
837 | bl->downloadMails(folder,getWrapper()); | 836 | bl->downloadMails(folder,getWrapper()); |
838 | } | 837 | } |
839 | 838 | ||
840 | QStringList MHviewItem::subFolders() | 839 | QStringList MHviewItem::subFolders() |
841 | { | 840 | { |
842 | return currentFolders; | 841 | return currentFolders; |
843 | } | 842 | } |
844 | 843 | ||
845 | void MHviewItem::contextMenuSelected(int which) | 844 | void MHviewItem::contextMenuSelected(int which) |
846 | { | 845 | { |
847 | switch (which) | 846 | switch (which) |
848 | { | 847 | { |
849 | case 0: | 848 | case 0: |
850 | refresh(true); | 849 | refresh(true); |
851 | break; | 850 | break; |
852 | case 1: | 851 | case 1: |
853 | createFolder(); | 852 | createFolder(); |
854 | break; | 853 | break; |
855 | case 2: | 854 | case 2: |
856 | deleteAllMail(getWrapper(),folder); | 855 | deleteAllMail(getWrapper(),folder); |
857 | break; | 856 | break; |
858 | case 3: | 857 | case 3: |
859 | downloadMails(); | 858 | downloadMails(); |
860 | break; | 859 | break; |
861 | default: | 860 | default: |
862 | break; | 861 | break; |
863 | } | 862 | } |
864 | } | 863 | } |
865 | 864 | ||
866 | MHfolderItem::~MHfolderItem() | 865 | MHfolderItem::~MHfolderItem() |
867 | {} | 866 | {} |
868 | 867 | ||
869 | MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) | 868 | MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) |
870 | : AccountViewItem( parent,after ) | 869 | : AccountViewItem( parent,after ) |
871 | { | 870 | { |
872 | folder = folderInit; | 871 | folder = folderInit; |
873 | mbox = parent; | 872 | mbox = parent; |
874 | initName(); | 873 | initName(); |
875 | } | 874 | } |
876 | 875 | ||
877 | MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) | 876 | MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) |
878 | : AccountViewItem( parent,after ) | 877 | : AccountViewItem( parent,after ) |
879 | { | 878 | { |
880 | folder = folderInit; | 879 | folder = folderInit; |
881 | mbox = master; | 880 | mbox = master; |
882 | initName(); | 881 | initName(); |
883 | } | 882 | } |
884 | 883 | ||
885 | void MHfolderItem::initName() | 884 | void MHfolderItem::initName() |
886 | { | 885 | { |
887 | QString bName = folder->getDisplayName(); | 886 | QString bName = folder->getDisplayName(); |
888 | if (bName.startsWith("/")&&bName.length()>1) | 887 | if (bName.startsWith("/")&&bName.length()>1) |
889 | { | 888 | { |
890 | bName.replace(0,1,""); | 889 | bName.replace(0,1,""); |
891 | } | 890 | } |
892 | int pos = bName.findRev("/"); | 891 | int pos = bName.findRev("/"); |
893 | if (pos > 0) | 892 | if (pos > 0) |
894 | { | 893 | { |
895 | bName.replace(0,pos+1,""); | 894 | bName.replace(0,pos+1,""); |
896 | } | 895 | } |
897 | if (bName.lower() == "outgoing") | 896 | if (bName.lower() == "outgoing") |
898 | { | 897 | { |
899 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); | 898 | setPixmap( 0, PIXMAP_OUTBOXFOLDER ); |
900 | } | 899 | } |
901 | else if (bName.lower() == "inbox") | 900 | else if (bName.lower() == "inbox") |
902 | { | 901 | { |
903 | setPixmap( 0, PIXMAP_INBOXFOLDER); | 902 | setPixmap( 0, PIXMAP_INBOXFOLDER); |
904 | } | 903 | } |
905 | else | 904 | else |
906 | { | 905 | { |
907 | setPixmap( 0, PIXMAP_MBOXFOLDER ); | 906 | setPixmap( 0, PIXMAP_MBOXFOLDER ); |
908 | } | 907 | } |
909 | setText( 0, bName ); | 908 | setText( 0, bName ); |
910 | } | 909 | } |
911 | 910 | ||
912 | Folder*MHfolderItem::getFolder() | 911 | Folder*MHfolderItem::getFolder() |
913 | { | 912 | { |
914 | return folder; | 913 | return folder; |
915 | } | 914 | } |
916 | 915 | ||
917 | void MHfolderItem::refresh(QList<RecMail>&target) | 916 | void MHfolderItem::refresh(QList<RecMail>&target) |
918 | { | 917 | { |
919 | if (folder->may_select()) | 918 | if (folder->may_select()) |
920 | mbox->getWrapper()->listMessages( folder->getName(),target ); | 919 | mbox->getWrapper()->listMessages( folder->getName(),target ); |
921 | } | 920 | } |
922 | 921 | ||
923 | RecBody MHfolderItem::fetchBody(const RecMail&aMail) | 922 | RecBody MHfolderItem::fetchBody(const RecMail&aMail) |
924 | { | 923 | { |
925 | return mbox->getWrapper()->fetchBody(aMail); | 924 | return mbox->getWrapper()->fetchBody(aMail); |
926 | } | 925 | } |
927 | 926 | ||
928 | void MHfolderItem::deleteFolder() | 927 | void MHfolderItem::deleteFolder() |
929 | { | 928 | { |
930 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), | 929 | int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), |
931 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), | 930 | QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), |
932 | QObject::tr("Yes",contextName), | 931 | QObject::tr("Yes",contextName), |
933 | QObject::tr("No",contextName),QString::null,1,1); | 932 | QObject::tr("No",contextName),QString::null,1,1); |
934 | qDebug("Auswahl: %i",yesno); | 933 | qDebug("Auswahl: %i",yesno); |
935 | if (yesno == 0) | 934 | if (yesno == 0) |
936 | { | 935 | { |
937 | if (mbox->getWrapper()->deleteMbox(folder)) | 936 | if (mbox->getWrapper()->deleteMbox(folder)) |
938 | { | 937 | { |
939 | QListView*v=listView(); | 938 | QListView*v=listView(); |
940 | MHviewItem * box = mbox; | 939 | MHviewItem * box = mbox; |
941 | /* be carefull - after that this object is destroyd so don't use | 940 | /* be carefull - after that this object is destroyd so don't use |
942 | * any member of it after that call!!*/ | 941 | * any member of it after that call!!*/ |
943 | mbox->refresh(true); | 942 | mbox->refresh(true); |
944 | if (v) | 943 | if (v) |
945 | { | 944 | { |
946 | v->setSelected(box,true); | 945 | v->setSelected(box,true); |
947 | } | 946 | } |
948 | } | 947 | } |
949 | } | 948 | } |
950 | } | 949 | } |
951 | 950 | ||
952 | QPopupMenu * MHfolderItem::getContextMenu() | 951 | QPopupMenu * MHfolderItem::getContextMenu() |
953 | { | 952 | { |
954 | QPopupMenu *m = new QPopupMenu(0); | 953 | QPopupMenu *m = new QPopupMenu(0); |
955 | if (m) | 954 | if (m) |
956 | { | 955 | { |
957 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); | 956 | m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); |
958 | m->insertItem(QObject::tr("Delete all mails",contextName),0); | 957 | m->insertItem(QObject::tr("Delete all mails",contextName),0); |
959 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); | 958 | m->insertItem(QObject::tr("Create new subfolder",contextName),3); |
960 | m->insertItem(QObject::tr("Delete folder",contextName),1); | 959 | m->insertItem(QObject::tr("Delete folder",contextName),1); |
961 | } | 960 | } |
962 | return m; | 961 | return m; |
963 | } | 962 | } |
964 | 963 | ||
965 | void MHfolderItem::downloadMails() | 964 | void MHfolderItem::downloadMails() |
966 | { | 965 | { |
967 | AccountView*bl = mbox->accountView(); | 966 | AccountView*bl = mbox->accountView(); |
968 | if (!bl) return; | 967 | if (!bl) return; |
969 | bl->downloadMails(folder,mbox->getWrapper()); | 968 | bl->downloadMails(folder,mbox->getWrapper()); |
970 | } | 969 | } |
971 | 970 | ||
972 | void MHfolderItem::createFolder() | 971 | void MHfolderItem::createFolder() |
973 | { | 972 | { |
974 | Newmdirdlg ndirdlg(0,0,true); | 973 | Newmdirdlg ndirdlg(0,0,true); |
975 | if ( QPEApplication::execDialog( &ndirdlg ) ) | 974 | if ( QPEApplication::execDialog( &ndirdlg ) ) |
976 | { | 975 | { |
977 | QString ndir = ndirdlg.Newdir(); | 976 | QString ndir = ndirdlg.Newdir(); |
978 | if (mbox->getWrapper()->createMbox(ndir,folder)) | 977 | if (mbox->getWrapper()->createMbox(ndir,folder)) |
979 | { | 978 | { |
980 | QListView*v=listView(); | 979 | QListView*v=listView(); |
981 | MHviewItem * box = mbox; | 980 | MHviewItem * box = mbox; |
982 | /* be carefull - after that this object is destroyd so don't use | 981 | /* be carefull - after that this object is destroyd so don't use |
983 | * any member of it after that call!!*/ | 982 | * any member of it after that call!!*/ |
984 | mbox->refresh(true); | 983 | mbox->refresh(true); |
985 | if (v) | 984 | if (v) |
986 | { | 985 | { |
987 | v->setSelected(box,true); | 986 | v->setSelected(box,true); |
988 | } | 987 | } |
989 | } | 988 | } |
990 | } | 989 | } |
991 | } | 990 | } |
992 | 991 | ||
993 | void MHfolderItem::contextMenuSelected(int which) | 992 | void MHfolderItem::contextMenuSelected(int which) |
994 | { | 993 | { |
995 | switch(which) | 994 | switch(which) |
996 | { | 995 | { |
997 | case 0: | 996 | case 0: |
998 | deleteAllMail(mbox->getWrapper(),folder); | 997 | deleteAllMail(mbox->getWrapper(),folder); |
999 | break; | 998 | break; |
1000 | case 1: | 999 | case 1: |
1001 | deleteFolder(); | 1000 | deleteFolder(); |
1002 | break; | 1001 | break; |
1003 | case 2: | 1002 | case 2: |
1004 | downloadMails(); | 1003 | downloadMails(); |
1005 | break; | 1004 | break; |
1006 | case 3: | 1005 | case 3: |
1007 | createFolder(); | 1006 | createFolder(); |
1008 | break; | 1007 | break; |
1009 | default: | 1008 | default: |
1010 | break; | 1009 | break; |
1011 | } | 1010 | } |
1012 | } | 1011 | } |
1013 | 1012 | ||
1014 | /** | 1013 | /** |
1015 | * Generic stuff | 1014 | * Generic stuff |
1016 | */ | 1015 | */ |
1017 | 1016 | ||
1018 | const QString AccountViewItem::contextName="AccountViewItem"; | 1017 | const QString AccountViewItem::contextName="AccountViewItem"; |
1019 | 1018 | ||
1020 | AccountViewItem::AccountViewItem( AccountView *parent ) | 1019 | AccountViewItem::AccountViewItem( AccountView *parent ) |
1021 | : QListViewItem( parent ) | 1020 | : QListViewItem( parent ) |
1022 | { | 1021 | { |
1023 | init(); | 1022 | init(); |
1024 | m_Backlink = parent; | 1023 | m_Backlink = parent; |
1025 | } | 1024 | } |
1026 | 1025 | ||
1027 | AccountViewItem::AccountViewItem( QListViewItem *parent) | 1026 | AccountViewItem::AccountViewItem( QListViewItem *parent) |
1028 | : QListViewItem( parent) | 1027 | : QListViewItem( parent) |
1029 | { | 1028 | { |
1030 | init(); | 1029 | init(); |
1031 | } | 1030 | } |
1032 | 1031 | ||
1033 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) | 1032 | AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) |
1034 | :QListViewItem( parent,after ) | 1033 | :QListViewItem( parent,after ) |
1035 | { | 1034 | { |
1036 | init(); | 1035 | init(); |
1037 | } | 1036 | } |
1038 | 1037 | ||
1039 | void AccountViewItem::init() | 1038 | void AccountViewItem::init() |
1040 | { | 1039 | { |
1041 | m_Backlink = 0; | 1040 | m_Backlink = 0; |
1042 | folder = 0; | 1041 | folder = 0; |
1043 | } | 1042 | } |
1044 | 1043 | ||
1045 | AccountViewItem::~AccountViewItem() | 1044 | AccountViewItem::~AccountViewItem() |
1046 | { | 1045 | { |
1047 | if (folder) delete folder; | 1046 | if (folder) delete folder; |
1048 | } | 1047 | } |
1049 | 1048 | ||
1050 | AccountView*AccountViewItem::accountView() | 1049 | AccountView*AccountViewItem::accountView() |
1051 | { | 1050 | { |
1052 | return m_Backlink; | 1051 | return m_Backlink; |
1053 | } | 1052 | } |
1054 | 1053 | ||
1055 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) | 1054 | void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) |
1056 | { | 1055 | { |
1057 | if (!wrapper) return; | 1056 | if (!wrapper) return; |
1058 | QString fname=""; | 1057 | QString fname=""; |
1059 | if (folder) fname = folder->getDisplayName(); | 1058 | if (folder) fname = folder->getDisplayName(); |
1060 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), | 1059 | int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), |
1061 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). | 1060 | QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). |
1062 | arg(fname), | 1061 | arg(fname), |
1063 | QObject::tr("Yes",contextName), | 1062 | QObject::tr("Yes",contextName), |
1064 | QObject::tr("No",contextName),QString::null,1,1); | 1063 | QObject::tr("No",contextName),QString::null,1,1); |
1065 | qDebug("Auswahl: %i",yesno); | 1064 | qDebug("Auswahl: %i",yesno); |
1066 | if (yesno == 0) | 1065 | if (yesno == 0) |
1067 | { | 1066 | { |
1068 | if (wrapper->deleteAllMail(folder)) | 1067 | if (wrapper->deleteAllMail(folder)) |
1069 | { | 1068 | { |
1070 | AccountView * view = (AccountView*)listView(); | 1069 | AccountView * view = (AccountView*)listView(); |
1071 | if (view) view->refreshCurrent(); | 1070 | if (view) view->refreshCurrent(); |
1072 | } | 1071 | } |
1073 | } | 1072 | } |
1074 | } | 1073 | } |
1075 | 1074 | ||
1076 | void AccountViewItem::removeChilds() | 1075 | void AccountViewItem::removeChilds() |
1077 | { | 1076 | { |
1078 | QListViewItem *child = firstChild(); | 1077 | QListViewItem *child = firstChild(); |
1079 | while ( child ) | 1078 | while ( child ) |
1080 | { | 1079 | { |
1081 | QListViewItem *tmp = child; | 1080 | QListViewItem *tmp = child; |
1082 | child = child->nextSibling(); | 1081 | child = child->nextSibling(); |
1083 | delete tmp; | 1082 | delete tmp; |
1084 | } | 1083 | } |
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | bool AccountViewItem::matchName(const QString&name)const | 1086 | bool AccountViewItem::matchName(const QString&name)const |
1088 | { | 1087 | { |
1089 | if (!folder) return false; | 1088 | if (!folder) return false; |
1090 | return folder->getDisplayName()==name; | 1089 | return folder->getDisplayName()==name; |
1091 | } | 1090 | } |
1092 | 1091 | ||
1093 | 1092 | ||
1094 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) | 1093 | AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) |
1095 | { | 1094 | { |
1096 | AccountViewItem*pitem,*sitem; | 1095 | AccountViewItem*pitem,*sitem; |
1097 | if (!start) pitem = (AccountViewItem*)firstChild(); | 1096 | if (!start) pitem = (AccountViewItem*)firstChild(); |
1098 | else pitem = (AccountViewItem*)start->firstChild(); | 1097 | else pitem = (AccountViewItem*)start->firstChild(); |
1099 | while (pitem) | 1098 | while (pitem) |
1100 | { | 1099 | { |
1101 | if (pitem->matchName(path)) | 1100 | if (pitem->matchName(path)) |
1102 | { | 1101 | { |
1103 | break; | 1102 | break; |
1104 | } | 1103 | } |
1105 | if (pitem->childCount()>0) | 1104 | if (pitem->childCount()>0) |
1106 | { | 1105 | { |
1107 | sitem = findSubItem(path,pitem); | 1106 | sitem = findSubItem(path,pitem); |
1108 | if (sitem) | 1107 | if (sitem) |
1109 | { | 1108 | { |
1110 | pitem = sitem; | 1109 | pitem = sitem; |
1111 | break; | 1110 | break; |
1112 | } | 1111 | } |
1113 | } | 1112 | } |
1114 | pitem=(AccountViewItem*)pitem->nextSibling(); | 1113 | pitem=(AccountViewItem*)pitem->nextSibling(); |
1115 | } | 1114 | } |
1116 | return pitem; | 1115 | return pitem; |
1117 | } | 1116 | } |
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp index 35f9cd4..50c82e5 100644 --- a/noncore/net/mail/addresspicker.cpp +++ b/noncore/net/mail/addresspicker.cpp | |||
@@ -1,114 +1,112 @@ | |||
1 | 1 | ||
2 | #include "composemail.h" | 2 | #include "composemail.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <opie2/ocontactaccess.h> | 5 | #include <opie2/ocontactaccess.h> |
6 | #include <opie2/opimcontact.h> | 6 | #include <opie2/opimcontact.h> |
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | 9 | ||
10 | /* QT */ | 10 | /* QT */ |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qtextstream.h> | ||
14 | #include <qlistbox.h> | 13 | #include <qlistbox.h> |
15 | #include <qfile.h> | ||
16 | 14 | ||
17 | /* STD */ | 15 | /* STD */ |
18 | #include <stdlib.h> | 16 | #include <stdlib.h> |
19 | 17 | ||
20 | AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) | 18 | AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags ) |
21 | : AddressPickerUI( parent, name, modal, flags ) | 19 | : AddressPickerUI( parent, name, modal, flags ) |
22 | { | 20 | { |
23 | okButton->setIconSet( Resource::loadPixmap( "enter" ) ); | 21 | okButton->setIconSet( Resource::loadPixmap( "enter" ) ); |
24 | cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); | 22 | cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); |
25 | 23 | ||
26 | connect(okButton, SIGNAL(clicked()), SLOT(accept())); | 24 | connect(okButton, SIGNAL(clicked()), SLOT(accept())); |
27 | connect(cancelButton, SIGNAL(clicked()), SLOT(close())); | 25 | connect(cancelButton, SIGNAL(clicked()), SLOT(close())); |
28 | Opie::OPimContactAccess::List::Iterator it; | 26 | Opie::OPimContactAccess::List::Iterator it; |
29 | 27 | ||
30 | QString lineEmail, lineName, contactLine; | 28 | QString lineEmail, lineName, contactLine; |
31 | /* what name has to set here???? */ | 29 | /* what name has to set here???? */ |
32 | Opie::OPimContactAccess m_contactdb("opiemail"); | 30 | Opie::OPimContactAccess m_contactdb("opiemail"); |
33 | 31 | ||
34 | QStringList mails; | 32 | QStringList mails; |
35 | QString pre,suf; | 33 | QString pre,suf; |
36 | Opie::OPimContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); | 34 | Opie::OPimContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); |
37 | for ( it = m_list.begin(); it != m_list.end(); ++it ) | 35 | for ( it = m_list.begin(); it != m_list.end(); ++it ) |
38 | { | 36 | { |
39 | if ((*it).defaultEmail().length()!=0) | 37 | if ((*it).defaultEmail().length()!=0) |
40 | { | 38 | { |
41 | mails = (*it).emailList(); | 39 | mails = (*it).emailList(); |
42 | if ((*it).fileAs().length()>0) | 40 | if ((*it).fileAs().length()>0) |
43 | { | 41 | { |
44 | pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; | 42 | pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; |
45 | suf = ">"; | 43 | suf = ">"; |
46 | } | 44 | } |
47 | else | 45 | else |
48 | { | 46 | { |
49 | pre = ""; | 47 | pre = ""; |
50 | suf = ""; | 48 | suf = ""; |
51 | } | 49 | } |
52 | QStringList::ConstIterator sit = mails.begin(); | 50 | QStringList::ConstIterator sit = mails.begin(); |
53 | for (;sit!=mails.end();++sit) | 51 | for (;sit!=mails.end();++sit) |
54 | { | 52 | { |
55 | contactLine=pre+(*sit)+suf; | 53 | contactLine=pre+(*sit)+suf; |
56 | addressList->insertItem(contactLine); | 54 | addressList->insertItem(contactLine); |
57 | } | 55 | } |
58 | } | 56 | } |
59 | } | 57 | } |
60 | if ( addressList->count() <= 0 ) | 58 | if ( addressList->count() <= 0 ) |
61 | { | 59 | { |
62 | #if 0 | 60 | #if 0 |
63 | // makes this realy sense?? | 61 | // makes this realy sense?? |
64 | addressList->insertItem( | 62 | addressList->insertItem( |
65 | tr( "There are no entries in the addressbook." ) ); | 63 | tr( "There are no entries in the addressbook." ) ); |
66 | #endif | 64 | #endif |
67 | addressList->setEnabled( false ); | 65 | addressList->setEnabled( false ); |
68 | okButton->setEnabled( false ); | 66 | okButton->setEnabled( false ); |
69 | } | 67 | } |
70 | else | 68 | else |
71 | { | 69 | { |
72 | // addressList->sort(); | 70 | // addressList->sort(); |
73 | } | 71 | } |
74 | } | 72 | } |
75 | 73 | ||
76 | void AddressPicker::accept() | 74 | void AddressPicker::accept() |
77 | { | 75 | { |
78 | QListBoxItem *item = addressList->firstItem(); | 76 | QListBoxItem *item = addressList->firstItem(); |
79 | QString names; | 77 | QString names; |
80 | 78 | ||
81 | while ( item ) | 79 | while ( item ) |
82 | { | 80 | { |
83 | if ( item->selected() ) | 81 | if ( item->selected() ) |
84 | names += item->text() + ", "; | 82 | names += item->text() + ", "; |
85 | item = item->next(); | 83 | item = item->next(); |
86 | } | 84 | } |
87 | names.replace( names.length() - 2, 2, "" ); | 85 | names.replace( names.length() - 2, 2, "" ); |
88 | 86 | ||
89 | if ( names.isEmpty() ) | 87 | if ( names.isEmpty() ) |
90 | { | 88 | { |
91 | QMessageBox::information(this, tr("Error"), tr("<p>You have to select" | 89 | QMessageBox::information(this, tr("Error"), tr("<p>You have to select" |
92 | " at least one address entry.</p>"), tr("Ok")); | 90 | " at least one address entry.</p>"), tr("Ok")); |
93 | return; | 91 | return; |
94 | } | 92 | } |
95 | 93 | ||
96 | selectedNames = names; | 94 | selectedNames = names; |
97 | QDialog::accept(); | 95 | QDialog::accept(); |
98 | } | 96 | } |
99 | 97 | ||
100 | QString AddressPicker::getNames() | 98 | QString AddressPicker::getNames() |
101 | { | 99 | { |
102 | QString names = 0; | 100 | QString names = 0; |
103 | 101 | ||
104 | AddressPicker picker(0, 0, true); | 102 | AddressPicker picker(0, 0, true); |
105 | 103 | ||
106 | int ret = QPEApplication::execDialog( &picker ); | 104 | int ret = QPEApplication::execDialog( &picker ); |
107 | if ( QDialog::Accepted == ret ) | 105 | if ( QDialog::Accepted == ret ) |
108 | { | 106 | { |
109 | return picker.selectedNames; | 107 | return picker.selectedNames; |
110 | } | 108 | } |
111 | 109 | ||
112 | return 0; | 110 | return 0; |
113 | } | 111 | } |
114 | 112 | ||
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp index 741a8e1..9960f88 100644 --- a/noncore/net/mail/libmailwrapper/abstractmail.cpp +++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp | |||
@@ -1,145 +1,143 @@ | |||
1 | #include "abstractmail.h" | 1 | #include "abstractmail.h" |
2 | #include "imapwrapper.h" | 2 | #include "imapwrapper.h" |
3 | #include "pop3wrapper.h" | 3 | #include "pop3wrapper.h" |
4 | #include "nntpwrapper.h" | 4 | #include "nntpwrapper.h" |
5 | #include "mhwrapper.h" | 5 | #include "mhwrapper.h" |
6 | #include "mboxwrapper.h" | ||
7 | #include "mailtypes.h" | 6 | #include "mailtypes.h" |
8 | 7 | ||
9 | #include <qstring.h> | ||
10 | #include <qfile.h> | 8 | #include <qfile.h> |
11 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
12 | #include <stdlib.h> | 10 | #include <stdlib.h> |
13 | #include <libetpan/mailmime_content.h> | 11 | #include <libetpan/mailmime_content.h> |
14 | #include <libetpan/mailmime.h> | 12 | #include <libetpan/mailmime.h> |
15 | 13 | ||
16 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) | 14 | AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) |
17 | { | 15 | { |
18 | return new IMAPwrapper(a); | 16 | return new IMAPwrapper(a); |
19 | } | 17 | } |
20 | 18 | ||
21 | AbstractMail* AbstractMail::getWrapper(POP3account *a) | 19 | AbstractMail* AbstractMail::getWrapper(POP3account *a) |
22 | { | 20 | { |
23 | return new POP3wrapper(a); | 21 | return new POP3wrapper(a); |
24 | } | 22 | } |
25 | 23 | ||
26 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) | 24 | AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) |
27 | { | 25 | { |
28 | return new NNTPwrapper(a); | 26 | return new NNTPwrapper(a); |
29 | } | 27 | } |
30 | 28 | ||
31 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) | 29 | AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) |
32 | { | 30 | { |
33 | return new MHwrapper(a,name); | 31 | return new MHwrapper(a,name); |
34 | } | 32 | } |
35 | 33 | ||
36 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) | 34 | encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) |
37 | { | 35 | { |
38 | qDebug("Decode string start"); | 36 | qDebug("Decode string start"); |
39 | char*result_text; | 37 | char*result_text; |
40 | size_t index = 0; | 38 | size_t index = 0; |
41 | /* reset for recursive use! */ | 39 | /* reset for recursive use! */ |
42 | size_t target_length = 0; | 40 | size_t target_length = 0; |
43 | result_text = 0; | 41 | result_text = 0; |
44 | int mimetype = MAILMIME_MECHANISM_7BIT; | 42 | int mimetype = MAILMIME_MECHANISM_7BIT; |
45 | if (enc.lower()=="quoted-printable") { | 43 | if (enc.lower()=="quoted-printable") { |
46 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 44 | mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
47 | } else if (enc.lower()=="base64") { | 45 | } else if (enc.lower()=="base64") { |
48 | mimetype = MAILMIME_MECHANISM_BASE64; | 46 | mimetype = MAILMIME_MECHANISM_BASE64; |
49 | } else if (enc.lower()=="8bit") { | 47 | } else if (enc.lower()=="8bit") { |
50 | mimetype = MAILMIME_MECHANISM_8BIT; | 48 | mimetype = MAILMIME_MECHANISM_8BIT; |
51 | } else if (enc.lower()=="binary") { | 49 | } else if (enc.lower()=="binary") { |
52 | mimetype = MAILMIME_MECHANISM_BINARY; | 50 | mimetype = MAILMIME_MECHANISM_BINARY; |
53 | } | 51 | } |
54 | 52 | ||
55 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, | 53 | int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, |
56 | &result_text,&target_length); | 54 | &result_text,&target_length); |
57 | 55 | ||
58 | encodedString* result = new encodedString(); | 56 | encodedString* result = new encodedString(); |
59 | if (err == MAILIMF_NO_ERROR) { | 57 | if (err == MAILIMF_NO_ERROR) { |
60 | result->setContent(result_text,target_length); | 58 | result->setContent(result_text,target_length); |
61 | } | 59 | } |
62 | qDebug("Decode string finished"); | 60 | qDebug("Decode string finished"); |
63 | return result; | 61 | return result; |
64 | } | 62 | } |
65 | 63 | ||
66 | QString AbstractMail::convert_String(const char*text) | 64 | QString AbstractMail::convert_String(const char*text) |
67 | { | 65 | { |
68 | size_t index = 0; | 66 | size_t index = 0; |
69 | char*res = 0; | 67 | char*res = 0; |
70 | 68 | ||
71 | /* attention - doesn't work with arm systems! */ | 69 | /* attention - doesn't work with arm systems! */ |
72 | int err = mailmime_encoded_phrase_parse("iso-8859-1", | 70 | int err = mailmime_encoded_phrase_parse("iso-8859-1", |
73 | text, strlen(text),&index, "iso-8859-1",&res); | 71 | text, strlen(text),&index, "iso-8859-1",&res); |
74 | if (err != MAILIMF_NO_ERROR) { | 72 | if (err != MAILIMF_NO_ERROR) { |
75 | if (res) free(res); | 73 | if (res) free(res); |
76 | return QString(text); | 74 | return QString(text); |
77 | } | 75 | } |
78 | if (res) { | 76 | if (res) { |
79 | QString result(res); | 77 | QString result(res); |
80 | free(res); | 78 | free(res); |
81 | return result; | 79 | return result; |
82 | } | 80 | } |
83 | return QString(text); | 81 | return QString(text); |
84 | } | 82 | } |
85 | 83 | ||
86 | /* cp & paste from launcher */ | 84 | /* cp & paste from launcher */ |
87 | QString AbstractMail::gen_attachment_id() | 85 | QString AbstractMail::gen_attachment_id() |
88 | { | 86 | { |
89 | QFile file( "/proc/sys/kernel/random/uuid" ); | 87 | QFile file( "/proc/sys/kernel/random/uuid" ); |
90 | if (!file.open(IO_ReadOnly ) ) | 88 | if (!file.open(IO_ReadOnly ) ) |
91 | return QString::null; | 89 | return QString::null; |
92 | 90 | ||
93 | QTextStream stream(&file); | 91 | QTextStream stream(&file); |
94 | 92 | ||
95 | return "{" + stream.read().stripWhiteSpace() + "}"; | 93 | return "{" + stream.read().stripWhiteSpace() + "}"; |
96 | } | 94 | } |
97 | 95 | ||
98 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) | 96 | int AbstractMail::createMbox(const QString&,const Folder*,const QString& delemiter,bool) |
99 | { | 97 | { |
100 | return 0; | 98 | return 0; |
101 | } | 99 | } |
102 | 100 | ||
103 | QString AbstractMail::defaultLocalfolder() | 101 | QString AbstractMail::defaultLocalfolder() |
104 | { | 102 | { |
105 | QString f = getenv( "HOME" ); | 103 | QString f = getenv( "HOME" ); |
106 | f += "/Applications/opiemail/localmail"; | 104 | f += "/Applications/opiemail/localmail"; |
107 | return f; | 105 | return f; |
108 | } | 106 | } |
109 | 107 | ||
110 | /* temporary - will be removed when implemented in all classes */ | 108 | /* temporary - will be removed when implemented in all classes */ |
111 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) | 109 | void AbstractMail::deleteMails(const QString &,QList<RecMail> &) |
112 | { | 110 | { |
113 | } | 111 | } |
114 | 112 | ||
115 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 113 | void AbstractMail::mvcpAllMails(Folder*fromFolder,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
116 | { | 114 | { |
117 | QList<RecMail> t; | 115 | QList<RecMail> t; |
118 | listMessages(fromFolder->getName(),t); | 116 | listMessages(fromFolder->getName(),t); |
119 | encodedString*st = 0; | 117 | encodedString*st = 0; |
120 | while (t.count()>0) { | 118 | while (t.count()>0) { |
121 | RecMail*r = t.at(0); | 119 | RecMail*r = t.at(0); |
122 | st = fetchRawBody(*r); | 120 | st = fetchRawBody(*r); |
123 | if (st) { | 121 | if (st) { |
124 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 122 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
125 | delete st; | 123 | delete st; |
126 | } | 124 | } |
127 | t.removeFirst(); | 125 | t.removeFirst(); |
128 | } | 126 | } |
129 | if (moveit) { | 127 | if (moveit) { |
130 | deleteAllMail(fromFolder); | 128 | deleteAllMail(fromFolder); |
131 | } | 129 | } |
132 | } | 130 | } |
133 | 131 | ||
134 | void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) | 132 | void AbstractMail::mvcpMail(const RecMail&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) |
135 | { | 133 | { |
136 | encodedString*st = 0; | 134 | encodedString*st = 0; |
137 | st = fetchRawBody(mail); | 135 | st = fetchRawBody(mail); |
138 | if (st) { | 136 | if (st) { |
139 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); | 137 | targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); |
140 | delete st; | 138 | delete st; |
141 | } | 139 | } |
142 | if (moveit) { | 140 | if (moveit) { |
143 | deleteMail(mail); | 141 | deleteMail(mail); |
144 | } | 142 | } |
145 | } | 143 | } |
diff --git a/noncore/net/mail/libmailwrapper/sendmailprogress.cpp b/noncore/net/mail/libmailwrapper/sendmailprogress.cpp index ef22750..dc0c75a 100644 --- a/noncore/net/mail/libmailwrapper/sendmailprogress.cpp +++ b/noncore/net/mail/libmailwrapper/sendmailprogress.cpp | |||
@@ -1,48 +1,47 @@ | |||
1 | #include "sendmailprogress.h" | 1 | #include "sendmailprogress.h" |
2 | #include <qprogressbar.h> | 2 | #include <qprogressbar.h> |
3 | #include <qlabel.h> | 3 | #include <qlabel.h> |
4 | #include <qstring.h> | ||
5 | 4 | ||
6 | progressMailSend::progressMailSend(QWidget*parent, const char * name) | 5 | progressMailSend::progressMailSend(QWidget*parent, const char * name) |
7 | :progressMailSendUI(parent,name,true),m_current_mail(0),m_current_single(0),m_max_mail(0),m_max_single(0) | 6 | :progressMailSendUI(parent,name,true),m_current_mail(0),m_current_single(0),m_max_mail(0),m_max_single(0) |
8 | { | 7 | { |
9 | } | 8 | } |
10 | 9 | ||
11 | progressMailSend::~progressMailSend() | 10 | progressMailSend::~progressMailSend() |
12 | { | 11 | { |
13 | } | 12 | } |
14 | 13 | ||
15 | void progressMailSend::setMaxMails(unsigned int aMaxMails) | 14 | void progressMailSend::setMaxMails(unsigned int aMaxMails) |
16 | { | 15 | { |
17 | m_max_mail = aMaxMails; | 16 | m_max_mail = aMaxMails; |
18 | allMailProgressBar->setTotalSteps(aMaxMails); | 17 | allMailProgressBar->setTotalSteps(aMaxMails); |
19 | setMails(); | 18 | setMails(); |
20 | } | 19 | } |
21 | 20 | ||
22 | void progressMailSend::setCurrentMails(unsigned int aCurrent) | 21 | void progressMailSend::setCurrentMails(unsigned int aCurrent) |
23 | { | 22 | { |
24 | m_current_mail = aCurrent; | 23 | m_current_mail = aCurrent; |
25 | allMailProgressBar->setProgress(aCurrent); | 24 | allMailProgressBar->setProgress(aCurrent); |
26 | setMails(); | 25 | setMails(); |
27 | } | 26 | } |
28 | 27 | ||
29 | void progressMailSend::setSingleMail(unsigned int aCurrent,unsigned int aMax) | 28 | void progressMailSend::setSingleMail(unsigned int aCurrent,unsigned int aMax) |
30 | { | 29 | { |
31 | m_current_single = aCurrent; | 30 | m_current_single = aCurrent; |
32 | m_max_single = aMax; | 31 | m_max_single = aMax; |
33 | setSingle(); | 32 | setSingle(); |
34 | } | 33 | } |
35 | 34 | ||
36 | void progressMailSend::setSingle() | 35 | void progressMailSend::setSingle() |
37 | { | 36 | { |
38 | QString text = QString(tr("%1 of %2 bytes send")).arg(m_current_single).arg(m_max_single); | 37 | QString text = QString(tr("%1 of %2 bytes send")).arg(m_current_single).arg(m_max_single); |
39 | singleMailLabel->setText(text); | 38 | singleMailLabel->setText(text); |
40 | singleMailProgressBar->setTotalSteps(m_max_single); | 39 | singleMailProgressBar->setTotalSteps(m_max_single); |
41 | singleMailProgressBar->setProgress(m_current_single); | 40 | singleMailProgressBar->setProgress(m_current_single); |
42 | } | 41 | } |
43 | 42 | ||
44 | void progressMailSend::setMails() | 43 | void progressMailSend::setMails() |
45 | { | 44 | { |
46 | QString text = QString(tr("Sending mail %1 of %2")).arg(m_current_mail+1).arg(m_max_mail); | 45 | QString text = QString(tr("Sending mail %1 of %2")).arg(m_current_mail+1).arg(m_max_mail); |
47 | allMailLabel->setText(text); | 46 | allMailLabel->setText(text); |
48 | } | 47 | } |
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp index d75d52a..d7a005e 100644 --- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp | |||
@@ -1,875 +1,873 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/types.h> | 3 | #include <sys/types.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include <fcntl.h> | 5 | #include <fcntl.h> |
6 | #include <string.h> | 6 | #include <string.h> |
7 | #include <qdir.h> | ||
8 | #include <qt.h> | 7 | #include <qt.h> |
9 | #include <qmessagebox.h> | ||
10 | 8 | ||
11 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
12 | #include <qpe/qcopenvelope_qws.h> | 10 | #include <qpe/qcopenvelope_qws.h> |
13 | 11 | ||
14 | #include <libetpan/libetpan.h> | 12 | #include <libetpan/libetpan.h> |
15 | 13 | ||
16 | #include "smtpwrapper.h" | 14 | #include "smtpwrapper.h" |
17 | #include "mailwrapper.h" | 15 | #include "mailwrapper.h" |
18 | #include "abstractmail.h" | 16 | #include "abstractmail.h" |
19 | #include "logindialog.h" | 17 | #include "logindialog.h" |
20 | #include "mailtypes.h" | 18 | #include "mailtypes.h" |
21 | #include "sendmailprogress.h" | 19 | #include "sendmailprogress.h" |
22 | 20 | ||
23 | const char* SMTPwrapper::USER_AGENT="OpieMail v0.4"; | 21 | const char* SMTPwrapper::USER_AGENT="OpieMail v0.4"; |
24 | 22 | ||
25 | progressMailSend*SMTPwrapper::sendProgress = 0; | 23 | progressMailSend*SMTPwrapper::sendProgress = 0; |
26 | 24 | ||
27 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) | 25 | SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) |
28 | : QObject() | 26 | : QObject() |
29 | { | 27 | { |
30 | m_SmtpAccount = aSmtp; | 28 | m_SmtpAccount = aSmtp; |
31 | Config cfg( "mail" ); | 29 | Config cfg( "mail" ); |
32 | cfg.setGroup( "Status" ); | 30 | cfg.setGroup( "Status" ); |
33 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); | 31 | m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); |
34 | emit queuedMails( m_queuedMail ); | 32 | emit queuedMails( m_queuedMail ); |
35 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); | 33 | connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); |
36 | m_smtp = 0; | 34 | m_smtp = 0; |
37 | } | 35 | } |
38 | 36 | ||
39 | SMTPwrapper::~SMTPwrapper() | 37 | SMTPwrapper::~SMTPwrapper() |
40 | { | 38 | { |
41 | disc_server(); | 39 | disc_server(); |
42 | } | 40 | } |
43 | 41 | ||
44 | void SMTPwrapper::emitQCop( int queued ) { | 42 | void SMTPwrapper::emitQCop( int queued ) { |
45 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); | 43 | QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); |
46 | env << queued; | 44 | env << queued; |
47 | } | 45 | } |
48 | 46 | ||
49 | QString SMTPwrapper::mailsmtpError( int errnum ) { | 47 | QString SMTPwrapper::mailsmtpError( int errnum ) { |
50 | switch ( errnum ) { | 48 | switch ( errnum ) { |
51 | case MAILSMTP_NO_ERROR: | 49 | case MAILSMTP_NO_ERROR: |
52 | return tr( "No error" ); | 50 | return tr( "No error" ); |
53 | case MAILSMTP_ERROR_UNEXPECTED_CODE: | 51 | case MAILSMTP_ERROR_UNEXPECTED_CODE: |
54 | return tr( "Unexpected error code" ); | 52 | return tr( "Unexpected error code" ); |
55 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: | 53 | case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: |
56 | return tr( "Service not available" ); | 54 | return tr( "Service not available" ); |
57 | case MAILSMTP_ERROR_STREAM: | 55 | case MAILSMTP_ERROR_STREAM: |
58 | return tr( "Stream error" ); | 56 | return tr( "Stream error" ); |
59 | case MAILSMTP_ERROR_HOSTNAME: | 57 | case MAILSMTP_ERROR_HOSTNAME: |
60 | return tr( "gethostname() failed" ); | 58 | return tr( "gethostname() failed" ); |
61 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: | 59 | case MAILSMTP_ERROR_NOT_IMPLEMENTED: |
62 | return tr( "Not implemented" ); | 60 | return tr( "Not implemented" ); |
63 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: | 61 | case MAILSMTP_ERROR_ACTION_NOT_TAKEN: |
64 | return tr( "Error, action not taken" ); | 62 | return tr( "Error, action not taken" ); |
65 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: | 63 | case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: |
66 | return tr( "Data exceeds storage allocation" ); | 64 | return tr( "Data exceeds storage allocation" ); |
67 | case MAILSMTP_ERROR_IN_PROCESSING: | 65 | case MAILSMTP_ERROR_IN_PROCESSING: |
68 | return tr( "Error in processing" ); | 66 | return tr( "Error in processing" ); |
69 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: | 67 | case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: |
70 | return tr( "Starttls not supported" ); | 68 | return tr( "Starttls not supported" ); |
71 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: | 69 | // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: |
72 | // return tr( "Insufficient system storage" ); | 70 | // return tr( "Insufficient system storage" ); |
73 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: | 71 | case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: |
74 | return tr( "Mailbox unavailable" ); | 72 | return tr( "Mailbox unavailable" ); |
75 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: | 73 | case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: |
76 | return tr( "Mailbox name not allowed" ); | 74 | return tr( "Mailbox name not allowed" ); |
77 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: | 75 | case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: |
78 | return tr( "Bad command sequence" ); | 76 | return tr( "Bad command sequence" ); |
79 | case MAILSMTP_ERROR_USER_NOT_LOCAL: | 77 | case MAILSMTP_ERROR_USER_NOT_LOCAL: |
80 | return tr( "User not local" ); | 78 | return tr( "User not local" ); |
81 | case MAILSMTP_ERROR_TRANSACTION_FAILED: | 79 | case MAILSMTP_ERROR_TRANSACTION_FAILED: |
82 | return tr( "Transaction failed" ); | 80 | return tr( "Transaction failed" ); |
83 | case MAILSMTP_ERROR_MEMORY: | 81 | case MAILSMTP_ERROR_MEMORY: |
84 | return tr( "Memory error" ); | 82 | return tr( "Memory error" ); |
85 | case MAILSMTP_ERROR_CONNECTION_REFUSED: | 83 | case MAILSMTP_ERROR_CONNECTION_REFUSED: |
86 | return tr( "Connection refused" ); | 84 | return tr( "Connection refused" ); |
87 | default: | 85 | default: |
88 | return tr( "Unknown error code" ); | 86 | return tr( "Unknown error code" ); |
89 | } | 87 | } |
90 | } | 88 | } |
91 | 89 | ||
92 | mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail ) { | 90 | mailimf_mailbox *SMTPwrapper::newMailbox(const QString&name, const QString&mail ) { |
93 | return mailimf_mailbox_new( strdup( name.latin1() ), | 91 | return mailimf_mailbox_new( strdup( name.latin1() ), |
94 | strdup( mail.latin1() ) ); | 92 | strdup( mail.latin1() ) ); |
95 | } | 93 | } |
96 | 94 | ||
97 | mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) { | 95 | mailimf_address_list *SMTPwrapper::parseAddresses(const QString&addr ) { |
98 | mailimf_address_list *addresses; | 96 | mailimf_address_list *addresses; |
99 | 97 | ||
100 | if ( addr.isEmpty() ) | 98 | if ( addr.isEmpty() ) |
101 | return NULL; | 99 | return NULL; |
102 | 100 | ||
103 | addresses = mailimf_address_list_new_empty(); | 101 | addresses = mailimf_address_list_new_empty(); |
104 | 102 | ||
105 | bool literal_open = false; | 103 | bool literal_open = false; |
106 | unsigned int startpos = 0; | 104 | unsigned int startpos = 0; |
107 | QStringList list; | 105 | QStringList list; |
108 | QString s; | 106 | QString s; |
109 | unsigned int i = 0; | 107 | unsigned int i = 0; |
110 | for (; i < addr.length();++i) { | 108 | for (; i < addr.length();++i) { |
111 | switch (addr[i]) { | 109 | switch (addr[i]) { |
112 | case '\"': | 110 | case '\"': |
113 | literal_open = !literal_open; | 111 | literal_open = !literal_open; |
114 | break; | 112 | break; |
115 | case ',': | 113 | case ',': |
116 | if (!literal_open) { | 114 | if (!literal_open) { |
117 | s = addr.mid(startpos,i-startpos); | 115 | s = addr.mid(startpos,i-startpos); |
118 | if (!s.isEmpty()) { | 116 | if (!s.isEmpty()) { |
119 | list.append(s); | 117 | list.append(s); |
120 | qDebug("Appended %s",s.latin1()); | 118 | qDebug("Appended %s",s.latin1()); |
121 | } | 119 | } |
122 | // !!!! this is a MUST BE! | 120 | // !!!! this is a MUST BE! |
123 | startpos = ++i; | 121 | startpos = ++i; |
124 | } | 122 | } |
125 | break; | 123 | break; |
126 | default: | 124 | default: |
127 | break; | 125 | break; |
128 | } | 126 | } |
129 | } | 127 | } |
130 | s = addr.mid(startpos,i-startpos); | 128 | s = addr.mid(startpos,i-startpos); |
131 | if (!s.isEmpty()) { | 129 | if (!s.isEmpty()) { |
132 | list.append(s); | 130 | list.append(s); |
133 | qDebug("Appended %s",s.latin1()); | 131 | qDebug("Appended %s",s.latin1()); |
134 | } | 132 | } |
135 | QStringList::Iterator it; | 133 | QStringList::Iterator it; |
136 | for ( it = list.begin(); it != list.end(); it++ ) { | 134 | for ( it = list.begin(); it != list.end(); it++ ) { |
137 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); | 135 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); |
138 | if ( err != MAILIMF_NO_ERROR ) { | 136 | if ( err != MAILIMF_NO_ERROR ) { |
139 | qDebug( "Error parsing" ); | 137 | qDebug( "Error parsing" ); |
140 | qDebug( *it ); | 138 | qDebug( *it ); |
141 | } else { | 139 | } else { |
142 | qDebug( "Parse success! %s",(*it).latin1()); | 140 | qDebug( "Parse success! %s",(*it).latin1()); |
143 | } | 141 | } |
144 | } | 142 | } |
145 | return addresses; | 143 | return addresses; |
146 | } | 144 | } |
147 | 145 | ||
148 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { | 146 | mailimf_fields *SMTPwrapper::createImfFields(const Mail&mail ) { |
149 | mailimf_fields *fields; | 147 | mailimf_fields *fields; |
150 | mailimf_field *xmailer; | 148 | mailimf_field *xmailer; |
151 | mailimf_mailbox *sender=0,*fromBox=0; | 149 | mailimf_mailbox *sender=0,*fromBox=0; |
152 | mailimf_mailbox_list *from=0; | 150 | mailimf_mailbox_list *from=0; |
153 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 151 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
154 | char *subject = strdup( mail.getSubject().latin1() ); | 152 | char *subject = strdup( mail.getSubject().latin1() ); |
155 | int err; | 153 | int err; |
156 | 154 | ||
157 | sender = newMailbox( mail.getName(), mail.getMail() ); | 155 | sender = newMailbox( mail.getName(), mail.getMail() ); |
158 | if ( sender == NULL ) | 156 | if ( sender == NULL ) |
159 | goto err_free; | 157 | goto err_free; |
160 | 158 | ||
161 | fromBox = newMailbox( mail.getName(), mail.getMail() ); | 159 | fromBox = newMailbox( mail.getName(), mail.getMail() ); |
162 | if ( fromBox == NULL ) | 160 | if ( fromBox == NULL ) |
163 | goto err_free_sender; | 161 | goto err_free_sender; |
164 | 162 | ||
165 | from = mailimf_mailbox_list_new_empty(); | 163 | from = mailimf_mailbox_list_new_empty(); |
166 | if ( from == NULL ) | 164 | if ( from == NULL ) |
167 | goto err_free_fromBox; | 165 | goto err_free_fromBox; |
168 | 166 | ||
169 | err = mailimf_mailbox_list_add( from, fromBox ); | 167 | err = mailimf_mailbox_list_add( from, fromBox ); |
170 | if ( err != MAILIMF_NO_ERROR ) | 168 | if ( err != MAILIMF_NO_ERROR ) |
171 | goto err_free_from; | 169 | goto err_free_from; |
172 | 170 | ||
173 | to = parseAddresses( mail.getTo() ); | 171 | to = parseAddresses( mail.getTo() ); |
174 | if ( to == NULL ) | 172 | if ( to == NULL ) |
175 | goto err_free_from; | 173 | goto err_free_from; |
176 | 174 | ||
177 | cc = parseAddresses( mail.getCC() ); | 175 | cc = parseAddresses( mail.getCC() ); |
178 | bcc = parseAddresses( mail.getBCC() ); | 176 | bcc = parseAddresses( mail.getBCC() ); |
179 | reply = parseAddresses( mail.getReply() ); | 177 | reply = parseAddresses( mail.getReply() ); |
180 | 178 | ||
181 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, | 179 | fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, |
182 | NULL, NULL, subject ); | 180 | NULL, NULL, subject ); |
183 | if ( fields == NULL ) | 181 | if ( fields == NULL ) |
184 | goto err_free_reply; | 182 | goto err_free_reply; |
185 | 183 | ||
186 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), | 184 | xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), |
187 | strdup( USER_AGENT ) ); | 185 | strdup( USER_AGENT ) ); |
188 | if ( xmailer == NULL ) | 186 | if ( xmailer == NULL ) |
189 | goto err_free_fields; | 187 | goto err_free_fields; |
190 | 188 | ||
191 | err = mailimf_fields_add( fields, xmailer ); | 189 | err = mailimf_fields_add( fields, xmailer ); |
192 | if ( err != MAILIMF_NO_ERROR ) | 190 | if ( err != MAILIMF_NO_ERROR ) |
193 | goto err_free_xmailer; | 191 | goto err_free_xmailer; |
194 | 192 | ||
195 | return fields; // Success :) | 193 | return fields; // Success :) |
196 | 194 | ||
197 | err_free_xmailer: | 195 | err_free_xmailer: |
198 | if (xmailer) | 196 | if (xmailer) |
199 | mailimf_field_free( xmailer ); | 197 | mailimf_field_free( xmailer ); |
200 | err_free_fields: | 198 | err_free_fields: |
201 | if (fields) | 199 | if (fields) |
202 | mailimf_fields_free( fields ); | 200 | mailimf_fields_free( fields ); |
203 | err_free_reply: | 201 | err_free_reply: |
204 | if (reply) | 202 | if (reply) |
205 | mailimf_address_list_free( reply ); | 203 | mailimf_address_list_free( reply ); |
206 | if (bcc) | 204 | if (bcc) |
207 | mailimf_address_list_free( bcc ); | 205 | mailimf_address_list_free( bcc ); |
208 | if (cc) | 206 | if (cc) |
209 | mailimf_address_list_free( cc ); | 207 | mailimf_address_list_free( cc ); |
210 | if (to) | 208 | if (to) |
211 | mailimf_address_list_free( to ); | 209 | mailimf_address_list_free( to ); |
212 | err_free_from: | 210 | err_free_from: |
213 | if (from) | 211 | if (from) |
214 | mailimf_mailbox_list_free( from ); | 212 | mailimf_mailbox_list_free( from ); |
215 | err_free_fromBox: | 213 | err_free_fromBox: |
216 | mailimf_mailbox_free( fromBox ); | 214 | mailimf_mailbox_free( fromBox ); |
217 | err_free_sender: | 215 | err_free_sender: |
218 | if (sender) | 216 | if (sender) |
219 | mailimf_mailbox_free( sender ); | 217 | mailimf_mailbox_free( sender ); |
220 | err_free: | 218 | err_free: |
221 | if (subject) | 219 | if (subject) |
222 | free( subject ); | 220 | free( subject ); |
223 | qDebug( "createImfFields - error" ); | 221 | qDebug( "createImfFields - error" ); |
224 | 222 | ||
225 | return NULL; // Error :( | 223 | return NULL; // Error :( |
226 | } | 224 | } |
227 | 225 | ||
228 | mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { | 226 | mailmime *SMTPwrapper::buildTxtPart(const QString&str ) { |
229 | mailmime *txtPart; | 227 | mailmime *txtPart; |
230 | mailmime_fields *fields; | 228 | mailmime_fields *fields; |
231 | mailmime_content *content; | 229 | mailmime_content *content; |
232 | mailmime_parameter *param; | 230 | mailmime_parameter *param; |
233 | int err; | 231 | int err; |
234 | 232 | ||
235 | param = mailmime_parameter_new( strdup( "charset" ), | 233 | param = mailmime_parameter_new( strdup( "charset" ), |
236 | strdup( "iso-8859-1" ) ); | 234 | strdup( "iso-8859-1" ) ); |
237 | if ( param == NULL ) | 235 | if ( param == NULL ) |
238 | goto err_free; | 236 | goto err_free; |
239 | 237 | ||
240 | content = mailmime_content_new_with_str( "text/plain" ); | 238 | content = mailmime_content_new_with_str( "text/plain" ); |
241 | if ( content == NULL ) | 239 | if ( content == NULL ) |
242 | goto err_free_param; | 240 | goto err_free_param; |
243 | 241 | ||
244 | err = clist_append( content->ct_parameters, param ); | 242 | err = clist_append( content->ct_parameters, param ); |
245 | if ( err != MAILIMF_NO_ERROR ) | 243 | if ( err != MAILIMF_NO_ERROR ) |
246 | goto err_free_content; | 244 | goto err_free_content; |
247 | 245 | ||
248 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 246 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
249 | if ( fields == NULL ) | 247 | if ( fields == NULL ) |
250 | goto err_free_content; | 248 | goto err_free_content; |
251 | 249 | ||
252 | txtPart = mailmime_new_empty( content, fields ); | 250 | txtPart = mailmime_new_empty( content, fields ); |
253 | if ( txtPart == NULL ) | 251 | if ( txtPart == NULL ) |
254 | goto err_free_fields; | 252 | goto err_free_fields; |
255 | 253 | ||
256 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); | 254 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); |
257 | if ( err != MAILIMF_NO_ERROR ) | 255 | if ( err != MAILIMF_NO_ERROR ) |
258 | goto err_free_txtPart; | 256 | goto err_free_txtPart; |
259 | 257 | ||
260 | return txtPart; // Success :) | 258 | return txtPart; // Success :) |
261 | 259 | ||
262 | err_free_txtPart: | 260 | err_free_txtPart: |
263 | mailmime_free( txtPart ); | 261 | mailmime_free( txtPart ); |
264 | err_free_fields: | 262 | err_free_fields: |
265 | mailmime_fields_free( fields ); | 263 | mailmime_fields_free( fields ); |
266 | err_free_content: | 264 | err_free_content: |
267 | mailmime_content_free( content ); | 265 | mailmime_content_free( content ); |
268 | err_free_param: | 266 | err_free_param: |
269 | mailmime_parameter_free( param ); | 267 | mailmime_parameter_free( param ); |
270 | err_free: | 268 | err_free: |
271 | qDebug( "buildTxtPart - error" ); | 269 | qDebug( "buildTxtPart - error" ); |
272 | 270 | ||
273 | return NULL; // Error :( | 271 | return NULL; // Error :( |
274 | } | 272 | } |
275 | 273 | ||
276 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { | 274 | mailmime *SMTPwrapper::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { |
277 | mailmime * filePart = 0; | 275 | mailmime * filePart = 0; |
278 | mailmime_fields * fields = 0; | 276 | mailmime_fields * fields = 0; |
279 | mailmime_content * content = 0; | 277 | mailmime_content * content = 0; |
280 | mailmime_parameter * param = 0; | 278 | mailmime_parameter * param = 0; |
281 | char*name = 0; | 279 | char*name = 0; |
282 | char*file = 0; | 280 | char*file = 0; |
283 | int err; | 281 | int err; |
284 | 282 | ||
285 | int pos = filename.findRev( '/' ); | 283 | int pos = filename.findRev( '/' ); |
286 | 284 | ||
287 | if (filename.length()>0) { | 285 | if (filename.length()>0) { |
288 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 286 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
289 | name = strdup( tmp.latin1() ); // just filename | 287 | name = strdup( tmp.latin1() ); // just filename |
290 | file = strdup( filename.latin1() ); // full name with path | 288 | file = strdup( filename.latin1() ); // full name with path |
291 | } | 289 | } |
292 | 290 | ||
293 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 291 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
294 | int mechanism = MAILMIME_MECHANISM_BASE64; | 292 | int mechanism = MAILMIME_MECHANISM_BASE64; |
295 | 293 | ||
296 | if ( mimetype.startsWith( "text/" ) ) { | 294 | if ( mimetype.startsWith( "text/" ) ) { |
297 | param = mailmime_parameter_new( strdup( "charset" ), | 295 | param = mailmime_parameter_new( strdup( "charset" ), |
298 | strdup( "iso-8859-1" ) ); | 296 | strdup( "iso-8859-1" ) ); |
299 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 297 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
300 | } | 298 | } |
301 | 299 | ||
302 | fields = mailmime_fields_new_filename( | 300 | fields = mailmime_fields_new_filename( |
303 | disptype, name, | 301 | disptype, name, |
304 | mechanism ); | 302 | mechanism ); |
305 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); | 303 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); |
306 | if (content!=0 && fields != 0) { | 304 | if (content!=0 && fields != 0) { |
307 | if (param) { | 305 | if (param) { |
308 | clist_append(content->ct_parameters,param); | 306 | clist_append(content->ct_parameters,param); |
309 | param = 0; | 307 | param = 0; |
310 | } | 308 | } |
311 | if (filename.length()>0) { | 309 | if (filename.length()>0) { |
312 | QFileInfo f(filename); | 310 | QFileInfo f(filename); |
313 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 311 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
314 | clist_append(content->ct_parameters,param); | 312 | clist_append(content->ct_parameters,param); |
315 | param = 0; | 313 | param = 0; |
316 | } | 314 | } |
317 | filePart = mailmime_new_empty( content, fields ); | 315 | filePart = mailmime_new_empty( content, fields ); |
318 | } | 316 | } |
319 | if (filePart) { | 317 | if (filePart) { |
320 | if (filename.length()>0) { | 318 | if (filename.length()>0) { |
321 | err = mailmime_set_body_file( filePart, file ); | 319 | err = mailmime_set_body_file( filePart, file ); |
322 | } else { | 320 | } else { |
323 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); | 321 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); |
324 | } | 322 | } |
325 | if (err != MAILIMF_NO_ERROR) { | 323 | if (err != MAILIMF_NO_ERROR) { |
326 | qDebug("Error setting body with file %s",file); | 324 | qDebug("Error setting body with file %s",file); |
327 | mailmime_free( filePart ); | 325 | mailmime_free( filePart ); |
328 | filePart = 0; | 326 | filePart = 0; |
329 | } | 327 | } |
330 | } | 328 | } |
331 | 329 | ||
332 | if (!filePart) { | 330 | if (!filePart) { |
333 | if ( param != NULL ) { | 331 | if ( param != NULL ) { |
334 | mailmime_parameter_free( param ); | 332 | mailmime_parameter_free( param ); |
335 | } | 333 | } |
336 | if (content) { | 334 | if (content) { |
337 | mailmime_content_free( content ); | 335 | mailmime_content_free( content ); |
338 | } | 336 | } |
339 | if (fields) { | 337 | if (fields) { |
340 | mailmime_fields_free( fields ); | 338 | mailmime_fields_free( fields ); |
341 | } else { | 339 | } else { |
342 | if (name) { | 340 | if (name) { |
343 | free( name ); | 341 | free( name ); |
344 | } | 342 | } |
345 | if (file) { | 343 | if (file) { |
346 | free( file ); | 344 | free( file ); |
347 | } | 345 | } |
348 | } | 346 | } |
349 | } | 347 | } |
350 | return filePart; // Success :) | 348 | return filePart; // Success :) |
351 | 349 | ||
352 | } | 350 | } |
353 | 351 | ||
354 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) { | 352 | void SMTPwrapper::addFileParts( mailmime *message,const QList<Attachment>&files ) { |
355 | const Attachment *it; | 353 | const Attachment *it; |
356 | unsigned int count = files.count(); | 354 | unsigned int count = files.count(); |
357 | qDebug("List contains %i values",count); | 355 | qDebug("List contains %i values",count); |
358 | for ( unsigned int i = 0; i < count; ++i ) { | 356 | for ( unsigned int i = 0; i < count; ++i ) { |
359 | qDebug( "Adding file" ); | 357 | qDebug( "Adding file" ); |
360 | mailmime *filePart; | 358 | mailmime *filePart; |
361 | int err; | 359 | int err; |
362 | it = ((QList<Attachment>)files).at(i); | 360 | it = ((QList<Attachment>)files).at(i); |
363 | 361 | ||
364 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 362 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
365 | if ( filePart == NULL ) { | 363 | if ( filePart == NULL ) { |
366 | qDebug( "addFileParts: error adding file:" ); | 364 | qDebug( "addFileParts: error adding file:" ); |
367 | qDebug( it->getFileName() ); | 365 | qDebug( it->getFileName() ); |
368 | continue; | 366 | continue; |
369 | } | 367 | } |
370 | err = mailmime_smart_add_part( message, filePart ); | 368 | err = mailmime_smart_add_part( message, filePart ); |
371 | if ( err != MAILIMF_NO_ERROR ) { | 369 | if ( err != MAILIMF_NO_ERROR ) { |
372 | mailmime_free( filePart ); | 370 | mailmime_free( filePart ); |
373 | qDebug("error smart add"); | 371 | qDebug("error smart add"); |
374 | } | 372 | } |
375 | } | 373 | } |
376 | } | 374 | } |
377 | 375 | ||
378 | mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) { | 376 | mailmime *SMTPwrapper::createMimeMail(const Mail &mail ) { |
379 | mailmime *message, *txtPart; | 377 | mailmime *message, *txtPart; |
380 | mailimf_fields *fields; | 378 | mailimf_fields *fields; |
381 | int err; | 379 | int err; |
382 | 380 | ||
383 | fields = createImfFields( mail ); | 381 | fields = createImfFields( mail ); |
384 | if ( fields == NULL ) | 382 | if ( fields == NULL ) |
385 | goto err_free; | 383 | goto err_free; |
386 | 384 | ||
387 | message = mailmime_new_message_data( NULL ); | 385 | message = mailmime_new_message_data( NULL ); |
388 | if ( message == NULL ) | 386 | if ( message == NULL ) |
389 | goto err_free_fields; | 387 | goto err_free_fields; |
390 | 388 | ||
391 | mailmime_set_imf_fields( message, fields ); | 389 | mailmime_set_imf_fields( message, fields ); |
392 | 390 | ||
393 | txtPart = buildTxtPart( mail.getMessage() ); | 391 | txtPart = buildTxtPart( mail.getMessage() ); |
394 | 392 | ||
395 | if ( txtPart == NULL ) | 393 | if ( txtPart == NULL ) |
396 | goto err_free_message; | 394 | goto err_free_message; |
397 | 395 | ||
398 | err = mailmime_smart_add_part( message, txtPart ); | 396 | err = mailmime_smart_add_part( message, txtPart ); |
399 | if ( err != MAILIMF_NO_ERROR ) | 397 | if ( err != MAILIMF_NO_ERROR ) |
400 | goto err_free_txtPart; | 398 | goto err_free_txtPart; |
401 | 399 | ||
402 | addFileParts( message, mail.getAttachments() ); | 400 | addFileParts( message, mail.getAttachments() ); |
403 | 401 | ||
404 | return message; // Success :) | 402 | return message; // Success :) |
405 | 403 | ||
406 | err_free_txtPart: | 404 | err_free_txtPart: |
407 | mailmime_free( txtPart ); | 405 | mailmime_free( txtPart ); |
408 | err_free_message: | 406 | err_free_message: |
409 | mailmime_free( message ); | 407 | mailmime_free( message ); |
410 | err_free_fields: | 408 | err_free_fields: |
411 | mailimf_fields_free( fields ); | 409 | mailimf_fields_free( fields ); |
412 | err_free: | 410 | err_free: |
413 | qDebug( "createMimeMail: error" ); | 411 | qDebug( "createMimeMail: error" ); |
414 | 412 | ||
415 | return NULL; // Error :( | 413 | return NULL; // Error :( |
416 | } | 414 | } |
417 | 415 | ||
418 | mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) { | 416 | mailimf_field *SMTPwrapper::getField( mailimf_fields *fields, int type ) { |
419 | mailimf_field *field; | 417 | mailimf_field *field; |
420 | clistiter *it; | 418 | clistiter *it; |
421 | 419 | ||
422 | it = clist_begin( fields->fld_list ); | 420 | it = clist_begin( fields->fld_list ); |
423 | while ( it ) { | 421 | while ( it ) { |
424 | field = (mailimf_field *) it->data; | 422 | field = (mailimf_field *) it->data; |
425 | if ( field->fld_type == type ) { | 423 | if ( field->fld_type == type ) { |
426 | return field; | 424 | return field; |
427 | } | 425 | } |
428 | it = it->next; | 426 | it = it->next; |
429 | } | 427 | } |
430 | 428 | ||
431 | return NULL; | 429 | return NULL; |
432 | } | 430 | } |
433 | 431 | ||
434 | void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 432 | void SMTPwrapper::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
435 | clistiter *it, *it2; | 433 | clistiter *it, *it2; |
436 | 434 | ||
437 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 435 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
438 | mailimf_address *addr; | 436 | mailimf_address *addr; |
439 | addr = (mailimf_address *) it->data; | 437 | addr = (mailimf_address *) it->data; |
440 | 438 | ||
441 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 439 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
442 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 440 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
443 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 441 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
444 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 442 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
445 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 443 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
446 | mailimf_mailbox *mbox; | 444 | mailimf_mailbox *mbox; |
447 | mbox = (mailimf_mailbox *) it2->data; | 445 | mbox = (mailimf_mailbox *) it2->data; |
448 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 446 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
449 | } | 447 | } |
450 | } | 448 | } |
451 | } | 449 | } |
452 | } | 450 | } |
453 | 451 | ||
454 | clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) { | 452 | clist *SMTPwrapper::createRcptList( mailimf_fields *fields ) { |
455 | clist *rcptList; | 453 | clist *rcptList; |
456 | mailimf_field *field; | 454 | mailimf_field *field; |
457 | 455 | ||
458 | rcptList = esmtp_address_list_new(); | 456 | rcptList = esmtp_address_list_new(); |
459 | 457 | ||
460 | field = getField( fields, MAILIMF_FIELD_TO ); | 458 | field = getField( fields, MAILIMF_FIELD_TO ); |
461 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) | 459 | if ( field && (field->fld_type == MAILIMF_FIELD_TO) |
462 | && field->fld_data.fld_to->to_addr_list ) { | 460 | && field->fld_data.fld_to->to_addr_list ) { |
463 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); | 461 | addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); |
464 | } | 462 | } |
465 | 463 | ||
466 | field = getField( fields, MAILIMF_FIELD_CC ); | 464 | field = getField( fields, MAILIMF_FIELD_CC ); |
467 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) | 465 | if ( field && (field->fld_type == MAILIMF_FIELD_CC) |
468 | && field->fld_data.fld_cc->cc_addr_list ) { | 466 | && field->fld_data.fld_cc->cc_addr_list ) { |
469 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); | 467 | addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); |
470 | } | 468 | } |
471 | 469 | ||
472 | field = getField( fields, MAILIMF_FIELD_BCC ); | 470 | field = getField( fields, MAILIMF_FIELD_BCC ); |
473 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) | 471 | if ( field && (field->fld_type == MAILIMF_FIELD_BCC) |
474 | && field->fld_data.fld_bcc->bcc_addr_list ) { | 472 | && field->fld_data.fld_bcc->bcc_addr_list ) { |
475 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); | 473 | addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); |
476 | } | 474 | } |
477 | 475 | ||
478 | return rcptList; | 476 | return rcptList; |
479 | } | 477 | } |
480 | 478 | ||
481 | char *SMTPwrapper::getFrom( mailimf_field *ffrom) { | 479 | char *SMTPwrapper::getFrom( mailimf_field *ffrom) { |
482 | char *from = NULL; | 480 | char *from = NULL; |
483 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) | 481 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) |
484 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { | 482 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { |
485 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; | 483 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; |
486 | clistiter *it; | 484 | clistiter *it; |
487 | for ( it = clist_begin( cl ); it; it = it->next ) { | 485 | for ( it = clist_begin( cl ); it; it = it->next ) { |
488 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 486 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
489 | from = strdup( mb->mb_addr_spec ); | 487 | from = strdup( mb->mb_addr_spec ); |
490 | } | 488 | } |
491 | } | 489 | } |
492 | 490 | ||
493 | return from; | 491 | return from; |
494 | } | 492 | } |
495 | 493 | ||
496 | char *SMTPwrapper::getFrom( mailmime *mail ) { | 494 | char *SMTPwrapper::getFrom( mailmime *mail ) { |
497 | /* no need to delete - its just a pointer to structure content */ | 495 | /* no need to delete - its just a pointer to structure content */ |
498 | mailimf_field *ffrom = 0; | 496 | mailimf_field *ffrom = 0; |
499 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 497 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
500 | return getFrom(ffrom); | 498 | return getFrom(ffrom); |
501 | } | 499 | } |
502 | 500 | ||
503 | void SMTPwrapper::progress( size_t current, size_t maximum ) { | 501 | void SMTPwrapper::progress( size_t current, size_t maximum ) { |
504 | if (SMTPwrapper::sendProgress) { | 502 | if (SMTPwrapper::sendProgress) { |
505 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); | 503 | SMTPwrapper::sendProgress->setSingleMail(current, maximum ); |
506 | qApp->processEvents(); | 504 | qApp->processEvents(); |
507 | } | 505 | } |
508 | } | 506 | } |
509 | 507 | ||
510 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { | 508 | void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { |
511 | if (!mail) | 509 | if (!mail) |
512 | return; | 510 | return; |
513 | QString localfolders = AbstractMail::defaultLocalfolder(); | 511 | QString localfolders = AbstractMail::defaultLocalfolder(); |
514 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 512 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
515 | wrap->createMbox(box); | 513 | wrap->createMbox(box); |
516 | wrap->storeMessage(mail,length,box); | 514 | wrap->storeMessage(mail,length,box); |
517 | delete wrap; | 515 | delete wrap; |
518 | } | 516 | } |
519 | 517 | ||
520 | void SMTPwrapper::smtpSend( mailmime *mail,bool later) { | 518 | void SMTPwrapper::smtpSend( mailmime *mail,bool later) { |
521 | clist *rcpts = 0; | 519 | clist *rcpts = 0; |
522 | char *from, *data; | 520 | char *from, *data; |
523 | size_t size; | 521 | size_t size; |
524 | 522 | ||
525 | from = data = 0; | 523 | from = data = 0; |
526 | 524 | ||
527 | mailmessage * msg = 0; | 525 | mailmessage * msg = 0; |
528 | msg = mime_message_init(mail); | 526 | msg = mime_message_init(mail); |
529 | mime_message_set_tmpdir(msg,getenv( "HOME" )); | 527 | mime_message_set_tmpdir(msg,getenv( "HOME" )); |
530 | int r = mailmessage_fetch(msg,&data,&size); | 528 | int r = mailmessage_fetch(msg,&data,&size); |
531 | mime_message_detach_mime(msg); | 529 | mime_message_detach_mime(msg); |
532 | mailmessage_free(msg); | 530 | mailmessage_free(msg); |
533 | if (r != MAIL_NO_ERROR || !data) { | 531 | if (r != MAIL_NO_ERROR || !data) { |
534 | if (data) | 532 | if (data) |
535 | free(data); | 533 | free(data); |
536 | qDebug("Error fetching mime..."); | 534 | qDebug("Error fetching mime..."); |
537 | return; | 535 | return; |
538 | } | 536 | } |
539 | msg = 0; | 537 | msg = 0; |
540 | if (later) { | 538 | if (later) { |
541 | storeMail(data,size,"Outgoing"); | 539 | storeMail(data,size,"Outgoing"); |
542 | if (data) | 540 | if (data) |
543 | free( data ); | 541 | free( data ); |
544 | Config cfg( "mail" ); | 542 | Config cfg( "mail" ); |
545 | cfg.setGroup( "Status" ); | 543 | cfg.setGroup( "Status" ); |
546 | cfg.writeEntry( "outgoing", ++m_queuedMail ); | 544 | cfg.writeEntry( "outgoing", ++m_queuedMail ); |
547 | emit queuedMails( m_queuedMail ); | 545 | emit queuedMails( m_queuedMail ); |
548 | return; | 546 | return; |
549 | } | 547 | } |
550 | from = getFrom( mail ); | 548 | from = getFrom( mail ); |
551 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); | 549 | rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); |
552 | smtpSend(from,rcpts,data,size); | 550 | smtpSend(from,rcpts,data,size); |
553 | if (data) { | 551 | if (data) { |
554 | free(data); | 552 | free(data); |
555 | } | 553 | } |
556 | if (from) { | 554 | if (from) { |
557 | free(from); | 555 | free(from); |
558 | } | 556 | } |
559 | if (rcpts) | 557 | if (rcpts) |
560 | smtp_address_list_free( rcpts ); | 558 | smtp_address_list_free( rcpts ); |
561 | } | 559 | } |
562 | 560 | ||
563 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) | 561 | void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) |
564 | { | 562 | { |
565 | if (data) { | 563 | if (data) { |
566 | storeMail(data,size,"Sendfailed"); | 564 | storeMail(data,size,"Sendfailed"); |
567 | } | 565 | } |
568 | if (failuremessage) { | 566 | if (failuremessage) { |
569 | QMessageBox::critical(0,tr("Error sending mail"), | 567 | QMessageBox::critical(0,tr("Error sending mail"), |
570 | tr("<center>%1</center>").arg(failuremessage)); | 568 | tr("<center>%1</center>").arg(failuremessage)); |
571 | } | 569 | } |
572 | } | 570 | } |
573 | 571 | ||
574 | int SMTPwrapper::start_smtp_tls() | 572 | int SMTPwrapper::start_smtp_tls() |
575 | { | 573 | { |
576 | if (!m_smtp) { | 574 | if (!m_smtp) { |
577 | return MAILSMTP_ERROR_IN_PROCESSING; | 575 | return MAILSMTP_ERROR_IN_PROCESSING; |
578 | } | 576 | } |
579 | int err = mailesmtp_starttls(m_smtp); | 577 | int err = mailesmtp_starttls(m_smtp); |
580 | if (err != MAILSMTP_NO_ERROR) return err; | 578 | if (err != MAILSMTP_NO_ERROR) return err; |
581 | mailstream_low * low; | 579 | mailstream_low * low; |
582 | mailstream_low * new_low; | 580 | mailstream_low * new_low; |
583 | low = mailstream_get_low(m_smtp->stream); | 581 | low = mailstream_get_low(m_smtp->stream); |
584 | if (!low) { | 582 | if (!low) { |
585 | return MAILSMTP_ERROR_IN_PROCESSING; | 583 | return MAILSMTP_ERROR_IN_PROCESSING; |
586 | } | 584 | } |
587 | int fd = mailstream_low_get_fd(low); | 585 | int fd = mailstream_low_get_fd(low); |
588 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 586 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
589 | mailstream_low_free(low); | 587 | mailstream_low_free(low); |
590 | mailstream_set_low(m_smtp->stream, new_low); | 588 | mailstream_set_low(m_smtp->stream, new_low); |
591 | } else { | 589 | } else { |
592 | return MAILSMTP_ERROR_IN_PROCESSING; | 590 | return MAILSMTP_ERROR_IN_PROCESSING; |
593 | } | 591 | } |
594 | return err; | 592 | return err; |
595 | } | 593 | } |
596 | 594 | ||
597 | void SMTPwrapper::connect_server() | 595 | void SMTPwrapper::connect_server() |
598 | { | 596 | { |
599 | const char *server, *user, *pass; | 597 | const char *server, *user, *pass; |
600 | bool ssl; | 598 | bool ssl; |
601 | uint16_t port; | 599 | uint16_t port; |
602 | ssl = false; | 600 | ssl = false; |
603 | bool try_tls = true; | 601 | bool try_tls = true; |
604 | bool force_tls=false; | 602 | bool force_tls=false; |
605 | server = user = pass = 0; | 603 | server = user = pass = 0; |
606 | QString failuretext = ""; | 604 | QString failuretext = ""; |
607 | 605 | ||
608 | if (m_smtp || !m_SmtpAccount) { | 606 | if (m_smtp || !m_SmtpAccount) { |
609 | return; | 607 | return; |
610 | } | 608 | } |
611 | server = m_SmtpAccount->getServer().latin1(); | 609 | server = m_SmtpAccount->getServer().latin1(); |
612 | if ( m_SmtpAccount->ConnectionType() == 2 ) { | 610 | if ( m_SmtpAccount->ConnectionType() == 2 ) { |
613 | ssl = true; | 611 | ssl = true; |
614 | try_tls = false; | 612 | try_tls = false; |
615 | } else if (m_SmtpAccount->ConnectionType() == 1) { | 613 | } else if (m_SmtpAccount->ConnectionType() == 1) { |
616 | force_tls = true; | 614 | force_tls = true; |
617 | } | 615 | } |
618 | int result = 1; | 616 | int result = 1; |
619 | port = m_SmtpAccount->getPort().toUInt(); | 617 | port = m_SmtpAccount->getPort().toUInt(); |
620 | 618 | ||
621 | m_smtp = mailsmtp_new( 20, &progress ); | 619 | m_smtp = mailsmtp_new( 20, &progress ); |
622 | if ( m_smtp == NULL ) { | 620 | if ( m_smtp == NULL ) { |
623 | /* no failure message cause this happens when problems with memory - than we | 621 | /* no failure message cause this happens when problems with memory - than we |
624 | we can not display any messagebox */ | 622 | we can not display any messagebox */ |
625 | return; | 623 | return; |
626 | } | 624 | } |
627 | 625 | ||
628 | int err = MAILSMTP_NO_ERROR; | 626 | int err = MAILSMTP_NO_ERROR; |
629 | qDebug( "Servername %s at port %i", server, port ); | 627 | qDebug( "Servername %s at port %i", server, port ); |
630 | if ( ssl ) { | 628 | if ( ssl ) { |
631 | qDebug( "SSL session" ); | 629 | qDebug( "SSL session" ); |
632 | err = mailsmtp_ssl_connect( m_smtp, server, port ); | 630 | err = mailsmtp_ssl_connect( m_smtp, server, port ); |
633 | } else { | 631 | } else { |
634 | qDebug( "No SSL session" ); | 632 | qDebug( "No SSL session" ); |
635 | err = mailsmtp_socket_connect( m_smtp, server, port ); | 633 | err = mailsmtp_socket_connect( m_smtp, server, port ); |
636 | } | 634 | } |
637 | if ( err != MAILSMTP_NO_ERROR ) { | 635 | if ( err != MAILSMTP_NO_ERROR ) { |
638 | qDebug("Error init connection"); | 636 | qDebug("Error init connection"); |
639 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 637 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
640 | result = 0; | 638 | result = 0; |
641 | } | 639 | } |
642 | 640 | ||
643 | /* switch to tls after init 'cause there it will send the ehlo */ | 641 | /* switch to tls after init 'cause there it will send the ehlo */ |
644 | if (result) { | 642 | if (result) { |
645 | err = mailsmtp_init( m_smtp ); | 643 | err = mailsmtp_init( m_smtp ); |
646 | if (err != MAILSMTP_NO_ERROR) { | 644 | if (err != MAILSMTP_NO_ERROR) { |
647 | result = 0; | 645 | result = 0; |
648 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); | 646 | failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); |
649 | } | 647 | } |
650 | } | 648 | } |
651 | 649 | ||
652 | if (try_tls) { | 650 | if (try_tls) { |
653 | err = start_smtp_tls(); | 651 | err = start_smtp_tls(); |
654 | if (err != MAILSMTP_NO_ERROR) { | 652 | if (err != MAILSMTP_NO_ERROR) { |
655 | try_tls = false; | 653 | try_tls = false; |
656 | } else { | 654 | } else { |
657 | err = mailesmtp_ehlo(m_smtp); | 655 | err = mailesmtp_ehlo(m_smtp); |
658 | } | 656 | } |
659 | } | 657 | } |
660 | 658 | ||
661 | if (!try_tls && force_tls) { | 659 | if (!try_tls && force_tls) { |
662 | result = 0; | 660 | result = 0; |
663 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); | 661 | failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); |
664 | } | 662 | } |
665 | 663 | ||
666 | if (result==1 && m_SmtpAccount->getLogin() ) { | 664 | if (result==1 && m_SmtpAccount->getLogin() ) { |
667 | qDebug("smtp with auth"); | 665 | qDebug("smtp with auth"); |
668 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { | 666 | if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { |
669 | // get'em | 667 | // get'em |
670 | LoginDialog login( m_SmtpAccount->getUser(), | 668 | LoginDialog login( m_SmtpAccount->getUser(), |
671 | m_SmtpAccount->getPassword(), NULL, 0, true ); | 669 | m_SmtpAccount->getPassword(), NULL, 0, true ); |
672 | login.show(); | 670 | login.show(); |
673 | if ( QDialog::Accepted == login.exec() ) { | 671 | if ( QDialog::Accepted == login.exec() ) { |
674 | // ok | 672 | // ok |
675 | user = login.getUser().latin1(); | 673 | user = login.getUser().latin1(); |
676 | pass = login.getPassword().latin1(); | 674 | pass = login.getPassword().latin1(); |
677 | } else { | 675 | } else { |
678 | result = 0; | 676 | result = 0; |
679 | failuretext=tr("Login aborted - storing mail to localfolder"); | 677 | failuretext=tr("Login aborted - storing mail to localfolder"); |
680 | } | 678 | } |
681 | } else { | 679 | } else { |
682 | user = m_SmtpAccount->getUser().latin1(); | 680 | user = m_SmtpAccount->getUser().latin1(); |
683 | pass = m_SmtpAccount->getPassword().latin1(); | 681 | pass = m_SmtpAccount->getPassword().latin1(); |
684 | } | 682 | } |
685 | qDebug( "session->auth: %i", m_smtp->auth); | 683 | qDebug( "session->auth: %i", m_smtp->auth); |
686 | if (result) { | 684 | if (result) { |
687 | err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); | 685 | err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); |
688 | if ( err == MAILSMTP_NO_ERROR ) { | 686 | if ( err == MAILSMTP_NO_ERROR ) { |
689 | qDebug("auth ok"); | 687 | qDebug("auth ok"); |
690 | } else { | 688 | } else { |
691 | failuretext = tr("Authentification failed"); | 689 | failuretext = tr("Authentification failed"); |
692 | result = 0; | 690 | result = 0; |
693 | } | 691 | } |
694 | } | 692 | } |
695 | } | 693 | } |
696 | } | 694 | } |
697 | 695 | ||
698 | void SMTPwrapper::disc_server() | 696 | void SMTPwrapper::disc_server() |
699 | { | 697 | { |
700 | if (m_smtp) { | 698 | if (m_smtp) { |
701 | mailsmtp_quit( m_smtp ); | 699 | mailsmtp_quit( m_smtp ); |
702 | mailsmtp_free( m_smtp ); | 700 | mailsmtp_free( m_smtp ); |
703 | m_smtp = 0; | 701 | m_smtp = 0; |
704 | } | 702 | } |
705 | } | 703 | } |
706 | 704 | ||
707 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) | 705 | int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) |
708 | { | 706 | { |
709 | int err,result; | 707 | int err,result; |
710 | QString failuretext = ""; | 708 | QString failuretext = ""; |
711 | 709 | ||
712 | connect_server(); | 710 | connect_server(); |
713 | 711 | ||
714 | result = 1; | 712 | result = 1; |
715 | if (m_smtp) { | 713 | if (m_smtp) { |
716 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); | 714 | err = mailsmtp_send( m_smtp, from, rcpts, data, size ); |
717 | if ( err != MAILSMTP_NO_ERROR ) { | 715 | if ( err != MAILSMTP_NO_ERROR ) { |
718 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); | 716 | failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); |
719 | result = 0; | 717 | result = 0; |
720 | } | 718 | } |
721 | } else { | 719 | } else { |
722 | result = 0; | 720 | result = 0; |
723 | } | 721 | } |
724 | 722 | ||
725 | if (!result) { | 723 | if (!result) { |
726 | storeFailedMail(data,size,failuretext); | 724 | storeFailedMail(data,size,failuretext); |
727 | } else { | 725 | } else { |
728 | qDebug( "Mail sent." ); | 726 | qDebug( "Mail sent." ); |
729 | storeMail(data,size,"Sent"); | 727 | storeMail(data,size,"Sent"); |
730 | } | 728 | } |
731 | return result; | 729 | return result; |
732 | } | 730 | } |
733 | 731 | ||
734 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) | 732 | void SMTPwrapper::sendMail(const Mail&mail,bool later ) |
735 | { | 733 | { |
736 | mailmime * mimeMail; | 734 | mailmime * mimeMail; |
737 | 735 | ||
738 | mimeMail = createMimeMail(mail ); | 736 | mimeMail = createMimeMail(mail ); |
739 | if ( mimeMail == NULL ) { | 737 | if ( mimeMail == NULL ) { |
740 | qDebug( "sendMail: error creating mime mail" ); | 738 | qDebug( "sendMail: error creating mime mail" ); |
741 | } else { | 739 | } else { |
742 | sendProgress = new progressMailSend(); | 740 | sendProgress = new progressMailSend(); |
743 | sendProgress->show(); | 741 | sendProgress->show(); |
744 | sendProgress->setMaxMails(1); | 742 | sendProgress->setMaxMails(1); |
745 | smtpSend( mimeMail,later); | 743 | smtpSend( mimeMail,later); |
746 | qDebug("Clean up done"); | 744 | qDebug("Clean up done"); |
747 | sendProgress->hide(); | 745 | sendProgress->hide(); |
748 | delete sendProgress; | 746 | delete sendProgress; |
749 | sendProgress = 0; | 747 | sendProgress = 0; |
750 | mailmime_free( mimeMail ); | 748 | mailmime_free( mimeMail ); |
751 | } | 749 | } |
752 | } | 750 | } |
753 | 751 | ||
754 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) { | 752 | int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,RecMail*which) { |
755 | size_t curTok = 0; | 753 | size_t curTok = 0; |
756 | mailimf_fields *fields = 0; | 754 | mailimf_fields *fields = 0; |
757 | mailimf_field*ffrom = 0; | 755 | mailimf_field*ffrom = 0; |
758 | clist *rcpts = 0; | 756 | clist *rcpts = 0; |
759 | char*from = 0; | 757 | char*from = 0; |
760 | int res = 0; | 758 | int res = 0; |
761 | 759 | ||
762 | encodedString * data = wrap->fetchRawBody(*which); | 760 | encodedString * data = wrap->fetchRawBody(*which); |
763 | if (!data) | 761 | if (!data) |
764 | return 0; | 762 | return 0; |
765 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); | 763 | int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); |
766 | if (err != MAILIMF_NO_ERROR) { | 764 | if (err != MAILIMF_NO_ERROR) { |
767 | delete data; | 765 | delete data; |
768 | delete wrap; | 766 | delete wrap; |
769 | return 0; | 767 | return 0; |
770 | } | 768 | } |
771 | 769 | ||
772 | rcpts = createRcptList( fields ); | 770 | rcpts = createRcptList( fields ); |
773 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); | 771 | ffrom = getField(fields, MAILIMF_FIELD_FROM ); |
774 | from = getFrom(ffrom); | 772 | from = getFrom(ffrom); |
775 | 773 | ||
776 | if (rcpts && from) { | 774 | if (rcpts && from) { |
777 | res = smtpSend(from,rcpts,data->Content(),data->Length()); | 775 | res = smtpSend(from,rcpts,data->Content(),data->Length()); |
778 | } | 776 | } |
779 | if (fields) { | 777 | if (fields) { |
780 | mailimf_fields_free(fields); | 778 | mailimf_fields_free(fields); |
781 | fields = 0; | 779 | fields = 0; |
782 | } | 780 | } |
783 | if (data) { | 781 | if (data) { |
784 | delete data; | 782 | delete data; |
785 | } | 783 | } |
786 | if (from) { | 784 | if (from) { |
787 | free(from); | 785 | free(from); |
788 | } | 786 | } |
789 | if (rcpts) { | 787 | if (rcpts) { |
790 | smtp_address_list_free( rcpts ); | 788 | smtp_address_list_free( rcpts ); |
791 | } | 789 | } |
792 | return res; | 790 | return res; |
793 | } | 791 | } |
794 | 792 | ||
795 | /* this is a special fun */ | 793 | /* this is a special fun */ |
796 | bool SMTPwrapper::flushOutbox() { | 794 | bool SMTPwrapper::flushOutbox() { |
797 | bool returnValue = true; | 795 | bool returnValue = true; |
798 | 796 | ||
799 | qDebug("Sending the queue"); | 797 | qDebug("Sending the queue"); |
800 | if (!m_SmtpAccount) { | 798 | if (!m_SmtpAccount) { |
801 | qDebug("No smtp account given"); | 799 | qDebug("No smtp account given"); |
802 | return false; | 800 | return false; |
803 | } | 801 | } |
804 | 802 | ||
805 | bool reset_user_value = false; | 803 | bool reset_user_value = false; |
806 | QString localfolders = AbstractMail::defaultLocalfolder(); | 804 | QString localfolders = AbstractMail::defaultLocalfolder(); |
807 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); | 805 | AbstractMail*wrap = AbstractMail::getWrapper(localfolders); |
808 | if (!wrap) { | 806 | if (!wrap) { |
809 | qDebug("memory error"); | 807 | qDebug("memory error"); |
810 | return false; | 808 | return false; |
811 | } | 809 | } |
812 | QString oldPw, oldUser; | 810 | QString oldPw, oldUser; |
813 | QList<RecMail> mailsToSend; | 811 | QList<RecMail> mailsToSend; |
814 | QList<RecMail> mailsToRemove; | 812 | QList<RecMail> mailsToRemove; |
815 | QString mbox("Outgoing"); | 813 | QString mbox("Outgoing"); |
816 | wrap->listMessages(mbox,mailsToSend); | 814 | wrap->listMessages(mbox,mailsToSend); |
817 | if (mailsToSend.count()==0) { | 815 | if (mailsToSend.count()==0) { |
818 | delete wrap; | 816 | delete wrap; |
819 | qDebug("No mails to send"); | 817 | qDebug("No mails to send"); |
820 | return false; | 818 | return false; |
821 | } | 819 | } |
822 | 820 | ||
823 | oldPw = m_SmtpAccount->getPassword(); | 821 | oldPw = m_SmtpAccount->getPassword(); |
824 | oldUser = m_SmtpAccount->getUser(); | 822 | oldUser = m_SmtpAccount->getUser(); |
825 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { | 823 | if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { |
826 | // get'em | 824 | // get'em |
827 | QString user,pass; | 825 | QString user,pass; |
828 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); | 826 | LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); |
829 | login.show(); | 827 | login.show(); |
830 | if ( QDialog::Accepted == login.exec() ) { | 828 | if ( QDialog::Accepted == login.exec() ) { |
831 | // ok | 829 | // ok |
832 | user = login.getUser().latin1(); | 830 | user = login.getUser().latin1(); |
833 | pass = login.getPassword().latin1(); | 831 | pass = login.getPassword().latin1(); |
834 | reset_user_value = true; | 832 | reset_user_value = true; |
835 | m_SmtpAccount->setUser(user); | 833 | m_SmtpAccount->setUser(user); |
836 | m_SmtpAccount->setPassword(pass); | 834 | m_SmtpAccount->setPassword(pass); |
837 | } else { | 835 | } else { |
838 | return true; | 836 | return true; |
839 | } | 837 | } |
840 | } | 838 | } |
841 | 839 | ||
842 | 840 | ||
843 | mailsToSend.setAutoDelete(false); | 841 | mailsToSend.setAutoDelete(false); |
844 | sendProgress = new progressMailSend(); | 842 | sendProgress = new progressMailSend(); |
845 | sendProgress->show(); | 843 | sendProgress->show(); |
846 | sendProgress->setMaxMails(mailsToSend.count()); | 844 | sendProgress->setMaxMails(mailsToSend.count()); |
847 | 845 | ||
848 | while (mailsToSend.count()>0) { | 846 | while (mailsToSend.count()>0) { |
849 | if (sendQueuedMail(wrap,mailsToSend.at(0))==0) { | 847 | if (sendQueuedMail(wrap,mailsToSend.at(0))==0) { |
850 | QMessageBox::critical(0,tr("Error sending mail"), | 848 | QMessageBox::critical(0,tr("Error sending mail"), |
851 | tr("Error sending queued mail - breaking")); | 849 | tr("Error sending queued mail - breaking")); |
852 | returnValue = false; | 850 | returnValue = false; |
853 | break; | 851 | break; |
854 | } | 852 | } |
855 | mailsToRemove.append(mailsToSend.at(0)); | 853 | mailsToRemove.append(mailsToSend.at(0)); |
856 | mailsToSend.removeFirst(); | 854 | mailsToSend.removeFirst(); |
857 | sendProgress->setCurrentMails(mailsToRemove.count()); | 855 | sendProgress->setCurrentMails(mailsToRemove.count()); |
858 | } | 856 | } |
859 | if (reset_user_value) { | 857 | if (reset_user_value) { |
860 | m_SmtpAccount->setUser(oldUser); | 858 | m_SmtpAccount->setUser(oldUser); |
861 | m_SmtpAccount->setPassword(oldPw); | 859 | m_SmtpAccount->setPassword(oldPw); |
862 | } | 860 | } |
863 | Config cfg( "mail" ); | 861 | Config cfg( "mail" ); |
864 | cfg.setGroup( "Status" ); | 862 | cfg.setGroup( "Status" ); |
865 | m_queuedMail = 0; | 863 | m_queuedMail = 0; |
866 | cfg.writeEntry( "outgoing", m_queuedMail ); | 864 | cfg.writeEntry( "outgoing", m_queuedMail ); |
867 | emit queuedMails( m_queuedMail ); | 865 | emit queuedMails( m_queuedMail ); |
868 | sendProgress->hide(); | 866 | sendProgress->hide(); |
869 | delete sendProgress; | 867 | delete sendProgress; |
870 | sendProgress = 0; | 868 | sendProgress = 0; |
871 | wrap->deleteMails(mbox,mailsToRemove); | 869 | wrap->deleteMails(mbox,mailsToRemove); |
872 | mailsToSend.setAutoDelete(true); | 870 | mailsToSend.setAutoDelete(true); |
873 | delete wrap; | 871 | delete wrap; |
874 | return returnValue; | 872 | return returnValue; |
875 | } | 873 | } |
diff --git a/noncore/net/mail/libmailwrapper/statusmail.cpp b/noncore/net/mail/libmailwrapper/statusmail.cpp index 172c58f..4134e79 100644 --- a/noncore/net/mail/libmailwrapper/statusmail.cpp +++ b/noncore/net/mail/libmailwrapper/statusmail.cpp | |||
@@ -1,91 +1,90 @@ | |||
1 | #include "statusmail.h" | 1 | #include "statusmail.h" |
2 | #include <qlist.h> | ||
3 | 2 | ||
4 | StatusMail::StatusMail(QList<Account>&list) | 3 | StatusMail::StatusMail(QList<Account>&list) |
5 | { | 4 | { |
6 | currentImapStat.message_count=0; | 5 | currentImapStat.message_count=0; |
7 | currentImapStat.message_unseen=0; | 6 | currentImapStat.message_unseen=0; |
8 | currentImapStat.message_recent=0; | 7 | currentImapStat.message_recent=0; |
9 | lastPop3Stat = currentImapStat; | 8 | lastPop3Stat = currentImapStat; |
10 | currentPop3Stat = currentImapStat; | 9 | currentPop3Stat = currentImapStat; |
11 | connectionList.setAutoDelete(true); | 10 | connectionList.setAutoDelete(true); |
12 | connectionList.clear(); | 11 | connectionList.clear(); |
13 | initAccounts(list); | 12 | initAccounts(list); |
14 | } | 13 | } |
15 | 14 | ||
16 | StatusMail::~StatusMail() | 15 | StatusMail::~StatusMail() |
17 | { | 16 | { |
18 | } | 17 | } |
19 | 18 | ||
20 | void StatusMail::initAccounts(QList<Account>&accounts) | 19 | void StatusMail::initAccounts(QList<Account>&accounts) |
21 | { | 20 | { |
22 | 21 | ||
23 | Account *it; | 22 | Account *it; |
24 | folderStat currentStat; | 23 | folderStat currentStat; |
25 | AbstractMail * current = 0; | 24 | AbstractMail * current = 0; |
26 | currentPop3Stat.message_count=0; | 25 | currentPop3Stat.message_count=0; |
27 | currentPop3Stat.message_recent=0; | 26 | currentPop3Stat.message_recent=0; |
28 | currentPop3Stat.message_unseen=0; | 27 | currentPop3Stat.message_unseen=0; |
29 | for ( it = accounts.first(); it; it = accounts.next() ) { | 28 | for ( it = accounts.first(); it; it = accounts.next() ) { |
30 | if ( it->getType().compare( "IMAP" ) == 0 && !it->getOffline() ) { | 29 | if ( it->getType().compare( "IMAP" ) == 0 && !it->getOffline() ) { |
31 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); | 30 | IMAPaccount*ima = static_cast<IMAPaccount *>(it); |
32 | current = AbstractMail::getWrapper(ima); | 31 | current = AbstractMail::getWrapper(ima); |
33 | connectionList.append(current); | 32 | connectionList.append(current); |
34 | current->statusFolder(currentStat); | 33 | current->statusFolder(currentStat); |
35 | currentImapStat.message_count+=currentStat.message_unseen; | 34 | currentImapStat.message_count+=currentStat.message_unseen; |
36 | currentImapStat.message_count+=currentStat.message_recent; | 35 | currentImapStat.message_count+=currentStat.message_recent; |
37 | currentImapStat.message_count+=currentStat.message_count; | 36 | currentImapStat.message_count+=currentStat.message_count; |
38 | } else if ( it->getType().compare( "POP3" ) == 0 && !it->getOffline() ) { | 37 | } else if ( it->getType().compare( "POP3" ) == 0 && !it->getOffline() ) { |
39 | POP3account *pop3 = static_cast<POP3account *>(it); | 38 | POP3account *pop3 = static_cast<POP3account *>(it); |
40 | current = AbstractMail::getWrapper(pop3); | 39 | current = AbstractMail::getWrapper(pop3); |
41 | connectionList.append(current); | 40 | connectionList.append(current); |
42 | current->statusFolder(currentStat); | 41 | current->statusFolder(currentStat); |
43 | currentPop3Stat.message_count+=currentStat.message_count; | 42 | currentPop3Stat.message_count+=currentStat.message_count; |
44 | } | 43 | } |
45 | current->logout(); | 44 | current->logout(); |
46 | } | 45 | } |
47 | qDebug("Pop3 init count: %i",currentPop3Stat.message_count); | 46 | qDebug("Pop3 init count: %i",currentPop3Stat.message_count); |
48 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | 47 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; |
49 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; | 48 | lastPop3Stat.message_unseen = currentPop3Stat.message_unseen; |
50 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; | 49 | lastPop3Stat.message_recent = currentPop3Stat.message_recent; |
51 | lastPop3Stat.message_count = currentPop3Stat.message_count; | 50 | lastPop3Stat.message_count = currentPop3Stat.message_count; |
52 | } | 51 | } |
53 | 52 | ||
54 | void StatusMail::reset_status() | 53 | void StatusMail::reset_status() |
55 | { | 54 | { |
56 | lastPop3Stat = currentPop3Stat; | 55 | lastPop3Stat = currentPop3Stat; |
57 | } | 56 | } |
58 | 57 | ||
59 | void StatusMail::check_current_stat(folderStat&targetStat) | 58 | void StatusMail::check_current_stat(folderStat&targetStat) |
60 | { | 59 | { |
61 | AbstractMail*it = 0; | 60 | AbstractMail*it = 0; |
62 | folderStat currentStat; | 61 | folderStat currentStat; |
63 | currentPop3Stat.message_recent = 0; | 62 | currentPop3Stat.message_recent = 0; |
64 | currentPop3Stat.message_count = 0; | 63 | currentPop3Stat.message_count = 0; |
65 | currentPop3Stat.message_unseen = 0; | 64 | currentPop3Stat.message_unseen = 0; |
66 | currentImapStat = currentPop3Stat; | 65 | currentImapStat = currentPop3Stat; |
67 | for ( it = connectionList.first(); it; it = connectionList.next() ) { | 66 | for ( it = connectionList.first(); it; it = connectionList.next() ) { |
68 | it->statusFolder(currentStat); | 67 | it->statusFolder(currentStat); |
69 | it->logout(); | 68 | it->logout(); |
70 | if (it->getType().lower()=="imap") { | 69 | if (it->getType().lower()=="imap") { |
71 | currentImapStat.message_unseen+=currentStat.message_unseen; | 70 | currentImapStat.message_unseen+=currentStat.message_unseen; |
72 | currentImapStat.message_recent+=currentStat.message_recent; | 71 | currentImapStat.message_recent+=currentStat.message_recent; |
73 | currentImapStat.message_count+=currentStat.message_count; | 72 | currentImapStat.message_count+=currentStat.message_count; |
74 | } else if (it->getType().lower()=="pop3") { | 73 | } else if (it->getType().lower()=="pop3") { |
75 | currentPop3Stat.message_count+=currentStat.message_count; | 74 | currentPop3Stat.message_count+=currentStat.message_count; |
76 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); | 75 | qDebug("Pop3 count: %i",currentPop3Stat.message_count); |
77 | } | 76 | } |
78 | } | 77 | } |
79 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); | 78 | qDebug("Pop3 last: %i",lastPop3Stat.message_count); |
80 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { | 79 | if (currentPop3Stat.message_count > lastPop3Stat.message_count) { |
81 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; | 80 | currentPop3Stat.message_recent = currentPop3Stat.message_count - lastPop3Stat.message_count; |
82 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; | 81 | currentPop3Stat.message_unseen = currentPop3Stat.message_recent; |
83 | } else { | 82 | } else { |
84 | lastPop3Stat.message_count = currentPop3Stat.message_count; | 83 | lastPop3Stat.message_count = currentPop3Stat.message_count; |
85 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; | 84 | currentPop3Stat.message_recent = currentPop3Stat.message_unseen = 0; |
86 | } | 85 | } |
87 | targetStat = currentImapStat; | 86 | targetStat = currentImapStat; |
88 | targetStat.message_unseen+=currentPop3Stat.message_unseen; | 87 | targetStat.message_unseen+=currentPop3Stat.message_unseen; |
89 | targetStat.message_recent+=currentPop3Stat.message_recent; | 88 | targetStat.message_recent+=currentPop3Stat.message_recent; |
90 | targetStat.message_count+=currentPop3Stat.message_count; | 89 | targetStat.message_count+=currentPop3Stat.message_count; |
91 | } | 90 | } |
diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 3f34fe7..bcf0866 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp | |||
@@ -1,217 +1,215 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qvbox.h> | 2 | #include <qvbox.h> |
3 | #include <qheader.h> | 3 | #include <qheader.h> |
4 | #include <qtimer.h> | 4 | #include <qtimer.h> |
5 | #include <qlayout.h> | 5 | #include <qlayout.h> |
6 | #include <qmessagebox.h> | ||
7 | 6 | ||
8 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/resource.h> | ||
10 | 8 | ||
11 | #include "defines.h" | 9 | #include "defines.h" |
12 | #include "mainwindow.h" | 10 | #include "mainwindow.h" |
13 | 11 | ||
14 | 12 | ||
15 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) | 13 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) |
16 | : QMainWindow( parent, name, flags ) | 14 | : QMainWindow( parent, name, flags ) |
17 | { | 15 | { |
18 | 16 | ||
19 | setCaption( tr( "Mail" ) ); | 17 | setCaption( tr( "Mail" ) ); |
20 | setToolBarsMovable( false ); | 18 | setToolBarsMovable( false ); |
21 | 19 | ||
22 | toolBar = new QToolBar( this ); | 20 | toolBar = new QToolBar( this ); |
23 | menuBar = new QMenuBar( toolBar ); | 21 | menuBar = new QMenuBar( toolBar ); |
24 | mailMenu = new QPopupMenu( menuBar ); | 22 | mailMenu = new QPopupMenu( menuBar ); |
25 | menuBar->insertItem( tr( "Mail" ), mailMenu ); | 23 | menuBar->insertItem( tr( "Mail" ), mailMenu ); |
26 | settingsMenu = new QPopupMenu( menuBar ); | 24 | settingsMenu = new QPopupMenu( menuBar ); |
27 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); | 25 | menuBar->insertItem( tr( "Settings" ), settingsMenu ); |
28 | 26 | ||
29 | addToolBar( toolBar ); | 27 | addToolBar( toolBar ); |
30 | toolBar->setHorizontalStretchable( true ); | 28 | toolBar->setHorizontalStretchable( true ); |
31 | 29 | ||
32 | QLabel *spacer = new QLabel( toolBar ); | 30 | QLabel *spacer = new QLabel( toolBar ); |
33 | spacer->setBackgroundMode( QWidget::PaletteButton ); | 31 | spacer->setBackgroundMode( QWidget::PaletteButton ); |
34 | toolBar->setStretchableWidget( spacer ); | 32 | toolBar->setStretchableWidget( spacer ); |
35 | 33 | ||
36 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, | 34 | composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, |
37 | 0, 0, this ); | 35 | 0, 0, this ); |
38 | composeMail->addTo( toolBar ); | 36 | composeMail->addTo( toolBar ); |
39 | composeMail->addTo( mailMenu ); | 37 | composeMail->addTo( mailMenu ); |
40 | 38 | ||
41 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, | 39 | sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, |
42 | 0, 0, this ); | 40 | 0, 0, this ); |
43 | sendQueued->addTo( toolBar ); | 41 | sendQueued->addTo( toolBar ); |
44 | sendQueued->addTo( mailMenu ); | 42 | sendQueued->addTo( mailMenu ); |
45 | 43 | ||
46 | /* | 44 | /* |
47 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, | 45 | syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, |
48 | 0, 0, this ); | 46 | 0, 0, this ); |
49 | syncFolders->addTo( toolBar ); | 47 | syncFolders->addTo( toolBar ); |
50 | syncFolders->addTo( mailMenu ); | 48 | syncFolders->addTo( mailMenu ); |
51 | */ | 49 | */ |
52 | 50 | ||
53 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, | 51 | showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, |
54 | 0, 0, this, 0, true ); | 52 | 0, 0, this, 0, true ); |
55 | showFolders->addTo( toolBar ); | 53 | showFolders->addTo( toolBar ); |
56 | showFolders->addTo( mailMenu ); | 54 | showFolders->addTo( mailMenu ); |
57 | showFolders->setOn( true ); | 55 | showFolders->setOn( true ); |
58 | connect(showFolders, SIGNAL( toggled(bool) ), | 56 | connect(showFolders, SIGNAL( toggled(bool) ), |
59 | SLOT( slotShowFolders(bool) ) ); | 57 | SLOT( slotShowFolders(bool) ) ); |
60 | 58 | ||
61 | /* | 59 | /* |
62 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), | 60 | searchMails = new QAction( tr( "Search mails" ), QIconSet( Resource::loadPixmap("find") ), |
63 | 0, 0, this ); | 61 | 0, 0, this ); |
64 | searchMails->addTo( toolBar ); | 62 | searchMails->addTo( toolBar ); |
65 | searchMails->addTo( mailMenu ); | 63 | searchMails->addTo( mailMenu ); |
66 | */ | 64 | */ |
67 | 65 | ||
68 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); | 66 | deleteMails = new QAction(tr("Delete Mail"), QIconSet( Resource::loadPixmap("trash")), 0, 0, this); |
69 | deleteMails->addTo( toolBar ); | 67 | deleteMails->addTo( toolBar ); |
70 | deleteMails->addTo( mailMenu ); | 68 | deleteMails->addTo( mailMenu ); |
71 | connect( deleteMails, SIGNAL( activated() ), | 69 | connect( deleteMails, SIGNAL( activated() ), |
72 | SLOT( slotDeleteMail() ) ); | 70 | SLOT( slotDeleteMail() ) ); |
73 | 71 | ||
74 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , | 72 | editSettings = new QAction( tr( "Edit settings" ), QIconSet( Resource::loadPixmap("SettingsIcon") ) , |
75 | 0, 0, this ); | 73 | 0, 0, this ); |
76 | editSettings->addTo( settingsMenu ); | 74 | editSettings->addTo( settingsMenu ); |
77 | connect( editSettings, SIGNAL( activated() ), | 75 | connect( editSettings, SIGNAL( activated() ), |
78 | SLOT( slotEditSettings() ) ); | 76 | SLOT( slotEditSettings() ) ); |
79 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , | 77 | editAccounts = new QAction( tr( "Configure accounts" ), QIconSet( Resource::loadPixmap("mail/editaccounts") ) , |
80 | 0, 0, this ); | 78 | 0, 0, this ); |
81 | editAccounts->addTo( settingsMenu ); | 79 | editAccounts->addTo( settingsMenu ); |
82 | 80 | ||
83 | //setCentralWidget( view ); | 81 | //setCentralWidget( view ); |
84 | 82 | ||
85 | QVBox* wrapperBox = new QVBox( this ); | 83 | QVBox* wrapperBox = new QVBox( this ); |
86 | setCentralWidget( wrapperBox ); | 84 | setCentralWidget( wrapperBox ); |
87 | 85 | ||
88 | QWidget *view = new QWidget( wrapperBox ); | 86 | QWidget *view = new QWidget( wrapperBox ); |
89 | 87 | ||
90 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); | 88 | layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); |
91 | 89 | ||
92 | folderView = new AccountView( view ); | 90 | folderView = new AccountView( view ); |
93 | folderView->header()->hide(); | 91 | folderView->header()->hide(); |
94 | folderView->setRootIsDecorated( true ); | 92 | folderView->setRootIsDecorated( true ); |
95 | folderView->addColumn( tr( "Mailbox" ) ); | 93 | folderView->addColumn( tr( "Mailbox" ) ); |
96 | 94 | ||
97 | layout->addWidget( folderView ); | 95 | layout->addWidget( folderView ); |
98 | 96 | ||
99 | mailView = new QListView( view ); | 97 | mailView = new QListView( view ); |
100 | mailView->addColumn( tr( "" ) ); | 98 | mailView->addColumn( tr( "" ) ); |
101 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); | 99 | mailView->addColumn( tr( "Subject" ),QListView::Manual ); |
102 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); | 100 | mailView->addColumn( tr( "Sender" ),QListView::Manual ); |
103 | mailView->addColumn( tr( "Size" ),QListView::Manual); | 101 | mailView->addColumn( tr( "Size" ),QListView::Manual); |
104 | mailView->addColumn( tr( "Date" )); | 102 | mailView->addColumn( tr( "Date" )); |
105 | mailView->setAllColumnsShowFocus(true); | 103 | mailView->setAllColumnsShowFocus(true); |
106 | mailView->setSorting(-1); | 104 | mailView->setSorting(-1); |
107 | 105 | ||
108 | statusWidget = new StatusWidget( wrapperBox ); | 106 | statusWidget = new StatusWidget( wrapperBox ); |
109 | statusWidget->hide(); | 107 | statusWidget->hide(); |
110 | 108 | ||
111 | layout->addWidget( mailView ); | 109 | layout->addWidget( mailView ); |
112 | layout->setStretchFactor( folderView, 1 ); | 110 | layout->setStretchFactor( folderView, 1 ); |
113 | layout->setStretchFactor( mailView, 2 ); | 111 | layout->setStretchFactor( mailView, 2 ); |
114 | 112 | ||
115 | slotAdjustLayout(); | 113 | slotAdjustLayout(); |
116 | 114 | ||
117 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); | 115 | QPEApplication::setStylusOperation( mailView->viewport(),QPEApplication::RightOnHold); |
118 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); | 116 | QPEApplication::setStylusOperation( folderView->viewport(),QPEApplication::RightOnHold); |
119 | 117 | ||
120 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, | 118 | connect( mailView, SIGNAL( mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),this, |
121 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); | 119 | SLOT( mailLeftClicked(int,QListViewItem*,const QPoint&,int) ) ); |
122 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, | 120 | connect( mailView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, |
123 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); | 121 | SLOT( mailHold(int,QListViewItem*,const QPoint&,int) ) ); |
124 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); | 122 | connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); |
125 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); | 123 | connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); |
126 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); | 124 | connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); |
127 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); | 125 | // connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); |
128 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); | 126 | connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); |
129 | // Added by Stefan Eilers to allow starting by addressbook.. | 127 | // Added by Stefan Eilers to allow starting by addressbook.. |
130 | // copied from old mail2 | 128 | // copied from old mail2 |
131 | #if !defined(QT_NO_COP) | 129 | #if !defined(QT_NO_COP) |
132 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 130 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), |
133 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 131 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); |
134 | #endif | 132 | #endif |
135 | 133 | ||
136 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); | 134 | QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); |
137 | } | 135 | } |
138 | 136 | ||
139 | MainWindow::~MainWindow() | 137 | MainWindow::~MainWindow() |
140 | { | 138 | { |
141 | } | 139 | } |
142 | 140 | ||
143 | void MainWindow::appMessage(const QCString &, const QByteArray &) | 141 | void MainWindow::appMessage(const QCString &, const QByteArray &) |
144 | { | 142 | { |
145 | qDebug("appMessage not reached"); | 143 | qDebug("appMessage not reached"); |
146 | } | 144 | } |
147 | 145 | ||
148 | void MainWindow::slotAdjustLayout() { | 146 | void MainWindow::slotAdjustLayout() { |
149 | 147 | ||
150 | QWidget *d = QApplication::desktop(); | 148 | QWidget *d = QApplication::desktop(); |
151 | 149 | ||
152 | if ( d->width() < d->height() ) { | 150 | if ( d->width() < d->height() ) { |
153 | layout->setDirection( QBoxLayout::TopToBottom ); | 151 | layout->setDirection( QBoxLayout::TopToBottom ); |
154 | } else { | 152 | } else { |
155 | layout->setDirection( QBoxLayout::LeftToRight ); | 153 | layout->setDirection( QBoxLayout::LeftToRight ); |
156 | } | 154 | } |
157 | } | 155 | } |
158 | 156 | ||
159 | void MainWindow::slotAdjustColumns() | 157 | void MainWindow::slotAdjustColumns() |
160 | { | 158 | { |
161 | bool hidden = folderView->isHidden(); | 159 | bool hidden = folderView->isHidden(); |
162 | if ( hidden ) folderView->show(); | 160 | if ( hidden ) folderView->show(); |
163 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); | 161 | folderView->setColumnWidth( 0, folderView->visibleWidth() ); |
164 | if ( hidden ) folderView->hide(); | 162 | if ( hidden ) folderView->hide(); |
165 | 163 | ||
166 | mailView->setColumnWidth( 0, 10 ); | 164 | mailView->setColumnWidth( 0, 10 ); |
167 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); | 165 | mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); |
168 | mailView->setColumnWidth( 2, 80 ); | 166 | mailView->setColumnWidth( 2, 80 ); |
169 | mailView->setColumnWidth( 3, 50 ); | 167 | mailView->setColumnWidth( 3, 50 ); |
170 | mailView->setColumnWidth( 4, 50 ); | 168 | mailView->setColumnWidth( 4, 50 ); |
171 | } | 169 | } |
172 | 170 | ||
173 | void MainWindow::slotEditSettings() | 171 | void MainWindow::slotEditSettings() |
174 | { | 172 | { |
175 | } | 173 | } |
176 | 174 | ||
177 | void MainWindow::slotShowFolders( bool ) | 175 | void MainWindow::slotShowFolders( bool ) |
178 | { | 176 | { |
179 | qDebug( "slotShowFolders not reached" ); | 177 | qDebug( "slotShowFolders not reached" ); |
180 | } | 178 | } |
181 | 179 | ||
182 | void MainWindow::refreshMailView(QList<RecMail>*) | 180 | void MainWindow::refreshMailView(QList<RecMail>*) |
183 | { | 181 | { |
184 | qDebug( "refreshMailView not reached" ); | 182 | qDebug( "refreshMailView not reached" ); |
185 | } | 183 | } |
186 | 184 | ||
187 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) | 185 | void MainWindow::mailLeftClicked(int, QListViewItem *,const QPoint&,int ) |
188 | { | 186 | { |
189 | qDebug( "mailLeftClicked not reached" ); | 187 | qDebug( "mailLeftClicked not reached" ); |
190 | } | 188 | } |
191 | 189 | ||
192 | void MainWindow::displayMail() | 190 | void MainWindow::displayMail() |
193 | { | 191 | { |
194 | qDebug("displayMail not reached"); | 192 | qDebug("displayMail not reached"); |
195 | } | 193 | } |
196 | 194 | ||
197 | void MainWindow::slotDeleteMail() | 195 | void MainWindow::slotDeleteMail() |
198 | { | 196 | { |
199 | qDebug("deleteMail not reached"); | 197 | qDebug("deleteMail not reached"); |
200 | } | 198 | } |
201 | 199 | ||
202 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) | 200 | void MainWindow::mailHold(int, QListViewItem *,const QPoint&,int ) |
203 | { | 201 | { |
204 | qDebug("mailHold not reached"); | 202 | qDebug("mailHold not reached"); |
205 | } | 203 | } |
206 | 204 | ||
207 | void MainWindow::slotSendQueued() | 205 | void MainWindow::slotSendQueued() |
208 | { | 206 | { |
209 | } | 207 | } |
210 | 208 | ||
211 | void MainWindow::slotEditAccounts() | 209 | void MainWindow::slotEditAccounts() |
212 | { | 210 | { |
213 | } | 211 | } |
214 | 212 | ||
215 | void MainWindow::slotComposeMail() | 213 | void MainWindow::slotComposeMail() |
216 | { | 214 | { |
217 | } | 215 | } |
diff --git a/noncore/net/mail/newmaildir.cpp b/noncore/net/mail/newmaildir.cpp index ab0d4e3..e6e9dc7 100644 --- a/noncore/net/mail/newmaildir.cpp +++ b/noncore/net/mail/newmaildir.cpp | |||
@@ -1,38 +1,36 @@ | |||
1 | #include "newmaildir.h" | 1 | #include "newmaildir.h" |
2 | #include <qdialog.h> | ||
3 | #include <qvariant.h> | ||
4 | #include <qlineedit.h> | 2 | #include <qlineedit.h> |
5 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
6 | 4 | ||
7 | Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name,bool no_sub) | 5 | Newmdirdlg::Newmdirdlg( QWidget* parent, const char* name,bool no_sub) |
8 | : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) | 6 | : Newmdirdlgui(parent,name,true),ndir(""),possible_subs(false) |
9 | { | 7 | { |
10 | if (no_sub) { | 8 | if (no_sub) { |
11 | subdirsPossibleBox->setChecked(false); | 9 | subdirsPossibleBox->setChecked(false); |
12 | subdirsPossibleBox->hide(); | 10 | subdirsPossibleBox->hide(); |
13 | } | 11 | } |
14 | } | 12 | } |
15 | 13 | ||
16 | Newmdirdlg::~Newmdirdlg() | 14 | Newmdirdlg::~Newmdirdlg() |
17 | { | 15 | { |
18 | } | 16 | } |
19 | 17 | ||
20 | void Newmdirdlg::accept() | 18 | void Newmdirdlg::accept() |
21 | { | 19 | { |
22 | ndir = dirnameEdit->text(); | 20 | ndir = dirnameEdit->text(); |
23 | possible_subs = subdirsPossibleBox->isChecked(); | 21 | possible_subs = subdirsPossibleBox->isChecked(); |
24 | if (ndir.isEmpty()) { | 22 | if (ndir.isEmpty()) { |
25 | return; | 23 | return; |
26 | } | 24 | } |
27 | Newmdirdlgui::accept(); | 25 | Newmdirdlgui::accept(); |
28 | } | 26 | } |
29 | 27 | ||
30 | const QString&Newmdirdlg::Newdir()const | 28 | const QString&Newmdirdlg::Newdir()const |
31 | { | 29 | { |
32 | return ndir; | 30 | return ndir; |
33 | } | 31 | } |
34 | 32 | ||
35 | const bool Newmdirdlg::subpossible()const | 33 | const bool Newmdirdlg::subpossible()const |
36 | { | 34 | { |
37 | return possible_subs; | 35 | return possible_subs; |
38 | } | 36 | } |
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index abf93dc..6bfc824 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -1,258 +1,254 @@ | |||
1 | 1 | ||
2 | #include "settingsdialog.h" | 2 | #include "settingsdialog.h" |
3 | #include "opiemail.h" | 3 | #include "opiemail.h" |
4 | #include "editaccounts.h" | 4 | #include "editaccounts.h" |
5 | #include "composemail.h" | 5 | #include "composemail.h" |
6 | #include "mailistviewitem.h" | 6 | #include "mailistviewitem.h" |
7 | #include "viewmail.h" | 7 | #include "viewmail.h" |
8 | #include "selectstore.h" | 8 | #include "selectstore.h" |
9 | #include "selectsmtp.h" | 9 | #include "selectsmtp.h" |
10 | 10 | ||
11 | /* OPIE */ | 11 | /* OPIE */ |
12 | #include <libmailwrapper/smtpwrapper.h> | 12 | #include <libmailwrapper/smtpwrapper.h> |
13 | #include <libmailwrapper/mailtypes.h> | 13 | #include <libmailwrapper/mailtypes.h> |
14 | #include <libmailwrapper/abstractmail.h> | 14 | #include <libmailwrapper/abstractmail.h> |
15 | #include <qpe/qcopenvelope_qws.h> | ||
16 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
17 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
18 | 17 | ||
19 | /* QT */ | 18 | /* QT */ |
20 | #include <qmessagebox.h> | ||
21 | #include <qaction.h> | ||
22 | #include <qapplication.h> | ||
23 | 19 | ||
24 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) | 20 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) |
25 | : MainWindow( parent, name, WStyle_ContextHelp ) | 21 | : MainWindow( parent, name, WStyle_ContextHelp ) |
26 | { | 22 | { |
27 | settings = new Settings(); | 23 | settings = new Settings(); |
28 | 24 | ||
29 | folderView->populate( settings->getAccounts() ); | 25 | folderView->populate( settings->getAccounts() ); |
30 | } | 26 | } |
31 | 27 | ||
32 | OpieMail::~OpieMail() | 28 | OpieMail::~OpieMail() |
33 | { | 29 | { |
34 | if (settings) delete settings; | 30 | if (settings) delete settings; |
35 | } | 31 | } |
36 | 32 | ||
37 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 33 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
38 | { | 34 | { |
39 | // copied from old mail2 | 35 | // copied from old mail2 |
40 | if (msg == "writeMail(QString,QString)") | 36 | if (msg == "writeMail(QString,QString)") |
41 | { | 37 | { |
42 | QDataStream stream(data,IO_ReadOnly); | 38 | QDataStream stream(data,IO_ReadOnly); |
43 | QString name, email; | 39 | QString name, email; |
44 | stream >> name >> email; | 40 | stream >> name >> email; |
45 | // removing the whitespaces at beginning and end is needed! | 41 | // removing the whitespaces at beginning and end is needed! |
46 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); | 42 | slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); |
47 | } | 43 | } |
48 | else if (msg == "newMail()") | 44 | else if (msg == "newMail()") |
49 | { | 45 | { |
50 | slotComposeMail(); | 46 | slotComposeMail(); |
51 | } | 47 | } |
52 | } | 48 | } |
53 | 49 | ||
54 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 50 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
55 | { | 51 | { |
56 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 52 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
57 | if (!email.isEmpty()) | 53 | if (!email.isEmpty()) |
58 | { | 54 | { |
59 | if (!name.isEmpty()) | 55 | if (!name.isEmpty()) |
60 | { | 56 | { |
61 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 57 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
62 | } | 58 | } |
63 | else | 59 | else |
64 | { | 60 | { |
65 | compose.setTo(email); | 61 | compose.setTo(email); |
66 | } | 62 | } |
67 | } | 63 | } |
68 | compose.slotAdjustColumns(); | 64 | compose.slotAdjustColumns(); |
69 | QPEApplication::execDialog( &compose ); | 65 | QPEApplication::execDialog( &compose ); |
70 | } | 66 | } |
71 | 67 | ||
72 | void OpieMail::slotComposeMail() | 68 | void OpieMail::slotComposeMail() |
73 | { | 69 | { |
74 | qDebug( "Compose Mail" ); | 70 | qDebug( "Compose Mail" ); |
75 | slotwriteMail(0l,0l); | 71 | slotwriteMail(0l,0l); |
76 | } | 72 | } |
77 | 73 | ||
78 | void OpieMail::slotSendQueued() | 74 | void OpieMail::slotSendQueued() |
79 | { | 75 | { |
80 | qDebug( "Send Queued" ); | 76 | qDebug( "Send Queued" ); |
81 | SMTPaccount *smtp = 0; | 77 | SMTPaccount *smtp = 0; |
82 | 78 | ||
83 | QList<Account> list = settings->getAccounts(); | 79 | QList<Account> list = settings->getAccounts(); |
84 | QList<SMTPaccount> smtpList; | 80 | QList<SMTPaccount> smtpList; |
85 | smtpList.setAutoDelete(false); | 81 | smtpList.setAutoDelete(false); |
86 | Account *it; | 82 | Account *it; |
87 | for ( it = list.first(); it; it = list.next() ) | 83 | for ( it = list.first(); it; it = list.next() ) |
88 | { | 84 | { |
89 | if ( it->getType().compare( "SMTP" ) == 0 ) | 85 | if ( it->getType().compare( "SMTP" ) == 0 ) |
90 | { | 86 | { |
91 | smtp = static_cast<SMTPaccount *>(it); | 87 | smtp = static_cast<SMTPaccount *>(it); |
92 | smtpList.append(smtp); | 88 | smtpList.append(smtp); |
93 | } | 89 | } |
94 | } | 90 | } |
95 | if (smtpList.count()==0) | 91 | if (smtpList.count()==0) |
96 | { | 92 | { |
97 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); | 93 | QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); |
98 | return; | 94 | return; |
99 | } | 95 | } |
100 | if (smtpList.count()==1) | 96 | if (smtpList.count()==1) |
101 | { | 97 | { |
102 | smtp = smtpList.at(0); | 98 | smtp = smtpList.at(0); |
103 | } | 99 | } |
104 | else | 100 | else |
105 | { | 101 | { |
106 | smtp = 0; | 102 | smtp = 0; |
107 | selectsmtp selsmtp; | 103 | selectsmtp selsmtp; |
108 | selsmtp.setSelectionlist(&smtpList); | 104 | selsmtp.setSelectionlist(&smtpList); |
109 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) | 105 | if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) |
110 | { | 106 | { |
111 | smtp = selsmtp.selected_smtp(); | 107 | smtp = selsmtp.selected_smtp(); |
112 | } | 108 | } |
113 | } | 109 | } |
114 | if (smtp) | 110 | if (smtp) |
115 | { | 111 | { |
116 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 112 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
117 | if ( wrap->flushOutbox() ) | 113 | if ( wrap->flushOutbox() ) |
118 | { | 114 | { |
119 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); | 115 | QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); |
120 | } | 116 | } |
121 | delete wrap; | 117 | delete wrap; |
122 | } | 118 | } |
123 | } | 119 | } |
124 | 120 | ||
125 | void OpieMail::slotSearchMails() | 121 | void OpieMail::slotSearchMails() |
126 | { | 122 | { |
127 | qDebug( "Search Mails" ); | 123 | qDebug( "Search Mails" ); |
128 | } | 124 | } |
129 | 125 | ||
130 | void OpieMail::slotEditSettings() | 126 | void OpieMail::slotEditSettings() |
131 | { | 127 | { |
132 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); | 128 | SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); |
133 | QPEApplication::execDialog( &settingsDialog ); | 129 | QPEApplication::execDialog( &settingsDialog ); |
134 | } | 130 | } |
135 | 131 | ||
136 | void OpieMail::slotEditAccounts() | 132 | void OpieMail::slotEditAccounts() |
137 | { | 133 | { |
138 | qDebug( "Edit Accounts" ); | 134 | qDebug( "Edit Accounts" ); |
139 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); | 135 | EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); |
140 | eaDialog.slotAdjustColumns(); | 136 | eaDialog.slotAdjustColumns(); |
141 | QPEApplication::execDialog( &eaDialog ); | 137 | QPEApplication::execDialog( &eaDialog ); |
142 | if ( settings ) delete settings; | 138 | if ( settings ) delete settings; |
143 | settings = new Settings(); | 139 | settings = new Settings(); |
144 | 140 | ||
145 | folderView->populate( settings->getAccounts() ); | 141 | folderView->populate( settings->getAccounts() ); |
146 | } | 142 | } |
147 | 143 | ||
148 | void OpieMail::displayMail() | 144 | void OpieMail::displayMail() |
149 | { | 145 | { |
150 | QListViewItem*item = mailView->currentItem(); | 146 | QListViewItem*item = mailView->currentItem(); |
151 | if (!item) return; | 147 | if (!item) return; |
152 | RecMail mail = ((MailListViewItem*)item)->data(); | 148 | RecMail mail = ((MailListViewItem*)item)->data(); |
153 | RecBody body = folderView->fetchBody(mail); | 149 | RecBody body = folderView->fetchBody(mail); |
154 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); | 150 | ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); |
155 | readMail.setBody( body ); | 151 | readMail.setBody( body ); |
156 | readMail.setMail( mail ); | 152 | readMail.setMail( mail ); |
157 | readMail.showMaximized(); | 153 | readMail.showMaximized(); |
158 | readMail.exec(); | 154 | readMail.exec(); |
159 | 155 | ||
160 | if ( readMail.deleted ) | 156 | if ( readMail.deleted ) |
161 | { | 157 | { |
162 | folderView->refreshCurrent(); | 158 | folderView->refreshCurrent(); |
163 | } | 159 | } |
164 | else | 160 | else |
165 | { | 161 | { |
166 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); | 162 | ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); |
167 | } | 163 | } |
168 | } | 164 | } |
169 | 165 | ||
170 | void OpieMail::slotDeleteMail() | 166 | void OpieMail::slotDeleteMail() |
171 | { | 167 | { |
172 | if (!mailView->currentItem()) return; | 168 | if (!mailView->currentItem()) return; |
173 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 169 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
174 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 170 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
175 | { | 171 | { |
176 | mail.Wrapper()->deleteMail( mail ); | 172 | mail.Wrapper()->deleteMail( mail ); |
177 | folderView->refreshCurrent(); | 173 | folderView->refreshCurrent(); |
178 | } | 174 | } |
179 | } | 175 | } |
180 | 176 | ||
181 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 177 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
182 | { | 178 | { |
183 | /* just the RIGHT button - or hold on pda */ | 179 | /* just the RIGHT button - or hold on pda */ |
184 | if (button!=2) {return;} | 180 | if (button!=2) {return;} |
185 | qDebug("Event right/hold"); | 181 | qDebug("Event right/hold"); |
186 | if (!item) return; | 182 | if (!item) return; |
187 | QPopupMenu *m = new QPopupMenu(0); | 183 | QPopupMenu *m = new QPopupMenu(0); |
188 | if (m) | 184 | if (m) |
189 | { | 185 | { |
190 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); | 186 | m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); |
191 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); | 187 | m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); |
192 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); | 188 | m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); |
193 | m->setFocus(); | 189 | m->setFocus(); |
194 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 190 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
195 | delete m; | 191 | delete m; |
196 | } | 192 | } |
197 | } | 193 | } |
198 | 194 | ||
199 | void OpieMail::slotShowFolders( bool show ) | 195 | void OpieMail::slotShowFolders( bool show ) |
200 | { | 196 | { |
201 | qDebug( "Show Folders" ); | 197 | qDebug( "Show Folders" ); |
202 | if ( show && folderView->isHidden() ) | 198 | if ( show && folderView->isHidden() ) |
203 | { | 199 | { |
204 | qDebug( "-> showing" ); | 200 | qDebug( "-> showing" ); |
205 | folderView->show(); | 201 | folderView->show(); |
206 | } | 202 | } |
207 | else if ( !show && !folderView->isHidden() ) | 203 | else if ( !show && !folderView->isHidden() ) |
208 | { | 204 | { |
209 | qDebug( "-> hiding" ); | 205 | qDebug( "-> hiding" ); |
210 | folderView->hide(); | 206 | folderView->hide(); |
211 | } | 207 | } |
212 | } | 208 | } |
213 | 209 | ||
214 | void OpieMail::refreshMailView(QList<RecMail>*list) | 210 | void OpieMail::refreshMailView(QList<RecMail>*list) |
215 | { | 211 | { |
216 | MailListViewItem*item = 0; | 212 | MailListViewItem*item = 0; |
217 | mailView->clear(); | 213 | mailView->clear(); |
218 | for (unsigned int i = 0; i < list->count();++i) | 214 | for (unsigned int i = 0; i < list->count();++i) |
219 | { | 215 | { |
220 | item = new MailListViewItem(mailView,item); | 216 | item = new MailListViewItem(mailView,item); |
221 | item->storeData(*(list->at(i))); | 217 | item->storeData(*(list->at(i))); |
222 | item->showEntry(); | 218 | item->showEntry(); |
223 | } | 219 | } |
224 | } | 220 | } |
225 | 221 | ||
226 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) | 222 | void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) |
227 | { | 223 | { |
228 | /* just LEFT button - or tap with stylus on pda */ | 224 | /* just LEFT button - or tap with stylus on pda */ |
229 | if (button!=1) return; | 225 | if (button!=1) return; |
230 | if (!item) return; | 226 | if (!item) return; |
231 | displayMail(); | 227 | displayMail(); |
232 | } | 228 | } |
233 | 229 | ||
234 | void OpieMail::slotMoveCopyMail() | 230 | void OpieMail::slotMoveCopyMail() |
235 | { | 231 | { |
236 | if (!mailView->currentItem()) return; | 232 | if (!mailView->currentItem()) return; |
237 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 233 | RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
238 | AbstractMail*targetMail = 0; | 234 | AbstractMail*targetMail = 0; |
239 | QString targetFolder = ""; | 235 | QString targetFolder = ""; |
240 | Selectstore sels; | 236 | Selectstore sels; |
241 | folderView->setupFolderselect(&sels); | 237 | folderView->setupFolderselect(&sels); |
242 | if (!sels.exec()) return; | 238 | if (!sels.exec()) return; |
243 | targetMail = sels.currentMail(); | 239 | targetMail = sels.currentMail(); |
244 | targetFolder = sels.currentFolder(); | 240 | targetFolder = sels.currentFolder(); |
245 | if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || | 241 | if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || |
246 | targetFolder.isEmpty()) | 242 | targetFolder.isEmpty()) |
247 | { | 243 | { |
248 | return; | 244 | return; |
249 | } | 245 | } |
250 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 246 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
251 | { | 247 | { |
252 | QMessageBox::critical(0,tr("Error creating new Folder"), | 248 | QMessageBox::critical(0,tr("Error creating new Folder"), |
253 | tr("<center>Error while creating<br>new folder - breaking.</center>")); | 249 | tr("<center>Error while creating<br>new folder - breaking.</center>")); |
254 | return; | 250 | return; |
255 | } | 251 | } |
256 | mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 252 | mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
257 | folderView->refreshCurrent(); | 253 | folderView->refreshCurrent(); |
258 | } | 254 | } |
diff --git a/noncore/net/mail/selectsmtp.cpp b/noncore/net/mail/selectsmtp.cpp index 79b10ef..82e8a0b 100644 --- a/noncore/net/mail/selectsmtp.cpp +++ b/noncore/net/mail/selectsmtp.cpp | |||
@@ -1,62 +1,55 @@ | |||
1 | #include "selectsmtp.h" | 1 | #include "selectsmtp.h" |
2 | #include <libmailwrapper/mailwrapper.h> | 2 | #include <libmailwrapper/mailwrapper.h> |
3 | #include <qlist.h> | ||
4 | #include <qlabel.h> | ||
5 | #include <qlayout.h> | ||
6 | #include <qcheckbox.h> | ||
7 | #include <qframe.h> | ||
8 | #include <qlineedit.h> | ||
9 | #include <qcombobox.h> | ||
10 | 3 | ||
11 | selectsmtp::selectsmtp(QWidget* parent, const char* name, bool modal, WFlags fl) | 4 | selectsmtp::selectsmtp(QWidget* parent, const char* name, bool modal, WFlags fl) |
12 | : selectstoreui(parent,name,modal,fl) | 5 | : selectstoreui(parent,name,modal,fl) |
13 | { | 6 | { |
14 | //m_smtpList.setAutoDelete(false); | 7 | //m_smtpList.setAutoDelete(false); |
15 | m_smtpList = 0; | 8 | m_smtpList = 0; |
16 | //headlabel->setText(tr("<center>Select SMTP account to use</center>")); | 9 | //headlabel->setText(tr("<center>Select SMTP account to use</center>")); |
17 | headlabel->hide(); | 10 | headlabel->hide(); |
18 | folderSelection->hide(); | 11 | folderSelection->hide(); |
19 | folderLabel->hide(); | 12 | folderLabel->hide(); |
20 | accountlabel->setText("<center>SMTP Accounts</center>"); | 13 | accountlabel->setText("<center>SMTP Accounts</center>"); |
21 | Line1->hide(); | 14 | Line1->hide(); |
22 | newFoldersel->hide(); | 15 | newFoldersel->hide(); |
23 | newFolderedit->hide(); | 16 | newFolderedit->hide(); |
24 | newFolderLabel->hide(); | 17 | newFolderLabel->hide(); |
25 | Line2->hide(); | 18 | Line2->hide(); |
26 | selMove->hide(); | 19 | selMove->hide(); |
27 | m_current_smtp = 0; | 20 | m_current_smtp = 0; |
28 | setCaption(tr("Select SMTP Account")); | 21 | setCaption(tr("Select SMTP Account")); |
29 | } | 22 | } |
30 | 23 | ||
31 | selectsmtp::~selectsmtp() | 24 | selectsmtp::~selectsmtp() |
32 | { | 25 | { |
33 | } | 26 | } |
34 | 27 | ||
35 | void selectsmtp::slotAccountselected(int which) | 28 | void selectsmtp::slotAccountselected(int which) |
36 | { | 29 | { |
37 | if (!m_smtpList || (unsigned)which>=m_smtpList->count() || which < 0) { | 30 | if (!m_smtpList || (unsigned)which>=m_smtpList->count() || which < 0) { |
38 | m_current_smtp = 0; | 31 | m_current_smtp = 0; |
39 | return; | 32 | return; |
40 | } | 33 | } |
41 | m_current_smtp = m_smtpList->at(which); | 34 | m_current_smtp = m_smtpList->at(which); |
42 | } | 35 | } |
43 | 36 | ||
44 | void selectsmtp::setSelectionlist(QList<SMTPaccount>*list) | 37 | void selectsmtp::setSelectionlist(QList<SMTPaccount>*list) |
45 | { | 38 | { |
46 | m_smtpList = list; | 39 | m_smtpList = list; |
47 | accountSelection->clear(); | 40 | accountSelection->clear(); |
48 | if (!m_smtpList || m_smtpList->count()==0) { | 41 | if (!m_smtpList || m_smtpList->count()==0) { |
49 | accountSelection->setEnabled(false); | 42 | accountSelection->setEnabled(false); |
50 | return; | 43 | return; |
51 | } | 44 | } |
52 | accountSelection->setEnabled(true); | 45 | accountSelection->setEnabled(true); |
53 | for (unsigned i = 0; m_smtpList!=0 && i < m_smtpList->count(); ++i) { | 46 | for (unsigned i = 0; m_smtpList!=0 && i < m_smtpList->count(); ++i) { |
54 | accountSelection->insertItem( m_smtpList->at(i)->getAccountName()); | 47 | accountSelection->insertItem( m_smtpList->at(i)->getAccountName()); |
55 | } | 48 | } |
56 | m_current_smtp = m_smtpList->at(0); | 49 | m_current_smtp = m_smtpList->at(0); |
57 | } | 50 | } |
58 | 51 | ||
59 | SMTPaccount*selectsmtp::selected_smtp() | 52 | SMTPaccount*selectsmtp::selected_smtp() |
60 | { | 53 | { |
61 | return m_current_smtp; | 54 | return m_current_smtp; |
62 | } | 55 | } |
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index 8636957..ec93f8d 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp | |||
@@ -1,472 +1,469 @@ | |||
1 | #include "composemail.h" | 1 | #include "composemail.h" |
2 | #include "viewmail.h" | 2 | #include "viewmail.h" |
3 | #include "accountview.h" | ||
4 | 3 | ||
5 | /* OPIE */ | 4 | /* OPIE */ |
6 | #include <libmailwrapper/settings.h> | 5 | #include <libmailwrapper/settings.h> |
7 | #include <libmailwrapper/abstractmail.h> | 6 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 7 | #include <libmailwrapper/mailtypes.h> |
9 | 8 | ||
10 | #include <opie2/ofiledialog.h> | 9 | #include <opie2/ofiledialog.h> |
11 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
12 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
13 | 12 | ||
14 | /* QT */ | 13 | /* QT */ |
15 | #include <qtextbrowser.h> | 14 | #include <qtextbrowser.h> |
16 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
17 | #include <qtextstream.h> | 16 | #include <qtextstream.h> |
18 | #include <qaction.h> | 17 | #include <qaction.h> |
19 | #include <qpopupmenu.h> | 18 | #include <qpopupmenu.h> |
20 | #include <qfile.h> | 19 | #include <qfile.h> |
21 | #include <qapplication.h> | ||
22 | #include <qvaluelist.h> | ||
23 | 20 | ||
24 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 21 | AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
25 | const QString&fsize,int num,const QValueList<int>&path) | 22 | const QString&fsize,int num,const QValueList<int>&path) |
26 | : QListViewItem(parent,after),_partNum(num) | 23 | : QListViewItem(parent,after),_partNum(num) |
27 | { | 24 | { |
28 | _path=path; | 25 | _path=path; |
29 | setText(0, mime); | 26 | setText(0, mime); |
30 | setText(1, desc); | 27 | setText(1, desc); |
31 | setText(2, file); | 28 | setText(2, file); |
32 | setText(3, fsize); | 29 | setText(3, fsize); |
33 | } | 30 | } |
34 | 31 | ||
35 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, | 32 | AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, |
36 | const QString&fsize,int num,const QValueList<int>&path) | 33 | const QString&fsize,int num,const QValueList<int>&path) |
37 | : QListViewItem(parent,after),_partNum(num) | 34 | : QListViewItem(parent,after),_partNum(num) |
38 | { | 35 | { |
39 | _path=path; | 36 | _path=path; |
40 | setText(0, mime); | 37 | setText(0, mime); |
41 | setText(1, desc); | 38 | setText(1, desc); |
42 | setText(2, file); | 39 | setText(2, file); |
43 | setText(3, fsize); | 40 | setText(3, fsize); |
44 | } | 41 | } |
45 | 42 | ||
46 | bool AttachItem::isParentof(const QValueList<int>&path) | 43 | bool AttachItem::isParentof(const QValueList<int>&path) |
47 | { | 44 | { |
48 | /* if not set, then no parent */ | 45 | /* if not set, then no parent */ |
49 | if (path.count()==0||_path.count()==0) return false; | 46 | if (path.count()==0||_path.count()==0) return false; |
50 | /* the parent must have one digit less then a child */ | 47 | /* the parent must have one digit less then a child */ |
51 | if (path.count()!=_path.count()+1) return false; | 48 | if (path.count()!=_path.count()+1) return false; |
52 | for (unsigned int i=0; i < _path.count();++i) | 49 | for (unsigned int i=0; i < _path.count();++i) |
53 | { | 50 | { |
54 | if (_path[i]!=path[i]) return false; | 51 | if (_path[i]!=path[i]) return false; |
55 | } | 52 | } |
56 | return true; | 53 | return true; |
57 | } | 54 | } |
58 | 55 | ||
59 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) | 56 | AttachItem* ViewMail::searchParent(const QValueList<int>&path) |
60 | { | 57 | { |
61 | QListViewItemIterator it( attachments ); | 58 | QListViewItemIterator it( attachments ); |
62 | for ( ; it.current(); ++it ) | 59 | for ( ; it.current(); ++it ) |
63 | { | 60 | { |
64 | AttachItem*ati = (AttachItem*)it.current(); | 61 | AttachItem*ati = (AttachItem*)it.current(); |
65 | if (ati->isParentof(path)) return ati; | 62 | if (ati->isParentof(path)) return ati; |
66 | } | 63 | } |
67 | return 0; | 64 | return 0; |
68 | } | 65 | } |
69 | 66 | ||
70 | AttachItem* ViewMail::lastChild(AttachItem*parent) | 67 | AttachItem* ViewMail::lastChild(AttachItem*parent) |
71 | { | 68 | { |
72 | if (!parent) return 0; | 69 | if (!parent) return 0; |
73 | AttachItem* item = (AttachItem*)parent->firstChild(); | 70 | AttachItem* item = (AttachItem*)parent->firstChild(); |
74 | if (!item) return item; | 71 | if (!item) return item; |
75 | AttachItem*temp=0; | 72 | AttachItem*temp=0; |
76 | while( (temp=(AttachItem*)item->nextSibling())) | 73 | while( (temp=(AttachItem*)item->nextSibling())) |
77 | { | 74 | { |
78 | item = temp; | 75 | item = temp; |
79 | } | 76 | } |
80 | return item; | 77 | return item; |
81 | } | 78 | } |
82 | 79 | ||
83 | void ViewMail::setBody( RecBody body ) | 80 | void ViewMail::setBody( RecBody body ) |
84 | { | 81 | { |
85 | 82 | ||
86 | m_body = body; | 83 | m_body = body; |
87 | m_mail[2] = body.Bodytext(); | 84 | m_mail[2] = body.Bodytext(); |
88 | attachbutton->setEnabled(body.Parts().count()>0); | 85 | attachbutton->setEnabled(body.Parts().count()>0); |
89 | attachments->setEnabled(body.Parts().count()>0); | 86 | attachments->setEnabled(body.Parts().count()>0); |
90 | if (body.Parts().count()==0) | 87 | if (body.Parts().count()==0) |
91 | { | 88 | { |
92 | return; | 89 | return; |
93 | } | 90 | } |
94 | AttachItem * curItem=0; | 91 | AttachItem * curItem=0; |
95 | AttachItem * parentItem = 0; | 92 | AttachItem * parentItem = 0; |
96 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); | 93 | QString type=body.Description().Type()+"/"+body.Description().Subtype(); |
97 | QString desc,fsize; | 94 | QString desc,fsize; |
98 | double s = body.Description().Size(); | 95 | double s = body.Description().Size(); |
99 | int w; | 96 | int w; |
100 | w=0; | 97 | w=0; |
101 | 98 | ||
102 | while (s>1024) | 99 | while (s>1024) |
103 | { | 100 | { |
104 | s/=1024; | 101 | s/=1024; |
105 | ++w; | 102 | ++w; |
106 | if (w>=2) break; | 103 | if (w>=2) break; |
107 | } | 104 | } |
108 | 105 | ||
109 | QString q=""; | 106 | QString q=""; |
110 | switch(w) | 107 | switch(w) |
111 | { | 108 | { |
112 | case 1: | 109 | case 1: |
113 | q="k"; | 110 | q="k"; |
114 | break; | 111 | break; |
115 | case 2: | 112 | case 2: |
116 | q="M"; | 113 | q="M"; |
117 | break; | 114 | break; |
118 | default: | 115 | default: |
119 | break; | 116 | break; |
120 | } | 117 | } |
121 | 118 | ||
122 | { | 119 | { |
123 | /* I did not found a method to make a CONTENT reset on a QTextStream | 120 | /* I did not found a method to make a CONTENT reset on a QTextStream |
124 | so I use this construct that the stream will re-constructed in each | 121 | so I use this construct that the stream will re-constructed in each |
125 | loop. To let it work, the textstream is packed into a own area of | 122 | loop. To let it work, the textstream is packed into a own area of |
126 | code is it will be destructed after finishing its small job. | 123 | code is it will be destructed after finishing its small job. |
127 | */ | 124 | */ |
128 | QTextOStream o(&fsize); | 125 | QTextOStream o(&fsize); |
129 | if (w>0) o.precision(2); else o.precision(0); | 126 | if (w>0) o.precision(2); else o.precision(0); |
130 | o.setf(QTextStream::fixed); | 127 | o.setf(QTextStream::fixed); |
131 | o << s << " " << q << "Byte"; | 128 | o << s << " " << q << "Byte"; |
132 | } | 129 | } |
133 | 130 | ||
134 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); | 131 | curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); |
135 | QString filename = ""; | 132 | QString filename = ""; |
136 | 133 | ||
137 | for (unsigned int i = 0; i < body.Parts().count();++i) | 134 | for (unsigned int i = 0; i < body.Parts().count();++i) |
138 | { | 135 | { |
139 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); | 136 | type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); |
140 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); | 137 | part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); |
141 | for (;it!=body.Parts()[i].Parameters().end();++it) | 138 | for (;it!=body.Parts()[i].Parameters().end();++it) |
142 | { | 139 | { |
143 | qDebug(it.key()); | 140 | qDebug(it.key()); |
144 | if (it.key().lower()=="name") | 141 | if (it.key().lower()=="name") |
145 | { | 142 | { |
146 | filename=it.data(); | 143 | filename=it.data(); |
147 | } | 144 | } |
148 | } | 145 | } |
149 | s = body.Parts()[i].Size(); | 146 | s = body.Parts()[i].Size(); |
150 | w = 0; | 147 | w = 0; |
151 | while (s>1024) | 148 | while (s>1024) |
152 | { | 149 | { |
153 | s/=1024; | 150 | s/=1024; |
154 | ++w; | 151 | ++w; |
155 | if (w>=2) break; | 152 | if (w>=2) break; |
156 | } | 153 | } |
157 | switch(w) | 154 | switch(w) |
158 | { | 155 | { |
159 | case 1: | 156 | case 1: |
160 | q="k"; | 157 | q="k"; |
161 | break; | 158 | break; |
162 | case 2: | 159 | case 2: |
163 | q="M"; | 160 | q="M"; |
164 | break; | 161 | break; |
165 | default: | 162 | default: |
166 | q=""; | 163 | q=""; |
167 | break; | 164 | break; |
168 | } | 165 | } |
169 | QTextOStream o(&fsize); | 166 | QTextOStream o(&fsize); |
170 | if (w>0) o.precision(2); else o.precision(0); | 167 | if (w>0) o.precision(2); else o.precision(0); |
171 | o.setf(QTextStream::fixed); | 168 | o.setf(QTextStream::fixed); |
172 | o << s << " " << q << "Byte"; | 169 | o << s << " " << q << "Byte"; |
173 | desc = body.Parts()[i].Description(); | 170 | desc = body.Parts()[i].Description(); |
174 | parentItem = searchParent(body.Parts()[i].Positionlist()); | 171 | parentItem = searchParent(body.Parts()[i].Positionlist()); |
175 | if (parentItem) | 172 | if (parentItem) |
176 | { | 173 | { |
177 | AttachItem*temp = lastChild(parentItem); | 174 | AttachItem*temp = lastChild(parentItem); |
178 | if (temp) curItem = temp; | 175 | if (temp) curItem = temp; |
179 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 176 | curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
180 | attachments->setRootIsDecorated(true); | 177 | attachments->setRootIsDecorated(true); |
181 | curItem = parentItem; | 178 | curItem = parentItem; |
182 | } | 179 | } |
183 | else | 180 | else |
184 | { | 181 | { |
185 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); | 182 | curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); |
186 | } | 183 | } |
187 | } | 184 | } |
188 | } | 185 | } |
189 | 186 | ||
190 | 187 | ||
191 | void ViewMail::slotShowHtml( bool state ) | 188 | void ViewMail::slotShowHtml( bool state ) |
192 | { | 189 | { |
193 | m_showHtml = state; | 190 | m_showHtml = state; |
194 | setText(); | 191 | setText(); |
195 | } | 192 | } |
196 | 193 | ||
197 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) | 194 | void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) |
198 | { | 195 | { |
199 | if (!item ) | 196 | if (!item ) |
200 | return; | 197 | return; |
201 | 198 | ||
202 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 199 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
203 | { | 200 | { |
204 | setText(); | 201 | setText(); |
205 | return; | 202 | return; |
206 | } | 203 | } |
207 | QPopupMenu *menu = new QPopupMenu(); | 204 | QPopupMenu *menu = new QPopupMenu(); |
208 | int ret=0; | 205 | int ret=0; |
209 | 206 | ||
210 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) | 207 | if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) |
211 | { | 208 | { |
212 | menu->insertItem( tr( "Show Text" ), 1 ); | 209 | menu->insertItem( tr( "Show Text" ), 1 ); |
213 | } | 210 | } |
214 | menu->insertItem( tr( "Save Attachment" ), 0 ); | 211 | menu->insertItem( tr( "Save Attachment" ), 0 ); |
215 | menu->insertSeparator(1); | 212 | menu->insertSeparator(1); |
216 | 213 | ||
217 | ret = menu->exec( point, 0 ); | 214 | ret = menu->exec( point, 0 ); |
218 | 215 | ||
219 | switch(ret) | 216 | switch(ret) |
220 | { | 217 | { |
221 | case 0: | 218 | case 0: |
222 | { | 219 | { |
223 | MimeTypes types; | 220 | MimeTypes types; |
224 | types.insert( "all", "*" ); | 221 | types.insert( "all", "*" ); |
225 | QString str = Opie::OFileDialog::getSaveFileName( 1, | 222 | QString str = Opie::OFileDialog::getSaveFileName( 1, |
226 | "/", item->text( 2 ) , types, 0 ); | 223 | "/", item->text( 2 ) , types, 0 ); |
227 | 224 | ||
228 | if( !str.isEmpty() ) | 225 | if( !str.isEmpty() ) |
229 | { | 226 | { |
230 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); | 227 | encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); |
231 | if (content) | 228 | if (content) |
232 | { | 229 | { |
233 | QFile output(str); | 230 | QFile output(str); |
234 | output.open(IO_WriteOnly); | 231 | output.open(IO_WriteOnly); |
235 | output.writeBlock(content->Content(),content->Length()); | 232 | output.writeBlock(content->Content(),content->Length()); |
236 | output.close(); | 233 | output.close(); |
237 | delete content; | 234 | delete content; |
238 | } | 235 | } |
239 | } | 236 | } |
240 | } | 237 | } |
241 | break ; | 238 | break ; |
242 | 239 | ||
243 | case 1: | 240 | case 1: |
244 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) | 241 | if ( ( ( AttachItem* )item )->Partnumber() == -1 ) |
245 | { | 242 | { |
246 | setText(); | 243 | setText(); |
247 | } | 244 | } |
248 | else | 245 | else |
249 | { | 246 | { |
250 | if ( m_recMail.Wrapper() != 0l ) | 247 | if ( m_recMail.Wrapper() != 0l ) |
251 | { // make sure that there is a wrapper , even after delete or simular actions | 248 | { // make sure that there is a wrapper , even after delete or simular actions |
252 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); | 249 | browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); |
253 | } | 250 | } |
254 | } | 251 | } |
255 | break; | 252 | break; |
256 | } | 253 | } |
257 | delete menu; | 254 | delete menu; |
258 | } | 255 | } |
259 | 256 | ||
260 | 257 | ||
261 | void ViewMail::setMail( RecMail mail ) | 258 | void ViewMail::setMail( RecMail mail ) |
262 | { | 259 | { |
263 | 260 | ||
264 | m_recMail = mail; | 261 | m_recMail = mail; |
265 | 262 | ||
266 | m_mail[0] = mail.getFrom(); | 263 | m_mail[0] = mail.getFrom(); |
267 | m_mail[1] = mail.getSubject(); | 264 | m_mail[1] = mail.getSubject(); |
268 | m_mail[3] = mail.getDate(); | 265 | m_mail[3] = mail.getDate(); |
269 | m_mail[4] = mail.Msgid(); | 266 | m_mail[4] = mail.Msgid(); |
270 | 267 | ||
271 | m_mail2[0] = mail.To(); | 268 | m_mail2[0] = mail.To(); |
272 | m_mail2[1] = mail.CC(); | 269 | m_mail2[1] = mail.CC(); |
273 | m_mail2[2] = mail.Bcc(); | 270 | m_mail2[2] = mail.Bcc(); |
274 | 271 | ||
275 | setText(); | 272 | setText(); |
276 | } | 273 | } |
277 | 274 | ||
278 | 275 | ||
279 | 276 | ||
280 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) | 277 | ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) |
281 | : ViewMailBase(parent, name, fl), _inLoop(false) | 278 | : ViewMailBase(parent, name, fl), _inLoop(false) |
282 | { | 279 | { |
283 | m_gotBody = false; | 280 | m_gotBody = false; |
284 | deleted = false; | 281 | deleted = false; |
285 | 282 | ||
286 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); | 283 | connect( reply, SIGNAL(activated()), SLOT(slotReply())); |
287 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); | 284 | connect( forward, SIGNAL(activated()), SLOT(slotForward())); |
288 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); | 285 | connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); |
289 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); | 286 | connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); |
290 | 287 | ||
291 | attachments->setEnabled(m_gotBody); | 288 | attachments->setEnabled(m_gotBody); |
292 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); | 289 | connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); |
293 | 290 | ||
294 | readConfig(); | 291 | readConfig(); |
295 | attachments->setSorting(-1); | 292 | attachments->setSorting(-1); |
296 | } | 293 | } |
297 | 294 | ||
298 | void ViewMail::readConfig() | 295 | void ViewMail::readConfig() |
299 | { | 296 | { |
300 | Config cfg( "mail" ); | 297 | Config cfg( "mail" ); |
301 | cfg.setGroup( "Settings" ); | 298 | cfg.setGroup( "Settings" ); |
302 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); | 299 | m_showHtml = cfg.readBoolEntry( "showHtml", false ); |
303 | showHtml->setOn( m_showHtml ); | 300 | showHtml->setOn( m_showHtml ); |
304 | } | 301 | } |
305 | 302 | ||
306 | void ViewMail::setText() | 303 | void ViewMail::setText() |
307 | { | 304 | { |
308 | 305 | ||
309 | QString toString; | 306 | QString toString; |
310 | QString ccString; | 307 | QString ccString; |
311 | QString bccString; | 308 | QString bccString; |
312 | 309 | ||
313 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) | 310 | for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |
314 | { | 311 | { |
315 | toString += (*it); | 312 | toString += (*it); |
316 | } | 313 | } |
317 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) | 314 | for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) |
318 | { | 315 | { |
319 | ccString += (*it); | 316 | ccString += (*it); |
320 | } | 317 | } |
321 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) | 318 | for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) |
322 | { | 319 | { |
323 | bccString += (*it); | 320 | bccString += (*it); |
324 | } | 321 | } |
325 | 322 | ||
326 | setCaption( caption().arg( m_mail[0] ) ); | 323 | setCaption( caption().arg( m_mail[0] ) ); |
327 | 324 | ||
328 | m_mailHtml = "<html><body>" | 325 | m_mailHtml = "<html><body>" |
329 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" | 326 | "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" |
330 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" | 327 | "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" |
331 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" | 328 | "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" |
332 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" | 329 | "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" |
333 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + | 330 | "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + |
334 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" | 331 | tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" |
335 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + | 332 | "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + |
336 | "</td></tr></table><font face=fixed>"; | 333 | "</td></tr></table><font face=fixed>"; |
337 | 334 | ||
338 | if ( !m_showHtml ) | 335 | if ( !m_showHtml ) |
339 | { | 336 | { |
340 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); | 337 | browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); |
341 | } | 338 | } |
342 | else | 339 | else |
343 | { | 340 | { |
344 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); | 341 | browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); |
345 | } | 342 | } |
346 | // remove later in favor of a real handling | 343 | // remove later in favor of a real handling |
347 | m_gotBody = true; | 344 | m_gotBody = true; |
348 | } | 345 | } |
349 | 346 | ||
350 | 347 | ||
351 | ViewMail::~ViewMail() | 348 | ViewMail::~ViewMail() |
352 | { | 349 | { |
353 | m_recMail.Wrapper()->cleanMimeCache(); | 350 | m_recMail.Wrapper()->cleanMimeCache(); |
354 | hide(); | 351 | hide(); |
355 | } | 352 | } |
356 | 353 | ||
357 | void ViewMail::hide() | 354 | void ViewMail::hide() |
358 | { | 355 | { |
359 | QWidget::hide(); | 356 | QWidget::hide(); |
360 | 357 | ||
361 | if (_inLoop) | 358 | if (_inLoop) |
362 | { | 359 | { |
363 | _inLoop = false; | 360 | _inLoop = false; |
364 | qApp->exit_loop(); | 361 | qApp->exit_loop(); |
365 | 362 | ||
366 | } | 363 | } |
367 | 364 | ||
368 | } | 365 | } |
369 | 366 | ||
370 | void ViewMail::exec() | 367 | void ViewMail::exec() |
371 | { | 368 | { |
372 | show(); | 369 | show(); |
373 | 370 | ||
374 | if (!_inLoop) | 371 | if (!_inLoop) |
375 | { | 372 | { |
376 | _inLoop = true; | 373 | _inLoop = true; |
377 | qApp->enter_loop(); | 374 | qApp->enter_loop(); |
378 | } | 375 | } |
379 | 376 | ||
380 | } | 377 | } |
381 | 378 | ||
382 | QString ViewMail::deHtml(const QString &string) | 379 | QString ViewMail::deHtml(const QString &string) |
383 | { | 380 | { |
384 | QString string_ = string; | 381 | QString string_ = string; |
385 | string_.replace(QRegExp("&"), "&"); | 382 | string_.replace(QRegExp("&"), "&"); |
386 | string_.replace(QRegExp("<"), "<"); | 383 | string_.replace(QRegExp("<"), "<"); |
387 | string_.replace(QRegExp(">"), ">"); | 384 | string_.replace(QRegExp(">"), ">"); |
388 | string_.replace(QRegExp("\\n"), "<br>"); | 385 | string_.replace(QRegExp("\\n"), "<br>"); |
389 | return string_; | 386 | return string_; |
390 | } | 387 | } |
391 | 388 | ||
392 | void ViewMail::slotReply() | 389 | void ViewMail::slotReply() |
393 | { | 390 | { |
394 | if (!m_gotBody) | 391 | if (!m_gotBody) |
395 | { | 392 | { |
396 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); | 393 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); |
397 | return; | 394 | return; |
398 | } | 395 | } |
399 | 396 | ||
400 | QString rtext; | 397 | QString rtext; |
401 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 398 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
402 | .arg( m_mail[0] ) | 399 | .arg( m_mail[0] ) |
403 | .arg( m_mail[3] ); | 400 | .arg( m_mail[3] ); |
404 | 401 | ||
405 | QString text = m_mail[2]; | 402 | QString text = m_mail[2]; |
406 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 403 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
407 | QStringList::Iterator it; | 404 | QStringList::Iterator it; |
408 | for (it = lines.begin(); it != lines.end(); it++) | 405 | for (it = lines.begin(); it != lines.end(); it++) |
409 | { | 406 | { |
410 | rtext += "> " + *it + "\n"; | 407 | rtext += "> " + *it + "\n"; |
411 | } | 408 | } |
412 | rtext += "\n"; | 409 | rtext += "\n"; |
413 | 410 | ||
414 | QString prefix; | 411 | QString prefix; |
415 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; | 412 | if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; |
416 | else prefix = "Re: "; // no i18n on purpose | 413 | else prefix = "Re: "; // no i18n on purpose |
417 | 414 | ||
418 | Settings *settings = new Settings(); | 415 | Settings *settings = new Settings(); |
419 | ComposeMail composer( settings ,this, 0, true); | 416 | ComposeMail composer( settings ,this, 0, true); |
420 | composer.setTo( m_mail[0] ); | 417 | composer.setTo( m_mail[0] ); |
421 | composer.setSubject( "Re: " + m_mail[1] ); | 418 | composer.setSubject( "Re: " + m_mail[1] ); |
422 | composer.setMessage( rtext ); | 419 | composer.setMessage( rtext ); |
423 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) | 420 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) ) |
424 | { | 421 | { |
425 | m_recMail.Wrapper()->answeredMail(m_recMail); | 422 | m_recMail.Wrapper()->answeredMail(m_recMail); |
426 | } | 423 | } |
427 | } | 424 | } |
428 | 425 | ||
429 | void ViewMail::slotForward() | 426 | void ViewMail::slotForward() |
430 | { | 427 | { |
431 | if (!m_gotBody) | 428 | if (!m_gotBody) |
432 | { | 429 | { |
433 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 430 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
434 | return; | 431 | return; |
435 | } | 432 | } |
436 | 433 | ||
437 | QString ftext; | 434 | QString ftext; |
438 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") | 435 | ftext += QString("\n----- Forwarded message from %1 -----\n\n") |
439 | .arg( m_mail[0] ); | 436 | .arg( m_mail[0] ); |
440 | if (!m_mail[3].isNull()) | 437 | if (!m_mail[3].isNull()) |
441 | ftext += QString("Date: %1\n") | 438 | ftext += QString("Date: %1\n") |
442 | .arg( m_mail[3] ); | 439 | .arg( m_mail[3] ); |
443 | if (!m_mail[0].isNull()) | 440 | if (!m_mail[0].isNull()) |
444 | ftext += QString("From: %1\n") | 441 | ftext += QString("From: %1\n") |
445 | .arg( m_mail[0] ); | 442 | .arg( m_mail[0] ); |
446 | if (!m_mail[1].isNull()) | 443 | if (!m_mail[1].isNull()) |
447 | ftext += QString("Subject: %1\n") | 444 | ftext += QString("Subject: %1\n") |
448 | .arg( m_mail[1] ); | 445 | .arg( m_mail[1] ); |
449 | 446 | ||
450 | ftext += QString("\n%1\n") | 447 | ftext += QString("\n%1\n") |
451 | .arg( m_mail[2]); | 448 | .arg( m_mail[2]); |
452 | 449 | ||
453 | ftext += QString("----- End forwarded message -----\n"); | 450 | ftext += QString("----- End forwarded message -----\n"); |
454 | 451 | ||
455 | Settings *settings = new Settings(); | 452 | Settings *settings = new Settings(); |
456 | ComposeMail composer( settings ,this, 0, true); | 453 | ComposeMail composer( settings ,this, 0, true); |
457 | composer.setSubject( "Fwd: " + m_mail[1] ); | 454 | composer.setSubject( "Fwd: " + m_mail[1] ); |
458 | composer.setMessage( ftext ); | 455 | composer.setMessage( ftext ); |
459 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) | 456 | if ( QDialog::Accepted == QPEApplication::execDialog( &composer )) |
460 | { | 457 | { |
461 | } | 458 | } |
462 | } | 459 | } |
463 | 460 | ||
464 | void ViewMail::slotDeleteMail( ) | 461 | void ViewMail::slotDeleteMail( ) |
465 | { | 462 | { |
466 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 463 | if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
467 | { | 464 | { |
468 | m_recMail.Wrapper()->deleteMail( m_recMail ); | 465 | m_recMail.Wrapper()->deleteMail( m_recMail ); |
469 | hide(); | 466 | hide(); |
470 | deleted = true; | 467 | deleted = true; |
471 | } | 468 | } |
472 | } | 469 | } |
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp index 7f1d8a0..c2bf08c 100644 --- a/noncore/net/mail/viewmailbase.cpp +++ b/noncore/net/mail/viewmailbase.cpp | |||
@@ -1,90 +1,89 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qlistview.h> | 2 | #include <qlistview.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qvbox.h> | 5 | #include <qvbox.h> |
6 | #include <qpopupmenu.h> | ||
7 | 6 | ||
8 | #include <qpe/qpetoolbar.h> | 7 | #include <qpe/qpetoolbar.h> |
9 | #include <qmenubar.h> | 8 | #include <qmenubar.h> |
10 | #include <qpe/resource.h> | 9 | #include <qpe/resource.h> |
11 | 10 | ||
12 | #include "viewmailbase.h" | 11 | #include "viewmailbase.h" |
13 | //#include "opendiag.h" | 12 | //#include "opendiag.h" |
14 | 13 | ||
15 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) | 14 | ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) |
16 | : QMainWindow(parent, name, fl) | 15 | : QMainWindow(parent, name, fl) |
17 | { | 16 | { |
18 | setCaption(tr("E-Mail by %1")); | 17 | setCaption(tr("E-Mail by %1")); |
19 | setToolBarsMovable(false); | 18 | setToolBarsMovable(false); |
20 | 19 | ||
21 | toolbar = new QToolBar(this); | 20 | toolbar = new QToolBar(this); |
22 | menubar = new QMenuBar( toolbar ); | 21 | menubar = new QMenuBar( toolbar ); |
23 | mailmenu = new QPopupMenu( menubar ); | 22 | mailmenu = new QPopupMenu( menubar ); |
24 | menubar->insertItem( tr( "Mail" ), mailmenu ); | 23 | menubar->insertItem( tr( "Mail" ), mailmenu ); |
25 | 24 | ||
26 | toolbar->setHorizontalStretchable(true); | 25 | toolbar->setHorizontalStretchable(true); |
27 | addToolBar(toolbar); | 26 | addToolBar(toolbar); |
28 | 27 | ||
29 | QLabel *spacer = new QLabel(toolbar); | 28 | QLabel *spacer = new QLabel(toolbar); |
30 | spacer->setBackgroundMode(QWidget::PaletteButton); | 29 | spacer->setBackgroundMode(QWidget::PaletteButton); |
31 | toolbar->setStretchableWidget(spacer); | 30 | toolbar->setStretchableWidget(spacer); |
32 | 31 | ||
33 | reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); | 32 | reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); |
34 | reply->addTo(toolbar); | 33 | reply->addTo(toolbar); |
35 | reply->addTo(mailmenu); | 34 | reply->addTo(mailmenu); |
36 | 35 | ||
37 | forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); | 36 | forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); |
38 | forward->addTo(toolbar); | 37 | forward->addTo(toolbar); |
39 | forward->addTo(mailmenu); | 38 | forward->addTo(mailmenu); |
40 | 39 | ||
41 | attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); | 40 | attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); |
42 | attachbutton->addTo(toolbar); | 41 | attachbutton->addTo(toolbar); |
43 | attachbutton->addTo(mailmenu); | 42 | attachbutton->addTo(mailmenu); |
44 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); | 43 | connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); |
45 | 44 | ||
46 | 45 | ||
47 | showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); | 46 | showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); |
48 | showHtml->addTo( toolbar ); | 47 | showHtml->addTo( toolbar ); |
49 | showHtml->addTo( mailmenu ); | 48 | showHtml->addTo( mailmenu ); |
50 | 49 | ||
51 | deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); | 50 | deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); |
52 | deleteMail->addTo(toolbar); | 51 | deleteMail->addTo(toolbar); |
53 | deleteMail->addTo(mailmenu); | 52 | deleteMail->addTo(mailmenu); |
54 | 53 | ||
55 | QVBox *view = new QVBox(this); | 54 | QVBox *view = new QVBox(this); |
56 | setCentralWidget(view); | 55 | setCentralWidget(view); |
57 | 56 | ||
58 | attachments = new QListView(view); | 57 | attachments = new QListView(view); |
59 | attachments->setMinimumHeight(90); | 58 | attachments->setMinimumHeight(90); |
60 | attachments->setMaximumHeight(90); | 59 | attachments->setMaximumHeight(90); |
61 | attachments->setAllColumnsShowFocus(true); | 60 | attachments->setAllColumnsShowFocus(true); |
62 | attachments->addColumn("Mime Type", 60); | 61 | attachments->addColumn("Mime Type", 60); |
63 | attachments->addColumn(tr("Description"), 100); | 62 | attachments->addColumn(tr("Description"), 100); |
64 | attachments->addColumn(tr("Filename"), 80); | 63 | attachments->addColumn(tr("Filename"), 80); |
65 | attachments->addColumn(tr("Size"), 80); | 64 | attachments->addColumn(tr("Size"), 80); |
66 | attachments->setSorting(-1); | 65 | attachments->setSorting(-1); |
67 | attachments->hide(); | 66 | attachments->hide(); |
68 | 67 | ||
69 | browser = new QTextBrowser(view); | 68 | browser = new QTextBrowser(view); |
70 | 69 | ||
71 | //openDiag = new OpenDiag(view); | 70 | //openDiag = new OpenDiag(view); |
72 | //openDiag->hide(); | 71 | //openDiag->hide(); |
73 | 72 | ||
74 | } | 73 | } |
75 | 74 | ||
76 | void ViewMailBase::slotChangeAttachview(bool state) | 75 | void ViewMailBase::slotChangeAttachview(bool state) |
77 | { | 76 | { |
78 | if (state) attachments->show(); | 77 | if (state) attachments->show(); |
79 | else attachments->hide(); | 78 | else attachments->hide(); |
80 | } | 79 | } |
81 | 80 | ||
82 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) | 81 | void ViewMailBase::keyPressEvent ( QKeyEvent * e ) |
83 | { | 82 | { |
84 | if( e->key()==Qt::Key_Escape ) { | 83 | if( e->key()==Qt::Key_Escape ) { |
85 | close(); | 84 | close(); |
86 | e->accept(); | 85 | e->accept(); |
87 | return; | 86 | return; |
88 | } | 87 | } |
89 | QWidget::keyPressEvent(e); | 88 | QWidget::keyPressEvent(e); |
90 | } | 89 | } |
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp index b76b397..817936d 100644 --- a/noncore/net/opietooth/applet/bluezapplet.cpp +++ b/noncore/net/opietooth/applet/bluezapplet.cpp | |||
@@ -1,222 +1,221 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> | 3 | .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <, > . <= redistribute it and/or modify it under | 6 | .> <, > . <= redistribute it and/or modify it under |
7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%+i> _;_. | 11 | .%+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=| MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. . .: details. | 18 | ++= -. . .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-= this library; see the file COPYING.LIB. | 22 | -- :-= this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | #include "bluezapplet.h" | 30 | #include "bluezapplet.h" |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | 32 | ||
33 | #include <qpe/resource.h> | ||
34 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
35 | #include <qpe/resource.h> | ||
36 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
35 | #include <qpe/resource.h> | ||
37 | 36 | ||
38 | #include <opie/odevice.h> | 37 | #include <opie/odevice.h> |
39 | 38 | ||
40 | #include <qpoint.h> | 39 | #include <qpoint.h> |
41 | #include <qpainter.h> | 40 | #include <qpainter.h> |
42 | #include <qlayout.h> | 41 | #include <qlayout.h> |
43 | #include <qframe.h> | 42 | #include <qframe.h> |
44 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
45 | #include <qstring.h> | 44 | #include <qstring.h> |
46 | #include <qtimer.h> | 45 | #include <qtimer.h> |
47 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
48 | 47 | ||
49 | #include <device.h> | 48 | #include <device.h> |
50 | 49 | ||
51 | using namespace Opie; | 50 | using namespace Opie; |
52 | 51 | ||
53 | namespace OpieTooth { | 52 | namespace OpieTooth { |
54 | 53 | ||
55 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { | 54 | BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { |
56 | setFixedHeight( 18 ); | 55 | setFixedHeight( 18 ); |
57 | setFixedWidth( 14 ); | 56 | setFixedWidth( 14 ); |
58 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); | 57 | bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); |
59 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); | 58 | bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); |
60 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); | 59 | // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); |
61 | startTimer(4000); | 60 | startTimer(4000); |
62 | btDevice = 0; | 61 | btDevice = 0; |
63 | bluezactive = false; | 62 | bluezactive = false; |
64 | bluezDiscoveryActive = false; | 63 | bluezDiscoveryActive = false; |
65 | 64 | ||
66 | } | 65 | } |
67 | 66 | ||
68 | BluezApplet::~BluezApplet() { | 67 | BluezApplet::~BluezApplet() { |
69 | if ( btDevice ) { | 68 | if ( btDevice ) { |
70 | delete btDevice; | 69 | delete btDevice; |
71 | } | 70 | } |
72 | } | 71 | } |
73 | 72 | ||
74 | bool BluezApplet::checkBluezStatus() { | 73 | bool BluezApplet::checkBluezStatus() { |
75 | if (btDevice) { | 74 | if (btDevice) { |
76 | if (btDevice->isLoaded() ) { | 75 | if (btDevice->isLoaded() ) { |
77 | return true; | 76 | return true; |
78 | } else { | 77 | } else { |
79 | return false; | 78 | return false; |
80 | } | 79 | } |
81 | } else { | 80 | } else { |
82 | return false; | 81 | return false; |
83 | } | 82 | } |
84 | } | 83 | } |
85 | 84 | ||
86 | int BluezApplet::setBluezStatus(int c) { | 85 | int BluezApplet::setBluezStatus(int c) { |
87 | 86 | ||
88 | if ( c == 1 ) { | 87 | if ( c == 1 ) { |
89 | switch ( ODevice::inst()->model() ) { | 88 | switch ( ODevice::inst()->model() ) { |
90 | case Model_iPAQ_H39xx: | 89 | case Model_iPAQ_H39xx: |
91 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); | 90 | btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); |
92 | break; | 91 | break; |
93 | 92 | ||
94 | case Model_iPAQ_H5xxx: | 93 | case Model_iPAQ_H5xxx: |
95 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); | 94 | btDevice = new Device( "/dev/tts/1", "any", "921600" ); |
96 | break; | 95 | break; |
97 | 96 | ||
98 | default: | 97 | default: |
99 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); | 98 | btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); |
100 | break; | 99 | break; |
101 | } | 100 | } |
102 | } else { | 101 | } else { |
103 | if ( btDevice ) { | 102 | if ( btDevice ) { |
104 | delete btDevice; | 103 | delete btDevice; |
105 | btDevice = 0; | 104 | btDevice = 0; |
106 | } | 105 | } |
107 | } | 106 | } |
108 | return 0; | 107 | return 0; |
109 | } | 108 | } |
110 | 109 | ||
111 | int BluezApplet::checkBluezDiscoveryStatus() { | 110 | int BluezApplet::checkBluezDiscoveryStatus() { |
112 | } | 111 | } |
113 | 112 | ||
114 | int BluezApplet::setBluezDiscoveryStatus(int d) { | 113 | int BluezApplet::setBluezDiscoveryStatus(int d) { |
115 | } | 114 | } |
116 | 115 | ||
117 | void BluezApplet::mousePressEvent( QMouseEvent *) { | 116 | void BluezApplet::mousePressEvent( QMouseEvent *) { |
118 | 117 | ||
119 | QPopupMenu *menu = new QPopupMenu(); | 118 | QPopupMenu *menu = new QPopupMenu(); |
120 | QPopupMenu *signal = new QPopupMenu(); | 119 | QPopupMenu *signal = new QPopupMenu(); |
121 | int ret=0; | 120 | int ret=0; |
122 | 121 | ||
123 | /* Refresh active state */ | 122 | /* Refresh active state */ |
124 | timerEvent( 0 ); | 123 | timerEvent( 0 ); |
125 | 124 | ||
126 | 125 | ||
127 | if (bluezactive) { | 126 | if (bluezactive) { |
128 | menu->insertItem( tr("Disable Bluetooth"), 0 ); | 127 | menu->insertItem( tr("Disable Bluetooth"), 0 ); |
129 | } else { | 128 | } else { |
130 | menu->insertItem( tr("Enable Bluetooth"), 1 ); | 129 | menu->insertItem( tr("Enable Bluetooth"), 1 ); |
131 | } | 130 | } |
132 | 131 | ||
133 | menu->insertItem( tr("Launch manager"), 2 ); | 132 | menu->insertItem( tr("Launch manager"), 2 ); |
134 | 133 | ||
135 | menu->insertSeparator(6); | 134 | menu->insertSeparator(6); |
136 | //menu->insertItem( tr("Signal strength"), signal, 5); | 135 | //menu->insertItem( tr("Signal strength"), signal, 5); |
137 | //menu->insertSeparator(8); | 136 | //menu->insertSeparator(8); |
138 | 137 | ||
139 | if (bluezDiscoveryActive) { | 138 | if (bluezDiscoveryActive) { |
140 | menu->insertItem( tr("Disable discovery"), 3 ); | 139 | menu->insertItem( tr("Disable discovery"), 3 ); |
141 | } else { | 140 | } else { |
142 | menu->insertItem( tr("Enable discovery"), 4 ); | 141 | menu->insertItem( tr("Enable discovery"), 4 ); |
143 | } | 142 | } |
144 | 143 | ||
145 | 144 | ||
146 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); | 145 | QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); |
147 | ret = menu->exec(p, 0); | 146 | ret = menu->exec(p, 0); |
148 | 147 | ||
149 | switch(ret) { | 148 | switch(ret) { |
150 | case 0: | 149 | case 0: |
151 | setBluezStatus(0); | 150 | setBluezStatus(0); |
152 | timerEvent( 0 ); | 151 | timerEvent( 0 ); |
153 | break; | 152 | break; |
154 | case 1: | 153 | case 1: |
155 | setBluezStatus(1); | 154 | setBluezStatus(1); |
156 | timerEvent( 0 ); | 155 | timerEvent( 0 ); |
157 | break; | 156 | break; |
158 | case 2: | 157 | case 2: |
159 | // start bluetoothmanager | 158 | // start bluetoothmanager |
160 | launchManager(); | 159 | launchManager(); |
161 | timerEvent( 0 ); | 160 | timerEvent( 0 ); |
162 | break; | 161 | break; |
163 | case 3: | 162 | case 3: |
164 | setBluezDiscoveryStatus(0); | 163 | setBluezDiscoveryStatus(0); |
165 | timerEvent( 0 ); | 164 | timerEvent( 0 ); |
166 | break; | 165 | break; |
167 | case 4: | 166 | case 4: |
168 | setBluezDiscoveryStatus(1); | 167 | setBluezDiscoveryStatus(1); |
169 | timerEvent(0 ); | 168 | timerEvent(0 ); |
170 | break; | 169 | break; |
171 | //case 7: | 170 | //case 7: |
172 | // With table of currently-detected devices. | 171 | // With table of currently-detected devices. |
173 | } | 172 | } |
174 | 173 | ||
175 | delete signal; | 174 | delete signal; |
176 | delete menu; | 175 | delete menu; |
177 | } | 176 | } |
178 | 177 | ||
179 | 178 | ||
180 | /** | 179 | /** |
181 | * Launches the bluetooth manager | 180 | * Launches the bluetooth manager |
182 | */ | 181 | */ |
183 | void BluezApplet::launchManager() { | 182 | void BluezApplet::launchManager() { |
184 | QCopEnvelope e("QPE/System", "execute(QString)"); | 183 | QCopEnvelope e("QPE/System", "execute(QString)"); |
185 | e << QString("bluetooth-manager"); | 184 | e << QString("bluetooth-manager"); |
186 | } | 185 | } |
187 | 186 | ||
188 | /** | 187 | /** |
189 | * Refresh timer | 188 | * Refresh timer |
190 | * @param the timer event | 189 | * @param the timer event |
191 | */ | 190 | */ |
192 | void BluezApplet::timerEvent( QTimerEvent * ) { | 191 | void BluezApplet::timerEvent( QTimerEvent * ) { |
193 | bool oldactive = bluezactive; | 192 | bool oldactive = bluezactive; |
194 | int olddiscovery = bluezDiscoveryActive; | 193 | int olddiscovery = bluezDiscoveryActive; |
195 | 194 | ||
196 | bluezactive = checkBluezStatus(); | 195 | bluezactive = checkBluezStatus(); |
197 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); | 196 | bluezDiscoveryActive = checkBluezDiscoveryStatus(); |
198 | 197 | ||
199 | if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) { | 198 | if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) { |
200 | update(); | 199 | update(); |
201 | } | 200 | } |
202 | } | 201 | } |
203 | 202 | ||
204 | /** | 203 | /** |
205 | * Implementation of the paint event | 204 | * Implementation of the paint event |
206 | * @param the QPaintEvent | 205 | * @param the QPaintEvent |
207 | */ | 206 | */ |
208 | void BluezApplet::paintEvent( QPaintEvent* ) { | 207 | void BluezApplet::paintEvent( QPaintEvent* ) { |
209 | QPainter p(this); | 208 | QPainter p(this); |
210 | qDebug("paint bluetooth pixmap"); | 209 | qDebug("paint bluetooth pixmap"); |
211 | 210 | ||
212 | if (bluezactive > 0) { | 211 | if (bluezactive > 0) { |
213 | p.drawPixmap( 0, 1, bluezOnPixmap ); | 212 | p.drawPixmap( 0, 1, bluezOnPixmap ); |
214 | } else { | 213 | } else { |
215 | p.drawPixmap( 0, 1, bluezOffPixmap ); | 214 | p.drawPixmap( 0, 1, bluezOffPixmap ); |
216 | } | 215 | } |
217 | 216 | ||
218 | if (bluezDiscoveryActive > 0) { | 217 | if (bluezDiscoveryActive > 0) { |
219 | p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap ); | 218 | p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap ); |
220 | } | 219 | } |
221 | } | 220 | } |
222 | }; | 221 | }; |
diff --git a/noncore/net/opietooth/blue-pin/main.cc b/noncore/net/opietooth/blue-pin/main.cc index 1b7daec..aa360aa 100644 --- a/noncore/net/opietooth/blue-pin/main.cc +++ b/noncore/net/opietooth/blue-pin/main.cc | |||
@@ -1,39 +1,38 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | 4 | ||
5 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
6 | #include <qpe/config.h> | ||
7 | 6 | ||
8 | #include "pindlg.h" | 7 | #include "pindlg.h" |
9 | 8 | ||
10 | 9 | ||
11 | int main( int argc, char* argv[] ) | 10 | int main( int argc, char* argv[] ) |
12 | { | 11 | { |
13 | if (argc < 2 ) { | 12 | if (argc < 2 ) { |
14 | printf("ERR\n"); | 13 | printf("ERR\n"); |
15 | exit(0); | 14 | exit(0); |
16 | } | 15 | } |
17 | QCString dir(argv[1] ); | 16 | QCString dir(argv[1] ); |
18 | QCString bdaddr( argv[2] ); | 17 | QCString bdaddr( argv[2] ); |
19 | QCString name; | 18 | QCString name; |
20 | if ( argc > 3 ) { | 19 | if ( argc > 3 ) { |
21 | name = argv[3]; | 20 | name = argv[3]; |
22 | } | 21 | } |
23 | QPEApplication a(argc, argv ); | 22 | QPEApplication a(argc, argv ); |
24 | QString status; | 23 | QString status; |
25 | if (dir == "out" ) { | 24 | if (dir == "out" ) { |
26 | status = QObject::tr("Outgoing connection to "); | 25 | status = QObject::tr("Outgoing connection to "); |
27 | }else | 26 | }else |
28 | status = QObject::tr("Incoming connection from "); | 27 | status = QObject::tr("Incoming connection from "); |
29 | status += name; | 28 | status += name; |
30 | status += "<br>"; | 29 | status += "<br>"; |
31 | status += "[" + bdaddr + "]"; | 30 | status += "[" + bdaddr + "]"; |
32 | OpieTooth::PinDlg dlg( status, bdaddr ); | 31 | OpieTooth::PinDlg dlg( status, bdaddr ); |
33 | if ( dlg.exec() ) { | 32 | if ( dlg.exec() ) { |
34 | printf("PIN:%s\n", dlg.pin().stripWhiteSpace().latin1() ); | 33 | printf("PIN:%s\n", dlg.pin().stripWhiteSpace().latin1() ); |
35 | }else | 34 | }else |
36 | printf("ERR\n"); | 35 | printf("ERR\n"); |
37 | return 0; | 36 | return 0; |
38 | } | 37 | } |
39 | 38 | ||
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc index 9418a20..f0b2309 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.cc +++ b/noncore/net/opietooth/blue-pin/pindlg.cc | |||
@@ -1,65 +1,64 @@ | |||
1 | 1 | ||
2 | #include "pindlg.h" | 2 | #include "pindlg.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qcheckbox.h> | 9 | #include <qcheckbox.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qlineedit.h> | 11 | #include <qlineedit.h> |
12 | #include <qtimer.h> | ||
13 | 12 | ||
14 | /* STD */ | 13 | /* STD */ |
15 | #include <stdio.h> | 14 | #include <stdio.h> |
16 | 15 | ||
17 | using namespace OpieTooth; | 16 | using namespace OpieTooth; |
18 | 17 | ||
19 | PinDlg::PinDlg( const QString& status, | 18 | PinDlg::PinDlg( const QString& status, |
20 | const QString& mac, QWidget* parent, | 19 | const QString& mac, QWidget* parent, |
21 | const char* name ) | 20 | const char* name ) |
22 | : PinDlgBase( parent, name, WType_Modal ) | 21 | : PinDlgBase( parent, name, WType_Modal ) |
23 | { | 22 | { |
24 | m_mac = mac; | 23 | m_mac = mac; |
25 | test( mac ); | 24 | test( mac ); |
26 | txtStatus->setText(status); | 25 | txtStatus->setText(status); |
27 | QPEApplication::showDialog( this ); | 26 | QPEApplication::showDialog( this ); |
28 | } | 27 | } |
29 | 28 | ||
30 | PinDlg::~PinDlg() | 29 | PinDlg::~PinDlg() |
31 | {} | 30 | {} |
32 | void PinDlg::setMac( const QString& mac ) | 31 | void PinDlg::setMac( const QString& mac ) |
33 | { | 32 | { |
34 | txtStatus->setText( mac ); | 33 | txtStatus->setText( mac ); |
35 | } | 34 | } |
36 | QString PinDlg::pin() const | 35 | QString PinDlg::pin() const |
37 | { | 36 | { |
38 | return lnePin->text(); | 37 | return lnePin->text(); |
39 | } | 38 | } |
40 | 39 | ||
41 | void PinDlg::test( const QString& mac ) | 40 | void PinDlg::test( const QString& mac ) |
42 | { | 41 | { |
43 | if (!mac.isEmpty() ) | 42 | if (!mac.isEmpty() ) |
44 | { | 43 | { |
45 | Config cfg("bluepin"); | 44 | Config cfg("bluepin"); |
46 | cfg.setGroup(mac); | 45 | cfg.setGroup(mac); |
47 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); | 46 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); |
48 | if ( !lnePin->text().isEmpty() ) | 47 | if ( !lnePin->text().isEmpty() ) |
49 | { | 48 | { |
50 | //QTimer::singleShot(100, this, SLOT(accept() ) ); | 49 | //QTimer::singleShot(100, this, SLOT(accept() ) ); |
51 | } | 50 | } |
52 | 51 | ||
53 | } | 52 | } |
54 | 53 | ||
55 | } | 54 | } |
56 | void PinDlg::accept() | 55 | void PinDlg::accept() |
57 | { | 56 | { |
58 | if ( ckbPin->isChecked() ) | 57 | if ( ckbPin->isChecked() ) |
59 | { | 58 | { |
60 | Config cfg("bluepin"); | 59 | Config cfg("bluepin"); |
61 | cfg.setGroup(m_mac ); | 60 | cfg.setGroup(m_mac ); |
62 | cfg.writeEntryCrypt("pin", lnePin->text() ); | 61 | cfg.writeEntryCrypt("pin", lnePin->text() ); |
63 | } | 62 | } |
64 | QDialog::accept(); | 63 | QDialog::accept(); |
65 | } | 64 | } |
diff --git a/noncore/net/opietooth/manager/bticonloader.cpp b/noncore/net/opietooth/manager/bticonloader.cpp index e5d8092..6bac256 100644 --- a/noncore/net/opietooth/manager/bticonloader.cpp +++ b/noncore/net/opietooth/manager/bticonloader.cpp | |||
@@ -1,79 +1,78 @@ | |||
1 | 1 | ||
2 | #include "bticonloader.h" | 2 | #include "bticonloader.h" |
3 | 3 | ||
4 | #include <qpixmap.h> | ||
5 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
6 | 5 | ||
7 | namespace OpieTooth { | 6 | namespace OpieTooth { |
8 | 7 | ||
9 | 8 | ||
10 | BTIconLoader::BTIconLoader() { | 9 | BTIconLoader::BTIconLoader() { |
11 | 10 | ||
12 | // still need to find out real ids | 11 | // still need to find out real ids |
13 | deviceIcons.insert( 100 , "computer_16" ); | 12 | deviceIcons.insert( 100 , "computer_16" ); |
14 | deviceIcons.insert( 101 , "phone_16" ); | 13 | deviceIcons.insert( 101 , "phone_16" ); |
15 | deviceIcons.insert( 102 , "brain_16" ); | 14 | deviceIcons.insert( 102 , "brain_16" ); |
16 | deviceIcons.insert( 103 , "conduit_16" ); | 15 | deviceIcons.insert( 103 , "conduit_16" ); |
17 | 16 | ||
18 | 17 | ||
19 | serviceIcons.insert( 4357 , "obex_16" ); //OBEXObjectPush | 18 | serviceIcons.insert( 4357 , "obex_16" ); //OBEXObjectPush |
20 | serviceIcons.insert( 4358 , "obex_16" ); //OBEXFileTransfer | 19 | serviceIcons.insert( 4358 , "obex_16" ); //OBEXFileTransfer |
21 | serviceIcons.insert( 4369 , "print_16" ); //Fax | 20 | serviceIcons.insert( 4369 , "print_16" ); //Fax |
22 | serviceIcons.insert( 4353 , "serial_16" ); //SerialPort | 21 | serviceIcons.insert( 4353 , "serial_16" ); //SerialPort |
23 | serviceIcons.insert( 4356 , "sync_16" ); //IrMCSync | 22 | serviceIcons.insert( 4356 , "sync_16" ); //IrMCSync |
24 | serviceIcons.insert( 4359 , "sync_16" ); //IrMCSyncCommand | 23 | serviceIcons.insert( 4359 , "sync_16" ); //IrMCSyncCommand |
25 | serviceIcons.insert( 4354 , "network_16" ); //LANAccessUsingPPP | 24 | serviceIcons.insert( 4354 , "network_16" ); //LANAccessUsingPPP |
26 | serviceIcons.insert( 4355 , "network_16"); //DialupNetworking | 25 | serviceIcons.insert( 4355 , "network_16"); //DialupNetworking |
27 | serviceIcons.insert( 4360 , "phone_16"); // Headset | 26 | serviceIcons.insert( 4360 , "phone_16"); // Headset |
28 | serviceIcons.insert( 4370 , "audio_16"); //HeadsetAudioGateway | 27 | serviceIcons.insert( 4370 , "audio_16"); //HeadsetAudioGateway |
29 | serviceIcons.insert( 4374 , "network_16"); // Network Access Point | 28 | serviceIcons.insert( 4374 , "network_16"); // Network Access Point |
30 | serviceIcons.insert( 4361 , "phone_16"); // CordlessTelephony | 29 | serviceIcons.insert( 4361 , "phone_16"); // CordlessTelephony |
31 | serviceIcons.insert( 4362 , "audio_16"); // AudioSource | 30 | serviceIcons.insert( 4362 , "audio_16"); // AudioSource |
32 | serviceIcons.insert( 4363 , "audio_16"); // AudioSink | 31 | serviceIcons.insert( 4363 , "audio_16"); // AudioSink |
33 | serviceIcons.insert( 4390 , "print_16" ); //HCR_Print | 32 | serviceIcons.insert( 4390 , "print_16" ); //HCR_Print |
34 | serviceIcons.insert( 4392 , "phone_16" ); //Common_ISDN_Access | 33 | serviceIcons.insert( 4392 , "phone_16" ); //Common_ISDN_Access |
35 | 34 | ||
36 | serviceIcons.insert( 4609 , "network_16" ); //GenericNetworking | 35 | serviceIcons.insert( 4609 , "network_16" ); //GenericNetworking |
37 | serviceIcons.insert( 4610 , "folder_16" ); //GenericFileTransfer | 36 | serviceIcons.insert( 4610 , "folder_16" ); //GenericFileTransfer |
38 | serviceIcons.insert( 4392 , "audio_16" ); //GenericAudio | 37 | serviceIcons.insert( 4392 , "audio_16" ); //GenericAudio |
39 | // serviceIcons.insert( 4392 , "phone_16" ); //GenericTelephony | 38 | // serviceIcons.insert( 4392 , "phone_16" ); //GenericTelephony |
40 | // the above is duplicated? -zecke | 39 | // the above is duplicated? -zecke |
41 | 40 | ||
42 | //serviceIcons.insert( "106" , "link_16" ); | 41 | //serviceIcons.insert( "106" , "link_16" ); |
43 | //serviceIcons.insert( "107" , "misc_16" ); | 42 | //serviceIcons.insert( "107" , "misc_16" ); |
44 | } | 43 | } |
45 | 44 | ||
46 | BTIconLoader::~BTIconLoader() { | 45 | BTIconLoader::~BTIconLoader() { |
47 | } | 46 | } |
48 | 47 | ||
49 | QPixmap BTIconLoader::deviceIcon( int deviceClass ) { | 48 | QPixmap BTIconLoader::deviceIcon( int deviceClass ) { |
50 | 49 | ||
51 | QString iconName; | 50 | QString iconName; |
52 | 51 | ||
53 | QMap<int, QString>::Iterator it; | 52 | QMap<int, QString>::Iterator it; |
54 | 53 | ||
55 | it = deviceIcons.find( deviceClass ); | 54 | it = deviceIcons.find( deviceClass ); |
56 | iconName = it.data(); | 55 | iconName = it.data(); |
57 | 56 | ||
58 | if ( iconName.isEmpty() ) { | 57 | if ( iconName.isEmpty() ) { |
59 | iconName = "unknown_16"; | 58 | iconName = "unknown_16"; |
60 | } | 59 | } |
61 | return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); | 60 | return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); |
62 | } | 61 | } |
63 | 62 | ||
64 | QPixmap BTIconLoader::serviceIcon( int serviceClass ) { | 63 | QPixmap BTIconLoader::serviceIcon( int serviceClass ) { |
65 | 64 | ||
66 | QString iconName; | 65 | QString iconName; |
67 | 66 | ||
68 | QMap<int, QString>::Iterator it; | 67 | QMap<int, QString>::Iterator it; |
69 | 68 | ||
70 | it = serviceIcons.find( serviceClass ); | 69 | it = serviceIcons.find( serviceClass ); |
71 | iconName = it.data(); | 70 | iconName = it.data(); |
72 | 71 | ||
73 | if ( iconName.isEmpty() ) { | 72 | if ( iconName.isEmpty() ) { |
74 | iconName = "unknown_16"; | 73 | iconName = "unknown_16"; |
75 | } | 74 | } |
76 | return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); | 75 | return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); |
77 | } | 76 | } |
78 | 77 | ||
79 | } | 78 | } |
diff --git a/noncore/net/opietooth/manager/btserviceitem.cpp b/noncore/net/opietooth/manager/btserviceitem.cpp index 7db93c9..fb5f21e 100644 --- a/noncore/net/opietooth/manager/btserviceitem.cpp +++ b/noncore/net/opietooth/manager/btserviceitem.cpp | |||
@@ -1,26 +1,25 @@ | |||
1 | 1 | ||
2 | #include <qobject.h> | ||
3 | #include "btserviceitem.h" | 2 | #include "btserviceitem.h" |
4 | 3 | ||
5 | using namespace OpieTooth; | 4 | using namespace OpieTooth; |
6 | 5 | ||
7 | BTServiceItem::BTServiceItem( QListViewItem* item, const Services& serv ) | 6 | BTServiceItem::BTServiceItem( QListViewItem* item, const Services& serv ) |
8 | : BTListItem( item ) { | 7 | : BTListItem( item ) { |
9 | m_service = serv; | 8 | m_service = serv; |
10 | setText(0, QObject::tr(serv.serviceName() ) ); | 9 | setText(0, QObject::tr(serv.serviceName() ) ); |
11 | } | 10 | } |
12 | BTServiceItem::~BTServiceItem() { | 11 | BTServiceItem::~BTServiceItem() { |
13 | 12 | ||
14 | } | 13 | } |
15 | QString BTServiceItem::type() const { | 14 | QString BTServiceItem::type() const { |
16 | return QString::fromLatin1("service"); | 15 | return QString::fromLatin1("service"); |
17 | } | 16 | } |
18 | int BTServiceItem::typeId() const { | 17 | int BTServiceItem::typeId() const { |
19 | return Service; | 18 | return Service; |
20 | } | 19 | } |
21 | Services BTServiceItem::services() const { | 20 | Services BTServiceItem::services() const { |
22 | return m_service; | 21 | return m_service; |
23 | } | 22 | } |
24 | int BTServiceItem::serviceId() const { | 23 | int BTServiceItem::serviceId() const { |
25 | return m_service.recHandle(); | 24 | return m_service.recHandle(); |
26 | }; | 25 | }; |
diff --git a/noncore/net/opietooth/manager/hciconfwrapper.cpp b/noncore/net/opietooth/manager/hciconfwrapper.cpp index 46eed42..35e9cd9 100644 --- a/noncore/net/opietooth/manager/hciconfwrapper.cpp +++ b/noncore/net/opietooth/manager/hciconfwrapper.cpp | |||
@@ -1,140 +1,139 @@ | |||
1 | #include "hciconfwrapper.h" | 1 | #include "hciconfwrapper.h" |
2 | 2 | ||
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qtextstream.h> | 4 | #include <qtextstream.h> |
5 | #include <qstringlist.h> | ||
6 | #include <qregexp.h> | 5 | #include <qregexp.h> |
7 | 6 | ||
8 | namespace OpieTooth { | 7 | namespace OpieTooth { |
9 | 8 | ||
10 | 9 | ||
11 | HciConfWrapper::HciConfWrapper( const QString &fileName) { | 10 | HciConfWrapper::HciConfWrapper( const QString &fileName) { |
12 | m_fileName = fileName; | 11 | m_fileName = fileName; |
13 | } | 12 | } |
14 | 13 | ||
15 | HciConfWrapper::~HciConfWrapper() { | 14 | HciConfWrapper::~HciConfWrapper() { |
16 | } | 15 | } |
17 | 16 | ||
18 | 17 | ||
19 | void HciConfWrapper::setPinHelper( const QString& app ) { | 18 | void HciConfWrapper::setPinHelper( const QString& app ) { |
20 | setValue( "pin_helper" , app ); | 19 | setValue( "pin_helper" , app ); |
21 | } | 20 | } |
22 | 21 | ||
23 | void HciConfWrapper::setName( const QString &name ) { | 22 | void HciConfWrapper::setName( const QString &name ) { |
24 | qDebug ("NAME : " + name); | 23 | qDebug ("NAME : " + name); |
25 | setValue( "name" , "\"" + name + "\"" ); | 24 | setValue( "name" , "\"" + name + "\"" ); |
26 | } | 25 | } |
27 | 26 | ||
28 | void HciConfWrapper::setIscan( bool enable) { | 27 | void HciConfWrapper::setIscan( bool enable) { |
29 | 28 | ||
30 | if ( enable ) { | 29 | if ( enable ) { |
31 | setValue( "iscan" , "enable" ); | 30 | setValue( "iscan" , "enable" ); |
32 | } else { | 31 | } else { |
33 | setValue( "iscan" , "disable" ); | 32 | setValue( "iscan" , "disable" ); |
34 | } | 33 | } |
35 | } | 34 | } |
36 | 35 | ||
37 | void HciConfWrapper::setPscan( bool enable) { | 36 | void HciConfWrapper::setPscan( bool enable) { |
38 | 37 | ||
39 | if ( enable ) { | 38 | if ( enable ) { |
40 | setValue( "pscan" , "enable" ); | 39 | setValue( "pscan" , "enable" ); |
41 | } else { | 40 | } else { |
42 | setValue( "pscan" , "disable" ); | 41 | setValue( "pscan" , "disable" ); |
43 | } | 42 | } |
44 | } | 43 | } |
45 | 44 | ||
46 | 45 | ||
47 | void HciConfWrapper::setAuth( bool enable) { | 46 | void HciConfWrapper::setAuth( bool enable) { |
48 | 47 | ||
49 | if ( enable ) { | 48 | if ( enable ) { |
50 | setValue( "auth" , "enable" ); | 49 | setValue( "auth" , "enable" ); |
51 | } else { | 50 | } else { |
52 | setValue( "auth" , "disable" ); | 51 | setValue( "auth" , "disable" ); |
53 | } | 52 | } |
54 | } | 53 | } |
55 | 54 | ||
56 | 55 | ||
57 | void HciConfWrapper::setEncrypt( bool enable) { | 56 | void HciConfWrapper::setEncrypt( bool enable) { |
58 | 57 | ||
59 | if ( enable ) { | 58 | if ( enable ) { |
60 | setValue( "encrypt" , "enable" ); | 59 | setValue( "encrypt" , "enable" ); |
61 | } else { | 60 | } else { |
62 | setValue( "encrypt" , "disable" ); | 61 | setValue( "encrypt" , "disable" ); |
63 | } | 62 | } |
64 | } | 63 | } |
65 | 64 | ||
66 | 65 | ||
67 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { | 66 | void HciConfWrapper::setValue(const QString &key, const QString &value ) { |
68 | 67 | ||
69 | if (m_file.isEmpty() ) // load first | 68 | if (m_file.isEmpty() ) // load first |
70 | return; | 69 | return; |
71 | 70 | ||
72 | QStringList::Iterator it; | 71 | QStringList::Iterator it; |
73 | 72 | ||
74 | QString str; | 73 | QString str; |
75 | for (it = m_file.begin(); it != m_file.end(); ++it ) { | 74 | for (it = m_file.begin(); it != m_file.end(); ++it ) { |
76 | str = (*it); | 75 | str = (*it); |
77 | if( (str.contains(key)) > 0 ) { | 76 | if( (str.contains(key)) > 0 ) { |
78 | qDebug("Found"); | 77 | qDebug("Found"); |
79 | // still need to look if its commented out!!! | 78 | // still need to look if its commented out!!! |
80 | str.simplifyWhiteSpace(); | 79 | str.simplifyWhiteSpace(); |
81 | qDebug( key ); | 80 | qDebug( key ); |
82 | if (str.startsWith("#")) { | 81 | if (str.startsWith("#")) { |
83 | str = (key + " " + value + ";"); | 82 | str = (key + " " + value + ";"); |
84 | } else { | 83 | } else { |
85 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); | 84 | str = str.replace( QRegExp( "\\s*"+key+"\\s+[^\\s][^;]*;" ), key + " " + value + ";"); |
86 | } | 85 | } |
87 | qDebug( str ); | 86 | qDebug( str ); |
88 | it = m_file.remove( it ); | 87 | it = m_file.remove( it ); |
89 | it = m_file.insert( it, str ); | 88 | it = m_file.insert( it, str ); |
90 | //return; the regexp is too wide -zecke // all set | 89 | //return; the regexp is too wide -zecke // all set |
91 | } | 90 | } |
92 | } | 91 | } |
93 | 92 | ||
94 | 93 | ||
95 | } | 94 | } |
96 | 95 | ||
97 | /** | 96 | /** |
98 | * This loads the config file and stores it inside | 97 | * This loads the config file and stores it inside |
99 | * the m_file | 98 | * the m_file |
100 | */ | 99 | */ |
101 | void HciConfWrapper::load() { | 100 | void HciConfWrapper::load() { |
102 | qWarning("loaded"); | 101 | qWarning("loaded"); |
103 | m_file.clear(); | 102 | m_file.clear(); |
104 | QFile file( m_fileName ); | 103 | QFile file( m_fileName ); |
105 | if (!file.open( IO_ReadOnly ) ) { | 104 | if (!file.open( IO_ReadOnly ) ) { |
106 | qDebug("Could not open"); | 105 | qDebug("Could not open"); |
107 | return; | 106 | return; |
108 | } | 107 | } |
109 | 108 | ||
110 | /** | 109 | /** |
111 | * readAll() into a QByteArray | 110 | * readAll() into a QByteArray |
112 | * QStringList::split('\n', array ) | 111 | * QStringList::split('\n', array ) |
113 | * would this be faster? -zecke | 112 | * would this be faster? -zecke |
114 | */ | 113 | */ |
115 | QTextStream stream(&file ); | 114 | QTextStream stream(&file ); |
116 | QString tmp; | 115 | QString tmp; |
117 | while ( !stream.atEnd() ) { | 116 | while ( !stream.atEnd() ) { |
118 | tmp = stream.readLine(); | 117 | tmp = stream.readLine(); |
119 | m_file.append( tmp ); | 118 | m_file.append( tmp ); |
120 | } | 119 | } |
121 | } | 120 | } |
122 | void HciConfWrapper::save() { | 121 | void HciConfWrapper::save() { |
123 | qWarning("save"); | 122 | qWarning("save"); |
124 | if (m_file.isEmpty() ) // load first | 123 | if (m_file.isEmpty() ) // load first |
125 | return; | 124 | return; |
126 | 125 | ||
127 | QFile file( m_fileName ); | 126 | QFile file( m_fileName ); |
128 | if ( !file.open(IO_WriteOnly ) ) { | 127 | if ( !file.open(IO_WriteOnly ) ) { |
129 | qWarning("could not open %s", m_fileName.latin1() ); | 128 | qWarning("could not open %s", m_fileName.latin1() ); |
130 | return; | 129 | return; |
131 | } | 130 | } |
132 | 131 | ||
133 | QTextStream stream(&file ); | 132 | QTextStream stream(&file ); |
134 | QStringList::Iterator it; | 133 | QStringList::Iterator it; |
135 | for ( it = m_file.begin(); it != m_file.end(); ++it ) { | 134 | for ( it = m_file.begin(); it != m_file.end(); ++it ) { |
136 | stream << (*it) << endl; | 135 | stream << (*it) << endl; |
137 | } | 136 | } |
138 | qWarning("saved"); | 137 | qWarning("saved"); |
139 | }; | 138 | }; |
140 | } | 139 | } |
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp b/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp index 1e7130f..a41f304 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp +++ b/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp | |||
@@ -1,54 +1,53 @@ | |||
1 | 1 | ||
2 | #include "rfcommassigndialogitem.h" | 2 | #include "rfcommassigndialogitem.h" |
3 | 3 | ||
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qcombobox.h> | 5 | #include <qcombobox.h> |
6 | #include <qlabel.h> | ||
7 | #include <qgroupbox.h> | 6 | #include <qgroupbox.h> |
8 | 7 | ||
9 | using namespace OpieTooth; | 8 | using namespace OpieTooth; |
10 | 9 | ||
11 | 10 | ||
12 | RfcommDialogItem::RfcommDialogItem( QWidget* parent, const char* name, WFlags fl ) | 11 | RfcommDialogItem::RfcommDialogItem( QWidget* parent, const char* name, WFlags fl ) |
13 | : RfcommDialogItemBase( parent, name, fl ) { | 12 | : RfcommDialogItemBase( parent, name, fl ) { |
14 | 13 | ||
15 | } | 14 | } |
16 | 15 | ||
17 | RfcommDialogItem::~RfcommDialogItem() { | 16 | RfcommDialogItem::~RfcommDialogItem() { |
18 | } | 17 | } |
19 | 18 | ||
20 | 19 | ||
21 | int RfcommDialogItem::ident() { | 20 | int RfcommDialogItem::ident() { |
22 | return m_ident; | 21 | return m_ident; |
23 | } | 22 | } |
24 | 23 | ||
25 | QString RfcommDialogItem::mac() { | 24 | QString RfcommDialogItem::mac() { |
26 | return m_macAddress->text(); | 25 | return m_macAddress->text(); |
27 | } | 26 | } |
28 | 27 | ||
29 | int RfcommDialogItem::channel() { | 28 | int RfcommDialogItem::channel() { |
30 | return m_channelDropdown->currentItem(); | 29 | return m_channelDropdown->currentItem(); |
31 | } | 30 | } |
32 | 31 | ||
33 | QString RfcommDialogItem::comment() { | 32 | QString RfcommDialogItem::comment() { |
34 | return m_commentLine->text(); | 33 | return m_commentLine->text(); |
35 | } | 34 | } |
36 | 35 | ||
37 | void RfcommDialogItem::setIdent( int ident ) { | 36 | void RfcommDialogItem::setIdent( int ident ) { |
38 | m_ident = ident; | 37 | m_ident = ident; |
39 | m_identLabel->setTitle( QString( "rfcomm%1").arg( ident ) ); | 38 | m_identLabel->setTitle( QString( "rfcomm%1").arg( ident ) ); |
40 | } | 39 | } |
41 | 40 | ||
42 | void RfcommDialogItem::setMac( const QString &mac ) { | 41 | void RfcommDialogItem::setMac( const QString &mac ) { |
43 | m_macAddress->setText( mac ); | 42 | m_macAddress->setText( mac ); |
44 | } | 43 | } |
45 | 44 | ||
46 | void RfcommDialogItem::setChannel( int channel ) { | 45 | void RfcommDialogItem::setChannel( int channel ) { |
47 | m_channelDropdown->setCurrentItem( channel ); | 46 | m_channelDropdown->setCurrentItem( channel ); |
48 | } | 47 | } |
49 | 48 | ||
50 | void RfcommDialogItem::setComment( const QString &comment ) { | 49 | void RfcommDialogItem::setComment( const QString &comment ) { |
51 | m_commentLine->setText( comment ); | 50 | m_commentLine->setText( comment ); |
52 | } | 51 | } |
53 | 52 | ||
54 | 53 | ||
diff --git a/noncore/net/wellenreiter/gui/protolistview.cpp b/noncore/net/wellenreiter/gui/protolistview.cpp index daca095..ed22bdd 100644 --- a/noncore/net/wellenreiter/gui/protolistview.cpp +++ b/noncore/net/wellenreiter/gui/protolistview.cpp | |||
@@ -1,124 +1,120 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | /* LOCAL */ | 16 | /* LOCAL */ |
17 | #include "protolistview.h" | 17 | #include "protolistview.h" |
18 | 18 | ||
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qhbox.h> | ||
22 | #include <qvbox.h> | 21 | #include <qvbox.h> |
23 | #include <qpalette.h> | ||
24 | #include <qcolor.h> | ||
25 | #include <qlabel.h> | 22 | #include <qlabel.h> |
26 | #include <qframe.h> | ||
27 | 23 | ||
28 | ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f ) | 24 | ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f ) |
29 | :QScrollView( parent, name, f ) | 25 | :QScrollView( parent, name, f ) |
30 | { | 26 | { |
31 | parse = ( QString( "parsePackets" ) == QString( name ) ); | 27 | parse = ( QString( "parsePackets" ) == QString( name ) ); |
32 | 28 | ||
33 | setMargins( 3, 3, 0, 0 ); | 29 | setMargins( 3, 3, 0, 0 ); |
34 | viewport()->setBackgroundColor( QCheckBox(0).palette().color( QPalette::Active, QColorGroup::Background ) ); | 30 | viewport()->setBackgroundColor( QCheckBox(0).palette().color( QPalette::Active, QColorGroup::Background ) ); |
35 | 31 | ||
36 | vbox = new QVBox( viewport() ); | 32 | vbox = new QVBox( viewport() ); |
37 | vbox->setSpacing( 1 ); | 33 | vbox->setSpacing( 1 ); |
38 | addChild( vbox ); | 34 | addChild( vbox ); |
39 | 35 | ||
40 | QHBox* hbox = new QHBox( vbox ); | 36 | QHBox* hbox = new QHBox( vbox ); |
41 | hbox->setSpacing( 40 ); | 37 | hbox->setSpacing( 40 ); |
42 | new QLabel( tr( "Protocol Family" ), hbox ); | 38 | new QLabel( tr( "Protocol Family" ), hbox ); |
43 | new QLabel( tr( "Perform Action" ), hbox ); | 39 | new QLabel( tr( "Perform Action" ), hbox ); |
44 | QFrame* frame = new QFrame( vbox ); | 40 | QFrame* frame = new QFrame( vbox ); |
45 | frame->setFrameStyle( QFrame::HLine + QFrame::Sunken ); | 41 | frame->setFrameStyle( QFrame::HLine + QFrame::Sunken ); |
46 | 42 | ||
47 | //TODO: hardcoded for now...a protocol database would be nice!? | 43 | //TODO: hardcoded for now...a protocol database would be nice!? |
48 | 44 | ||
49 | //addProtocol( "Ethernet" ); | 45 | //addProtocol( "Ethernet" ); |
50 | addProtocol( "Prism" ); | 46 | addProtocol( "Prism" ); |
51 | //addProtocol( "802.11" ); | 47 | //addProtocol( "802.11" ); |
52 | addProtocol( "802.11 Management" ); | 48 | addProtocol( "802.11 Management" ); |
53 | addProtocol( "802.11 SSID" ); | 49 | addProtocol( "802.11 SSID" ); |
54 | addProtocol( "802.11 Rates" ); | 50 | addProtocol( "802.11 Rates" ); |
55 | addProtocol( "802.11 CF" ); | 51 | addProtocol( "802.11 CF" ); |
56 | addProtocol( "802.11 FH" ); | 52 | addProtocol( "802.11 FH" ); |
57 | addProtocol( "802.11 DS" ); | 53 | addProtocol( "802.11 DS" ); |
58 | addProtocol( "802.11 Tim" ); | 54 | addProtocol( "802.11 Tim" ); |
59 | addProtocol( "802.11 IBSS" ); | 55 | addProtocol( "802.11 IBSS" ); |
60 | addProtocol( "802.11 Challenge" ); | 56 | addProtocol( "802.11 Challenge" ); |
61 | addProtocol( "802.11 Data" ); | 57 | addProtocol( "802.11 Data" ); |
62 | addProtocol( "802.11 LLC" ); | 58 | addProtocol( "802.11 LLC" ); |
63 | addProtocol( "802.11 Data" ); | 59 | addProtocol( "802.11 Data" ); |
64 | addProtocol( "IP" ); | 60 | addProtocol( "IP" ); |
65 | addProtocol( "ARP" ); | 61 | addProtocol( "ARP" ); |
66 | addProtocol( "UDP" ); | 62 | addProtocol( "UDP" ); |
67 | addProtocol( "TCP" ); | 63 | addProtocol( "TCP" ); |
68 | } | 64 | } |
69 | 65 | ||
70 | 66 | ||
71 | ProtocolListView::~ProtocolListView() | 67 | ProtocolListView::~ProtocolListView() |
72 | { | 68 | { |
73 | } | 69 | } |
74 | 70 | ||
75 | 71 | ||
76 | void ProtocolListView::addProtocol( const QString& name ) | 72 | void ProtocolListView::addProtocol( const QString& name ) |
77 | { | 73 | { |
78 | QHBox* hbox = new QHBox( vbox ); | 74 | QHBox* hbox = new QHBox( vbox ); |
79 | new QCheckBox( name, hbox, (const char*) name ); | 75 | new QCheckBox( name, hbox, (const char*) name ); |
80 | 76 | ||
81 | if ( parse ) | 77 | if ( parse ) |
82 | { | 78 | { |
83 | QComboBox* combo = new QComboBox( hbox, (const char*) name ); | 79 | QComboBox* combo = new QComboBox( hbox, (const char*) name ); |
84 | #ifdef QWS | 80 | #ifdef QWS |
85 | combo->setFixedWidth( 75 ); | 81 | combo->setFixedWidth( 75 ); |
86 | #endif | 82 | #endif |
87 | combo->insertItem( "Pass" ); | 83 | combo->insertItem( "Pass" ); |
88 | combo->insertItem( "Discard!" ); | 84 | combo->insertItem( "Discard!" ); |
89 | combo->insertItem( "TouchSound" ); | 85 | combo->insertItem( "TouchSound" ); |
90 | combo->insertItem( "AlarmSound" ); | 86 | combo->insertItem( "AlarmSound" ); |
91 | combo->insertItem( "KeySound" ); | 87 | combo->insertItem( "KeySound" ); |
92 | combo->insertItem( "LedOn" ); | 88 | combo->insertItem( "LedOn" ); |
93 | combo->insertItem( "LedOff" ); | 89 | combo->insertItem( "LedOff" ); |
94 | combo->insertItem( "LogMessage" ); | 90 | combo->insertItem( "LogMessage" ); |
95 | combo->insertItem( "MessageBox" ); | 91 | combo->insertItem( "MessageBox" ); |
96 | } | 92 | } |
97 | else | 93 | else |
98 | { | 94 | { |
99 | QComboBox* combo = new QComboBox( hbox, (const char*) name ); | 95 | QComboBox* combo = new QComboBox( hbox, (const char*) name ); |
100 | #ifdef QWS | 96 | #ifdef QWS |
101 | combo->setFixedWidth( 75 ); | 97 | combo->setFixedWidth( 75 ); |
102 | #endif | 98 | #endif |
103 | combo->insertItem( "Pass" ); | 99 | combo->insertItem( "Pass" ); |
104 | combo->insertItem( "Discard!" ); | 100 | combo->insertItem( "Discard!" ); |
105 | } | 101 | } |
106 | } | 102 | } |
107 | 103 | ||
108 | 104 | ||
109 | bool ProtocolListView::isProtocolChecked( const QString& name ) | 105 | bool ProtocolListView::isProtocolChecked( const QString& name ) |
110 | { | 106 | { |
111 | QCheckBox* box = (QCheckBox*) child( (const char*) name ); | 107 | QCheckBox* box = (QCheckBox*) child( (const char*) name ); |
112 | return ( box && box->isOn() ); | 108 | return ( box && box->isOn() ); |
113 | } | 109 | } |
114 | 110 | ||
115 | 111 | ||
116 | QString ProtocolListView::protocolAction( const QString& name ) | 112 | QString ProtocolListView::protocolAction( const QString& name ) |
117 | { | 113 | { |
118 | QComboBox* combo = (QComboBox*) child( (const char*) name, "QComboBox" ); | 114 | QComboBox* combo = (QComboBox*) child( (const char*) name, "QComboBox" ); |
119 | if ( combo ) | 115 | if ( combo ) |
120 | return combo->currentText(); | 116 | return combo->currentText(); |
121 | else | 117 | else |
122 | return "<unknown>"; | 118 | return "<unknown>"; |
123 | } | 119 | } |
124 | 120 | ||
diff --git a/noncore/net/wellenreiter/gui/resource.cpp b/noncore/net/wellenreiter/gui/resource.cpp index a39bbcc..5e5ddc6 100644 --- a/noncore/net/wellenreiter/gui/resource.cpp +++ b/noncore/net/wellenreiter/gui/resource.cpp | |||
@@ -1,50 +1,49 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "resource.h" | 16 | #include "resource.h" |
17 | 17 | ||
18 | #define PIXMAPPATH "/usr/local/share" | 18 | #define PIXMAPPATH "/usr/local/share" |
19 | 19 | ||
20 | #include <qpixmap.h> | ||
21 | #include <qiconset.h> | 20 | #include <qiconset.h> |
22 | 21 | ||
23 | namespace Resource | 22 | namespace Resource |
24 | { | 23 | { |
25 | 24 | ||
26 | QPixmap loadPixmap( const QString& pix ) | 25 | QPixmap loadPixmap( const QString& pix ) |
27 | { | 26 | { |
28 | QString filename; | 27 | QString filename; |
29 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); | 28 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); |
30 | QPixmap pixmap( filename ); | 29 | QPixmap pixmap( filename ); |
31 | if ( pixmap.isNull() ) | 30 | if ( pixmap.isNull() ) |
32 | { | 31 | { |
33 | qDebug( "Wellenreiter::Resource: can't find pixmap " + filename ); | 32 | qDebug( "Wellenreiter::Resource: can't find pixmap " + filename ); |
34 | } | 33 | } |
35 | return pixmap; | 34 | return pixmap; |
36 | }; | 35 | }; |
37 | 36 | ||
38 | QIconSet loadIconSet( const QString& pix ) | 37 | QIconSet loadIconSet( const QString& pix ) |
39 | { | 38 | { |
40 | QString filename; | 39 | QString filename; |
41 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); | 40 | filename.sprintf( "%s/%s.png", (const char*) PIXMAPPATH, (const char*) pix ); |
42 | QPixmap pixmap( filename ); | 41 | QPixmap pixmap( filename ); |
43 | if ( pixmap.isNull() ) | 42 | if ( pixmap.isNull() ) |
44 | { | 43 | { |
45 | qDebug( "Wellenreiter::Resource: can't find pixmap " + filename ); | 44 | qDebug( "Wellenreiter::Resource: can't find pixmap " + filename ); |
46 | } | 45 | } |
47 | return QIconSet( pixmap ); | 46 | return QIconSet( pixmap ); |
48 | }; | 47 | }; |
49 | 48 | ||
50 | }; | 49 | }; |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index b42f1df..c75f9b1 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -1,564 +1,563 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | **********************************************************************/ | 14 | **********************************************************************/ |
15 | 15 | ||
16 | #include "scanlist.h" | 16 | #include "scanlist.h" |
17 | #include "configwindow.h" | 17 | #include "configwindow.h" |
18 | #include "logwindow.h" | 18 | #include "logwindow.h" |
19 | 19 | ||
20 | #include <assert.h> | 20 | #include <assert.h> |
21 | #include <qcursor.h> | 21 | #include <qcursor.h> |
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qtextstream.h> | ||
24 | #include <qpopupmenu.h> | 23 | #include <qpopupmenu.h> |
25 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
26 | 25 | ||
27 | #ifdef QWS | 26 | #ifdef QWS |
28 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
29 | #endif | 28 | #endif |
30 | 29 | ||
31 | #ifdef QWS | 30 | #ifdef QWS |
32 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
33 | #else | 32 | #else |
34 | #include "resource.h" | 33 | #include "resource.h" |
35 | #endif | 34 | #endif |
36 | 35 | ||
37 | const int col_type = 0; | 36 | const int col_type = 0; |
38 | const int col_essid = 0; | 37 | const int col_essid = 0; |
39 | const int col_sig = 1; | 38 | const int col_sig = 1; |
40 | const int col_ap = 2; | 39 | const int col_ap = 2; |
41 | const int col_channel = 3; | 40 | const int col_channel = 3; |
42 | const int col_wep = 4; | 41 | const int col_wep = 4; |
43 | const int col_traffic = 5; | 42 | const int col_traffic = 5; |
44 | const int col_ip = 6; | 43 | const int col_ip = 6; |
45 | const int col_manuf = 7; | 44 | const int col_manuf = 7; |
46 | const int col_firstseen = 8; | 45 | const int col_firstseen = 8; |
47 | const int col_lastseen = 9; | 46 | const int col_lastseen = 9; |
48 | const int col_location = 10; | 47 | const int col_location = 10; |
49 | 48 | ||
50 | MScanListView::MScanListView( QWidget* parent, const char* name ) | 49 | MScanListView::MScanListView( QWidget* parent, const char* name ) |
51 | :OListView( parent, name ) | 50 | :OListView( parent, name ) |
52 | { | 51 | { |
53 | 52 | ||
54 | setFrameShape( QListView::StyledPanel ); | 53 | setFrameShape( QListView::StyledPanel ); |
55 | setFrameShadow( QListView::Sunken ); | 54 | setFrameShadow( QListView::Sunken ); |
56 | 55 | ||
57 | addColumn( tr( "Net/Station" ) ); | 56 | addColumn( tr( "Net/Station" ) ); |
58 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); | 57 | setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); |
59 | addColumn( tr( "#" ) ); | 58 | addColumn( tr( "#" ) ); |
60 | setColumnAlignment( col_sig, AlignCenter ); | 59 | setColumnAlignment( col_sig, AlignCenter ); |
61 | addColumn( tr( "MAC" ) ); | 60 | addColumn( tr( "MAC" ) ); |
62 | setColumnAlignment( col_ap, AlignCenter ); | 61 | setColumnAlignment( col_ap, AlignCenter ); |
63 | addColumn( tr( "Chn" ) ); | 62 | addColumn( tr( "Chn" ) ); |
64 | setColumnAlignment( col_channel, AlignCenter ); | 63 | setColumnAlignment( col_channel, AlignCenter ); |
65 | addColumn( tr( "W" ) ); | 64 | addColumn( tr( "W" ) ); |
66 | setColumnAlignment( col_wep, AlignCenter ); | 65 | setColumnAlignment( col_wep, AlignCenter ); |
67 | addColumn( tr( "T" ) ); | 66 | addColumn( tr( "T" ) ); |
68 | setColumnAlignment( col_traffic, AlignCenter ); | 67 | setColumnAlignment( col_traffic, AlignCenter ); |
69 | addColumn( tr( "IP" ) ); | 68 | addColumn( tr( "IP" ) ); |
70 | setColumnAlignment( col_ip, AlignCenter ); | 69 | setColumnAlignment( col_ip, AlignCenter ); |
71 | addColumn( tr( "Manufacturer" ) ); | 70 | addColumn( tr( "Manufacturer" ) ); |
72 | setColumnAlignment( col_manuf, AlignCenter ); | 71 | setColumnAlignment( col_manuf, AlignCenter ); |
73 | addColumn( tr( "First Seen" ) ); | 72 | addColumn( tr( "First Seen" ) ); |
74 | setColumnAlignment( col_firstseen, AlignCenter ); | 73 | setColumnAlignment( col_firstseen, AlignCenter ); |
75 | addColumn( tr( "Last Seen" ) ); | 74 | addColumn( tr( "Last Seen" ) ); |
76 | setColumnAlignment( col_lastseen, AlignCenter ); | 75 | setColumnAlignment( col_lastseen, AlignCenter ); |
77 | addColumn( tr( "Location" ) ); | 76 | addColumn( tr( "Location" ) ); |
78 | setColumnAlignment( col_location, AlignCenter ); | 77 | setColumnAlignment( col_location, AlignCenter ); |
79 | setRootIsDecorated( true ); | 78 | setRootIsDecorated( true ); |
80 | setAllColumnsShowFocus( true ); | 79 | setAllColumnsShowFocus( true ); |
81 | 80 | ||
82 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), | 81 | connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), |
83 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); | 82 | this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); |
84 | 83 | ||
85 | #ifdef QWS | 84 | #ifdef QWS |
86 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 85 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
87 | #endif | 86 | #endif |
88 | 87 | ||
89 | }; | 88 | }; |
90 | 89 | ||
91 | 90 | ||
92 | MScanListView::~MScanListView() | 91 | MScanListView::~MScanListView() |
93 | { | 92 | { |
94 | }; | 93 | }; |
95 | 94 | ||
96 | 95 | ||
97 | OListViewItem* MScanListView::childFactory() | 96 | OListViewItem* MScanListView::childFactory() |
98 | { | 97 | { |
99 | return new MScanListItem( this ); | 98 | return new MScanListItem( this ); |
100 | } | 99 | } |
101 | 100 | ||
102 | 101 | ||
103 | void MScanListView::serializeTo( QDataStream& s) const | 102 | void MScanListView::serializeTo( QDataStream& s) const |
104 | { | 103 | { |
105 | qDebug( "serializing MScanListView" ); | 104 | qDebug( "serializing MScanListView" ); |
106 | OListView::serializeTo( s ); | 105 | OListView::serializeTo( s ); |
107 | } | 106 | } |
108 | 107 | ||
109 | 108 | ||
110 | void MScanListView::serializeFrom( QDataStream& s) | 109 | void MScanListView::serializeFrom( QDataStream& s) |
111 | { | 110 | { |
112 | qDebug( "serializing MScanListView" ); | 111 | qDebug( "serializing MScanListView" ); |
113 | OListView::serializeFrom( s ); | 112 | OListView::serializeFrom( s ); |
114 | } | 113 | } |
115 | 114 | ||
116 | 115 | ||
117 | void MScanListView::addNewItem( const QString& type, | 116 | void MScanListView::addNewItem( const QString& type, |
118 | const QString& essid, | 117 | const QString& essid, |
119 | const OMacAddress& mac, | 118 | const OMacAddress& mac, |
120 | bool wep, | 119 | bool wep, |
121 | int channel, | 120 | int channel, |
122 | int signal, | 121 | int signal, |
123 | const GpsLocation& loc, | 122 | const GpsLocation& loc, |
124 | bool probe ) | 123 | bool probe ) |
125 | { | 124 | { |
126 | QString macaddr = mac.toString(true); | 125 | QString macaddr = mac.toString(true); |
127 | 126 | ||
128 | #ifdef DEBUG | 127 | #ifdef DEBUG |
129 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, | 128 | qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, |
130 | (const char*) essid, (const char*) macaddr, channel ); | 129 | (const char*) essid, (const char*) macaddr, channel ); |
131 | #endif | 130 | #endif |
132 | 131 | ||
133 | // search, if we already have seen this net | 132 | // search, if we already have seen this net |
134 | 133 | ||
135 | QString s; | 134 | QString s; |
136 | MScanListItem* network; | 135 | MScanListItem* network; |
137 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); | 136 | MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); |
138 | 137 | ||
139 | while ( item && ( item->text( col_essid ) != essid ) ) | 138 | while ( item && ( item->text( col_essid ) != essid ) ) |
140 | { | 139 | { |
141 | #ifdef DEBUG | 140 | #ifdef DEBUG |
142 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); | 141 | qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); |
143 | #endif | 142 | #endif |
144 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 143 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
145 | } | 144 | } |
146 | if ( item ) | 145 | if ( item ) |
147 | { | 146 | { |
148 | // we have already seen this net, check all childs if MAC exists | 147 | // we have already seen this net, check all childs if MAC exists |
149 | 148 | ||
150 | network = item; | 149 | network = item; |
151 | 150 | ||
152 | item = static_cast<MScanListItem*> ( item->firstChild() ); | 151 | item = static_cast<MScanListItem*> ( item->firstChild() ); |
153 | assert( item ); // this shouldn't fail | 152 | assert( item ); // this shouldn't fail |
154 | 153 | ||
155 | while ( item && ( item->text( col_ap ) != macaddr ) ) | 154 | while ( item && ( item->text( col_ap ) != macaddr ) ) |
156 | { | 155 | { |
157 | #ifdef DEBUG | 156 | #ifdef DEBUG |
158 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); | 157 | qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); |
159 | #endif | 158 | #endif |
160 | item = static_cast<MScanListItem*> ( item->nextSibling() ); | 159 | item = static_cast<MScanListItem*> ( item->nextSibling() ); |
161 | } | 160 | } |
162 | 161 | ||
163 | if ( item ) | 162 | if ( item ) |
164 | { | 163 | { |
165 | // we have already seen this item, it's a dupe | 164 | // we have already seen this item, it's a dupe |
166 | #ifdef DEBUG | 165 | #ifdef DEBUG |
167 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); | 166 | qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); |
168 | #endif | 167 | #endif |
169 | item->receivedBeacon(); | 168 | item->receivedBeacon(); |
170 | return; | 169 | return; |
171 | } | 170 | } |
172 | } | 171 | } |
173 | else | 172 | else |
174 | { | 173 | { |
175 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); | 174 | s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); |
176 | MLogWindow::logwindow()->log( s ); | 175 | MLogWindow::logwindow()->log( s ); |
177 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); | 176 | network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); |
178 | } | 177 | } |
179 | 178 | ||
180 | 179 | ||
181 | // insert new station as child from network | 180 | // insert new station as child from network |
182 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? | 181 | // no essid to reduce clutter, maybe later we have a nick or stationname to display!? |
183 | 182 | ||
184 | #ifdef DEBUG | 183 | #ifdef DEBUG |
185 | qDebug( "inserting new station %s", (const char*) macaddr ); | 184 | qDebug( "inserting new station %s", (const char*) macaddr ); |
186 | #endif | 185 | #endif |
187 | 186 | ||
188 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); | 187 | MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); |
189 | station->setManufacturer( mac.manufacturer() ); | 188 | station->setManufacturer( mac.manufacturer() ); |
190 | station->setLocation( loc.dmsPosition() ); | 189 | station->setLocation( loc.dmsPosition() ); |
191 | 190 | ||
192 | if ( type == "managed" ) | 191 | if ( type == "managed" ) |
193 | { | 192 | { |
194 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); | 193 | s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); |
195 | } | 194 | } |
196 | else | 195 | else |
197 | { | 196 | { |
198 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); | 197 | s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); |
199 | } | 198 | } |
200 | MLogWindow::logwindow()->log( s ); | 199 | MLogWindow::logwindow()->log( s ); |
201 | } | 200 | } |
202 | 201 | ||
203 | 202 | ||
204 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) | 203 | void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) |
205 | { | 204 | { |
206 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); | 205 | MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); |
207 | 206 | ||
208 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) | 207 | while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) |
209 | { | 208 | { |
210 | #ifdef DEBUG | 209 | #ifdef DEBUG |
211 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); | 210 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); |
212 | #endif | 211 | #endif |
213 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 212 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
214 | } | 213 | } |
215 | 214 | ||
216 | if ( subitem ) | 215 | if ( subitem ) |
217 | { | 216 | { |
218 | // we have already seen this item, it's a dupe | 217 | // we have already seen this item, it's a dupe |
219 | #ifdef DEBUG | 218 | #ifdef DEBUG |
220 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); | 219 | qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); |
221 | #endif | 220 | #endif |
222 | subitem->receivedBeacon(); //FIXME: sent data bit | 221 | subitem->receivedBeacon(); //FIXME: sent data bit |
223 | return; | 222 | return; |
224 | } | 223 | } |
225 | 224 | ||
226 | // Hey, it seems to be a new item :-D | 225 | // Hey, it seems to be a new item :-D |
227 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); | 226 | MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); |
228 | station->setManufacturer( addr.manufacturer() ); | 227 | station->setManufacturer( addr.manufacturer() ); |
229 | 228 | ||
230 | QString s; | 229 | QString s; |
231 | if ( type == "station" ) | 230 | if ( type == "station" ) |
232 | { | 231 | { |
233 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 232 | s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
234 | } | 233 | } |
235 | else | 234 | else |
236 | { | 235 | { |
237 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); | 236 | s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); |
238 | } | 237 | } |
239 | MLogWindow::logwindow()->log( s ); | 238 | MLogWindow::logwindow()->log( s ); |
240 | } | 239 | } |
241 | 240 | ||
242 | 241 | ||
243 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) | 242 | void MScanListView::WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ) |
244 | { | 243 | { |
245 | qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() ); | 244 | qDebug( "WDSTraffic: %s and %s seem to form a WDS", (const char*) viaFrom.toString(), (const char*) viaTo.toString() ); |
246 | QString s; | 245 | QString s; |
247 | MScanListItem* network; | 246 | MScanListItem* network; |
248 | 247 | ||
249 | QListViewItemIterator it( this ); | 248 | QListViewItemIterator it( this ); |
250 | while ( it.current() && | 249 | while ( it.current() && |
251 | it.current()->text( col_ap ) != viaFrom.toString(true) && | 250 | it.current()->text( col_ap ) != viaFrom.toString(true) && |
252 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; | 251 | it.current()->text( col_ap ) != viaTo.toString(true) ) ++it; |
253 | 252 | ||
254 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 253 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
255 | 254 | ||
256 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations | 255 | if ( item ) // Either viaFrom or viaTo AP has shown up yet, so just add our two new stations |
257 | { | 256 | { |
258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); | 257 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from ); |
259 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); | 258 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), to ); |
260 | } | 259 | } |
261 | else | 260 | else |
262 | { | 261 | { |
263 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); | 262 | qDebug( "D'Oh! Stations without AP... ignoring for now... will handle this in 1.1 version :-D" ); |
264 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); | 263 | MLogWindow::logwindow()->log( "WARNING: Unhandled WSD traffic!" ); |
265 | } | 264 | } |
266 | } | 265 | } |
267 | 266 | ||
268 | 267 | ||
269 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 268 | void MScanListView::toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
270 | { | 269 | { |
271 | QString s; | 270 | QString s; |
272 | MScanListItem* network; | 271 | MScanListItem* network; |
273 | 272 | ||
274 | QListViewItemIterator it( this ); | 273 | QListViewItemIterator it( this ); |
275 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 274 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
276 | 275 | ||
277 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 276 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
278 | 277 | ||
279 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 278 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
280 | { | 279 | { |
281 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); | 280 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "adhoc" ); |
282 | } | 281 | } |
283 | else | 282 | else |
284 | { | 283 | { |
285 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 284 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
286 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); | 285 | MLogWindow::logwindow()->log( "WARNING: Unhandled toDS traffic!" ); |
287 | 286 | ||
288 | } | 287 | } |
289 | } | 288 | } |
290 | 289 | ||
291 | 290 | ||
292 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 291 | void MScanListView::fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
293 | { | 292 | { |
294 | QString s; | 293 | QString s; |
295 | MScanListItem* network; | 294 | MScanListItem* network; |
296 | 295 | ||
297 | QListViewItemIterator it( this ); | 296 | QListViewItemIterator it( this ); |
298 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; | 297 | while ( it.current() && it.current()->text( col_ap ) != via.toString(true) ) ++it; |
299 | 298 | ||
300 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); | 299 | MScanListItem* item = static_cast<MScanListItem*>( it.current() ); |
301 | 300 | ||
302 | if ( item ) // AP has shown up yet, so just add our new "from" - station | 301 | if ( item ) // AP has shown up yet, so just add our new "from" - station |
303 | { | 302 | { |
304 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); | 303 | addIfNotExisting( static_cast<MScanListItem*>(item->parent()), from, "station" ); |
305 | } | 304 | } |
306 | else | 305 | else |
307 | { | 306 | { |
308 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); | 307 | qDebug( "D'Oh! Station without AP... ignoring for now... will handle this in 1.1 :-D" ); |
309 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); | 308 | MLogWindow::logwindow()->log( "WARNING: Unhandled fromDS traffic!" ); |
310 | } | 309 | } |
311 | } | 310 | } |
312 | 311 | ||
313 | 312 | ||
314 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) | 313 | void MScanListView::IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ) |
315 | { | 314 | { |
316 | qWarning( "D'oh! Not yet implemented..." ); | 315 | qWarning( "D'oh! Not yet implemented..." ); |
317 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); | 316 | MLogWindow::logwindow()->log( "WARNING: Unhandled IBSS traffic!" ); |
318 | } | 317 | } |
319 | 318 | ||
320 | 319 | ||
321 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) | 320 | void MScanListView::identify( const OMacAddress& macaddr, const QString& ip ) |
322 | { | 321 | { |
323 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); | 322 | qDebug( "identify %s = %s", (const char*) macaddr.toString(), (const char*) ip ); |
324 | 323 | ||
325 | QListViewItemIterator it( this ); | 324 | QListViewItemIterator it( this ); |
326 | for ( ; it.current(); ++it ) | 325 | for ( ; it.current(); ++it ) |
327 | { | 326 | { |
328 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 327 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
329 | { | 328 | { |
330 | it.current()->setText( col_ip, ip ); | 329 | it.current()->setText( col_ip, ip ); |
331 | return; | 330 | return; |
332 | } | 331 | } |
333 | } | 332 | } |
334 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 333 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
335 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", | 334 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled identification %s = %s!", |
336 | (const char*) macaddr.toString(), (const char*) ip ) ); | 335 | (const char*) macaddr.toString(), (const char*) ip ) ); |
337 | } | 336 | } |
338 | 337 | ||
339 | 338 | ||
340 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) | 339 | void MScanListView::addService( const QString& name, const OMacAddress& macaddr, const QString& ip ) |
341 | { | 340 | { |
342 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); | 341 | qDebug( "addService '%s', Server = %s = %s", (const char*) name, (const char*) macaddr.toString(), (const char*) ip ); |
343 | 342 | ||
344 | //TODO: Refactor that out, we need it all over the place. | 343 | //TODO: Refactor that out, we need it all over the place. |
345 | // Best to do it in a more comfortable abstraction in OListView | 344 | // Best to do it in a more comfortable abstraction in OListView |
346 | // (Hmm, didn't I already start something in this direction?) | 345 | // (Hmm, didn't I already start something in this direction?) |
347 | 346 | ||
348 | QListViewItemIterator it( this ); | 347 | QListViewItemIterator it( this ); |
349 | for ( ; it.current(); ++it ) | 348 | for ( ; it.current(); ++it ) |
350 | { | 349 | { |
351 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) | 350 | if ( it.current()->text( col_ap ) == macaddr.toString(true) ) |
352 | { | 351 | { |
353 | 352 | ||
354 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); | 353 | MScanListItem* subitem = static_cast<MScanListItem*>( it.current()->firstChild() ); |
355 | 354 | ||
356 | while ( subitem && ( subitem->text( col_essid ) != name ) ) | 355 | while ( subitem && ( subitem->text( col_essid ) != name ) ) |
357 | { | 356 | { |
358 | #ifdef DEBUG | 357 | #ifdef DEBUG |
359 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); | 358 | qDebug( "subitemtext: %s", (const char*) subitem->text( col_essid ) ); |
360 | #endif | 359 | #endif |
361 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); | 360 | subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); |
362 | } | 361 | } |
363 | 362 | ||
364 | if ( subitem ) | 363 | if ( subitem ) |
365 | { | 364 | { |
366 | // we have already seen this item, it's a dupe | 365 | // we have already seen this item, it's a dupe |
367 | #ifdef DEBUG | 366 | #ifdef DEBUG |
368 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); | 367 | qDebug( "%s is a dupe - ignoring...", (const char*) name ); |
369 | #endif | 368 | #endif |
370 | subitem->receivedBeacon(); //FIXME: sent data bit | 369 | subitem->receivedBeacon(); //FIXME: sent data bit |
371 | return; | 370 | return; |
372 | } | 371 | } |
373 | 372 | ||
374 | // never seen that - add new item | 373 | // never seen that - add new item |
375 | 374 | ||
376 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); | 375 | MScanListItem* item = new MScanListItem( it.current(), "service", "N/A", " ", false, -1, -1 ); |
377 | item->setText( col_essid, name ); | 376 | item->setText( col_essid, name ); |
378 | 377 | ||
379 | return; | 378 | return; |
380 | } | 379 | } |
381 | } | 380 | } |
382 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); | 381 | qDebug( "D'oh! Received identification, but item not yet in list... ==> Handle this!" ); |
383 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", | 382 | MLogWindow::logwindow()->log( QString().sprintf( "WARNING: Unhandled service addition %s = %s!", |
384 | (const char*) macaddr.toString(), (const char*) ip ) ); | 383 | (const char*) macaddr.toString(), (const char*) ip ) ); |
385 | } | 384 | } |
386 | 385 | ||
387 | 386 | ||
388 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) | 387 | void MScanListView::contextMenuRequested( QListViewItem* item, const QPoint&, int col ) |
389 | { | 388 | { |
390 | if ( !item ) return; | 389 | if ( !item ) return; |
391 | 390 | ||
392 | MScanListItem* itm = static_cast<MScanListItem*>( item ); | 391 | MScanListItem* itm = static_cast<MScanListItem*>( item ); |
393 | 392 | ||
394 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", | 393 | qDebug( "contextMenuRequested on item '%s' (%s) in column: '%d'", |
395 | (const char*) itm->text(0), (const char*) itm->type, col ); | 394 | (const char*) itm->text(0), (const char*) itm->type, col ); |
396 | 395 | ||
397 | if ( itm->type == "adhoc" || itm->type == "managed" ) | 396 | if ( itm->type == "adhoc" || itm->type == "managed" ) |
398 | { | 397 | { |
399 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); | 398 | QString entry = QString().sprintf( "&Join %s Net '%s'...", (const char*) itm->type, (const char*) itm->essid() ); |
400 | 399 | ||
401 | QPopupMenu m( this ); | 400 | QPopupMenu m( this ); |
402 | m.insertItem( entry, 37773, 0 ); | 401 | m.insertItem( entry, 37773, 0 ); |
403 | int result = m.exec( QCursor::pos() ); | 402 | int result = m.exec( QCursor::pos() ); |
404 | if ( result == 37773 ) | 403 | if ( result == 37773 ) |
405 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); | 404 | emit joinNetwork( itm->type, itm->essid(), itm->channel(), itm->macaddr() ); |
406 | } | 405 | } |
407 | } | 406 | } |
408 | 407 | ||
409 | //============================================================ | 408 | //============================================================ |
410 | // MScanListItem | 409 | // MScanListItem |
411 | //============================================================ | 410 | //============================================================ |
412 | 411 | ||
413 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, | 412 | MScanListItem::MScanListItem( QListView* parent, const QString& type, const QString& essid, const QString& macaddr, |
414 | bool wep, int channel, int signal, bool probed ) | 413 | bool wep, int channel, int signal, bool probed ) |
415 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), | 414 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ), |
416 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), | 415 | _type( type ), _essid( essid ), _macaddr( macaddr ), _wep( wep ), |
417 | _channel( channel ), _signal( signal ), _beacons( 1 ) | 416 | _channel( channel ), _signal( signal ), _beacons( 1 ) |
418 | { | 417 | { |
419 | #ifdef DEBUG | 418 | #ifdef DEBUG |
420 | qDebug( "creating scanlist item" ); | 419 | qDebug( "creating scanlist item" ); |
421 | #endif | 420 | #endif |
422 | 421 | ||
423 | if ( WellenreiterConfigWindow::instance() ) | 422 | if ( WellenreiterConfigWindow::instance() ) |
424 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
425 | 424 | ||
426 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
427 | } | 426 | } |
428 | 427 | ||
429 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
430 | bool wep, int channel, int signal ) | 429 | bool wep, int channel, int signal ) |
431 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
432 | { | 431 | { |
433 | #ifdef DEBUG | 432 | #ifdef DEBUG |
434 | qDebug( "creating scanlist item" ); | 433 | qDebug( "creating scanlist item" ); |
435 | #endif | 434 | #endif |
436 | if ( WellenreiterConfigWindow::instance() ) | 435 | if ( WellenreiterConfigWindow::instance() ) |
437 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 436 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
438 | 437 | ||
439 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 438 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
440 | } | 439 | } |
441 | 440 | ||
442 | const QString& MScanListItem::essid() const | 441 | const QString& MScanListItem::essid() const |
443 | { | 442 | { |
444 | if ( type == "network" ) | 443 | if ( type == "network" ) |
445 | return _essid; | 444 | return _essid; |
446 | else | 445 | else |
447 | return ( (MScanListItem*) parent() )->essid(); | 446 | return ( (MScanListItem*) parent() )->essid(); |
448 | } | 447 | } |
449 | 448 | ||
450 | OListViewItem* MScanListItem::childFactory() | 449 | OListViewItem* MScanListItem::childFactory() |
451 | { | 450 | { |
452 | return new MScanListItem( this ); | 451 | return new MScanListItem( this ); |
453 | } | 452 | } |
454 | 453 | ||
455 | void MScanListItem::serializeTo( QDataStream& s ) const | 454 | void MScanListItem::serializeTo( QDataStream& s ) const |
456 | { | 455 | { |
457 | #ifdef DEBUG | 456 | #ifdef DEBUG |
458 | qDebug( "serializing MScanListItem" ); | 457 | qDebug( "serializing MScanListItem" ); |
459 | #endif | 458 | #endif |
460 | OListViewItem::serializeTo( s ); | 459 | OListViewItem::serializeTo( s ); |
461 | 460 | ||
462 | s << _type; | 461 | s << _type; |
463 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); | 462 | s << (Q_UINT8) ( _wep ? 'y' : 'n' ); |
464 | } | 463 | } |
465 | 464 | ||
466 | void MScanListItem::serializeFrom( QDataStream& s ) | 465 | void MScanListItem::serializeFrom( QDataStream& s ) |
467 | { | 466 | { |
468 | #ifdef DEBUG | 467 | #ifdef DEBUG |
469 | qDebug( "serializing MScanListItem" ); | 468 | qDebug( "serializing MScanListItem" ); |
470 | #endif | 469 | #endif |
471 | OListViewItem::serializeFrom( s ); | 470 | OListViewItem::serializeFrom( s ); |
472 | 471 | ||
473 | char wep; | 472 | char wep; |
474 | s >> _type; | 473 | s >> _type; |
475 | s >> (Q_UINT8) wep; | 474 | s >> (Q_UINT8) wep; |
476 | _wep = (wep == 'y'); | 475 | _wep = (wep == 'y'); |
477 | 476 | ||
478 | QString name; | 477 | QString name; |
479 | name.sprintf( "wellenreiter/%s", (const char*) _type ); | 478 | name.sprintf( "wellenreiter/%s", (const char*) _type ); |
480 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 479 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
481 | if ( _wep ) | 480 | if ( _wep ) |
482 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 481 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
483 | listView()->triggerUpdate(); | 482 | listView()->triggerUpdate(); |
484 | } | 483 | } |
485 | 484 | ||
486 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) | 485 | void MScanListItem::decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ) |
487 | { | 486 | { |
488 | #ifdef DEBUG | 487 | #ifdef DEBUG |
489 | qDebug( "decorating scanlist item %s / %s / %s [%d]", | 488 | qDebug( "decorating scanlist item %s / %s / %s [%d]", |
490 | (const char*) type, | 489 | (const char*) type, |
491 | (const char*) essid, | 490 | (const char*) essid, |
492 | (const char*) macaddr, | 491 | (const char*) macaddr, |
493 | channel ); | 492 | channel ); |
494 | #endif | 493 | #endif |
495 | 494 | ||
496 | // set icon for managed or adhoc mode | 495 | // set icon for managed or adhoc mode |
497 | QString name; | 496 | QString name; |
498 | name.sprintf( "wellenreiter/%s", (const char*) type ); | 497 | name.sprintf( "wellenreiter/%s", (const char*) type ); |
499 | setPixmap( col_type, Resource::loadPixmap( name ) ); | 498 | setPixmap( col_type, Resource::loadPixmap( name ) ); |
500 | 499 | ||
501 | // special case for probed networks FIXME: This is ugly at present | 500 | // special case for probed networks FIXME: This is ugly at present |
502 | if ( type == "network" && probed ) | 501 | if ( type == "network" && probed ) |
503 | { | 502 | { |
504 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); | 503 | setPixmap( col_type, Resource::loadPixmap( "wellenreiter/network-probed.png" ) ); |
505 | } | 504 | } |
506 | 505 | ||
507 | // set icon for wep (wireless encryption protocol) | 506 | // set icon for wep (wireless encryption protocol) |
508 | if ( wep ) | 507 | if ( wep ) |
509 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! | 508 | setPixmap( col_wep, Resource::loadPixmap( "wellenreiter/cracked" ) ); //FIXME: rename the pixmap! |
510 | 509 | ||
511 | // set channel and signal text | 510 | // set channel and signal text |
512 | 511 | ||
513 | if ( signal != -1 ) | 512 | if ( signal != -1 ) |
514 | setText( col_sig, QString::number( signal ) ); | 513 | setText( col_sig, QString::number( signal ) ); |
515 | if ( channel != -1 ) | 514 | if ( channel != -1 ) |
516 | setText( col_channel, QString::number( channel ) ); | 515 | setText( col_channel, QString::number( channel ) ); |
517 | 516 | ||
518 | setText( col_firstseen, QTime::currentTime().toString() ); | 517 | setText( col_firstseen, QTime::currentTime().toString() ); |
519 | //setText( col_lastseen, QTime::currentTime().toString() ); | 518 | //setText( col_lastseen, QTime::currentTime().toString() ); |
520 | 519 | ||
521 | listView()->triggerUpdate(); | 520 | listView()->triggerUpdate(); |
522 | 521 | ||
523 | this->type = type; | 522 | this->type = type; |
524 | _type = type; | 523 | _type = type; |
525 | _essid = essid; | 524 | _essid = essid; |
526 | _macaddr = macaddr; | 525 | _macaddr = macaddr; |
527 | _channel = channel; | 526 | _channel = channel; |
528 | _beacons = 1; | 527 | _beacons = 1; |
529 | _signal = 0; | 528 | _signal = 0; |
530 | 529 | ||
531 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) | 530 | if ( WellenreiterConfigWindow::instance()->openTree->isChecked() ) |
532 | { | 531 | { |
533 | listView()->ensureItemVisible( this ); | 532 | listView()->ensureItemVisible( this ); |
534 | } | 533 | } |
535 | 534 | ||
536 | } | 535 | } |
537 | 536 | ||
538 | 537 | ||
539 | void MScanListItem::setManufacturer( const QString& manufacturer ) | 538 | void MScanListItem::setManufacturer( const QString& manufacturer ) |
540 | { | 539 | { |
541 | setText( col_manuf, manufacturer ); | 540 | setText( col_manuf, manufacturer ); |
542 | } | 541 | } |
543 | 542 | ||
544 | 543 | ||
545 | void MScanListItem::setLocation( const QString& location ) | 544 | void MScanListItem::setLocation( const QString& location ) |
546 | { | 545 | { |
547 | setText( col_location, location ); | 546 | setText( col_location, location ); |
548 | } | 547 | } |
549 | 548 | ||
550 | 549 | ||
551 | void MScanListItem::receivedBeacon() | 550 | void MScanListItem::receivedBeacon() |
552 | { | 551 | { |
553 | _beacons++; | 552 | _beacons++; |
554 | #ifdef DEBUG | 553 | #ifdef DEBUG |
555 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); | 554 | qDebug( "MScanListItem %s: received beacon #%d", (const char*) _macaddr, _beacons ); |
556 | #endif | 555 | #endif |
557 | setText( col_sig, QString::number( _beacons ) ); | 556 | setText( col_sig, QString::number( _beacons ) ); |
558 | setText( col_lastseen, QTime::currentTime().toString() ); | 557 | setText( col_lastseen, QTime::currentTime().toString() ); |
559 | 558 | ||
560 | MScanListItem* p = (MScanListItem*) parent(); | 559 | MScanListItem* p = (MScanListItem*) parent(); |
561 | if ( p ) p->receivedBeacon(); | 560 | if ( p ) p->receivedBeacon(); |
562 | 561 | ||
563 | } | 562 | } |
564 | 563 | ||
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp index c2413dc..b8b6730 100644 --- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp +++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp | |||
@@ -1,186 +1,177 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Opie Environment. | 4 | ** This file is part of Opie Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ***********************************************************************/ | 14 | ***********************************************************************/ |
15 | 15 | ||
16 | #include "wellenreiterbase.h" | 16 | #include "wellenreiterbase.h" |
17 | 17 | ||
18 | #include <qheader.h> | ||
19 | #include <qlabel.h> | 18 | #include <qlabel.h> |
20 | #include <qlistview.h> | ||
21 | #include <qmultilineedit.h> | ||
22 | #include <qpushbutton.h> | ||
23 | #include <qlayout.h> | 19 | #include <qlayout.h> |
24 | #include <qvariant.h> | ||
25 | #include <qtooltip.h> | ||
26 | #include <qwhatsthis.h> | ||
27 | #include <qimage.h> | ||
28 | #include <qpixmap.h> | ||
29 | 20 | ||
30 | #include "logwindow.h" | 21 | #include "logwindow.h" |
31 | #include "hexwindow.h" | 22 | #include "hexwindow.h" |
32 | #include "scanlist.h" | 23 | #include "scanlist.h" |
33 | #include "statwindow.h" | 24 | #include "statwindow.h" |
34 | #include "graphwindow.h" | 25 | #include "graphwindow.h" |
35 | 26 | ||
36 | #ifdef QWS | 27 | #ifdef QWS |
37 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
38 | #include <opie2/otabwidget.h> | 29 | #include <opie2/otabwidget.h> |
39 | using namespace Opie; | 30 | using namespace Opie; |
40 | #else | 31 | #else |
41 | #include "resource.h" | 32 | #include "resource.h" |
42 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
43 | #endif | 34 | #endif |
44 | 35 | ||
45 | 36 | ||
46 | /* | 37 | /* |
47 | * Constructs a WellenreiterBase which is a child of 'parent', with the | 38 | * Constructs a WellenreiterBase which is a child of 'parent', with the |
48 | * name 'name' and widget flags set to 'f' | 39 | * name 'name' and widget flags set to 'f' |
49 | */ | 40 | */ |
50 | WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) | 41 | WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) |
51 | : QWidget( parent, name, fl ) | 42 | : QWidget( parent, name, fl ) |
52 | { | 43 | { |
53 | //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); | 44 | //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); |
54 | //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); | 45 | //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); |
55 | //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); | 46 | //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); |
56 | //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); | 47 | //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); |
57 | 48 | ||
58 | if ( !name ) | 49 | if ( !name ) |
59 | setName( "WellenreiterBase" ); | 50 | setName( "WellenreiterBase" ); |
60 | resize( 191, 294 ); | 51 | resize( 191, 294 ); |
61 | #ifdef QWS | 52 | #ifdef QWS |
62 | setCaption( tr( "Wellenreiter/Opie" ) ); | 53 | setCaption( tr( "Wellenreiter/Opie" ) ); |
63 | #else | 54 | #else |
64 | setCaption( tr( "Wellenreiter/X11" ) ); | 55 | setCaption( tr( "Wellenreiter/X11" ) ); |
65 | #endif | 56 | #endif |
66 | WellenreiterBaseLayout = new QVBoxLayout( this ); | 57 | WellenreiterBaseLayout = new QVBoxLayout( this ); |
67 | WellenreiterBaseLayout->setSpacing( 2 ); | 58 | WellenreiterBaseLayout->setSpacing( 2 ); |
68 | WellenreiterBaseLayout->setMargin( 0 ); | 59 | WellenreiterBaseLayout->setMargin( 0 ); |
69 | #ifdef QWS | 60 | #ifdef QWS |
70 | TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); | 61 | TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); |
71 | #else | 62 | #else |
72 | TabWidget = new QTabWidget( this, "TabWidget" ); | 63 | TabWidget = new QTabWidget( this, "TabWidget" ); |
73 | #endif | 64 | #endif |
74 | ap = new QWidget( TabWidget, "ap" ); | 65 | ap = new QWidget( TabWidget, "ap" ); |
75 | apLayout = new QVBoxLayout( ap ); | 66 | apLayout = new QVBoxLayout( ap ); |
76 | apLayout->setSpacing( 2 ); | 67 | apLayout->setSpacing( 2 ); |
77 | apLayout->setMargin( 2 ); | 68 | apLayout->setMargin( 2 ); |
78 | 69 | ||
79 | //--------- NETVIEW TAB -------------- | 70 | //--------- NETVIEW TAB -------------- |
80 | 71 | ||
81 | netview = new MScanListView( ap ); | 72 | netview = new MScanListView( ap ); |
82 | apLayout->addWidget( netview ); | 73 | apLayout->addWidget( netview ); |
83 | 74 | ||
84 | //--------- GRAPH TAB -------------- | 75 | //--------- GRAPH TAB -------------- |
85 | 76 | ||
86 | graphwindow = new MGraphWindow( TabWidget, "Graph" ); | 77 | graphwindow = new MGraphWindow( TabWidget, "Graph" ); |
87 | 78 | ||
88 | //--------- LOG TAB -------------- | 79 | //--------- LOG TAB -------------- |
89 | 80 | ||
90 | logwindow = new MLogWindow( TabWidget, "Log" ); | 81 | logwindow = new MLogWindow( TabWidget, "Log" ); |
91 | 82 | ||
92 | //--------- HEX TAB -------------- | 83 | //--------- HEX TAB -------------- |
93 | 84 | ||
94 | hexwindow = new MHexWindow( TabWidget, "Hex" ); | 85 | hexwindow = new MHexWindow( TabWidget, "Hex" ); |
95 | 86 | ||
96 | //--------- STAT TAB -------------- | 87 | //--------- STAT TAB -------------- |
97 | 88 | ||
98 | statwindow = new MStatWindow( TabWidget, "Stat" ); | 89 | statwindow = new MStatWindow( TabWidget, "Stat" ); |
99 | 90 | ||
100 | //--------- ABOUT TAB -------------- | 91 | //--------- ABOUT TAB -------------- |
101 | 92 | ||
102 | about = new QWidget( TabWidget, "about" ); | 93 | about = new QWidget( TabWidget, "about" ); |
103 | aboutLayout = new QGridLayout( about ); | 94 | aboutLayout = new QGridLayout( about ); |
104 | aboutLayout->setSpacing( 6 ); | 95 | aboutLayout->setSpacing( 6 ); |
105 | aboutLayout->setMargin( 11 ); | 96 | aboutLayout->setMargin( 11 ); |
106 | 97 | ||
107 | PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); | 98 | PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); |
108 | PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); | 99 | PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); |
109 | PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); | 100 | PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); |
110 | PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); | 101 | PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); |
111 | PixmapLabel1_3_2->setLineWidth( 2 ); | 102 | PixmapLabel1_3_2->setLineWidth( 2 ); |
112 | PixmapLabel1_3_2->setMargin( 0 ); | 103 | PixmapLabel1_3_2->setMargin( 0 ); |
113 | PixmapLabel1_3_2->setMidLineWidth( 0 ); | 104 | PixmapLabel1_3_2->setMidLineWidth( 0 ); |
114 | PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); | 105 | PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); |
115 | PixmapLabel1_3_2->setScaledContents( TRUE ); | 106 | PixmapLabel1_3_2->setScaledContents( TRUE ); |
116 | PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); | 107 | PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); |
117 | 108 | ||
118 | aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); | 109 | aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); |
119 | 110 | ||
120 | TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); | 111 | TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); |
121 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); | 112 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); |
122 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); | 113 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); |
123 | TextLabel1_4_2_font.setPointSize( 10 ); | 114 | TextLabel1_4_2_font.setPointSize( 10 ); |
124 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 115 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
125 | TextLabel1_4_2->setText( tr( "<p align=center>\n" | 116 | TextLabel1_4_2->setText( tr( "<p align=center>\n" |
126 | "<hr>\n" | 117 | "<hr>\n" |
127 | "Michael 'Mickey' Lauer<br><hr>\n" | 118 | "Michael 'Mickey' Lauer<br><hr>\n" |
128 | "Max Moser<br>\n" | 119 | "Max Moser<br>\n" |
129 | "Martin J. Muench<br>\n" | 120 | "Martin J. Muench<br>\n" |
130 | "<b>www.wellenreiter.net</b>\n" | 121 | "<b>www.wellenreiter.net</b>\n" |
131 | "</p>" ) ); | 122 | "</p>" ) ); |
132 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); | 123 | TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); |
133 | 124 | ||
134 | aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); | 125 | aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); |
135 | 126 | ||
136 | #ifdef QWS | 127 | #ifdef QWS |
137 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); | 128 | TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); |
138 | TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); | 129 | TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); |
139 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); | 130 | TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); |
140 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); | 131 | TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); |
141 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); | 132 | TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); |
142 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); | 133 | TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); |
143 | #else | 134 | #else |
144 | TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); | 135 | TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); |
145 | TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); | 136 | TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); |
146 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); | 137 | TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); |
147 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); | 138 | TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); |
148 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); | 139 | TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); |
149 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); | 140 | TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); |
150 | #endif | 141 | #endif |
151 | WellenreiterBaseLayout->addWidget( TabWidget ); | 142 | WellenreiterBaseLayout->addWidget( TabWidget ); |
152 | 143 | ||
153 | #ifdef QWS | 144 | #ifdef QWS |
154 | TabWidget->setCurrentTab( tr( "Nets" ) ); | 145 | TabWidget->setCurrentTab( tr( "Nets" ) ); |
155 | #endif | 146 | #endif |
156 | 147 | ||
157 | } | 148 | } |
158 | 149 | ||
159 | /* | 150 | /* |
160 | * Destroys the object and frees any allocated resources | 151 | * Destroys the object and frees any allocated resources |
161 | */ | 152 | */ |
162 | WellenreiterBase::~WellenreiterBase() | 153 | WellenreiterBase::~WellenreiterBase() |
163 | { | 154 | { |
164 | // no need to delete child widgets, Qt does it all for us | 155 | // no need to delete child widgets, Qt does it all for us |
165 | } | 156 | } |
166 | 157 | ||
167 | /* | 158 | /* |
168 | * Main event handler. Reimplemented to handle application | 159 | * Main event handler. Reimplemented to handle application |
169 | * font changes | 160 | * font changes |
170 | */ | 161 | */ |
171 | bool WellenreiterBase::event( QEvent* ev ) | 162 | bool WellenreiterBase::event( QEvent* ev ) |
172 | { | 163 | { |
173 | bool ret = QWidget::event( ev ); | 164 | bool ret = QWidget::event( ev ); |
174 | if ( ev->type() == QEvent::ApplicationFontChange ) { | 165 | if ( ev->type() == QEvent::ApplicationFontChange ) { |
175 | //QFont Log_2_font( Log_2->font() ); | 166 | //QFont Log_2_font( Log_2->font() ); |
176 | //Log_2_font.setFamily( "adobe-courier" ); | 167 | //Log_2_font.setFamily( "adobe-courier" ); |
177 | //Log_2_font.setPointSize( 8 ); | 168 | //Log_2_font.setPointSize( 8 ); |
178 | //Log_2->setFont( Log_2_font ); | 169 | //Log_2->setFont( Log_2_font ); |
179 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); | 170 | QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); |
180 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); | 171 | TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); |
181 | TextLabel1_4_2_font.setPointSize( 10 ); | 172 | TextLabel1_4_2_font.setPointSize( 10 ); |
182 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); | 173 | TextLabel1_4_2->setFont( TextLabel1_4_2_font ); |
183 | } | 174 | } |
184 | return ret; | 175 | return ret; |
185 | } | 176 | } |
186 | 177 | ||