summaryrefslogtreecommitdiff
authorar <ar>2004-02-21 15:27:41 (UTC)
committer ar <ar>2004-02-21 15:27:41 (UTC)
commit460258f203be746ff79e14f32a823f381b8ea513 (patch) (unidiff)
tree87dddbacda3050027d343730cf021b53045e80cb
parent76b70b355d2c1c32c0f74e844e0654e39db2a175 (diff)
downloadopie-460258f203be746ff79e14f32a823f381b8ea513.zip
opie-460258f203be746ff79e14f32a823f381b8ea513.tar.gz
opie-460258f203be746ff79e14f32a823f381b8ea513.tar.bz2
improve support for BigScreen
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/accountitem.cpp309
-rw-r--r--noncore/net/mail/accountview.cpp48
-rw-r--r--noncore/net/mail/addresspicker.cpp120
-rw-r--r--noncore/net/mail/editaccounts.cpp183
-rw-r--r--noncore/net/mail/opiemail.cpp113
-rw-r--r--noncore/net/mail/viewmail.cpp513
-rw-r--r--noncore/net/opieirc/ircservereditor.cpp10
-rw-r--r--noncore/net/opieirc/ircserverlist.cpp76
-rw-r--r--noncore/net/opieirc/ircsettings.cpp22
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.cc41
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp261
-rw-r--r--noncore/net/opietooth/manager/obexpopup.cpp22
-rw-r--r--noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp51
-rw-r--r--noncore/net/opietooth/manager/rfcpopup.cpp49
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp5
15 files changed, 1100 insertions, 723 deletions
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 2d3cd4b..c8f6ec4 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -1,842 +1,927 @@
1
1#include "accountitem.h" 2#include "accountitem.h"
2#include "accountview.h" 3#include "accountview.h"
3#include <qpopupmenu.h>
4#include <qmessagebox.h>
5#include "selectstore.h" 4#include "selectstore.h"
6#include "newmaildir.h" 5#include "newmaildir.h"
6#include "defines.h"
7
8/* OPIE */
7#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
8#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
9#include <libmailwrapper/mailwrapper.h> 11#include <libmailwrapper/mailwrapper.h>
10#include "defines.h" 12#include <qpe/qpeapplication.h>
13
14/* QT */
15#include <qpopupmenu.h>
16#include <qmessagebox.h>
11 17
12#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} 18#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
13/** 19/**
14 * POP3 Account stuff 20 * POP3 Account stuff
15 */ 21 */
16POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 22POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
17 : AccountViewItem( parent ) 23 : AccountViewItem( parent )
18{ 24{
19 account = a; 25 account = a;
20 wrapper = AbstractMail::getWrapper( account ); 26 wrapper = AbstractMail::getWrapper( account );
21 SETPIX(PIXMAP_POP3FOLDER); 27 SETPIX(PIXMAP_POP3FOLDER);
22#if 0 28#if 0
23 if (!account->getOffline()) { 29 if (!account->getOffline())
30 {
24 setPixmap( 0, ); 31 setPixmap( 0, );
25 } else { 32 }
33 else
34 {
26 setPixmap( 0, PIXMAP_OFFLINE ); 35 setPixmap( 0, PIXMAP_OFFLINE );
27 } 36 }
28#endif 37#endif
29 setText( 0, account->getAccountName() ); 38 setText( 0, account->getAccountName() );
30 setOpen( true ); 39 setOpen( true );
31} 40}
32 41
33POP3viewItem::~POP3viewItem() 42POP3viewItem::~POP3viewItem()
34{ 43{
35 delete wrapper; 44 delete wrapper;
36} 45}
37 46
38AbstractMail *POP3viewItem::getWrapper() 47AbstractMail *POP3viewItem::getWrapper()
39{ 48{
40 return wrapper; 49 return wrapper;
41} 50}
42 51
43void POP3viewItem::refresh( QList<RecMail> & ) 52void POP3viewItem::refresh( QList<RecMail> & )
44{ 53{
45 refresh(); 54 refresh();
46} 55}
47 56
48void POP3viewItem::refresh() 57void POP3viewItem::refresh()
49{ 58{
50 if (account->getOffline()) return; 59 if (account->getOffline()) return;
51 QList<Folder> *folders = wrapper->listFolders(); 60 QList<Folder> *folders = wrapper->listFolders();
52 QListViewItem *child = firstChild(); 61 QListViewItem *child = firstChild();
53 while ( child ) { 62 while ( child )
63 {
54 QListViewItem *tmp = child; 64 QListViewItem *tmp = child;
55 child = child->nextSibling(); 65 child = child->nextSibling();
56 delete tmp; 66 delete tmp;
57 } 67 }
58 Folder *it; 68 Folder *it;
59 QListViewItem*item = 0; 69 QListViewItem*item = 0;
60 for ( it = folders->first(); it; it = folders->next() ) { 70 for ( it = folders->first(); it; it = folders->next() )
71 {
61 item = new POP3folderItem( it, this , item ); 72 item = new POP3folderItem( it, this , item );
62 item->setSelectable(it->may_select()); 73 item->setSelectable(it->may_select());
63 } 74 }
64 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 75 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65 folders->setAutoDelete(false); 76 folders->setAutoDelete(false);
66 delete folders; 77 delete folders;
67} 78}
68 79
69RecBody POP3viewItem::fetchBody( const RecMail &mail ) 80RecBody POP3viewItem::fetchBody( const RecMail &mail )
70{ 81{
71 qDebug( "POP3 fetchBody" ); 82 qDebug( "POP3 fetchBody" );
72 return wrapper->fetchBody( mail ); 83 return wrapper->fetchBody( mail );
73} 84}
74 85
75QPopupMenu * POP3viewItem::getContextMenu() 86QPopupMenu * POP3viewItem::getContextMenu()
76{ 87{
77 QPopupMenu *m = new QPopupMenu(0); 88 QPopupMenu *m = new QPopupMenu(0);
78 if (m) { 89 if (m)
79 if (!account->getOffline()) { 90 {
91 if (!account->getOffline())
92 {
80 m->insertItem(QObject::tr("Disconnect",contextName),0); 93 m->insertItem(QObject::tr("Disconnect",contextName),0);
81 m->insertItem(QObject::tr("Set offline",contextName),1); 94 m->insertItem(QObject::tr("Set offline",contextName),1);
82 } else { 95 }
96 else
97 {
83 m->insertItem(QObject::tr("Set online",contextName),1); 98 m->insertItem(QObject::tr("Set online",contextName),1);
84 } 99 }
85 } 100 }
86 return m; 101 return m;
87} 102}
88 103
89void POP3viewItem::disconnect() 104void POP3viewItem::disconnect()
90{ 105{
91 QListViewItem *child = firstChild(); 106 QListViewItem *child = firstChild();
92 while ( child ) { 107 while ( child )
108 {
93 QListViewItem *tmp = child; 109 QListViewItem *tmp = child;
94 child = child->nextSibling(); 110 child = child->nextSibling();
95 delete tmp; 111 delete tmp;
96 } 112 }
97 wrapper->logout(); 113 wrapper->logout();
98} 114}
99 115
100void POP3viewItem::setOnOffline() 116void POP3viewItem::setOnOffline()
101{ 117{
102 if (!account->getOffline()) { 118 if (!account->getOffline())
119 {
103 disconnect(); 120 disconnect();
104 } 121 }
105 account->setOffline(!account->getOffline()); 122 account->setOffline(!account->getOffline());
106 account->save(); 123 account->save();
107 SETPIX(PIXMAP_POP3FOLDER); 124 SETPIX(PIXMAP_POP3FOLDER);
108 refresh(); 125 refresh();
109} 126}
110 127
111void POP3viewItem::contextMenuSelected(int which) 128void POP3viewItem::contextMenuSelected(int which)
112{ 129{
113 switch (which) { 130 switch (which)
131 {
114 case 0: 132 case 0:
115 disconnect(); 133 disconnect();
116 break; 134 break;
117 case 1: 135 case 1:
118 setOnOffline(); 136 setOnOffline();
119 break; 137 break;
120 } 138 }
121} 139}
122 140
123POP3folderItem::~POP3folderItem() 141POP3folderItem::~POP3folderItem()
124{ 142{}
125}
126 143
127POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after ) 144POP3folderItem::POP3folderItem( Folder *folderInit, POP3viewItem *parent , QListViewItem*after )
128 : AccountViewItem( parent,after ) 145 : AccountViewItem( parent,after )
129{ 146{
130 folder = folderInit; 147 folder = folderInit;
131 pop3 = parent; 148 pop3 = parent;
132 if (folder->getDisplayName().lower()!="inbox") { 149 if (folder->getDisplayName().lower()!="inbox")
150 {
133 setPixmap( 0, PIXMAP_POP3FOLDER ); 151 setPixmap( 0, PIXMAP_POP3FOLDER );
134 } else { 152 }
153 else
154 {
135 setPixmap( 0, PIXMAP_INBOXFOLDER); 155 setPixmap( 0, PIXMAP_INBOXFOLDER);
136 } 156 }
137 setText( 0, folder->getDisplayName() ); 157 setText( 0, folder->getDisplayName() );
138} 158}
139 159
140void POP3folderItem::refresh(QList<RecMail>&target) 160void POP3folderItem::refresh(QList<RecMail>&target)
141{ 161{
142 if (folder->may_select()) 162 if (folder->may_select())
143 pop3->getWrapper()->listMessages( folder->getName(),target ); 163 pop3->getWrapper()->listMessages( folder->getName(),target );
144} 164}
145 165
146RecBody POP3folderItem::fetchBody(const RecMail&aMail) 166RecBody POP3folderItem::fetchBody(const RecMail&aMail)
147{ 167{
148 return pop3->getWrapper()->fetchBody(aMail); 168 return pop3->getWrapper()->fetchBody(aMail);
149} 169}
150 170
151QPopupMenu * POP3folderItem::getContextMenu() 171QPopupMenu * POP3folderItem::getContextMenu()
152{ 172{
153 QPopupMenu *m = new QPopupMenu(0); 173 QPopupMenu *m = new QPopupMenu(0);
154 if (m) { 174 if (m)
175 {
155 m->insertItem(QObject::tr("Refresh header list",contextName),0); 176 m->insertItem(QObject::tr("Refresh header list",contextName),0);
156 m->insertItem(QObject::tr("Delete all mails",contextName),1); 177 m->insertItem(QObject::tr("Delete all mails",contextName),1);
157 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 178 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
158 } 179 }
159 return m; 180 return m;
160} 181}
161 182
162void POP3folderItem::downloadMails() 183void POP3folderItem::downloadMails()
163{ 184{
164 AccountView*bl = pop3->accountView(); 185 AccountView*bl = pop3->accountView();
165 if (!bl) return; 186 if (!bl) return;
166 bl->downloadMails(folder,pop3->getWrapper()); 187 bl->downloadMails(folder,pop3->getWrapper());
167} 188}
168 189
169void POP3folderItem::contextMenuSelected(int which) 190void POP3folderItem::contextMenuSelected(int which)
170{ 191{
171 AccountView * view = (AccountView*)listView(); 192 AccountView * view = (AccountView*)listView();
172 switch (which) { 193 switch (which)
194 {
173 case 0: 195 case 0:
174 /* must be 'cause pop3 lists are cached */ 196 /* must be 'cause pop3 lists are cached */
175 pop3->getWrapper()->logout(); 197 pop3->getWrapper()->logout();
176 view->refreshCurrent(); 198 view->refreshCurrent();
177 break; 199 break;
178 case 1: 200 case 1:
179 deleteAllMail(pop3->getWrapper(),folder); 201 deleteAllMail(pop3->getWrapper(),folder);
180 break; 202 break;
181 case 2: 203 case 2:
182 downloadMails(); 204 downloadMails();
183 break; 205 break;
184 default: 206 default:
185 break; 207 break;
186 } 208 }
187} 209}
188 210
189/** 211/**
190 * IMAP Account stuff 212 * IMAP Account stuff
191 */ 213 */
192IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent ) 214IMAPviewItem::IMAPviewItem( IMAPaccount *a, AccountView *parent )
193 : AccountViewItem( parent ) 215 : AccountViewItem( parent )
194{ 216{
195 account = a; 217 account = a;
196 wrapper = AbstractMail::getWrapper( account ); 218 wrapper = AbstractMail::getWrapper( account );
197 SETPIX(PIXMAP_IMAPFOLDER); 219 SETPIX(PIXMAP_IMAPFOLDER);
198 setText( 0, account->getAccountName() ); 220 setText( 0, account->getAccountName() );
199 setOpen( true ); 221 setOpen( true );
200} 222}
201 223
202IMAPviewItem::~IMAPviewItem() 224IMAPviewItem::~IMAPviewItem()
203{ 225{
204 delete wrapper; 226 delete wrapper;
205} 227}
206 228
207AbstractMail *IMAPviewItem::getWrapper() 229AbstractMail *IMAPviewItem::getWrapper()
208{ 230{
209 return wrapper; 231 return wrapper;
210} 232}
211 233
212void IMAPviewItem::refresh(QList<RecMail>&) 234void IMAPviewItem::refresh(QList<RecMail>&)
213{ 235{
214 refreshFolders(false); 236 refreshFolders(false);
215} 237}
216 238
217const QStringList&IMAPviewItem::subFolders() 239const QStringList&IMAPviewItem::subFolders()
218{ 240{
219 return currentFolders; 241 return currentFolders;
220} 242}
221 243
222void IMAPviewItem::refreshFolders(bool force) 244void IMAPviewItem::refreshFolders(bool force)
223{ 245{
224 if (childCount()>0 && force==false) return; 246 if (childCount()>0 && force==false) return;
225 if (account->getOffline()) return; 247 if (account->getOffline()) return;
226 248
227 removeChilds(); 249 removeChilds();
228 currentFolders.clear(); 250 currentFolders.clear();
229 QList<Folder> *folders = wrapper->listFolders(); 251 QList<Folder> *folders = wrapper->listFolders();
230 252
231 Folder *it; 253 Folder *it;
232 QListViewItem*item = 0; 254 QListViewItem*item = 0;
233 QListViewItem*titem = 0; 255 QListViewItem*titem = 0;
234 QString fname,del,search; 256 QString fname,del,search;
235 int pos; 257 int pos;
236 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 258 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
237 folders->setAutoDelete(false); 259 folders->setAutoDelete(false);
238 260
239 for ( it = folders->first(); it; it = folders->next() ) { 261 for ( it = folders->first(); it; it = folders->next() )
240 if (it->getDisplayName().lower()=="inbox") { 262 {
263 if (it->getDisplayName().lower()=="inbox")
264 {
241 item = new IMAPfolderItem( it, this , item ); 265 item = new IMAPfolderItem( it, this , item );
242 folders->remove(it); 266 folders->remove(it);
243 qDebug("inbox found"); 267 qDebug("inbox found");
244 break; 268 break;
245 } 269 }
246 } 270 }
247 for ( it = folders->first(); it; it = folders->next() ) { 271 for ( it = folders->first(); it; it = folders->next() )
272 {
248 fname = it->getDisplayName(); 273 fname = it->getDisplayName();
249 currentFolders.append(it->getName()); 274 currentFolders.append(it->getName());
250 pos = fname.findRev(it->Separator()); 275 pos = fname.findRev(it->Separator());
251 if (pos != -1) { 276 if (pos != -1)
277 {
252 fname = fname.left(pos); 278 fname = fname.left(pos);
253 } 279 }
254 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname); 280 IMAPfolderItem*pitem = (IMAPfolderItem*)findSubItem(fname);
255 if (pitem) { 281 if (pitem)
282 {
256 titem = item; 283 titem = item;
257 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this); 284 item = new IMAPfolderItem(it,pitem,pitem->firstChild(),this);
258 /* setup the short name */ 285 /* setup the short name */
259 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1)); 286 item->setText(0,it->getDisplayName().right(it->getDisplayName().length()-pos-1));
260 item = titem; 287 item = titem;
261 } else { 288 }
289 else
290 {
262 item = new IMAPfolderItem( it, this , item ); 291 item = new IMAPfolderItem( it, this , item );
263 } 292 }
264 } 293 }
265 delete folders; 294 delete folders;
266} 295}
267 296
268QPopupMenu * IMAPviewItem::getContextMenu() 297QPopupMenu * IMAPviewItem::getContextMenu()
269{ 298{
270 QPopupMenu *m = new QPopupMenu(0); 299 QPopupMenu *m = new QPopupMenu(0);
271 if (m) { 300 if (m)
272 if (!account->getOffline()) { 301 {
302 if (!account->getOffline())
303 {
273 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 304 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
274 m->insertItem(QObject::tr("Create new folder",contextName),1); 305 m->insertItem(QObject::tr("Create new folder",contextName),1);
275 m->insertSeparator(); 306 m->insertSeparator();
276 m->insertItem(QObject::tr("Disconnect",contextName),2); 307 m->insertItem(QObject::tr("Disconnect",contextName),2);
277 m->insertItem(QObject::tr("Set offline",contextName),3); 308 m->insertItem(QObject::tr("Set offline",contextName),3);
278 } else { 309 }
310 else
311 {
279 m->insertItem(QObject::tr("Set online",contextName),3); 312 m->insertItem(QObject::tr("Set online",contextName),3);
280 } 313 }
281 } 314 }
282 return m; 315 return m;
283} 316}
284 317
285void IMAPviewItem::createNewFolder() 318void IMAPviewItem::createNewFolder()
286{ 319{
287 Newmdirdlg ndirdlg; 320 Newmdirdlg ndirdlg;
288 ndirdlg.showMaximized(); 321 if ( QPEApplication::execDialog( &ndirdlg ))
289 if (ndirdlg.exec()) { 322 {
290 QString ndir = ndirdlg.Newdir(); 323 QString ndir = ndirdlg.Newdir();
291 bool makesubs = ndirdlg.subpossible(); 324 bool makesubs = ndirdlg.subpossible();
292 QString delemiter = "/"; 325 QString delemiter = "/";
293 IMAPfolderItem*item = (IMAPfolderItem*)firstChild(); 326 IMAPfolderItem*item = (IMAPfolderItem*)firstChild();
294 if (item) { 327 if (item)
328 {
295 delemiter = item->Delemiter(); 329 delemiter = item->Delemiter();
296 } 330 }
297 if (wrapper->createMbox(ndir,0,delemiter,makesubs)) { 331 if (wrapper->createMbox(ndir,0,delemiter,makesubs))
332 {
298 refreshFolders(true); 333 refreshFolders(true);
299 } 334 }
300 } 335 }
301} 336}
302 337
303void IMAPviewItem::contextMenuSelected(int id) 338void IMAPviewItem::contextMenuSelected(int id)
304{ 339{
305 qDebug("Id selected: %i",id); 340 qDebug("Id selected: %i",id);
306 switch (id) { 341 switch (id)
342 {
307 case 0: 343 case 0:
308 refreshFolders(true); 344 refreshFolders(true);
309 break; 345 break;
310 case 1: 346 case 1:
311 createNewFolder(); 347 createNewFolder();
312 break; 348 break;
313 case 2: 349 case 2:
314 removeChilds(); 350 removeChilds();
315 wrapper->logout(); 351 wrapper->logout();
316 break; 352 break;
317 case 3: 353 case 3:
318 if (account->getOffline()==false) { 354 if (account->getOffline()==false)
355 {
319 removeChilds(); 356 removeChilds();
320 wrapper->logout(); 357 wrapper->logout();
321 } 358 }
322 account->setOffline(!account->getOffline()); 359 account->setOffline(!account->getOffline());
323 account->save(); 360 account->save();
324 SETPIX(PIXMAP_IMAPFOLDER); 361 SETPIX(PIXMAP_IMAPFOLDER);
325 refreshFolders(false); 362 refreshFolders(false);
326 break; 363 break;
327 default: 364 default:
328 break; 365 break;
329 } 366 }
330} 367}
331 368
332RecBody IMAPviewItem::fetchBody(const RecMail&) 369RecBody IMAPviewItem::fetchBody(const RecMail&)
333{ 370{
334 return RecBody(); 371 return RecBody();
335} 372}
336 373
337bool IMAPviewItem::offline() 374bool IMAPviewItem::offline()
338{ 375{
339 return account->getOffline(); 376 return account->getOffline();
340} 377}
341 378
342IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after ) 379IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPviewItem *parent , QListViewItem*after )
343 : AccountViewItem( parent , after ) 380 : AccountViewItem( parent , after )
344{ 381{
345 folder = folderInit; 382 folder = folderInit;
346 imap = parent; 383 imap = parent;
347 if (folder->getDisplayName().lower()!="inbox") { 384 if (folder->getDisplayName().lower()!="inbox")
385 {
348 setPixmap( 0, PIXMAP_IMAPFOLDER ); 386 setPixmap( 0, PIXMAP_IMAPFOLDER );
349 } else { 387 }
388 else
389 {
350 setPixmap( 0, PIXMAP_INBOXFOLDER); 390 setPixmap( 0, PIXMAP_INBOXFOLDER);
351 } 391 }
352 setText( 0, folder->getDisplayName() ); 392 setText( 0, folder->getDisplayName() );
353} 393}
354 394
355IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ) 395IMAPfolderItem::IMAPfolderItem( Folder *folderInit, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master )
356 : AccountViewItem( parent,after ) 396 : AccountViewItem( parent,after )
357{ 397{
358 folder = folderInit; 398 folder = folderInit;
359 imap = master; 399 imap = master;
360 if (folder->getDisplayName().lower()!="inbox") { 400 if (folder->getDisplayName().lower()!="inbox")
401 {
361 setPixmap( 0, PIXMAP_IMAPFOLDER ); 402 setPixmap( 0, PIXMAP_IMAPFOLDER );
362 } else { 403 }
404 else
405 {
363 setPixmap( 0, PIXMAP_INBOXFOLDER); 406 setPixmap( 0, PIXMAP_INBOXFOLDER);
364 } 407 }
365 setText( 0, folder->getDisplayName() ); 408 setText( 0, folder->getDisplayName() );
366} 409}
367 410
368IMAPfolderItem::~IMAPfolderItem() 411IMAPfolderItem::~IMAPfolderItem()
369{ 412{}
370}
371 413
372const QString& IMAPfolderItem::Delemiter()const 414const QString& IMAPfolderItem::Delemiter()const
373{ 415{
374 return folder->Separator(); 416 return folder->Separator();
375} 417}
376 418
377void IMAPfolderItem::refresh(QList<RecMail>&target) 419void IMAPfolderItem::refresh(QList<RecMail>&target)
378{ 420{
379 if (folder->may_select()) { 421 if (folder->may_select())
422 {
380 imap->getWrapper()->listMessages( folder->getName(),target ); 423 imap->getWrapper()->listMessages( folder->getName(),target );
381 } else { 424 }
425 else
426 {
382 target.clear(); 427 target.clear();
383 } 428 }
384} 429}
385 430
386RecBody IMAPfolderItem::fetchBody(const RecMail&aMail) 431RecBody IMAPfolderItem::fetchBody(const RecMail&aMail)
387{ 432{
388 return imap->getWrapper()->fetchBody(aMail); 433 return imap->getWrapper()->fetchBody(aMail);
389} 434}
390 435
391QPopupMenu * IMAPfolderItem::getContextMenu() 436QPopupMenu * IMAPfolderItem::getContextMenu()
392{ 437{
393 QPopupMenu *m = new QPopupMenu(0); 438 QPopupMenu *m = new QPopupMenu(0);
394 if (m) { 439 if (m)
395 if (folder->may_select()) { 440 {
441 if (folder->may_select())
442 {
396 m->insertItem(QObject::tr("Refresh header list",contextName),0); 443 m->insertItem(QObject::tr("Refresh header list",contextName),0);
397 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4); 444 m->insertItem(QObject::tr("Move/Copie all mails",contextName),4);
398 m->insertItem(QObject::tr("Delete all mails",contextName),1); 445 m->insertItem(QObject::tr("Delete all mails",contextName),1);
399 } 446 }
400 if (folder->no_inferior()==false) { 447 if (folder->no_inferior()==false)
448 {
401 m->insertItem(QObject::tr("Create new subfolder",contextName),2); 449 m->insertItem(QObject::tr("Create new subfolder",contextName),2);
402 } 450 }
403 if (folder->getDisplayName().lower()!="inbox") { 451 if (folder->getDisplayName().lower()!="inbox")
452 {
404 m->insertItem(QObject::tr("Delete folder",contextName),3); 453 m->insertItem(QObject::tr("Delete folder",contextName),3);
405 } 454 }
406 } 455 }
407 return m; 456 return m;
408} 457}
409 458
410void IMAPfolderItem::createNewFolder() 459void IMAPfolderItem::createNewFolder()
411{ 460{
412 Newmdirdlg ndirdlg; 461 Newmdirdlg ndirdlg;
413 ndirdlg.showMaximized(); 462 if ( QPEApplication::execDialog( &ndirdlg ) )
414 if (ndirdlg.exec()) { 463 {
415 QString ndir = ndirdlg.Newdir(); 464 QString ndir = ndirdlg.Newdir();
416 bool makesubs = ndirdlg.subpossible(); 465 bool makesubs = ndirdlg.subpossible();
417 QString delemiter = Delemiter(); 466 QString delemiter = Delemiter();
418 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs)) { 467 if (imap->wrapper->createMbox(ndir,folder,delemiter,makesubs))
468 {
419 imap->refreshFolders(true); 469 imap->refreshFolders(true);
420 } 470 }
421 } 471 }
422} 472}
423 473
424void IMAPfolderItem::deleteFolder() 474void IMAPfolderItem::deleteFolder()
425{ 475{
426 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 476 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
427 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 477 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
428 QObject::tr("Yes",contextName), 478 QObject::tr("Yes",contextName),
429 QObject::tr("No",contextName),QString::null,1,1); 479 QObject::tr("No",contextName),QString::null,1,1);
430 qDebug("Auswahl: %i",yesno); 480 qDebug("Auswahl: %i",yesno);
431 if (yesno == 0) { 481 if (yesno == 0)
432 if (imap->getWrapper()->deleteMbox(folder)) { 482 {
483 if (imap->getWrapper()->deleteMbox(folder))
484 {
433 QListView*v=listView(); 485 QListView*v=listView();
434 IMAPviewItem * box = imap; 486 IMAPviewItem * box = imap;
435 /* be carefull - after that this object is destroyd so don't use 487 /* be carefull - after that this object is destroyd so don't use
436 * any member of it after that call!!*/ 488 * any member of it after that call!!*/
437 imap->refreshFolders(true); 489 imap->refreshFolders(true);
438 if (v) { 490 if (v)
491 {
439 v->setSelected(box,true); 492 v->setSelected(box,true);
440 } 493 }
441 } 494 }
442 } 495 }
443} 496}
444 497
445void IMAPfolderItem::downloadMails() 498void IMAPfolderItem::downloadMails()
446{ 499{
447 AccountView*bl = imap->accountView(); 500 AccountView*bl = imap->accountView();
448 if (!bl) return; 501 if (!bl) return;
449 bl->downloadMails(folder,imap->getWrapper()); 502 bl->downloadMails(folder,imap->getWrapper());
450} 503}
451 504
452void IMAPfolderItem::contextMenuSelected(int id) 505void IMAPfolderItem::contextMenuSelected(int id)
453{ 506{
454 qDebug("Selected id: %i",id); 507 qDebug("Selected id: %i",id);
455 AccountView * view = (AccountView*)listView(); 508 AccountView * view = (AccountView*)listView();
456 switch(id) { 509 switch(id)
510 {
457 case 0: 511 case 0:
458 view->refreshCurrent(); 512 view->refreshCurrent();
459 break; 513 break;
460 case 1: 514 case 1:
461 deleteAllMail(imap->getWrapper(),folder); 515 deleteAllMail(imap->getWrapper(),folder);
462 break; 516 break;
463 case 2: 517 case 2:
464 createNewFolder(); 518 createNewFolder();
465 break; 519 break;
466 case 3: 520 case 3:
467 deleteFolder(); 521 deleteFolder();
468 break; 522 break;
469 case 4: 523 case 4:
470 downloadMails(); 524 downloadMails();
471 break; 525 break;
472 default: 526 default:
473 break; 527 break;
474 } 528 }
475} 529}
476 530
477/** 531/**
478 * MH Account stuff 532 * MH Account stuff
479 */ 533 */
480/* MH is a little bit different - the top folder can contains messages other than in IMAP and 534/* MH is a little bit different - the top folder can contains messages other than in IMAP and
481 POP3 and MBOX */ 535 POP3 and MBOX */
482MHviewItem::MHviewItem( const QString&aPath, AccountView *parent ) 536MHviewItem::MHviewItem( const QString&aPath, AccountView *parent )
483 : AccountViewItem( parent ) 537 : AccountViewItem( parent )
484{ 538{
485 m_Path = aPath; 539 m_Path = aPath;
486 /* be carefull - the space within settext is wanted - thats why the string twice */ 540 /* be carefull - the space within settext is wanted - thats why the string twice */
487 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders"); 541 wrapper = AbstractMail::getWrapper( m_Path,"Local Folders");
488 setPixmap( 0, PIXMAP_LOCALFOLDER ); 542 setPixmap( 0, PIXMAP_LOCALFOLDER );
489 setText( 0, " Local Folders" ); 543 setText( 0, " Local Folders" );
490 setOpen( true ); 544 setOpen( true );
491 folder = 0; 545 folder = 0;
492} 546}
493 547
494MHviewItem::~MHviewItem() 548MHviewItem::~MHviewItem()
495{ 549{
496 delete wrapper; 550 delete wrapper;
497} 551}
498 552
499AbstractMail *MHviewItem::getWrapper() 553AbstractMail *MHviewItem::getWrapper()
500{ 554{
501 return wrapper; 555 return wrapper;
502} 556}
503 557
504void MHviewItem::refresh( QList<RecMail> & target) 558void MHviewItem::refresh( QList<RecMail> & target)
505{ 559{
506 refresh(false); 560 refresh(false);
507 getWrapper()->listMessages( "",target ); 561 getWrapper()->listMessages( "",target );
508} 562}
509 563
510void MHviewItem::refresh(bool force) 564void MHviewItem::refresh(bool force)
511{ 565{
512 if (childCount()>0 && force==false) return; 566 if (childCount()>0 && force==false) return;
513 removeChilds(); 567 removeChilds();
514 currentFolders.clear(); 568 currentFolders.clear();
515 QList<Folder> *folders = wrapper->listFolders(); 569 QList<Folder> *folders = wrapper->listFolders();
516 Folder *it; 570 Folder *it;
517 MHfolderItem*item = 0; 571 MHfolderItem*item = 0;
518 MHfolderItem*pmaster = 0; 572 MHfolderItem*pmaster = 0;
519 QString fname = ""; 573 QString fname = "";
520 int pos; 574 int pos;
521 for ( it = folders->first(); it; it = folders->next() ) { 575 for ( it = folders->first(); it; it = folders->next() )
576 {
522 fname = it->getDisplayName(); 577 fname = it->getDisplayName();
523 /* this folder itself */ 578 /* this folder itself */
524 if (fname=="/") { 579 if (fname=="/")
580 {
525 currentFolders.append(fname); 581 currentFolders.append(fname);
526 folder = it; 582 folder = it;
527 continue; 583 continue;
528 } 584 }
529 currentFolders.append(fname); 585 currentFolders.append(fname);
530 pos = fname.findRev("/"); 586 pos = fname.findRev("/");
531 if (pos > 0) { 587 if (pos > 0)
588 {
532 fname = fname.left(pos); 589 fname = fname.left(pos);
533 pmaster = (MHfolderItem*)findSubItem(fname); 590 pmaster = (MHfolderItem*)findSubItem(fname);
534 } else { 591 }
592 else
593 {
535 pmaster = 0; 594 pmaster = 0;
536 } 595 }
537 if (pmaster) { 596 if (pmaster)
597 {
538 item = new MHfolderItem( it, pmaster, item, this ); 598 item = new MHfolderItem( it, pmaster, item, this );
539 } else { 599 }
600 else
601 {
540 item = new MHfolderItem( it, this , item ); 602 item = new MHfolderItem( it, this , item );
541 } 603 }
542 item->setSelectable(it->may_select()); 604 item->setSelectable(it->may_select());
543 } 605 }
544 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 606 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
545 folders->setAutoDelete(false); 607 folders->setAutoDelete(false);
546 delete folders; 608 delete folders;
547} 609}
548 610
549RecBody MHviewItem::fetchBody( const RecMail &mail ) 611RecBody MHviewItem::fetchBody( const RecMail &mail )
550{ 612{
551 qDebug( "MH fetchBody" ); 613 qDebug( "MH fetchBody" );
552 return wrapper->fetchBody( mail ); 614 return wrapper->fetchBody( mail );
553} 615}
554 616
555QPopupMenu * MHviewItem::getContextMenu() 617QPopupMenu * MHviewItem::getContextMenu()
556{ 618{
557 QPopupMenu *m = new QPopupMenu(0); 619 QPopupMenu *m = new QPopupMenu(0);
558 if (m) { 620 if (m)
621 {
559 m->insertItem(QObject::tr("Refresh folder list",contextName),0); 622 m->insertItem(QObject::tr("Refresh folder list",contextName),0);
560 m->insertItem(QObject::tr("Create new folder",contextName),1); 623 m->insertItem(QObject::tr("Create new folder",contextName),1);
561 m->insertItem(QObject::tr("Delete all mails",contextName),2); 624 m->insertItem(QObject::tr("Delete all mails",contextName),2);
562 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3); 625 m->insertItem(QObject::tr("Move/Copie all mails",contextName),3);
563 } 626 }
564 return m; 627 return m;
565} 628}
566 629
567void MHviewItem::createFolder() 630void MHviewItem::createFolder()
568{ 631{
569 Newmdirdlg ndirdlg(0,0,true); 632 Newmdirdlg ndirdlg(0,0,true);
570 ndirdlg.showMaximized(); 633 if ( QPEApplication::execDialog( &ndirdlg ) )
571 if (ndirdlg.exec()) { 634 {
572 QString ndir = ndirdlg.Newdir(); 635 QString ndir = ndirdlg.Newdir();
573 if (wrapper->createMbox(ndir)) { 636 if (wrapper->createMbox(ndir))
637 {
574 refresh(true); 638 refresh(true);
575 } 639 }
576 } 640 }
577} 641}
578 642
579void MHviewItem::downloadMails() 643void MHviewItem::downloadMails()
580{ 644{
581 AccountView*bl = accountView(); 645 AccountView*bl = accountView();
582 if (!bl) return; 646 if (!bl) return;
583 bl->downloadMails(folder,getWrapper()); 647 bl->downloadMails(folder,getWrapper());
584} 648}
585 649
586QStringList MHviewItem::subFolders() 650QStringList MHviewItem::subFolders()
587{ 651{
588 return currentFolders; 652 return currentFolders;
589} 653}
590 654
591void MHviewItem::contextMenuSelected(int which) 655void MHviewItem::contextMenuSelected(int which)
592{ 656{
593 switch (which) { 657 switch (which)
658 {
594 case 0: 659 case 0:
595 refresh(true); 660 refresh(true);
596 break; 661 break;
597 case 1: 662 case 1:
598 createFolder(); 663 createFolder();
599 break; 664 break;
600 case 2: 665 case 2:
601 deleteAllMail(getWrapper(),folder); 666 deleteAllMail(getWrapper(),folder);
602 break; 667 break;
603 case 3: 668 case 3:
604 downloadMails(); 669 downloadMails();
605 break; 670 break;
606 default: 671 default:
607 break; 672 break;
608 } 673 }
609} 674}
610 675
611MHfolderItem::~MHfolderItem() 676MHfolderItem::~MHfolderItem()
612{ 677{}
613}
614 678
615MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after ) 679MHfolderItem::MHfolderItem( Folder *folderInit, MHviewItem *parent , QListViewItem*after )
616 : AccountViewItem( parent,after ) 680 : AccountViewItem( parent,after )
617{ 681{
618 folder = folderInit; 682 folder = folderInit;
619 mbox = parent; 683 mbox = parent;
620 initName(); 684 initName();
621} 685}
622 686
623MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 687MHfolderItem::MHfolderItem( Folder *folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
624 : AccountViewItem( parent,after ) 688 : AccountViewItem( parent,after )
625{ 689{
626 folder = folderInit; 690 folder = folderInit;
627 mbox = master; 691 mbox = master;
628 initName(); 692 initName();
629} 693}
630 694
631void MHfolderItem::initName() 695void MHfolderItem::initName()
632{ 696{
633 QString bName = folder->getDisplayName(); 697 QString bName = folder->getDisplayName();
634 if (bName.startsWith("/")&&bName.length()>1) { 698 if (bName.startsWith("/")&&bName.length()>1)
699 {
635 bName.replace(0,1,""); 700 bName.replace(0,1,"");
636 } 701 }
637 int pos = bName.findRev("/"); 702 int pos = bName.findRev("/");
638 if (pos > 0) { 703 if (pos > 0)
704 {
639 bName.replace(0,pos+1,""); 705 bName.replace(0,pos+1,"");
640 } 706 }
641 if (bName.lower() == "outgoing") { 707 if (bName.lower() == "outgoing")
708 {
642 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 709 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
643 } else if (bName.lower() == "inbox") { 710 }
711 else if (bName.lower() == "inbox")
712 {
644 setPixmap( 0, PIXMAP_INBOXFOLDER); 713 setPixmap( 0, PIXMAP_INBOXFOLDER);
645 } else { 714 }
715 else
716 {
646 setPixmap( 0, PIXMAP_MBOXFOLDER ); 717 setPixmap( 0, PIXMAP_MBOXFOLDER );
647 } 718 }
648 setText( 0, bName ); 719 setText( 0, bName );
649} 720}
650 721
651Folder*MHfolderItem::getFolder() 722Folder*MHfolderItem::getFolder()
652{ 723{
653 return folder; 724 return folder;
654} 725}
655 726
656void MHfolderItem::refresh(QList<RecMail>&target) 727void MHfolderItem::refresh(QList<RecMail>&target)
657{ 728{
658 if (folder->may_select()) 729 if (folder->may_select())
659 mbox->getWrapper()->listMessages( folder->getName(),target ); 730 mbox->getWrapper()->listMessages( folder->getName(),target );
660} 731}
661 732
662RecBody MHfolderItem::fetchBody(const RecMail&aMail) 733RecBody MHfolderItem::fetchBody(const RecMail&aMail)
663{ 734{
664 return mbox->getWrapper()->fetchBody(aMail); 735 return mbox->getWrapper()->fetchBody(aMail);
665} 736}
666 737
667void MHfolderItem::deleteFolder() 738void MHfolderItem::deleteFolder()
668{ 739{
669 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 740 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
670 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 741 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
671 QObject::tr("Yes",contextName), 742 QObject::tr("Yes",contextName),
672 QObject::tr("No",contextName),QString::null,1,1); 743 QObject::tr("No",contextName),QString::null,1,1);
673 qDebug("Auswahl: %i",yesno); 744 qDebug("Auswahl: %i",yesno);
674 if (yesno == 0) { 745 if (yesno == 0)
675 if (mbox->getWrapper()->deleteMbox(folder)) { 746 {
747 if (mbox->getWrapper()->deleteMbox(folder))
748 {
676 QListView*v=listView(); 749 QListView*v=listView();
677 MHviewItem * box = mbox; 750 MHviewItem * box = mbox;
678 /* be carefull - after that this object is destroyd so don't use 751 /* be carefull - after that this object is destroyd so don't use
679 * any member of it after that call!!*/ 752 * any member of it after that call!!*/
680 mbox->refresh(true); 753 mbox->refresh(true);
681 if (v) { 754 if (v)
755 {
682 v->setSelected(box,true); 756 v->setSelected(box,true);
683 } 757 }
684 } 758 }
685 } 759 }
686} 760}
687 761
688QPopupMenu * MHfolderItem::getContextMenu() 762QPopupMenu * MHfolderItem::getContextMenu()
689{ 763{
690 QPopupMenu *m = new QPopupMenu(0); 764 QPopupMenu *m = new QPopupMenu(0);
691 if (m) { 765 if (m)
766 {
692 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 767 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
693 m->insertItem(QObject::tr("Delete all mails",contextName),0); 768 m->insertItem(QObject::tr("Delete all mails",contextName),0);
694 m->insertItem(QObject::tr("Create new subfolder",contextName),3); 769 m->insertItem(QObject::tr("Create new subfolder",contextName),3);
695 m->insertItem(QObject::tr("Delete folder",contextName),1); 770 m->insertItem(QObject::tr("Delete folder",contextName),1);
696 } 771 }
697 return m; 772 return m;
698} 773}
699 774
700void MHfolderItem::downloadMails() 775void MHfolderItem::downloadMails()
701{ 776{
702 AccountView*bl = mbox->accountView(); 777 AccountView*bl = mbox->accountView();
703 if (!bl) return; 778 if (!bl) return;
704 bl->downloadMails(folder,mbox->getWrapper()); 779 bl->downloadMails(folder,mbox->getWrapper());
705} 780}
706 781
707void MHfolderItem::createFolder() 782void MHfolderItem::createFolder()
708{ 783{
709 Newmdirdlg ndirdlg(0,0,true); 784 Newmdirdlg ndirdlg(0,0,true);
710 ndirdlg.showMaximized(); 785 if ( QPEApplication::execDialog( &ndirdlg ) )
711 if (ndirdlg.exec()) { 786 {
712 QString ndir = ndirdlg.Newdir(); 787 QString ndir = ndirdlg.Newdir();
713 if (mbox->getWrapper()->createMbox(ndir,folder)) { 788 if (mbox->getWrapper()->createMbox(ndir,folder))
789 {
714 QListView*v=listView(); 790 QListView*v=listView();
715 MHviewItem * box = mbox; 791 MHviewItem * box = mbox;
716 /* be carefull - after that this object is destroyd so don't use 792 /* be carefull - after that this object is destroyd so don't use
717 * any member of it after that call!!*/ 793 * any member of it after that call!!*/
718 mbox->refresh(true); 794 mbox->refresh(true);
719 if (v) { 795 if (v)
796 {
720 v->setSelected(box,true); 797 v->setSelected(box,true);
721 } 798 }
722 } 799 }
723 } 800 }
724} 801}
725 802
726void MHfolderItem::contextMenuSelected(int which) 803void MHfolderItem::contextMenuSelected(int which)
727{ 804{
728 switch(which) { 805 switch(which)
806 {
729 case 0: 807 case 0:
730 deleteAllMail(mbox->getWrapper(),folder); 808 deleteAllMail(mbox->getWrapper(),folder);
731 break; 809 break;
732 case 1: 810 case 1:
733 deleteFolder(); 811 deleteFolder();
734 break; 812 break;
735 case 2: 813 case 2:
736 downloadMails(); 814 downloadMails();
737 break; 815 break;
738 case 3: 816 case 3:
739 createFolder(); 817 createFolder();
740 break; 818 break;
741 default: 819 default:
742 break; 820 break;
743 } 821 }
744} 822}
745 823
746/** 824/**
747 * Generic stuff 825 * Generic stuff
748 */ 826 */
749 827
750const QString AccountViewItem::contextName="AccountViewItem"; 828const QString AccountViewItem::contextName="AccountViewItem";
751 829
752AccountViewItem::AccountViewItem( AccountView *parent ) 830AccountViewItem::AccountViewItem( AccountView *parent )
753 : QListViewItem( parent ) 831 : QListViewItem( parent )
754{ 832{
755 init(); 833 init();
756 m_Backlink = parent; 834 m_Backlink = parent;
757} 835}
758 836
759AccountViewItem::AccountViewItem( QListViewItem *parent) 837AccountViewItem::AccountViewItem( QListViewItem *parent)
760 : QListViewItem( parent) 838 : QListViewItem( parent)
761{ 839{
762 init(); 840 init();
763} 841}
764 842
765AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 843AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
766 :QListViewItem( parent,after ) 844 :QListViewItem( parent,after )
767{ 845{
768 init(); 846 init();
769} 847}
770 848
771void AccountViewItem::init() 849void AccountViewItem::init()
772{ 850{
773 m_Backlink = 0; 851 m_Backlink = 0;
774 folder = 0; 852 folder = 0;
775} 853}
776 854
777AccountViewItem::~AccountViewItem() 855AccountViewItem::~AccountViewItem()
778{ 856{
779 if (folder) delete folder; 857 if (folder) delete folder;
780} 858}
781 859
782AccountView*AccountViewItem::accountView() 860AccountView*AccountViewItem::accountView()
783{ 861{
784 return m_Backlink; 862 return m_Backlink;
785} 863}
786 864
787void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder) 865void AccountViewItem::deleteAllMail(AbstractMail*wrapper,Folder*folder)
788{ 866{
789 if (!wrapper) return; 867 if (!wrapper) return;
790 QString fname=""; 868 QString fname="";
791 if (folder) fname = folder->getDisplayName(); 869 if (folder) fname = folder->getDisplayName();
792 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 870 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
793 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 871 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
794 arg(fname), 872 arg(fname),
795 QObject::tr("Yes",contextName), 873 QObject::tr("Yes",contextName),
796 QObject::tr("No",contextName),QString::null,1,1); 874 QObject::tr("No",contextName),QString::null,1,1);
797 qDebug("Auswahl: %i",yesno); 875 qDebug("Auswahl: %i",yesno);
798 if (yesno == 0) { 876 if (yesno == 0)
799 if (wrapper->deleteAllMail(folder)) { 877 {
878 if (wrapper->deleteAllMail(folder))
879 {
800 AccountView * view = (AccountView*)listView(); 880 AccountView * view = (AccountView*)listView();
801 if (view) view->refreshCurrent(); 881 if (view) view->refreshCurrent();
802 } 882 }
803 } 883 }
804} 884}
805 885
806void AccountViewItem::removeChilds() 886void AccountViewItem::removeChilds()
807{ 887{
808 QListViewItem *child = firstChild(); 888 QListViewItem *child = firstChild();
809 while ( child ) { 889 while ( child )
890 {
810 QListViewItem *tmp = child; 891 QListViewItem *tmp = child;
811 child = child->nextSibling(); 892 child = child->nextSibling();
812 delete tmp; 893 delete tmp;
813 } 894 }
814} 895}
815 896
816bool AccountViewItem::matchName(const QString&name)const 897bool AccountViewItem::matchName(const QString&name)const
817{ 898{
818 if (!folder) return false; 899 if (!folder) return false;
819 return folder->getDisplayName()==name; 900 return folder->getDisplayName()==name;
820} 901}
821 902
822 903
823AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) 904AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
824{ 905{
825 AccountViewItem*pitem,*sitem; 906 AccountViewItem*pitem,*sitem;
826 if (!start) pitem = (AccountViewItem*)firstChild(); 907 if (!start) pitem = (AccountViewItem*)firstChild();
827 else pitem = (AccountViewItem*)start->firstChild(); 908 else pitem = (AccountViewItem*)start->firstChild();
828 while (pitem) { 909 while (pitem)
829 if (pitem->matchName(path)) { 910 {
911 if (pitem->matchName(path))
912 {
830 break; 913 break;
831 } 914 }
832 if (pitem->childCount()>0) { 915 if (pitem->childCount()>0)
916 {
833 sitem = findSubItem(path,pitem); 917 sitem = findSubItem(path,pitem);
834 if (sitem) { 918 if (sitem)
919 {
835 pitem = sitem; 920 pitem = sitem;
836 break; 921 break;
837 } 922 }
838 } 923 }
839 pitem=(AccountViewItem*)pitem->nextSibling(); 924 pitem=(AccountViewItem*)pitem->nextSibling();
840 } 925 }
841 return pitem; 926 return pitem;
842} 927}
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index d9792d4..2ddf834 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,149 +1,163 @@
1
1#include "accountview.h" 2#include "accountview.h"
2#include "accountitem.h" 3#include "accountitem.h"
3#include "selectstore.h" 4#include "selectstore.h"
4#include <qmessagebox.h> 5
5#include <qpopupmenu.h> 6/* OPIE */
6#include <libmailwrapper/settings.h> 7#include <libmailwrapper/settings.h>
7#include <libmailwrapper/mailwrapper.h> 8#include <libmailwrapper/mailwrapper.h>
8#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
9#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
11#include <qpe/qpeapplication.h>
10 12
13/* QT */
14#include <qmessagebox.h>
15#include <qpopupmenu.h>
11 16
12AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 17AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
13 : QListView( parent, name, flags ) 18 : QListView( parent, name, flags )
14{ 19{
15 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ), 20 connect( this, SIGNAL( selectionChanged( QListViewItem * ) ),
16 SLOT( refresh( QListViewItem * ) ) ); 21 SLOT( refresh( QListViewItem * ) ) );
17 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this, 22 connect( this, SIGNAL( mouseButtonPressed(int, QListViewItem *,const QPoint&,int ) ),this,
18 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) ); 23 SLOT( slotHold( int, QListViewItem *,const QPoint&,int ) ) );
19 setSorting(0); 24 setSorting(0);
20} 25}
21 26
22AccountView::~AccountView() 27AccountView::~AccountView()
23{ 28{
24 imapAccounts.clear(); 29 imapAccounts.clear();
25 mhAccounts.clear(); 30 mhAccounts.clear();
26} 31}
27 32
28void AccountView::slotContextMenu(int id) 33void AccountView::slotContextMenu(int id)
29{ 34{
30 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 35 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
31 if (!view) return; 36 if (!view) return;
32 view->contextMenuSelected(id); 37 view->contextMenuSelected(id);
33} 38}
34 39
35void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 40void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
36{ 41{
37 if (button==1) {return;} 42 if (button==1) {return;}
38 if (!item) return; 43 if (!item) return;
39 AccountViewItem *view = static_cast<AccountViewItem *>(item); 44 AccountViewItem *view = static_cast<AccountViewItem *>(item);
40 QPopupMenu*m = view->getContextMenu(); 45 QPopupMenu*m = view->getContextMenu();
41 if (!m) return; 46 if (!m) return;
42 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 47 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
43 m->setFocus(); 48 m->setFocus();
44 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 49 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
45 delete m; 50 delete m;
46} 51}
47 52
48void AccountView::populate( QList<Account> list ) 53void AccountView::populate( QList<Account> list )
49{ 54{
50 clear(); 55 clear();
51 56
52 imapAccounts.clear(); 57 imapAccounts.clear();
53 mhAccounts.clear(); 58 mhAccounts.clear();
54 59
55 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 60 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
56 61
57 Account *it; 62 Account *it;
58 for ( it = list.first(); it; it = list.next() ) { 63 for ( it = list.first(); it; it = list.next() )
59 if ( it->getType().compare( "IMAP" ) == 0 ) { 64 {
65 if ( it->getType().compare( "IMAP" ) == 0 )
66 {
60 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 67 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
61 qDebug( "added IMAP " + imap->getAccountName() ); 68 qDebug( "added IMAP " + imap->getAccountName() );
62 imapAccounts.append(new IMAPviewItem( imap, this )); 69 imapAccounts.append(new IMAPviewItem( imap, this ));
63 } else if ( it->getType().compare( "POP3" ) == 0 ) { 70 }
71 else if ( it->getType().compare( "POP3" ) == 0 )
72 {
64 POP3account *pop3 = static_cast<POP3account *>(it); 73 POP3account *pop3 = static_cast<POP3account *>(it);
65 qDebug( "added POP3 " + pop3->getAccountName() ); 74 qDebug( "added POP3 " + pop3->getAccountName() );
66 /* must not be hold 'cause it isn't required */ 75 /* must not be hold 'cause it isn't required */
67 (void) new POP3viewItem( pop3, this ); 76 (void) new POP3viewItem( pop3, this );
68 } 77 }
69 } 78 }
70} 79}
71 80
72void AccountView::refresh(QListViewItem *item) { 81void AccountView::refresh(QListViewItem *item)
82{
73 83
74 qDebug("AccountView refresh..."); 84 qDebug("AccountView refresh...");
75 if ( item ) { 85 if ( item )
86 {
76 m_currentItem = item; 87 m_currentItem = item;
77 QList<RecMail> headerlist; 88 QList<RecMail> headerlist;
78 headerlist.setAutoDelete(true); 89 headerlist.setAutoDelete(true);
79 AccountViewItem *view = static_cast<AccountViewItem *>(item); 90 AccountViewItem *view = static_cast<AccountViewItem *>(item);
80 view->refresh(headerlist); 91 view->refresh(headerlist);
81 emit refreshMailview(&headerlist); 92 emit refreshMailview(&headerlist);
82 } 93 }
83} 94}
84 95
85void AccountView::refreshCurrent() 96void AccountView::refreshCurrent()
86{ 97{
87 m_currentItem = currentItem(); 98 m_currentItem = currentItem();
88 if ( !m_currentItem ) return; 99 if ( !m_currentItem ) return;
89 QList<RecMail> headerlist; 100 QList<RecMail> headerlist;
90 headerlist.setAutoDelete(true); 101 headerlist.setAutoDelete(true);
91 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 102 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
92 view->refresh(headerlist); 103 view->refresh(headerlist);
93 emit refreshMailview(&headerlist); 104 emit refreshMailview(&headerlist);
94} 105}
95 106
96void AccountView::refreshAll() 107void AccountView::refreshAll()
97{ 108{
98
99} 109}
100 110
101RecBody AccountView::fetchBody(const RecMail&aMail) 111RecBody AccountView::fetchBody(const RecMail&aMail)
102{ 112{
103 QListViewItem*item = selectedItem (); 113 QListViewItem*item = selectedItem ();
104 if (!item) return RecBody(); 114 if (!item) return RecBody();
105 AccountViewItem *view = static_cast<AccountViewItem *>(item); 115 AccountViewItem *view = static_cast<AccountViewItem *>(item);
106 return view->fetchBody(aMail); 116 return view->fetchBody(aMail);
107} 117}
108 118
109void AccountView::setupFolderselect(Selectstore*sels) 119void AccountView::setupFolderselect(Selectstore*sels)
110{ 120{
111 sels->showMaximized(); 121 QPEApplication::showDialog( sels );
112 QStringList sFolders; 122 QStringList sFolders;
113 unsigned int i = 0; 123 unsigned int i = 0;
114 for (i=0; i < mhAccounts.count();++i) { 124 for (i=0; i < mhAccounts.count();++i)
125 {
115 mhAccounts[i]->refresh(false); 126 mhAccounts[i]->refresh(false);
116 sFolders = mhAccounts[i]->subFolders(); 127 sFolders = mhAccounts[i]->subFolders();
117 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 128 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
118 } 129 }
119 for (i=0; i < imapAccounts.count();++i) { 130 for (i=0; i < imapAccounts.count();++i)
131 {
120 if (imapAccounts[i]->offline()) 132 if (imapAccounts[i]->offline())
121 continue; 133 continue;
122 imapAccounts[i]->refreshFolders(false); 134 imapAccounts[i]->refreshFolders(false);
123 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 135 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
124 } 136 }
125} 137}
126 138
127void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper) 139void AccountView::downloadMails(Folder*fromFolder,AbstractMail*fromWrapper)
128{ 140{
129 AbstractMail*targetMail = 0; 141 AbstractMail*targetMail = 0;
130 QString targetFolder = ""; 142 QString targetFolder = "";
131 Selectstore sels; 143 Selectstore sels;
132 setupFolderselect(&sels); 144 setupFolderselect(&sels);
133 if (!sels.exec()) return; 145 if (!sels.exec()) return;
134 targetMail = sels.currentMail(); 146 targetMail = sels.currentMail();
135 targetFolder = sels.currentFolder(); 147 targetFolder = sels.currentFolder();
136 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 148 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
137 targetFolder.isEmpty()) { 149 targetFolder.isEmpty())
150 {
138 return; 151 return;
139 } 152 }
140 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { 153 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
154 {
141 QMessageBox::critical(0,tr("Error creating new Folder"), 155 QMessageBox::critical(0,tr("Error creating new Folder"),
142 tr("<center>Error while creating<br>new folder - breaking.</center>")); 156 tr("<center>Error while creating<br>new folder - breaking.</center>"));
143 return; 157 return;
144 } 158 }
145 qDebug("Targetfolder: %s",targetFolder.latin1()); 159 qDebug("Targetfolder: %s",targetFolder.latin1());
146 qDebug("Fromfolder: %s",fromFolder->getName().latin1()); 160 qDebug("Fromfolder: %s",fromFolder->getName().latin1());
147 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); 161 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
148 refreshCurrent(); 162 refreshCurrent();
149} 163}
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp
index f4f4cea..8cdabde 100644
--- a/noncore/net/mail/addresspicker.cpp
+++ b/noncore/net/mail/addresspicker.cpp
@@ -1,100 +1,114 @@
1
2#include "composemail.h"
3
4/* OPIE */
5#include <opie2/ocontactaccess.h>
6#include <opie2/ocontact.h>
7#include <qpe/resource.h>
8#include <qpe/qpeapplication.h>
9
10/* QT */
1#include <qpushbutton.h> 11#include <qpushbutton.h>
2#include <qmessagebox.h> 12#include <qmessagebox.h>
3#include <qtextstream.h> 13#include <qtextstream.h>
4#include <qlistbox.h> 14#include <qlistbox.h>
5#include <qfile.h> 15#include <qfile.h>
6 16
7#include <qpe/resource.h> 17/* STD */
8#include <opie2/ocontactaccess.h>
9#include <opie2/ocontact.h>
10
11
12#include <stdlib.h> 18#include <stdlib.h>
13 19
14#include "composemail.h" 20AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
15 21 : AddressPickerUI( parent, name, modal, flags )
16AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFlags flags )
17 : AddressPickerUI( parent, name, modal, flags )
18{ 22{
19 okButton->setIconSet( Resource::loadPixmap( "enter" ) ); 23 okButton->setIconSet( Resource::loadPixmap( "enter" ) );
20 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) ); 24 cancelButton->setIconSet( Resource::loadPixmap( "editdelete" ) );
21 25
22 connect(okButton, SIGNAL(clicked()), SLOT(accept())); 26 connect(okButton, SIGNAL(clicked()), SLOT(accept()));
23 connect(cancelButton, SIGNAL(clicked()), SLOT(close())); 27 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
24 Opie::OContactAccess::List::Iterator it; 28 Opie::OContactAccess::List::Iterator it;
25 29
26 QString lineEmail, lineName, contactLine; 30 QString lineEmail, lineName, contactLine;
27 /* what name has to set here???? */ 31 /* what name has to set here???? */
28 Opie::OContactAccess m_contactdb("opiemail"); 32 Opie::OContactAccess m_contactdb("opiemail");
29 33
30 QStringList mails; 34 QStringList mails;
31 QString pre,suf; 35 QString pre,suf;
32 Opie::OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 ); 36 Opie::OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
33 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 37 for ( it = m_list.begin(); it != m_list.end(); ++it )
34 if ((*it).defaultEmail().length()!=0) { 38 {
39 if ((*it).defaultEmail().length()!=0)
40 {
35 mails = (*it).emailList(); 41 mails = (*it).emailList();
36 if ((*it).fileAs().length()>0) { 42 if ((*it).fileAs().length()>0)
43 {
37 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <"; 44 pre = "\""+(*it).firstName()+" "+(*it).lastName()+"\" <";
38 suf = ">"; 45 suf = ">";
39 } else { 46 }
47 else
48 {
40 pre = ""; 49 pre = "";
41 suf = ""; 50 suf = "";
42 } 51 }
43 QStringList::ConstIterator sit = mails.begin(); 52 QStringList::ConstIterator sit = mails.begin();
44 for (;sit!=mails.end();++sit) { 53 for (;sit!=mails.end();++sit)
54 {
45 contactLine=pre+(*sit)+suf; 55 contactLine=pre+(*sit)+suf;
46 addressList->insertItem(contactLine); 56 addressList->insertItem(contactLine);
47 } 57 }
48 } 58 }
49 } 59 }
50 if ( addressList->count() <= 0 ) { 60 if ( addressList->count() <= 0 )
61 {
51#if 0 62#if 0
52 // makes this realy sense?? 63 // makes this realy sense??
53 addressList->insertItem( 64 addressList->insertItem(
54 tr( "There are no entries in the addressbook." ) ); 65 tr( "There are no entries in the addressbook." ) );
55#endif 66#endif
56 addressList->setEnabled( false ); 67 addressList->setEnabled( false );
57 okButton->setEnabled( false ); 68 okButton->setEnabled( false );
58 } else { 69 }
59// addressList->sort(); 70 else
71 {
72 // addressList->sort();
60 } 73 }
61} 74}
62 75
63void AddressPicker::accept() 76void AddressPicker::accept()
64{ 77{
65 QListBoxItem *item = addressList->firstItem(); 78 QListBoxItem *item = addressList->firstItem();
66 QString names; 79 QString names;
67 80
68 while ( item ) { 81 while ( item )
69 if ( item->selected() ) 82 {
70 names += item->text() + ", "; 83 if ( item->selected() )
71 item = item->next(); 84 names += item->text() + ", ";
72 } 85 item = item->next();
73 names.replace( names.length() - 2, 2, "" ); 86 }
74 87 names.replace( names.length() - 2, 2, "" );
75 if ( names.isEmpty() ) { 88
76 QMessageBox::information(this, tr("Error"), tr("<p>You have to select" 89 if ( names.isEmpty() )
77 " at least one address entry.</p>"), tr("Ok")); 90 {
78 return; 91 QMessageBox::information(this, tr("Error"), tr("<p>You have to select"
79 } 92 " at least one address entry.</p>"), tr("Ok"));
80 93 return;
81 selectedNames = names; 94 }
82 QDialog::accept(); 95
96 selectedNames = names;
97 QDialog::accept();
83} 98}
84 99
85QString AddressPicker::getNames() 100QString AddressPicker::getNames()
86{ 101{
87 QString names = 0; 102 QString names = 0;
88 103
89 AddressPicker picker(0, 0, true); 104 AddressPicker picker(0, 0, true);
90 picker.showMaximized(); 105
91 picker.show(); 106 int ret = QPEApplication::execDialog( &picker );
92 107 if ( QDialog::Accepted == ret )
93 int ret = picker.exec(); 108 {
94 if ( QDialog::Accepted == ret ) { 109 return picker.selectedNames;
95 return picker.selectedNames; 110 }
96 } 111
97 112 return 0;
98 return 0;
99} 113}
100 114
diff --git a/noncore/net/mail/editaccounts.cpp b/noncore/net/mail/editaccounts.cpp
index 1cb202e..60bffa5 100644
--- a/noncore/net/mail/editaccounts.cpp
+++ b/noncore/net/mail/editaccounts.cpp
@@ -1,473 +1,528 @@
1#include <qt.h>
2 1
3#include "defines.h" 2#include "defines.h"
4#include "editaccounts.h" 3#include "editaccounts.h"
5 4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
9#include <qt.h>
10
6AccountListItem::AccountListItem( QListView *parent, Account *a) 11AccountListItem::AccountListItem( QListView *parent, Account *a)
7 : QListViewItem( parent ) 12 : QListViewItem( parent )
8{ 13{
9 account = a; 14 account = a;
10 setText( 0, account->getAccountName() ); 15 setText( 0, account->getAccountName() );
11 setText( 1, account->getType() ); 16 setText( 1, account->getType() );
12} 17}
13 18
14EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 19EditAccounts::EditAccounts( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
15 : EditAccountsUI( parent, name, modal, flags ) 20 : EditAccountsUI( parent, name, modal, flags )
16{ 21{
17 qDebug( "New Account Configuration Widget" ); 22 qDebug( "New Account Configuration Widget" );
18 settings = s; 23 settings = s;
19 24
20 mailList->addColumn( tr( "Account" ) ); 25 mailList->addColumn( tr( "Account" ) );
21 mailList->addColumn( tr( "Type" ) ); 26 mailList->addColumn( tr( "Type" ) );
22 27
23 newsList->addColumn( tr( "Account" ) ); 28 newsList->addColumn( tr( "Account" ) );
24 29
25 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) ); 30 connect( newMail, SIGNAL( clicked() ), SLOT( slotNewMail() ) );
26 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) ); 31 connect( editMail, SIGNAL( clicked() ), SLOT( slotEditMail() ) );
27 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) ); 32 connect( deleteMail, SIGNAL( clicked() ), SLOT( slotDeleteMail() ) );
28 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) ); 33 connect( newNews, SIGNAL( clicked() ), SLOT( slotNewNews() ) );
29 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) ); 34 connect( editNews, SIGNAL( clicked() ), SLOT( slotEditNews() ) );
30 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) ); 35 connect( deleteNews, SIGNAL( clicked() ), SLOT( slotDeleteNews() ) );
31 36
32 slotFillLists(); 37 slotFillLists();
33} 38}
34 39
35void EditAccounts::slotFillLists() 40void EditAccounts::slotFillLists()
36{ 41{
37 mailList->clear(); 42 mailList->clear();
38 newsList->clear(); 43 newsList->clear();
39 44
40 QList<Account> accounts = settings->getAccounts(); 45 QList<Account> accounts = settings->getAccounts();
41 Account *it; 46 Account *it;
42 for ( it = accounts.first(); it; it = accounts.next() ) { 47 for ( it = accounts.first(); it; it = accounts.next() )
43 if ( it->getType().compare( "NNTP" ) == 0 ) { 48 {
49 if ( it->getType().compare( "NNTP" ) == 0 )
50 {
44 (void) new AccountListItem( newsList, it ); 51 (void) new AccountListItem( newsList, it );
45 } else { 52 }
53 else
54 {
46 (void) new AccountListItem( mailList, it ); 55 (void) new AccountListItem( mailList, it );
47 } 56 }
48 } 57 }
49} 58}
50 59
51void EditAccounts::slotNewMail() 60void EditAccounts::slotNewMail()
52{ 61{
53 qDebug( "New Mail Account" ); 62 qDebug( "New Mail Account" );
54 QString *selection = new QString(); 63 QString *selection = new QString();
55 SelectMailType selType( selection, this, 0, true ); 64 SelectMailType selType( selection, this, 0, true );
56 selType.show(); 65 selType.show();
57 if ( QDialog::Accepted == selType.exec() ) { 66 if ( QDialog::Accepted == selType.exec() )
67 {
58 slotNewAccount( *selection ); 68 slotNewAccount( *selection );
59 } 69 }
60} 70}
61 71
62void EditAccounts::slotNewAccount( const QString &type ) 72void EditAccounts::slotNewAccount( const QString &type )
63{ 73{
64 if ( type.compare( "IMAP" ) == 0 ) { 74 if ( type.compare( "IMAP" ) == 0 )
75 {
65 qDebug( "-> config IMAP" ); 76 qDebug( "-> config IMAP" );
66 IMAPaccount *account = new IMAPaccount(); 77 IMAPaccount *account = new IMAPaccount();
67 IMAPconfig imap( account, this, 0, true ); 78 IMAPconfig imap( account, this, 0, true );
68 imap.showMaximized(); 79 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
69 if ( QDialog::Accepted == imap.exec() ) { 80 {
70 settings->addAccount( account ); 81 settings->addAccount( account );
71 account->save(); 82 account->save();
72 slotFillLists(); 83 slotFillLists();
73 } else { 84 }
85 else
86 {
74 account->remove(); 87 account->remove();
75 } 88 }
76 } else if ( type.compare( "POP3" ) == 0 ) { 89 }
90 else if ( type.compare( "POP3" ) == 0 )
91 {
77 qDebug( "-> config POP3" ); 92 qDebug( "-> config POP3" );
78 POP3account *account = new POP3account(); 93 POP3account *account = new POP3account();
79 POP3config pop3( account, this, 0, true, WStyle_ContextHelp ); 94 POP3config pop3( account, this, 0, true, WStyle_ContextHelp );
80 pop3.showMaximized(); 95 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
81 if ( QDialog::Accepted == pop3.exec() ) { 96 {
82 settings->addAccount( account ); 97 settings->addAccount( account );
83 account->save(); 98 account->save();
84 slotFillLists(); 99 slotFillLists();
85 } else { 100 }
101 else
102 {
86 account->remove(); 103 account->remove();
87 } 104 }
88 } else if ( type.compare( "SMTP" ) == 0 ) { 105 }
106 else if ( type.compare( "SMTP" ) == 0 )
107 {
89 qDebug( "-> config SMTP" ); 108 qDebug( "-> config SMTP" );
90 SMTPaccount *account = new SMTPaccount(); 109 SMTPaccount *account = new SMTPaccount();
91 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp ); 110 SMTPconfig smtp( account, this, 0, true, WStyle_ContextHelp );
92 smtp.showMaximized(); 111 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
93 if ( QDialog::Accepted == smtp.exec() ) { 112 {
94 settings->addAccount( account ); 113 settings->addAccount( account );
95 account->save(); 114 account->save();
96 slotFillLists(); 115 slotFillLists();
97 116
98 } else { 117 }
118 else
119 {
99 account->remove(); 120 account->remove();
100 } 121 }
101 } else if ( type.compare( "NNTP" ) == 0 ) { 122 }
123 else if ( type.compare( "NNTP" ) == 0 )
124 {
102 qDebug( "-> config NNTP" ); 125 qDebug( "-> config NNTP" );
103 NNTPaccount *account = new NNTPaccount(); 126 NNTPaccount *account = new NNTPaccount();
104 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp ); 127 NNTPconfig nntp( account, this, 0, true, WStyle_ContextHelp );
105 nntp.showMaximized(); 128 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
106 if ( QDialog::Accepted == nntp.exec() ) { 129 {
107 settings->addAccount( account ); 130 settings->addAccount( account );
108 account->save(); 131 account->save();
109 slotFillLists(); 132 slotFillLists();
110 } else { 133 }
134 else
135 {
111 account->remove(); 136 account->remove();
112 } 137 }
113 } 138 }
114} 139}
115 140
116void EditAccounts::slotEditAccount( Account *account ) 141void EditAccounts::slotEditAccount( Account *account )
117{ 142{
118 if ( account->getType().compare( "IMAP" ) == 0 ) { 143 if ( account->getType().compare( "IMAP" ) == 0 )
144 {
119 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account); 145 IMAPaccount *imapAcc = static_cast<IMAPaccount *>(account);
120 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp ); 146 IMAPconfig imap( imapAcc, this, 0, true, WStyle_ContextHelp );
121 imap.showMaximized(); 147 if ( QDialog::Accepted == QPEApplication::execDialog( &imap ) )
122 if ( QDialog::Accepted == imap.exec() ) { 148 {
123 slotFillLists(); 149 slotFillLists();
124 } 150 }
125 } else if ( account->getType().compare( "POP3" ) == 0 ) { 151 }
152 else if ( account->getType().compare( "POP3" ) == 0 )
153 {
126 POP3account *pop3Acc = static_cast<POP3account *>(account); 154 POP3account *pop3Acc = static_cast<POP3account *>(account);
127 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp ); 155 POP3config pop3( pop3Acc, this, 0, true, WStyle_ContextHelp );
128 pop3.showMaximized(); 156 if ( QDialog::Accepted == QPEApplication::execDialog( &pop3 ) )
129 if ( QDialog::Accepted == pop3.exec() ) { 157 {
130 slotFillLists(); 158 slotFillLists();
131 } 159 }
132 } else if ( account->getType().compare( "SMTP" ) == 0 ) { 160 }
161 else if ( account->getType().compare( "SMTP" ) == 0 )
162 {
133 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account); 163 SMTPaccount *smtpAcc = static_cast<SMTPaccount *>(account);
134 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp ); 164 SMTPconfig smtp( smtpAcc, this, 0, true, WStyle_ContextHelp );
135 smtp.showMaximized(); 165 if ( QDialog::Accepted == QPEApplication::execDialog( &smtp ) )
136 if ( QDialog::Accepted == smtp.exec() ) { 166 {
137 slotFillLists(); 167 slotFillLists();
138 } 168 }
139 } else if ( account->getType().compare( "NNTP" ) == 0 ) { 169 }
170 else if ( account->getType().compare( "NNTP" ) == 0 )
171 {
140 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account); 172 NNTPaccount *nntpAcc = static_cast<NNTPaccount *>(account);
141 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp ); 173 NNTPconfig nntp( nntpAcc, this, 0, true, WStyle_ContextHelp );
142 nntp.showMaximized(); 174 if ( QDialog::Accepted == QPEApplication::execDialog( &nntp ) )
143 if ( QDialog::Accepted == nntp.exec() ) { 175 {
144 slotFillLists(); 176 slotFillLists();
145 } 177 }
146 } 178 }
147} 179}
148 180
149void EditAccounts::slotDeleteAccount( Account *account ) 181void EditAccounts::slotDeleteAccount( Account *account )
150{ 182{
151 if ( QMessageBox::information( this, tr( "Question" ), 183 if ( QMessageBox::information( this, tr( "Question" ),
152 tr( "<p>Do you really want to delete the selected Account?</p>" ), 184 tr( "<p>Do you really want to delete the selected Account?</p>" ),
153 tr( "Yes" ), tr( "No" ) ) == 0 ) { 185 tr( "Yes" ), tr( "No" ) ) == 0 )
186 {
154 settings->delAccount( account ); 187 settings->delAccount( account );
155 slotFillLists(); 188 slotFillLists();
156 } 189 }
157} 190}
158 191
159void EditAccounts::slotEditMail() 192void EditAccounts::slotEditMail()
160{ 193{
161 qDebug( "Edit Mail Account" ); 194 qDebug( "Edit Mail Account" );
162 if ( !mailList->currentItem() ) { 195 if ( !mailList->currentItem() )
196 {
163 QMessageBox::information( this, tr( "Error" ), 197 QMessageBox::information( this, tr( "Error" ),
164 tr( "<p>Please select an account.</p>" ), 198 tr( "<p>Please select an account.</p>" ),
165 tr( "Ok" ) ); 199 tr( "Ok" ) );
166 return; 200 return;
167 } 201 }
168 202
169 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 203 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
170 slotEditAccount( a ); 204 slotEditAccount( a );
171} 205}
172 206
173void EditAccounts::slotDeleteMail() 207void EditAccounts::slotDeleteMail()
174{ 208{
175 if ( !mailList->currentItem() ) { 209 if ( !mailList->currentItem() )
210 {
176 QMessageBox::information( this, tr( "Error" ), 211 QMessageBox::information( this, tr( "Error" ),
177 tr( "<p>Please select an account.</p>" ), 212 tr( "<p>Please select an account.</p>" ),
178 tr( "Ok" ) ); 213 tr( "Ok" ) );
179 return; 214 return;
180 } 215 }
181 216
182 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount(); 217 Account *a = ((AccountListItem *) mailList->currentItem())->getAccount();
183 slotDeleteAccount( a ); 218 slotDeleteAccount( a );
184} 219}
185 220
186void EditAccounts::slotNewNews() 221void EditAccounts::slotNewNews()
187{ 222{
188 qDebug( "New News Account" ); 223 qDebug( "New News Account" );
189 slotNewAccount( "NNTP" ); 224 slotNewAccount( "NNTP" );
190} 225}
191 226
192void EditAccounts::slotEditNews() 227void EditAccounts::slotEditNews()
193{ 228{
194 qDebug( "Edit News Account" ); 229 qDebug( "Edit News Account" );
195 if ( !newsList->currentItem() ) { 230 if ( !newsList->currentItem() )
231 {
196 QMessageBox::information( this, tr( "Error" ), 232 QMessageBox::information( this, tr( "Error" ),
197 tr( "<p>Please select an account.</p>" ), 233 tr( "<p>Please select an account.</p>" ),
198 tr( "Ok" ) ); 234 tr( "Ok" ) );
199 return; 235 return;
200 } 236 }
201 237
202 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 238 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
203 slotEditAccount( a ); 239 slotEditAccount( a );
204} 240}
205 241
206void EditAccounts::slotDeleteNews() 242void EditAccounts::slotDeleteNews()
207{ 243{
208 qDebug( "Delete News Account" ); 244 qDebug( "Delete News Account" );
209 if ( !newsList->currentItem() ) { 245 if ( !newsList->currentItem() )
246 {
210 QMessageBox::information( this, tr( "Error" ), 247 QMessageBox::information( this, tr( "Error" ),
211 tr( "<p>Please select an account.</p>" ), 248 tr( "<p>Please select an account.</p>" ),
212 tr( "Ok" ) ); 249 tr( "Ok" ) );
213 return; 250 return;
214 } 251 }
215 252
216 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount(); 253 Account *a = ((AccountListItem *) newsList->currentItem())->getAccount();
217 slotDeleteAccount( a ); 254 slotDeleteAccount( a );
218} 255}
219 256
220void EditAccounts::slotAdjustColumns() 257void EditAccounts::slotAdjustColumns()
221{ 258{
222 int currPage = configTab->currentPageIndex(); 259 int currPage = configTab->currentPageIndex();
223 260
224 configTab->showPage( mailTab ); 261 configTab->showPage( mailTab );
225 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 ); 262 mailList->setColumnWidth( 0, mailList->visibleWidth() - 50 );
226 mailList->setColumnWidth( 1, 50 ); 263 mailList->setColumnWidth( 1, 50 );
227 264
228 configTab->showPage( newsTab ); 265 configTab->showPage( newsTab );
229 newsList->setColumnWidth( 0, newsList->visibleWidth() ); 266 newsList->setColumnWidth( 0, newsList->visibleWidth() );
230 267
231 configTab->setCurrentPage( currPage ); 268 configTab->setCurrentPage( currPage );
232} 269}
233 270
234void EditAccounts::accept() 271void EditAccounts::accept()
235{ 272{
236 settings->saveAccounts(); 273 settings->saveAccounts();
237 274
238 QDialog::accept(); 275 QDialog::accept();
239} 276}
240 277
241/** 278/**
242 * SelectMailType 279 * SelectMailType
243 */ 280 */
244 281
245SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags ) 282SelectMailType::SelectMailType( QString *selection, QWidget *parent, const char *name, bool modal, WFlags flags )
246 : SelectMailTypeUI( parent, name, modal, flags ) 283 : SelectMailTypeUI( parent, name, modal, flags )
247{ 284{
248 selected = selection; 285 selected = selection;
249 selected->replace( 0, selected->length(), typeBox->currentText() ); 286 selected->replace( 0, selected->length(), typeBox->currentText() );
250 connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) ); 287 connect( typeBox, SIGNAL( activated( const QString & ) ), SLOT( slotSelection( const QString & ) ) );
251} 288}
252 289
253void SelectMailType::slotSelection( const QString &sel ) 290void SelectMailType::slotSelection( const QString &sel )
254{ 291{
255 selected->replace( 0, selected->length(), sel ); 292 selected->replace( 0, selected->length(), sel );
256} 293}
257 294
258/** 295/**
259 * IMAPconfig 296 * IMAPconfig
260 */ 297 */
261 298
262IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 299IMAPconfig::IMAPconfig( IMAPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
263 : IMAPconfigUI( parent, name, modal, flags ) 300 : IMAPconfigUI( parent, name, modal, flags )
264{ 301{
265 data = account; 302 data = account;
266 303
267 fillValues(); 304 fillValues();
268 305
269 connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); 306 connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) );
270 ComboBox1->insertItem( "Only if available", 0 ); 307 ComboBox1->insertItem( "Only if available", 0 );
271 ComboBox1->insertItem( "Always, Negotiated", 1 ); 308 ComboBox1->insertItem( "Always, Negotiated", 1 );
272 ComboBox1->insertItem( "Connect on secure port", 2 ); 309 ComboBox1->insertItem( "Connect on secure port", 2 );
273 ComboBox1->insertItem( "Run command instead", 3 ); 310 ComboBox1->insertItem( "Run command instead", 3 );
274 CommandEdit->hide(); 311 CommandEdit->hide();
275 ComboBox1->setCurrentItem( data->ConnectionType() ); 312 ComboBox1->setCurrentItem( data->ConnectionType() );
276} 313}
277 314
278void IMAPconfig::slotConnectionToggle( int index ) 315void IMAPconfig::slotConnectionToggle( int index )
279{ 316{
280 if ( index == 2 ) { 317 if ( index == 2 )
281 portLine->setText( IMAP_SSL_PORT ); 318 {
282 } else if ( index == 3 ) { 319 portLine->setText( IMAP_SSL_PORT );
320 }
321 else if ( index == 3 )
322 {
283 portLine->setText( IMAP_PORT ); 323 portLine->setText( IMAP_PORT );
284 CommandEdit->show(); 324 CommandEdit->show();
285 } else { 325 }
326 else
327 {
286 portLine->setText( IMAP_PORT ); 328 portLine->setText( IMAP_PORT );
287 } 329 }
288} 330}
289 331
290void IMAPconfig::fillValues() 332void IMAPconfig::fillValues()
291{ 333{
292 accountLine->setText( data->getAccountName() ); 334 accountLine->setText( data->getAccountName() );
293 serverLine->setText( data->getServer() ); 335 serverLine->setText( data->getServer() );
294 portLine->setText( data->getPort() ); 336 portLine->setText( data->getPort() );
295 ComboBox1->setCurrentItem( data->ConnectionType() ); 337 ComboBox1->setCurrentItem( data->ConnectionType() );
296 userLine->setText( data->getUser() ); 338 userLine->setText( data->getUser() );
297 passLine->setText( data->getPassword() ); 339 passLine->setText( data->getPassword() );
298 prefixLine->setText(data->getPrefix()); 340 prefixLine->setText(data->getPrefix());
299} 341}
300 342
301void IMAPconfig::accept() 343void IMAPconfig::accept()
302{ 344{
303 data->setAccountName( accountLine->text() ); 345 data->setAccountName( accountLine->text() );
304 data->setServer( serverLine->text() ); 346 data->setServer( serverLine->text() );
305 data->setPort( portLine->text() ); 347 data->setPort( portLine->text() );
306 data->setConnectionType( ComboBox1->currentItem() ); 348 data->setConnectionType( ComboBox1->currentItem() );
307 data->setUser( userLine->text() ); 349 data->setUser( userLine->text() );
308 data->setPassword( passLine->text() ); 350 data->setPassword( passLine->text() );
309 data->setPrefix(prefixLine->text()); 351 data->setPrefix(prefixLine->text());
310 352
311 QDialog::accept(); 353 QDialog::accept();
312} 354}
313 355
314/** 356/**
315 * POP3config 357 * POP3config
316 */ 358 */
317 359
318POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 360POP3config::POP3config( POP3account *account, QWidget *parent, const char *name, bool modal, WFlags flags )
319 : POP3configUI( parent, name, modal, flags ) 361 : POP3configUI( parent, name, modal, flags )
320{ 362{
321 data = account; 363 data = account;
322 fillValues(); 364 fillValues();
323 365
324 connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); 366 connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) );
325 ComboBox1->insertItem( "Only if available", 0 ); 367 ComboBox1->insertItem( "Only if available", 0 );
326 ComboBox1->insertItem( "Always, Negotiated", 1 ); 368 ComboBox1->insertItem( "Always, Negotiated", 1 );
327 ComboBox1->insertItem( "Connect on secure port", 2 ); 369 ComboBox1->insertItem( "Connect on secure port", 2 );
328 ComboBox1->insertItem( "Run command instead", 3 ); 370 ComboBox1->insertItem( "Run command instead", 3 );
329 CommandEdit->hide(); 371 CommandEdit->hide();
330 ComboBox1->setCurrentItem( data->ConnectionType() ); 372 ComboBox1->setCurrentItem( data->ConnectionType() );
331} 373}
332 374
333void POP3config::slotConnectionToggle( int index ) 375void POP3config::slotConnectionToggle( int index )
334{ 376{
335 // 2 is ssl connection 377 // 2 is ssl connection
336 if ( index == 2 ) { 378 if ( index == 2 )
337 portLine->setText( POP3_SSL_PORT ); 379 {
338 } else if ( index == 3 ) { 380 portLine->setText( POP3_SSL_PORT );
381 }
382 else if ( index == 3 )
383 {
339 portLine->setText( POP3_PORT ); 384 portLine->setText( POP3_PORT );
340 CommandEdit->show(); 385 CommandEdit->show();
341 } else { 386 }
387 else
388 {
342 portLine->setText( POP3_PORT ); 389 portLine->setText( POP3_PORT );
343 } 390 }
344} 391}
345 392
346void POP3config::fillValues() 393void POP3config::fillValues()
347{ 394{
348 accountLine->setText( data->getAccountName() ); 395 accountLine->setText( data->getAccountName() );
349 serverLine->setText( data->getServer() ); 396 serverLine->setText( data->getServer() );
350 portLine->setText( data->getPort() ); 397 portLine->setText( data->getPort() );
351 ComboBox1->setCurrentItem( data->ConnectionType() ); 398 ComboBox1->setCurrentItem( data->ConnectionType() );
352 userLine->setText( data->getUser() ); 399 userLine->setText( data->getUser() );
353 passLine->setText( data->getPassword() ); 400 passLine->setText( data->getPassword() );
354} 401}
355 402
356void POP3config::accept() 403void POP3config::accept()
357{ 404{
358 data->setAccountName( accountLine->text() ); 405 data->setAccountName( accountLine->text() );
359 data->setServer( serverLine->text() ); 406 data->setServer( serverLine->text() );
360 data->setPort( portLine->text() ); 407 data->setPort( portLine->text() );
361 data->setConnectionType( ComboBox1->currentItem() ); 408 data->setConnectionType( ComboBox1->currentItem() );
362 data->setUser( userLine->text() ); 409 data->setUser( userLine->text() );
363 data->setPassword( passLine->text() ); 410 data->setPassword( passLine->text() );
364 411
365 QDialog::accept(); 412 QDialog::accept();
366} 413}
367 414
368/** 415/**
369 * SMTPconfig 416 * SMTPconfig
370 */ 417 */
371 418
372SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 419SMTPconfig::SMTPconfig( SMTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
373 : SMTPconfigUI( parent, name, modal, flags ) 420 : SMTPconfigUI( parent, name, modal, flags )
374{ 421{
375 data = account; 422 data = account;
376 423
377 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); 424 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) );
378 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); 425 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) );
379 426
380 fillValues(); 427 fillValues();
381 428
382 connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) ); 429 connect( ComboBox1, SIGNAL( activated( int ) ), SLOT( slotConnectionToggle( int ) ) );
383 ComboBox1->insertItem( "Only if available", 0 ); 430 ComboBox1->insertItem( "Only if available", 0 );
384 ComboBox1->insertItem( "Always, Negotiated", 1 ); 431 ComboBox1->insertItem( "Always, Negotiated", 1 );
385 ComboBox1->insertItem( "Connect on secure port", 2 ); 432 ComboBox1->insertItem( "Connect on secure port", 2 );
386 ComboBox1->insertItem( "Run command instead", 3 ); 433 ComboBox1->insertItem( "Run command instead", 3 );
387 CommandEdit->hide(); 434 CommandEdit->hide();
388 ComboBox1->setCurrentItem( data->ConnectionType() ); 435 ComboBox1->setCurrentItem( data->ConnectionType() );
389} 436}
390 437
391void SMTPconfig::slotConnectionToggle( int index ) 438void SMTPconfig::slotConnectionToggle( int index )
392{ 439{
393 // 2 is ssl connection 440 // 2 is ssl connection
394 if ( index == 2 ) { 441 if ( index == 2 )
395 portLine->setText( SMTP_SSL_PORT ); 442 {
396 } else if ( index == 3 ) { 443 portLine->setText( SMTP_SSL_PORT );
444 }
445 else if ( index == 3 )
446 {
397 portLine->setText( SMTP_PORT ); 447 portLine->setText( SMTP_PORT );
398 CommandEdit->show(); 448 CommandEdit->show();
399 } else { 449 }
450 else
451 {
400 portLine->setText( SMTP_PORT ); 452 portLine->setText( SMTP_PORT );
401 } 453 }
402} 454}
403 455
404void SMTPconfig::fillValues() 456void SMTPconfig::fillValues()
405{ 457{
406 accountLine->setText( data->getAccountName() ); 458 accountLine->setText( data->getAccountName() );
407 serverLine->setText( data->getServer() ); 459 serverLine->setText( data->getServer() );
408 portLine->setText( data->getPort() ); 460 portLine->setText( data->getPort() );
409 ComboBox1->setCurrentItem( data->ConnectionType() ); 461 ComboBox1->setCurrentItem( data->ConnectionType() );
410 loginBox->setChecked( data->getLogin() ); 462 loginBox->setChecked( data->getLogin() );
411 userLine->setText( data->getUser() ); 463 userLine->setText( data->getUser() );
412 passLine->setText( data->getPassword() ); 464 passLine->setText( data->getPassword() );
413} 465}
414 466
415void SMTPconfig::accept() 467void SMTPconfig::accept()
416{ 468{
417 data->setAccountName( accountLine->text() ); 469 data->setAccountName( accountLine->text() );
418 data->setServer( serverLine->text() ); 470 data->setServer( serverLine->text() );
419 data->setPort( portLine->text() ); 471 data->setPort( portLine->text() );
420 data->setConnectionType( ComboBox1->currentItem() ); 472 data->setConnectionType( ComboBox1->currentItem() );
421 data->setLogin( loginBox->isChecked() ); 473 data->setLogin( loginBox->isChecked() );
422 data->setUser( userLine->text() ); 474 data->setUser( userLine->text() );
423 data->setPassword( passLine->text() ); 475 data->setPassword( passLine->text() );
424 476
425 QDialog::accept(); 477 QDialog::accept();
426} 478}
427 479
428/** 480/**
429 * NNTPconfig 481 * NNTPconfig
430 */ 482 */
431 483
432NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags ) 484NNTPconfig::NNTPconfig( NNTPaccount *account, QWidget *parent, const char *name, bool modal, WFlags flags )
433 : NNTPconfigUI( parent, name, modal, flags ) 485 : NNTPconfigUI( parent, name, modal, flags )
434{ 486{
435 data = account; 487 data = account;
436 488
437 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) ); 489 connect( loginBox, SIGNAL( toggled( bool ) ), userLine, SLOT( setEnabled( bool ) ) );
438 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) ); 490 connect( loginBox, SIGNAL( toggled( bool ) ), passLine, SLOT( setEnabled( bool ) ) );
439 491
440 fillValues(); 492 fillValues();
441 493
442 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) ); 494 connect( sslBox, SIGNAL( toggled( bool ) ), SLOT( slotSSL( bool ) ) );
443} 495}
444 496
445void NNTPconfig::slotSSL( bool enabled ) 497void NNTPconfig::slotSSL( bool enabled )
446{ 498{
447 if ( enabled ) { 499 if ( enabled )
500 {
448 portLine->setText( NNTP_SSL_PORT ); 501 portLine->setText( NNTP_SSL_PORT );
449 } else { 502 }
503 else
504 {
450 portLine->setText( NNTP_PORT ); 505 portLine->setText( NNTP_PORT );
451 } 506 }
452} 507}
453 508
454void NNTPconfig::fillValues() 509void NNTPconfig::fillValues()
455{ 510{
456 accountLine->setText( data->getAccountName() ); 511 accountLine->setText( data->getAccountName() );
457 serverLine->setText( data->getServer() ); 512 serverLine->setText( data->getServer() );
458 portLine->setText( data->getPort() ); 513 portLine->setText( data->getPort() );
459 sslBox->setChecked( data->getSSL() ); 514 sslBox->setChecked( data->getSSL() );
460 loginBox->setChecked( data->getLogin() ); 515 loginBox->setChecked( data->getLogin() );
461 userLine->setText( data->getUser() ); 516 userLine->setText( data->getUser() );
462 passLine->setText( data->getPassword() ); 517 passLine->setText( data->getPassword() );
463} 518}
464 519
465void NNTPconfig::accept() 520void NNTPconfig::accept()
466{ 521{
467 data->setAccountName( accountLine->text() ); 522 data->setAccountName( accountLine->text() );
468 data->setServer( serverLine->text() ); 523 data->setServer( serverLine->text() );
469 data->setPort( portLine->text() ); 524 data->setPort( portLine->text() );
470 data->setSSL( sslBox->isChecked() ); 525 data->setSSL( sslBox->isChecked() );
471 data->setLogin( loginBox->isChecked() ); 526 data->setLogin( loginBox->isChecked() );
472 data->setUser( userLine->text() ); 527 data->setUser( userLine->text() );
473 data->setPassword( passLine->text() ); 528 data->setPassword( passLine->text() );
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 0795436..abf93dc 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,229 +1,258 @@
1#include <qmessagebox.h> 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"
7#include "viewmail.h"
8#include "selectstore.h"
9#include "selectsmtp.h"
10
11/* OPIE */
6#include <libmailwrapper/smtpwrapper.h> 12#include <libmailwrapper/smtpwrapper.h>
13#include <libmailwrapper/mailtypes.h>
14#include <libmailwrapper/abstractmail.h>
7#include <qpe/qcopenvelope_qws.h> 15#include <qpe/qcopenvelope_qws.h>
8#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qpeapplication.h>
18
19/* QT */
20#include <qmessagebox.h>
9#include <qaction.h> 21#include <qaction.h>
10#include <qapplication.h> 22#include <qapplication.h>
11#include <libmailwrapper/mailtypes.h>
12#include <libmailwrapper/abstractmail.h>
13#include "mailistviewitem.h"
14#include "viewmail.h"
15#include "selectstore.h"
16#include "selectsmtp.h"
17 23
18OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 24OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags )
19 : MainWindow( parent, name, WStyle_ContextHelp ) 25 : MainWindow( parent, name, WStyle_ContextHelp )
20{ 26{
21 settings = new Settings(); 27 settings = new Settings();
22 28
23 folderView->populate( settings->getAccounts() ); 29 folderView->populate( settings->getAccounts() );
24} 30}
25 31
26OpieMail::~OpieMail() 32OpieMail::~OpieMail()
27{ 33{
28 if (settings) delete settings; 34 if (settings) delete settings;
29} 35}
30 36
31void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 37void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
32{ 38{
33 // copied from old mail2 39 // copied from old mail2
34 if (msg == "writeMail(QString,QString)") { 40 if (msg == "writeMail(QString,QString)")
41 {
35 QDataStream stream(data,IO_ReadOnly); 42 QDataStream stream(data,IO_ReadOnly);
36 QString name, email; 43 QString name, email;
37 stream >> name >> email; 44 stream >> name >> email;
38 // removing the whitespaces at beginning and end is needed! 45 // removing the whitespaces at beginning and end is needed!
39 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 46 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
40 } else if (msg == "newMail()") { 47 }
48 else if (msg == "newMail()")
49 {
41 slotComposeMail(); 50 slotComposeMail();
42 } 51 }
43} 52}
44 53
45void OpieMail::slotwriteMail(const QString&name,const QString&email) 54void OpieMail::slotwriteMail(const QString&name,const QString&email)
46{ 55{
47 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 56 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
48 if (!email.isEmpty()) { 57 if (!email.isEmpty())
49 if (!name.isEmpty()) { 58 {
59 if (!name.isEmpty())
60 {
50 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 61 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
51 } else { 62 }
63 else
64 {
52 compose.setTo(email); 65 compose.setTo(email);
53 } 66 }
54 } 67 }
55 compose.showMaximized();
56 compose.slotAdjustColumns(); 68 compose.slotAdjustColumns();
57 compose.exec(); 69 QPEApplication::execDialog( &compose );
58} 70}
59 71
60void OpieMail::slotComposeMail() 72void OpieMail::slotComposeMail()
61{ 73{
62 qDebug( "Compose Mail" ); 74 qDebug( "Compose Mail" );
63 slotwriteMail(0l,0l); 75 slotwriteMail(0l,0l);
64} 76}
65 77
66void OpieMail::slotSendQueued() 78void OpieMail::slotSendQueued()
67{ 79{
68 qDebug( "Send Queued" ); 80 qDebug( "Send Queued" );
69 SMTPaccount *smtp = 0; 81 SMTPaccount *smtp = 0;
70 82
71 QList<Account> list = settings->getAccounts(); 83 QList<Account> list = settings->getAccounts();
72 QList<SMTPaccount> smtpList; 84 QList<SMTPaccount> smtpList;
73 smtpList.setAutoDelete(false); 85 smtpList.setAutoDelete(false);
74 Account *it; 86 Account *it;
75 for ( it = list.first(); it; it = list.next() ) { 87 for ( it = list.first(); it; it = list.next() )
76 if ( it->getType().compare( "SMTP" ) == 0 ) { 88 {
89 if ( it->getType().compare( "SMTP" ) == 0 )
90 {
77 smtp = static_cast<SMTPaccount *>(it); 91 smtp = static_cast<SMTPaccount *>(it);
78 smtpList.append(smtp); 92 smtpList.append(smtp);
79 } 93 }
80 } 94 }
81 if (smtpList.count()==0) { 95 if (smtpList.count()==0)
96 {
82 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 97 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
83 return; 98 return;
84 } 99 }
85 if (smtpList.count()==1) { 100 if (smtpList.count()==1)
101 {
86 smtp = smtpList.at(0); 102 smtp = smtpList.at(0);
87 } else { 103 }
104 else
105 {
88 smtp = 0; 106 smtp = 0;
89 selectsmtp selsmtp; 107 selectsmtp selsmtp;
90 selsmtp.setSelectionlist(&smtpList); 108 selsmtp.setSelectionlist(&smtpList);
91 selsmtp.showMaximized(); 109 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
92 if (selsmtp.exec()==QDialog::Accepted) { 110 {
93 smtp = selsmtp.selected_smtp(); 111 smtp = selsmtp.selected_smtp();
94 } 112 }
95 } 113 }
96 if (smtp) { 114 if (smtp)
115 {
97 SMTPwrapper * wrap = new SMTPwrapper(smtp); 116 SMTPwrapper * wrap = new SMTPwrapper(smtp);
98 if ( wrap->flushOutbox() ) { 117 if ( wrap->flushOutbox() )
118 {
99 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 119 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
100 } 120 }
101 delete wrap; 121 delete wrap;
102 } 122 }
103} 123}
104 124
105void OpieMail::slotSearchMails() 125void OpieMail::slotSearchMails()
106{ 126{
107 qDebug( "Search Mails" ); 127 qDebug( "Search Mails" );
108} 128}
109 129
110void OpieMail::slotEditSettings() 130void OpieMail::slotEditSettings()
111{ 131{
112 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 132 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
113 settingsDialog.showMaximized(); 133 QPEApplication::execDialog( &settingsDialog );
114 settingsDialog.exec();
115} 134}
116 135
117void OpieMail::slotEditAccounts() 136void OpieMail::slotEditAccounts()
118{ 137{
119 qDebug( "Edit Accounts" ); 138 qDebug( "Edit Accounts" );
120 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 139 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
121 eaDialog.showMaximized();
122 eaDialog.slotAdjustColumns(); 140 eaDialog.slotAdjustColumns();
123 eaDialog.exec(); 141 QPEApplication::execDialog( &eaDialog );
124 if ( settings ) delete settings; 142 if ( settings ) delete settings;
125 settings = new Settings(); 143 settings = new Settings();
126 144
127 folderView->populate( settings->getAccounts() ); 145 folderView->populate( settings->getAccounts() );
128} 146}
129 147
130void OpieMail::displayMail() 148void OpieMail::displayMail()
131{ 149{
132 QListViewItem*item = mailView->currentItem(); 150 QListViewItem*item = mailView->currentItem();
133 if (!item) return; 151 if (!item) return;
134 RecMail mail = ((MailListViewItem*)item)->data(); 152 RecMail mail = ((MailListViewItem*)item)->data();
135 RecBody body = folderView->fetchBody(mail); 153 RecBody body = folderView->fetchBody(mail);
136 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp ); 154 ViewMail readMail( this,"", Qt::WType_Modal | WStyle_ContextHelp );
137 readMail.setBody( body ); 155 readMail.setBody( body );
138 readMail.setMail( mail ); 156 readMail.setMail( mail );
139 readMail.showMaximized(); 157 readMail.showMaximized();
140 readMail.exec(); 158 readMail.exec();
141 159
142 if ( readMail.deleted ) { 160 if ( readMail.deleted )
143 folderView->refreshCurrent(); 161 {
144 } else { 162 folderView->refreshCurrent();
163 }
164 else
165 {
145 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) ); 166 ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "" ) );
146 } 167 }
147} 168}
148 169
149void OpieMail::slotDeleteMail() 170void OpieMail::slotDeleteMail()
150{ 171{
151 if (!mailView->currentItem()) return; 172 if (!mailView->currentItem()) return;
152 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 173 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
153 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 ) { 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 )
154 mail.Wrapper()->deleteMail( mail ); 175 {
155 folderView->refreshCurrent(); 176 mail.Wrapper()->deleteMail( mail );
177 folderView->refreshCurrent();
156 } 178 }
157} 179}
158 180
159void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) 181void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int )
160{ 182{
161 /* just the RIGHT button - or hold on pda */ 183 /* just the RIGHT button - or hold on pda */
162 if (button!=2) {return;} 184 if (button!=2) {return;}
163 qDebug("Event right/hold"); 185 qDebug("Event right/hold");
164 if (!item) return; 186 if (!item) return;
165 QPopupMenu *m = new QPopupMenu(0); 187 QPopupMenu *m = new QPopupMenu(0);
166 if (m) { 188 if (m)
189 {
167 m->insertItem(tr("Read this mail"),this,SLOT(displayMail())); 190 m->insertItem(tr("Read this mail"),this,SLOT(displayMail()));
168 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail())); 191 m->insertItem(tr("Delete this mail"),this,SLOT(slotDeleteMail()));
169 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail())); 192 m->insertItem(tr("Copy/Move this mail"),this,SLOT(slotMoveCopyMail()));
170 m->setFocus(); 193 m->setFocus();
171 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 194 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
172 delete m; 195 delete m;
173 } 196 }
174} 197}
175 198
176void OpieMail::slotShowFolders( bool show ) 199void OpieMail::slotShowFolders( bool show )
177{ 200{
178 qDebug( "Show Folders" ); 201 qDebug( "Show Folders" );
179 if ( show && folderView->isHidden() ) { 202 if ( show && folderView->isHidden() )
203 {
180 qDebug( "-> showing" ); 204 qDebug( "-> showing" );
181 folderView->show(); 205 folderView->show();
182 } else if ( !show && !folderView->isHidden() ) { 206 }
207 else if ( !show && !folderView->isHidden() )
208 {
183 qDebug( "-> hiding" ); 209 qDebug( "-> hiding" );
184 folderView->hide(); 210 folderView->hide();
185 } 211 }
186} 212}
187 213
188void OpieMail::refreshMailView(QList<RecMail>*list) 214void OpieMail::refreshMailView(QList<RecMail>*list)
189{ 215{
190 MailListViewItem*item = 0; 216 MailListViewItem*item = 0;
191 mailView->clear(); 217 mailView->clear();
192 for (unsigned int i = 0; i < list->count();++i) { 218 for (unsigned int i = 0; i < list->count();++i)
219 {
193 item = new MailListViewItem(mailView,item); 220 item = new MailListViewItem(mailView,item);
194 item->storeData(*(list->at(i))); 221 item->storeData(*(list->at(i)));
195 item->showEntry(); 222 item->showEntry();
196 } 223 }
197} 224}
198 225
199void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int ) 226void OpieMail::mailLeftClicked(int button, QListViewItem *item,const QPoint&,int )
200{ 227{
201 /* just LEFT button - or tap with stylus on pda */ 228 /* just LEFT button - or tap with stylus on pda */
202 if (button!=1) return; 229 if (button!=1) return;
203 if (!item) return; 230 if (!item) return;
204 displayMail(); 231 displayMail();
205} 232}
206 233
207void OpieMail::slotMoveCopyMail() 234void OpieMail::slotMoveCopyMail()
208{ 235{
209 if (!mailView->currentItem()) return; 236 if (!mailView->currentItem()) return;
210 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); 237 RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data();
211 AbstractMail*targetMail = 0; 238 AbstractMail*targetMail = 0;
212 QString targetFolder = ""; 239 QString targetFolder = "";
213 Selectstore sels; 240 Selectstore sels;
214 folderView->setupFolderselect(&sels); 241 folderView->setupFolderselect(&sels);
215 if (!sels.exec()) return; 242 if (!sels.exec()) return;
216 targetMail = sels.currentMail(); 243 targetMail = sels.currentMail();
217 targetFolder = sels.currentFolder(); 244 targetFolder = sels.currentFolder();
218 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) || 245 if ( (mail.Wrapper()==targetMail && mail.getMbox()==targetFolder) ||
219 targetFolder.isEmpty()) { 246 targetFolder.isEmpty())
247 {
220 return; 248 return;
221 } 249 }
222 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) { 250 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
251 {
223 QMessageBox::critical(0,tr("Error creating new Folder"), 252 QMessageBox::critical(0,tr("Error creating new Folder"),
224 tr("<center>Error while creating<br>new folder - breaking.</center>")); 253 tr("<center>Error while creating<br>new folder - breaking.</center>"));
225 return; 254 return;
226 } 255 }
227 mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); 256 mail.Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails());
228 folderView->refreshCurrent(); 257 folderView->refreshCurrent();
229} 258}
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 99965d4..f015228 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,429 +1,472 @@
1#include "composemail.h"
2#include "viewmail.h"
3#include "accountview.h"
4
5/* OPIE */
6#include <libmailwrapper/settings.h>
7#include <libmailwrapper/abstractmail.h>
8#include <libmailwrapper/mailtypes.h>
9
10#include <opie2/ofiledialog.h>
11#include <qpe/config.h>
12#include <qpe/qpeapplication.h>
13
14/* QT */
1#include <qtextbrowser.h> 15#include <qtextbrowser.h>
2#include <qmessagebox.h> 16#include <qmessagebox.h>
3#include <qtextstream.h> 17#include <qtextstream.h>
4#include <qaction.h> 18#include <qaction.h>
5#include <qpopupmenu.h> 19#include <qpopupmenu.h>
6#include <qfile.h> 20#include <qfile.h>
7#include <qapplication.h> 21#include <qapplication.h>
8#include <qvaluelist.h> 22#include <qvaluelist.h>
9 23
10#include <qpe/config.h>
11
12#include <opie2/ofiledialog.h>
13
14#include <libmailwrapper/settings.h>
15#include "composemail.h"
16#include "viewmail.h"
17#include <libmailwrapper/abstractmail.h>
18#include "accountview.h"
19#include <libmailwrapper/mailtypes.h>
20
21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 24AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path) 25 const QString&fsize,int num,const QValueList<int>&path)
23 : QListViewItem(parent,after),_partNum(num) 26 : QListViewItem(parent,after),_partNum(num)
24{ 27{
25 _path=path; 28 _path=path;
26 setText(0, mime); 29 setText(0, mime);
27 setText(1, desc); 30 setText(1, desc);
28 setText(2, file); 31 setText(2, file);
29 setText(3, fsize); 32 setText(3, fsize);
30} 33}
31 34
32AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 35AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path) 36 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num) 37 : QListViewItem(parent,after),_partNum(num)
35{ 38{
36 _path=path; 39 _path=path;
37 setText(0, mime); 40 setText(0, mime);
38 setText(1, desc); 41 setText(1, desc);
39 setText(2, file); 42 setText(2, file);
40 setText(3, fsize); 43 setText(3, fsize);
41} 44}
42 45
43bool AttachItem::isParentof(const QValueList<int>&path) 46bool AttachItem::isParentof(const QValueList<int>&path)
44{ 47{
45 /* if not set, then no parent */ 48 /* if not set, then no parent */
46 if (path.count()==0||_path.count()==0) return false; 49 if (path.count()==0||_path.count()==0) return false;
47 /* the parent must have one digit less then a child */ 50 /* the parent must have one digit less then a child */
48 if (path.count()!=_path.count()+1) return false; 51 if (path.count()!=_path.count()+1) return false;
49 for (unsigned int i=0; i < _path.count();++i) { 52 for (unsigned int i=0; i < _path.count();++i)
53 {
50 if (_path[i]!=path[i]) return false; 54 if (_path[i]!=path[i]) return false;
51 } 55 }
52 return true; 56 return true;
53} 57}
54 58
55AttachItem* ViewMail::searchParent(const QValueList<int>&path) 59AttachItem* ViewMail::searchParent(const QValueList<int>&path)
56{ 60{
57 QListViewItemIterator it( attachments ); 61 QListViewItemIterator it( attachments );
58 for ( ; it.current(); ++it ) { 62 for ( ; it.current(); ++it )
63 {
59 AttachItem*ati = (AttachItem*)it.current(); 64 AttachItem*ati = (AttachItem*)it.current();
60 if (ati->isParentof(path)) return ati; 65 if (ati->isParentof(path)) return ati;
61 } 66 }
62 return 0; 67 return 0;
63} 68}
64 69
65AttachItem* ViewMail::lastChild(AttachItem*parent) 70AttachItem* ViewMail::lastChild(AttachItem*parent)
66{ 71{
67 if (!parent) return 0; 72 if (!parent) return 0;
68 AttachItem* item = (AttachItem*)parent->firstChild(); 73 AttachItem* item = (AttachItem*)parent->firstChild();
69 if (!item) return item; 74 if (!item) return item;
70 AttachItem*temp=0; 75 AttachItem*temp=0;
71 while( (temp=(AttachItem*)item->nextSibling())) { 76 while( (temp=(AttachItem*)item->nextSibling()))
77 {
72 item = temp; 78 item = temp;
73 } 79 }
74 return item; 80 return item;
75} 81}
76 82
77void ViewMail::setBody( RecBody body ) { 83void ViewMail::setBody( RecBody body )
78
79m_body = body;
80m_mail[2] = body.Bodytext();
81attachbutton->setEnabled(body.Parts().count()>0);
82attachments->setEnabled(body.Parts().count()>0);
83if (body.Parts().count()==0) {
84 return;
85}
86AttachItem * curItem=0;
87AttachItem * parentItem = 0;
88QString type=body.Description().Type()+"/"+body.Description().Subtype();
89QString desc,fsize;
90double s = body.Description().Size();
91int w;
92w=0;
93
94while (s>1024) {
95 s/=1024;
96 ++w;
97 if (w>=2) break;
98}
99
100QString q="";
101switch(w) {
102case 1:
103 q="k";
104 break;
105case 2:
106 q="M";
107 break;
108default:
109 break;
110}
111
112{ 84{
113 /* I did not found a method to make a CONTENT reset on a QTextStream
114 so I use this construct that the stream will re-constructed in each
115 loop. To let it work, the textstream is packed into a own area of
116 code is it will be destructed after finishing its small job.
117 */
118 QTextOStream o(&fsize);
119 if (w>0) o.precision(2); else o.precision(0);
120 o.setf(QTextStream::fixed);
121 o << s << " " << q << "Byte";
122}
123
124curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
125QString filename = "";
126 85
127for (unsigned int i = 0; i < body.Parts().count();++i) { 86 m_body = body;
128 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 87 m_mail[2] = body.Bodytext();
129 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 88 attachbutton->setEnabled(body.Parts().count()>0);
130 for (;it!=body.Parts()[i].Parameters().end();++it) { 89 attachments->setEnabled(body.Parts().count()>0);
131 qDebug(it.key()); 90 if (body.Parts().count()==0)
132 if (it.key().lower()=="name") { 91 {
133 filename=it.data(); 92 return;
134 }
135 } 93 }
136 s = body.Parts()[i].Size(); 94 AttachItem * curItem=0;
137 w = 0; 95 AttachItem * parentItem = 0;
138 while (s>1024) { 96 QString type=body.Description().Type()+"/"+body.Description().Subtype();
97 QString desc,fsize;
98 double s = body.Description().Size();
99 int w;
100 w=0;
101
102 while (s>1024)
103 {
139 s/=1024; 104 s/=1024;
140 ++w; 105 ++w;
141 if (w>=2) break; 106 if (w>=2) break;
142 } 107 }
143 switch(w) { 108
109 QString q="";
110 switch(w)
111 {
144 case 1: 112 case 1:
145 q="k"; 113 q="k";
146 break; 114 break;
147 case 2: 115 case 2:
148 q="M"; 116 q="M";
149 break; 117 break;
150 default: 118 default:
151 q="";
152 break; 119 break;
153 } 120 }
154 QTextOStream o(&fsize); 121
155 if (w>0) o.precision(2); else o.precision(0); 122 {
156 o.setf(QTextStream::fixed); 123 /* I did not found a method to make a CONTENT reset on a QTextStream
157 o << s << " " << q << "Byte"; 124 so I use this construct that the stream will re-constructed in each
158 desc = body.Parts()[i].Description(); 125 loop. To let it work, the textstream is packed into a own area of
159 parentItem = searchParent(body.Parts()[i].Positionlist()); 126 code is it will be destructed after finishing its small job.
160 if (parentItem) { 127 */
161 AttachItem*temp = lastChild(parentItem); 128 QTextOStream o(&fsize);
162 if (temp) curItem = temp; 129 if (w>0) o.precision(2); else o.precision(0);
163 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 130 o.setf(QTextStream::fixed);
164 attachments->setRootIsDecorated(true); 131 o << s << " " << q << "Byte";
165 curItem = parentItem; 132 }
166 } else { 133
167 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 134 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
135 QString filename = "";
136
137 for (unsigned int i = 0; i < body.Parts().count();++i)
138 {
139 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
140 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
141 for (;it!=body.Parts()[i].Parameters().end();++it)
142 {
143 qDebug(it.key());
144 if (it.key().lower()=="name")
145 {
146 filename=it.data();
147 }
148 }
149 s = body.Parts()[i].Size();
150 w = 0;
151 while (s>1024)
152 {
153 s/=1024;
154 ++w;
155 if (w>=2) break;
156 }
157 switch(w)
158 {
159 case 1:
160 q="k";
161 break;
162 case 2:
163 q="M";
164 break;
165 default:
166 q="";
167 break;
168 }
169 QTextOStream o(&fsize);
170 if (w>0) o.precision(2); else o.precision(0);
171 o.setf(QTextStream::fixed);
172 o << s << " " << q << "Byte";
173 desc = body.Parts()[i].Description();
174 parentItem = searchParent(body.Parts()[i].Positionlist());
175 if (parentItem)
176 {
177 AttachItem*temp = lastChild(parentItem);
178 if (temp) curItem = temp;
179 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
180 attachments->setRootIsDecorated(true);
181 curItem = parentItem;
182 }
183 else
184 {
185 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
186 }
168 } 187 }
169}
170} 188}
171 189
172 190
173void ViewMail::slotShowHtml( bool state ) { 191void ViewMail::slotShowHtml( bool state )
192{
174 m_showHtml = state; 193 m_showHtml = state;
175 setText(); 194 setText();
176} 195}
177 196
178void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { 197void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
198{
179 if (!item ) 199 if (!item )
180 return; 200 return;
181 201
182 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 202 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
203 {
183 setText(); 204 setText();
184 return; 205 return;
185 } 206 }
186 QPopupMenu *menu = new QPopupMenu(); 207 QPopupMenu *menu = new QPopupMenu();
187 int ret=0; 208 int ret=0;
188 209
189 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) { 210 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
190 menu->insertItem( tr( "Show Text" ), 1 ); 211 {
191 } 212 menu->insertItem( tr( "Show Text" ), 1 );
192 menu->insertItem( tr( "Save Attachment" ), 0 ); 213 }
193 menu->insertSeparator(1); 214 menu->insertItem( tr( "Save Attachment" ), 0 );
194 215 menu->insertSeparator(1);
195 ret = menu->exec( point, 0 ); 216
196 217 ret = menu->exec( point, 0 );
197 switch(ret) { 218
198 case 0: 219 switch(ret)
199 { MimeTypes types; 220 {
200 types.insert( "all", "*" ); 221 case 0:
201 QString str = Opie::OFileDialog::getSaveFileName( 1, 222 {
202 "/", item->text( 2 ) , types, 0 ); 223 MimeTypes types;
203 224 types.insert( "all", "*" );
204 if( !str.isEmpty() ) { 225 QString str = Opie::OFileDialog::getSaveFileName( 1,
205 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 226 "/", item->text( 2 ) , types, 0 );
206 if (content) { 227
207 QFile output(str); 228 if( !str.isEmpty() )
208 output.open(IO_WriteOnly); 229 {
209 output.writeBlock(content->Content(),content->Length()); 230 encodedString*content = m_recMail.Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
210 output.close(); 231 if (content)
211 delete content; 232 {
212 } 233 QFile output(str);
213 } 234 output.open(IO_WriteOnly);
214 } 235 output.writeBlock(content->Content(),content->Length());
236 output.close();
237 delete content;
238 }
239 }
240 }
215 break ; 241 break ;
216 242
217 case 1: 243 case 1:
218 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { 244 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
219 setText(); 245 {
220 } else { 246 setText();
221 if ( m_recMail.Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions 247 }
248 else
249 {
250 if ( m_recMail.Wrapper() != 0l )
251 { // make sure that there is a wrapper , even after delete or simular actions
222 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 252 browser->setText( m_recMail.Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
223 } 253 }
224 } 254 }
225 break; 255 break;
226 } 256 }
227 delete menu; 257 delete menu;
228} 258}
229 259
230 260
231void ViewMail::setMail( RecMail mail ) { 261void ViewMail::setMail( RecMail mail )
262{
232 263
233 m_recMail = mail; 264 m_recMail = mail;
234 265
235 m_mail[0] = mail.getFrom(); 266 m_mail[0] = mail.getFrom();
236 m_mail[1] = mail.getSubject(); 267 m_mail[1] = mail.getSubject();
237 m_mail[3] = mail.getDate(); 268 m_mail[3] = mail.getDate();
238 m_mail[4] = mail.Msgid(); 269 m_mail[4] = mail.Msgid();
239 270
240 m_mail2[0] = mail.To(); 271 m_mail2[0] = mail.To();
241 m_mail2[1] = mail.CC(); 272 m_mail2[1] = mail.CC();
242 m_mail2[2] = mail.Bcc(); 273 m_mail2[2] = mail.Bcc();
243 274
244 setText(); 275 setText();
245} 276}
246 277
247 278
248 279
249ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 280ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
250 : ViewMailBase(parent, name, fl), _inLoop(false) 281 : ViewMailBase(parent, name, fl), _inLoop(false)
251{ 282{
252 m_gotBody = false; 283 m_gotBody = false;
253 deleted = false; 284 deleted = false;
254 285
255 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 286 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
256 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 287 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
257 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); 288 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) );
258 connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); 289 connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) );
259 290
260 attachments->setEnabled(m_gotBody); 291 attachments->setEnabled(m_gotBody);
261 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); 292 connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) );
262 293
263 readConfig(); 294 readConfig();
264 attachments->setSorting(-1); 295 attachments->setSorting(-1);
265} 296}
266 297
267void ViewMail::readConfig() { 298void ViewMail::readConfig()
299{
268 Config cfg( "mail" ); 300 Config cfg( "mail" );
269 cfg.setGroup( "Settings" ); 301 cfg.setGroup( "Settings" );
270 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 302 m_showHtml = cfg.readBoolEntry( "showHtml", false );
271 showHtml->setOn( m_showHtml ); 303 showHtml->setOn( m_showHtml );
272} 304}
273 305
274void ViewMail::setText() 306void ViewMail::setText()
275{ 307{
276 308
277 QString toString; 309 QString toString;
278 QString ccString; 310 QString ccString;
279 QString bccString; 311 QString bccString;
280 312
281 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { 313 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
314 {
282 toString += (*it); 315 toString += (*it);
283 } 316 }
284 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { 317 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
318 {
285 ccString += (*it); 319 ccString += (*it);
286 } 320 }
287 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { 321 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
322 {
288 bccString += (*it); 323 bccString += (*it);
289 } 324 }
290 325
291 setCaption( caption().arg( m_mail[0] ) ); 326 setCaption( caption().arg( m_mail[0] ) );
292 327
293 m_mailHtml = "<html><body>" 328 m_mailHtml = "<html><body>"
294 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 329 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
295 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 330 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
296 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 331 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
297 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 332 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
298 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 333 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
299 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 334 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
300 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 335 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
301 "</td></tr></table><font face=fixed>"; 336 "</td></tr></table><font face=fixed>";
302 337
303 if ( !m_showHtml ) { 338 if ( !m_showHtml )
304 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 339 {
305 } else { 340 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
306 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 341 }
342 else
343 {
344 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
307 } 345 }
308 // remove later in favor of a real handling 346 // remove later in favor of a real handling
309 m_gotBody = true; 347 m_gotBody = true;
310} 348}
311 349
312 350
313ViewMail::~ViewMail() 351ViewMail::~ViewMail()
314{ 352{
315 m_recMail.Wrapper()->cleanMimeCache(); 353 m_recMail.Wrapper()->cleanMimeCache();
316 hide(); 354 hide();
317} 355}
318 356
319void ViewMail::hide() 357void ViewMail::hide()
320{ 358{
321 QWidget::hide(); 359 QWidget::hide();
322 360
323 if (_inLoop) { 361 if (_inLoop)
324 _inLoop = false; 362 {
325 qApp->exit_loop(); 363 _inLoop = false;
364 qApp->exit_loop();
326 365
327 } 366 }
328 367
329} 368}
330 369
331void ViewMail::exec() 370void ViewMail::exec()
332{ 371{
333 show(); 372 show();
334 373
335 if (!_inLoop) { 374 if (!_inLoop)
336 _inLoop = true; 375 {
337 qApp->enter_loop(); 376 _inLoop = true;
338 } 377 qApp->enter_loop();
378 }
339 379
340} 380}
341 381
342QString ViewMail::deHtml(const QString &string) 382QString ViewMail::deHtml(const QString &string)
343{ 383{
344 QString string_ = string; 384 QString string_ = string;
345 string_.replace(QRegExp("&"), "&amp;"); 385 string_.replace(QRegExp("&"), "&amp;");
346 string_.replace(QRegExp("<"), "&lt;"); 386 string_.replace(QRegExp("<"), "&lt;");
347 string_.replace(QRegExp(">"), "&gt;"); 387 string_.replace(QRegExp(">"), "&gt;");
348 string_.replace(QRegExp("\\n"), "<br>"); 388 string_.replace(QRegExp("\\n"), "<br>");
349 return string_; 389 return string_;
350} 390}
351 391
352void ViewMail::slotReply() 392void ViewMail::slotReply()
353{ 393{
354 if (!m_gotBody) { 394 if (!m_gotBody)
355 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 395 {
356 return; 396 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
357 } 397 return;
358 398 }
359 QString rtext; 399
360 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 400 QString rtext;
361 .arg( m_mail[0] ) 401 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
362 .arg( m_mail[3] ); 402 .arg( m_mail[0] )
363 403 .arg( m_mail[3] );
364 QString text = m_mail[2]; 404
365 QStringList lines = QStringList::split(QRegExp("\\n"), text); 405 QString text = m_mail[2];
366 QStringList::Iterator it; 406 QStringList lines = QStringList::split(QRegExp("\\n"), text);
367 for (it = lines.begin(); it != lines.end(); it++) { 407 QStringList::Iterator it;
368 rtext += "> " + *it + "\n"; 408 for (it = lines.begin(); it != lines.end(); it++)
369 } 409 {
370 rtext += "\n"; 410 rtext += "> " + *it + "\n";
371 411 }
372 QString prefix; 412 rtext += "\n";
373 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = ""; 413
374 else prefix = "Re: "; // no i18n on purpose 414 QString prefix;
375 415 if ( m_mail[1].find(QRegExp("^Re: *$")) != -1) prefix = "";
376 Settings *settings = new Settings(); 416 else prefix = "Re: "; // no i18n on purpose
377 ComposeMail composer( settings ,this, 0, true); 417
378 composer.setTo( m_mail[0] ); 418 Settings *settings = new Settings();
379 composer.setSubject( "Re: " + m_mail[1] ); 419 ComposeMail composer( settings ,this, 0, true);
380 composer.setMessage( rtext ); 420 composer.setTo( m_mail[0] );
381 composer.showMaximized(); 421 composer.setSubject( "Re: " + m_mail[1] );
382 if ( QDialog::Accepted==composer.exec()) { 422 composer.setMessage( rtext );
423 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ) )
424 {
383 m_recMail.Wrapper()->answeredMail(m_recMail); 425 m_recMail.Wrapper()->answeredMail(m_recMail);
384 } 426 }
385} 427}
386 428
387void ViewMail::slotForward() 429void ViewMail::slotForward()
388{ 430{
389 if (!m_gotBody) { 431 if (!m_gotBody)
390 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); 432 {
391 return; 433 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok"));
392 } 434 return;
393 435 }
394 QString ftext;
395 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
396 .arg( m_mail[0] );
397 if (!m_mail[3].isNull())
398 ftext += QString("Date: %1\n")
399 .arg( m_mail[3] );
400 if (!m_mail[0].isNull())
401 ftext += QString("From: %1\n")
402 .arg( m_mail[0] );
403 if (!m_mail[1].isNull())
404 ftext += QString("Subject: %1\n")
405 .arg( m_mail[1] );
406
407 ftext += QString("\n%1\n")
408 .arg( m_mail[2]);
409
410 ftext += QString("----- End forwarded message -----\n");
411
412 Settings *settings = new Settings();
413 ComposeMail composer( settings ,this, 0, true);
414 composer.setSubject( "Fwd: " + m_mail[1] );
415 composer.setMessage( ftext );
416 composer.showMaximized();
417 if ( QDialog::Accepted==composer.exec()) {
418 436
437 QString ftext;
438 ftext += QString("\n----- Forwarded message from %1 -----\n\n")
439 .arg( m_mail[0] );
440 if (!m_mail[3].isNull())
441 ftext += QString("Date: %1\n")
442 .arg( m_mail[3] );
443 if (!m_mail[0].isNull())
444 ftext += QString("From: %1\n")
445 .arg( m_mail[0] );
446 if (!m_mail[1].isNull())
447 ftext += QString("Subject: %1\n")
448 .arg( m_mail[1] );
449
450 ftext += QString("\n%1\n")
451 .arg( m_mail[2]);
452
453 ftext += QString("----- End forwarded message -----\n");
454
455 Settings *settings = new Settings();
456 ComposeMail composer( settings ,this, 0, true);
457 composer.setSubject( "Fwd: " + m_mail[1] );
458 composer.setMessage( ftext );
459 if ( QDialog::Accepted == QPEApplication::execDialog( &composer ))
460 {
419 } 461 }
420} 462}
421 463
422void ViewMail::slotDeleteMail( ) 464void ViewMail::slotDeleteMail( )
423{ 465{
424 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 ) { 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 )
467 {
425 m_recMail.Wrapper()->deleteMail( m_recMail ); 468 m_recMail.Wrapper()->deleteMail( m_recMail );
426 hide(); 469 hide();
427 deleted = true; 470 deleted = true;
428 } 471 }
429} 472}
diff --git a/noncore/net/opieirc/ircservereditor.cpp b/noncore/net/opieirc/ircservereditor.cpp
index 60274d1..2d11bf0 100644
--- a/noncore/net/opieirc/ircservereditor.cpp
+++ b/noncore/net/opieirc/ircservereditor.cpp
@@ -1,70 +1,76 @@
1#include "ircservereditor.h"
2
3/* OPIE */
4#include <qpe/qpeapplication.h>
5
6/* QT */
1#include <qmessagebox.h> 7#include <qmessagebox.h>
2#include <qlayout.h> 8#include <qlayout.h>
3#include <qlabel.h> 9#include <qlabel.h>
4#include <qwhatsthis.h> 10#include <qwhatsthis.h>
5#include "ircservereditor.h"
6 11
7IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 12IRCServerEditor::IRCServerEditor(IRCServer server, QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) {
8 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5); 13 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 5);
9 QLabel *label = new QLabel(tr("Profile name :"), this); 14 QLabel *label = new QLabel(tr("Profile name :"), this);
10 m_name = new QLineEdit(server.name(), this); 15 m_name = new QLineEdit(server.name(), this);
11 QWhatsThis::add(m_name, tr("The name of this server profile in the overview")); 16 QWhatsThis::add(m_name, tr("The name of this server profile in the overview"));
12 layout->addWidget(label, 0, 0); 17 layout->addWidget(label, 0, 0);
13 layout->addWidget(m_name, 0, 1); 18 layout->addWidget(m_name, 0, 1);
14 label = new QLabel(tr("Hostname :"), this); 19 label = new QLabel(tr("Hostname :"), this);
15 m_hostname = new QLineEdit(server.hostname(), this); 20 m_hostname = new QLineEdit(server.hostname(), this);
16 QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address")); 21 QWhatsThis::add(m_hostname, tr("The server to connect to - can be any valid host name or IP address"));
17 layout->addWidget(label, 1, 0); 22 layout->addWidget(label, 1, 0);
18 layout->addWidget(m_hostname, 1, 1); 23 layout->addWidget(m_hostname, 1, 1);
19 label = new QLabel(tr("Port :"), this); 24 label = new QLabel(tr("Port :"), this);
20 m_port = new QLineEdit(QString::number(server.port()), this); 25 m_port = new QLineEdit(QString::number(server.port()), this);
21 QWhatsThis::add(m_port, tr("The server port to connect to. Usually 6667")); 26 QWhatsThis::add(m_port, tr("The server port to connect to. Usually 6667"));
22 layout->addWidget(label, 2, 0); 27 layout->addWidget(label, 2, 0);
23 layout->addWidget(m_port, 2, 1); 28 layout->addWidget(m_port, 2, 1);
24 label = new QLabel(tr("Nickname :"), this); 29 label = new QLabel(tr("Nickname :"), this);
25 m_nickname = new QLineEdit(server.nick(), this); 30 m_nickname = new QLineEdit(server.nick(), this);
26 QWhatsThis::add(m_nickname, tr("Your nick name on the IRC network")); 31 QWhatsThis::add(m_nickname, tr("Your nick name on the IRC network"));
27 layout->addWidget(label, 3, 0); 32 layout->addWidget(label, 3, 0);
28 layout->addWidget(m_nickname, 3, 1); 33 layout->addWidget(m_nickname, 3, 1);
29 label = new QLabel(tr("Realname :"), this); 34 label = new QLabel(tr("Realname :"), this);
30 m_realname = new QLineEdit(server.realname(), this); 35 m_realname = new QLineEdit(server.realname(), this);
31 QWhatsThis::add(m_realname, tr("Your real name")); 36 QWhatsThis::add(m_realname, tr("Your real name"));
32 layout->addWidget(label, 4, 0); 37 layout->addWidget(label, 4, 0);
33 layout->addWidget(m_realname, 4, 1); 38 layout->addWidget(m_realname, 4, 1);
34 label = new QLabel(tr("Password :"), this); 39 label = new QLabel(tr("Password :"), this);
35 m_password = new QLineEdit(server.password(), this); 40 m_password = new QLineEdit(server.password(), this);
36 m_password->setEchoMode( QLineEdit::Password ); 41 m_password->setEchoMode( QLineEdit::Password );
37 QWhatsThis::add(m_password, tr("Password to connect to the server (if required)")); 42 QWhatsThis::add(m_password, tr("Password to connect to the server (if required)"));
38 layout->addWidget(label, 5, 0); 43 layout->addWidget(label, 5, 0);
39 layout->addWidget(m_password, 5, 1); 44 layout->addWidget(m_password, 5, 1);
40 label = new QLabel(tr("Channels :"), this); 45 label = new QLabel(tr("Channels :"), this);
41 m_channels = new QLineEdit(server.channels(), this); 46 m_channels = new QLineEdit(server.channels(), this);
42 QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically")); 47 QWhatsThis::add(m_channels, tr("Comma-Separated list of all channels you would like to join automatically"));
43 layout->addWidget(label, 6, 0); 48 layout->addWidget(label, 6, 0);
44 layout->addWidget(m_channels, 6, 1); 49 layout->addWidget(m_channels, 6, 1);
45 setCaption(tr("Edit server information")); 50 setCaption(tr("Edit server information"));
46 showMaximized(); 51
52 QPEApplication::showDialog( this );
47} 53}
48 54
49 55
50void IRCServerEditor::accept() { 56void IRCServerEditor::accept() {
51 if (m_name->text().length()==0) 57 if (m_name->text().length()==0)
52 QMessageBox::critical(this, tr("Error"), tr("Profile name required")); 58 QMessageBox::critical(this, tr("Error"), tr("Profile name required"));
53 else if (m_hostname->text().length()==0) 59 else if (m_hostname->text().length()==0)
54 QMessageBox::critical(this, tr("Error"), tr("Host name required")); 60 QMessageBox::critical(this, tr("Error"), tr("Host name required"));
55 else if (m_port->text().toInt()<=0) 61 else if (m_port->text().toInt()<=0)
56 QMessageBox::critical(this, tr("Error"), tr("Port required")); 62 QMessageBox::critical(this, tr("Error"), tr("Port required"));
57 else if (m_nickname->text().length()==0) 63 else if (m_nickname->text().length()==0)
58 QMessageBox::critical(this, tr("Error"), tr("Nickname required")); 64 QMessageBox::critical(this, tr("Error"), tr("Nickname required"));
59 else if (m_realname->text().length()==0) 65 else if (m_realname->text().length()==0)
60 QMessageBox::critical(this, tr("Error"), tr("Realname required")); 66 QMessageBox::critical(this, tr("Error"), tr("Realname required"));
61 else { 67 else {
62 /* Now verify whether the channel list has a valid format */ 68 /* Now verify whether the channel list has a valid format */
63 QStringList channels = QStringList::split(QChar(','), m_channels->text()); 69 QStringList channels = QStringList::split(QChar(','), m_channels->text());
64 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) { 70 for (QStringList::Iterator it = channels.begin(); it != channels.end(); ++it) {
65 QString channelName = (*it).stripWhiteSpace(); 71 QString channelName = (*it).stripWhiteSpace();
66 if (!channelName.startsWith("#") && !channelName.startsWith("+")) { 72 if (!channelName.startsWith("#") && !channelName.startsWith("+")) {
67 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'")); 73 QMessageBox::critical(this, tr("Error"), tr("The channel list needs to contain a\ncomma separated list of channel\n names which start with either '#' or '+'"));
68 return; 74 return;
69 } 75 }
70 } 76 }
diff --git a/noncore/net/opieirc/ircserverlist.cpp b/noncore/net/opieirc/ircserverlist.cpp
index 595ae3e..62bfc17 100644
--- a/noncore/net/opieirc/ircserverlist.cpp
+++ b/noncore/net/opieirc/ircserverlist.cpp
@@ -1,135 +1,161 @@
1
2#include "ircserverlist.h"
3#include "ircservereditor.h"
4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
1#include <qlayout.h> 9#include <qlayout.h>
2#include <qlabel.h> 10#include <qlabel.h>
3#include <qhbox.h> 11#include <qhbox.h>
4#include <qpushbutton.h> 12#include <qpushbutton.h>
5#include <qwhatsthis.h> 13#include <qwhatsthis.h>
6#include "ircserverlist.h"
7#include "ircservereditor.h"
8 14
9class IRCListBoxServer : public QListBoxText { 15class IRCListBoxServer : public QListBoxText
16{
10public: 17public:
11 IRCListBoxServer(IRCServer server) : QListBoxText(server.name()) { 18 IRCListBoxServer(IRCServer server) : QListBoxText(server.name())
19 {
12 m_server = server; 20 m_server = server;
13 } 21 }
14 22
15 IRCServer server() { 23 IRCServer server()
24 {
16 return m_server; 25 return m_server;
17 } 26 }
18 27
19 void setServer(IRCServer server) { 28 void setServer(IRCServer server)
29 {
20 m_server = server; 30 m_server = server;
21 setText(m_server.name()); 31 setText(m_server.name());
22 } 32 }
23protected: 33protected:
24 IRCServer m_server; 34 IRCServer m_server;
25}; 35};
26 36
27IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 37IRCServerList::IRCServerList(QWidget* parent, const char *name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
38{
28 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5); 39 QVBoxLayout *layout = new QVBoxLayout(this, 5, 5);
29 setCaption(tr("Serverlist Browser")); 40 setCaption(tr("Serverlist Browser"));
30 QLabel *label = new QLabel(tr("Please choose a server profile"), this); 41 QLabel *label = new QLabel(tr("Please choose a server profile"), this);
31 label->setAlignment(AlignHCenter); 42 label->setAlignment(AlignHCenter);
32 layout->addWidget(label); 43 layout->addWidget(label);
33 m_list = new QListBox(this); 44 m_list = new QListBox(this);
34 QWhatsThis::add(m_list, tr("Select a server profile from this list and then tap on OK in the upper-right corner")); 45 QWhatsThis::add(m_list, tr("Select a server profile from this list and then tap on OK in the upper-right corner"));
35 layout->addWidget(m_list); 46 layout->addWidget(m_list);
36 QHBox *buttons = new QHBox(this); 47 QHBox *buttons = new QHBox(this);
37 QPushButton *del = new QPushButton(tr("Delete"), buttons); 48 QPushButton *del = new QPushButton(tr("Delete"), buttons);
38 QPushButton *edit = new QPushButton(tr("Edit"), buttons); 49 QPushButton *edit = new QPushButton(tr("Edit"), buttons);
39 QPushButton *add = new QPushButton(tr("Add"), buttons); 50 QPushButton *add = new QPushButton(tr("Add"), buttons);
40 QWhatsThis::add(del, tr("Delete the currently selected server profile")); 51 QWhatsThis::add(del, tr("Delete the currently selected server profile"));
41 QWhatsThis::add(edit, tr("Edit the currently selected server profile")); 52 QWhatsThis::add(edit, tr("Edit the currently selected server profile"));
42 QWhatsThis::add(add, tr("Add a new server profile")); 53 QWhatsThis::add(add, tr("Add a new server profile"));
43 connect(del, SIGNAL(clicked()), this, SLOT(delServer())); 54 connect(del, SIGNAL(clicked()), this, SLOT(delServer()));
44 connect(edit, SIGNAL(clicked()), this, SLOT(editServer())); 55 connect(edit, SIGNAL(clicked()), this, SLOT(editServer()));
45 connect(add, SIGNAL(clicked()), this, SLOT(addServer())); 56 connect(add, SIGNAL(clicked()), this, SLOT(addServer()));
46 layout->addWidget(buttons); 57 layout->addWidget(buttons);
47 /* Load the configuration file */ 58 /* Load the configuration file */
48 m_config = new Config("OpieIRC"); 59 m_config = new Config("OpieIRC");
49 m_config->setGroup("OpieIRC"); 60 m_config->setGroup("OpieIRC");
50 int count = m_config->readNumEntry("ServerCount", 0); 61 int count = m_config->readNumEntry("ServerCount", 0);
51 if (count) { 62 if (count)
52 for (int i=0; i<count; i++) { 63 {
64 for (int i=0; i<count; i++)
65 {
53 m_config->setGroup("OpieIRC"); 66 m_config->setGroup("OpieIRC");
54 QString name = m_config->readEntry("Server"+QString::number(i)); 67 QString name = m_config->readEntry("Server"+QString::number(i));
55 if (name.length() > 0) { 68 if (name.length() > 0)
69 {
56 IRCServer server; 70 IRCServer server;
57 m_config->setGroup(name); 71 m_config->setGroup(name);
58 server.setName(name); 72 server.setName(name);
59 server.setHostname(m_config->readEntry("Hostname")); 73 server.setHostname(m_config->readEntry("Hostname"));
60 server.setPort(m_config->readNumEntry("Port")); 74 server.setPort(m_config->readNumEntry("Port"));
61 server.setUsername(m_config->readEntry("Username")); 75 server.setUsername(m_config->readEntry("Username"));
62 server.setPassword(m_config->readEntry("Password")); 76 server.setPassword(m_config->readEntry("Password"));
63 server.setNick(m_config->readEntry("Nick")); 77 server.setNick(m_config->readEntry("Nick"));
64 server.setRealname(m_config->readEntry("Realname")); 78 server.setRealname(m_config->readEntry("Realname"));
65 server.setChannels(m_config->readEntry("Channels")); 79 server.setChannels(m_config->readEntry("Channels"));
66 m_list->insertItem(new IRCListBoxServer(server)); 80 m_list->insertItem(new IRCListBoxServer(server));
67 } 81 }
68 } 82 }
69 } 83 }
70 84
71 showMaximized(); 85 QPEApplication::showDialog( this );
72} 86}
73 87
74void IRCServerList::addServer() { 88void IRCServerList::addServer()
89{
75 IRCServer server; 90 IRCServer server;
76 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 91 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
77 if (editor.exec() == QDialog::Accepted) { 92 if (editor.exec() == QDialog::Accepted)
93 {
78 server = editor.getServer(); 94 server = editor.getServer();
79 /* Gets deleted by QListBox, so this is ok */ 95 /* Gets deleted by QListBox, so this is ok */
80 m_list->insertItem(new IRCListBoxServer(server)); 96 m_list->insertItem(new IRCListBoxServer(server));
81 } 97 }
82} 98}
83 99
84void IRCServerList::delServer() { 100void IRCServerList::delServer()
101{
85 int index = m_list->currentItem(); 102 int index = m_list->currentItem();
86 if (index != -1) { 103 if (index != -1)
104 {
87 m_list->removeItem(index); 105 m_list->removeItem(index);
88 } 106 }
89} 107}
90 108
91void IRCServerList::editServer() { 109void IRCServerList::editServer()
110{
92 int index = m_list->currentItem(); 111 int index = m_list->currentItem();
93 if (index != -1) { 112 if (index != -1)
113 {
94 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index); 114 IRCListBoxServer *item = (IRCListBoxServer *)m_list->item(index);
95 IRCServer server = item->server(); 115 IRCServer server = item->server();
96 IRCServerEditor editor(server, this, "ServerEditor", TRUE); 116 IRCServerEditor editor(server, this, "ServerEditor", TRUE);
97 if (editor.exec() == QDialog::Accepted) { 117 if (editor.exec() == QDialog::Accepted)
118 {
98 server = editor.getServer(); 119 server = editor.getServer();
99 item->setServer(server); 120 item->setServer(server);
100 } 121 }
101 } 122 }
102} 123}
103 124
104int IRCServerList::exec() { 125int IRCServerList::exec()
126{
105 int returncode = QDialog::exec(); 127 int returncode = QDialog::exec();
106 /* Now save the changes */ 128 /* Now save the changes */
107 m_config->setGroup("OpieIRC"); 129 m_config->setGroup("OpieIRC");
108 m_config->writeEntry("ServerCount", QString::number(m_list->count())); 130 m_config->writeEntry("ServerCount", QString::number(m_list->count()));
109 for (unsigned int i=0; i<m_list->count(); i++) { 131 for (unsigned int i=0; i<m_list->count(); i++)
132 {
110 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server(); 133 IRCServer server = ((IRCListBoxServer *)m_list->item(i))->server();
111 m_config->setGroup("OpieIRC"); 134 m_config->setGroup("OpieIRC");
112 m_config->writeEntry("Server"+QString::number(i), server.name()); 135 m_config->writeEntry("Server"+QString::number(i), server.name());
113 m_config->setGroup(server.name()); 136 m_config->setGroup(server.name());
114 m_config->writeEntry("Hostname", server.hostname()); 137 m_config->writeEntry("Hostname", server.hostname());
115 m_config->writeEntry("Port", QString::number(server.port())); 138 m_config->writeEntry("Port", QString::number(server.port()));
116 m_config->writeEntry("Username", server.username()); 139 m_config->writeEntry("Username", server.username());
117 m_config->writeEntry("Password", server.password()); 140 m_config->writeEntry("Password", server.password());
118 m_config->writeEntry("Nick", server.nick()); 141 m_config->writeEntry("Nick", server.nick());
119 m_config->writeEntry("Realname", server.realname()); 142 m_config->writeEntry("Realname", server.realname());
120 m_config->writeEntry("Channels", server.channels()); 143 m_config->writeEntry("Channels", server.channels());
121 } 144 }
122 return returncode; 145 return returncode;
123} 146}
124 147
125bool IRCServerList::hasServer() { 148bool IRCServerList::hasServer()
149{
126 return (m_list->currentItem() != -1); 150 return (m_list->currentItem() != -1);
127} 151}
128 152
129IRCServer IRCServerList::server() { 153IRCServer IRCServerList::server()
154{
130 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server(); 155 return ((IRCListBoxServer *)m_list->item(m_list->currentItem()))->server();
131} 156}
132 157
133IRCServerList::~IRCServerList() { 158IRCServerList::~IRCServerList()
159{
134 delete m_config; 160 delete m_config;
135} 161}
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
index 2862296..f69d2c4 100644
--- a/noncore/net/opieirc/ircsettings.cpp
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -1,32 +1,39 @@
1
2#include "ircsettings.h"
3#include "irctab.h"
4
5/* OPIE */
1#include <opie/ocolorbutton.h> 6#include <opie/ocolorbutton.h>
2#include <opie/otabwidget.h> 7#include <opie/otabwidget.h>
8#include <qpe/qpeapplication.h>
9
10/* QT */
3#include <qvalidator.h> 11#include <qvalidator.h>
4#include <qwhatsthis.h> 12#include <qwhatsthis.h>
5#include "ircsettings.h"
6#include "irctab.h"
7 13
8IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { 14IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
15{
9 setCaption(tr("Settings") ); 16 setCaption(tr("Settings") );
10 m_config = new Config("OpieIRC"); 17 m_config = new Config("OpieIRC");
11 m_config->setGroup("OpieIRC"); 18 m_config->setGroup("OpieIRC");
12 QHBoxLayout *l = new QHBoxLayout(this, 2, 2); 19 QHBoxLayout *l = new QHBoxLayout(this, 2, 2);
13 OTabWidget *tw = new OTabWidget(this); 20 OTabWidget *tw = new OTabWidget(this);
14 l->addWidget(tw); 21 l->addWidget(tw);
15 /* General Configuration */ 22 /* General Configuration */
16 QWidget *genwidget = new QWidget(tw); 23 QWidget *genwidget = new QWidget(tw);
17 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); 24 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0);
18 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); 25 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
19 layout->addWidget(label, 0, 0); 26 layout->addWidget(label, 0, 0);
20 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); 27 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
21 QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this")); 28 QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this"));
22 QIntValidator *validator = new QIntValidator(this); 29 QIntValidator *validator = new QIntValidator(this);
23 validator->setTop(10000); 30 validator->setTop(10000);
24 validator->setBottom(0); 31 validator->setBottom(0);
25 m_lines->setValidator(validator); 32 m_lines->setValidator(validator);
26 layout->addWidget(m_lines, 0, 1); 33 layout->addWidget(m_lines, 0, 1);
27 tw->addTab(genwidget, "opieirc/settings", tr("General")); 34 tw->addTab(genwidget, "opieirc/settings", tr("General"));
28 35
29 /* Color configuration */ 36 /* Color configuration */
30 QScrollView *view = new QScrollView(this); 37 QScrollView *view = new QScrollView(this);
31 view->setResizePolicy(QScrollView::AutoOneFit); 38 view->setResizePolicy(QScrollView::AutoOneFit);
32 view->setFrameStyle( QFrame::NoFrame ); 39 view->setFrameStyle( QFrame::NoFrame );
@@ -49,50 +56,53 @@ IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags)
49 QWhatsThis::add(m_error, tr("Text color to be used to display errors")); 56 QWhatsThis::add(m_error, tr("Text color to be used to display errors"));
50 layout->addWidget(m_error, 2, 1); 57 layout->addWidget(m_error, 2, 1);
51 label = new QLabel(tr("Text written by yourself :"), widget); 58 label = new QLabel(tr("Text written by yourself :"), widget);
52 layout->addWidget(label, 3, 0); 59 layout->addWidget(label, 3, 0);
53 m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); 60 m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000"));
54 QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); 61 QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself"));
55 layout->addWidget(m_self, 3, 1); 62 layout->addWidget(m_self, 3, 1);
56 label = new QLabel(tr("Text written by others :"), widget); 63 label = new QLabel(tr("Text written by others :"), widget);
57 layout->addWidget(label, 4, 0); 64 layout->addWidget(label, 4, 0);
58 m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); 65 m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB"));
59 QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); 66 QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others"));
60 layout->addWidget(m_other, 4, 1); 67 layout->addWidget(m_other, 4, 1);
61 label = new QLabel(tr("Text written by the server :"), widget); 68 label = new QLabel(tr("Text written by the server :"), widget);
62 layout->addWidget(label, 5, 0); 69 layout->addWidget(label, 5, 0);
63 m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); 70 m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF"));
64 QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); 71 QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server"));
65 layout->addWidget(m_server, 5, 1); 72 layout->addWidget(m_server, 5, 1);
66 label = new QLabel(tr("Notifications :"), widget); 73 label = new QLabel(tr("Notifications :"), widget);
67 layout->addWidget(label, 6, 0); 74 layout->addWidget(label, 6, 0);
68 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); 75 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300"));
69 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); 76 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications"));
70 layout->addWidget(m_notification, 6, 1); 77 layout->addWidget(m_notification, 6, 1);
71 tw->addTab(view, "opieirc/colors", tr("Colors")); 78 tw->addTab(view, "opieirc/colors", tr("Colors"));
72 tw->setCurrentTab( genwidget ); 79 tw->setCurrentTab( genwidget );
73 showMaximized(); 80
81 QPEApplication::showDialog( this );
74} 82}
75 83
76void IRCSettings::accept() { 84void IRCSettings::accept()
85{
77 IRCTab::m_backgroundColor = m_background->color().name(); 86 IRCTab::m_backgroundColor = m_background->color().name();
78 IRCTab::m_textColor = m_text->color().name(); 87 IRCTab::m_textColor = m_text->color().name();
79 IRCTab::m_errorColor = m_error->color().name(); 88 IRCTab::m_errorColor = m_error->color().name();
80 IRCTab::m_selfColor = m_self->color().name(); 89 IRCTab::m_selfColor = m_self->color().name();
81 IRCTab::m_otherColor = m_other->color().name(); 90 IRCTab::m_otherColor = m_other->color().name();
82 IRCTab::m_serverColor = m_server->color().name(); 91 IRCTab::m_serverColor = m_server->color().name();
83 IRCTab::m_notificationColor = m_notification->color().name(); 92 IRCTab::m_notificationColor = m_notification->color().name();
84 IRCTab::m_maxLines = m_lines->text().toInt(); 93 IRCTab::m_maxLines = m_lines->text().toInt();
85 m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor); 94 m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor);
86 m_config->writeEntry("TextColor", IRCTab::m_textColor); 95 m_config->writeEntry("TextColor", IRCTab::m_textColor);
87 m_config->writeEntry("ErrorColor", IRCTab::m_errorColor); 96 m_config->writeEntry("ErrorColor", IRCTab::m_errorColor);
88 m_config->writeEntry("SelfColor", IRCTab::m_selfColor); 97 m_config->writeEntry("SelfColor", IRCTab::m_selfColor);
89 m_config->writeEntry("OtherColor", IRCTab::m_otherColor); 98 m_config->writeEntry("OtherColor", IRCTab::m_otherColor);
90 m_config->writeEntry("ServerColor", IRCTab::m_serverColor); 99 m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
91 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); 100 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
92 m_config->writeEntry("Lines", m_lines->text()); 101 m_config->writeEntry("Lines", m_lines->text());
93 QDialog::accept(); 102 QDialog::accept();
94} 103}
95 104
96IRCSettings::~IRCSettings() { 105IRCSettings::~IRCSettings()
106{
97 delete m_config; 107 delete m_config;
98} 108}
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc
index 7d60d6c..9418a20 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.cc
+++ b/noncore/net/opietooth/blue-pin/pindlg.cc
@@ -1,54 +1,65 @@
1 1
2#include <stdio.h> 2#include "pindlg.h"
3
4/* OPIE */
5#include <qpe/config.h>
6#include <qpe/qpeapplication.h>
3 7
8/* QT */
4#include <qcheckbox.h> 9#include <qcheckbox.h>
5#include <qlabel.h> 10#include <qlabel.h>
6#include <qlineedit.h> 11#include <qlineedit.h>
7#include <qtimer.h> 12#include <qtimer.h>
8 13
9#include <qpe/config.h> 14/* STD */
10 15#include <stdio.h>
11#include "pindlg.h"
12 16
13using namespace OpieTooth; 17using namespace OpieTooth;
14 18
15PinDlg::PinDlg( const QString& status, 19PinDlg::PinDlg( const QString& status,
16 const QString& mac, QWidget* parent, 20 const QString& mac, QWidget* parent,
17 const char* name ) 21 const char* name )
18 : PinDlgBase( parent, name, WType_Modal ) 22 : PinDlgBase( parent, name, WType_Modal )
19{ 23{
20 m_mac = mac; 24 m_mac = mac;
21 test( mac ); 25 test( mac );
22 txtStatus->setText(status); 26 txtStatus->setText(status);
23 showMaximized(); 27 QPEApplication::showDialog( this );
24} 28}
25PinDlg::~PinDlg() {
26 29
27} 30PinDlg::~PinDlg()
28void PinDlg::setMac( const QString& mac ) { 31{}
32void PinDlg::setMac( const QString& mac )
33{
29 txtStatus->setText( mac ); 34 txtStatus->setText( mac );
30} 35}
31QString PinDlg::pin() const{ 36QString PinDlg::pin() const
37{
32 return lnePin->text(); 38 return lnePin->text();
33} 39}
34 40
35void PinDlg::test( const QString& mac ) { 41void PinDlg::test( const QString& mac )
36 if (!mac.isEmpty() ) { 42{
43 if (!mac.isEmpty() )
44 {
37 Config cfg("bluepin"); 45 Config cfg("bluepin");
38 cfg.setGroup(mac); 46 cfg.setGroup(mac);
39 lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); 47 lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) );
40 if ( !lnePin->text().isEmpty() ) { 48 if ( !lnePin->text().isEmpty() )
49 {
41 //QTimer::singleShot(100, this, SLOT(accept() ) ); 50 //QTimer::singleShot(100, this, SLOT(accept() ) );
42 } 51 }
43 52
44 } 53 }
45 54
46} 55}
47void PinDlg::accept() { 56void PinDlg::accept()
48 if ( ckbPin->isChecked() ) { 57{
58 if ( ckbPin->isChecked() )
59 {
49 Config cfg("bluepin"); 60 Config cfg("bluepin");
50 cfg.setGroup(m_mac ); 61 cfg.setGroup(m_mac );
51 cfg.writeEntryCrypt("pin", lnePin->text() ); 62 cfg.writeEntryCrypt("pin", lnePin->text() );
52 } 63 }
53 QDialog::accept(); 64 QDialog::accept();
54} 65}
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 2e68984..0ea45d2 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,627 +1,688 @@
1/* 1/*
2 * bluebase.cpp * 2 * bluebase.cpp *
3 * --------------------- 3 * ---------------------
4 * 4 *
5 * copyright : (c) 2002 by Maximilian Reiß 5 * copyright : (c) 2002 by Maximilian Reiß
6 * email : max.reiss@gmx.de 6 * email : max.reiss@gmx.de
7 * 7 *
8 */ 8 */
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20#include "hciconfwrapper.h" 20#include "hciconfwrapper.h"
21#include "devicehandler.h" 21#include "devicehandler.h"
22#include "btconnectionitem.h" 22#include "btconnectionitem.h"
23#include "rfcommassigndialogimpl.h" 23#include "rfcommassigndialogimpl.h"
24 24
25#include <remotedevice.h> 25/* OPIE */
26#include <services.h> 26#include <qpe/qpeapplication.h>
27 27#include <qpe/resource.h>
28#include <stdlib.h> 28#include <qpe/config.h>
29 29
30/* QT */
30#include <qframe.h> 31#include <qframe.h>
31#include <qlabel.h> 32#include <qlabel.h>
32#include <qpushbutton.h> 33#include <qpushbutton.h>
33#include <qlayout.h> 34#include <qlayout.h>
34#include <qvariant.h> 35#include <qvariant.h>
35#include <qimage.h> 36#include <qimage.h>
36#include <qpixmap.h> 37#include <qpixmap.h>
37#include <qtabwidget.h> 38#include <qtabwidget.h>
38#include <qscrollview.h> 39#include <qscrollview.h>
39#include <qvbox.h> 40#include <qvbox.h>
40#include <qmessagebox.h> 41#include <qmessagebox.h>
41#include <qcheckbox.h> 42#include <qcheckbox.h>
42#include <qlineedit.h> 43#include <qlineedit.h>
43#include <qlistview.h> 44#include <qlistview.h>
44#include <qdir.h> 45#include <qdir.h>
45#include <qpopupmenu.h> 46#include <qpopupmenu.h>
46#include <qtimer.h> 47#include <qtimer.h>
47#include <qlist.h> 48#include <qlist.h>
48 49
49#include <qpe/qpeapplication.h> 50/* STD */
50#include <qpe/resource.h> 51#include <remotedevice.h>
51#include <qpe/config.h> 52#include <services.h>
52 53#include <stdlib.h>
53 54
54using namespace OpieTooth; 55using namespace OpieTooth;
55 56
56BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 57BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
57 : BluetoothBase( parent, name, fl ) { 58 : BluetoothBase( parent, name, fl )
59{
58 60
59 m_localDevice = new Manager( "hci0" ); 61 m_localDevice = new Manager( "hci0" );
60 62
61 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 63 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
62 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 64 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
63 65
64 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); 66 connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) );
65// not good since lib is async 67 // not good since lib is async
66 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 68 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
67 // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 69 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
68 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 70 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
69 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 71 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
70 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 72 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
71 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 73 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
72 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 74 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
73 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 75 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
74 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), 76 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
75 this, SLOT( deviceActive( const QString& , bool ) ) ); 77 this, SLOT( deviceActive( const QString& , bool ) ) );
76 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), 78 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
77 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); 79 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
78 connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), 80 connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
79 this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); 81 this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
80 82
81 83
82 // let hold be rightButtonClicked() 84 // let hold be rightButtonClicked()
83 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); 85 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold);
84 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); 86 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold);
85 87
86 //Load all icons needed 88 //Load all icons needed
87 m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); 89 m_offPix = Resource::loadPixmap( "opietooth/notconnected" );
88 m_onPix = Resource::loadPixmap( "opietooth/connected" ); 90 m_onPix = Resource::loadPixmap( "opietooth/connected" );
89 m_findPix = Resource::loadPixmap( "opietooth/find" ); 91 m_findPix = Resource::loadPixmap( "opietooth/find" );
90 92
91 QPalette pal = this->palette(); 93 QPalette pal = this->palette();
92 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 94 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
93 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 95 pal.setColor( QPalette::Active, QColorGroup::Button, col );
94 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 96 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
95 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 97 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
96 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 98 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
97 this->setPalette( pal ); 99 this->setPalette( pal );
98 100
99 setCaption( tr( "Bluetooth Manager" ) ); 101 setCaption( tr( "Bluetooth Manager" ) );
100 102
101 readConfig(); 103 readConfig();
102 initGui(); 104 initGui();
103 105
104 ListView2->setRootIsDecorated(true); 106 ListView2->setRootIsDecorated(true);
105 107
106 108
107 writeToHciConfig(); 109 writeToHciConfig();
108 // search conncetions 110 // search conncetions
109 addConnectedDevices(); 111 addConnectedDevices();
110 addSignalStrength(); 112 addSignalStrength();
111 m_iconLoader = new BTIconLoader(); 113 m_iconLoader = new BTIconLoader();
112 readSavedDevices(); 114 readSavedDevices();
113} 115}
114 116
115/** 117/**
116 * Reads all options from the config file 118 * Reads all options from the config file
117 */ 119 */
118void BlueBase::readConfig() { 120void BlueBase::readConfig()
121{
119 122
120 Config cfg( "bluetoothmanager" ); 123 Config cfg( "bluetoothmanager" );
121 cfg.setGroup( "bluezsettings" ); 124 cfg.setGroup( "bluezsettings" );
122 125
123 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 126 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
124 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 127 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
125 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 128 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
126 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 129 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
127 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 130 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
128 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 131 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
129} 132}
130 133
131/** 134/**
132 * Writes all options to the config file 135 * Writes all options to the config file
133 */ 136 */
134void BlueBase::writeConfig() { 137void BlueBase::writeConfig()
138{
135 139
136 Config cfg( "bluetoothmanager" ); 140 Config cfg( "bluetoothmanager" );
137 cfg.setGroup( "bluezsettings" ); 141 cfg.setGroup( "bluezsettings" );
138 142
139 cfg.writeEntry( "name" , m_deviceName ); 143 cfg.writeEntry( "name" , m_deviceName );
140 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); 144 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
141 cfg.writeEntry( "useEncryption" , m_useEncryption ); 145 cfg.writeEntry( "useEncryption" , m_useEncryption );
142 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); 146 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
143 cfg.writeEntry( "enablePagescan" , m_enablePagescan ); 147 cfg.writeEntry( "enablePagescan" , m_enablePagescan );
144 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); 148 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
145 149
146 writeToHciConfig(); 150 writeToHciConfig();
147} 151}
148 152
149/** 153/**
150 * Modify the hcid.conf file to our needs 154 * Modify the hcid.conf file to our needs
151 */ 155 */
152void BlueBase::writeToHciConfig() { 156void BlueBase::writeToHciConfig()
157{
153 qWarning("writeToHciConfig"); 158 qWarning("writeToHciConfig");
154 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); 159 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
155 hciconf.load(); 160 hciconf.load();
156 hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" ); 161 hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" );
157 hciconf.setName( m_deviceName ); 162 hciconf.setName( m_deviceName );
158 hciconf.setEncrypt( m_useEncryption ); 163 hciconf.setEncrypt( m_useEncryption );
159 hciconf.setAuth( m_enableAuthentification ); 164 hciconf.setAuth( m_enableAuthentification );
160 hciconf.setPscan( m_enablePagescan ); 165 hciconf.setPscan( m_enablePagescan );
161 hciconf.setIscan( m_enableInquiryscan ); 166 hciconf.setIscan( m_enableInquiryscan );
162 hciconf.save(); 167 hciconf.save();
163} 168}
164 169
165 170
166/** 171/**
167 * Read the list of allready known devices 172 * Read the list of allready known devices
168 */ 173 */
169void BlueBase::readSavedDevices() { 174void BlueBase::readSavedDevices()
175{
170 176
171 QValueList<RemoteDevice> loadedDevices; 177 QValueList<RemoteDevice> loadedDevices;
172 DeviceHandler handler; 178 DeviceHandler handler;
173 loadedDevices = handler.load(); 179 loadedDevices = handler.load();
174 180
175 addSearchedDevices( loadedDevices ); 181 addSearchedDevices( loadedDevices );
176} 182}
177 183
178 184
179/** 185/**
180 * Write the list of allready known devices 186 * Write the list of allready known devices
181 */ 187 */
182void BlueBase::writeSavedDevices() { 188void BlueBase::writeSavedDevices()
189{
183 QListViewItemIterator it( ListView2 ); 190 QListViewItemIterator it( ListView2 );
184 BTListItem* item; 191 BTListItem* item;
185 BTDeviceItem* device; 192 BTDeviceItem* device;
186 RemoteDevice::ValueList list; 193 RemoteDevice::ValueList list;
187 for ( ; it.current(); ++it ) { 194 for ( ; it.current(); ++it )
195 {
188 item = (BTListItem*)it.current(); 196 item = (BTListItem*)it.current();
189 if(item->typeId() != BTListItem::Device ) 197 if(item->typeId() != BTListItem::Device )
190 continue; 198 continue;
191 device = (BTDeviceItem*)item; 199 device = (BTDeviceItem*)item;
192 200
193 list.append( device->remoteDevice() ); 201 list.append( device->remoteDevice() );
194 } 202 }
195 /* 203 /*
196 * if not empty save the List through DeviceHandler 204 * if not empty save the List through DeviceHandler
197 */ 205 */
198 if ( list.isEmpty() ) 206 if ( list.isEmpty() )
199 return; 207 return;
200 DeviceHandler handler; 208 DeviceHandler handler;
201 handler.save( list ); 209 handler.save( list );
202} 210}
203 211
204 212
205/** 213/**
206 * Set up the gui 214 * Set up the gui
207 */ 215 */
208void BlueBase::initGui() { 216void BlueBase::initGui()
217{
209 StatusLabel->setText( status() ); // maybe move it to getStatus() 218 StatusLabel->setText( status() ); // maybe move it to getStatus()
210 cryptCheckBox->setChecked( m_useEncryption ); 219 cryptCheckBox->setChecked( m_useEncryption );
211 authCheckBox->setChecked( m_enableAuthentification ); 220 authCheckBox->setChecked( m_enableAuthentification );
212 pagescanCheckBox->setChecked( m_enablePagescan ); 221 pagescanCheckBox->setChecked( m_enablePagescan );
213 inquiryscanCheckBox->setChecked( m_enableInquiryscan ); 222 inquiryscanCheckBox->setChecked( m_enableInquiryscan );
214 deviceNameLine->setText( m_deviceName ); 223 deviceNameLine->setText( m_deviceName );
215 passkeyLine->setText( m_defaultPasskey ); 224 passkeyLine->setText( m_defaultPasskey );
216 // set info tab 225 // set info tab
217 setInfo(); 226 setInfo();
218} 227}
219 228
220 229
221/** 230/**
222 * Get the status informations and returns it 231 * Get the status informations and returns it
223 * @return QString the status informations gathered 232 * @return QString the status informations gathered
224 */ 233 */
225QString BlueBase::status()const{ 234QString BlueBase::status()const
235{
226 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 236 QString infoString = tr( "<b>Device name : </b> Ipaq" );
227 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 237 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
228 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 238 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
229 239
230 return (infoString); 240 return (infoString);
231} 241}
232 242
233 243
234/** 244/**
235 * Read the current values from the gui and invoke writeConfig() 245 * Read the current values from the gui and invoke writeConfig()
236 */ 246 */
237void BlueBase::applyConfigChanges() { 247void BlueBase::applyConfigChanges()
248{
238 m_deviceName = deviceNameLine->text(); 249 m_deviceName = deviceNameLine->text();
239 m_defaultPasskey = passkeyLine->text(); 250 m_defaultPasskey = passkeyLine->text();
240 m_useEncryption = cryptCheckBox->isChecked(); 251 m_useEncryption = cryptCheckBox->isChecked();
241 m_enableAuthentification = authCheckBox->isChecked(); 252 m_enableAuthentification = authCheckBox->isChecked();
242 m_enablePagescan = pagescanCheckBox->isChecked(); 253 m_enablePagescan = pagescanCheckBox->isChecked();
243 m_enableInquiryscan = inquiryscanCheckBox->isChecked(); 254 m_enableInquiryscan = inquiryscanCheckBox->isChecked();
244 255
245 writeConfig(); 256 writeConfig();
246 257
247 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); 258 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
248} 259}
249 260
250/** 261/**
251 * Launch Rfcomm Bind dialog 262 * Launch Rfcomm Bind dialog
252 * 263 *
253 */ 264 */
254void BlueBase::rfcommDialog() { 265void BlueBase::rfcommDialog()
266{
255 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); 267 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp );
256 268
257 rfcommAssign.showMaximized(); 269 if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted )
258 270 {
259 if ( rfcommAssign.exec() == QDialog::Accepted ) {
260 rfcommAssign.saveConfig(); 271 rfcommAssign.saveConfig();
261 } 272 }
262} 273}
263 274
264/** 275/**
265 * Add fresh found devices from scan dialog to the listing 276 * Add fresh found devices from scan dialog to the listing
266 * 277 *
267 */ 278 */
268void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { 279void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices )
280{
269 BTDeviceItem * deviceItem; 281 BTDeviceItem * deviceItem;
270 QValueList<RemoteDevice>::ConstIterator it; 282 QValueList<RemoteDevice>::ConstIterator it;
271 283
272 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { 284 for( it = newDevices.begin(); it != newDevices.end() ; ++it )
285 {
273 286
274 if (find( (*it) )) // is already inserted 287 if (find( (*it) )) // is already inserted
275 continue; 288 continue;
276 289
277 deviceItem = new BTDeviceItem( ListView2 , (*it) ); 290 deviceItem = new BTDeviceItem( ListView2 , (*it) );
278 deviceItem->setPixmap( 1, m_findPix ); 291 deviceItem->setPixmap( 1, m_findPix );
279 deviceItem->setExpandable ( true ); 292 deviceItem->setExpandable ( true );
280 293
281 // look if device is avail. atm, async 294 // look if device is avail. atm, async
282 deviceActive( (*it) ); 295 deviceActive( (*it) );
283 296
284 // ggf auch hier? 297 // ggf auch hier?
285 addServicesToDevice( deviceItem ); 298 addServicesToDevice( deviceItem );
286 } 299 }
287} 300}
288 301
289 302
290/** 303/**
291 * Action that is toggled on entrys on click 304 * Action that is toggled on entrys on click
292 */ 305 */
293void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { 306void BlueBase::startServiceActionClicked( QListViewItem */*item*/ )
294} 307{}
295 308
296 309
297/** 310/**
298 * Action that are toggled on hold (mostly QPopups i guess) 311 * Action that are toggled on hold (mostly QPopups i guess)
299 */ 312 */
300void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { 313void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ )
314{
301 if (!item ) 315 if (!item )
302 return; 316 return;
303 317
304 QPopupMenu *menu = new QPopupMenu(); 318 QPopupMenu *menu = new QPopupMenu();
305 int ret=0; 319 int ret=0;
306 320
307 if ( ((BTListItem*)item)->type() == "device") { 321 if ( ((BTListItem*)item)->type() == "device")
322 {
308 323
309 QPopupMenu *groups = new QPopupMenu(); 324 QPopupMenu *groups = new QPopupMenu();
310 325
311 menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); 326 menu->insertItem( ((BTDeviceItem*)item)->name(),0 );
312 menu->insertSeparator(1); 327 menu->insertSeparator(1);
313 menu->insertItem( tr("rescan sevices"), 2); 328 menu->insertItem( tr("rescan sevices"), 2);
314 menu->insertItem( tr("to group"), groups , 3); 329 menu->insertItem( tr("to group"), groups , 3);
315 menu->insertItem( tr("delete"), 4); 330 menu->insertItem( tr("delete"), 4);
316 331
317 ret = menu->exec( point , 0); 332 ret = menu->exec( point , 0);
318 333
319 switch(ret) { 334 switch(ret)
335 {
320 case -1: 336 case -1:
321 break; 337 break;
322 case 2: 338 case 2:
323 addServicesToDevice( (BTDeviceItem*)item ); 339 addServicesToDevice( (BTDeviceItem*)item );
324 break; 340 break;
325 341
326 case 4: 342 case 4:
327 // deletes childs too 343 // deletes childs too
328 delete item; 344 delete item;
329 break; 345 break;
330 } 346 }
331 delete groups; 347 delete groups;
332 348
333 } 349 }
334 350
335 /* 351 /*
336 * We got service sensitive PopupMenus in our factory 352 * We got service sensitive PopupMenus in our factory
337 * We will create one through the factory and will insert 353 * We will create one through the factory and will insert
338 * our Separator + ShowInfo into the menu or create a new 354 * our Separator + ShowInfo into the menu or create a new
339 * one if the factory returns 0 355 * one if the factory returns 0
340 * PopupMenu deletion is kind of weird. 356 * PopupMenu deletion is kind of weird.
341 * If escaped( -1 ) or any of our items were chosen we'll 357 * If escaped( -1 ) or any of our items were chosen we'll
342 * delete the PopupMenu otherwise it's the responsibility of 358 * delete the PopupMenu otherwise it's the responsibility of
343 * the PopupMenu to delete itself 359 * the PopupMenu to delete itself
344 * 360 *
345 */ 361 */
346 else if ( ((BTListItem*)item)->type() == "service") { 362 else if ( ((BTListItem*)item)->type() == "service")
363 {
347 BTServiceItem* service = (BTServiceItem*)item; 364 BTServiceItem* service = (BTServiceItem*)item;
348 QMap<int, QString> list = service->services().classIdList(); 365 QMap<int, QString> list = service->services().classIdList();
349 QMap<int, QString>::Iterator it = list.begin(); 366 QMap<int, QString>::Iterator it = list.begin();
350 QPopupMenu *popup =0l; 367 QPopupMenu *popup =0l;
351 if ( it != list.end() ) { 368 if ( it != list.end() )
352 qWarning("Searching id %d %s", it.key(), it.data().latin1() ); 369 {
370 qWarning("Searching id %d %s", it.key(), it.data().latin1() );
353 popup = m_popHelper.find( it.key(), 371 popup = m_popHelper.find( it.key(),
354 service->services(), 372 service->services(),
355 (BTDeviceItem*)service->parent() ); 373 (BTDeviceItem*)service->parent() );
356 }else { 374 }
357 qWarning("Empty"); 375 else
358 } 376 {
377 qWarning("Empty");
378 }
359 379
360 if ( popup == 0l ) { 380 if ( popup == 0l )
381 {
361 qWarning("factory returned 0l"); 382 qWarning("factory returned 0l");
362 popup = new QPopupMenu(); 383 popup = new QPopupMenu();
363 } 384 }
364 int test1 = popup->insertItem( tr("Test1:"), 2); 385 int test1 = popup->insertItem( tr("Test1:"), 2);
365 386
366 ret = popup->exec( point ); 387 ret = popup->exec( point );
367 qWarning("returned from exec() "); 388 qWarning("returned from exec() ");
368 if ( ret == -1 ) { 389 if ( ret == -1 )
390 {
369 ; 391 ;
370 } else if ( ret == test1 ) { 392 }
393 else if ( ret == test1 )
394 {
371 ; 395 ;
372 } 396 }
373 delete popup; 397 delete popup;
374 } 398 }
375 delete menu; 399 delete menu;
376} 400}
377 401
378 402
379/** 403/**
380 * Search and display avail. services for a device (on expand from device listing) 404 * Search and display avail. services for a device (on expand from device listing)
381 * @param item the service item returned 405 * @param item the service item returned
382 */ 406 */
383void BlueBase::addServicesToDevice( BTDeviceItem * item ) { 407void BlueBase::addServicesToDevice( BTDeviceItem * item )
408{
384 qDebug("addServicesToDevice"); 409 qDebug("addServicesToDevice");
385 // row of mac adress text(3) 410 // row of mac adress text(3)
386 RemoteDevice device = item->remoteDevice(); 411 RemoteDevice device = item->remoteDevice();
387 m_deviceList.insert( item->mac() , item ); 412 m_deviceList.insert( item->mac() , item );
388 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 413 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
389 m_localDevice->searchServices( device ); 414 m_localDevice->searchServices( device );
390} 415}
391 416
392 417
393/** 418/**
394 * Overloaded. This one it the one that is 419 * Overloaded. This one it the one that is
395 ted to the foundServices signal 420 ted to the foundServices signal
396 * @param device the mac address of the remote device 421 * @param device the mac address of the remote device
397 * @param servicesList the list with the service the device has. 422 * @param servicesList the list with the service the device has.
398 */ 423 */
399void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 424void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList )
425{
400 qDebug("fill services list"); 426 qDebug("fill services list");
401 427
402 QMap<QString,BTDeviceItem*>::Iterator it; 428 QMap<QString,BTDeviceItem*>::Iterator it;
403 BTDeviceItem* deviceItem = 0; 429 BTDeviceItem* deviceItem = 0;
404 430
405 // get the right devices which requested the search 431 // get the right devices which requested the search
406 it = m_deviceList.find( device ); 432 it = m_deviceList.find( device );
407 if( it == m_deviceList.end() ) 433 if( it == m_deviceList.end() )
408 return; 434 return;
409 deviceItem = it.data(); 435 deviceItem = it.data();
410 436
411 // remove previous entries 437 // remove previous entries
412 QList<QListViewItem> tempList; 438 QList<QListViewItem> tempList;
413 tempList.setAutoDelete( true ); 439 tempList.setAutoDelete( true );
414 QListViewItem * child = deviceItem->firstChild(); 440 QListViewItem * child = deviceItem->firstChild();
415 while( child ) { 441 while( child )
416 tempList.append( child ); 442 {
417 child = child->nextSibling(); 443 tempList.append( child );
444 child = child->nextSibling();
418 } 445 }
419 tempList.clear(); 446 tempList.clear();
420 447
421 QValueList<OpieTooth::Services>::Iterator it2; 448 QValueList<OpieTooth::Services>::Iterator it2;
422 BTServiceItem* serviceItem; 449 BTServiceItem* serviceItem;
423 450
424 451
425 if (!servicesList.isEmpty() ) { 452 if (!servicesList.isEmpty() )
453 {
426 // add services 454 // add services
427 QMap<int, QString> list; 455 QMap<int, QString> list;
428 QMap<int, QString>::Iterator classIt; 456 QMap<int, QString>::Iterator classIt;
429 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 457 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 )
458 {
430 serviceItem = new BTServiceItem( deviceItem, (*it2) ); 459 serviceItem = new BTServiceItem( deviceItem, (*it2) );
431 list = (*it2).classIdList(); 460 list = (*it2).classIdList();
432 classIt = list.begin(); 461 classIt = list.begin();
433 int classId=0; 462 int classId=0;
434 if ( classIt != list.end() ) { 463 if ( classIt != list.end() )
464 {
435 classId = classIt.key(); 465 classId = classIt.key();
436 } 466 }
437 467
438 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 468 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
439 } 469 }
440 } else { 470 }
471 else
472 {
441 Services s1; 473 Services s1;
442 s1.setServiceName( tr("no services found") ); 474 s1.setServiceName( tr("no services found") );
443 serviceItem = new BTServiceItem( deviceItem, s1 ); 475 serviceItem = new BTServiceItem( deviceItem, s1 );
444 } 476 }
445 // now remove them from the list 477 // now remove them from the list
446 m_deviceList.remove( it ); 478 m_deviceList.remove( it );
447} 479}
448 480
449 481
450 482
451 483
452 484
453void BlueBase::addSignalStrength() { 485void BlueBase::addSignalStrength()
486{
454 487
455 QListViewItemIterator it( ListView4 ); 488 QListViewItemIterator it( ListView4 );
456 for ( ; it.current(); ++it ) { 489 for ( ; it.current(); ++it )
457 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); 490 {
458 } 491 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
492 }
459 493
460 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); 494 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
461} 495}
462 496
463void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { 497void BlueBase::addSignalStrength( const QString& mac, const QString& strength )
498{
464 499
465 QListViewItemIterator it( ListView4 ); 500 QListViewItemIterator it( ListView4 );
466 for ( ; it.current(); ++it ) { 501 for ( ; it.current(); ++it )
467 if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { 502 {
468 ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); 503 if( ((BTConnectionItem*)it.current())->connection().mac() == mac )
469 } 504 {
470 } 505 ((BTConnectionItem*)it.current() )->setSignalStrength( strength );
506 }
507 }
471} 508}
472 509
473/** 510/**
474 * Add the existing connections (pairs) to the connections tab. 511 * Add the existing connections (pairs) to the connections tab.
475 * This one triggers the search 512 * This one triggers the search
476 */ 513 */
477void BlueBase::addConnectedDevices() { 514void BlueBase::addConnectedDevices()
478 m_localDevice->searchConnections(); 515{
516 m_localDevice->searchConnections();
479} 517}
480 518
481/** 519/**
482 * This adds the found connections to the connection tab. 520 * This adds the found connections to the connection tab.
483 * @param connectionList the ValueList with all current connections 521 * @param connectionList the ValueList with all current connections
484 */ 522 */
485void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { 523void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList )
524{
486 525
487 QValueList<OpieTooth::ConnectionState>::Iterator it; 526 QValueList<OpieTooth::ConnectionState>::Iterator it;
488 BTConnectionItem * connectionItem; 527 BTConnectionItem * connectionItem;
489 528
490 if ( !connectionList.isEmpty() ) { 529 if ( !connectionList.isEmpty() )
530 {
491 531
492 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 532 for (it = connectionList.begin(); it != connectionList.end(); ++it)
533 {
493 534
494 QListViewItemIterator it2( ListView4 ); 535 QListViewItemIterator it2( ListView4 );
495 bool found = false; 536 bool found = false;
496 for ( ; it2.current(); ++it2 ) { 537 for ( ; it2.current(); ++it2 )
497 if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { 538 {
498 found = true; 539 if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() )
499 } 540 {
500 } 541 found = true;
542 }
543 }
501 544
502 if ( found == false ) { 545 if ( found == false )
503 connectionItem = new BTConnectionItem( ListView4, (*it) ); 546 {
547 connectionItem = new BTConnectionItem( ListView4, (*it) );
504 548
505 if( m_deviceList.find((*it).mac()).data() ) { 549 if( m_deviceList.find((*it).mac()).data() )
506 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); 550 {
507 } 551 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
508 } 552 }
553 }
509 554
510 } 555 }
511 556
512 QListViewItemIterator it2( ListView4 ); 557 QListViewItemIterator it2( ListView4 );
513 for ( ; it2.current(); ++it2 ) { 558 for ( ; it2.current(); ++it2 )
514 bool found = false; 559 {
515 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 560 bool found = false;
516 if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { 561 for (it = connectionList.begin(); it != connectionList.end(); ++it)
517 found = true; 562 {
518 } 563 if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() )
564 {
565 found = true;
566 }
519 } 567 }
520 568
521 if ( !found ) { 569 if ( !found )
522 delete it2.current(); 570 {
523 } 571 delete it2.current();
572 }
524 573
525 } 574 }
526 575
527 576
528 } else { 577 }
578 else
579 {
529 ListView4->clear(); 580 ListView4->clear();
530 ConnectionState con; 581 ConnectionState con;
531 con.setMac( tr("No connections found") ); 582 con.setMac( tr("No connections found") );
532 connectionItem = new BTConnectionItem( ListView4 , con ); 583 connectionItem = new BTConnectionItem( ListView4 , con );
533 } 584 }
534 585
535 // recall connection search after some time 586 // recall connection search after some time
536 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); 587 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) );
537} 588}
538 589
539 590
540/** 591/**
541 * Find out if a device can currently be reached 592 * Find out if a device can currently be reached
542 * @param device 593 * @param device
543 */ 594 */
544void BlueBase::deviceActive( const RemoteDevice &device ) { 595void BlueBase::deviceActive( const RemoteDevice &device )
596{
545 // search by mac, async, gets a signal back 597 // search by mac, async, gets a signal back
546 // We should have a BTDeviceItem there or where does it get added to the map -zecke 598 // We should have a BTDeviceItem there or where does it get added to the map -zecke
547 m_localDevice->isAvailable( device.mac() ); 599 m_localDevice->isAvailable( device.mac() );
548} 600}
549 601
550 602
551/** 603/**
552 * The signal catcher. Set the avail. status on device. 604 * The signal catcher. Set the avail. status on device.
553 * @param device - the mac address 605 * @param device - the mac address
554 * @param connected - if it is avail. or not 606 * @param connected - if it is avail. or not
555 */ 607 */
556void BlueBase::deviceActive( const QString& device, bool connected ) { 608void BlueBase::deviceActive( const QString& device, bool connected )
609{
557 qDebug("deviceActive slot"); 610 qDebug("deviceActive slot");
558 611
559 QMap<QString,BTDeviceItem*>::Iterator it; 612 QMap<QString,BTDeviceItem*>::Iterator it;
560 613
561 it = m_deviceList.find( device ); 614 it = m_deviceList.find( device );
562 if( it == m_deviceList.end() ) 615 if( it == m_deviceList.end() )
563 return; 616 return;
564 617
565 BTDeviceItem* deviceItem = it.data(); 618 BTDeviceItem* deviceItem = it.data();
566 619
567 620
568 if ( connected ) { 621 if ( connected )
622 {
569 deviceItem->setPixmap( 1, m_onPix ); 623 deviceItem->setPixmap( 1, m_onPix );
570 } else { 624 }
625 else
626 {
571 deviceItem->setPixmap( 1, m_offPix ); 627 deviceItem->setPixmap( 1, m_offPix );
572 } 628 }
573 m_deviceList.remove( it ); 629 m_deviceList.remove( it );
574} 630}
575 631
576 632
577/** 633/**
578 * Open the "scan for devices" dialog 634 * Open the "scan for devices" dialog
579 */ 635 */
580void BlueBase::startScan() { 636void BlueBase::startScan()
637{
581 ScanDialog *scan = new ScanDialog( this, "ScanDialog", 638 ScanDialog *scan = new ScanDialog( this, "ScanDialog",
582 true, WDestructiveClose ); 639 true, WDestructiveClose );
583 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), 640 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ),
584 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); 641 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) );
585 642
586 scan->showMaximized(); 643 QPEApplication::showDialog( scan );
587} 644}
588 645
589 646
590/** 647/**
591 * Set the informations about the local device in information Tab 648 * Set the informations about the local device in information Tab
592 */ 649 */
593void BlueBase::setInfo() { 650void BlueBase::setInfo()
651{
594 StatusLabel->setText( status() ); 652 StatusLabel->setText( status() );
595} 653}
596 654
597 655
598/** 656/**
599 * Decontructor 657 * Decontructor
600 */ 658 */
601BlueBase::~BlueBase() { 659BlueBase::~BlueBase()
660{
602 writeSavedDevices(); 661 writeSavedDevices();
603 delete m_iconLoader; 662 delete m_iconLoader;
604} 663}
605 664
606 665
607/** 666/**
608 * find searches the ListView for a BTDeviceItem containig 667 * find searches the ListView for a BTDeviceItem containig
609 * the same Device if found return true else false 668 * the same Device if found return true else false
610 * @param dev RemoteDevice to find 669 * @param dev RemoteDevice to find
611 * @return returns true if found 670 * @return returns true if found
612 */ 671 */
613bool BlueBase::find( const RemoteDevice& rem ) { 672bool BlueBase::find( const RemoteDevice& rem )
673{
614 QListViewItemIterator it( ListView2 ); 674 QListViewItemIterator it( ListView2 );
615 BTListItem* item; 675 BTListItem* item;
616 BTDeviceItem* device; 676 BTDeviceItem* device;
617 for (; it.current(); ++it ) { 677 for (; it.current(); ++it )
678 {
618 item = (BTListItem*) it.current(); 679 item = (BTListItem*) it.current();
619 if ( item->typeId() != BTListItem::Device ) 680 if ( item->typeId() != BTListItem::Device )
620 continue; 681 continue;
621 682
622 device = (BTDeviceItem*)item; 683 device = (BTDeviceItem*)item;
623 if ( rem.equals( device->remoteDevice() ) ) 684 if ( rem.equals( device->remoteDevice() ) )
624 return true; 685 return true;
625 } 686 }
626 return false; // not found 687 return false; // not found
627} 688}
diff --git a/noncore/net/opietooth/manager/obexpopup.cpp b/noncore/net/opietooth/manager/obexpopup.cpp
index a550648..d147d52 100644
--- a/noncore/net/opietooth/manager/obexpopup.cpp
+++ b/noncore/net/opietooth/manager/obexpopup.cpp
@@ -1,41 +1,45 @@
1 1
2#include <qtimer.h>
3
4#include "obexdialog.h" 2#include "obexdialog.h"
5#include "obexpopup.h" 3#include "obexpopup.h"
6 4
5/* OPIE */
6#include <qpe/qpeapplication.h>
7
8/* QT */
9#include <qtimer.h>
10
7using namespace OpieTooth; 11using namespace OpieTooth;
8 12
9/* 13/*
10 * c'tor init the QAction 14 * c'tor init the QAction
11 */ 15 */
12ObexPopup::ObexPopup() 16ObexPopup::ObexPopup()
13 : QPopupMenu() { 17 : QPopupMenu()
18{
14 qWarning("RfcCommPopup c'tor"); 19 qWarning("RfcCommPopup c'tor");
15 20
16 QAction* a; 21 QAction* a;
17 22
18 /* connect action */ 23 /* connect action */
19 a = new QAction( ); // so it's get deleted 24 a = new QAction( ); // so it's get deleted
20 a->setText("Push file"); 25 a->setText("Push file");
21 a->addTo( this ); 26 a->addTo( this );
22 connect( a, SIGNAL( activated() ), 27 connect( a, SIGNAL( activated() ),
23 this, SLOT( slotPush() ) ); 28 this, SLOT( slotPush() ) );
24}; 29};
25 30
26 31
27ObexPopup::~ObexPopup() { 32ObexPopup::~ObexPopup()
28} 33{}
29 34
30 35
31void ObexPopup::slotPush() { 36void ObexPopup::slotPush()
37{
32 38
33 qWarning("push something"); 39 qWarning("push something");
34 40
35
36 ObexDialog obexDialog; 41 ObexDialog obexDialog;
37 obexDialog.showMaximized(); 42 QPEApplication::execDialog( &obexDialog );
38 obexDialog.exec();
39} 43}
40 44
41 45
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
index b5cc074..fc76301 100644
--- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
+++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
@@ -1,120 +1,135 @@
1 1
2#include "rfcommassigndialogimpl.h" 2#include "rfcommassigndialogimpl.h"
3#include "rfcommassigndialogitem.h" 3#include "rfcommassigndialogitem.h"
4#include "rfcommconfhandler.h" 4#include "rfcommconfhandler.h"
5 5
6/* OPIE */
6#include <qpe/config.h> 7#include <qpe/config.h>
8#include <qpe/qpeapplication.h>
7 9
10/* QT */
8#include <qlayout.h> 11#include <qlayout.h>
9 12
10using namespace OpieTooth; 13using namespace OpieTooth;
11 14
12// TODO: write only the file in bluebase? 15// TODO: write only the file in bluebase?
13// muss rfcommd dann neu gestartet werden 16// muss rfcommd dann neu gestartet werden
14// sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es? 17// sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es?
15 18
16 19
17RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 20RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
18 : RfcommAssignDialogBase( parent, name, modal, fl ) { 21 : RfcommAssignDialogBase( parent, name, modal, fl )
22{
19 23
20 m_range = 5; 24 m_range = 5;
21 25
22 m_scrollView = new QScrollView( this ); 26 m_scrollView = new QScrollView( this );
23 m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); 27 m_scrollView->setResizePolicy( QScrollView::AutoOneFit );
24 m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); 28 m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff );
25 29
26 RfcommAssignDialogBaseLayout->addWidget( m_scrollView ); 30 RfcommAssignDialogBaseLayout->addWidget( m_scrollView );
27 31
28 m_box = new QVBox( m_scrollView->viewport() ); 32 m_box = new QVBox( m_scrollView->viewport() );
29 m_scrollView->addChild( m_box ); 33 m_scrollView->addChild( m_box );
30 34
31 confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); 35 confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" );
32 36
33 loadConfig(); 37 loadConfig();
34} 38}
35 39
36RfcommAssignDialog::~RfcommAssignDialog() { 40RfcommAssignDialog::~RfcommAssignDialog()
37 if ( confHandler ) { 41{
42 if ( confHandler )
43 {
38 delete confHandler; 44 delete confHandler;
39 } 45 }
40} 46}
41 47
42 48
43void RfcommAssignDialog::newDevice( const QString & mac ) { 49void RfcommAssignDialog::newDevice( const QString & mac )
50{
44 51
45 for ( int i = 0 ; i < m_range; i++ ) { 52 for ( int i = 0 ; i < m_range; i++ )
53 {
46 54
47 QMap<QString, RfCommConfObject*>::Iterator it; 55 QMap<QString, RfCommConfObject*>::Iterator it;
48 it = confHandler->foundEntries().find( QString("%1").arg( i ) ); 56 it = confHandler->foundEntries().find( QString("%1").arg( i ) );
49 // make sure that rfcommX is not assigned yet 57 // make sure that rfcommX is not assigned yet
50 if ( it == confHandler->foundEntries().end() ) { 58 if ( it == confHandler->foundEntries().end() )
59 {
51 QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); 60 QDialog dialog( this, "newdevice", true, WStyle_ContextHelp );
52 dialog.showMaximized(); 61
53 RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); 62 RfcommDialogItem *newDev = new RfcommDialogItem( &dialog );
54 newDev->setIdent( i ); 63 newDev->setIdent( i );
55 newDev->setMac( mac ); 64 newDev->setMac( mac );
56 65
57 if ( dialog.exec() == QDialog::Accepted ) { 66 if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted )
67 {
58 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); 68 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box );
59 m_itemList.insert( i , rfcomm ); 69 m_itemList.insert( i , rfcomm );
60 rfcomm->setIdent( i ); 70 rfcomm->setIdent( i );
61 rfcomm->setMac( mac ); 71 rfcomm->setMac( mac );
62 rfcomm->setChannel( newDev->channel() ); 72 rfcomm->setChannel( newDev->channel() );
63 rfcomm->setComment( newDev->comment() ); 73 rfcomm->setComment( newDev->comment() );
64 qDebug( "New device set up" ); 74 qDebug( "New device set up" );
65 } 75 }
66 } 76 }
67 } 77 }
68} 78}
69 79
70void RfcommAssignDialog::loadConfig() { 80void RfcommAssignDialog::loadConfig()
81{
71 82
72 //Config cfg( "bluetoothmanager-rfcommbind" ); 83 //Config cfg( "bluetoothmanager-rfcommbind" );
73 84
74 for ( int i = 0 ; i < m_range; i++ ) { 85 for ( int i = 0 ; i < m_range; i++ )
86 {
75 // cfg.setGroup( QString("%1").arg( i ) ); 87 // cfg.setGroup( QString("%1").arg( i ) );
76 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); 88 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box );
77 m_itemList.insert( i , rfcomm ); 89 m_itemList.insert( i , rfcomm );
78 rfcomm->setIdent( i ); 90 rfcomm->setIdent( i );
79 QMap<QString, RfCommConfObject*>::Iterator it; 91 QMap<QString, RfCommConfObject*>::Iterator it;
80 it = confHandler->foundEntries().find( QString("%1").arg( i ) ); 92 it = confHandler->foundEntries().find( QString("%1").arg( i ) );
81 if ( it != confHandler->foundEntries().end() ) { 93 if ( it != confHandler->foundEntries().end() )
94 {
82 qDebug( "Found key in foundEntries() " ); 95 qDebug( "Found key in foundEntries() " );
83 rfcomm->setMac( it.data()->mac() ); 96 rfcomm->setMac( it.data()->mac() );
84 rfcomm->setChannel( it.data()->channel() ); 97 rfcomm->setChannel( it.data()->channel() );
85 rfcomm->setComment( it.data()->comment() ); 98 rfcomm->setComment( it.data()->comment() );
86 } 99 }
87 /* Use rfcomm.conf directly for now 100 /* Use rfcomm.conf directly for now
88 * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); 101 * rfcomm->setMac( cfg.readEntry( "mac", "" ) );
89 * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); 102 * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) );
90 * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); 103 * rfcomm->setComment( cfg.readEntry( "comment", "" ) );
91 */ 104 */
92 } 105 }
93} 106}
94 107
95 108
96void RfcommAssignDialog::saveConfig() { 109void RfcommAssignDialog::saveConfig()
110{
97 111
98 //Config cfg( "bluetoothmanager-rfcommbind" ); 112 //Config cfg( "bluetoothmanager-rfcommbind" );
99 113
100 QMap< int, RfcommDialogItem*>::Iterator it; 114 QMap< int, RfcommDialogItem*>::Iterator it;
101 115
102 QMap< QString, RfCommConfObject*> outMap; 116 QMap< QString, RfCommConfObject*> outMap;
103 117
104 for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) { 118 for( it = m_itemList.begin(); it != m_itemList.end(); ++it )
119 {
105 120
106 //cfg.setGroup( QString("%1").arg( it.key() ) ); 121 //cfg.setGroup( QString("%1").arg( it.key() ) );
107 RfcommDialogItem *rfcomm = it.data(); 122 RfcommDialogItem *rfcomm = it.data();
108 123
109 124
110 outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); 125 outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) );
111 126
112 127
113 //cfg.writeEntry( "mac", rfcomm->mac() ); 128 //cfg.writeEntry( "mac", rfcomm->mac() );
114 //cfg.writeEntry( "channel", rfcomm->channel() ); 129 //cfg.writeEntry( "channel", rfcomm->channel() );
115 //cfg.writeEntry( "comment", rfcomm->comment() ); 130 //cfg.writeEntry( "comment", rfcomm->comment() );
116 } 131 }
117 132
118 confHandler->save( outMap ); 133 confHandler->save( outMap );
119 134
120} 135}
diff --git a/noncore/net/opietooth/manager/rfcpopup.cpp b/noncore/net/opietooth/manager/rfcpopup.cpp
index d95f14b..04bfe48 100644
--- a/noncore/net/opietooth/manager/rfcpopup.cpp
+++ b/noncore/net/opietooth/manager/rfcpopup.cpp
@@ -1,96 +1,103 @@
1 1
2#include <qtimer.h>
3
4#include "pppdialog.h" 2#include "pppdialog.h"
5#include "rfcpopup.h" 3#include "rfcpopup.h"
6#include "rfcommassigndialogimpl.h" 4#include "rfcommassigndialogimpl.h"
7 5
6/* OPIE */
7#include <qpe/qpeapplication.h>
8
9/* QT */
10#include <qtimer.h>
11
8using namespace OpieTooth; 12using namespace OpieTooth;
9 13
10/* 14/*
11 * c'tor init the QAction 15 * c'tor init the QAction
12 */ 16 */
13RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) 17RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item )
14 : QPopupMenu() { 18 : QPopupMenu()
19{
15 qWarning("RfcCommPopup c'tor"); 20 qWarning("RfcCommPopup c'tor");
16 21
17 QAction* a; 22 QAction* a;
18 23
19 24
20 m_item = item; 25 m_item = item;
21 26
22 /* connect action */ 27 /* connect action */
23 a = new QAction( ); // so it's get deleted 28 a = new QAction( ); // so it's get deleted
24 a->setText("Connect"); 29 a->setText("Connect");
25 a->addTo( this ); 30 a->addTo( this );
26 connect( a, SIGNAL( activated() ), 31 connect( a, SIGNAL( activated() ),
27 this, SLOT( slotConnect() ) ); 32 this, SLOT( slotConnect() ) );
28 33
29 34
30 /* disconnect action */ 35 /* disconnect action */
31 a = new QAction( ); 36 a = new QAction( );
32 a->setText("Disconnect"); 37 a->setText("Disconnect");
33 a->addTo( this ); 38 a->addTo( this );
34 connect( a, SIGNAL( activated() ) , 39 connect( a, SIGNAL( activated() ) ,
35 this, SLOT( slotDisconnect() ) ); 40 this, SLOT( slotDisconnect() ) );
36 41
37 42
38 /* foo action */ 43 /* foo action */
39 a = new QAction( ); 44 a = new QAction( );
40 a->setText("Bind table"); 45 a->setText("Bind table");
41 a->addTo( this ); 46 a->addTo( this );
42 connect( a, SIGNAL( activated() ), 47 connect( a, SIGNAL( activated() ),
43 this, SLOT( slotBind() ) ); 48 this, SLOT( slotBind() ) );
44 49
45 50
46 /* bar action */ 51 /* bar action */
47 a = new QAction( ); 52 a = new QAction( );
48 a->setText( "Bar" ); 53 a->setText( "Bar" );
49 a->addTo( this ); 54 a->addTo( this );
50 connect( a, SIGNAL( activated() ), 55 connect( a, SIGNAL( activated() ),
51 this, SLOT( slotBar() ) ); 56 this, SLOT( slotBar() ) );
52 57
53}; 58};
54 59
55 60
56RfcCommPopup::~RfcCommPopup() { 61RfcCommPopup::~RfcCommPopup()
57/* delete m_con; 62{
58 delete m_dis; 63 /* delete m_con;
59 delete m_foo; 64 delete m_dis;
60 delete m_bar; */ 65 delete m_foo;
66 delete m_bar; */
61} 67}
62 68
63 69
64void RfcCommPopup::slotConnect() { 70void RfcCommPopup::slotConnect()
71{
65 72
66 qWarning("connect"); 73 qWarning("connect");
67 74
68
69
70 PPPDialog pppDialog; 75 PPPDialog pppDialog;
71 pppDialog.showMaximized(); 76 QPEApplication::execDialog( &pppDialog );
72 pppDialog.exec();
73} 77}
74 78
75 79
76void RfcCommPopup::slotDisconnect() { 80void RfcCommPopup::slotDisconnect()
81{
77 qWarning("slot disconnected"); 82 qWarning("slot disconnected");
78} 83}
79 84
80 85
81void RfcCommPopup::slotBind() { 86void RfcCommPopup::slotBind()
87{
82 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); 88 RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp );
83 89
84 rfcommAssign.showMaximized();
85 rfcommAssign.newDevice( m_item->mac() ); 90 rfcommAssign.newDevice( m_item->mac() );
86 91
87 if ( rfcommAssign.exec() == QDialog::Accepted ) { 92 if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted )
93 {
88 rfcommAssign.saveConfig(); 94 rfcommAssign.saveConfig();
89 } 95 }
90} 96}
91 97
92 98
93void RfcCommPopup::slotBar() { 99void RfcCommPopup::slotBar()
100{
94 qWarning("slotBar"); 101 qWarning("slotBar");
95}; 102};
96 103
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 3729ed0..95a8294 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -156,52 +156,49 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n
156 mb->insertItem( d ); 156 mb->insertItem( d );
157 mb->insertItem( uploadButton ); 157 mb->insertItem( uploadButton );
158 mb->insertItem( stopButton ); 158 mb->insertItem( stopButton );
159 mb->insertItem( startButton ); 159 mb->insertItem( startButton );
160 #endif 160 #endif
161 161
162 updateToolButtonState(); 162 updateToolButtonState();
163 163
164 // setup status bar (for now only on X11) 164 // setup status bar (for now only on X11)
165 165
166 #ifndef QWS 166 #ifndef QWS
167 statusBar()->message( tr( "Ready." ) ); 167 statusBar()->message( tr( "Ready." ) );
168 #endif 168 #endif
169 169
170 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); 170 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) );
171 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); 171 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) );
172}; 172};
173 173
174 174
175 175
176void WellenreiterMainWindow::showConfigure() 176void WellenreiterMainWindow::showConfigure()
177{ 177{
178 qDebug( "show configure..." ); 178 qDebug( "show configure..." );
179 cw->setCaption( tr( "Configure" ) ); 179 cw->setCaption( tr( "Configure" ) );
180 #ifdef QWS 180 int result = QPEApplication::execDialog( cw );
181 cw->showMaximized();
182 #endif
183 int result = cw->exec();
184 181
185 if ( result ) updateToolButtonState(); 182 if ( result ) updateToolButtonState();
186} 183}
187 184
188 185
189void WellenreiterMainWindow::updateToolButtonState() 186void WellenreiterMainWindow::updateToolButtonState()
190{ 187{
191 const QString& interface = cw->interfaceName->currentText(); 188 const QString& interface = cw->interfaceName->currentText();
192 const int cardtype = cw->driverType(); 189 const int cardtype = cw->driverType();
193 190
194 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 191 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
195 { 192 {
196 startButton->setEnabled( true ); 193 startButton->setEnabled( true );
197 menuBar()->setItemEnabled( startID, true ); 194 menuBar()->setItemEnabled( startID, true );
198 } 195 }
199 else 196 else
200 { 197 {
201 startButton->setEnabled( false ); 198 startButton->setEnabled( false );
202 menuBar()->setItemEnabled( startID, false ); 199 menuBar()->setItemEnabled( startID, false );
203 } 200 }
204} 201}
205 202
206 203
207void WellenreiterMainWindow::changedSniffingState() 204void WellenreiterMainWindow::changedSniffingState()