summaryrefslogtreecommitdiff
authorzecke <zecke>2004-03-14 13:22:42 (UTC)
committer zecke <zecke>2004-03-14 13:22:42 (UTC)
commit0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44 (patch) (unidiff)
treef6a68afa76a9be4099c3de7a286caeadd250c966
parentd9d68663164078b8dbdbfe70d291291b9fd5aacf (diff)
downloadopie-0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44.zip
opie-0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44.tar.gz
opie-0f7217afa7cdcb108dd2afba0ff6b42c97ab6f44.tar.bz2
Convert net to ODP and QtAUX
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/linphone/main.cpp4
-rw-r--r--noncore/net/mail/accountitem.cpp5
-rw-r--r--noncore/net/mail/accountitem.h56
-rw-r--r--noncore/net/mail/accountview.cpp1
-rw-r--r--noncore/net/mail/accountview.h4
-rw-r--r--noncore/net/mail/composemail.cpp8
-rw-r--r--noncore/net/mail/composemail.h2
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/abstractmail.h12
-rw-r--r--noncore/net/mail/libmailwrapper/generatemail.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/generatemail.h4
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/genericwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/imapwrapper.h12
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/mailtypes.h4
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/mailwrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.cpp5
-rw-r--r--noncore/net/mail/libmailwrapper/mboxwrapper.h8
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.cpp13
-rw-r--r--noncore/net/mail/libmailwrapper/mhwrapper.h20
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/nntpwrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.cpp7
-rw-r--r--noncore/net/mail/libmailwrapper/pop3wrapper.h6
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/smtpwrapper.h4
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.cpp3
-rw-r--r--noncore/net/mail/libmailwrapper/storemail.h2
-rw-r--r--noncore/net/mail/mail.pro2
-rw-r--r--noncore/net/mail/main.cpp2
-rw-r--r--noncore/net/mail/taskbarapplet/mailapplet.cpp2
-rw-r--r--noncore/net/mail/viewmail.cpp3
-rw-r--r--noncore/net/mail/viewmailbase.cpp2
-rw-r--r--noncore/net/opieftp/main.cpp2
-rw-r--r--noncore/net/opieirc/config.in2
-rw-r--r--noncore/net/opieirc/ircsettings.cpp6
-rw-r--r--noncore/net/opieirc/ircsettings.h16
-rw-r--r--noncore/net/opieirc/main.cpp3
-rw-r--r--noncore/net/opieirc/opieirc.pro2
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp2
-rw-r--r--noncore/net/opietooth/lib/device.cc12
-rw-r--r--noncore/net/opietooth/lib/device.h12
-rw-r--r--noncore/net/opietooth/lib/manager.cc22
-rw-r--r--noncore/net/opietooth/lib/manager.h26
-rw-r--r--noncore/net/opietooth/lib/startdunconnection.cpp6
-rw-r--r--noncore/net/opietooth/lib/startdunconnection.h8
-rw-r--r--noncore/net/opietooth/lib/startpanconnection.cpp10
-rw-r--r--noncore/net/opietooth/lib/startpanconnection.h8
-rw-r--r--noncore/net/opietooth/manager/main.cpp4
-rw-r--r--noncore/net/opietooth/manager/obexdialog.cpp7
-rw-r--r--noncore/net/opietooth/manager/obexdialog.h2
-rw-r--r--noncore/net/opietooth/manager/pppdialog.cpp6
-rw-r--r--noncore/net/opietooth/manager/pppdialog.h4
-rw-r--r--noncore/net/ubrowser/main.cpp4
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp6
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp3
-rw-r--r--noncore/net/wellenreiter/gui/mainwindow.cpp5
-rw-r--r--noncore/net/wellenreiter/gui/packetview.cpp3
-rw-r--r--noncore/net/wellenreiter/gui/packetview.h6
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.cpp6
-rw-r--r--noncore/net/wellenreiter/gui/scanlist.h26
-rw-r--r--noncore/net/wellenreiter/gui/statwindow.cpp3
-rw-r--r--noncore/net/wellenreiter/gui/statwindow.h4
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp10
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h56
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.cpp3
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiterbase.h2
70 files changed, 310 insertions, 228 deletions
diff --git a/noncore/net/linphone/main.cpp b/noncore/net/linphone/main.cpp
index 9146fee..6368708 100644
--- a/noncore/net/linphone/main.cpp
+++ b/noncore/net/linphone/main.cpp
@@ -1,22 +1,24 @@
1/*************************************************************************** 1/***************************************************************************
2 main-opie.cpp - description 2 main-opie.cpp - description
3 ------------------- 3 -------------------
4 begin : ven mai 23 19:26:00 CEST 2003 4 begin : ven mai 23 19:26:00 CEST 2003
5 copyright : (C) 2003 by Simon Morlat 5 copyright : (C) 2003 by Simon Morlat
6 email : simon.morlat@linphone.org 6 email : simon.morlat@linphone.org
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#include <opie/oapplicationfactory.h> 17#include <opie2/oapplicationfactory.h>
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20
21using namespace Opie::Core;
20OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 22OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
21 23
22 24
diff --git a/noncore/net/mail/accountitem.cpp b/noncore/net/mail/accountitem.cpp
index 9a09c18..e4bb6c5 100644
--- a/noncore/net/mail/accountitem.cpp
+++ b/noncore/net/mail/accountitem.cpp
@@ -1,244 +1,245 @@
1 1
2#include "accountitem.h" 2#include "accountitem.h"
3#include "accountview.h" 3#include "accountview.h"
4#include "newmaildir.h" 4#include "newmaildir.h"
5#include "nntpgroupsdlg.h" 5#include "nntpgroupsdlg.h"
6#include "defines.h" 6#include "defines.h"
7 7
8/* OPIE */ 8/* OPIE */
9#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
10#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
11#include <libmailwrapper/mailwrapper.h> 11#include <libmailwrapper/mailwrapper.h>
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13 13
14/* QT */ 14/* QT */
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16#include <qmessagebox.h> 16#include <qmessagebox.h>
17 17
18using namespace Opie::Core;
18#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );} 19#define SETPIX(x) if (!account->getOffline()) {setPixmap( 0,x);} else {setPixmap( 0, PIXMAP_OFFLINE );}
19/** 20/**
20 * POP3 Account stuff 21 * POP3 Account stuff
21 */ 22 */
22POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent ) 23POP3viewItem::POP3viewItem( POP3account *a, AccountView *parent )
23 : AccountViewItem( parent ) 24 : AccountViewItem( parent )
24{ 25{
25 account = a; 26 account = a;
26 wrapper = AbstractMail::getWrapper( account ); 27 wrapper = AbstractMail::getWrapper( account );
27 SETPIX(PIXMAP_POP3FOLDER); 28 SETPIX(PIXMAP_POP3FOLDER);
28#if 0 29#if 0
29 if (!account->getOffline()) 30 if (!account->getOffline())
30 { 31 {
31 setPixmap( 0, ); 32 setPixmap( 0, );
32 } 33 }
33 else 34 else
34 { 35 {
35 setPixmap( 0, PIXMAP_OFFLINE ); 36 setPixmap( 0, PIXMAP_OFFLINE );
36 } 37 }
37#endif 38#endif
38 setText( 0, account->getAccountName() ); 39 setText( 0, account->getAccountName() );
39 setOpen( true ); 40 setOpen( true );
40} 41}
41 42
42POP3viewItem::~POP3viewItem() 43POP3viewItem::~POP3viewItem()
43{ 44{
44 delete wrapper; 45 delete wrapper;
45} 46}
46 47
47AbstractMail *POP3viewItem::getWrapper() 48AbstractMail *POP3viewItem::getWrapper()
48{ 49{
49 return wrapper; 50 return wrapper;
50} 51}
51 52
52void POP3viewItem::refresh(QValueList<Opie::OSmartPointer<RecMail> > & ) 53void POP3viewItem::refresh(QValueList<Opie::Core::OSmartPointer<RecMail> > & )
53{ 54{
54 refresh(); 55 refresh();
55} 56}
56 57
57void POP3viewItem::refresh() 58void POP3viewItem::refresh()
58{ 59{
59 if (account->getOffline()) return; 60 if (account->getOffline()) return;
60 QValueList<FolderP> *folders = wrapper->listFolders(); 61 QValueList<FolderP> *folders = wrapper->listFolders();
61 QListViewItem *child = firstChild(); 62 QListViewItem *child = firstChild();
62 while ( child ) 63 while ( child )
63 { 64 {
64 QListViewItem *tmp = child; 65 QListViewItem *tmp = child;
65 child = child->nextSibling(); 66 child = child->nextSibling();
66 delete tmp; 67 delete tmp;
67 } 68 }
68 QValueList<FolderP>::ConstIterator it; 69 QValueList<FolderP>::ConstIterator it;
69 QListViewItem*item = 0; 70 QListViewItem*item = 0;
70 for ( it = folders->begin(); it!=folders->end(); ++it) 71 for ( it = folders->begin(); it!=folders->end(); ++it)
71 { 72 {
72 item = new POP3folderItem( (*it), this , item ); 73 item = new POP3folderItem( (*it), this , item );
73 item->setSelectable( (*it)->may_select()); 74 item->setSelectable( (*it)->may_select());
74 } 75 }
75 delete folders; 76 delete folders;
76} 77}
77 78
78RecBody POP3viewItem::fetchBody( const RecMailP &mail ) 79RecBody POP3viewItem::fetchBody( const RecMailP &mail )
79{ 80{
80 qDebug( "POP3 fetchBody" ); 81 qDebug( "POP3 fetchBody" );
81 return wrapper->fetchBody( mail ); 82 return wrapper->fetchBody( mail );
82} 83}
83 84
84QPopupMenu * POP3viewItem::getContextMenu() 85QPopupMenu * POP3viewItem::getContextMenu()
85{ 86{
86 QPopupMenu *m = new QPopupMenu(0); 87 QPopupMenu *m = new QPopupMenu(0);
87 if (m) 88 if (m)
88 { 89 {
89 if (!account->getOffline()) 90 if (!account->getOffline())
90 { 91 {
91 m->insertItem(QObject::tr("Disconnect",contextName),0); 92 m->insertItem(QObject::tr("Disconnect",contextName),0);
92 m->insertItem(QObject::tr("Set offline",contextName),1); 93 m->insertItem(QObject::tr("Set offline",contextName),1);
93 } 94 }
94 else 95 else
95 { 96 {
96 m->insertItem(QObject::tr("Set online",contextName),1); 97 m->insertItem(QObject::tr("Set online",contextName),1);
97 } 98 }
98 } 99 }
99 return m; 100 return m;
100} 101}
101 102
102void POP3viewItem::disconnect() 103void POP3viewItem::disconnect()
103{ 104{
104 QListViewItem *child = firstChild(); 105 QListViewItem *child = firstChild();
105 while ( child ) 106 while ( child )
106 { 107 {
107 QListViewItem *tmp = child; 108 QListViewItem *tmp = child;
108 child = child->nextSibling(); 109 child = child->nextSibling();
109 delete tmp; 110 delete tmp;
110 } 111 }
111 wrapper->logout(); 112 wrapper->logout();
112} 113}
113 114
114void POP3viewItem::setOnOffline() 115void POP3viewItem::setOnOffline()
115{ 116{
116 if (!account->getOffline()) 117 if (!account->getOffline())
117 { 118 {
118 disconnect(); 119 disconnect();
119 } 120 }
120 account->setOffline(!account->getOffline()); 121 account->setOffline(!account->getOffline());
121 account->save(); 122 account->save();
122 SETPIX(PIXMAP_POP3FOLDER); 123 SETPIX(PIXMAP_POP3FOLDER);
123 refresh(); 124 refresh();
124} 125}
125 126
126void POP3viewItem::contextMenuSelected(int which) 127void POP3viewItem::contextMenuSelected(int which)
127{ 128{
128 switch (which) 129 switch (which)
129 { 130 {
130 case 0: 131 case 0:
131 disconnect(); 132 disconnect();
132 break; 133 break;
133 case 1: 134 case 1:
134 setOnOffline(); 135 setOnOffline();
135 break; 136 break;
136 } 137 }
137} 138}
138 139
139POP3folderItem::~POP3folderItem() 140POP3folderItem::~POP3folderItem()
140{} 141{}
141 142
142POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after ) 143POP3folderItem::POP3folderItem( const FolderP&folderInit, POP3viewItem *parent , QListViewItem*after )
143 : AccountViewItem(folderInit,parent,after ) 144 : AccountViewItem(folderInit,parent,after )
144{ 145{
145 pop3 = parent; 146 pop3 = parent;
146 if (folder->getDisplayName().lower()!="inbox") 147 if (folder->getDisplayName().lower()!="inbox")
147 { 148 {
148 setPixmap( 0, PIXMAP_POP3FOLDER ); 149 setPixmap( 0, PIXMAP_POP3FOLDER );
149 } 150 }
150 else 151 else
151 { 152 {
152 setPixmap( 0, PIXMAP_INBOXFOLDER); 153 setPixmap( 0, PIXMAP_INBOXFOLDER);
153 } 154 }
154 setText( 0, folder->getDisplayName() ); 155 setText( 0, folder->getDisplayName() );
155} 156}
156 157
157void POP3folderItem::refresh(QValueList<RecMailP>&target) 158void POP3folderItem::refresh(QValueList<RecMailP>&target)
158{ 159{
159 if (folder->may_select()) 160 if (folder->may_select())
160 pop3->getWrapper()->listMessages( folder->getName(),target ); 161 pop3->getWrapper()->listMessages( folder->getName(),target );
161} 162}
162 163
163RecBody POP3folderItem::fetchBody(const RecMailP&aMail) 164RecBody POP3folderItem::fetchBody(const RecMailP&aMail)
164{ 165{
165 return pop3->getWrapper()->fetchBody(aMail); 166 return pop3->getWrapper()->fetchBody(aMail);
166} 167}
167 168
168QPopupMenu * POP3folderItem::getContextMenu() 169QPopupMenu * POP3folderItem::getContextMenu()
169{ 170{
170 QPopupMenu *m = new QPopupMenu(0); 171 QPopupMenu *m = new QPopupMenu(0);
171 if (m) 172 if (m)
172 { 173 {
173 m->insertItem(QObject::tr("Refresh header list",contextName),0); 174 m->insertItem(QObject::tr("Refresh header list",contextName),0);
174 m->insertItem(QObject::tr("Delete all mails",contextName),1); 175 m->insertItem(QObject::tr("Delete all mails",contextName),1);
175 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 176 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
176 } 177 }
177 return m; 178 return m;
178} 179}
179 180
180void POP3folderItem::downloadMails() 181void POP3folderItem::downloadMails()
181{ 182{
182 AccountView*bl = pop3->accountView(); 183 AccountView*bl = pop3->accountView();
183 if (!bl) return; 184 if (!bl) return;
184 bl->downloadMails(folder,pop3->getWrapper()); 185 bl->downloadMails(folder,pop3->getWrapper());
185} 186}
186 187
187void POP3folderItem::contextMenuSelected(int which) 188void POP3folderItem::contextMenuSelected(int which)
188{ 189{
189 AccountView * view = (AccountView*)listView(); 190 AccountView * view = (AccountView*)listView();
190 switch (which) 191 switch (which)
191 { 192 {
192 case 0: 193 case 0:
193 /* must be 'cause pop3 lists are cached */ 194 /* must be 'cause pop3 lists are cached */
194 pop3->getWrapper()->logout(); 195 pop3->getWrapper()->logout();
195 view->refreshCurrent(); 196 view->refreshCurrent();
196 break; 197 break;
197 case 1: 198 case 1:
198 deleteAllMail(pop3->getWrapper(),folder); 199 deleteAllMail(pop3->getWrapper(),folder);
199 break; 200 break;
200 case 2: 201 case 2:
201 downloadMails(); 202 downloadMails();
202 break; 203 break;
203 default: 204 default:
204 break; 205 break;
205 } 206 }
206} 207}
207 208
208/** 209/**
209 * NNTP Account stuff 210 * NNTP Account stuff
210 */ 211 */
211NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent ) 212NNTPviewItem::NNTPviewItem( NNTPaccount *a, AccountView *parent )
212 : AccountViewItem( parent ) 213 : AccountViewItem( parent )
213{ 214{
214 account = a; 215 account = a;
215 wrapper = AbstractMail::getWrapper( account ); 216 wrapper = AbstractMail::getWrapper( account );
216 //FIXME 217 //FIXME
217 SETPIX(PIXMAP_POP3FOLDER); 218 SETPIX(PIXMAP_POP3FOLDER);
218#if 0 219#if 0
219 if (!account->getOffline()) 220 if (!account->getOffline())
220 { 221 {
221 setPixmap( 0, ); 222 setPixmap( 0, );
222 } 223 }
223 else 224 else
224 { 225 {
225 setPixmap( 0, PIXMAP_OFFLINE ); 226 setPixmap( 0, PIXMAP_OFFLINE );
226 } 227 }
227#endif 228#endif
228 setText( 0, account->getAccountName() ); 229 setText( 0, account->getAccountName() );
229 setOpen( true ); 230 setOpen( true );
230} 231}
231 232
232NNTPviewItem::~NNTPviewItem() 233NNTPviewItem::~NNTPviewItem()
233{ 234{
234 delete wrapper; 235 delete wrapper;
235} 236}
236 237
237AbstractMail *NNTPviewItem::getWrapper() 238AbstractMail *NNTPviewItem::getWrapper()
238{ 239{
239 return wrapper; 240 return wrapper;
240} 241}
241 242
242void NNTPviewItem::refresh( QValueList<RecMailP> & ) 243void NNTPviewItem::refresh( QValueList<RecMailP> & )
243{ 244{
244 refresh(); 245 refresh();
@@ -853,281 +854,281 @@ void MHviewItem::contextMenuSelected(int which)
853 case 1: 854 case 1:
854 createFolder(); 855 createFolder();
855 break; 856 break;
856 case 2: 857 case 2:
857 deleteAllMail(getWrapper(),folder); 858 deleteAllMail(getWrapper(),folder);
858 break; 859 break;
859 case 3: 860 case 3:
860 downloadMails(); 861 downloadMails();
861 break; 862 break;
862 default: 863 default:
863 break; 864 break;
864 } 865 }
865} 866}
866 867
867MHfolderItem::~MHfolderItem() 868MHfolderItem::~MHfolderItem()
868{} 869{}
869 870
870MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after ) 871MHfolderItem::MHfolderItem( const FolderP &folderInit, MHviewItem *parent , QListViewItem*after )
871 : AccountViewItem(folderInit, parent,after ) 872 : AccountViewItem(folderInit, parent,after )
872{ 873{
873 mbox = parent; 874 mbox = parent;
874 initName(); 875 initName();
875} 876}
876 877
877MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master) 878MHfolderItem::MHfolderItem(const FolderP& folderInit, MHfolderItem *parent, QListViewItem*after, MHviewItem*master)
878 : AccountViewItem(folderInit, parent,after ) 879 : AccountViewItem(folderInit, parent,after )
879{ 880{
880 folder = folderInit; 881 folder = folderInit;
881 mbox = master; 882 mbox = master;
882 initName(); 883 initName();
883} 884}
884 885
885void MHfolderItem::initName() 886void MHfolderItem::initName()
886{ 887{
887 QString bName = folder->getDisplayName(); 888 QString bName = folder->getDisplayName();
888 if (bName.startsWith("/")&&bName.length()>1) 889 if (bName.startsWith("/")&&bName.length()>1)
889 { 890 {
890 bName.replace(0,1,""); 891 bName.replace(0,1,"");
891 } 892 }
892 int pos = bName.findRev("/"); 893 int pos = bName.findRev("/");
893 if (pos > 0) 894 if (pos > 0)
894 { 895 {
895 bName.replace(0,pos+1,""); 896 bName.replace(0,pos+1,"");
896 } 897 }
897 if (bName.lower() == "outgoing") 898 if (bName.lower() == "outgoing")
898 { 899 {
899 setPixmap( 0, PIXMAP_OUTBOXFOLDER ); 900 setPixmap( 0, PIXMAP_OUTBOXFOLDER );
900 } 901 }
901 else if (bName.lower() == "inbox") 902 else if (bName.lower() == "inbox")
902 { 903 {
903 setPixmap( 0, PIXMAP_INBOXFOLDER); 904 setPixmap( 0, PIXMAP_INBOXFOLDER);
904 } else if (bName.lower() == "drafts") { 905 } else if (bName.lower() == "drafts") {
905 setPixmap(0, Resource::loadPixmap("inline/edit")); 906 setPixmap(0, Resource::loadPixmap("inline/edit"));
906 } else { 907 } else {
907 setPixmap( 0, PIXMAP_MBOXFOLDER ); 908 setPixmap( 0, PIXMAP_MBOXFOLDER );
908 } 909 }
909 setText( 0, bName ); 910 setText( 0, bName );
910} 911}
911 912
912const FolderP&MHfolderItem::getFolder()const 913const FolderP&MHfolderItem::getFolder()const
913{ 914{
914 return folder; 915 return folder;
915} 916}
916 917
917void MHfolderItem::refresh(QValueList<RecMailP>&target) 918void MHfolderItem::refresh(QValueList<RecMailP>&target)
918{ 919{
919 if (folder->may_select()) 920 if (folder->may_select())
920 mbox->getWrapper()->listMessages( folder->getName(),target ); 921 mbox->getWrapper()->listMessages( folder->getName(),target );
921} 922}
922 923
923RecBody MHfolderItem::fetchBody(const RecMailP&aMail) 924RecBody MHfolderItem::fetchBody(const RecMailP&aMail)
924{ 925{
925 return mbox->getWrapper()->fetchBody(aMail); 926 return mbox->getWrapper()->fetchBody(aMail);
926} 927}
927 928
928void MHfolderItem::deleteFolder() 929void MHfolderItem::deleteFolder()
929{ 930{
930 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName), 931 int yesno = QMessageBox::warning(0,QObject::tr("Delete folder",contextName),
931 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()), 932 QObject::tr("<center>Realy delete folder <br><b>%1</b><br>and all if it content?</center>",contextName).arg(folder->getDisplayName()),
932 QObject::tr("Yes",contextName), 933 QObject::tr("Yes",contextName),
933 QObject::tr("No",contextName),QString::null,1,1); 934 QObject::tr("No",contextName),QString::null,1,1);
934 qDebug("Auswahl: %i",yesno); 935 qDebug("Auswahl: %i",yesno);
935 if (yesno == 0) 936 if (yesno == 0)
936 { 937 {
937 if (mbox->getWrapper()->deleteMbox(folder)) 938 if (mbox->getWrapper()->deleteMbox(folder))
938 { 939 {
939 QListView*v=listView(); 940 QListView*v=listView();
940 MHviewItem * box = mbox; 941 MHviewItem * box = mbox;
941 /* be carefull - after that this object is destroyd so don't use 942 /* be carefull - after that this object is destroyd so don't use
942 * any member of it after that call!!*/ 943 * any member of it after that call!!*/
943 mbox->refresh(true); 944 mbox->refresh(true);
944 if (v) 945 if (v)
945 { 946 {
946 v->setSelected(box,true); 947 v->setSelected(box,true);
947 } 948 }
948 } 949 }
949 } 950 }
950} 951}
951 952
952QPopupMenu * MHfolderItem::getContextMenu() 953QPopupMenu * MHfolderItem::getContextMenu()
953{ 954{
954 QPopupMenu *m = new QPopupMenu(0); 955 QPopupMenu *m = new QPopupMenu(0);
955 if (m) 956 if (m)
956 { 957 {
957 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2); 958 m->insertItem(QObject::tr("Move/Copie all mails",contextName),2);
958 m->insertItem(QObject::tr("Delete all mails",contextName),0); 959 m->insertItem(QObject::tr("Delete all mails",contextName),0);
959 m->insertItem(QObject::tr("Create new subfolder",contextName),3); 960 m->insertItem(QObject::tr("Create new subfolder",contextName),3);
960 m->insertItem(QObject::tr("Delete folder",contextName),1); 961 m->insertItem(QObject::tr("Delete folder",contextName),1);
961 } 962 }
962 return m; 963 return m;
963} 964}
964 965
965void MHfolderItem::downloadMails() 966void MHfolderItem::downloadMails()
966{ 967{
967 AccountView*bl = mbox->accountView(); 968 AccountView*bl = mbox->accountView();
968 if (!bl) return; 969 if (!bl) return;
969 bl->downloadMails(folder,mbox->getWrapper()); 970 bl->downloadMails(folder,mbox->getWrapper());
970} 971}
971 972
972void MHfolderItem::createFolder() 973void MHfolderItem::createFolder()
973{ 974{
974 Newmdirdlg ndirdlg(0,0,true); 975 Newmdirdlg ndirdlg(0,0,true);
975 if ( QPEApplication::execDialog( &ndirdlg ) ) 976 if ( QPEApplication::execDialog( &ndirdlg ) )
976 { 977 {
977 QString ndir = ndirdlg.Newdir(); 978 QString ndir = ndirdlg.Newdir();
978 if (mbox->getWrapper()->createMbox(ndir,folder)) 979 if (mbox->getWrapper()->createMbox(ndir,folder))
979 { 980 {
980 QListView*v=listView(); 981 QListView*v=listView();
981 MHviewItem * box = mbox; 982 MHviewItem * box = mbox;
982 /* be carefull - after that this object is destroyd so don't use 983 /* be carefull - after that this object is destroyd so don't use
983 * any member of it after that call!!*/ 984 * any member of it after that call!!*/
984 mbox->refresh(true); 985 mbox->refresh(true);
985 if (v) 986 if (v)
986 { 987 {
987 v->setSelected(box,true); 988 v->setSelected(box,true);
988 } 989 }
989 } 990 }
990 } 991 }
991} 992}
992 993
993void MHfolderItem::contextMenuSelected(int which) 994void MHfolderItem::contextMenuSelected(int which)
994{ 995{
995 switch(which) 996 switch(which)
996 { 997 {
997 case 0: 998 case 0:
998 deleteAllMail(mbox->getWrapper(),folder); 999 deleteAllMail(mbox->getWrapper(),folder);
999 break; 1000 break;
1000 case 1: 1001 case 1:
1001 deleteFolder(); 1002 deleteFolder();
1002 break; 1003 break;
1003 case 2: 1004 case 2:
1004 downloadMails(); 1005 downloadMails();
1005 break; 1006 break;
1006 case 3: 1007 case 3:
1007 createFolder(); 1008 createFolder();
1008 break; 1009 break;
1009 default: 1010 default:
1010 break; 1011 break;
1011 } 1012 }
1012} 1013}
1013 1014
1014bool MHfolderItem::isDraftfolder() 1015bool MHfolderItem::isDraftfolder()
1015{ 1016{
1016 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true; 1017 if (folder && folder->getName()==AbstractMail::defaultLocalfolder()+"/"+AbstractMail::draftFolder()) return true;
1017 return false; 1018 return false;
1018} 1019}
1019 1020
1020/** 1021/**
1021 * Generic stuff 1022 * Generic stuff
1022 */ 1023 */
1023 1024
1024const QString AccountViewItem::contextName="AccountViewItem"; 1025const QString AccountViewItem::contextName="AccountViewItem";
1025 1026
1026AccountViewItem::AccountViewItem( AccountView *parent ) 1027AccountViewItem::AccountViewItem( AccountView *parent )
1027 : QListViewItem( parent ) 1028 : QListViewItem( parent )
1028{ 1029{
1029 init(); 1030 init();
1030 m_Backlink = parent; 1031 m_Backlink = parent;
1031} 1032}
1032 1033
1033AccountViewItem::AccountViewItem( QListViewItem *parent) 1034AccountViewItem::AccountViewItem( QListViewItem *parent)
1034 : QListViewItem( parent),folder(0) 1035 : QListViewItem( parent),folder(0)
1035{ 1036{
1036 init(); 1037 init();
1037} 1038}
1038 1039
1039AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after ) 1040AccountViewItem::AccountViewItem( QListViewItem *parent , QListViewItem*after )
1040 :QListViewItem( parent,after ),folder(0) 1041 :QListViewItem( parent,after ),folder(0)
1041{ 1042{
1042 init(); 1043 init();
1043} 1044}
1044 1045
1045AccountViewItem::AccountViewItem( const Opie::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ) 1046AccountViewItem::AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after )
1046 :QListViewItem( parent,after ),folder(folderInit) 1047 :QListViewItem( parent,after ),folder(folderInit)
1047{ 1048{
1048 init(); 1049 init();
1049} 1050}
1050 1051
1051void AccountViewItem::init() 1052void AccountViewItem::init()
1052{ 1053{
1053 m_Backlink = 0; 1054 m_Backlink = 0;
1054} 1055}
1055 1056
1056AccountViewItem::~AccountViewItem() 1057AccountViewItem::~AccountViewItem()
1057{ 1058{
1058 folder = 0; 1059 folder = 0;
1059} 1060}
1060 1061
1061AccountView*AccountViewItem::accountView() 1062AccountView*AccountViewItem::accountView()
1062{ 1063{
1063 return m_Backlink; 1064 return m_Backlink;
1064} 1065}
1065 1066
1066void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder) 1067void AccountViewItem::deleteAllMail(AbstractMail*wrapper,const FolderP&folder)
1067{ 1068{
1068 if (!wrapper) return; 1069 if (!wrapper) return;
1069 QString fname=""; 1070 QString fname="";
1070 if (folder) fname = folder->getDisplayName(); 1071 if (folder) fname = folder->getDisplayName();
1071 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName), 1072 int yesno = QMessageBox::warning(0,QObject::tr("Delete all mails",contextName),
1072 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName). 1073 QObject::tr("<center>Realy delete all mails in box <br>%1</center>",contextName).
1073 arg(fname), 1074 arg(fname),
1074 QObject::tr("Yes",contextName), 1075 QObject::tr("Yes",contextName),
1075 QObject::tr("No",contextName),QString::null,1,1); 1076 QObject::tr("No",contextName),QString::null,1,1);
1076 qDebug("Auswahl: %i",yesno); 1077 qDebug("Auswahl: %i",yesno);
1077 if (yesno == 0) 1078 if (yesno == 0)
1078 { 1079 {
1079 if (wrapper->deleteAllMail(folder)) 1080 if (wrapper->deleteAllMail(folder))
1080 { 1081 {
1081 AccountView * view = (AccountView*)listView(); 1082 AccountView * view = (AccountView*)listView();
1082 if (view) view->refreshCurrent(); 1083 if (view) view->refreshCurrent();
1083 } 1084 }
1084 } 1085 }
1085} 1086}
1086 1087
1087void AccountViewItem::removeChilds() 1088void AccountViewItem::removeChilds()
1088{ 1089{
1089 QListViewItem *child = firstChild(); 1090 QListViewItem *child = firstChild();
1090 while ( child ) 1091 while ( child )
1091 { 1092 {
1092 QListViewItem *tmp = child; 1093 QListViewItem *tmp = child;
1093 child = child->nextSibling(); 1094 child = child->nextSibling();
1094 delete tmp; 1095 delete tmp;
1095 } 1096 }
1096} 1097}
1097 1098
1098bool AccountViewItem::matchName(const QString&name)const 1099bool AccountViewItem::matchName(const QString&name)const
1099{ 1100{
1100 if (!folder) return false; 1101 if (!folder) return false;
1101 return folder->getDisplayName()==name; 1102 return folder->getDisplayName()==name;
1102} 1103}
1103 1104
1104 1105
1105AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start) 1106AccountViewItem*AccountViewItem::findSubItem(const QString&path,AccountViewItem*start)
1106{ 1107{
1107 AccountViewItem*pitem,*sitem; 1108 AccountViewItem*pitem,*sitem;
1108 if (!start) pitem = (AccountViewItem*)firstChild(); 1109 if (!start) pitem = (AccountViewItem*)firstChild();
1109 else pitem = (AccountViewItem*)start->firstChild(); 1110 else pitem = (AccountViewItem*)start->firstChild();
1110 while (pitem) 1111 while (pitem)
1111 { 1112 {
1112 if (pitem->matchName(path)) 1113 if (pitem->matchName(path))
1113 { 1114 {
1114 break; 1115 break;
1115 } 1116 }
1116 if (pitem->childCount()>0) 1117 if (pitem->childCount()>0)
1117 { 1118 {
1118 sitem = findSubItem(path,pitem); 1119 sitem = findSubItem(path,pitem);
1119 if (sitem) 1120 if (sitem)
1120 { 1121 {
1121 pitem = sitem; 1122 pitem = sitem;
1122 break; 1123 break;
1123 } 1124 }
1124 } 1125 }
1125 pitem=(AccountViewItem*)pitem->nextSibling(); 1126 pitem=(AccountViewItem*)pitem->nextSibling();
1126 } 1127 }
1127 return pitem; 1128 return pitem;
1128} 1129}
1129 1130
1130bool AccountViewItem::isDraftfolder() 1131bool AccountViewItem::isDraftfolder()
1131{ 1132{
1132 return false; 1133 return false;
1133} 1134}
diff --git a/noncore/net/mail/accountitem.h b/noncore/net/mail/accountitem.h
index 276eae0..6cdb260 100644
--- a/noncore/net/mail/accountitem.h
+++ b/noncore/net/mail/accountitem.h
@@ -1,210 +1,210 @@
1#ifndef __ACCOUNT_ITEM 1#ifndef __ACCOUNT_ITEM
2#define __ACCOUNT_ITEM 2#define __ACCOUNT_ITEM
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <opie2/osmartpointer.h> 6#include <opie2/osmartpointer.h>
7 7
8class POP3wrapper; 8class POP3wrapper;
9class RecMail; 9class RecMail;
10class RecBody; 10class RecBody;
11class QPopupMenu; 11class QPopupMenu;
12class Selectstore; 12class Selectstore;
13class AccountView; 13class AccountView;
14class POP3account; 14class POP3account;
15class NNTPaccount; 15class NNTPaccount;
16class IMAPaccount; 16class IMAPaccount;
17class AbstractMail; 17class AbstractMail;
18class Folder; 18class Folder;
19 19
20class AccountViewItem : public QListViewItem 20class AccountViewItem : public QListViewItem
21{ 21{
22 22
23public: 23public:
24 AccountViewItem( AccountView *parent ); 24 AccountViewItem( AccountView *parent );
25 AccountViewItem( QListViewItem *parent); 25 AccountViewItem( QListViewItem *parent);
26 AccountViewItem( QListViewItem *parent , QListViewItem*after ); 26 AccountViewItem( QListViewItem *parent , QListViewItem*after );
27 AccountViewItem( const Opie::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after ); 27 AccountViewItem( const Opie::Core::OSmartPointer<Folder>&folderInit,QListViewItem *parent , QListViewItem*after );
28 28
29 virtual ~AccountViewItem(); 29 virtual ~AccountViewItem();
30 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&)=0; 30 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&)=0;
31 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&)=0; 31 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&)=0;
32 virtual QPopupMenu * getContextMenu(){return 0;}; 32 virtual QPopupMenu * getContextMenu(){return 0;};
33 virtual void contextMenuSelected(int){} 33 virtual void contextMenuSelected(int){}
34 virtual AccountView*accountView(); 34 virtual AccountView*accountView();
35 virtual bool matchName(const QString&name)const; 35 virtual bool matchName(const QString&name)const;
36 virtual bool isDraftfolder(); 36 virtual bool isDraftfolder();
37 37
38protected: 38protected:
39 AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0); 39 AccountViewItem*findSubItem(const QString&path,AccountViewItem*start=0);
40 virtual void init(); 40 virtual void init();
41 virtual void removeChilds(); 41 virtual void removeChilds();
42 virtual void deleteAllMail(AbstractMail*wrapper,const Opie::OSmartPointer<Folder>&f); 42 virtual void deleteAllMail(AbstractMail*wrapper,const Opie::Core::OSmartPointer<Folder>&f);
43 static const QString contextName; 43 static const QString contextName;
44 AccountView*m_Backlink; 44 AccountView*m_Backlink;
45 Opie::OSmartPointer<Folder> folder; 45 Opie::Core::OSmartPointer<Folder> folder;
46}; 46};
47 47
48class POP3viewItem : public AccountViewItem 48class POP3viewItem : public AccountViewItem
49{ 49{
50 50
51public: 51public:
52 POP3viewItem( POP3account *a, AccountView *parent ); 52 POP3viewItem( POP3account *a, AccountView *parent );
53 virtual ~POP3viewItem(); 53 virtual ~POP3viewItem();
54 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&target ); 54 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
55 virtual RecBody fetchBody( const Opie::OSmartPointer<RecMail> &mail ); 55 virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
56 AbstractMail *getWrapper(); 56 AbstractMail *getWrapper();
57 virtual QPopupMenu * getContextMenu(); 57 virtual QPopupMenu * getContextMenu();
58 virtual void contextMenuSelected(int); 58 virtual void contextMenuSelected(int);
59 59
60protected: 60protected:
61 POP3account *account; 61 POP3account *account;
62 virtual void refresh(); 62 virtual void refresh();
63 AbstractMail *wrapper; 63 AbstractMail *wrapper;
64 void disconnect(); 64 void disconnect();
65 void setOnOffline(); 65 void setOnOffline();
66}; 66};
67 67
68class POP3folderItem : public AccountViewItem 68class POP3folderItem : public AccountViewItem
69{ 69{
70 70
71public: 71public:
72 POP3folderItem( const Opie::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after ); 72 POP3folderItem( const Opie::Core::OSmartPointer<Folder>&folder, POP3viewItem *parent , QListViewItem*after );
73 virtual ~POP3folderItem(); 73 virtual ~POP3folderItem();
74 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&); 74 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
75 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&); 75 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
76 virtual QPopupMenu * getContextMenu(); 76 virtual QPopupMenu * getContextMenu();
77 virtual void contextMenuSelected(int); 77 virtual void contextMenuSelected(int);
78 78
79protected: 79protected:
80 void downloadMails(); 80 void downloadMails();
81 POP3viewItem *pop3; 81 POP3viewItem *pop3;
82}; 82};
83 83
84 84
85class NNTPviewItem : public AccountViewItem 85class NNTPviewItem : public AccountViewItem
86{ 86{
87 87
88public: 88public:
89 NNTPviewItem( NNTPaccount *a, AccountView *parent ); 89 NNTPviewItem( NNTPaccount *a, AccountView *parent );
90 virtual ~NNTPviewItem(); 90 virtual ~NNTPviewItem();
91 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&target ); 91 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
92 virtual RecBody fetchBody( const Opie::OSmartPointer<RecMail> &mail ); 92 virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
93 AbstractMail *getWrapper(); 93 AbstractMail *getWrapper();
94 virtual QPopupMenu * getContextMenu(); 94 virtual QPopupMenu * getContextMenu();
95 virtual void contextMenuSelected(int); 95 virtual void contextMenuSelected(int);
96 96
97protected: 97protected:
98 NNTPaccount *account; 98 NNTPaccount *account;
99 virtual void refresh(); 99 virtual void refresh();
100 AbstractMail *wrapper; 100 AbstractMail *wrapper;
101 void disconnect(); 101 void disconnect();
102 void setOnOffline(); 102 void setOnOffline();
103 void subscribeGroups(); 103 void subscribeGroups();
104}; 104};
105 105
106class NNTPfolderItem : public AccountViewItem 106class NNTPfolderItem : public AccountViewItem
107{ 107{
108 108
109public: 109public:
110 NNTPfolderItem(const Opie::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after ); 110 NNTPfolderItem(const Opie::Core::OSmartPointer<Folder>&folder, NNTPviewItem *parent , QListViewItem*after );
111 virtual ~NNTPfolderItem(); 111 virtual ~NNTPfolderItem();
112 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&); 112 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
113 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&); 113 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
114 virtual QPopupMenu * getContextMenu(); 114 virtual QPopupMenu * getContextMenu();
115 virtual void contextMenuSelected(int); 115 virtual void contextMenuSelected(int);
116 116
117protected: 117protected:
118 void downloadMails(); 118 void downloadMails();
119 NNTPviewItem *nntp; 119 NNTPviewItem *nntp;
120}; 120};
121 121
122 122
123 123
124class IMAPviewItem : public AccountViewItem 124class IMAPviewItem : public AccountViewItem
125{ 125{
126 friend class IMAPfolderItem; 126 friend class IMAPfolderItem;
127public: 127public:
128 IMAPviewItem( IMAPaccount *a, AccountView *parent ); 128 IMAPviewItem( IMAPaccount *a, AccountView *parent );
129 virtual ~IMAPviewItem(); 129 virtual ~IMAPviewItem();
130 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&); 130 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
131 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&); 131 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
132 AbstractMail *getWrapper(); 132 AbstractMail *getWrapper();
133 virtual QPopupMenu * getContextMenu(); 133 virtual QPopupMenu * getContextMenu();
134 virtual void contextMenuSelected(int); 134 virtual void contextMenuSelected(int);
135 const QStringList&subFolders(); 135 const QStringList&subFolders();
136 virtual void refreshFolders(bool force=false); 136 virtual void refreshFolders(bool force=false);
137 bool offline(); 137 bool offline();
138 138
139protected: 139protected:
140 virtual void createNewFolder(); 140 virtual void createNewFolder();
141 IMAPaccount *account; 141 IMAPaccount *account;
142 AbstractMail *wrapper; 142 AbstractMail *wrapper;
143 QStringList currentFolders; 143 QStringList currentFolders;
144}; 144};
145 145
146class IMAPfolderItem : public AccountViewItem 146class IMAPfolderItem : public AccountViewItem
147{ 147{
148 148
149public: 149public:
150 IMAPfolderItem( const Opie::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after ); 150 IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPviewItem *parent , QListViewItem*after );
151 IMAPfolderItem( const Opie::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master ); 151 IMAPfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, IMAPfolderItem *parent , QListViewItem*after, IMAPviewItem *master );
152 virtual ~IMAPfolderItem(); 152 virtual ~IMAPfolderItem();
153 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&); 153 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
154 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&); 154 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
155 virtual QPopupMenu * getContextMenu(); 155 virtual QPopupMenu * getContextMenu();
156 virtual void contextMenuSelected(int); 156 virtual void contextMenuSelected(int);
157 virtual const QString& Delemiter()const; 157 virtual const QString& Delemiter()const;
158protected: 158protected:
159 virtual void createNewFolder(); 159 virtual void createNewFolder();
160 virtual void deleteFolder(); 160 virtual void deleteFolder();
161 virtual void downloadMails(); 161 virtual void downloadMails();
162 IMAPviewItem *imap; 162 IMAPviewItem *imap;
163}; 163};
164 164
165class MHviewItem : public AccountViewItem 165class MHviewItem : public AccountViewItem
166{ 166{
167 friend class MHfolderItem; 167 friend class MHfolderItem;
168 168
169public: 169public:
170 MHviewItem( const QString&aMboxPath, AccountView *parent ); 170 MHviewItem( const QString&aMboxPath, AccountView *parent );
171 virtual ~MHviewItem(); 171 virtual ~MHviewItem();
172 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&target ); 172 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
173 virtual RecBody fetchBody( const Opie::OSmartPointer<RecMail> &mail ); 173 virtual RecBody fetchBody( const Opie::Core::OSmartPointer<RecMail> &mail );
174 AbstractMail *getWrapper(); 174 AbstractMail *getWrapper();
175 virtual QPopupMenu * getContextMenu(); 175 virtual QPopupMenu * getContextMenu();
176 virtual void contextMenuSelected(int); 176 virtual void contextMenuSelected(int);
177 QStringList subFolders(); 177 QStringList subFolders();
178 virtual void refresh(bool force=false); 178 virtual void refresh(bool force=false);
179 179
180protected: 180protected:
181 void downloadMails(); 181 void downloadMails();
182 virtual void createFolder(); 182 virtual void createFolder();
183 QString m_Path; 183 QString m_Path;
184 AbstractMail *wrapper; 184 AbstractMail *wrapper;
185 QStringList currentFolders; 185 QStringList currentFolders;
186}; 186};
187 187
188class MHfolderItem : public AccountViewItem 188class MHfolderItem : public AccountViewItem
189{ 189{
190 190
191public: 191public:
192 MHfolderItem( const Opie::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after ); 192 MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHviewItem *parent , QListViewItem*after );
193 MHfolderItem( const Opie::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master); 193 MHfolderItem( const Opie::Core::OSmartPointer<Folder>&folder, MHfolderItem *parent, QListViewItem*after, MHviewItem*master);
194 virtual ~MHfolderItem(); 194 virtual ~MHfolderItem();
195 virtual void refresh(QValueList<Opie::OSmartPointer<RecMail> >&); 195 virtual void refresh(QValueList<Opie::Core::OSmartPointer<RecMail> >&);
196 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&); 196 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&);
197 virtual QPopupMenu * getContextMenu(); 197 virtual QPopupMenu * getContextMenu();
198 virtual void contextMenuSelected(int); 198 virtual void contextMenuSelected(int);
199 virtual const Opie::OSmartPointer<Folder>&getFolder()const; 199 virtual const Opie::Core::OSmartPointer<Folder>&getFolder()const;
200 virtual bool isDraftfolder(); 200 virtual bool isDraftfolder();
201 201
202protected: 202protected:
203 void downloadMails(); 203 void downloadMails();
204 virtual void createFolder(); 204 virtual void createFolder();
205 virtual void deleteFolder(); 205 virtual void deleteFolder();
206 void initName(); 206 void initName();
207 MHviewItem *mbox; 207 MHviewItem *mbox;
208}; 208};
209 209
210#endif 210#endif
diff --git a/noncore/net/mail/accountview.cpp b/noncore/net/mail/accountview.cpp
index 26107ff..811e57a 100644
--- a/noncore/net/mail/accountview.cpp
+++ b/noncore/net/mail/accountview.cpp
@@ -1,175 +1,176 @@
1 1
2#include "accountview.h" 2#include "accountview.h"
3#include "accountitem.h" 3#include "accountitem.h"
4#include "selectstore.h" 4#include "selectstore.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <libmailwrapper/settings.h> 7#include <libmailwrapper/settings.h>
8#include <libmailwrapper/mailwrapper.h> 8#include <libmailwrapper/mailwrapper.h>
9#include <libmailwrapper/mailtypes.h> 9#include <libmailwrapper/mailtypes.h>
10#include <libmailwrapper/abstractmail.h> 10#include <libmailwrapper/abstractmail.h>
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12 12
13/* QT */ 13/* QT */
14#include <qmessagebox.h> 14#include <qmessagebox.h>
15#include <qpopupmenu.h> 15#include <qpopupmenu.h>
16 16
17using namespace Opie::Core;
17AccountView::AccountView( QWidget *parent, const char *name, WFlags flags ) 18AccountView::AccountView( QWidget *parent, const char *name, WFlags flags )
18 : QListView( parent, name, flags ) 19 : QListView( parent, name, flags )
19{ 20{
20 connect( this, SIGNAL( selectionChanged(QListViewItem*) ), 21 connect( this, SIGNAL( selectionChanged(QListViewItem*) ),
21 SLOT( refresh(QListViewItem*) ) ); 22 SLOT( refresh(QListViewItem*) ) );
22 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this, 23 connect( this, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),this,
23 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) ); 24 SLOT( slotHold(int,QListViewItem*,const QPoint&,int) ) );
24 setSorting(0); 25 setSorting(0);
25} 26}
26 27
27AccountView::~AccountView() 28AccountView::~AccountView()
28{ 29{
29 imapAccounts.clear(); 30 imapAccounts.clear();
30 mhAccounts.clear(); 31 mhAccounts.clear();
31} 32}
32 33
33void AccountView::slotContextMenu(int id) 34void AccountView::slotContextMenu(int id)
34{ 35{
35 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 36 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
36 if (!view) return; 37 if (!view) return;
37 view->contextMenuSelected(id); 38 view->contextMenuSelected(id);
38} 39}
39 40
40void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int) 41void AccountView::slotHold(int button, QListViewItem * item,const QPoint&,int)
41{ 42{
42 if (button==1) {return;} 43 if (button==1) {return;}
43 if (!item) return; 44 if (!item) return;
44 AccountViewItem *view = static_cast<AccountViewItem *>(item); 45 AccountViewItem *view = static_cast<AccountViewItem *>(item);
45 QPopupMenu*m = view->getContextMenu(); 46 QPopupMenu*m = view->getContextMenu();
46 if (!m) return; 47 if (!m) return;
47 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int))); 48 connect(m,SIGNAL(activated(int)),this,SLOT(slotContextMenu(int)));
48 m->setFocus(); 49 m->setFocus();
49 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); 50 m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) );
50 delete m; 51 delete m;
51} 52}
52 53
53void AccountView::populate( QList<Account> list ) 54void AccountView::populate( QList<Account> list )
54{ 55{
55 clear(); 56 clear();
56 57
57 imapAccounts.clear(); 58 imapAccounts.clear();
58 mhAccounts.clear(); 59 mhAccounts.clear();
59 60
60 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this)); 61 mhAccounts.append(new MHviewItem(AbstractMail::defaultLocalfolder(),this));
61 62
62 Account *it; 63 Account *it;
63 for ( it = list.first(); it; it = list.next() ) 64 for ( it = list.first(); it; it = list.next() )
64 { 65 {
65 if ( it->getType() == MAILLIB::A_IMAP ) 66 if ( it->getType() == MAILLIB::A_IMAP )
66 { 67 {
67 IMAPaccount *imap = static_cast<IMAPaccount *>(it); 68 IMAPaccount *imap = static_cast<IMAPaccount *>(it);
68 qDebug( "added IMAP " + imap->getAccountName() ); 69 qDebug( "added IMAP " + imap->getAccountName() );
69 imapAccounts.append(new IMAPviewItem( imap, this )); 70 imapAccounts.append(new IMAPviewItem( imap, this ));
70 } 71 }
71 else if ( it->getType() == MAILLIB::A_POP3 ) 72 else if ( it->getType() == MAILLIB::A_POP3 )
72 { 73 {
73 POP3account *pop3 = static_cast<POP3account *>(it); 74 POP3account *pop3 = static_cast<POP3account *>(it);
74 qDebug( "added POP3 " + pop3->getAccountName() ); 75 qDebug( "added POP3 " + pop3->getAccountName() );
75 /* must not be hold 'cause it isn't required */ 76 /* must not be hold 'cause it isn't required */
76 (void) new POP3viewItem( pop3, this ); 77 (void) new POP3viewItem( pop3, this );
77 } 78 }
78 else if ( it->getType() == MAILLIB::A_NNTP ) 79 else if ( it->getType() == MAILLIB::A_NNTP )
79 { 80 {
80 NNTPaccount *nntp = static_cast<NNTPaccount *>(it); 81 NNTPaccount *nntp = static_cast<NNTPaccount *>(it);
81 qDebug( "added NNTP " + nntp->getAccountName() ); 82 qDebug( "added NNTP " + nntp->getAccountName() );
82 /* must not be hold 'cause it isn't required */ 83 /* must not be hold 'cause it isn't required */
83 (void) new NNTPviewItem( nntp, this ); 84 (void) new NNTPviewItem( nntp, this );
84 } 85 }
85 } 86 }
86} 87}
87 88
88void AccountView::refresh(QListViewItem *item) 89void AccountView::refresh(QListViewItem *item)
89{ 90{
90 91
91 qDebug("AccountView refresh..."); 92 qDebug("AccountView refresh...");
92 if ( item ) 93 if ( item )
93 { 94 {
94 m_currentItem = item; 95 m_currentItem = item;
95 QValueList<RecMailP> headerlist; 96 QValueList<RecMailP> headerlist;
96 AccountViewItem *view = static_cast<AccountViewItem *>(item); 97 AccountViewItem *view = static_cast<AccountViewItem *>(item);
97 view->refresh(headerlist); 98 view->refresh(headerlist);
98 emit refreshMailview(headerlist); 99 emit refreshMailview(headerlist);
99 } 100 }
100} 101}
101 102
102void AccountView::refreshCurrent() 103void AccountView::refreshCurrent()
103{ 104{
104 m_currentItem = currentItem(); 105 m_currentItem = currentItem();
105 if ( !m_currentItem ) return; 106 if ( !m_currentItem ) return;
106 QValueList<RecMailP> headerlist; 107 QValueList<RecMailP> headerlist;
107 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem); 108 AccountViewItem *view = static_cast<AccountViewItem *>(m_currentItem);
108 view->refresh(headerlist); 109 view->refresh(headerlist);
109 emit refreshMailview(headerlist); 110 emit refreshMailview(headerlist);
110} 111}
111 112
112void AccountView::refreshAll() 113void AccountView::refreshAll()
113{ 114{
114} 115}
115 116
116RecBody AccountView::fetchBody(const RecMailP&aMail) 117RecBody AccountView::fetchBody(const RecMailP&aMail)
117{ 118{
118 QListViewItem*item = selectedItem (); 119 QListViewItem*item = selectedItem ();
119 if (!item) return RecBody(); 120 if (!item) return RecBody();
120 AccountViewItem *view = static_cast<AccountViewItem *>(item); 121 AccountViewItem *view = static_cast<AccountViewItem *>(item);
121 return view->fetchBody(aMail); 122 return view->fetchBody(aMail);
122} 123}
123 124
124void AccountView::setupFolderselect(Selectstore*sels) 125void AccountView::setupFolderselect(Selectstore*sels)
125{ 126{
126 QPEApplication::showDialog( sels ); 127 QPEApplication::showDialog( sels );
127 QStringList sFolders; 128 QStringList sFolders;
128 unsigned int i = 0; 129 unsigned int i = 0;
129 for (i=0; i < mhAccounts.count();++i) 130 for (i=0; i < mhAccounts.count();++i)
130 { 131 {
131 mhAccounts[i]->refresh(false); 132 mhAccounts[i]->refresh(false);
132 sFolders = mhAccounts[i]->subFolders(); 133 sFolders = mhAccounts[i]->subFolders();
133 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders); 134 sels->addAccounts(mhAccounts[i]->getWrapper(),sFolders);
134 } 135 }
135 for (i=0; i < imapAccounts.count();++i) 136 for (i=0; i < imapAccounts.count();++i)
136 { 137 {
137 if (imapAccounts[i]->offline()) 138 if (imapAccounts[i]->offline())
138 continue; 139 continue;
139 imapAccounts[i]->refreshFolders(false); 140 imapAccounts[i]->refreshFolders(false);
140 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders()); 141 sels->addAccounts(imapAccounts[i]->getWrapper(),imapAccounts[i]->subFolders());
141 } 142 }
142} 143}
143 144
144void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper) 145void AccountView::downloadMails(const FolderP&fromFolder,AbstractMail*fromWrapper)
145{ 146{
146 AbstractMail*targetMail = 0; 147 AbstractMail*targetMail = 0;
147 QString targetFolder = ""; 148 QString targetFolder = "";
148 Selectstore sels; 149 Selectstore sels;
149 setupFolderselect(&sels); 150 setupFolderselect(&sels);
150 if (!sels.exec()) return; 151 if (!sels.exec()) return;
151 targetMail = sels.currentMail(); 152 targetMail = sels.currentMail();
152 targetFolder = sels.currentFolder(); 153 targetFolder = sels.currentFolder();
153 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) || 154 if ( (fromWrapper==targetMail && fromFolder->getName()==targetFolder) ||
154 targetFolder.isEmpty()) 155 targetFolder.isEmpty())
155 { 156 {
156 return; 157 return;
157 } 158 }
158 if (sels.newFolder() && !targetMail->createMbox(targetFolder)) 159 if (sels.newFolder() && !targetMail->createMbox(targetFolder))
159 { 160 {
160 QMessageBox::critical(0,tr("Error creating new Folder"), 161 QMessageBox::critical(0,tr("Error creating new Folder"),
161 tr("<center>Error while creating<br>new folder - breaking.</center>")); 162 tr("<center>Error while creating<br>new folder - breaking.</center>"));
162 return; 163 return;
163 } 164 }
164 qDebug("Targetfolder: %s",targetFolder.latin1()); 165 qDebug("Targetfolder: %s",targetFolder.latin1());
165 qDebug("Fromfolder: %s",fromFolder->getName().latin1()); 166 qDebug("Fromfolder: %s",fromFolder->getName().latin1());
166 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails()); 167 fromWrapper->mvcpAllMails(fromFolder,targetFolder,targetMail,sels.moveMails());
167 refreshCurrent(); 168 refreshCurrent();
168} 169}
169 170
170bool AccountView::currentisDraft() 171bool AccountView::currentisDraft()
171{ 172{
172 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem()); 173 AccountViewItem *view = static_cast<AccountViewItem *>(currentItem());
173 if (!view) return false; 174 if (!view) return false;
174 return view->isDraftfolder(); 175 return view->isDraftfolder();
175} 176}
diff --git a/noncore/net/mail/accountview.h b/noncore/net/mail/accountview.h
index d236058..b082b1f 100644
--- a/noncore/net/mail/accountview.h
+++ b/noncore/net/mail/accountview.h
@@ -1,45 +1,45 @@
1#ifndef ACCOUNTVIEW_H 1#ifndef ACCOUNTVIEW_H
2#define ACCOUNTVIEW_H 2#define ACCOUNTVIEW_H
3 3
4#include <qlistview.h> 4#include <qlistview.h>
5#include <qlist.h> 5#include <qlist.h>
6#include <opie2/osmartpointer.h> 6#include <opie2/osmartpointer.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8 8
9class Selectstore; 9class Selectstore;
10class Folder; 10class Folder;
11class AbstractMail; 11class AbstractMail;
12class Account; 12class Account;
13class IMAPviewItem; 13class IMAPviewItem;
14class MHviewItem; 14class MHviewItem;
15 15
16class AccountView : public QListView 16class AccountView : public QListView
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); 21 AccountView( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 );
22 virtual ~AccountView(); 22 virtual ~AccountView();
23 virtual void populate( QList<Account> list ); 23 virtual void populate( QList<Account> list );
24 virtual RecBody fetchBody(const Opie::OSmartPointer<RecMail>&aMail); 24 virtual RecBody fetchBody(const Opie::Core::OSmartPointer<RecMail>&aMail);
25 virtual void downloadMails(const Opie::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper); 25 virtual void downloadMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,AbstractMail*fromWrapper);
26 virtual bool currentisDraft(); 26 virtual bool currentisDraft();
27 27
28public slots: 28public slots:
29 virtual void refreshAll(); 29 virtual void refreshAll();
30 virtual void refresh(QListViewItem *item); 30 virtual void refresh(QListViewItem *item);
31 virtual void refreshCurrent(); 31 virtual void refreshCurrent();
32 virtual void slotHold(int, QListViewItem *,const QPoint&,int); 32 virtual void slotHold(int, QListViewItem *,const QPoint&,int);
33 virtual void slotContextMenu(int id); 33 virtual void slotContextMenu(int id);
34 void setupFolderselect(Selectstore*sels); 34 void setupFolderselect(Selectstore*sels);
35 35
36signals: 36signals:
37 void refreshMailview(const QValueList<RecMailP>& ); 37 void refreshMailview(const QValueList<RecMailP>& );
38 38
39protected: 39protected:
40 QListViewItem* m_currentItem; 40 QListViewItem* m_currentItem;
41 QValueList<IMAPviewItem*> imapAccounts; 41 QValueList<IMAPviewItem*> imapAccounts;
42 QValueList<MHviewItem*> mhAccounts; 42 QValueList<MHviewItem*> mhAccounts;
43}; 43};
44 44
45#endif 45#endif
diff --git a/noncore/net/mail/composemail.cpp b/noncore/net/mail/composemail.cpp
index 74ccc7b..5bc2883 100644
--- a/noncore/net/mail/composemail.cpp
+++ b/noncore/net/mail/composemail.cpp
@@ -1,300 +1,302 @@
1#include <qt.h> 1#include <qt.h>
2 2
3#include <opie2/ofiledialog.h> 3#include <opie2/ofiledialog.h>
4#include <qpe/resource.h> 4#include <qpe/resource.h>
5#include <qpe/config.h> 5#include <qpe/config.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <qpe/contact.h> 7#include <qpe/contact.h>
8 8
9#include "composemail.h" 9#include "composemail.h"
10 10
11#include <libmailwrapper/smtpwrapper.h> 11#include <libmailwrapper/smtpwrapper.h>
12#include <libmailwrapper/storemail.h> 12#include <libmailwrapper/storemail.h>
13#include <libmailwrapper/abstractmail.h> 13#include <libmailwrapper/abstractmail.h>
14#include <libmailwrapper/mailtypes.h> 14#include <libmailwrapper/mailtypes.h>
15 15
16using namespace Opie::Core;
17using namespace Opie::Ui;
16ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) 18ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags )
17 : ComposeMailUI( parent, name, modal, flags ) 19 : ComposeMailUI( parent, name, modal, flags )
18{ 20{
19 settings = s; 21 settings = s;
20 m_replyid = ""; 22 m_replyid = "";
21 23
22 QString vfilename = Global::applicationFileName("addressbook", 24 QString vfilename = Global::applicationFileName("addressbook",
23 "businesscard.vcf"); 25 "businesscard.vcf");
24 Contact c; 26 Contact c;
25 if (QFile::exists(vfilename)) { 27 if (QFile::exists(vfilename)) {
26 c = Contact::readVCard( vfilename )[0]; 28 c = Contact::readVCard( vfilename )[0];
27 } 29 }
28 30
29 QStringList mails = c.emailList(); 31 QStringList mails = c.emailList();
30 QString defmail = c.defaultEmail(); 32 QString defmail = c.defaultEmail();
31 33
32 if (defmail.length()!=0) { 34 if (defmail.length()!=0) {
33 fromBox->insertItem(defmail); 35 fromBox->insertItem(defmail);
34 } 36 }
35 QStringList::ConstIterator sit = mails.begin(); 37 QStringList::ConstIterator sit = mails.begin();
36 for (;sit!=mails.end();++sit) { 38 for (;sit!=mails.end();++sit) {
37 if ( (*sit)==defmail) 39 if ( (*sit)==defmail)
38 continue; 40 continue;
39 fromBox->insertItem((*sit)); 41 fromBox->insertItem((*sit));
40 } 42 }
41 senderNameEdit->setText(c.firstName()+" "+c.lastName()); 43 senderNameEdit->setText(c.firstName()+" "+c.lastName());
42 Config cfg( "mail" ); 44 Config cfg( "mail" );
43 cfg.setGroup( "Compose" ); 45 cfg.setGroup( "Compose" );
44 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); 46 checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) );
45 47
46 attList->addColumn( tr( "Name" ) ); 48 attList->addColumn( tr( "Name" ) );
47 attList->addColumn( tr( "Size" ) ); 49 attList->addColumn( tr( "Size" ) );
48 50
49 QList<Account> accounts = settings->getAccounts(); 51 QList<Account> accounts = settings->getAccounts();
50 52
51 Account *it; 53 Account *it;
52 for ( it = accounts.first(); it; it = accounts.next() ) { 54 for ( it = accounts.first(); it; it = accounts.next() ) {
53 if ( it->getType()==MAILLIB::A_SMTP ) { 55 if ( it->getType()==MAILLIB::A_SMTP ) {
54 SMTPaccount *smtp = static_cast<SMTPaccount *>(it); 56 SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
55 smtpAccountBox->insertItem( smtp->getAccountName() ); 57 smtpAccountBox->insertItem( smtp->getAccountName() );
56 smtpAccounts.append( smtp ); 58 smtpAccounts.append( smtp );
57 } 59 }
58 } 60 }
59 61
60 if ( smtpAccounts.count() > 0 ) { 62 if ( smtpAccounts.count() > 0 ) {
61 fillValues( smtpAccountBox->currentItem() ); 63 fillValues( smtpAccountBox->currentItem() );
62 } else { 64 } else {
63 QMessageBox::information( this, tr( "Problem" ), 65 QMessageBox::information( this, tr( "Problem" ),
64 tr( "<p>Please create an SMTP account first.</p>" ), 66 tr( "<p>Please create an SMTP account first.</p>" ),
65 tr( "Ok" ) ); 67 tr( "Ok" ) );
66 return; 68 return;
67 } 69 }
68 70
69 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); 71 connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
70 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); 72 connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
71 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); 73 connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
72 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); 74 connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
73 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); 75 connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
74 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); 76 connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
75 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); 77 connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
76} 78}
77 79
78void ComposeMail::pickAddress( QLineEdit *line ) 80void ComposeMail::pickAddress( QLineEdit *line )
79{ 81{
80 QString names = AddressPicker::getNames(); 82 QString names = AddressPicker::getNames();
81 if ( line->text().isEmpty() ) { 83 if ( line->text().isEmpty() ) {
82 line->setText( names ); 84 line->setText( names );
83 } else if ( !names.isEmpty() ) { 85 } else if ( !names.isEmpty() ) {
84 line->setText( line->text() + ", " + names ); 86 line->setText( line->text() + ", " + names );
85 } 87 }
86} 88}
87 89
88 90
89void ComposeMail::setTo( const QString & to ) 91void ComposeMail::setTo( const QString & to )
90{ 92{
91 toLine->setText( to ); 93 toLine->setText( to );
92} 94}
93 95
94void ComposeMail::setSubject( const QString & subject ) 96void ComposeMail::setSubject( const QString & subject )
95{ 97{
96 subjectLine->setText( subject ); 98 subjectLine->setText( subject );
97} 99}
98 100
99void ComposeMail::setInReplyTo( const QString & messageId ) 101void ComposeMail::setInReplyTo( const QString & messageId )
100{ 102{
101 m_replyid = messageId; 103 m_replyid = messageId;
102} 104}
103 105
104void ComposeMail::setMessage( const QString & text ) 106void ComposeMail::setMessage( const QString & text )
105{ 107{
106 message->setText( text ); 108 message->setText( text );
107} 109}
108 110
109 111
110void ComposeMail::pickAddressTo() 112void ComposeMail::pickAddressTo()
111{ 113{
112 pickAddress( toLine ); 114 pickAddress( toLine );
113} 115}
114 116
115void ComposeMail::pickAddressCC() 117void ComposeMail::pickAddressCC()
116{ 118{
117 pickAddress( ccLine ); 119 pickAddress( ccLine );
118} 120}
119 121
120void ComposeMail::pickAddressBCC() 122void ComposeMail::pickAddressBCC()
121{ 123{
122 pickAddress( bccLine ); 124 pickAddress( bccLine );
123} 125}
124 126
125void ComposeMail::pickAddressReply() 127void ComposeMail::pickAddressReply()
126{ 128{
127 pickAddress( replyLine ); 129 pickAddress( replyLine );
128} 130}
129 131
130void ComposeMail::fillValues( int ) 132void ComposeMail::fillValues( int )
131{ 133{
132#if 0 134#if 0
133 SMTPaccount *smtp = smtpAccounts.at( current ); 135 SMTPaccount *smtp = smtpAccounts.at( current );
134 ccLine->clear(); 136 ccLine->clear();
135 if ( smtp->getUseCC() ) { 137 if ( smtp->getUseCC() ) {
136 ccLine->setText( smtp->getCC() ); 138 ccLine->setText( smtp->getCC() );
137 } 139 }
138 bccLine->clear(); 140 bccLine->clear();
139 if ( smtp->getUseBCC() ) { 141 if ( smtp->getUseBCC() ) {
140 bccLine->setText( smtp->getBCC() ); 142 bccLine->setText( smtp->getBCC() );
141 } 143 }
142 replyLine->clear(); 144 replyLine->clear();
143 if ( smtp->getUseReply() ) { 145 if ( smtp->getUseReply() ) {
144 replyLine->setText( smtp->getReply() ); 146 replyLine->setText( smtp->getReply() );
145 } 147 }
146 sigMultiLine->setText( smtp->getSignature() ); 148 sigMultiLine->setText( smtp->getSignature() );
147#endif 149#endif
148} 150}
149 151
150void ComposeMail::slotAdjustColumns() 152void ComposeMail::slotAdjustColumns()
151{ 153{
152 int currPage = tabWidget->currentPageIndex(); 154 int currPage = tabWidget->currentPageIndex();
153 155
154 tabWidget->showPage( attachTab ); 156 tabWidget->showPage( attachTab );
155 attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); 157 attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
156 attList->setColumnWidth( 1, 80 ); 158 attList->setColumnWidth( 1, 80 );
157 159
158 tabWidget->setCurrentPage( currPage ); 160 tabWidget->setCurrentPage( currPage );
159} 161}
160 162
161void ComposeMail::addAttachment() 163void ComposeMail::addAttachment()
162{ 164{
163 DocLnk lnk = Opie::OFileDialog::getOpenFileName( 1, "/" ); 165 DocLnk lnk = OFileDialog::getOpenFileName( 1, "/" );
164 if ( !lnk.name().isEmpty() ) { 166 if ( !lnk.name().isEmpty() ) {
165 Attachment *att = new Attachment( lnk ); 167 Attachment *att = new Attachment( lnk );
166 (void) new AttachViewItem( attList, att ); 168 (void) new AttachViewItem( attList, att );
167 } 169 }
168} 170}
169 171
170void ComposeMail::removeAttachment() 172void ComposeMail::removeAttachment()
171{ 173{
172 if ( !attList->currentItem() ) { 174 if ( !attList->currentItem() ) {
173 QMessageBox::information( this, tr( "Error" ), 175 QMessageBox::information( this, tr( "Error" ),
174 tr( "<p>Please select a File.</p>" ), 176 tr( "<p>Please select a File.</p>" ),
175 tr( "Ok" ) ); 177 tr( "Ok" ) );
176 } else { 178 } else {
177 attList->takeItem( attList->currentItem() ); 179 attList->takeItem( attList->currentItem() );
178 } 180 }
179} 181}
180 182
181void ComposeMail::accept() 183void ComposeMail::accept()
182{ 184{
183 if ( checkBoxLater->isChecked() ) { 185 if ( checkBoxLater->isChecked() ) {
184 qDebug( "Send later" ); 186 qDebug( "Send later" );
185 } 187 }
186 188
187#if 0 189#if 0
188 qDebug( "Sending Mail with " + 190 qDebug( "Sending Mail with " +
189 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() ); 191 smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() );
190#endif 192#endif
191 Opie::OSmartPointer<Mail> mail=new Mail; 193 Opie::Core::OSmartPointer<Mail> mail=new Mail;
192 194
193 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); 195 SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() );
194 mail->setMail(fromBox->currentText()); 196 mail->setMail(fromBox->currentText());
195 197
196 if ( !toLine->text().isEmpty() ) { 198 if ( !toLine->text().isEmpty() ) {
197 mail->setTo( toLine->text() ); 199 mail->setTo( toLine->text() );
198 } else { 200 } else {
199 QMessageBox::warning(0,tr("Sending mail"), 201 QMessageBox::warning(0,tr("Sending mail"),
200 tr("No Receiver spezified" ) ); 202 tr("No Receiver spezified" ) );
201 return; 203 return;
202 } 204 }
203 mail->setName(senderNameEdit->text()); 205 mail->setName(senderNameEdit->text());
204 mail->setCC( ccLine->text() ); 206 mail->setCC( ccLine->text() );
205 mail->setBCC( bccLine->text() ); 207 mail->setBCC( bccLine->text() );
206 mail->setReply( replyLine->text() ); 208 mail->setReply( replyLine->text() );
207 mail->setSubject( subjectLine->text() ); 209 mail->setSubject( subjectLine->text() );
208 if (!m_replyid.isEmpty()) { 210 if (!m_replyid.isEmpty()) {
209 QStringList ids; 211 QStringList ids;
210 ids.append(m_replyid); 212 ids.append(m_replyid);
211 mail->setInreply(ids); 213 mail->setInreply(ids);
212 } 214 }
213 QString txt = message->text(); 215 QString txt = message->text();
214 if ( !sigMultiLine->text().isEmpty() ) { 216 if ( !sigMultiLine->text().isEmpty() ) {
215 txt.append( "\n--\n" ); 217 txt.append( "\n--\n" );
216 txt.append( sigMultiLine->text() ); 218 txt.append( sigMultiLine->text() );
217 } 219 }
218 mail->setMessage( txt ); 220 mail->setMessage( txt );
219 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 221 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
220 while ( it != NULL ) { 222 while ( it != NULL ) {
221 mail->addAttachment( it->getAttachment() ); 223 mail->addAttachment( it->getAttachment() );
222 it = (AttachViewItem *) it->nextSibling(); 224 it = (AttachViewItem *) it->nextSibling();
223 } 225 }
224 226
225 SMTPwrapper wrapper( smtp ); 227 SMTPwrapper wrapper( smtp );
226 wrapper.sendMail( mail,checkBoxLater->isChecked() ); 228 wrapper.sendMail( mail,checkBoxLater->isChecked() );
227 229
228 QDialog::accept(); 230 QDialog::accept();
229} 231}
230 232
231void ComposeMail::reject() 233void ComposeMail::reject()
232{ 234{
233 int yesno = QMessageBox::warning(0,tr("Store message"), 235 int yesno = QMessageBox::warning(0,tr("Store message"),
234 tr("Store message into drafts?"), 236 tr("Store message into drafts?"),
235 tr("Yes"), 237 tr("Yes"),
236 tr("No"),QString::null,0,1); 238 tr("No"),QString::null,0,1);
237 239
238 if (yesno == 0) { 240 if (yesno == 0) {
239 Opie::OSmartPointer<Mail> mail=new Mail(); 241 Opie::Core::OSmartPointer<Mail> mail=new Mail();
240 mail->setMail(fromBox->currentText()); 242 mail->setMail(fromBox->currentText());
241 mail->setTo( toLine->text() ); 243 mail->setTo( toLine->text() );
242 mail->setName(senderNameEdit->text()); 244 mail->setName(senderNameEdit->text());
243 mail->setCC( ccLine->text() ); 245 mail->setCC( ccLine->text() );
244 mail->setBCC( bccLine->text() ); 246 mail->setBCC( bccLine->text() );
245 mail->setReply( replyLine->text() ); 247 mail->setReply( replyLine->text() );
246 mail->setSubject( subjectLine->text() ); 248 mail->setSubject( subjectLine->text() );
247 if (!m_replyid.isEmpty()) { 249 if (!m_replyid.isEmpty()) {
248 QStringList ids; 250 QStringList ids;
249 ids.append(m_replyid); 251 ids.append(m_replyid);
250 mail->setInreply(ids); 252 mail->setInreply(ids);
251 } 253 }
252 QString txt = message->text(); 254 QString txt = message->text();
253 if ( !sigMultiLine->text().isEmpty() ) { 255 if ( !sigMultiLine->text().isEmpty() ) {
254 txt.append( "\n--\n" ); 256 txt.append( "\n--\n" );
255 txt.append( sigMultiLine->text() ); 257 txt.append( sigMultiLine->text() );
256 } 258 }
257 qDebug(txt); 259 qDebug(txt);
258 mail->setMessage( txt ); 260 mail->setMessage( txt );
259 261
260 /* only use the default drafts folder name! */ 262 /* only use the default drafts folder name! */
261 Storemail wrapper(AbstractMail::draftFolder()); 263 Storemail wrapper(AbstractMail::draftFolder());
262 wrapper.storeMail(mail); 264 wrapper.storeMail(mail);
263 265
264 AttachViewItem *it = (AttachViewItem *) attList->firstChild(); 266 AttachViewItem *it = (AttachViewItem *) attList->firstChild();
265 /* attachments we will ignore! */ 267 /* attachments we will ignore! */
266 if ( it != NULL ) { 268 if ( it != NULL ) {
267 QMessageBox::warning(0,tr("Store message"), 269 QMessageBox::warning(0,tr("Store message"),
268 tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); 270 tr("<center>Attachments will not be stored in \"Draft\" folder</center>"));
269 } 271 }
270 } 272 }
271 QDialog::reject(); 273 QDialog::reject();
272} 274}
273 275
274ComposeMail::~ComposeMail() 276ComposeMail::~ComposeMail()
275{ 277{
276} 278}
277 279
278void ComposeMail::reEditMail(const RecMailP&current) 280void ComposeMail::reEditMail(const RecMailP&current)
279{ 281{
280 RecMailP data = current; 282 RecMailP data = current;
281 message->setText(data->Wrapper()->fetchBody(current).Bodytext()); 283 message->setText(data->Wrapper()->fetchBody(current).Bodytext());
282 subjectLine->setText( data->getSubject()); 284 subjectLine->setText( data->getSubject());
283 toLine->setText(data->To().join(",")); 285 toLine->setText(data->To().join(","));
284 ccLine->setText(data->CC().join(",")); 286 ccLine->setText(data->CC().join(","));
285 bccLine->setText(data->Bcc().join(",")); 287 bccLine->setText(data->Bcc().join(","));
286 replyLine->setText(data->Replyto()); 288 replyLine->setText(data->Replyto());
287} 289}
288 290
289AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) 291AttachViewItem::AttachViewItem( QListView *parent, Attachment *att )
290 : QListViewItem( parent ) 292 : QListViewItem( parent )
291{ 293{
292 attachment = att; 294 attachment = att;
293 qDebug( att->getMimeType() ); 295 qDebug( att->getMimeType() );
294 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ? 296 setPixmap( 0, attachment->getDocLnk().pixmap().isNull() ?
295 Resource::loadPixmap( "UnknownDocument-14" ) : 297 Resource::loadPixmap( "UnknownDocument-14" ) :
296 attachment->getDocLnk().pixmap() ); 298 attachment->getDocLnk().pixmap() );
297 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); 299 setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() );
298 setText( 1, QString::number( att->getSize() ) ); 300 setText( 1, QString::number( att->getSize() ) );
299} 301}
300 302
diff --git a/noncore/net/mail/composemail.h b/noncore/net/mail/composemail.h
index c12eb30..4693927 100644
--- a/noncore/net/mail/composemail.h
+++ b/noncore/net/mail/composemail.h
@@ -1,81 +1,81 @@
1#ifndef COMPOSEMAIL_H 1#ifndef COMPOSEMAIL_H
2#define COMPOSEMAIL_H 2#define COMPOSEMAIL_H
3 3
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qlistview.h> 5#include <qlistview.h>
6 6
7#include "composemailui.h" 7#include "composemailui.h"
8#include "addresspickerui.h" 8#include "addresspickerui.h"
9#include <libmailwrapper/settings.h> 9#include <libmailwrapper/settings.h>
10#include <libmailwrapper/mailwrapper.h> 10#include <libmailwrapper/mailwrapper.h>
11 11
12class RecMail; 12class RecMail;
13 13
14#include <opie2/osmartpointer.h> 14#include <opie2/osmartpointer.h>
15 15
16class AddressPicker : public AddressPickerUI 16class AddressPicker : public AddressPickerUI
17{ 17{
18 Q_OBJECT 18 Q_OBJECT
19 19
20public: 20public:
21 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 21 AddressPicker( QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
22 static QString getNames(); 22 static QString getNames();
23 23
24protected: 24protected:
25 QString selectedNames; 25 QString selectedNames;
26 void accept(); 26 void accept();
27 27
28}; 28};
29 29
30class RecMail; 30class RecMail;
31 31
32class ComposeMail : public ComposeMailUI 32class ComposeMail : public ComposeMailUI
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35 35
36public: 36public:
37 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 ); 37 ComposeMail( Settings *s, QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags flags = 0 );
38 virtual ~ComposeMail(); 38 virtual ~ComposeMail();
39 39
40 void reEditMail(const Opie::OSmartPointer<RecMail>&current); 40 void reEditMail(const Opie::Core::OSmartPointer<RecMail>&current);
41 41
42public slots: 42public slots:
43 void slotAdjustColumns(); 43 void slotAdjustColumns();
44 44
45 void setTo( const QString & to ); 45 void setTo( const QString & to );
46 void setSubject( const QString & subject ); 46 void setSubject( const QString & subject );
47 void setInReplyTo( const QString & messageId ); 47 void setInReplyTo( const QString & messageId );
48 void setMessage( const QString & text ); 48 void setMessage( const QString & text );
49 49
50protected slots: 50protected slots:
51 void accept(); 51 void accept();
52 void reject(); 52 void reject();
53 53
54private slots: 54private slots:
55 void fillValues( int current ); 55 void fillValues( int current );
56 void pickAddress( QLineEdit *line ); 56 void pickAddress( QLineEdit *line );
57 void pickAddressTo(); 57 void pickAddressTo();
58 void pickAddressCC(); 58 void pickAddressCC();
59 void pickAddressBCC(); 59 void pickAddressBCC();
60 void pickAddressReply(); 60 void pickAddressReply();
61 void addAttachment(); 61 void addAttachment();
62 void removeAttachment(); 62 void removeAttachment();
63 63
64protected: 64protected:
65 Settings *settings; 65 Settings *settings;
66 QList<SMTPaccount> smtpAccounts; 66 QList<SMTPaccount> smtpAccounts;
67 QString m_replyid; 67 QString m_replyid;
68}; 68};
69 69
70class AttachViewItem : public QListViewItem 70class AttachViewItem : public QListViewItem
71{ 71{
72public: 72public:
73 AttachViewItem( QListView *parent, Attachment *att ); 73 AttachViewItem( QListView *parent, Attachment *att );
74 Attachment *getAttachment() { return attachment; } 74 Attachment *getAttachment() { return attachment; }
75 75
76private: 76private:
77 Attachment *attachment; 77 Attachment *attachment;
78 78
79}; 79};
80 80
81#endif 81#endif
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.cpp b/noncore/net/mail/libmailwrapper/abstractmail.cpp
index 68a7a4d..6bebb7b 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.cpp
+++ b/noncore/net/mail/libmailwrapper/abstractmail.cpp
@@ -1,167 +1,168 @@
1#include "abstractmail.h" 1#include "abstractmail.h"
2#include "imapwrapper.h" 2#include "imapwrapper.h"
3#include "pop3wrapper.h" 3#include "pop3wrapper.h"
4#include "nntpwrapper.h" 4#include "nntpwrapper.h"
5#include "mhwrapper.h" 5#include "mhwrapper.h"
6#include "mailtypes.h" 6#include "mailtypes.h"
7 7
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <stdlib.h> 10#include <stdlib.h>
11#include <libetpan/mailmime_content.h> 11#include <libetpan/mailmime_content.h>
12#include <libetpan/mailmime.h> 12#include <libetpan/mailmime.h>
13 13
14using namespace Opie::Core;
14AbstractMail* AbstractMail::getWrapper(IMAPaccount *a) 15AbstractMail* AbstractMail::getWrapper(IMAPaccount *a)
15{ 16{
16 return new IMAPwrapper(a); 17 return new IMAPwrapper(a);
17} 18}
18 19
19AbstractMail* AbstractMail::getWrapper(POP3account *a) 20AbstractMail* AbstractMail::getWrapper(POP3account *a)
20{ 21{
21 return new POP3wrapper(a); 22 return new POP3wrapper(a);
22} 23}
23 24
24AbstractMail* AbstractMail::getWrapper(NNTPaccount *a) 25AbstractMail* AbstractMail::getWrapper(NNTPaccount *a)
25{ 26{
26 return new NNTPwrapper(a); 27 return new NNTPwrapper(a);
27} 28}
28 29
29AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name) 30AbstractMail* AbstractMail::getWrapper(const QString&a,const QString&name)
30{ 31{
31 return new MHwrapper(a,name); 32 return new MHwrapper(a,name);
32} 33}
33 34
34AbstractMail* AbstractMail::getWrapper(Account*a) 35AbstractMail* AbstractMail::getWrapper(Account*a)
35{ 36{
36 if (!a) return 0; 37 if (!a) return 0;
37 switch (a->getType()) { 38 switch (a->getType()) {
38 case MAILLIB::A_IMAP: 39 case MAILLIB::A_IMAP:
39 return new IMAPwrapper((IMAPaccount*)a); 40 return new IMAPwrapper((IMAPaccount*)a);
40 break; 41 break;
41 case MAILLIB::A_POP3: 42 case MAILLIB::A_POP3:
42 return new POP3wrapper((POP3account*)a); 43 return new POP3wrapper((POP3account*)a);
43 break; 44 break;
44 case MAILLIB::A_NNTP: 45 case MAILLIB::A_NNTP:
45 return new NNTPwrapper((NNTPaccount*)a); 46 return new NNTPwrapper((NNTPaccount*)a);
46 break; 47 break;
47 default: 48 default:
48 return 0; 49 return 0;
49 } 50 }
50} 51}
51 52
52encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc) 53encodedString* AbstractMail::decode_String(const encodedString*text,const QString&enc)
53{ 54{
54 qDebug("Decode string start"); 55 qDebug("Decode string start");
55 char*result_text; 56 char*result_text;
56 size_t index = 0; 57 size_t index = 0;
57 /* reset for recursive use! */ 58 /* reset for recursive use! */
58 size_t target_length = 0; 59 size_t target_length = 0;
59 result_text = 0; 60 result_text = 0;
60 int mimetype = MAILMIME_MECHANISM_7BIT; 61 int mimetype = MAILMIME_MECHANISM_7BIT;
61 if (enc.lower()=="quoted-printable") { 62 if (enc.lower()=="quoted-printable") {
62 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 63 mimetype = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
63 } else if (enc.lower()=="base64") { 64 } else if (enc.lower()=="base64") {
64 mimetype = MAILMIME_MECHANISM_BASE64; 65 mimetype = MAILMIME_MECHANISM_BASE64;
65 } else if (enc.lower()=="8bit") { 66 } else if (enc.lower()=="8bit") {
66 mimetype = MAILMIME_MECHANISM_8BIT; 67 mimetype = MAILMIME_MECHANISM_8BIT;
67 } else if (enc.lower()=="binary") { 68 } else if (enc.lower()=="binary") {
68 mimetype = MAILMIME_MECHANISM_BINARY; 69 mimetype = MAILMIME_MECHANISM_BINARY;
69 } 70 }
70 71
71 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype, 72 int err = mailmime_part_parse(text->Content(),text->Length(),&index,mimetype,
72 &result_text,&target_length); 73 &result_text,&target_length);
73 74
74 encodedString* result = new encodedString(); 75 encodedString* result = new encodedString();
75 if (err == MAILIMF_NO_ERROR) { 76 if (err == MAILIMF_NO_ERROR) {
76 result->setContent(result_text,target_length); 77 result->setContent(result_text,target_length);
77 } 78 }
78 qDebug("Decode string finished"); 79 qDebug("Decode string finished");
79 return result; 80 return result;
80} 81}
81 82
82QString AbstractMail::convert_String(const char*text) 83QString AbstractMail::convert_String(const char*text)
83{ 84{
84 //size_t index = 0; 85 //size_t index = 0;
85 char*res = 0; 86 char*res = 0;
86 int err = MAILIMF_NO_ERROR; 87 int err = MAILIMF_NO_ERROR;
87 88
88 QString result(text); 89 QString result(text);
89 90
90 /* due a bug in libetpan it isn't usable this moment */ 91 /* due a bug in libetpan it isn't usable this moment */
91/* int err = mailmime_encoded_phrase_parse("iso-8859-1", 92/* int err = mailmime_encoded_phrase_parse("iso-8859-1",
92 text, strlen(text),&index, "iso-8859-1",&res);*/ 93 text, strlen(text),&index, "iso-8859-1",&res);*/
93 //qDebug("Input: %s",text); 94 //qDebug("Input: %s",text);
94 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 95 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
95// result = QString(res); 96// result = QString(res);
96// qDebug("Res: %s, length: %i",res,strlen(res)); 97// qDebug("Res: %s, length: %i",res,strlen(res));
97 } 98 }
98 if (res) free(res); 99 if (res) free(res);
99 return result; 100 return result;
100} 101}
101 102
102/* cp & paste from launcher */ 103/* cp & paste from launcher */
103QString AbstractMail::gen_attachment_id() 104QString AbstractMail::gen_attachment_id()
104{ 105{
105 QFile file( "/proc/sys/kernel/random/uuid" ); 106 QFile file( "/proc/sys/kernel/random/uuid" );
106 if (!file.open(IO_ReadOnly ) ) 107 if (!file.open(IO_ReadOnly ) )
107 return QString::null; 108 return QString::null;
108 109
109 QTextStream stream(&file); 110 QTextStream stream(&file);
110 111
111 return "{" + stream.read().stripWhiteSpace() + "}"; 112 return "{" + stream.read().stripWhiteSpace() + "}";
112} 113}
113 114
114int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool) 115int AbstractMail::createMbox(const QString&,const FolderP&,const QString& ,bool)
115{ 116{
116 return 0; 117 return 0;
117} 118}
118 119
119QString AbstractMail::defaultLocalfolder() 120QString AbstractMail::defaultLocalfolder()
120{ 121{
121 QString f = getenv( "HOME" ); 122 QString f = getenv( "HOME" );
122 f += "/Applications/opiemail/localmail"; 123 f += "/Applications/opiemail/localmail";
123 return f; 124 return f;
124} 125}
125 126
126QString AbstractMail::draftFolder() 127QString AbstractMail::draftFolder()
127{ 128{
128 return QString("Drafts"); 129 return QString("Drafts");
129} 130}
130 131
131/* temporary - will be removed when implemented in all classes */ 132/* temporary - will be removed when implemented in all classes */
132void AbstractMail::deleteMails(const QString &,const QValueList<Opie::OSmartPointer<RecMail> > &) 133void AbstractMail::deleteMails(const QString &,const QValueList<Opie::Core::OSmartPointer<RecMail> > &)
133{ 134{
134} 135}
135 136
136void AbstractMail::mvcpAllMails(const FolderP&fromFolder, 137void AbstractMail::mvcpAllMails(const FolderP&fromFolder,
137 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 138 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
138{ 139{
139 QValueList<RecMailP> t; 140 QValueList<RecMailP> t;
140 listMessages(fromFolder->getName(),t); 141 listMessages(fromFolder->getName(),t);
141 encodedString*st = 0; 142 encodedString*st = 0;
142 while (t.count()>0) { 143 while (t.count()>0) {
143 RecMailP r = (*t.begin()); 144 RecMailP r = (*t.begin());
144 st = fetchRawBody(r); 145 st = fetchRawBody(r);
145 if (st) { 146 if (st) {
146 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 147 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
147 delete st; 148 delete st;
148 } 149 }
149 t.remove(t.begin()); 150 t.remove(t.begin());
150 } 151 }
151 if (moveit) { 152 if (moveit) {
152 deleteAllMail(fromFolder); 153 deleteAllMail(fromFolder);
153 } 154 }
154} 155}
155 156
156void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 157void AbstractMail::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
157{ 158{
158 encodedString*st = 0; 159 encodedString*st = 0;
159 st = fetchRawBody(mail); 160 st = fetchRawBody(mail);
160 if (st) { 161 if (st) {
161 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder); 162 targetWrapper->storeMessage(st->Content(),st->Length(),targetFolder);
162 delete st; 163 delete st;
163 } 164 }
164 if (moveit) { 165 if (moveit) {
165 deleteMail(mail); 166 deleteMail(mail);
166 } 167 }
167} 168}
diff --git a/noncore/net/mail/libmailwrapper/abstractmail.h b/noncore/net/mail/libmailwrapper/abstractmail.h
index b03d757..2d55c83 100644
--- a/noncore/net/mail/libmailwrapper/abstractmail.h
+++ b/noncore/net/mail/libmailwrapper/abstractmail.h
@@ -1,72 +1,72 @@
1#ifndef __abstract_mail_ 1#ifndef __abstract_mail_
2#define __abstract_mail_ 2#define __abstract_mail_
3 3
4#include "maildefines.h" 4#include "maildefines.h"
5 5
6#include "settings.h" 6#include "settings.h"
7 7
8#include <qobject.h> 8#include <qobject.h>
9#include <opie2/osmartpointer.h> 9#include <opie2/osmartpointer.h>
10#include "mailtypes.h" 10#include "mailtypes.h"
11 11
12class IMAPwrapper; 12class IMAPwrapper;
13class POP3wrapper; 13class POP3wrapper;
14class Folder; 14class Folder;
15class encodedString; 15class encodedString;
16struct folderStat; 16struct folderStat;
17 17
18class AbstractMail:public QObject 18class AbstractMail:public QObject
19{ 19{
20 Q_OBJECT 20 Q_OBJECT
21public: 21public:
22 AbstractMail(){}; 22 AbstractMail(){};
23 virtual ~AbstractMail(){} 23 virtual ~AbstractMail(){}
24 virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders()=0; 24 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders()=0;
25 virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0; 25 virtual void listMessages(const QString & mailbox,QValueList<RecMailP>&target )=0;
26 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0; 26 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX")=0;
27 virtual RecBody fetchBody(const RecMailP&mail)=0; 27 virtual RecBody fetchBody(const RecMailP&mail)=0;
28 virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0; 28 virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part)=0;
29 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0; 29 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part)=0;
30 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0; 30 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part)=0;
31 virtual encodedString* fetchRawBody(const RecMailP&mail)=0; 31 virtual encodedString* fetchRawBody(const RecMailP&mail)=0;
32 32
33 virtual void deleteMail(const RecMailP&mail)=0; 33 virtual void deleteMail(const RecMailP&mail)=0;
34 virtual void answeredMail(const RecMailP&mail)=0; 34 virtual void answeredMail(const RecMailP&mail)=0;
35 virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&)=0; 35 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&)=0;
36 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> >&target); 36 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> >&target);
37 virtual int deleteMbox(const Opie::OSmartPointer<Folder>&)=0; 37 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&)=0;
38 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0; 38 virtual void storeMessage(const char*msg,size_t length, const QString&folder)=0;
39 39
40 virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, 40 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
41 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 41 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
42 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 42 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
43 43
44 virtual void cleanMimeCache(){}; 44 virtual void cleanMimeCache(){};
45 /* mail box methods */ 45 /* mail box methods */
46 /* parameter is the box to create. 46 /* parameter is the box to create.
47 * if the implementing subclass has prefixes, 47 * if the implementing subclass has prefixes,
48 * them has to be appended automatic. 48 * them has to be appended automatic.
49 */ 49 */
50 virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0, 50 virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
51 const QString& delemiter="/",bool getsubfolder=false); 51 const QString& delemiter="/",bool getsubfolder=false);
52 virtual void logout()=0; 52 virtual void logout()=0;
53 53
54 static AbstractMail* getWrapper(IMAPaccount *a); 54 static AbstractMail* getWrapper(IMAPaccount *a);
55 static AbstractMail* getWrapper(POP3account *a); 55 static AbstractMail* getWrapper(POP3account *a);
56 static AbstractMail* getWrapper(NNTPaccount *a); 56 static AbstractMail* getWrapper(NNTPaccount *a);
57 /* mbox only! */ 57 /* mbox only! */
58 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders"); 58 static AbstractMail* getWrapper(const QString&a,const QString&name="Local Folders");
59 static AbstractMail* getWrapper(Account*a); 59 static AbstractMail* getWrapper(Account*a);
60 60
61 static QString defaultLocalfolder(); 61 static QString defaultLocalfolder();
62 static QString draftFolder(); 62 static QString draftFolder();
63 63
64 virtual MAILLIB::ATYPE getType()const=0; 64 virtual MAILLIB::ATYPE getType()const=0;
65 virtual const QString&getName()const=0; 65 virtual const QString&getName()const=0;
66 66
67protected: 67protected:
68 static encodedString*decode_String(const encodedString*text,const QString&enc); 68 static encodedString*decode_String(const encodedString*text,const QString&enc);
69 static QString convert_String(const char*text); 69 static QString convert_String(const char*text);
70 static QString gen_attachment_id(); 70 static QString gen_attachment_id();
71}; 71};
72#endif 72#endif
diff --git a/noncore/net/mail/libmailwrapper/generatemail.cpp b/noncore/net/mail/libmailwrapper/generatemail.cpp
index cb7ccc0..cb58d82 100644
--- a/noncore/net/mail/libmailwrapper/generatemail.cpp
+++ b/noncore/net/mail/libmailwrapper/generatemail.cpp
@@ -1,467 +1,468 @@
1#include "generatemail.h" 1#include "generatemail.h"
2#include "mailwrapper.h" 2#include "mailwrapper.h"
3 3
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5 5
6#include <qt.h> 6#include <qt.h>
7 7
8using namespace Opie::Core;
8const char* Generatemail::USER_AGENT="OpieMail v0.6"; 9const char* Generatemail::USER_AGENT="OpieMail v0.6";
9 10
10Generatemail::Generatemail() 11Generatemail::Generatemail()
11{ 12{
12} 13}
13 14
14Generatemail::~Generatemail() 15Generatemail::~Generatemail()
15{ 16{
16} 17}
17 18
18void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { 19void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) {
19 clistiter *it, *it2; 20 clistiter *it, *it2;
20 21
21 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { 22 for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) {
22 mailimf_address *addr; 23 mailimf_address *addr;
23 addr = (mailimf_address *) it->data; 24 addr = (mailimf_address *) it->data;
24 25
25 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { 26 if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) {
26 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); 27 esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL );
27 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { 28 } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) {
28 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; 29 clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list;
29 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { 30 for ( it2 = clist_begin( l ); it2; it2 = it2->next ) {
30 mailimf_mailbox *mbox; 31 mailimf_mailbox *mbox;
31 mbox = (mailimf_mailbox *) it2->data; 32 mbox = (mailimf_mailbox *) it2->data;
32 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); 33 esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL );
33 } 34 }
34 } 35 }
35 } 36 }
36} 37}
37 38
38char *Generatemail::getFrom( mailimf_field *ffrom) { 39char *Generatemail::getFrom( mailimf_field *ffrom) {
39 char *from = NULL; 40 char *from = NULL;
40 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) 41 if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM)
41 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { 42 && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) {
42 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; 43 clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list;
43 clistiter *it; 44 clistiter *it;
44 for ( it = clist_begin( cl ); it; it = it->next ) { 45 for ( it = clist_begin( cl ); it; it = it->next ) {
45 mailimf_mailbox *mb = (mailimf_mailbox *) it->data; 46 mailimf_mailbox *mb = (mailimf_mailbox *) it->data;
46 from = strdup( mb->mb_addr_spec ); 47 from = strdup( mb->mb_addr_spec );
47 } 48 }
48 } 49 }
49 50
50 return from; 51 return from;
51} 52}
52 53
53char *Generatemail::getFrom( mailmime *mail ) { 54char *Generatemail::getFrom( mailmime *mail ) {
54 /* no need to delete - its just a pointer to structure content */ 55 /* no need to delete - its just a pointer to structure content */
55 mailimf_field *ffrom = 0; 56 mailimf_field *ffrom = 0;
56 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); 57 ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM );
57 return getFrom(ffrom); 58 return getFrom(ffrom);
58} 59}
59 60
60mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { 61mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) {
61 mailimf_field *field; 62 mailimf_field *field;
62 clistiter *it; 63 clistiter *it;
63 64
64 it = clist_begin( fields->fld_list ); 65 it = clist_begin( fields->fld_list );
65 while ( it ) { 66 while ( it ) {
66 field = (mailimf_field *) it->data; 67 field = (mailimf_field *) it->data;
67 if ( field->fld_type == type ) { 68 if ( field->fld_type == type ) {
68 return field; 69 return field;
69 } 70 }
70 it = it->next; 71 it = it->next;
71 } 72 }
72 73
73 return NULL; 74 return NULL;
74} 75}
75 76
76mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { 77mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) {
77 mailimf_address_list *addresses; 78 mailimf_address_list *addresses;
78 79
79 if ( addr.isEmpty() ) 80 if ( addr.isEmpty() )
80 return NULL; 81 return NULL;
81 82
82 addresses = mailimf_address_list_new_empty(); 83 addresses = mailimf_address_list_new_empty();
83 84
84 bool literal_open = false; 85 bool literal_open = false;
85 unsigned int startpos = 0; 86 unsigned int startpos = 0;
86 QStringList list; 87 QStringList list;
87 QString s; 88 QString s;
88 unsigned int i = 0; 89 unsigned int i = 0;
89 for (; i < addr.length();++i) { 90 for (; i < addr.length();++i) {
90 switch (addr[i]) { 91 switch (addr[i]) {
91 case '\"': 92 case '\"':
92 literal_open = !literal_open; 93 literal_open = !literal_open;
93 break; 94 break;
94 case ',': 95 case ',':
95 if (!literal_open) { 96 if (!literal_open) {
96 s = addr.mid(startpos,i-startpos); 97 s = addr.mid(startpos,i-startpos);
97 if (!s.isEmpty()) { 98 if (!s.isEmpty()) {
98 list.append(s); 99 list.append(s);
99 qDebug("Appended %s",s.latin1()); 100 qDebug("Appended %s",s.latin1());
100 } 101 }
101 // !!!! this is a MUST BE! 102 // !!!! this is a MUST BE!
102 startpos = ++i; 103 startpos = ++i;
103 } 104 }
104 break; 105 break;
105 default: 106 default:
106 break; 107 break;
107 } 108 }
108 } 109 }
109 s = addr.mid(startpos,i-startpos); 110 s = addr.mid(startpos,i-startpos);
110 if (!s.isEmpty()) { 111 if (!s.isEmpty()) {
111 list.append(s); 112 list.append(s);
112 qDebug("Appended %s",s.latin1()); 113 qDebug("Appended %s",s.latin1());
113 } 114 }
114 QStringList::Iterator it; 115 QStringList::Iterator it;
115 for ( it = list.begin(); it != list.end(); it++ ) { 116 for ( it = list.begin(); it != list.end(); it++ ) {
116 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); 117 int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() );
117 if ( err != MAILIMF_NO_ERROR ) { 118 if ( err != MAILIMF_NO_ERROR ) {
118 qDebug( "Error parsing" ); 119 qDebug( "Error parsing" );
119 qDebug( *it ); 120 qDebug( *it );
120 } else { 121 } else {
121 qDebug( "Parse success! %s",(*it).latin1()); 122 qDebug( "Parse success! %s",(*it).latin1());
122 } 123 }
123 } 124 }
124 return addresses; 125 return addresses;
125} 126}
126 127
127mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { 128mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) {
128 mailmime * filePart = 0; 129 mailmime * filePart = 0;
129 mailmime_fields * fields = 0; 130 mailmime_fields * fields = 0;
130 mailmime_content * content = 0; 131 mailmime_content * content = 0;
131 mailmime_parameter * param = 0; 132 mailmime_parameter * param = 0;
132 char*name = 0; 133 char*name = 0;
133 char*file = 0; 134 char*file = 0;
134 int err; 135 int err;
135 136
136 int pos = filename.findRev( '/' ); 137 int pos = filename.findRev( '/' );
137 138
138 if (filename.length()>0) { 139 if (filename.length()>0) {
139 QString tmp = filename.right( filename.length() - ( pos + 1 ) ); 140 QString tmp = filename.right( filename.length() - ( pos + 1 ) );
140 name = strdup( tmp.latin1() ); // just filename 141 name = strdup( tmp.latin1() ); // just filename
141 file = strdup( filename.latin1() ); // full name with path 142 file = strdup( filename.latin1() ); // full name with path
142 } 143 }
143 144
144 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; 145 int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT;
145 int mechanism = MAILMIME_MECHANISM_BASE64; 146 int mechanism = MAILMIME_MECHANISM_BASE64;
146 147
147 if ( mimetype.startsWith( "text/" ) ) { 148 if ( mimetype.startsWith( "text/" ) ) {
148 param = mailmime_parameter_new( strdup( "charset" ), 149 param = mailmime_parameter_new( strdup( "charset" ),
149 strdup( "iso-8859-1" ) ); 150 strdup( "iso-8859-1" ) );
150 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; 151 mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
151 } 152 }
152 153
153 fields = mailmime_fields_new_filename( 154 fields = mailmime_fields_new_filename(
154 disptype, name, 155 disptype, name,
155 mechanism ); 156 mechanism );
156 content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); 157 content = mailmime_content_new_with_str( (char*)mimetype.latin1() );
157 if (content!=0 && fields != 0) { 158 if (content!=0 && fields != 0) {
158 if (param) { 159 if (param) {
159 clist_append(content->ct_parameters,param); 160 clist_append(content->ct_parameters,param);
160 param = 0; 161 param = 0;
161 } 162 }
162 if (filename.length()>0) { 163 if (filename.length()>0) {
163 QFileInfo f(filename); 164 QFileInfo f(filename);
164 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); 165 param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1()));
165 clist_append(content->ct_parameters,param); 166 clist_append(content->ct_parameters,param);
166 param = 0; 167 param = 0;
167 } 168 }
168 filePart = mailmime_new_empty( content, fields ); 169 filePart = mailmime_new_empty( content, fields );
169 } 170 }
170 if (filePart) { 171 if (filePart) {
171 if (filename.length()>0) { 172 if (filename.length()>0) {
172 err = mailmime_set_body_file( filePart, file ); 173 err = mailmime_set_body_file( filePart, file );
173 } else { 174 } else {
174 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); 175 err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length());
175 } 176 }
176 if (err != MAILIMF_NO_ERROR) { 177 if (err != MAILIMF_NO_ERROR) {
177 qDebug("Error setting body with file %s",file); 178 qDebug("Error setting body with file %s",file);
178 mailmime_free( filePart ); 179 mailmime_free( filePart );
179 filePart = 0; 180 filePart = 0;
180 } 181 }
181 } 182 }
182 183
183 if (!filePart) { 184 if (!filePart) {
184 if ( param != NULL ) { 185 if ( param != NULL ) {
185 mailmime_parameter_free( param ); 186 mailmime_parameter_free( param );
186 } 187 }
187 if (content) { 188 if (content) {
188 mailmime_content_free( content ); 189 mailmime_content_free( content );
189 } 190 }
190 if (fields) { 191 if (fields) {
191 mailmime_fields_free( fields ); 192 mailmime_fields_free( fields );
192 } else { 193 } else {
193 if (name) { 194 if (name) {
194 free( name ); 195 free( name );
195 } 196 }
196 if (file) { 197 if (file) {
197 free( file ); 198 free( file );
198 } 199 }
199 } 200 }
200 } 201 }
201 return filePart; // Success :) 202 return filePart; // Success :)
202 203
203} 204}
204 205
205void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { 206void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) {
206 const Attachment *it; 207 const Attachment *it;
207 unsigned int count = files.count(); 208 unsigned int count = files.count();
208 qDebug("List contains %i values",count); 209 qDebug("List contains %i values",count);
209 for ( unsigned int i = 0; i < count; ++i ) { 210 for ( unsigned int i = 0; i < count; ++i ) {
210 qDebug( "Adding file" ); 211 qDebug( "Adding file" );
211 mailmime *filePart; 212 mailmime *filePart;
212 int err; 213 int err;
213 it = ((QList<Attachment>)files).at(i); 214 it = ((QList<Attachment>)files).at(i);
214 215
215 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); 216 filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" );
216 if ( filePart == NULL ) { 217 if ( filePart == NULL ) {
217 qDebug( "addFileParts: error adding file:" ); 218 qDebug( "addFileParts: error adding file:" );
218 qDebug( it->getFileName() ); 219 qDebug( it->getFileName() );
219 continue; 220 continue;
220 } 221 }
221 err = mailmime_smart_add_part( message, filePart ); 222 err = mailmime_smart_add_part( message, filePart );
222 if ( err != MAILIMF_NO_ERROR ) { 223 if ( err != MAILIMF_NO_ERROR ) {
223 mailmime_free( filePart ); 224 mailmime_free( filePart );
224 qDebug("error smart add"); 225 qDebug("error smart add");
225 } 226 }
226 } 227 }
227} 228}
228 229
229mailmime *Generatemail::buildTxtPart(const QString&str ) { 230mailmime *Generatemail::buildTxtPart(const QString&str ) {
230 mailmime *txtPart; 231 mailmime *txtPart;
231 mailmime_fields *fields; 232 mailmime_fields *fields;
232 mailmime_content *content; 233 mailmime_content *content;
233 mailmime_parameter *param; 234 mailmime_parameter *param;
234 int err; 235 int err;
235 236
236 param = mailmime_parameter_new( strdup( "charset" ), 237 param = mailmime_parameter_new( strdup( "charset" ),
237 strdup( "iso-8859-1" ) ); 238 strdup( "iso-8859-1" ) );
238 if ( param == NULL ) 239 if ( param == NULL )
239 goto err_free; 240 goto err_free;
240 241
241 content = mailmime_content_new_with_str( "text/plain" ); 242 content = mailmime_content_new_with_str( "text/plain" );
242 if ( content == NULL ) 243 if ( content == NULL )
243 goto err_free_param; 244 goto err_free_param;
244 245
245 err = clist_append( content->ct_parameters, param ); 246 err = clist_append( content->ct_parameters, param );
246 if ( err != MAILIMF_NO_ERROR ) 247 if ( err != MAILIMF_NO_ERROR )
247 goto err_free_content; 248 goto err_free_content;
248 249
249 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); 250 fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT);
250 if ( fields == NULL ) 251 if ( fields == NULL )
251 goto err_free_content; 252 goto err_free_content;
252 253
253 txtPart = mailmime_new_empty( content, fields ); 254 txtPart = mailmime_new_empty( content, fields );
254 if ( txtPart == NULL ) 255 if ( txtPart == NULL )
255 goto err_free_fields; 256 goto err_free_fields;
256 257
257 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); 258 err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() );
258 if ( err != MAILIMF_NO_ERROR ) 259 if ( err != MAILIMF_NO_ERROR )
259 goto err_free_txtPart; 260 goto err_free_txtPart;
260 261
261 return txtPart; // Success :) 262 return txtPart; // Success :)
262 263
263err_free_txtPart: 264err_free_txtPart:
264 mailmime_free( txtPart ); 265 mailmime_free( txtPart );
265err_free_fields: 266err_free_fields:
266 mailmime_fields_free( fields ); 267 mailmime_fields_free( fields );
267err_free_content: 268err_free_content:
268 mailmime_content_free( content ); 269 mailmime_content_free( content );
269err_free_param: 270err_free_param:
270 mailmime_parameter_free( param ); 271 mailmime_parameter_free( param );
271err_free: 272err_free:
272 qDebug( "buildTxtPart - error" ); 273 qDebug( "buildTxtPart - error" );
273 274
274 return NULL; // Error :( 275 return NULL; // Error :(
275} 276}
276 277
277mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { 278mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) {
278 return mailimf_mailbox_new( strdup( name.latin1() ), 279 return mailimf_mailbox_new( strdup( name.latin1() ),
279 strdup( mail.latin1() ) ); 280 strdup( mail.latin1() ) );
280} 281}
281 282
282mailimf_fields *Generatemail::createImfFields(const Opie::OSmartPointer<Mail>&mail ) 283mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail )
283{ 284{
284 mailimf_fields *fields = NULL; 285 mailimf_fields *fields = NULL;
285 mailimf_field *xmailer = NULL; 286 mailimf_field *xmailer = NULL;
286 mailimf_mailbox *sender=0,*fromBox=0; 287 mailimf_mailbox *sender=0,*fromBox=0;
287 mailimf_mailbox_list *from=0; 288 mailimf_mailbox_list *from=0;
288 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; 289 mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0;
289 clist*in_reply_to = 0; 290 clist*in_reply_to = 0;
290 char *subject = strdup( mail->getSubject().latin1() ); 291 char *subject = strdup( mail->getSubject().latin1() );
291 int err; 292 int err;
292 int res = 1; 293 int res = 1;
293 294
294 sender = newMailbox( mail->getName(), mail->getMail() ); 295 sender = newMailbox( mail->getName(), mail->getMail() );
295 if ( sender == NULL ) { 296 if ( sender == NULL ) {
296 res = 0; 297 res = 0;
297 } 298 }
298 299
299 if (res) { 300 if (res) {
300 fromBox = newMailbox( mail->getName(), mail->getMail() ); 301 fromBox = newMailbox( mail->getName(), mail->getMail() );
301 } 302 }
302 if ( fromBox == NULL ) { 303 if ( fromBox == NULL ) {
303 res = 0; 304 res = 0;
304 } 305 }
305 306
306 if (res) { 307 if (res) {
307 from = mailimf_mailbox_list_new_empty(); 308 from = mailimf_mailbox_list_new_empty();
308 } 309 }
309 if ( from == NULL ) { 310 if ( from == NULL ) {
310 res = 0; 311 res = 0;
311 } 312 }
312 313
313 if (res && from) { 314 if (res && from) {
314 err = mailimf_mailbox_list_add( from, fromBox ); 315 err = mailimf_mailbox_list_add( from, fromBox );
315 if ( err != MAILIMF_NO_ERROR ) { 316 if ( err != MAILIMF_NO_ERROR ) {
316 res = 0; 317 res = 0;
317 } 318 }
318 } 319 }
319 320
320 if (res) to = parseAddresses( mail->getTo() ); 321 if (res) to = parseAddresses( mail->getTo() );
321 if (res) cc = parseAddresses( mail->getCC() ); 322 if (res) cc = parseAddresses( mail->getCC() );
322 if (res) bcc = parseAddresses( mail->getBCC() ); 323 if (res) bcc = parseAddresses( mail->getBCC() );
323 if (res) reply = parseAddresses( mail->getReply() ); 324 if (res) reply = parseAddresses( mail->getReply() );
324 325
325 if (res && mail->Inreply().count()>0) { 326 if (res && mail->Inreply().count()>0) {
326 in_reply_to = clist_new(); 327 in_reply_to = clist_new();
327 char*c_reply; 328 char*c_reply;
328 unsigned int nsize = 0; 329 unsigned int nsize = 0;
329 for (QStringList::ConstIterator it=mail->Inreply().begin(); 330 for (QStringList::ConstIterator it=mail->Inreply().begin();
330 it != mail->Inreply().end();++it) { 331 it != mail->Inreply().end();++it) {
331 if ((*it).isEmpty()) 332 if ((*it).isEmpty())
332 continue; 333 continue;
333 QString h((*it)); 334 QString h((*it));
334 while (h.length()>0 && h[0]=='<') { 335 while (h.length()>0 && h[0]=='<') {
335 h.remove(0,1); 336 h.remove(0,1);
336 } 337 }
337 while (h.length()>0 && h[h.length()-1]=='>') { 338 while (h.length()>0 && h[h.length()-1]=='>') {
338 h.remove(h.length()-1,1); 339 h.remove(h.length()-1,1);
339 } 340 }
340 if (h.isEmpty()) continue; 341 if (h.isEmpty()) continue;
341 nsize = strlen(h.latin1()); 342 nsize = strlen(h.latin1());
342 /* yes! must be malloc! */ 343 /* yes! must be malloc! */
343 c_reply = (char*)malloc( (nsize+1)*sizeof(char)); 344 c_reply = (char*)malloc( (nsize+1)*sizeof(char));
344 memset(c_reply,0,nsize+1); 345 memset(c_reply,0,nsize+1);
345 memcpy(c_reply,h.latin1(),nsize); 346 memcpy(c_reply,h.latin1(),nsize);
346 clist_append(in_reply_to,c_reply); 347 clist_append(in_reply_to,c_reply);
347 qDebug("In reply to: %s",c_reply); 348 qDebug("In reply to: %s",c_reply);
348 } 349 }
349 } 350 }
350 351
351 if (res) { 352 if (res) {
352 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc, 353 fields = mailimf_fields_new_with_data( from, sender, reply, to, cc, bcc,
353 in_reply_to, NULL, subject ); 354 in_reply_to, NULL, subject );
354 if ( fields == NULL ) { 355 if ( fields == NULL ) {
355 qDebug("Error creating mailimf fields"); 356 qDebug("Error creating mailimf fields");
356 res = 0; 357 res = 0;
357 } 358 }
358 } 359 }
359 if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ), 360 if (res) xmailer = mailimf_field_new_custom( strdup( "User-Agent" ),
360 strdup( USER_AGENT ) ); 361 strdup( USER_AGENT ) );
361 if ( xmailer == NULL ) { 362 if ( xmailer == NULL ) {
362 res = 0; 363 res = 0;
363 } else { 364 } else {
364 err = mailimf_fields_add( fields, xmailer ); 365 err = mailimf_fields_add( fields, xmailer );
365 if ( err != MAILIMF_NO_ERROR ) { 366 if ( err != MAILIMF_NO_ERROR ) {
366 res = 0; 367 res = 0;
367 } 368 }
368 } 369 }
369 if (!res ) { 370 if (!res ) {
370 if (xmailer) { 371 if (xmailer) {
371 mailimf_field_free( xmailer ); 372 mailimf_field_free( xmailer );
372 xmailer = NULL; 373 xmailer = NULL;
373 } 374 }
374 if (fields) { 375 if (fields) {
375 mailimf_fields_free( fields ); 376 mailimf_fields_free( fields );
376 fields = NULL; 377 fields = NULL;
377 } else { 378 } else {
378 if (reply) 379 if (reply)
379 mailimf_address_list_free( reply ); 380 mailimf_address_list_free( reply );
380 if (bcc) 381 if (bcc)
381 mailimf_address_list_free( bcc ); 382 mailimf_address_list_free( bcc );
382 if (cc) 383 if (cc)
383 mailimf_address_list_free( cc ); 384 mailimf_address_list_free( cc );
384 if (to) 385 if (to)
385 mailimf_address_list_free( to ); 386 mailimf_address_list_free( to );
386 if (fromBox) { 387 if (fromBox) {
387 mailimf_mailbox_free( fromBox ); 388 mailimf_mailbox_free( fromBox );
388 } else if (from) { 389 } else if (from) {
389 mailimf_mailbox_list_free( from ); 390 mailimf_mailbox_list_free( from );
390 } 391 }
391 if (sender) { 392 if (sender) {
392 mailimf_mailbox_free( sender ); 393 mailimf_mailbox_free( sender );
393 } 394 }
394 if (subject) { 395 if (subject) {
395 free( subject ); 396 free( subject );
396 } 397 }
397 } 398 }
398 } 399 }
399 return fields; 400 return fields;
400} 401}
401 402
402mailmime *Generatemail::createMimeMail(const Opie::OSmartPointer<Mail> &mail ) { 403mailmime *Generatemail::createMimeMail(const Opie::Core::OSmartPointer<Mail> &mail ) {
403 mailmime *message, *txtPart; 404 mailmime *message, *txtPart;
404 mailimf_fields *fields; 405 mailimf_fields *fields;
405 int err; 406 int err;
406 407
407 fields = createImfFields( mail ); 408 fields = createImfFields( mail );
408 if ( fields == NULL ) 409 if ( fields == NULL )
409 goto err_free; 410 goto err_free;
410 411
411 message = mailmime_new_message_data( NULL ); 412 message = mailmime_new_message_data( NULL );
412 if ( message == NULL ) 413 if ( message == NULL )
413 goto err_free_fields; 414 goto err_free_fields;
414 415
415 mailmime_set_imf_fields( message, fields ); 416 mailmime_set_imf_fields( message, fields );
416 417
417 txtPart = buildTxtPart( mail->getMessage() ); 418 txtPart = buildTxtPart( mail->getMessage() );
418 419
419 if ( txtPart == NULL ) 420 if ( txtPart == NULL )
420 goto err_free_message; 421 goto err_free_message;
421 422
422 err = mailmime_smart_add_part( message, txtPart ); 423 err = mailmime_smart_add_part( message, txtPart );
423 if ( err != MAILIMF_NO_ERROR ) 424 if ( err != MAILIMF_NO_ERROR )
424 goto err_free_txtPart; 425 goto err_free_txtPart;
425 426
426 addFileParts( message, mail->getAttachments() ); 427 addFileParts( message, mail->getAttachments() );
427 428
428 return message; // Success :) 429 return message; // Success :)
429 430
430err_free_txtPart: 431err_free_txtPart:
431 mailmime_free( txtPart ); 432 mailmime_free( txtPart );
432err_free_message: 433err_free_message:
433 mailmime_free( message ); 434 mailmime_free( message );
434err_free_fields: 435err_free_fields:
435 mailimf_fields_free( fields ); 436 mailimf_fields_free( fields );
436err_free: 437err_free:
437 qDebug( "createMimeMail: error" ); 438 qDebug( "createMimeMail: error" );
438 439
439 return NULL; // Error :( 440 return NULL; // Error :(
440} 441}
441 442
442clist *Generatemail::createRcptList( mailimf_fields *fields ) { 443clist *Generatemail::createRcptList( mailimf_fields *fields ) {
443 clist *rcptList; 444 clist *rcptList;
444 mailimf_field *field; 445 mailimf_field *field;
445 446
446 rcptList = esmtp_address_list_new(); 447 rcptList = esmtp_address_list_new();
447 448
448 field = getField( fields, MAILIMF_FIELD_TO ); 449 field = getField( fields, MAILIMF_FIELD_TO );
449 if ( field && (field->fld_type == MAILIMF_FIELD_TO) 450 if ( field && (field->fld_type == MAILIMF_FIELD_TO)
450 && field->fld_data.fld_to->to_addr_list ) { 451 && field->fld_data.fld_to->to_addr_list ) {
451 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list ); 452 addRcpts( rcptList, field->fld_data.fld_to->to_addr_list );
452 } 453 }
453 454
454 field = getField( fields, MAILIMF_FIELD_CC ); 455 field = getField( fields, MAILIMF_FIELD_CC );
455 if ( field && (field->fld_type == MAILIMF_FIELD_CC) 456 if ( field && (field->fld_type == MAILIMF_FIELD_CC)
456 && field->fld_data.fld_cc->cc_addr_list ) { 457 && field->fld_data.fld_cc->cc_addr_list ) {
457 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list ); 458 addRcpts( rcptList, field->fld_data.fld_cc->cc_addr_list );
458 } 459 }
459 460
460 field = getField( fields, MAILIMF_FIELD_BCC ); 461 field = getField( fields, MAILIMF_FIELD_BCC );
461 if ( field && (field->fld_type == MAILIMF_FIELD_BCC) 462 if ( field && (field->fld_type == MAILIMF_FIELD_BCC)
462 && field->fld_data.fld_bcc->bcc_addr_list ) { 463 && field->fld_data.fld_bcc->bcc_addr_list ) {
463 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list ); 464 addRcpts( rcptList, field->fld_data.fld_bcc->bcc_addr_list );
464 } 465 }
465 466
466 return rcptList; 467 return rcptList;
467} 468}
diff --git a/noncore/net/mail/libmailwrapper/generatemail.h b/noncore/net/mail/libmailwrapper/generatemail.h
index c246a2a..a767b61 100644
--- a/noncore/net/mail/libmailwrapper/generatemail.h
+++ b/noncore/net/mail/libmailwrapper/generatemail.h
@@ -1,46 +1,46 @@
1#ifndef __GENERATE_MAIL_H 1#ifndef __GENERATE_MAIL_H
2#define __GENERATE_MAIL_H 2#define __GENERATE_MAIL_H
3 3
4#include <qpe/applnk.h> 4#include <qpe/applnk.h>
5 5
6#include <qobject.h> 6#include <qobject.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9#include <opie2/osmartpointer.h> 9#include <opie2/osmartpointer.h>
10 10
11class Mail; 11class Mail;
12class RecMail; 12class RecMail;
13class Attachment; 13class Attachment;
14struct mailimf_fields; 14struct mailimf_fields;
15struct mailimf_field; 15struct mailimf_field;
16struct mailimf_mailbox; 16struct mailimf_mailbox;
17struct mailmime; 17struct mailmime;
18struct mailimf_address_list; 18struct mailimf_address_list;
19class progressMailSend; 19class progressMailSend;
20struct mailsmtp; 20struct mailsmtp;
21 21
22class Generatemail : public QObject 22class Generatemail : public QObject
23{ 23{
24 Q_OBJECT 24 Q_OBJECT
25public: 25public:
26 Generatemail(); 26 Generatemail();
27 virtual ~Generatemail(); 27 virtual ~Generatemail();
28 28
29protected: 29protected:
30 static void addRcpts( clist *list, mailimf_address_list *addr_list ); 30 static void addRcpts( clist *list, mailimf_address_list *addr_list );
31 static char *getFrom( mailmime *mail ); 31 static char *getFrom( mailmime *mail );
32 static char *getFrom( mailimf_field *ffrom); 32 static char *getFrom( mailimf_field *ffrom);
33 static mailimf_field *getField( mailimf_fields *fields, int type ); 33 static mailimf_field *getField( mailimf_fields *fields, int type );
34 mailimf_address_list *parseAddresses(const QString&addr ); 34 mailimf_address_list *parseAddresses(const QString&addr );
35 void addFileParts( mailmime *message,const QList<Attachment>&files ); 35 void addFileParts( mailmime *message,const QList<Attachment>&files );
36 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content); 36 mailmime *buildFilePart(const QString&filename,const QString&mimetype,const QString&content);
37 mailmime *buildTxtPart(const QString&str ); 37 mailmime *buildTxtPart(const QString&str );
38 mailimf_mailbox *newMailbox(const QString&name,const QString&mail ); 38 mailimf_mailbox *newMailbox(const QString&name,const QString&mail );
39 mailimf_fields *createImfFields(const Opie::OSmartPointer<Mail> &mail ); 39 mailimf_fields *createImfFields(const Opie::Core::OSmartPointer<Mail> &mail );
40 mailmime *createMimeMail(const Opie::OSmartPointer<Mail>&mail ); 40 mailmime *createMimeMail(const Opie::Core::OSmartPointer<Mail>&mail );
41 clist *createRcptList( mailimf_fields *fields ); 41 clist *createRcptList( mailimf_fields *fields );
42 42
43 static const char* USER_AGENT; 43 static const char* USER_AGENT;
44}; 44};
45 45
46#endif 46#endif
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.cpp b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
index ee2c8cd..f428415 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.cpp
@@ -1,196 +1,197 @@
1#include "genericwrapper.h" 1#include "genericwrapper.h"
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5using namespace Opie::Core;
5Genericwrapper::Genericwrapper() 6Genericwrapper::Genericwrapper()
6 : AbstractMail() 7 : AbstractMail()
7{ 8{
8 bodyCache.clear(); 9 bodyCache.clear();
9 m_storage = 0; 10 m_storage = 0;
10 m_folder = 0; 11 m_folder = 0;
11} 12}
12 13
13Genericwrapper::~Genericwrapper() 14Genericwrapper::~Genericwrapper()
14{ 15{
15 if (m_folder) { 16 if (m_folder) {
16 mailfolder_free(m_folder); 17 mailfolder_free(m_folder);
17 } 18 }
18 if (m_storage) { 19 if (m_storage) {
19 mailstorage_free(m_storage); 20 mailstorage_free(m_storage);
20 } 21 }
21 cleanMimeCache(); 22 cleanMimeCache();
22} 23}
23 24
24void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime) 25void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
25{ 26{
26 if (!mime) { 27 if (!mime) {
27 return; 28 return;
28 } 29 }
29 mailmime_field*field = 0; 30 mailmime_field*field = 0;
30 mailmime_single_fields fields; 31 mailmime_single_fields fields;
31 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 32 memset(&fields, 0, sizeof(struct mailmime_single_fields));
32 if (mime->mm_mime_fields != NULL) { 33 if (mime->mm_mime_fields != NULL) {
33 mailmime_single_fields_init(&fields, mime->mm_mime_fields, 34 mailmime_single_fields_init(&fields, mime->mm_mime_fields,
34 mime->mm_content_type); 35 mime->mm_content_type);
35 } 36 }
36 37
37 mailmime_content*type = fields.fld_content; 38 mailmime_content*type = fields.fld_content;
38 clistcell*current; 39 clistcell*current;
39 if (!type) { 40 if (!type) {
40 target.setType("text"); 41 target.setType("text");
41 target.setSubtype("plain"); 42 target.setSubtype("plain");
42 } else { 43 } else {
43 target.setSubtype(type->ct_subtype); 44 target.setSubtype(type->ct_subtype);
44 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { 45 switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
45 case MAILMIME_DISCRETE_TYPE_TEXT: 46 case MAILMIME_DISCRETE_TYPE_TEXT:
46 target.setType("text"); 47 target.setType("text");
47 break; 48 break;
48 case MAILMIME_DISCRETE_TYPE_IMAGE: 49 case MAILMIME_DISCRETE_TYPE_IMAGE:
49 target.setType("image"); 50 target.setType("image");
50 break; 51 break;
51 case MAILMIME_DISCRETE_TYPE_AUDIO: 52 case MAILMIME_DISCRETE_TYPE_AUDIO:
52 target.setType("audio"); 53 target.setType("audio");
53 break; 54 break;
54 case MAILMIME_DISCRETE_TYPE_VIDEO: 55 case MAILMIME_DISCRETE_TYPE_VIDEO:
55 target.setType("video"); 56 target.setType("video");
56 break; 57 break;
57 case MAILMIME_DISCRETE_TYPE_APPLICATION: 58 case MAILMIME_DISCRETE_TYPE_APPLICATION:
58 target.setType("application"); 59 target.setType("application");
59 break; 60 break;
60 case MAILMIME_DISCRETE_TYPE_EXTENSION: 61 case MAILMIME_DISCRETE_TYPE_EXTENSION:
61 default: 62 default:
62 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { 63 if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
63 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); 64 target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
64 } 65 }
65 break; 66 break;
66 } 67 }
67 if (type->ct_parameters) { 68 if (type->ct_parameters) {
68 fillParameters(target,type->ct_parameters); 69 fillParameters(target,type->ct_parameters);
69 } 70 }
70 } 71 }
71 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { 72 if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
72 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { 73 for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
73 field = (mailmime_field*)current->data; 74 field = (mailmime_field*)current->data;
74 switch(field->fld_type) { 75 switch(field->fld_type) {
75 case MAILMIME_FIELD_TRANSFER_ENCODING: 76 case MAILMIME_FIELD_TRANSFER_ENCODING:
76 target.setEncoding(getencoding(field->fld_data.fld_encoding)); 77 target.setEncoding(getencoding(field->fld_data.fld_encoding));
77 break; 78 break;
78 case MAILMIME_FIELD_ID: 79 case MAILMIME_FIELD_ID:
79 target.setIdentifier(field->fld_data.fld_id); 80 target.setIdentifier(field->fld_data.fld_id);
80 break; 81 break;
81 case MAILMIME_FIELD_DESCRIPTION: 82 case MAILMIME_FIELD_DESCRIPTION:
82 target.setDescription(field->fld_data.fld_description); 83 target.setDescription(field->fld_data.fld_description);
83 break; 84 break;
84 default: 85 default:
85 break; 86 break;
86 } 87 }
87 } 88 }
88 } 89 }
89} 90}
90 91
91void Genericwrapper::fillParameters(RecPart&target,clist*parameters) 92void Genericwrapper::fillParameters(RecPart&target,clist*parameters)
92{ 93{
93 if (!parameters) {return;} 94 if (!parameters) {return;}
94 clistcell*current=0; 95 clistcell*current=0;
95 mailmime_parameter*param; 96 mailmime_parameter*param;
96 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) { 97 for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
97 param = (mailmime_parameter*)current->data; 98 param = (mailmime_parameter*)current->data;
98 if (param) { 99 if (param) {
99 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value)); 100 target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
100 } 101 }
101 } 102 }
102} 103}
103 104
104QString Genericwrapper::getencoding(mailmime_mechanism*aEnc) 105QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
105{ 106{
106 QString enc="7bit"; 107 QString enc="7bit";
107 if (!aEnc) return enc; 108 if (!aEnc) return enc;
108 switch(aEnc->enc_type) { 109 switch(aEnc->enc_type) {
109 case MAILMIME_MECHANISM_7BIT: 110 case MAILMIME_MECHANISM_7BIT:
110 enc = "7bit"; 111 enc = "7bit";
111 break; 112 break;
112 case MAILMIME_MECHANISM_8BIT: 113 case MAILMIME_MECHANISM_8BIT:
113 enc = "8bit"; 114 enc = "8bit";
114 break; 115 break;
115 case MAILMIME_MECHANISM_BINARY: 116 case MAILMIME_MECHANISM_BINARY:
116 enc = "binary"; 117 enc = "binary";
117 break; 118 break;
118 case MAILMIME_MECHANISM_QUOTED_PRINTABLE: 119 case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
119 enc = "quoted-printable"; 120 enc = "quoted-printable";
120 break; 121 break;
121 case MAILMIME_MECHANISM_BASE64: 122 case MAILMIME_MECHANISM_BASE64:
122 enc = "base64"; 123 enc = "base64";
123 break; 124 break;
124 case MAILMIME_MECHANISM_TOKEN: 125 case MAILMIME_MECHANISM_TOKEN:
125 default: 126 default:
126 if (aEnc->enc_token) { 127 if (aEnc->enc_token) {
127 enc = QString(aEnc->enc_token); 128 enc = QString(aEnc->enc_token);
128 } 129 }
129 break; 130 break;
130 } 131 }
131 return enc; 132 return enc;
132} 133}
133 134
134void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count) 135void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
135{ 136{
136 if (current_rec >= 10) { 137 if (current_rec >= 10) {
137 qDebug("too deep recursion!"); 138 qDebug("too deep recursion!");
138 } 139 }
139 if (!message || !mime) { 140 if (!message || !mime) {
140 return; 141 return;
141 } 142 }
142 int r; 143 int r;
143 char*data = 0; 144 char*data = 0;
144 size_t len; 145 size_t len;
145 clistiter * cur = 0; 146 clistiter * cur = 0;
146 QString b; 147 QString b;
147 RecPart part; 148 RecPart part;
148 149
149 switch (mime->mm_type) { 150 switch (mime->mm_type) {
150 case MAILMIME_SINGLE: 151 case MAILMIME_SINGLE:
151 { 152 {
152 QValueList<int>countlist = recList; 153 QValueList<int>countlist = recList;
153 countlist.append(current_count); 154 countlist.append(current_count);
154 r = mailmessage_fetch_section(message,mime,&data,&len); 155 r = mailmessage_fetch_section(message,mime,&data,&len);
155 part.setSize(len); 156 part.setSize(len);
156 part.setPositionlist(countlist); 157 part.setPositionlist(countlist);
157 b = gen_attachment_id(); 158 b = gen_attachment_id();
158 part.setIdentifier(b); 159 part.setIdentifier(b);
159 fillSingleBody(part,message,mime); 160 fillSingleBody(part,message,mime);
160 if (part.Type()=="text" && target.Bodytext().isNull()) { 161 if (part.Type()=="text" && target.Bodytext().isNull()) {
161 encodedString*rs = new encodedString(); 162 encodedString*rs = new encodedString();
162 rs->setContent(data,len); 163 rs->setContent(data,len);
163 encodedString*res = decode_String(rs,part.Encoding()); 164 encodedString*res = decode_String(rs,part.Encoding());
164 if (countlist.count()>2) { 165 if (countlist.count()>2) {
165 bodyCache[b]=rs; 166 bodyCache[b]=rs;
166 target.addPart(part); 167 target.addPart(part);
167 } else { 168 } else {
168 delete rs; 169 delete rs;
169 } 170 }
170 b = QString(res->Content()); 171 b = QString(res->Content());
171 delete res; 172 delete res;
172 target.setBodytext(b); 173 target.setBodytext(b);
173 target.setDescription(part); 174 target.setDescription(part);
174 } else { 175 } else {
175 bodyCache[b]=new encodedString(data,len); 176 bodyCache[b]=new encodedString(data,len);
176 target.addPart(part); 177 target.addPart(part);
177 } 178 }
178 } 179 }
179 break; 180 break;
180 case MAILMIME_MULTIPLE: 181 case MAILMIME_MULTIPLE:
181 { 182 {
182 unsigned int ccount = 1; 183 unsigned int ccount = 1;
183 mailmime*cbody=0; 184 mailmime*cbody=0;
184 QValueList<int>countlist = recList; 185 QValueList<int>countlist = recList;
185 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { 186 for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
186 cbody = (mailmime*)clist_content(cur); 187 cbody = (mailmime*)clist_content(cur);
187 if (cbody->mm_type==MAILMIME_MULTIPLE) { 188 if (cbody->mm_type==MAILMIME_MULTIPLE) {
188 RecPart targetPart; 189 RecPart targetPart;
189 targetPart.setType("multipart"); 190 targetPart.setType("multipart");
190 countlist.append(current_count); 191 countlist.append(current_count);
191 targetPart.setPositionlist(countlist); 192 targetPart.setPositionlist(countlist);
192 target.addPart(targetPart); 193 target.addPart(targetPart);
193 } 194 }
194 traverseBody(target,message, cbody,countlist,current_rec+1,ccount); 195 traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
195 if (cbody->mm_type==MAILMIME_MULTIPLE) { 196 if (cbody->mm_type==MAILMIME_MULTIPLE) {
196 countlist = recList; 197 countlist = recList;
@@ -198,278 +199,278 @@ void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mi
198 ++ccount; 199 ++ccount;
199 } 200 }
200 } 201 }
201 break; 202 break;
202 case MAILMIME_MESSAGE: 203 case MAILMIME_MESSAGE:
203 { 204 {
204 QValueList<int>countlist = recList; 205 QValueList<int>countlist = recList;
205 countlist.append(current_count); 206 countlist.append(current_count);
206 /* the own header is always at recursion 0 - we don't need that */ 207 /* the own header is always at recursion 0 - we don't need that */
207 if (current_rec > 0) { 208 if (current_rec > 0) {
208 part.setPositionlist(countlist); 209 part.setPositionlist(countlist);
209 r = mailmessage_fetch_section(message,mime,&data,&len); 210 r = mailmessage_fetch_section(message,mime,&data,&len);
210 part.setSize(len); 211 part.setSize(len);
211 part.setPositionlist(countlist); 212 part.setPositionlist(countlist);
212 b = gen_attachment_id(); 213 b = gen_attachment_id();
213 part.setIdentifier(b); 214 part.setIdentifier(b);
214 part.setType("message"); 215 part.setType("message");
215 part.setSubtype("rfc822"); 216 part.setSubtype("rfc822");
216 bodyCache[b]=new encodedString(data,len); 217 bodyCache[b]=new encodedString(data,len);
217 target.addPart(part); 218 target.addPart(part);
218 } 219 }
219 if (mime->mm_data.mm_message.mm_msg_mime != NULL) { 220 if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
220 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1); 221 traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
221 } 222 }
222 } 223 }
223 break; 224 break;
224 } 225 }
225} 226}
226 227
227RecBody Genericwrapper::parseMail( mailmessage * msg ) 228RecBody Genericwrapper::parseMail( mailmessage * msg )
228{ 229{
229 int err = MAILIMF_NO_ERROR; 230 int err = MAILIMF_NO_ERROR;
230 mailmime_single_fields fields; 231 mailmime_single_fields fields;
231 /* is bound to msg and will be freed there */ 232 /* is bound to msg and will be freed there */
232 mailmime * mime=0; 233 mailmime * mime=0;
233 RecBody body; 234 RecBody body;
234 memset(&fields, 0, sizeof(struct mailmime_single_fields)); 235 memset(&fields, 0, sizeof(struct mailmime_single_fields));
235 err = mailmessage_get_bodystructure(msg,&mime); 236 err = mailmessage_get_bodystructure(msg,&mime);
236 QValueList<int>recList; 237 QValueList<int>recList;
237 traverseBody(body,msg,mime,recList); 238 traverseBody(body,msg,mime,recList);
238 return body; 239 return body;
239} 240}
240 241
241QString Genericwrapper::parseDateTime( mailimf_date_time *date ) 242QString Genericwrapper::parseDateTime( mailimf_date_time *date )
242{ 243{
243 char tmp[23]; 244 char tmp[23];
244 245
245 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", 246 snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
246 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); 247 date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
247 248
248 return QString( tmp ); 249 return QString( tmp );
249} 250}
250 251
251QString Genericwrapper::parseAddressList( mailimf_address_list *list ) 252QString Genericwrapper::parseAddressList( mailimf_address_list *list )
252{ 253{
253 QString result( "" ); 254 QString result( "" );
254 255
255 bool first = true; 256 bool first = true;
256 if (list == 0) return result; 257 if (list == 0) return result;
257 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) { 258 for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
258 mailimf_address *addr = (mailimf_address *) current->data; 259 mailimf_address *addr = (mailimf_address *) current->data;
259 260
260 if ( !first ) { 261 if ( !first ) {
261 result.append( "," ); 262 result.append( "," );
262 } else { 263 } else {
263 first = false; 264 first = false;
264 } 265 }
265 266
266 switch ( addr->ad_type ) { 267 switch ( addr->ad_type ) {
267 case MAILIMF_ADDRESS_MAILBOX: 268 case MAILIMF_ADDRESS_MAILBOX:
268 result.append( parseMailbox( addr->ad_data.ad_mailbox ) ); 269 result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
269 break; 270 break;
270 case MAILIMF_ADDRESS_GROUP: 271 case MAILIMF_ADDRESS_GROUP:
271 result.append( parseGroup( addr->ad_data.ad_group ) ); 272 result.append( parseGroup( addr->ad_data.ad_group ) );
272 break; 273 break;
273 default: 274 default:
274 qDebug( "Generic: unkown mailimf address type" ); 275 qDebug( "Generic: unkown mailimf address type" );
275 break; 276 break;
276 } 277 }
277 } 278 }
278 279
279 return result; 280 return result;
280} 281}
281 282
282QString Genericwrapper::parseGroup( mailimf_group *group ) 283QString Genericwrapper::parseGroup( mailimf_group *group )
283{ 284{
284 QString result( "" ); 285 QString result( "" );
285 286
286 result.append( group->grp_display_name ); 287 result.append( group->grp_display_name );
287 result.append( ": " ); 288 result.append( ": " );
288 289
289 if ( group->grp_mb_list != NULL ) { 290 if ( group->grp_mb_list != NULL ) {
290 result.append( parseMailboxList( group->grp_mb_list ) ); 291 result.append( parseMailboxList( group->grp_mb_list ) );
291 } 292 }
292 293
293 result.append( ";" ); 294 result.append( ";" );
294 295
295 return result; 296 return result;
296} 297}
297 298
298QString Genericwrapper::parseMailbox( mailimf_mailbox *box ) 299QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
299{ 300{
300 QString result( "" ); 301 QString result( "" );
301 302
302 if ( box->mb_display_name == NULL ) { 303 if ( box->mb_display_name == NULL ) {
303 result.append( box->mb_addr_spec ); 304 result.append( box->mb_addr_spec );
304 } else { 305 } else {
305 result.append( convert_String(box->mb_display_name).latin1() ); 306 result.append( convert_String(box->mb_display_name).latin1() );
306 result.append( " <" ); 307 result.append( " <" );
307 result.append( box->mb_addr_spec ); 308 result.append( box->mb_addr_spec );
308 result.append( ">" ); 309 result.append( ">" );
309 } 310 }
310 311
311 return result; 312 return result;
312} 313}
313 314
314QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list ) 315QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
315{ 316{
316 QString result( "" ); 317 QString result( "" );
317 318
318 bool first = true; 319 bool first = true;
319 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) { 320 for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
320 mailimf_mailbox *box = (mailimf_mailbox *) current->data; 321 mailimf_mailbox *box = (mailimf_mailbox *) current->data;
321 322
322 if ( !first ) { 323 if ( !first ) {
323 result.append( "," ); 324 result.append( "," );
324 } else { 325 } else {
325 first = false; 326 first = false;
326 } 327 }
327 328
328 result.append( parseMailbox( box ) ); 329 result.append( parseMailbox( box ) );
329 } 330 }
330 331
331 return result; 332 return result;
332} 333}
333 334
334encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part) 335encodedString* Genericwrapper::fetchDecodedPart(const RecMailP&,const RecPart&part)
335{ 336{
336 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); 337 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
337 if (it==bodyCache.end()) return new encodedString(); 338 if (it==bodyCache.end()) return new encodedString();
338 encodedString*t = decode_String(it.data(),part.Encoding()); 339 encodedString*t = decode_String(it.data(),part.Encoding());
339 return t; 340 return t;
340} 341}
341 342
342encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part) 343encodedString* Genericwrapper::fetchRawPart(const RecMailP&mail,const RecPart&part)
343{ 344{
344 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier()); 345 QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
345 if (it==bodyCache.end()) return new encodedString(); 346 if (it==bodyCache.end()) return new encodedString();
346 encodedString*t = it.data(); 347 encodedString*t = it.data();
347 return t; 348 return t;
348} 349}
349 350
350QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part) 351QString Genericwrapper::fetchTextPart(const RecMailP&mail,const RecPart&part)
351{ 352{
352 encodedString*t = fetchDecodedPart(mail,part); 353 encodedString*t = fetchDecodedPart(mail,part);
353 QString text=t->Content(); 354 QString text=t->Content();
354 delete t; 355 delete t;
355 return text; 356 return text;
356} 357}
357 358
358void Genericwrapper::cleanMimeCache() 359void Genericwrapper::cleanMimeCache()
359{ 360{
360 QMap<QString,encodedString*>::Iterator it = bodyCache.begin(); 361 QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
361 for (;it!=bodyCache.end();++it) { 362 for (;it!=bodyCache.end();++it) {
362 encodedString*t = it.data(); 363 encodedString*t = it.data();
363 //it.setValue(0); 364 //it.setValue(0);
364 if (t) delete t; 365 if (t) delete t;
365 } 366 }
366 bodyCache.clear(); 367 bodyCache.clear();
367 qDebug("Genericwrapper: cache cleaned"); 368 qDebug("Genericwrapper: cache cleaned");
368} 369}
369 370
370QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies) 371QStringList Genericwrapper::parseInreplies(mailimf_in_reply_to * in_replies)
371{ 372{
372 QStringList res; 373 QStringList res;
373 if (!in_replies || !in_replies->mid_list) return res; 374 if (!in_replies || !in_replies->mid_list) return res;
374 clistiter * current = 0; 375 clistiter * current = 0;
375 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) { 376 for ( current = clist_begin( in_replies->mid_list ); current != NULL; current = current->next ) {
376 QString h((char*)current->data); 377 QString h((char*)current->data);
377 while (h.length()>0 && h[0]=='<') { 378 while (h.length()>0 && h[0]=='<') {
378 h.remove(0,1); 379 h.remove(0,1);
379 } 380 }
380 while (h.length()>0 && h[h.length()-1]=='>') { 381 while (h.length()>0 && h[h.length()-1]=='>') {
381 h.remove(h.length()-1,1); 382 h.remove(h.length()-1,1);
382 } 383 }
383 if (h.length()>0) { 384 if (h.length()>0) {
384 res.append(h); 385 res.append(h);
385 } 386 }
386 } 387 }
387 return res; 388 return res;
388} 389}
389 390
390void Genericwrapper::parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to) 391void Genericwrapper::parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to)
391{ 392{
392 int r; 393 int r;
393 mailmessage_list * env_list = 0; 394 mailmessage_list * env_list = 0;
394 r = mailsession_get_messages_list(session,&env_list); 395 r = mailsession_get_messages_list(session,&env_list);
395 if (r != MAIL_NO_ERROR) { 396 if (r != MAIL_NO_ERROR) {
396 qDebug("Error message list"); 397 qDebug("Error message list");
397 return; 398 return;
398 } 399 }
399 r = mailsession_get_envelopes_list(session, env_list); 400 r = mailsession_get_envelopes_list(session, env_list);
400 if (r != MAIL_NO_ERROR) { 401 if (r != MAIL_NO_ERROR) {
401 qDebug("Error filling message list"); 402 qDebug("Error filling message list");
402 if (env_list) { 403 if (env_list) {
403 mailmessage_list_free(env_list); 404 mailmessage_list_free(env_list);
404 } 405 }
405 return; 406 return;
406 } 407 }
407 mailimf_references * refs = 0; 408 mailimf_references * refs = 0;
408 mailimf_in_reply_to * in_replies = 0; 409 mailimf_in_reply_to * in_replies = 0;
409 uint32_t i = 0; 410 uint32_t i = 0;
410 for(; i < carray_count(env_list->msg_tab) ; ++i) { 411 for(; i < carray_count(env_list->msg_tab) ; ++i) {
411 mailmessage * msg; 412 mailmessage * msg;
412 QBitArray mFlags(7); 413 QBitArray mFlags(7);
413 msg = (mailmessage*)carray_get(env_list->msg_tab, i); 414 msg = (mailmessage*)carray_get(env_list->msg_tab, i);
414 if (msg->msg_fields == NULL) { 415 if (msg->msg_fields == NULL) {
415 //qDebug("could not fetch envelope of message %i", i); 416 //qDebug("could not fetch envelope of message %i", i);
416 continue; 417 continue;
417 } 418 }
418 RecMailP mail = new RecMail(); 419 RecMailP mail = new RecMail();
419 mail->setWrapper(this); 420 mail->setWrapper(this);
420 mail_flags * flag_result = 0; 421 mail_flags * flag_result = 0;
421 r = mailmessage_get_flags(msg,&flag_result); 422 r = mailmessage_get_flags(msg,&flag_result);
422 if (r == MAIL_ERROR_NOT_IMPLEMENTED) { 423 if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
423 mFlags.setBit(FLAG_SEEN); 424 mFlags.setBit(FLAG_SEEN);
424 } 425 }
425 mailimf_single_fields single_fields; 426 mailimf_single_fields single_fields;
426 mailimf_single_fields_init(&single_fields, msg->msg_fields); 427 mailimf_single_fields_init(&single_fields, msg->msg_fields);
427 mail->setMsgsize(msg->msg_size); 428 mail->setMsgsize(msg->msg_size);
428 mail->setFlags(mFlags); 429 mail->setFlags(mFlags);
429 mail->setMbox(mailbox); 430 mail->setMbox(mailbox);
430 mail->setNumber(msg->msg_index); 431 mail->setNumber(msg->msg_index);
431 if (single_fields.fld_subject) 432 if (single_fields.fld_subject)
432 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value)); 433 mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
433 if (single_fields.fld_from) 434 if (single_fields.fld_from)
434 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list)); 435 mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
435 if (!mbox_as_to) { 436 if (!mbox_as_to) {
436 if (single_fields.fld_to) 437 if (single_fields.fld_to)
437 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) ); 438 mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
438 } else { 439 } else {
439 mail->setTo(mailbox); 440 mail->setTo(mailbox);
440 } 441 }
441 if (single_fields.fld_cc) 442 if (single_fields.fld_cc)
442 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) ); 443 mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
443 if (single_fields.fld_bcc) 444 if (single_fields.fld_bcc)
444 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) ); 445 mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
445 if (single_fields.fld_orig_date) 446 if (single_fields.fld_orig_date)
446 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) ); 447 mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
447 // crashes when accessing pop3 account? 448 // crashes when accessing pop3 account?
448 if (single_fields.fld_message_id->mid_value) { 449 if (single_fields.fld_message_id->mid_value) {
449 mail->setMsgid(QString(single_fields.fld_message_id->mid_value)); 450 mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
450 qDebug("Msgid == %s",mail->Msgid().latin1()); 451 qDebug("Msgid == %s",mail->Msgid().latin1());
451 } 452 }
452 453
453 if (single_fields.fld_reply_to) { 454 if (single_fields.fld_reply_to) {
454 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list); 455 QStringList t = parseAddressList(single_fields.fld_reply_to->rt_addr_list);
455 if (t.count()>0) { 456 if (t.count()>0) {
456 mail->setReplyto(t[0]); 457 mail->setReplyto(t[0]);
457 } 458 }
458 } 459 }
459#if 0 460#if 0
460 refs = single_fields.fld_references; 461 refs = single_fields.fld_references;
461 if (refs && refs->mid_list && clist_count(refs->mid_list)) { 462 if (refs && refs->mid_list && clist_count(refs->mid_list)) {
462 char * text = (char*)refs->mid_list->first->data; 463 char * text = (char*)refs->mid_list->first->data;
463 mail->setReplyto(QString(text)); 464 mail->setReplyto(QString(text));
464 } 465 }
465#endif 466#endif
466 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list && 467 if (single_fields.fld_in_reply_to && single_fields.fld_in_reply_to->mid_list &&
467 clist_count(single_fields.fld_in_reply_to->mid_list)) { 468 clist_count(single_fields.fld_in_reply_to->mid_list)) {
468 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to)); 469 mail->setInreply(parseInreplies(single_fields.fld_in_reply_to));
469 } 470 }
470 target.append(mail); 471 target.append(mail);
471 } 472 }
472 if (env_list) { 473 if (env_list) {
473 mailmessage_list_free(env_list); 474 mailmessage_list_free(env_list);
474 } 475 }
475} 476}
diff --git a/noncore/net/mail/libmailwrapper/genericwrapper.h b/noncore/net/mail/libmailwrapper/genericwrapper.h
index f9968d1..f5b9504 100644
--- a/noncore/net/mail/libmailwrapper/genericwrapper.h
+++ b/noncore/net/mail/libmailwrapper/genericwrapper.h
@@ -1,67 +1,67 @@
1#ifndef __GENERIC_WRAPPER_H 1#ifndef __GENERIC_WRAPPER_H
2#define __GENERIC_WRAPPER_H 2#define __GENERIC_WRAPPER_H
3 3
4#include "abstractmail.h" 4#include "abstractmail.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class RecMail; 9class RecMail;
10class RecBody; 10class RecBody;
11class encodedString; 11class encodedString;
12struct mailpop3; 12struct mailpop3;
13struct mailmessage; 13struct mailmessage;
14struct mailmime; 14struct mailmime;
15struct mailmime_mechanism; 15struct mailmime_mechanism;
16struct mailimf_mailbox_list; 16struct mailimf_mailbox_list;
17struct mailimf_mailbox; 17struct mailimf_mailbox;
18struct mailimf_date_time; 18struct mailimf_date_time;
19struct mailimf_group; 19struct mailimf_group;
20struct mailimf_address_list; 20struct mailimf_address_list;
21struct mailsession; 21struct mailsession;
22struct mailstorage; 22struct mailstorage;
23struct mailfolder; 23struct mailfolder;
24struct mailimf_in_reply_to; 24struct mailimf_in_reply_to;
25 25
26/* this class hold just the funs shared between 26/* this class hold just the funs shared between
27 * mbox and pop3 (later mh, too) mail access. 27 * mbox and pop3 (later mh, too) mail access.
28 * it is not desigend to make a instance of it! 28 * it is not desigend to make a instance of it!
29 */ 29 */
30class Genericwrapper : public AbstractMail 30class Genericwrapper : public AbstractMail
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 Genericwrapper(); 34 Genericwrapper();
35 virtual ~Genericwrapper(); 35 virtual ~Genericwrapper();
36 36
37 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); 37 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part);
38 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); 38 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part);
39 virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); 39 virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part);
40 virtual void cleanMimeCache(); 40 virtual void cleanMimeCache();
41 virtual int deleteMbox(const Opie::OSmartPointer<Folder>&){return 1;} 41 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&){return 1;}
42 virtual void logout(){}; 42 virtual void logout(){};
43 virtual void storeMessage(const char*msg,size_t length, const QString&folder){}; 43 virtual void storeMessage(const char*msg,size_t length, const QString&folder){};
44 44
45protected: 45protected:
46 RecBody parseMail( mailmessage * msg ); 46 RecBody parseMail( mailmessage * msg );
47 QString parseMailboxList( mailimf_mailbox_list *list ); 47 QString parseMailboxList( mailimf_mailbox_list *list );
48 QString parseMailbox( mailimf_mailbox *box ); 48 QString parseMailbox( mailimf_mailbox *box );
49 QString parseGroup( mailimf_group *group ); 49 QString parseGroup( mailimf_group *group );
50 QString parseAddressList( mailimf_address_list *list ); 50 QString parseAddressList( mailimf_address_list *list );
51 QString parseDateTime( mailimf_date_time *date ); 51 QString parseDateTime( mailimf_date_time *date );
52 52
53 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1); 53 void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
54 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime); 54 static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
55 static void fillParameters(RecPart&target,clist*parameters); 55 static void fillParameters(RecPart&target,clist*parameters);
56 static QString getencoding(mailmime_mechanism*aEnc); 56 static QString getencoding(mailmime_mechanism*aEnc);
57 virtual void parseList(QValueList<Opie::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false); 57 virtual void parseList(QValueList<Opie::Core::OSmartPointer<RecMail> > &target,mailsession*session,const QString&mailbox,bool mbox_as_to=false);
58 QStringList parseInreplies(mailimf_in_reply_to * in_replies); 58 QStringList parseInreplies(mailimf_in_reply_to * in_replies);
59 59
60 QString msgTempName; 60 QString msgTempName;
61 unsigned int last_msg_id; 61 unsigned int last_msg_id;
62 QMap<QString,encodedString*> bodyCache; 62 QMap<QString,encodedString*> bodyCache;
63 mailstorage * m_storage; 63 mailstorage * m_storage;
64 mailfolder*m_folder; 64 mailfolder*m_folder;
65}; 65};
66 66
67#endif 67#endif
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.cpp b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
index 071e734..56e7df9 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.cpp
@@ -1,461 +1,462 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <libetpan/libetpan.h> 2#include <libetpan/libetpan.h>
3#include <qpe/global.h> 3#include <qpe/global.h>
4 4
5#include "imapwrapper.h" 5#include "imapwrapper.h"
6#include "mailtypes.h" 6#include "mailtypes.h"
7#include "logindialog.h" 7#include "logindialog.h"
8 8
9using namespace Opie::Core;
9IMAPwrapper::IMAPwrapper( IMAPaccount *a ) 10IMAPwrapper::IMAPwrapper( IMAPaccount *a )
10 : AbstractMail() 11 : AbstractMail()
11{ 12{
12 account = a; 13 account = a;
13 m_imap = 0; 14 m_imap = 0;
14 m_Lastmbox = ""; 15 m_Lastmbox = "";
15} 16}
16 17
17IMAPwrapper::~IMAPwrapper() 18IMAPwrapper::~IMAPwrapper()
18{ 19{
19 logout(); 20 logout();
20} 21}
21 22
22/* to avoid to often select statements in loops etc. 23/* to avoid to often select statements in loops etc.
23 we trust that we are logged in and connection is established!*/ 24 we trust that we are logged in and connection is established!*/
24int IMAPwrapper::selectMbox(const QString&mbox) 25int IMAPwrapper::selectMbox(const QString&mbox)
25{ 26{
26 if (mbox == m_Lastmbox) { 27 if (mbox == m_Lastmbox) {
27 return MAILIMAP_NO_ERROR; 28 return MAILIMAP_NO_ERROR;
28 } 29 }
29 int err = mailimap_select( m_imap, (char*)mbox.latin1()); 30 int err = mailimap_select( m_imap, (char*)mbox.latin1());
30 if ( err != MAILIMAP_NO_ERROR ) { 31 if ( err != MAILIMAP_NO_ERROR ) {
31 qDebug("error selecting mailbox: %s",m_imap->imap_response); 32 qDebug("error selecting mailbox: %s",m_imap->imap_response);
32 m_Lastmbox = ""; 33 m_Lastmbox = "";
33 return err; 34 return err;
34 } 35 }
35 m_Lastmbox = mbox; 36 m_Lastmbox = mbox;
36 return err; 37 return err;
37} 38}
38 39
39void IMAPwrapper::imap_progress( size_t current, size_t maximum ) 40void IMAPwrapper::imap_progress( size_t current, size_t maximum )
40{ 41{
41 qDebug( "IMAP: %i of %i", current, maximum ); 42 qDebug( "IMAP: %i of %i", current, maximum );
42} 43}
43 44
44bool IMAPwrapper::start_tls(bool force_tls) 45bool IMAPwrapper::start_tls(bool force_tls)
45{ 46{
46 int err; 47 int err;
47 bool try_tls; 48 bool try_tls;
48 mailimap_capability_data * cap_data = 0; 49 mailimap_capability_data * cap_data = 0;
49 50
50 err = mailimap_capability(m_imap,&cap_data); 51 err = mailimap_capability(m_imap,&cap_data);
51 if (err != MAILIMAP_NO_ERROR) { 52 if (err != MAILIMAP_NO_ERROR) {
52 Global::statusMessage("error getting capabilities!"); 53 Global::statusMessage("error getting capabilities!");
53 qDebug("error getting capabilities!"); 54 qDebug("error getting capabilities!");
54 return false; 55 return false;
55 } 56 }
56 clistiter * cur; 57 clistiter * cur;
57 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { 58 for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) {
58 struct mailimap_capability * cap; 59 struct mailimap_capability * cap;
59 cap = (struct mailimap_capability *)clist_content(cur); 60 cap = (struct mailimap_capability *)clist_content(cur);
60 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { 61 if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) {
61 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { 62 if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) {
62 try_tls = true; 63 try_tls = true;
63 break; 64 break;
64 } 65 }
65 } 66 }
66 } 67 }
67 if (cap_data) { 68 if (cap_data) {
68 mailimap_capability_data_free(cap_data); 69 mailimap_capability_data_free(cap_data);
69 } 70 }
70 if (try_tls) { 71 if (try_tls) {
71 err = mailimap_starttls(m_imap); 72 err = mailimap_starttls(m_imap);
72 if (err != MAILIMAP_NO_ERROR && force_tls) { 73 if (err != MAILIMAP_NO_ERROR && force_tls) {
73 Global::statusMessage(tr("Server has no TLS support!")); 74 Global::statusMessage(tr("Server has no TLS support!"));
74 qDebug("Server has no TLS support!"); 75 qDebug("Server has no TLS support!");
75 try_tls = false; 76 try_tls = false;
76 } else { 77 } else {
77 mailstream_low * low; 78 mailstream_low * low;
78 mailstream_low * new_low; 79 mailstream_low * new_low;
79 low = mailstream_get_low(m_imap->imap_stream); 80 low = mailstream_get_low(m_imap->imap_stream);
80 if (!low) { 81 if (!low) {
81 try_tls = false; 82 try_tls = false;
82 } else { 83 } else {
83 int fd = mailstream_low_get_fd(low); 84 int fd = mailstream_low_get_fd(low);
84 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 85 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
85 mailstream_low_free(low); 86 mailstream_low_free(low);
86 mailstream_set_low(m_imap->imap_stream, new_low); 87 mailstream_set_low(m_imap->imap_stream, new_low);
87 } else { 88 } else {
88 try_tls = false; 89 try_tls = false;
89 } 90 }
90 } 91 }
91 } 92 }
92 } 93 }
93 return try_tls; 94 return try_tls;
94} 95}
95 96
96void IMAPwrapper::login() 97void IMAPwrapper::login()
97{ 98{
98 const char *server, *user, *pass; 99 const char *server, *user, *pass;
99 uint16_t port; 100 uint16_t port;
100 int err = MAILIMAP_NO_ERROR; 101 int err = MAILIMAP_NO_ERROR;
101 102
102 if (account->getOffline()) return; 103 if (account->getOffline()) return;
103 /* we are connected this moment */ 104 /* we are connected this moment */
104 /* TODO: setup a timer holding the line or if connection closed - delete the value */ 105 /* TODO: setup a timer holding the line or if connection closed - delete the value */
105 if (m_imap) { 106 if (m_imap) {
106 err = mailimap_noop(m_imap); 107 err = mailimap_noop(m_imap);
107 if (err!=MAILIMAP_NO_ERROR) { 108 if (err!=MAILIMAP_NO_ERROR) {
108 logout(); 109 logout();
109 } else { 110 } else {
110 mailstream_flush(m_imap->imap_stream); 111 mailstream_flush(m_imap->imap_stream);
111 return; 112 return;
112 } 113 }
113 } 114 }
114 server = account->getServer().latin1(); 115 server = account->getServer().latin1();
115 port = account->getPort().toUInt(); 116 port = account->getPort().toUInt();
116 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 117 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
117 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 118 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
118 login.show(); 119 login.show();
119 if ( QDialog::Accepted == login.exec() ) { 120 if ( QDialog::Accepted == login.exec() ) {
120 // ok 121 // ok
121 user = login.getUser().latin1(); 122 user = login.getUser().latin1();
122 pass = login.getPassword().latin1(); 123 pass = login.getPassword().latin1();
123 } else { 124 } else {
124 // cancel 125 // cancel
125 qDebug( "IMAP: Login canceled" ); 126 qDebug( "IMAP: Login canceled" );
126 return; 127 return;
127 } 128 }
128 } else { 129 } else {
129 user = account->getUser().latin1(); 130 user = account->getUser().latin1();
130 pass = account->getPassword().latin1(); 131 pass = account->getPassword().latin1();
131 } 132 }
132 133
133 m_imap = mailimap_new( 20, &imap_progress ); 134 m_imap = mailimap_new( 20, &imap_progress );
134 135
135 /* connect */ 136 /* connect */
136 bool ssl = false; 137 bool ssl = false;
137 bool try_tls = false; 138 bool try_tls = false;
138 bool force_tls = false; 139 bool force_tls = false;
139 140
140 if ( account->ConnectionType() == 2 ) { 141 if ( account->ConnectionType() == 2 ) {
141 ssl = true; 142 ssl = true;
142 } 143 }
143 if (account->ConnectionType()==1) { 144 if (account->ConnectionType()==1) {
144 force_tls = true; 145 force_tls = true;
145 } 146 }
146 147
147 if ( ssl ) { 148 if ( ssl ) {
148 qDebug( "using ssl" ); 149 qDebug( "using ssl" );
149 err = mailimap_ssl_connect( m_imap, (char*)server, port ); 150 err = mailimap_ssl_connect( m_imap, (char*)server, port );
150 } else { 151 } else {
151 err = mailimap_socket_connect( m_imap, (char*)server, port ); 152 err = mailimap_socket_connect( m_imap, (char*)server, port );
152 } 153 }
153 154
154 if ( err != MAILIMAP_NO_ERROR && 155 if ( err != MAILIMAP_NO_ERROR &&
155 err != MAILIMAP_NO_ERROR_AUTHENTICATED && 156 err != MAILIMAP_NO_ERROR_AUTHENTICATED &&
156 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) { 157 err != MAILIMAP_NO_ERROR_NON_AUTHENTICATED ) {
157 QString failure = ""; 158 QString failure = "";
158 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) { 159 if (err == MAILIMAP_ERROR_CONNECTION_REFUSED) {
159 failure="Connection refused"; 160 failure="Connection refused";
160 } else { 161 } else {
161 failure="Unknown failure"; 162 failure="Unknown failure";
162 } 163 }
163 Global::statusMessage(tr("error connecting imap server: %1").arg(failure)); 164 Global::statusMessage(tr("error connecting imap server: %1").arg(failure));
164 mailimap_free( m_imap ); 165 mailimap_free( m_imap );
165 m_imap = 0; 166 m_imap = 0;
166 return; 167 return;
167 } 168 }
168 169
169 if (!ssl) { 170 if (!ssl) {
170 try_tls = start_tls(force_tls); 171 try_tls = start_tls(force_tls);
171 } 172 }
172 173
173 bool ok = true; 174 bool ok = true;
174 if (force_tls && !try_tls) { 175 if (force_tls && !try_tls) {
175 Global::statusMessage(tr("Server has no TLS support!")); 176 Global::statusMessage(tr("Server has no TLS support!"));
176 qDebug("Server has no TLS support!"); 177 qDebug("Server has no TLS support!");
177 ok = false; 178 ok = false;
178 } 179 }
179 180
180 181
181 /* login */ 182 /* login */
182 183
183 if (ok) { 184 if (ok) {
184 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass ); 185 err = mailimap_login_simple( m_imap, (char*)user, (char*)pass );
185 if ( err != MAILIMAP_NO_ERROR ) { 186 if ( err != MAILIMAP_NO_ERROR ) {
186 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response)); 187 Global::statusMessage(tr("error logging in imap server: %1").arg(m_imap->imap_response));
187 ok = false; 188 ok = false;
188 } 189 }
189 } 190 }
190 if (!ok) { 191 if (!ok) {
191 err = mailimap_close( m_imap ); 192 err = mailimap_close( m_imap );
192 mailimap_free( m_imap ); 193 mailimap_free( m_imap );
193 m_imap = 0; 194 m_imap = 0;
194 } 195 }
195} 196}
196 197
197void IMAPwrapper::logout() 198void IMAPwrapper::logout()
198{ 199{
199 int err = MAILIMAP_NO_ERROR; 200 int err = MAILIMAP_NO_ERROR;
200 if (!m_imap) return; 201 if (!m_imap) return;
201 err = mailimap_logout( m_imap ); 202 err = mailimap_logout( m_imap );
202 err = mailimap_close( m_imap ); 203 err = mailimap_close( m_imap );
203 mailimap_free( m_imap ); 204 mailimap_free( m_imap );
204 m_imap = 0; 205 m_imap = 0;
205 m_Lastmbox = ""; 206 m_Lastmbox = "";
206} 207}
207 208
208void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::OSmartPointer<RecMail> > &target ) 209void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
209{ 210{
210 int err = MAILIMAP_NO_ERROR; 211 int err = MAILIMAP_NO_ERROR;
211 clist *result = 0; 212 clist *result = 0;
212 clistcell *current; 213 clistcell *current;
213 mailimap_fetch_type *fetchType = 0; 214 mailimap_fetch_type *fetchType = 0;
214 mailimap_set *set = 0; 215 mailimap_set *set = 0;
215 216
216 login(); 217 login();
217 if (!m_imap) { 218 if (!m_imap) {
218 return; 219 return;
219 } 220 }
220 /* select mailbox READONLY for operations */ 221 /* select mailbox READONLY for operations */
221 err = selectMbox(mailbox); 222 err = selectMbox(mailbox);
222 if ( err != MAILIMAP_NO_ERROR ) { 223 if ( err != MAILIMAP_NO_ERROR ) {
223 return; 224 return;
224 } 225 }
225 226
226 int last = m_imap->imap_selection_info->sel_exists; 227 int last = m_imap->imap_selection_info->sel_exists;
227 228
228 if (last == 0) { 229 if (last == 0) {
229 Global::statusMessage(tr("Mailbox has no mails")); 230 Global::statusMessage(tr("Mailbox has no mails"));
230 return; 231 return;
231 } else { 232 } else {
232 } 233 }
233 234
234 /* the range has to start at 1!!! not with 0!!!! */ 235 /* the range has to start at 1!!! not with 0!!!! */
235 set = mailimap_set_new_interval( 1, last ); 236 set = mailimap_set_new_interval( 1, last );
236 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 237 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
237 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 238 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
238 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 239 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
239 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 240 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
240 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 241 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
241 242
242 err = mailimap_fetch( m_imap, set, fetchType, &result ); 243 err = mailimap_fetch( m_imap, set, fetchType, &result );
243 mailimap_set_free( set ); 244 mailimap_set_free( set );
244 mailimap_fetch_type_free( fetchType ); 245 mailimap_fetch_type_free( fetchType );
245 246
246 QString date,subject,from; 247 QString date,subject,from;
247 248
248 if ( err == MAILIMAP_NO_ERROR ) { 249 if ( err == MAILIMAP_NO_ERROR ) {
249 mailimap_msg_att * msg_att; 250 mailimap_msg_att * msg_att;
250 int i = 0; 251 int i = 0;
251 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 252 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
252 ++i; 253 ++i;
253 msg_att = (mailimap_msg_att*)current->data; 254 msg_att = (mailimap_msg_att*)current->data;
254 RecMail*m = parse_list_result(msg_att); 255 RecMail*m = parse_list_result(msg_att);
255 if (m) { 256 if (m) {
256 m->setNumber(i); 257 m->setNumber(i);
257 m->setMbox(mailbox); 258 m->setMbox(mailbox);
258 m->setWrapper(this); 259 m->setWrapper(this);
259 target.append(m); 260 target.append(m);
260 } 261 }
261 } 262 }
262 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count())); 263 Global::statusMessage(tr("Mailbox has %1 mails").arg(target.count()));
263 } else { 264 } else {
264 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response)); 265 Global::statusMessage(tr("Error fetching headers: %1").arg(m_imap->imap_response));
265 } 266 }
266 if (result) mailimap_fetch_list_free(result); 267 if (result) mailimap_fetch_list_free(result);
267} 268}
268 269
269QValueList<Opie::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 270QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
270{ 271{
271 const char *path, *mask; 272 const char *path, *mask;
272 int err = MAILIMAP_NO_ERROR; 273 int err = MAILIMAP_NO_ERROR;
273 clist *result = 0; 274 clist *result = 0;
274 clistcell *current = 0; 275 clistcell *current = 0;
275 clistcell*cur_flag = 0; 276 clistcell*cur_flag = 0;
276 mailimap_mbx_list_flags*bflags = 0; 277 mailimap_mbx_list_flags*bflags = 0;
277 278
278 QValueList<FolderP>* folders = new QValueList<FolderP>(); 279 QValueList<FolderP>* folders = new QValueList<FolderP>();
279 login(); 280 login();
280 if (!m_imap) { 281 if (!m_imap) {
281 return folders; 282 return folders;
282 } 283 }
283 284
284/* 285/*
285 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 286 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
286 * We must not forget to filter them out in next loop! 287 * We must not forget to filter them out in next loop!
287 * it seems like ugly code. and yes - it is ugly code. but the best way. 288 * it seems like ugly code. and yes - it is ugly code. but the best way.
288 */ 289 */
289 QString temp; 290 QString temp;
290 mask = "INBOX" ; 291 mask = "INBOX" ;
291 mailimap_mailbox_list *list; 292 mailimap_mailbox_list *list;
292 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 293 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
293 QString del; 294 QString del;
294 bool selectable = true; 295 bool selectable = true;
295 bool no_inferiors = false; 296 bool no_inferiors = false;
296 if ( err == MAILIMAP_NO_ERROR ) { 297 if ( err == MAILIMAP_NO_ERROR ) {
297 current = result->first; 298 current = result->first;
298 for ( int i = result->count; i > 0; i-- ) { 299 for ( int i = result->count; i > 0; i-- ) {
299 list = (mailimap_mailbox_list *) current->data; 300 list = (mailimap_mailbox_list *) current->data;
300 // it is better use the deep copy mechanism of qt itself 301 // it is better use the deep copy mechanism of qt itself
301 // instead of using strdup! 302 // instead of using strdup!
302 temp = list->mb_name; 303 temp = list->mb_name;
303 del = list->mb_delimiter; 304 del = list->mb_delimiter;
304 current = current->next; 305 current = current->next;
305 if ( (bflags = list->mb_flag) ) { 306 if ( (bflags = list->mb_flag) ) {
306 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 307 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
307 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 308 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
308 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 309 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
309 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 310 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
310 no_inferiors = true; 311 no_inferiors = true;
311 } 312 }
312 } 313 }
313 } 314 }
314 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 315 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
315 } 316 }
316 } else { 317 } else {
317 qDebug("error fetching folders: %s",m_imap->imap_response); 318 qDebug("error fetching folders: %s",m_imap->imap_response);
318 } 319 }
319 mailimap_list_result_free( result ); 320 mailimap_list_result_free( result );
320 321
321/* 322/*
322 * second stage - get the other then inbox folders 323 * second stage - get the other then inbox folders
323 */ 324 */
324 mask = "*" ; 325 mask = "*" ;
325 path = account->getPrefix().latin1(); 326 path = account->getPrefix().latin1();
326 if (!path) path = ""; 327 if (!path) path = "";
327 qDebug(path); 328 qDebug(path);
328 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 329 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
329 if ( err == MAILIMAP_NO_ERROR ) { 330 if ( err == MAILIMAP_NO_ERROR ) {
330 current = result->first; 331 current = result->first;
331 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 332 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
332 no_inferiors = false; 333 no_inferiors = false;
333 list = (mailimap_mailbox_list *) current->data; 334 list = (mailimap_mailbox_list *) current->data;
334 // it is better use the deep copy mechanism of qt itself 335 // it is better use the deep copy mechanism of qt itself
335 // instead of using strdup! 336 // instead of using strdup!
336 temp = list->mb_name; 337 temp = list->mb_name;
337 if (temp.lower()=="inbox") 338 if (temp.lower()=="inbox")
338 continue; 339 continue;
339 if (temp.lower()==account->getPrefix().lower()) 340 if (temp.lower()==account->getPrefix().lower())
340 continue; 341 continue;
341 if ( (bflags = list->mb_flag) ) { 342 if ( (bflags = list->mb_flag) ) {
342 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 343 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
343 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 344 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
344 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 345 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
345 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 346 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
346 no_inferiors = true; 347 no_inferiors = true;
347 } 348 }
348 } 349 }
349 } 350 }
350 del = list->mb_delimiter; 351 del = list->mb_delimiter;
351 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 352 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
352 } 353 }
353 } else { 354 } else {
354 qDebug("error fetching folders %s",m_imap->imap_response); 355 qDebug("error fetching folders %s",m_imap->imap_response);
355 } 356 }
356 if (result) mailimap_list_result_free( result ); 357 if (result) mailimap_list_result_free( result );
357 return folders; 358 return folders;
358} 359}
359 360
360RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 361RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
361{ 362{
362 RecMail * m = 0; 363 RecMail * m = 0;
363 mailimap_msg_att_item *item=0; 364 mailimap_msg_att_item *item=0;
364 clistcell *current,*c,*cf; 365 clistcell *current,*c,*cf;
365 mailimap_msg_att_dynamic*flist; 366 mailimap_msg_att_dynamic*flist;
366 mailimap_flag_fetch*cflag; 367 mailimap_flag_fetch*cflag;
367 int size; 368 int size;
368 QBitArray mFlags(7); 369 QBitArray mFlags(7);
369 QStringList addresslist; 370 QStringList addresslist;
370 371
371 if (!m_att) { 372 if (!m_att) {
372 return m; 373 return m;
373 } 374 }
374 m = new RecMail(); 375 m = new RecMail();
375 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 376 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
376 current = c; 377 current = c;
377 size = 0; 378 size = 0;
378 item = (mailimap_msg_att_item*)current->data; 379 item = (mailimap_msg_att_item*)current->data;
379 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 380 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
380 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 381 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
381 if (!flist->att_list) { 382 if (!flist->att_list) {
382 continue; 383 continue;
383 } 384 }
384 cf = flist->att_list->first; 385 cf = flist->att_list->first;
385 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 386 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
386 cflag = (mailimap_flag_fetch*)cf->data; 387 cflag = (mailimap_flag_fetch*)cf->data;
387 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 388 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
388 switch (cflag->fl_flag->fl_type) { 389 switch (cflag->fl_flag->fl_type) {
389 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 390 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
390 mFlags.setBit(FLAG_ANSWERED); 391 mFlags.setBit(FLAG_ANSWERED);
391 break; 392 break;
392 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 393 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
393 mFlags.setBit(FLAG_FLAGGED); 394 mFlags.setBit(FLAG_FLAGGED);
394 break; 395 break;
395 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 396 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
396 mFlags.setBit(FLAG_DELETED); 397 mFlags.setBit(FLAG_DELETED);
397 break; 398 break;
398 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 399 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
399 mFlags.setBit(FLAG_SEEN); 400 mFlags.setBit(FLAG_SEEN);
400 break; 401 break;
401 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 402 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
402 mFlags.setBit(FLAG_DRAFT); 403 mFlags.setBit(FLAG_DRAFT);
403 break; 404 break;
404 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 405 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
405 break; 406 break;
406 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 407 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
407 break; 408 break;
408 default: 409 default:
409 break; 410 break;
410 } 411 }
411 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { 412 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
412 mFlags.setBit(FLAG_RECENT); 413 mFlags.setBit(FLAG_RECENT);
413 } 414 }
414 } 415 }
415 continue; 416 continue;
416 } 417 }
417 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 418 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
418 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 419 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
419 m->setDate(head->env_date); 420 m->setDate(head->env_date);
420 m->setSubject(convert_String((const char*)head->env_subject)); 421 m->setSubject(convert_String((const char*)head->env_subject));
421 //m->setSubject(head->env_subject); 422 //m->setSubject(head->env_subject);
422 if (head->env_from!=NULL) { 423 if (head->env_from!=NULL) {
423 addresslist = address_list_to_stringlist(head->env_from->frm_list); 424 addresslist = address_list_to_stringlist(head->env_from->frm_list);
424 if (addresslist.count()) { 425 if (addresslist.count()) {
425 m->setFrom(addresslist.first()); 426 m->setFrom(addresslist.first());
426 } 427 }
427 } 428 }
428 if (head->env_to!=NULL) { 429 if (head->env_to!=NULL) {
429 addresslist = address_list_to_stringlist(head->env_to->to_list); 430 addresslist = address_list_to_stringlist(head->env_to->to_list);
430 m->setTo(addresslist); 431 m->setTo(addresslist);
431 } 432 }
432 if (head->env_cc!=NULL) { 433 if (head->env_cc!=NULL) {
433 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 434 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
434 m->setCC(addresslist); 435 m->setCC(addresslist);
435 } 436 }
436 if (head->env_bcc!=NULL) { 437 if (head->env_bcc!=NULL) {
437 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 438 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
438 m->setBcc(addresslist); 439 m->setBcc(addresslist);
439 } 440 }
440 /* reply to address, eg. email. */ 441 /* reply to address, eg. email. */
441 if (head->env_reply_to!=NULL) { 442 if (head->env_reply_to!=NULL) {
442 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 443 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
443 if (addresslist.count()) { 444 if (addresslist.count()) {
444 m->setReplyto(addresslist.first()); 445 m->setReplyto(addresslist.first());
445 } 446 }
446 } 447 }
447 if (head->env_in_reply_to!=NULL) { 448 if (head->env_in_reply_to!=NULL) {
448 QString h(head->env_in_reply_to); 449 QString h(head->env_in_reply_to);
449 while (h.length()>0 && h[0]=='<') { 450 while (h.length()>0 && h[0]=='<') {
450 h.remove(0,1); 451 h.remove(0,1);
451 } 452 }
452 while (h.length()>0 && h[h.length()-1]=='>') { 453 while (h.length()>0 && h[h.length()-1]=='>') {
453 h.remove(h.length()-1,1); 454 h.remove(h.length()-1,1);
454 } 455 }
455 if (h.length()>0) { 456 if (h.length()>0) {
456 m->setInreply(QStringList(h)); 457 m->setInreply(QStringList(h));
457 } 458 }
458 } 459 }
459 if (head->env_message_id) { 460 if (head->env_message_id) {
460 m->setMsgid(QString(head->env_message_id)); 461 m->setMsgid(QString(head->env_message_id));
461 } 462 }
diff --git a/noncore/net/mail/libmailwrapper/imapwrapper.h b/noncore/net/mail/libmailwrapper/imapwrapper.h
index 3bd5967..7448acb 100644
--- a/noncore/net/mail/libmailwrapper/imapwrapper.h
+++ b/noncore/net/mail/libmailwrapper/imapwrapper.h
@@ -1,80 +1,80 @@
1#ifndef __IMAPWRAPPER 1#ifndef __IMAPWRAPPER
2#define __IMAPWRAPPER 2#define __IMAPWRAPPER
3 3
4#include <qlist.h> 4#include <qlist.h>
5#include "mailwrapper.h" 5#include "mailwrapper.h"
6#include "abstractmail.h" 6#include "abstractmail.h"
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9struct mailimap; 9struct mailimap;
10struct mailimap_body; 10struct mailimap_body;
11struct mailimap_body_type_1part; 11struct mailimap_body_type_1part;
12struct mailimap_body_type_text; 12struct mailimap_body_type_text;
13struct mailimap_body_type_basic; 13struct mailimap_body_type_basic;
14struct mailimap_body_type_msg; 14struct mailimap_body_type_msg;
15struct mailimap_body_type_mpart; 15struct mailimap_body_type_mpart;
16struct mailimap_body_fields; 16struct mailimap_body_fields;
17struct mailimap_msg_att; 17struct mailimap_msg_att;
18class encodedString; 18class encodedString;
19 19
20class IMAPwrapper : public AbstractMail 20class IMAPwrapper : public AbstractMail
21{ 21{
22 Q_OBJECT 22 Q_OBJECT
23public: 23public:
24 IMAPwrapper( IMAPaccount *a ); 24 IMAPwrapper( IMAPaccount *a );
25 virtual ~IMAPwrapper(); 25 virtual ~IMAPwrapper();
26 virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); 26 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
27 virtual void listMessages(const QString & mailbox,QValueList<Opie::OSmartPointer<RecMail> >&target ); 27 virtual void listMessages(const QString & mailbox,QValueList<Opie::Core::OSmartPointer<RecMail> >&target );
28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 28 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
29 29
30 virtual void deleteMail(const RecMailP&mail); 30 virtual void deleteMail(const RecMailP&mail);
31 virtual void answeredMail(const RecMailP&mail); 31 virtual void answeredMail(const RecMailP&mail);
32 virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&folder); 32 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&folder);
33 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 33 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
34 virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, 34 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
35 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 35 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
36 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 36 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
37 37
38 virtual RecBody fetchBody(const RecMailP&mail); 38 virtual RecBody fetchBody(const RecMailP&mail);
39 virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part); 39 virtual QString fetchTextPart(const RecMailP&mail,const RecPart&part);
40 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part); 40 virtual encodedString* fetchDecodedPart(const RecMailP&mail,const RecPart&part);
41 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part); 41 virtual encodedString* fetchRawPart(const RecMailP&mail,const RecPart&part);
42 virtual encodedString* fetchRawBody(const RecMailP&mail); 42 virtual encodedString* fetchRawBody(const RecMailP&mail);
43 43
44 virtual int createMbox(const QString&,const Opie::OSmartPointer<Folder>&parentfolder=0, 44 virtual int createMbox(const QString&,const Opie::Core::OSmartPointer<Folder>&parentfolder=0,
45 const QString& delemiter="/",bool getsubfolder=false); 45 const QString& delemiter="/",bool getsubfolder=false);
46 virtual int deleteMbox(const Opie::OSmartPointer<Folder>&folder); 46 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&folder);
47 47
48 static void imap_progress( size_t current, size_t maximum ); 48 static void imap_progress( size_t current, size_t maximum );
49 49
50 virtual void logout(); 50 virtual void logout();
51 virtual MAILLIB::ATYPE getType()const; 51 virtual MAILLIB::ATYPE getType()const;
52 virtual const QString&getName()const; 52 virtual const QString&getName()const;
53 53
54protected: 54protected:
55 RecMail*parse_list_result(mailimap_msg_att*); 55 RecMail*parse_list_result(mailimap_msg_att*);
56 void login(); 56 void login();
57 bool start_tls(bool force=true); 57 bool start_tls(bool force=true);
58 58
59 virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc=""); 59 virtual QString fetchTextPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call=false,const QString&enc="");
60 virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call); 60 virtual encodedString*fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call);
61 int selectMbox(const QString&mbox); 61 int selectMbox(const QString&mbox);
62 62
63 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description); 63 void fillSinglePart(RecPart&target_part,mailimap_body_type_1part*Description);
64 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which); 64 void fillSingleTextPart(RecPart&target_part,mailimap_body_type_text*which);
65 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which); 65 void fillSingleBasicPart(RecPart&target_part,mailimap_body_type_basic*which);
66 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which); 66 void fillSingleMsgPart(RecPart&target_part,mailimap_body_type_msg*which);
67 void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which); 67 void fillMultiPart(RecPart&target_part,mailimap_body_type_mpart*which);
68 void traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1); 68 void traverseBody(const RecMailP&mail,mailimap_body*body,RecBody&target_body,int current_recursion,QValueList<int>recList,int current_count=1);
69 69
70 /* just helpers */ 70 /* just helpers */
71 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which); 71 static void fillBodyFields(RecPart&target_part,mailimap_body_fields*which);
72 static QStringList address_list_to_stringlist(clist*list); 72 static QStringList address_list_to_stringlist(clist*list);
73 73
74 74
75 IMAPaccount *account; 75 IMAPaccount *account;
76 mailimap *m_imap; 76 mailimap *m_imap;
77 QString m_Lastmbox; 77 QString m_Lastmbox;
78}; 78};
79 79
80#endif 80#endif
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.cpp b/noncore/net/mail/libmailwrapper/mailtypes.cpp
index 7dd7e58..fd91fe5 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.cpp
+++ b/noncore/net/mail/libmailwrapper/mailtypes.cpp
@@ -1,203 +1,204 @@
1#include "mailtypes.h" 1#include "mailtypes.h"
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4using namespace Opie::Core;
4RecMail::RecMail() 5RecMail::RecMail()
5 :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7) 6 :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_size(0),msg_flags(7)
6{ 7{
7 init(); 8 init();
8} 9}
9 10
10RecMail::RecMail(const RecMail&old) 11RecMail::RecMail(const RecMail&old)
11 :Opie::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7) 12 :Opie::Core::ORefCount(),subject(""),date(""),from(""),mbox(""),msg_id(""),msg_number(0),msg_flags(7)
12{ 13{
13 init(); 14 init();
14 copy_old(old); 15 copy_old(old);
15 qDebug("Copy constructor RecMail"); 16 qDebug("Copy constructor RecMail");
16} 17}
17 18
18RecMail::~RecMail() 19RecMail::~RecMail()
19{ 20{
20 wrapper = 0; 21 wrapper = 0;
21} 22}
22 23
23void RecMail::copy_old(const RecMail&old) 24void RecMail::copy_old(const RecMail&old)
24{ 25{
25 subject = old.subject; 26 subject = old.subject;
26 date = old.date; 27 date = old.date;
27 mbox = old.mbox; 28 mbox = old.mbox;
28 msg_id = old.msg_id; 29 msg_id = old.msg_id;
29 msg_size = old.msg_size; 30 msg_size = old.msg_size;
30 msg_number = old.msg_number; 31 msg_number = old.msg_number;
31 from = old.from; 32 from = old.from;
32 msg_flags = old.msg_flags; 33 msg_flags = old.msg_flags;
33 to = old.to; 34 to = old.to;
34 cc = old.cc; 35 cc = old.cc;
35 bcc = old.bcc; 36 bcc = old.bcc;
36 wrapper = old.wrapper; 37 wrapper = old.wrapper;
37 in_reply_to = old.in_reply_to; 38 in_reply_to = old.in_reply_to;
38 references = old.references; 39 references = old.references;
39 replyto = old.replyto; 40 replyto = old.replyto;
40} 41}
41 42
42void RecMail::init() 43void RecMail::init()
43{ 44{
44 to.clear(); 45 to.clear();
45 cc.clear(); 46 cc.clear();
46 bcc.clear(); 47 bcc.clear();
47 in_reply_to.clear(); 48 in_reply_to.clear();
48 references.clear(); 49 references.clear();
49 wrapper = 0; 50 wrapper = 0;
50} 51}
51 52
52void RecMail::setWrapper(AbstractMail*awrapper) 53void RecMail::setWrapper(AbstractMail*awrapper)
53{ 54{
54 wrapper = awrapper; 55 wrapper = awrapper;
55} 56}
56 57
57AbstractMail* RecMail::Wrapper() 58AbstractMail* RecMail::Wrapper()
58{ 59{
59 return wrapper; 60 return wrapper;
60} 61}
61 62
62void RecMail::setTo(const QStringList&list) 63void RecMail::setTo(const QStringList&list)
63{ 64{
64 to = list; 65 to = list;
65} 66}
66 67
67const QStringList&RecMail::To()const 68const QStringList&RecMail::To()const
68{ 69{
69 return to; 70 return to;
70} 71}
71 72
72void RecMail::setCC(const QStringList&list) 73void RecMail::setCC(const QStringList&list)
73{ 74{
74 cc = list; 75 cc = list;
75} 76}
76 77
77const QStringList&RecMail::CC()const 78const QStringList&RecMail::CC()const
78{ 79{
79 return cc; 80 return cc;
80} 81}
81 82
82void RecMail::setBcc(const QStringList&list) 83void RecMail::setBcc(const QStringList&list)
83{ 84{
84 bcc = list; 85 bcc = list;
85} 86}
86 87
87const QStringList& RecMail::Bcc()const 88const QStringList& RecMail::Bcc()const
88{ 89{
89 return bcc; 90 return bcc;
90} 91}
91 92
92void RecMail::setInreply(const QStringList&list) 93void RecMail::setInreply(const QStringList&list)
93{ 94{
94 in_reply_to = list; 95 in_reply_to = list;
95} 96}
96 97
97const QStringList& RecMail::Inreply()const 98const QStringList& RecMail::Inreply()const
98{ 99{
99 return in_reply_to; 100 return in_reply_to;
100} 101}
101 102
102void RecMail::setReferences(const QStringList&list) 103void RecMail::setReferences(const QStringList&list)
103{ 104{
104 references = list; 105 references = list;
105} 106}
106 107
107const QStringList& RecMail::References()const 108const QStringList& RecMail::References()const
108{ 109{
109 return references; 110 return references;
110} 111}
111 112
112RecPart::RecPart() 113RecPart::RecPart()
113 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0) 114 : m_type(""),m_subtype(""),m_identifier(""),m_encoding(""),m_description(""),m_lines(0),m_size(0)
114{ 115{
115 m_Parameters.clear(); 116 m_Parameters.clear();
116 m_poslist.clear(); 117 m_poslist.clear();
117} 118}
118 119
119RecPart::~RecPart() 120RecPart::~RecPart()
120{ 121{
121} 122}
122 123
123void RecPart::setSize(unsigned int size) 124void RecPart::setSize(unsigned int size)
124{ 125{
125 m_size = size; 126 m_size = size;
126} 127}
127 128
128const unsigned int RecPart::Size()const 129const unsigned int RecPart::Size()const
129{ 130{
130 return m_size; 131 return m_size;
131} 132}
132 133
133void RecPart::setLines(unsigned int lines) 134void RecPart::setLines(unsigned int lines)
134{ 135{
135 m_lines = lines; 136 m_lines = lines;
136} 137}
137 138
138const unsigned int RecPart::Lines()const 139const unsigned int RecPart::Lines()const
139{ 140{
140 return m_lines; 141 return m_lines;
141} 142}
142 143
143const QString& RecPart::Type()const 144const QString& RecPart::Type()const
144{ 145{
145 return m_type; 146 return m_type;
146} 147}
147 148
148void RecPart::setType(const QString&type) 149void RecPart::setType(const QString&type)
149{ 150{
150 m_type = type; 151 m_type = type;
151} 152}
152 153
153const QString& RecPart::Subtype()const 154const QString& RecPart::Subtype()const
154{ 155{
155 return m_subtype; 156 return m_subtype;
156} 157}
157 158
158void RecPart::setSubtype(const QString&subtype) 159void RecPart::setSubtype(const QString&subtype)
159{ 160{
160 m_subtype = subtype; 161 m_subtype = subtype;
161} 162}
162 163
163const QString& RecPart::Identifier()const 164const QString& RecPart::Identifier()const
164{ 165{
165 return m_identifier; 166 return m_identifier;
166} 167}
167 168
168void RecPart::setIdentifier(const QString&identifier) 169void RecPart::setIdentifier(const QString&identifier)
169{ 170{
170 m_identifier = identifier; 171 m_identifier = identifier;
171} 172}
172 173
173const QString& RecPart::Encoding()const 174const QString& RecPart::Encoding()const
174{ 175{
175 return m_encoding; 176 return m_encoding;
176} 177}
177 178
178void RecPart::setEncoding(const QString&encoding) 179void RecPart::setEncoding(const QString&encoding)
179{ 180{
180 m_encoding = encoding; 181 m_encoding = encoding;
181} 182}
182 183
183const QString& RecPart::Description()const 184const QString& RecPart::Description()const
184{ 185{
185 return m_description; 186 return m_description;
186} 187}
187 188
188void RecPart::setDescription(const QString&desc) 189void RecPart::setDescription(const QString&desc)
189{ 190{
190 m_description = desc; 191 m_description = desc;
191} 192}
192 193
193void RecPart::setParameters(const part_plist_t&list) 194void RecPart::setParameters(const part_plist_t&list)
194{ 195{
195 m_Parameters = list; 196 m_Parameters = list;
196} 197}
197 198
198const part_plist_t& RecPart::Parameters()const 199const part_plist_t& RecPart::Parameters()const
199{ 200{
200 return m_Parameters; 201 return m_Parameters;
201} 202}
202 203
203void RecPart::addParameter(const QString&key,const QString&value) 204void RecPart::addParameter(const QString&key,const QString&value)
diff --git a/noncore/net/mail/libmailwrapper/mailtypes.h b/noncore/net/mail/libmailwrapper/mailtypes.h
index dc10de6..941556a 100644
--- a/noncore/net/mail/libmailwrapper/mailtypes.h
+++ b/noncore/net/mail/libmailwrapper/mailtypes.h
@@ -1,200 +1,200 @@
1#ifndef __MAIL_TYPES_H 1#ifndef __MAIL_TYPES_H
2#define __MAIL_TYPES_H 2#define __MAIL_TYPES_H
3 3
4#define FLAG_ANSWERED 0 4#define FLAG_ANSWERED 0
5#define FLAG_FLAGGED 1 5#define FLAG_FLAGGED 1
6#define FLAG_DELETED 2 6#define FLAG_DELETED 2
7#define FLAG_SEEN 3 7#define FLAG_SEEN 3
8#define FLAG_DRAFT 4 8#define FLAG_DRAFT 4
9#define FLAG_RECENT 5 9#define FLAG_RECENT 5
10 10
11#include <opie2/osmartpointer.h> 11#include <opie2/osmartpointer.h>
12 12
13#include <qbitarray.h> 13#include <qbitarray.h>
14#include <qstring.h> 14#include <qstring.h>
15#include <qstringlist.h> 15#include <qstringlist.h>
16#include <qmap.h> 16#include <qmap.h>
17#include <qvaluelist.h> 17#include <qvaluelist.h>
18 18
19class AbstractMail; 19class AbstractMail;
20/* a class to describe mails in a mailbox */ 20/* a class to describe mails in a mailbox */
21/* Attention! 21/* Attention!
22 From programmers point of view it would make sense to 22 From programmers point of view it would make sense to
23 store the mail body into this class, too. 23 store the mail body into this class, too.
24 But: not from the point of view of the device. 24 But: not from the point of view of the device.
25 Mailbodies can be real large. So we request them when 25 Mailbodies can be real large. So we request them when
26 needed from the mail-wrapper class direct from the server itself 26 needed from the mail-wrapper class direct from the server itself
27 (imap) or from a file-based cache (pop3?) 27 (imap) or from a file-based cache (pop3?)
28 So there is no interface "const QString&body()" but you should 28 So there is no interface "const QString&body()" but you should
29 make a request to the mailwrapper with this class as parameter to 29 make a request to the mailwrapper with this class as parameter to
30 get the body. Same words for the attachments. 30 get the body. Same words for the attachments.
31*/ 31*/
32class RecMail:public Opie::ORefCount 32class RecMail:public Opie::Core::ORefCount
33{ 33{
34public: 34public:
35 RecMail(); 35 RecMail();
36 RecMail(const RecMail&old); 36 RecMail(const RecMail&old);
37 virtual ~RecMail(); 37 virtual ~RecMail();
38 38
39 const unsigned int getNumber()const{return msg_number;} 39 const unsigned int getNumber()const{return msg_number;}
40 void setNumber(unsigned int number){msg_number=number;} 40 void setNumber(unsigned int number){msg_number=number;}
41 const QString&getDate()const{ return date; } 41 const QString&getDate()const{ return date; }
42 void setDate( const QString&a ) { date = a; } 42 void setDate( const QString&a ) { date = a; }
43 const QString&getFrom()const{ return from; } 43 const QString&getFrom()const{ return from; }
44 void setFrom( const QString&a ) { from = a; } 44 void setFrom( const QString&a ) { from = a; }
45 const QString&getSubject()const { return subject; } 45 const QString&getSubject()const { return subject; }
46 void setSubject( const QString&s ) { subject = s; } 46 void setSubject( const QString&s ) { subject = s; }
47 const QString&getMbox()const{return mbox;} 47 const QString&getMbox()const{return mbox;}
48 void setMbox(const QString&box){mbox = box;} 48 void setMbox(const QString&box){mbox = box;}
49 void setMsgid(const QString&id){msg_id=id;} 49 void setMsgid(const QString&id){msg_id=id;}
50 const QString&Msgid()const{return msg_id;} 50 const QString&Msgid()const{return msg_id;}
51 void setReplyto(const QString&reply){replyto=reply;} 51 void setReplyto(const QString&reply){replyto=reply;}
52 const QString&Replyto()const{return replyto;} 52 const QString&Replyto()const{return replyto;}
53 void setMsgsize(unsigned int size){msg_size = size;} 53 void setMsgsize(unsigned int size){msg_size = size;}
54 const unsigned int Msgsize()const{return msg_size;} 54 const unsigned int Msgsize()const{return msg_size;}
55 55
56 56
57 void setTo(const QStringList&list); 57 void setTo(const QStringList&list);
58 const QStringList&To()const; 58 const QStringList&To()const;
59 void setCC(const QStringList&list); 59 void setCC(const QStringList&list);
60 const QStringList&CC()const; 60 const QStringList&CC()const;
61 void setBcc(const QStringList&list); 61 void setBcc(const QStringList&list);
62 const QStringList&Bcc()const; 62 const QStringList&Bcc()const;
63 void setInreply(const QStringList&list); 63 void setInreply(const QStringList&list);
64 const QStringList&Inreply()const; 64 const QStringList&Inreply()const;
65 void setReferences(const QStringList&list); 65 void setReferences(const QStringList&list);
66 const QStringList&References()const; 66 const QStringList&References()const;
67 67
68 const QBitArray&getFlags()const{return msg_flags;} 68 const QBitArray&getFlags()const{return msg_flags;}
69 void setFlags(const QBitArray&flags){msg_flags = flags;} 69 void setFlags(const QBitArray&flags){msg_flags = flags;}
70 70
71 void setWrapper(AbstractMail*wrapper); 71 void setWrapper(AbstractMail*wrapper);
72 AbstractMail* Wrapper(); 72 AbstractMail* Wrapper();
73 73
74protected: 74protected:
75 QString subject,date,from,mbox,msg_id,replyto; 75 QString subject,date,from,mbox,msg_id,replyto;
76 unsigned int msg_number,msg_size; 76 unsigned int msg_number,msg_size;
77 QBitArray msg_flags; 77 QBitArray msg_flags;
78 QStringList to,cc,bcc,in_reply_to,references; 78 QStringList to,cc,bcc,in_reply_to,references;
79 AbstractMail*wrapper; 79 AbstractMail*wrapper;
80 void init(); 80 void init();
81 void copy_old(const RecMail&old); 81 void copy_old(const RecMail&old);
82}; 82};
83 83
84typedef Opie::OSmartPointer<RecMail> RecMailP; 84typedef Opie::Core::OSmartPointer<RecMail> RecMailP;
85typedef QMap<QString,QString> part_plist_t; 85typedef QMap<QString,QString> part_plist_t;
86 86
87class RecPart 87class RecPart
88{ 88{
89protected: 89protected:
90 QString m_type,m_subtype,m_identifier,m_encoding,m_description; 90 QString m_type,m_subtype,m_identifier,m_encoding,m_description;
91 unsigned int m_lines,m_size; 91 unsigned int m_lines,m_size;
92 part_plist_t m_Parameters; 92 part_plist_t m_Parameters;
93 /* describes the position in the mail */ 93 /* describes the position in the mail */
94 QValueList<int> m_poslist; 94 QValueList<int> m_poslist;
95 95
96public: 96public:
97 RecPart(); 97 RecPart();
98 virtual ~RecPart(); 98 virtual ~RecPart();
99 99
100 const QString&Type()const; 100 const QString&Type()const;
101 void setType(const QString&type); 101 void setType(const QString&type);
102 const QString&Subtype()const; 102 const QString&Subtype()const;
103 void setSubtype(const QString&subtype); 103 void setSubtype(const QString&subtype);
104 const QString&Identifier()const; 104 const QString&Identifier()const;
105 void setIdentifier(const QString&identifier); 105 void setIdentifier(const QString&identifier);
106 const QString&Encoding()const; 106 const QString&Encoding()const;
107 void setEncoding(const QString&encoding); 107 void setEncoding(const QString&encoding);
108 const QString&Description()const; 108 const QString&Description()const;
109 void setDescription(const QString&desc); 109 void setDescription(const QString&desc);
110 void setLines(unsigned int lines); 110 void setLines(unsigned int lines);
111 const unsigned int Lines()const; 111 const unsigned int Lines()const;
112 void setSize(unsigned int size); 112 void setSize(unsigned int size);
113 const unsigned int Size()const; 113 const unsigned int Size()const;
114 114
115 115
116 void setParameters(const part_plist_t&list); 116 void setParameters(const part_plist_t&list);
117 const part_plist_t&Parameters()const; 117 const part_plist_t&Parameters()const;
118 void addParameter(const QString&key,const QString&value); 118 void addParameter(const QString&key,const QString&value);
119 const QString searchParamter(const QString&key)const; 119 const QString searchParamter(const QString&key)const;
120 void setPositionlist(const QValueList<int>&poslist); 120 void setPositionlist(const QValueList<int>&poslist);
121 const QValueList<int>& Positionlist()const; 121 const QValueList<int>& Positionlist()const;
122}; 122};
123 123
124class RecBody 124class RecBody
125{ 125{
126protected: 126protected:
127 QString m_BodyText; 127 QString m_BodyText;
128 QValueList<RecPart> m_PartsList; 128 QValueList<RecPart> m_PartsList;
129 RecPart m_description; 129 RecPart m_description;
130 130
131public: 131public:
132 RecBody(); 132 RecBody();
133 virtual ~RecBody(); 133 virtual ~RecBody();
134 void setBodytext(const QString&); 134 void setBodytext(const QString&);
135 const QString& Bodytext()const; 135 const QString& Bodytext()const;
136 136
137 void setDescription(const RecPart&des); 137 void setDescription(const RecPart&des);
138 const RecPart& Description()const; 138 const RecPart& Description()const;
139 139
140 void setParts(const QValueList<RecPart>&parts); 140 void setParts(const QValueList<RecPart>&parts);
141 const QValueList<RecPart>& Parts()const; 141 const QValueList<RecPart>& Parts()const;
142 void addPart(const RecPart&part); 142 void addPart(const RecPart&part);
143}; 143};
144 144
145class encodedString 145class encodedString
146{ 146{
147public: 147public:
148 encodedString(); 148 encodedString();
149 /* 149 /*
150 creates an new content string. 150 creates an new content string.
151 it makes a deep copy of it! 151 it makes a deep copy of it!
152 */ 152 */
153 encodedString(const char*nContent,unsigned int length); 153 encodedString(const char*nContent,unsigned int length);
154 /* 154 /*
155 Take over the nContent. Means: it will just copy the pointer, not the content. 155 Take over the nContent. Means: it will just copy the pointer, not the content.
156 so make sure: No one else frees the string, the string has allocated with 156 so make sure: No one else frees the string, the string has allocated with
157 malloc for compatibility with c-based libs 157 malloc for compatibility with c-based libs
158 */ 158 */
159 encodedString(char*nContent,unsigned int nSize); 159 encodedString(char*nContent,unsigned int nSize);
160 /* copy construkor - makes ALWAYS a deep copy!!!! */ 160 /* copy construkor - makes ALWAYS a deep copy!!!! */
161 encodedString(const encodedString&old); 161 encodedString(const encodedString&old);
162 /* assign operator - makes ALWAYS a deep copy!!!! */ 162 /* assign operator - makes ALWAYS a deep copy!!!! */
163 encodedString& operator=(const encodedString&old); 163 encodedString& operator=(const encodedString&old);
164 /* destructor - cleans the content */ 164 /* destructor - cleans the content */
165 virtual ~encodedString(); 165 virtual ~encodedString();
166 166
167 /* returns a pointer to the content - do not delete yoursel! */ 167 /* returns a pointer to the content - do not delete yoursel! */
168 const char*Content()const; 168 const char*Content()const;
169 /* returns the lengths of the content 'cause it must not be a null-terminated string! */ 169 /* returns the lengths of the content 'cause it must not be a null-terminated string! */
170 const int Length()const; 170 const int Length()const;
171 171
172 /* 172 /*
173 makes a deep copy of nContent! 173 makes a deep copy of nContent!
174 */ 174 */
175 void setContent(const char*nContent,int nSize); 175 void setContent(const char*nContent,int nSize);
176 /* 176 /*
177 Take over the nContent. Means: it will just copy the pointer, not the content. 177 Take over the nContent. Means: it will just copy the pointer, not the content.
178 so make sure: No one else frees the string, the string has allocated with 178 so make sure: No one else frees the string, the string has allocated with
179 malloc for compatibility with c-based libs 179 malloc for compatibility with c-based libs
180 */ 180 */
181 void setContent(char*nContent,int nSize); 181 void setContent(char*nContent,int nSize);
182 182
183protected: 183protected:
184 char * content; 184 char * content;
185 unsigned int size; 185 unsigned int size;
186 186
187 void init(); 187 void init();
188 void copy_old(const encodedString&old); 188 void copy_old(const encodedString&old);
189 void clean(); 189 void clean();
190}; 190};
191 191
192struct folderStat 192struct folderStat
193{ 193{
194 unsigned int message_count; 194 unsigned int message_count;
195 unsigned int message_unseen; 195 unsigned int message_unseen;
196 unsigned int message_recent; 196 unsigned int message_recent;
197 folderStat&operator=(const folderStat&old); 197 folderStat&operator=(const folderStat&old);
198}; 198};
199 199
200#endif 200#endif
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.cpp b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
index 9bf2fd3..eddc0b9 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.cpp
@@ -1,178 +1,179 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h> 2#include <sys/stat.h>
3#include <sys/types.h> 3#include <sys/types.h>
4#include <unistd.h> 4#include <unistd.h>
5#include <fcntl.h> 5#include <fcntl.h>
6#include <string.h> 6#include <string.h>
7#include <qdir.h> 7#include <qdir.h>
8 8
9#include "mailwrapper.h" 9#include "mailwrapper.h"
10//#include "logindialog.h" 10//#include "logindialog.h"
11//#include "defines.h" 11//#include "defines.h"
12 12
13#define UNDEFINED 64 13#define UNDEFINED 64
14#define MAXLINE 76 14#define MAXLINE 76
15#define UTF16MASK 0x03FFUL 15#define UTF16MASK 0x03FFUL
16#define UTF16SHIFT 10 16#define UTF16SHIFT 10
17#define UTF16BASE 0x10000UL 17#define UTF16BASE 0x10000UL
18#define UTF16HIGHSTART 0xD800UL 18#define UTF16HIGHSTART 0xD800UL
19#define UTF16HIGHEND 0xDBFFUL 19#define UTF16HIGHEND 0xDBFFUL
20#define UTF16LOSTART 0xDC00UL 20#define UTF16LOSTART 0xDC00UL
21#define UTF16LOEND 0xDFFFUL 21#define UTF16LOEND 0xDFFFUL
22 22
23 23
24using namespace Opie::Core;
24Attachment::Attachment( DocLnk lnk ) 25Attachment::Attachment( DocLnk lnk )
25{ 26{
26 doc = lnk; 27 doc = lnk;
27 size = QFileInfo( doc.file() ).size(); 28 size = QFileInfo( doc.file() ).size();
28} 29}
29 30
30Folder::Folder(const QString&tmp_name, const QString&sep ) 31Folder::Folder(const QString&tmp_name, const QString&sep )
31{ 32{
32 name = tmp_name; 33 name = tmp_name;
33 nameDisplay = name; 34 nameDisplay = name;
34 separator = sep; 35 separator = sep;
35 prefix = ""; 36 prefix = "";
36} 37}
37 38
38Folder::~Folder() 39Folder::~Folder()
39{ 40{
40} 41}
41 42
42const QString& Folder::Separator()const 43const QString& Folder::Separator()const
43{ 44{
44 return separator; 45 return separator;
45} 46}
46 47
47IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix ) 48IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&aprefix )
48 : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf) 49 : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf)
49{ 50{
50 // Decode IMAP foldername 51 // Decode IMAP foldername
51 nameDisplay = IMAPFolder::decodeFolderName( name ); 52 nameDisplay = IMAPFolder::decodeFolderName( name );
52 /* 53 /*
53 qDebug( "folder " + name + " - displayed as " + nameDisplay ); 54 qDebug( "folder " + name + " - displayed as " + nameDisplay );
54 */ 55 */
55 prefix = aprefix; 56 prefix = aprefix;
56 57
57 if (prefix.length()>0) { 58 if (prefix.length()>0) {
58 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) { 59 if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
59 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length()); 60 nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
60 } 61 }
61 } 62 }
62} 63}
63 64
64IMAPFolder::~IMAPFolder() 65IMAPFolder::~IMAPFolder()
65{ 66{
66} 67}
67 68
68static unsigned char base64chars[] = 69static unsigned char base64chars[] =
69 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,"; 70 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
70 71
71/** 72/**
72 * Decodes base64 encoded parts of the imapfolder name 73 * Decodes base64 encoded parts of the imapfolder name
73 * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc 74 * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc
74 */ 75 */
75QString IMAPFolder::decodeFolderName( const QString &name ) 76QString IMAPFolder::decodeFolderName( const QString &name )
76{ 77{
77 unsigned char c, i, bitcount; 78 unsigned char c, i, bitcount;
78 unsigned long ucs4, utf16, bitbuf; 79 unsigned long ucs4, utf16, bitbuf;
79 unsigned char base64[256], utf8[6]; 80 unsigned char base64[256], utf8[6];
80 unsigned long srcPtr = 0; 81 unsigned long srcPtr = 0;
81 QCString dst = ""; 82 QCString dst = "";
82 QCString src = name.ascii(); 83 QCString src = name.ascii();
83 84
84 /* initialize modified base64 decoding table */ 85 /* initialize modified base64 decoding table */
85 memset(base64, UNDEFINED, sizeof(base64)); 86 memset(base64, UNDEFINED, sizeof(base64));
86 for (i = 0; i < sizeof(base64chars); ++i) { 87 for (i = 0; i < sizeof(base64chars); ++i) {
87 base64[(int)base64chars[i]] = i; 88 base64[(int)base64chars[i]] = i;
88 } 89 }
89 90
90 /* loop until end of string */ 91 /* loop until end of string */
91 while (srcPtr < src.length ()) { 92 while (srcPtr < src.length ()) {
92 c = src[srcPtr++]; 93 c = src[srcPtr++];
93 /* deal with literal characters and &- */ 94 /* deal with literal characters and &- */
94 if (c != '&' || src[srcPtr] == '-') { 95 if (c != '&' || src[srcPtr] == '-') {
95 /* encode literally */ 96 /* encode literally */
96 dst += c; 97 dst += c;
97 /* skip over the '-' if this is an &- sequence */ 98 /* skip over the '-' if this is an &- sequence */
98 if (c == '&') 99 if (c == '&')
99 srcPtr++; 100 srcPtr++;
100 } else { 101 } else {
101 /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */ 102 /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */
102 bitbuf = 0; 103 bitbuf = 0;
103 bitcount = 0; 104 bitcount = 0;
104 ucs4 = 0; 105 ucs4 = 0;
105 while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) { 106 while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) {
106 ++srcPtr; 107 ++srcPtr;
107 bitbuf = (bitbuf << 6) | c; 108 bitbuf = (bitbuf << 6) | c;
108 bitcount += 6; 109 bitcount += 6;
109 /* enough bits for a UTF-16 character? */ 110 /* enough bits for a UTF-16 character? */
110 if (bitcount >= 16) { 111 if (bitcount >= 16) {
111 bitcount -= 16; 112 bitcount -= 16;
112 utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff; 113 utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff;
113 /* convert UTF16 to UCS4 */ 114 /* convert UTF16 to UCS4 */
114 if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) { 115 if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) {
115 ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT; 116 ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT;
116 continue; 117 continue;
117 } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) { 118 } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) {
118 ucs4 += utf16 - UTF16LOSTART + UTF16BASE; 119 ucs4 += utf16 - UTF16LOSTART + UTF16BASE;
119 } else { 120 } else {
120 ucs4 = utf16; 121 ucs4 = utf16;
121 } 122 }
122 /* convert UTF-16 range of UCS4 to UTF-8 */ 123 /* convert UTF-16 range of UCS4 to UTF-8 */
123 if (ucs4 <= 0x7fUL) { 124 if (ucs4 <= 0x7fUL) {
124 utf8[0] = ucs4; 125 utf8[0] = ucs4;
125 i = 1; 126 i = 1;
126 } else if (ucs4 <= 0x7ffUL) { 127 } else if (ucs4 <= 0x7ffUL) {
127 utf8[0] = 0xc0 | (ucs4 >> 6); 128 utf8[0] = 0xc0 | (ucs4 >> 6);
128 utf8[1] = 0x80 | (ucs4 & 0x3f); 129 utf8[1] = 0x80 | (ucs4 & 0x3f);
129 i = 2; 130 i = 2;
130 } else if (ucs4 <= 0xffffUL) { 131 } else if (ucs4 <= 0xffffUL) {
131 utf8[0] = 0xe0 | (ucs4 >> 12); 132 utf8[0] = 0xe0 | (ucs4 >> 12);
132 utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f); 133 utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f);
133 utf8[2] = 0x80 | (ucs4 & 0x3f); 134 utf8[2] = 0x80 | (ucs4 & 0x3f);
134 i = 3; 135 i = 3;
135 } else { 136 } else {
136 utf8[0] = 0xf0 | (ucs4 >> 18); 137 utf8[0] = 0xf0 | (ucs4 >> 18);
137 utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f); 138 utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f);
138 utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f); 139 utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f);
139 utf8[3] = 0x80 | (ucs4 & 0x3f); 140 utf8[3] = 0x80 | (ucs4 & 0x3f);
140 i = 4; 141 i = 4;
141 } 142 }
142 /* copy it */ 143 /* copy it */
143 for (c = 0; c < i; ++c) { 144 for (c = 0; c < i; ++c) {
144 dst += utf8[c]; 145 dst += utf8[c];
145 } 146 }
146 } 147 }
147 } 148 }
148 /* skip over trailing '-' in modified UTF-7 encoding */ 149 /* skip over trailing '-' in modified UTF-7 encoding */
149 if (src[srcPtr] == '-') 150 if (src[srcPtr] == '-')
150 ++srcPtr; 151 ++srcPtr;
151 } 152 }
152 } 153 }
153 154
154 return QString::fromUtf8( dst.data() ); 155 return QString::fromUtf8( dst.data() );
155} 156}
156 157
157Mail::Mail() 158Mail::Mail()
158 :Opie::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("") 159 :Opie::Core::ORefCount(),name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("")
159{ 160{
160} 161}
161 162
162MHFolder::MHFolder(const QString&disp_name,const QString&mbox) 163MHFolder::MHFolder(const QString&disp_name,const QString&mbox)
163 : Folder( disp_name,"/" ) 164 : Folder( disp_name,"/" )
164{ 165{
165 separator = "/"; 166 separator = "/";
166 name = mbox; 167 name = mbox;
167 if (!disp_name.startsWith("/") && disp_name.length()>0) 168 if (!disp_name.startsWith("/") && disp_name.length()>0)
168 name+="/"; 169 name+="/";
169 name+=disp_name; 170 name+=disp_name;
170 if (disp_name.length()==0) { 171 if (disp_name.length()==0) {
171 nameDisplay = separator; 172 nameDisplay = separator;
172 } 173 }
173 prefix = mbox; 174 prefix = mbox;
174} 175}
175 176
176MHFolder::~MHFolder() 177MHFolder::~MHFolder()
177{ 178{
178} 179}
diff --git a/noncore/net/mail/libmailwrapper/mailwrapper.h b/noncore/net/mail/libmailwrapper/mailwrapper.h
index 6bf0078..542de03 100644
--- a/noncore/net/mail/libmailwrapper/mailwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mailwrapper.h
@@ -1,106 +1,106 @@
1#ifndef MAILWRAPPER_H 1#ifndef MAILWRAPPER_H
2#define MAILWRAPPER_H 2#define MAILWRAPPER_H
3 3
4#include <qpe/applnk.h> 4#include <qpe/applnk.h>
5 5
6#include <qbitarray.h> 6#include <qbitarray.h>
7#include <qdatetime.h> 7#include <qdatetime.h>
8 8
9#include "settings.h" 9#include "settings.h"
10 10
11#include <opie2/osmartpointer.h> 11#include <opie2/osmartpointer.h>
12 12
13class Attachment 13class Attachment
14{ 14{
15public: 15public:
16 Attachment( DocLnk lnk ); 16 Attachment( DocLnk lnk );
17 virtual ~Attachment(){} 17 virtual ~Attachment(){}
18 const QString getFileName()const{ return doc.file(); } 18 const QString getFileName()const{ return doc.file(); }
19 const QString getName()const{ return doc.name(); } 19 const QString getName()const{ return doc.name(); }
20 const QString getMimeType()const{ return doc.type(); } 20 const QString getMimeType()const{ return doc.type(); }
21 const QPixmap getPixmap()const{ return doc.pixmap(); } 21 const QPixmap getPixmap()const{ return doc.pixmap(); }
22 const int getSize()const { return size; } 22 const int getSize()const { return size; }
23 DocLnk getDocLnk() { return doc; } 23 DocLnk getDocLnk() { return doc; }
24 24
25protected: 25protected:
26 DocLnk doc; 26 DocLnk doc;
27 int size; 27 int size;
28 28
29}; 29};
30 30
31class Mail:public Opie::ORefCount 31class Mail:public Opie::Core::ORefCount
32{ 32{
33public: 33public:
34 Mail(); 34 Mail();
35 /* Possible that this destructor must not be declared virtual 35 /* Possible that this destructor must not be declared virtual
36 * 'cause it seems that it will never have some child classes. 36 * 'cause it seems that it will never have some child classes.
37 * in this case this object will not get a virtual table -> memory and 37 * in this case this object will not get a virtual table -> memory and
38 * speed will be a little bit better? 38 * speed will be a little bit better?
39 */ 39 */
40 virtual ~Mail(){} 40 virtual ~Mail(){}
41 void addAttachment( Attachment *att ) { attList.append( att ); } 41 void addAttachment( Attachment *att ) { attList.append( att ); }
42 const QList<Attachment>& getAttachments()const { return attList; } 42 const QList<Attachment>& getAttachments()const { return attList; }
43 void removeAttachment( Attachment *att ) { attList.remove( att ); } 43 void removeAttachment( Attachment *att ) { attList.remove( att ); }
44 const QString&getName()const { return name; } 44 const QString&getName()const { return name; }
45 void setName( QString s ) { name = s; } 45 void setName( QString s ) { name = s; }
46 const QString&getMail()const{ return mail; } 46 const QString&getMail()const{ return mail; }
47 void setMail( const QString&s ) { mail = s; } 47 void setMail( const QString&s ) { mail = s; }
48 const QString&getTo()const{ return to; } 48 const QString&getTo()const{ return to; }
49 void setTo( const QString&s ) { to = s; } 49 void setTo( const QString&s ) { to = s; }
50 const QString&getCC()const{ return cc; } 50 const QString&getCC()const{ return cc; }
51 void setCC( const QString&s ) { cc = s; } 51 void setCC( const QString&s ) { cc = s; }
52 const QString&getBCC()const { return bcc; } 52 const QString&getBCC()const { return bcc; }
53 void setBCC( const QString&s ) { bcc = s; } 53 void setBCC( const QString&s ) { bcc = s; }
54 const QString&getMessage()const { return message; } 54 const QString&getMessage()const { return message; }
55 void setMessage( const QString&s ) { message = s; } 55 void setMessage( const QString&s ) { message = s; }
56 const QString&getSubject()const { return subject; } 56 const QString&getSubject()const { return subject; }
57 void setSubject( const QString&s ) { subject = s; } 57 void setSubject( const QString&s ) { subject = s; }
58 const QString&getReply()const{ return reply; } 58 const QString&getReply()const{ return reply; }
59 void setReply( const QString&a ) { reply = a; } 59 void setReply( const QString&a ) { reply = a; }
60 void setInreply(const QStringList&list){m_in_reply_to = list;} 60 void setInreply(const QStringList&list){m_in_reply_to = list;}
61 const QStringList&Inreply()const{return m_in_reply_to;} 61 const QStringList&Inreply()const{return m_in_reply_to;}
62 62
63private: 63private:
64 QList<Attachment> attList; 64 QList<Attachment> attList;
65 QString name, mail, to, cc, bcc, reply, subject, message; 65 QString name, mail, to, cc, bcc, reply, subject, message;
66 QStringList m_in_reply_to; 66 QStringList m_in_reply_to;
67}; 67};
68 68
69class Folder:public Opie::ORefCount 69class Folder:public Opie::Core::ORefCount
70{ 70{
71public: 71public:
72 Folder( const QString&init_name,const QString&sep ); 72 Folder( const QString&init_name,const QString&sep );
73 virtual ~Folder(); 73 virtual ~Folder();
74 const QString&getDisplayName()const { return nameDisplay; } 74 const QString&getDisplayName()const { return nameDisplay; }
75 const QString&getName()const { return name; } 75 const QString&getName()const { return name; }
76 const QString&getPrefix()const{return prefix; } 76 const QString&getPrefix()const{return prefix; }
77 virtual bool may_select()const{return true;} 77 virtual bool may_select()const{return true;}
78 virtual bool no_inferior()const{return true;} 78 virtual bool no_inferior()const{return true;}
79 const QString&Separator()const; 79 const QString&Separator()const;
80 80
81protected: 81protected:
82 QString nameDisplay, name, separator,prefix; 82 QString nameDisplay, name, separator,prefix;
83}; 83};
84 84
85typedef Opie::OSmartPointer<Folder> FolderP; 85typedef Opie::Core::OSmartPointer<Folder> FolderP;
86 86
87class MHFolder : public Folder 87class MHFolder : public Folder
88{ 88{
89public: 89public:
90 MHFolder(const QString&disp_name,const QString&mbox); 90 MHFolder(const QString&disp_name,const QString&mbox);
91 virtual ~MHFolder(); 91 virtual ~MHFolder();
92}; 92};
93 93
94class IMAPFolder : public Folder 94class IMAPFolder : public Folder
95{ 95{
96 public: 96 public:
97 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" ); 97 IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
98 virtual ~IMAPFolder(); 98 virtual ~IMAPFolder();
99 virtual bool may_select()const{return m_MaySelect;} 99 virtual bool may_select()const{return m_MaySelect;}
100 virtual bool no_inferior()const{return m_NoInferior;} 100 virtual bool no_inferior()const{return m_NoInferior;}
101 private: 101 private:
102 static QString decodeFolderName( const QString &name ); 102 static QString decodeFolderName( const QString &name );
103 bool m_MaySelect,m_NoInferior; 103 bool m_MaySelect,m_NoInferior;
104}; 104};
105 105
106#endif 106#endif
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
index 5e6b714..4aee0be 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.cpp
@@ -1,241 +1,242 @@
1#include "mboxwrapper.h" 1#include "mboxwrapper.h"
2#include "mailtypes.h" 2#include "mailtypes.h"
3#include "mailwrapper.h" 3#include "mailwrapper.h"
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#include <qpe/global.h> 7#include <qpe/global.h>
8 8
9using namespace Opie::Core;
9MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name) 10MBOXwrapper::MBOXwrapper(const QString & mbox_dir,const QString&mbox_name)
10 : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name) 11 : Genericwrapper(),MBOXPath(mbox_dir),MBOXName(mbox_name)
11{ 12{
12 QDir dir(MBOXPath); 13 QDir dir(MBOXPath);
13 if (!dir.exists()) { 14 if (!dir.exists()) {
14 dir.mkdir(MBOXPath); 15 dir.mkdir(MBOXPath);
15 } 16 }
16} 17}
17 18
18MBOXwrapper::~MBOXwrapper() 19MBOXwrapper::~MBOXwrapper()
19{ 20{
20} 21}
21 22
22void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target ) 23void MBOXwrapper::listMessages(const QString & mailbox, QValueList<RecMailP> &target )
23{ 24{
24 mailstorage*storage = mailstorage_new(NULL); 25 mailstorage*storage = mailstorage_new(NULL);
25 QString p = MBOXPath+"/"; 26 QString p = MBOXPath+"/";
26 p+=mailbox; 27 p+=mailbox;
27 28
28 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 29 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
29 mailfolder*folder; 30 mailfolder*folder;
30 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 31 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
31 r = mailfolder_connect(folder); 32 r = mailfolder_connect(folder);
32 if (r != MAIL_NO_ERROR) { 33 if (r != MAIL_NO_ERROR) {
33 qDebug("Error initializing mbox"); 34 qDebug("Error initializing mbox");
34 mailfolder_free(folder); 35 mailfolder_free(folder);
35 mailstorage_free(storage); 36 mailstorage_free(storage);
36 return; 37 return;
37 } 38 }
38 39
39 parseList(target,folder->fld_session,mailbox); 40 parseList(target,folder->fld_session,mailbox);
40 41
41 mailfolder_disconnect(folder); 42 mailfolder_disconnect(folder);
42 mailfolder_free(folder); 43 mailfolder_free(folder);
43 mailstorage_free(storage); 44 mailstorage_free(storage);
44 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 45 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
45} 46}
46 47
47QValueList<Opie::OSmartPointer<Folder> >* MBOXwrapper::listFolders() 48QValueList<Opie::Core::OSmartPointer<Folder> >* MBOXwrapper::listFolders()
48{ 49{
49 QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); 50 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
50 QDir dir(MBOXPath); 51 QDir dir(MBOXPath);
51 if (!dir.exists()) return folders; 52 if (!dir.exists()) return folders;
52 dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable); 53 dir.setFilter(QDir::Files|QDir::Writable|QDir::Readable);
53 QStringList entries = dir.entryList(); 54 QStringList entries = dir.entryList();
54 QStringList::ConstIterator it = entries.begin(); 55 QStringList::ConstIterator it = entries.begin();
55 for (;it!=entries.end();++it) { 56 for (;it!=entries.end();++it) {
56 FolderP inb=new Folder(*it,"/"); 57 FolderP inb=new Folder(*it,"/");
57 folders->append(inb); 58 folders->append(inb);
58 } 59 }
59 return folders; 60 return folders;
60} 61}
61 62
62void MBOXwrapper::deleteMail(const RecMailP & mail) 63void MBOXwrapper::deleteMail(const RecMailP & mail)
63{ 64{
64 mailstorage*storage = mailstorage_new(NULL); 65 mailstorage*storage = mailstorage_new(NULL);
65 QString p = MBOXPath+"/"; 66 QString p = MBOXPath+"/";
66 p+=mail->getMbox(); 67 p+=mail->getMbox();
67 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 68 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
68 mailfolder*folder; 69 mailfolder*folder;
69 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 70 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
70 r = mailfolder_connect(folder); 71 r = mailfolder_connect(folder);
71 if (r != MAIL_NO_ERROR) { 72 if (r != MAIL_NO_ERROR) {
72 qDebug("Error initializing mbox"); 73 qDebug("Error initializing mbox");
73 mailfolder_free(folder); 74 mailfolder_free(folder);
74 mailstorage_free(storage); 75 mailstorage_free(storage);
75 return; 76 return;
76 } 77 }
77 r = mailsession_remove_message(folder->fld_session,mail->getNumber()); 78 r = mailsession_remove_message(folder->fld_session,mail->getNumber());
78 if (r != MAIL_NO_ERROR) { 79 if (r != MAIL_NO_ERROR) {
79 qDebug("error deleting mail"); 80 qDebug("error deleting mail");
80 } 81 }
81 mailfolder_free(folder); 82 mailfolder_free(folder);
82 mailstorage_free(storage); 83 mailstorage_free(storage);
83} 84}
84 85
85void MBOXwrapper::answeredMail(const RecMailP&) 86void MBOXwrapper::answeredMail(const RecMailP&)
86{ 87{
87} 88}
88 89
89RecBody MBOXwrapper::fetchBody( const RecMailP &mail ) 90RecBody MBOXwrapper::fetchBody( const RecMailP &mail )
90{ 91{
91 RecBody body; 92 RecBody body;
92 mailstorage*storage = mailstorage_new(NULL); 93 mailstorage*storage = mailstorage_new(NULL);
93 QString p = MBOXPath+"/"; 94 QString p = MBOXPath+"/";
94 p+=mail->getMbox(); 95 p+=mail->getMbox();
95 mailmessage * msg; 96 mailmessage * msg;
96 char*data=0; 97 char*data=0;
97 size_t size; 98 size_t size;
98 99
99 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 100 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
100 mailfolder*folder; 101 mailfolder*folder;
101 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 102 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
102 r = mailfolder_connect(folder); 103 r = mailfolder_connect(folder);
103 if (r != MAIL_NO_ERROR) { 104 if (r != MAIL_NO_ERROR) {
104 qDebug("Error initializing mbox"); 105 qDebug("Error initializing mbox");
105 mailfolder_free(folder); 106 mailfolder_free(folder);
106 mailstorage_free(storage); 107 mailstorage_free(storage);
107 return body; 108 return body;
108 } 109 }
109 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); 110 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg);
110 if (r != MAIL_NO_ERROR) { 111 if (r != MAIL_NO_ERROR) {
111 qDebug("Error fetching mail %i",mail->getNumber()); 112 qDebug("Error fetching mail %i",mail->getNumber());
112 mailfolder_free(folder); 113 mailfolder_free(folder);
113 mailstorage_free(storage); 114 mailstorage_free(storage);
114 return body; 115 return body;
115 } 116 }
116 r = mailmessage_fetch(msg,&data,&size); 117 r = mailmessage_fetch(msg,&data,&size);
117 if (r != MAIL_NO_ERROR) { 118 if (r != MAIL_NO_ERROR) {
118 qDebug("Error fetching mail %i",mail->getNumber()); 119 qDebug("Error fetching mail %i",mail->getNumber());
119 mailfolder_free(folder); 120 mailfolder_free(folder);
120 mailstorage_free(storage); 121 mailstorage_free(storage);
121 mailmessage_free(msg); 122 mailmessage_free(msg);
122 return body; 123 return body;
123 } 124 }
124 body = parseMail(msg); 125 body = parseMail(msg);
125 mailmessage_fetch_result_free(msg,data); 126 mailmessage_fetch_result_free(msg,data);
126 mailfolder_free(folder); 127 mailfolder_free(folder);
127 mailstorage_free(storage); 128 mailstorage_free(storage);
128 129
129 return body; 130 return body;
130} 131}
131 132
132void MBOXwrapper::mbox_progress( size_t current, size_t maximum ) 133void MBOXwrapper::mbox_progress( size_t current, size_t maximum )
133{ 134{
134 qDebug("MBOX %i von %i",current,maximum); 135 qDebug("MBOX %i von %i",current,maximum);
135} 136}
136 137
137int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool ) 138int MBOXwrapper::createMbox(const QString&folder,const FolderP&,const QString&,bool )
138{ 139{
139 QString p = MBOXPath+"/"; 140 QString p = MBOXPath+"/";
140 p+=folder; 141 p+=folder;
141 QFileInfo fi(p); 142 QFileInfo fi(p);
142 if (fi.exists()) { 143 if (fi.exists()) {
143 Global::statusMessage(tr("Mailbox exists.")); 144 Global::statusMessage(tr("Mailbox exists."));
144 return 0; 145 return 0;
145 } 146 }
146 mailmbox_folder*f = 0; 147 mailmbox_folder*f = 0;
147 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) { 148 if (mailmbox_init(p.latin1(),0,1,0,&f) != MAIL_NO_ERROR) {
148 Global::statusMessage(tr("Error init folder")); 149 Global::statusMessage(tr("Error init folder"));
149 return 0; 150 return 0;
150 } 151 }
151 if (f) mailmbox_done(f); 152 if (f) mailmbox_done(f);
152 return 1; 153 return 1;
153} 154}
154 155
155void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder) 156void MBOXwrapper::storeMessage(const char*msg,size_t length, const QString&folder)
156{ 157{
157 QString p = MBOXPath+"/"; 158 QString p = MBOXPath+"/";
158 p+=folder; 159 p+=folder;
159 mailmbox_folder*f = 0; 160 mailmbox_folder*f = 0;
160 int r = mailmbox_init(p.latin1(),0,1,0,&f); 161 int r = mailmbox_init(p.latin1(),0,1,0,&f);
161 if (r != MAIL_NO_ERROR) { 162 if (r != MAIL_NO_ERROR) {
162 Global::statusMessage(tr("Error init folder")); 163 Global::statusMessage(tr("Error init folder"));
163 return; 164 return;
164 } 165 }
165 r = mailmbox_append_message(f,msg,length); 166 r = mailmbox_append_message(f,msg,length);
166 if (r != MAIL_NO_ERROR) { 167 if (r != MAIL_NO_ERROR) {
167 Global::statusMessage(tr("Error writing to message folder")); 168 Global::statusMessage(tr("Error writing to message folder"));
168 } 169 }
169 mailmbox_done(f); 170 mailmbox_done(f);
170} 171}
171 172
172encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail) 173encodedString* MBOXwrapper::fetchRawBody(const RecMailP&mail)
173{ 174{
174 RecBody body; 175 RecBody body;
175 mailstorage*storage = mailstorage_new(NULL); 176 mailstorage*storage = mailstorage_new(NULL);
176 QString p = MBOXPath+"/"; 177 QString p = MBOXPath+"/";
177 p+=mail->getMbox(); 178 p+=mail->getMbox();
178 mailmessage * msg; 179 mailmessage * msg;
179 char*data=0; 180 char*data=0;
180 size_t size; 181 size_t size;
181 182
182 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0); 183 int r = mbox_mailstorage_init(storage,(char*)p.latin1(),0,0,0);
183 mailfolder*folder; 184 mailfolder*folder;
184 folder = mailfolder_new( storage,(char*)p.latin1(),NULL); 185 folder = mailfolder_new( storage,(char*)p.latin1(),NULL);
185 r = mailfolder_connect(folder); 186 r = mailfolder_connect(folder);
186 if (r != MAIL_NO_ERROR) { 187 if (r != MAIL_NO_ERROR) {
187 Global::statusMessage(tr("Error initializing mbox")); 188 Global::statusMessage(tr("Error initializing mbox"));
188 mailfolder_free(folder); 189 mailfolder_free(folder);
189 mailstorage_free(storage); 190 mailstorage_free(storage);
190 return 0; 191 return 0;
191 } 192 }
192 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg); 193 r = mailsession_get_message(folder->fld_session, mail->getNumber(), &msg);
193 if (r != MAIL_NO_ERROR) { 194 if (r != MAIL_NO_ERROR) {
194 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); 195 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
195 mailfolder_free(folder); 196 mailfolder_free(folder);
196 mailstorage_free(storage); 197 mailstorage_free(storage);
197 return 0; 198 return 0;
198 } 199 }
199 r = mailmessage_fetch(msg,&data,&size); 200 r = mailmessage_fetch(msg,&data,&size);
200 if (r != MAIL_NO_ERROR) { 201 if (r != MAIL_NO_ERROR) {
201 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); 202 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
202 mailfolder_free(folder); 203 mailfolder_free(folder);
203 mailstorage_free(storage); 204 mailstorage_free(storage);
204 mailmessage_free(msg); 205 mailmessage_free(msg);
205 return 0; 206 return 0;
206 } 207 }
207 encodedString*result = new encodedString(data,size); 208 encodedString*result = new encodedString(data,size);
208 209
209 mailfolder_free(folder); 210 mailfolder_free(folder);
210 mailstorage_free(storage); 211 mailstorage_free(storage);
211 mailmessage_free(msg); 212 mailmessage_free(msg);
212 return result; 213 return result;
213} 214}
214 215
215void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) 216void MBOXwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target)
216{ 217{
217 QString p = MBOXPath+"/"; 218 QString p = MBOXPath+"/";
218 p+=mailbox; 219 p+=mailbox;
219 mailmbox_folder*f = 0; 220 mailmbox_folder*f = 0;
220 int r = mailmbox_init(p.latin1(),0,1,0,&f); 221 int r = mailmbox_init(p.latin1(),0,1,0,&f);
221 if (r != MAIL_NO_ERROR) { 222 if (r != MAIL_NO_ERROR) {
222 qDebug("Error init folder"); 223 qDebug("Error init folder");
223 return; 224 return;
224 } 225 }
225 deleteMails(f,target); 226 deleteMails(f,target);
226 mailmbox_done(f); 227 mailmbox_done(f);
227} 228}
228 229
229void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target) 230void MBOXwrapper::deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target)
230{ 231{
231 if (!f) return; 232 if (!f) return;
232 int r; 233 int r;
233 QValueList<RecMailP>::ConstIterator it; 234 QValueList<RecMailP>::ConstIterator it;
234 for (it=target.begin(); it != target.end();++it) { 235 for (it=target.begin(); it != target.end();++it) {
235 r = mailmbox_delete_msg(f,(*it)->getNumber()); 236 r = mailmbox_delete_msg(f,(*it)->getNumber());
236 if (r!=MAILMBOX_NO_ERROR) { 237 if (r!=MAILMBOX_NO_ERROR) {
237 qDebug("error delete mail"); 238 qDebug("error delete mail");
238 } 239 }
239 } 240 }
240 r = mailmbox_expunge(f); 241 r = mailmbox_expunge(f);
241 if (r != MAILMBOX_NO_ERROR) { 242 if (r != MAILMBOX_NO_ERROR) {
diff --git a/noncore/net/mail/libmailwrapper/mboxwrapper.h b/noncore/net/mail/libmailwrapper/mboxwrapper.h
index 33eeb1e..a2ecfee 100644
--- a/noncore/net/mail/libmailwrapper/mboxwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mboxwrapper.h
@@ -1,46 +1,46 @@
1#ifndef __MBOX_WRAPPER_H 1#ifndef __MBOX_WRAPPER_H
2#define __MBOX_WRAPPER_H 2#define __MBOX_WRAPPER_H
3 3
4#include "genericwrapper.h" 4#include "genericwrapper.h"
5#include <qstring.h> 5#include <qstring.h>
6 6
7class encodedString; 7class encodedString;
8struct mailmbox_folder; 8struct mailmbox_folder;
9 9
10class MBOXwrapper : public Genericwrapper 10class MBOXwrapper : public Genericwrapper
11{ 11{
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 MBOXwrapper(const QString & dir,const QString&name); 15 MBOXwrapper(const QString & dir,const QString&name);
16 virtual ~MBOXwrapper(); 16 virtual ~MBOXwrapper();
17 17
18 virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target ); 18 virtual void listMessages(const QString & mailbox, QValueList<RecMailP>&target );
19 virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); 19 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
20 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 20 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
21 21
22 virtual void deleteMail(const RecMailP&mail); 22 virtual void deleteMail(const RecMailP&mail);
23 virtual void answeredMail(const RecMailP&mail); 23 virtual void answeredMail(const RecMailP&mail);
24 24
25 virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0, 25 virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
26 const QString&d="",bool s=false); 26 const QString&d="",bool s=false);
27 virtual int deleteMbox(const Opie::OSmartPointer<Folder>&); 27 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
28 28
29 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 29 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
30 30
31 virtual RecBody fetchBody( const RecMailP &mail ); 31 virtual RecBody fetchBody( const RecMailP &mail );
32 static void mbox_progress( size_t current, size_t maximum ); 32 static void mbox_progress( size_t current, size_t maximum );
33 33
34 virtual encodedString* fetchRawBody(const RecMailP&mail); 34 virtual encodedString* fetchRawBody(const RecMailP&mail);
35 virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target); 35 virtual void deleteMails(const QString & FolderName,const QValueList<RecMailP> &target);
36 virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); 36 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
37 virtual MAILLIB::ATYPE getType()const; 37 virtual MAILLIB::ATYPE getType()const;
38 virtual const QString&getName()const; 38 virtual const QString&getName()const;
39 39
40protected: 40protected:
41 static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target); 41 static void deleteMails(mailmbox_folder*f,const QValueList<RecMailP> &target);
42 QString MBOXPath; 42 QString MBOXPath;
43 QString MBOXName; 43 QString MBOXName;
44}; 44};
45 45
46#endif 46#endif
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
index 0b00a2e..21e24a0 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp
@@ -1,441 +1,444 @@
1#include "mhwrapper.h" 1#include "mhwrapper.h"
2#include "mailtypes.h" 2#include "mailtypes.h"
3#include "mailwrapper.h" 3#include "mailwrapper.h"
4#include <libetpan/libetpan.h> 4#include <libetpan/libetpan.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <qmessagebox.h> 6#include <qmessagebox.h>
7#include <stdlib.h> 7#include <stdlib.h>
8#include <qpe/global.h> 8#include <qpe/global.h>
9#include <opie2/oprocess.h> 9#include <opie2/oprocess.h>
10 10
11using namespace Opie::Core;
12using namespace Opie::Core;
13using namespace Opie::Core;
11MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) 14MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name)
12 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) 15 : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name)
13{ 16{
14 if (MHPath.length()>0) { 17 if (MHPath.length()>0) {
15 if (MHPath[MHPath.length()-1]=='/') { 18 if (MHPath[MHPath.length()-1]=='/') {
16 MHPath=MHPath.left(MHPath.length()-1); 19 MHPath=MHPath.left(MHPath.length()-1);
17 } 20 }
18 qDebug(MHPath); 21 qDebug(MHPath);
19 QDir dir(MHPath); 22 QDir dir(MHPath);
20 if (!dir.exists()) { 23 if (!dir.exists()) {
21 dir.mkdir(MHPath); 24 dir.mkdir(MHPath);
22 } 25 }
23 init_storage(); 26 init_storage();
24 } 27 }
25} 28}
26 29
27void MHwrapper::init_storage() 30void MHwrapper::init_storage()
28{ 31{
29 int r; 32 int r;
30 QString pre = MHPath; 33 QString pre = MHPath;
31 if (!m_storage) { 34 if (!m_storage) {
32 m_storage = mailstorage_new(NULL); 35 m_storage = mailstorage_new(NULL);
33 r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); 36 r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0);
34 if (r != MAIL_NO_ERROR) { 37 if (r != MAIL_NO_ERROR) {
35 qDebug("error initializing storage"); 38 qDebug("error initializing storage");
36 mailstorage_free(m_storage); 39 mailstorage_free(m_storage);
37 m_storage = 0; 40 m_storage = 0;
38 return; 41 return;
39 } 42 }
40 } 43 }
41 r = mailstorage_connect(m_storage); 44 r = mailstorage_connect(m_storage);
42 if (r!=MAIL_NO_ERROR) { 45 if (r!=MAIL_NO_ERROR) {
43 qDebug("error connecting storage"); 46 qDebug("error connecting storage");
44 mailstorage_free(m_storage); 47 mailstorage_free(m_storage);
45 m_storage = 0; 48 m_storage = 0;
46 } 49 }
47} 50}
48 51
49void MHwrapper::clean_storage() 52void MHwrapper::clean_storage()
50{ 53{
51 if (m_storage) { 54 if (m_storage) {
52 mailstorage_disconnect(m_storage); 55 mailstorage_disconnect(m_storage);
53 mailstorage_free(m_storage); 56 mailstorage_free(m_storage);
54 m_storage = 0; 57 m_storage = 0;
55 } 58 }
56} 59}
57 60
58MHwrapper::~MHwrapper() 61MHwrapper::~MHwrapper()
59{ 62{
60 clean_storage(); 63 clean_storage();
61} 64}
62 65
63void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ) 66void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
64{ 67{
65 init_storage(); 68 init_storage();
66 if (!m_storage) { 69 if (!m_storage) {
67 return; 70 return;
68 } 71 }
69 QString f = buildPath(mailbox); 72 QString f = buildPath(mailbox);
70 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 73 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
71 if (r!=MAIL_NO_ERROR) { 74 if (r!=MAIL_NO_ERROR) {
72 qDebug("listMessages: error selecting folder!"); 75 qDebug("listMessages: error selecting folder!");
73 return; 76 return;
74 } 77 }
75 parseList(target,m_storage->sto_session,f); 78 parseList(target,m_storage->sto_session,f);
76 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); 79 Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count()));
77} 80}
78 81
79QValueList<Opie::OSmartPointer<Folder> >* MHwrapper::listFolders() 82QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders()
80{ 83{
81 QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); 84 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
82 /* this is needed! */ 85 /* this is needed! */
83 if (m_storage) mailstorage_disconnect(m_storage); 86 if (m_storage) mailstorage_disconnect(m_storage);
84 init_storage(); 87 init_storage();
85 if (!m_storage) { 88 if (!m_storage) {
86 return folders; 89 return folders;
87 } 90 }
88 mail_list*flist = 0; 91 mail_list*flist = 0;
89 clistcell*current=0; 92 clistcell*current=0;
90 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); 93 int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist);
91 if (r != MAIL_NO_ERROR || !flist) { 94 if (r != MAIL_NO_ERROR || !flist) {
92 qDebug("error getting folder list"); 95 qDebug("error getting folder list");
93 return folders; 96 return folders;
94 } 97 }
95 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { 98 for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) {
96 QString t = (char*)current->data; 99 QString t = (char*)current->data;
97 t.replace(0,MHPath.length(),""); 100 t.replace(0,MHPath.length(),"");
98 folders->append(new MHFolder(t,MHPath)); 101 folders->append(new MHFolder(t,MHPath));
99 } 102 }
100 mail_list_free(flist); 103 mail_list_free(flist);
101 return folders; 104 return folders;
102} 105}
103 106
104void MHwrapper::deleteMail(const RecMailP&mail) 107void MHwrapper::deleteMail(const RecMailP&mail)
105{ 108{
106 init_storage(); 109 init_storage();
107 if (!m_storage) { 110 if (!m_storage) {
108 return; 111 return;
109 } 112 }
110 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 113 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
111 if (r!=MAIL_NO_ERROR) { 114 if (r!=MAIL_NO_ERROR) {
112 qDebug("error selecting folder!"); 115 qDebug("error selecting folder!");
113 return; 116 return;
114 } 117 }
115 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); 118 r = mailsession_remove_message(m_storage->sto_session,mail->getNumber());
116 if (r != MAIL_NO_ERROR) { 119 if (r != MAIL_NO_ERROR) {
117 qDebug("error deleting mail"); 120 qDebug("error deleting mail");
118 } 121 }
119} 122}
120 123
121void MHwrapper::answeredMail(const RecMailP&) 124void MHwrapper::answeredMail(const RecMailP&)
122{ 125{
123} 126}
124 127
125RecBody MHwrapper::fetchBody( const RecMailP &mail ) 128RecBody MHwrapper::fetchBody( const RecMailP &mail )
126{ 129{
127 RecBody body; 130 RecBody body;
128 init_storage(); 131 init_storage();
129 if (!m_storage) { 132 if (!m_storage) {
130 return body; 133 return body;
131 } 134 }
132 mailmessage * msg; 135 mailmessage * msg;
133 char*data=0; 136 char*data=0;
134 137
135 /* mail should hold the complete path! */ 138 /* mail should hold the complete path! */
136 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 139 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
137 if (r != MAIL_NO_ERROR) { 140 if (r != MAIL_NO_ERROR) {
138 return body; 141 return body;
139 } 142 }
140 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 143 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
141 if (r != MAIL_NO_ERROR) { 144 if (r != MAIL_NO_ERROR) {
142 qDebug("Error fetching mail %i",mail->getNumber()); 145 qDebug("Error fetching mail %i",mail->getNumber());
143 return body; 146 return body;
144 } 147 }
145 body = parseMail(msg); 148 body = parseMail(msg);
146 mailmessage_fetch_result_free(msg,data); 149 mailmessage_fetch_result_free(msg,data);
147 return body; 150 return body;
148} 151}
149 152
150void MHwrapper::mbox_progress( size_t current, size_t maximum ) 153void MHwrapper::mbox_progress( size_t current, size_t maximum )
151{ 154{
152 qDebug("MH %i von %i",current,maximum); 155 qDebug("MH %i von %i",current,maximum);
153} 156}
154 157
155QString MHwrapper::buildPath(const QString&p) 158QString MHwrapper::buildPath(const QString&p)
156{ 159{
157 QString f=""; 160 QString f="";
158 if (p.length()==0||p=="/") 161 if (p.length()==0||p=="/")
159 return MHPath; 162 return MHPath;
160 if (!p.startsWith(MHPath)) { 163 if (!p.startsWith(MHPath)) {
161 f+=MHPath; 164 f+=MHPath;
162 } 165 }
163 if (!p.startsWith("/")) { 166 if (!p.startsWith("/")) {
164 f+="/"; 167 f+="/";
165 } 168 }
166 f+=p; 169 f+=p;
167 return f; 170 return f;
168} 171}
169 172
170int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) 173int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool )
171{ 174{
172 init_storage(); 175 init_storage();
173 if (!m_storage) { 176 if (!m_storage) {
174 return 0; 177 return 0;
175 } 178 }
176 QString f; 179 QString f;
177 if (!pfolder) { 180 if (!pfolder) {
178 // toplevel folder 181 // toplevel folder
179 f = buildPath(folder); 182 f = buildPath(folder);
180 } else { 183 } else {
181 f = pfolder->getName(); 184 f = pfolder->getName();
182 f+="/"; 185 f+="/";
183 f+=folder; 186 f+=folder;
184 } 187 }
185 qDebug(f); 188 qDebug(f);
186 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); 189 int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1());
187 if (r != MAIL_NO_ERROR) { 190 if (r != MAIL_NO_ERROR) {
188 qDebug("error creating folder %i",r); 191 qDebug("error creating folder %i",r);
189 return 0; 192 return 0;
190 } 193 }
191 qDebug("Folder created"); 194 qDebug("Folder created");
192 return 1; 195 return 1;
193} 196}
194 197
195void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) 198void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder)
196{ 199{
197 init_storage(); 200 init_storage();
198 if (!m_storage) { 201 if (!m_storage) {
199 return; 202 return;
200 } 203 }
201 QString f = buildPath(Folder); 204 QString f = buildPath(Folder);
202 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 205 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
203 if (r!=MAIL_NO_ERROR) { 206 if (r!=MAIL_NO_ERROR) {
204 qDebug("error selecting folder!"); 207 qDebug("error selecting folder!");
205 return; 208 return;
206 } 209 }
207 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); 210 r = mailsession_append_message(m_storage->sto_session,(char*)msg,length);
208 if (r!=MAIL_NO_ERROR) { 211 if (r!=MAIL_NO_ERROR) {
209 qDebug("error storing mail"); 212 qDebug("error storing mail");
210 } 213 }
211 return; 214 return;
212} 215}
213 216
214encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) 217encodedString* MHwrapper::fetchRawBody(const RecMailP&mail)
215{ 218{
216 encodedString*result = 0; 219 encodedString*result = 0;
217 init_storage(); 220 init_storage();
218 if (!m_storage) { 221 if (!m_storage) {
219 return result; 222 return result;
220 } 223 }
221 mailmessage * msg = 0; 224 mailmessage * msg = 0;
222 char*data=0; 225 char*data=0;
223 size_t size; 226 size_t size;
224 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 227 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
225 if (r!=MAIL_NO_ERROR) { 228 if (r!=MAIL_NO_ERROR) {
226 qDebug("error selecting folder!"); 229 qDebug("error selecting folder!");
227 return result; 230 return result;
228 } 231 }
229 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); 232 r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg);
230 if (r != MAIL_NO_ERROR) { 233 if (r != MAIL_NO_ERROR) {
231 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); 234 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
232 return 0; 235 return 0;
233 } 236 }
234 r = mailmessage_fetch(msg,&data,&size); 237 r = mailmessage_fetch(msg,&data,&size);
235 if (r != MAIL_NO_ERROR) { 238 if (r != MAIL_NO_ERROR) {
236 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); 239 Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber()));
237 if (msg) mailmessage_free(msg); 240 if (msg) mailmessage_free(msg);
238 return 0; 241 return 0;
239 } 242 }
240 result = new encodedString(data,size); 243 result = new encodedString(data,size);
241 if (msg) mailmessage_free(msg); 244 if (msg) mailmessage_free(msg);
242 return result; 245 return result;
243} 246}
244 247
245void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) 248void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target)
246{ 249{
247 QString f = buildPath(mailbox); 250 QString f = buildPath(mailbox);
248 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); 251 int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1());
249 if (r!=MAIL_NO_ERROR) { 252 if (r!=MAIL_NO_ERROR) {
250 qDebug("deleteMails: error selecting folder!"); 253 qDebug("deleteMails: error selecting folder!");
251 return; 254 return;
252 } 255 }
253 QValueList<RecMailP>::ConstIterator it; 256 QValueList<RecMailP>::ConstIterator it;
254 for (it=target.begin(); it!=target.end();++it) { 257 for (it=target.begin(); it!=target.end();++it) {
255 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); 258 r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber());
256 if (r != MAIL_NO_ERROR) { 259 if (r != MAIL_NO_ERROR) {
257 qDebug("error deleting mail"); 260 qDebug("error deleting mail");
258 break; 261 break;
259 } 262 }
260 } 263 }
261} 264}
262 265
263int MHwrapper::deleteAllMail(const FolderP&tfolder) 266int MHwrapper::deleteAllMail(const FolderP&tfolder)
264{ 267{
265 init_storage(); 268 init_storage();
266 if (!m_storage) { 269 if (!m_storage) {
267 return 0; 270 return 0;
268 } 271 }
269 int res = 1; 272 int res = 1;
270 if (!tfolder) return 0; 273 if (!tfolder) return 0;
271 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 274 int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
272 if (r!=MAIL_NO_ERROR) { 275 if (r!=MAIL_NO_ERROR) {
273 qDebug("error selecting folder!"); 276 qDebug("error selecting folder!");
274 return 0; 277 return 0;
275 } 278 }
276 mailmessage_list*l=0; 279 mailmessage_list*l=0;
277 r = mailsession_get_messages_list(m_storage->sto_session,&l); 280 r = mailsession_get_messages_list(m_storage->sto_session,&l);
278 if (r != MAIL_NO_ERROR) { 281 if (r != MAIL_NO_ERROR) {
279 qDebug("Error message list"); 282 qDebug("Error message list");
280 res = 0; 283 res = 0;
281 } 284 }
282 unsigned j = 0; 285 unsigned j = 0;
283 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { 286 for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) {
284 mailmessage * msg; 287 mailmessage * msg;
285 msg = (mailmessage*)carray_get(l->msg_tab, i); 288 msg = (mailmessage*)carray_get(l->msg_tab, i);
286 j = msg->msg_index; 289 j = msg->msg_index;
287 r = mailsession_remove_message(m_storage->sto_session,j); 290 r = mailsession_remove_message(m_storage->sto_session,j);
288 if (r != MAIL_NO_ERROR) { 291 if (r != MAIL_NO_ERROR) {
289 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 292 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
290 res = 0; 293 res = 0;
291 break; 294 break;
292 } 295 }
293 } 296 }
294 if (l) mailmessage_list_free(l); 297 if (l) mailmessage_list_free(l);
295 return res; 298 return res;
296} 299}
297 300
298int MHwrapper::deleteMbox(const FolderP&tfolder) 301int MHwrapper::deleteMbox(const FolderP&tfolder)
299{ 302{
300 init_storage(); 303 init_storage();
301 if (!m_storage) { 304 if (!m_storage) {
302 return 0; 305 return 0;
303 } 306 }
304 if (!tfolder) return 0; 307 if (!tfolder) return 0;
305 if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; 308 if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0;
306 309
307 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); 310 int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1());
308 311
309 if (r != MAIL_NO_ERROR) { 312 if (r != MAIL_NO_ERROR) {
310 qDebug("error deleting mail box"); 313 qDebug("error deleting mail box");
311 return 0; 314 return 0;
312 } 315 }
313 QString cmd = "rm -rf "+tfolder->getName(); 316 QString cmd = "rm -rf "+tfolder->getName();
314 QStringList command; 317 QStringList command;
315 command << "/bin/sh"; 318 command << "/bin/sh";
316 command << "-c"; 319 command << "-c";
317 command << cmd.latin1(); 320 command << cmd.latin1();
318 OProcess *process = new OProcess(); 321 OProcess *process = new OProcess();
319 322
320 connect(process, SIGNAL(processExited(OProcess*)), 323 connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
321 this, SLOT( processEnded(OProcess*))); 324 this, SLOT( processEnded(OProcess*)));
322 connect(process, SIGNAL( receivedStderr(OProcess*,char*,int)), 325 connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
323 this, SLOT( oprocessStderr(OProcess*,char*,int))); 326 this, SLOT( oprocessStderr(OProcess*,char*,int)));
324 327
325 *process << command; 328 *process << command;
326 removeMboxfailed = false; 329 removeMboxfailed = false;
327 if(!process->start(OProcess::Block, OProcess::All) ) { 330 if(!process->start(OProcess::Block, OProcess::All) ) {
328 qDebug("could not start process"); 331 qDebug("could not start process");
329 return 0; 332 return 0;
330 } 333 }
331 qDebug("mail box deleted"); 334 qDebug("mail box deleted");
332 return 1; 335 return 1;
333} 336}
334 337
335void MHwrapper::processEnded(OProcess *p) 338void MHwrapper::processEnded(OProcess *p)
336{ 339{
337 if (p) delete p; 340 if (p) delete p;
338} 341}
339 342
340void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) 343void MHwrapper::oprocessStderr(OProcess*, char *buffer, int )
341{ 344{
342 QString lineStr = buffer; 345 QString lineStr = buffer;
343 QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); 346 QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") );
344 removeMboxfailed = true; 347 removeMboxfailed = true;
345} 348}
346 349
347void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) 350void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox)
348{ 351{
349 init_storage(); 352 init_storage();
350 if (!m_storage) { 353 if (!m_storage) {
351 return; 354 return;
352 } 355 }
353 target_stat.message_count = 0; 356 target_stat.message_count = 0;
354 target_stat.message_unseen = 0; 357 target_stat.message_unseen = 0;
355 target_stat.message_recent = 0; 358 target_stat.message_recent = 0;
356 QString f = buildPath(mailbox); 359 QString f = buildPath(mailbox);
357 int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, 360 int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count,
358 &target_stat.message_recent,&target_stat.message_unseen); 361 &target_stat.message_recent,&target_stat.message_unseen);
359 if (r != MAIL_NO_ERROR) { 362 if (r != MAIL_NO_ERROR) {
360 Global::statusMessage(tr("Error retrieving status")); 363 Global::statusMessage(tr("Error retrieving status"));
361 } 364 }
362} 365}
363 366
364MAILLIB::ATYPE MHwrapper::getType()const 367MAILLIB::ATYPE MHwrapper::getType()const
365{ 368{
366 return MAILLIB::A_MH; 369 return MAILLIB::A_MH;
367} 370}
368 371
369const QString&MHwrapper::getName()const 372const QString&MHwrapper::getName()const
370{ 373{
371 return MHName; 374 return MHName;
372} 375}
373void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 376void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
374{ 377{
375 init_storage(); 378 init_storage();
376 if (!m_storage) { 379 if (!m_storage) {
377 return; 380 return;
378 } 381 }
379 if (targetWrapper != this) { 382 if (targetWrapper != this) {
380 qDebug("Using generic"); 383 qDebug("Using generic");
381 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); 384 Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit);
382 return; 385 return;
383 } 386 }
384 qDebug("Using internal routines for move/copy"); 387 qDebug("Using internal routines for move/copy");
385 QString tf = buildPath(targetFolder); 388 QString tf = buildPath(targetFolder);
386 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); 389 int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1());
387 if (r != MAIL_NO_ERROR) { 390 if (r != MAIL_NO_ERROR) {
388 qDebug("Error selecting source mailbox"); 391 qDebug("Error selecting source mailbox");
389 return; 392 return;
390 } 393 }
391 if (moveit) { 394 if (moveit) {
392 r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 395 r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
393 } else { 396 } else {
394 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); 397 r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1());
395 } 398 }
396 if (r != MAIL_NO_ERROR) { 399 if (r != MAIL_NO_ERROR) {
397 qDebug("Error copy/moving mail internal (%i)",r); 400 qDebug("Error copy/moving mail internal (%i)",r);
398 } 401 }
399} 402}
400 403
401void MHwrapper::mvcpAllMails(const FolderP&fromFolder, 404void MHwrapper::mvcpAllMails(const FolderP&fromFolder,
402 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) 405 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit)
403{ 406{
404 init_storage(); 407 init_storage();
405 if (!m_storage) { 408 if (!m_storage) {
406 return; 409 return;
407 } 410 }
408 if (targetWrapper != this) { 411 if (targetWrapper != this) {
409 qDebug("Using generic"); 412 qDebug("Using generic");
410 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); 413 Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit);
411 return; 414 return;
412 } 415 }
413 if (!fromFolder) return; 416 if (!fromFolder) return;
414 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); 417 int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1());
415 if (r!=MAIL_NO_ERROR) { 418 if (r!=MAIL_NO_ERROR) {
416 qDebug("error selecting source folder!"); 419 qDebug("error selecting source folder!");
417 return; 420 return;
418 } 421 }
419 QString tf = buildPath(targetFolder); 422 QString tf = buildPath(targetFolder);
420 mailmessage_list*l=0; 423 mailmessage_list*l=0;
421 r = mailsession_get_messages_list(m_storage->sto_session,&l); 424 r = mailsession_get_messages_list(m_storage->sto_session,&l);
422 if (r != MAIL_NO_ERROR) { 425 if (r != MAIL_NO_ERROR) {
423 qDebug("Error message list"); 426 qDebug("Error message list");
424 } 427 }
425 unsigned j = 0; 428 unsigned j = 0;
426 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { 429 for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) {
427 mailmessage * msg; 430 mailmessage * msg;
428 msg = (mailmessage*)carray_get(l->msg_tab, i); 431 msg = (mailmessage*)carray_get(l->msg_tab, i);
429 j = msg->msg_index; 432 j = msg->msg_index;
430 if (moveit) { 433 if (moveit) {
431 r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); 434 r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1());
432 } else { 435 } else {
433 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); 436 r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1());
434 } 437 }
435 if (r != MAIL_NO_ERROR) { 438 if (r != MAIL_NO_ERROR) {
436 qDebug("Error copy/moving mail internal (%i)",r); 439 qDebug("Error copy/moving mail internal (%i)",r);
437 break; 440 break;
438 } 441 }
439 } 442 }
440 if (l) mailmessage_list_free(l); 443 if (l) mailmessage_list_free(l);
441} 444}
diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.h b/noncore/net/mail/libmailwrapper/mhwrapper.h
index 208cf2f..1245507 100644
--- a/noncore/net/mail/libmailwrapper/mhwrapper.h
+++ b/noncore/net/mail/libmailwrapper/mhwrapper.h
@@ -1,60 +1,60 @@
1#ifndef __MH_WRAPPER_H 1#ifndef __MH_WRAPPER_H
2#define __MH_WRAPPER_H 2#define __MH_WRAPPER_H
3 3
4#include "maildefines.h" 4#include "maildefines.h"
5 5
6#include "genericwrapper.h" 6#include "genericwrapper.h"
7#include <qstring.h> 7#include <qstring.h>
8 8
9class encodedString; 9class encodedString;
10struct mailmbox_folder; 10struct mailmbox_folder;
11class OProcess; 11namespace Opie {namespace Core {class Opie::Core::OProcess;}}
12 12
13class MHwrapper : public Genericwrapper 13class MHwrapper : public Genericwrapper
14{ 14{
15 Q_OBJECT 15 Q_OBJECT
16public: 16public:
17 MHwrapper(const QString & dir,const QString&name); 17 MHwrapper(const QString & dir,const QString&name);
18 virtual ~MHwrapper(); 18 virtual ~MHwrapper();
19 19
20 virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); 20 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target );
21 virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); 21 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
22 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 22 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
23 23
24 virtual void deleteMail(const RecMailP&mail); 24 virtual void deleteMail(const RecMailP&mail);
25 virtual void answeredMail(const RecMailP&mail); 25 virtual void answeredMail(const RecMailP&mail);
26 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 26 virtual void mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
27 virtual void mvcpAllMails(const Opie::OSmartPointer<Folder>&fromFolder, 27 virtual void mvcpAllMails(const Opie::Core::OSmartPointer<Folder>&fromFolder,
28 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit); 28 const QString&targetFolder,AbstractMail*targetWrapper,bool moveit);
29 29
30 virtual int createMbox(const QString&folder,const Opie::OSmartPointer<Folder>&f=0, 30 virtual int createMbox(const QString&folder,const Opie::Core::OSmartPointer<Folder>&f=0,
31 const QString&d="",bool s=false); 31 const QString&d="",bool s=false);
32 virtual int deleteMbox(const Opie::OSmartPointer<Folder>&); 32 virtual int deleteMbox(const Opie::Core::OSmartPointer<Folder>&);
33 33
34 virtual void storeMessage(const char*msg,size_t length, const QString&folder); 34 virtual void storeMessage(const char*msg,size_t length, const QString&folder);
35 35
36 virtual RecBody fetchBody( const RecMailP &mail ); 36 virtual RecBody fetchBody( const RecMailP &mail );
37 static void mbox_progress( size_t current, size_t maximum ); 37 static void mbox_progress( size_t current, size_t maximum );
38 38
39 virtual encodedString* fetchRawBody(const RecMailP&mail); 39 virtual encodedString* fetchRawBody(const RecMailP&mail);
40 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::OSmartPointer<RecMail> > &target); 40 virtual void deleteMails(const QString & FolderName,const QValueList<Opie::Core::OSmartPointer<RecMail> > &target);
41 virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); 41 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
42 virtual MAILLIB::ATYPE getType()const; 42 virtual MAILLIB::ATYPE getType()const;
43 virtual const QString&getName()const; 43 virtual const QString&getName()const;
44 44
45public slots: 45public slots:
46 /* for deleting maildirs we are using a system call */ 46 /* for deleting maildirs we are using a system call */
47 virtual void oprocessStderr(OProcess*, char *buffer, int ); 47 virtual void oprocessStderr(Opie::Core::OProcess*, char *buffer, int );
48 virtual void processEnded(OProcess *); 48 virtual void processEnded(Opie::Core::OProcess *);
49protected: 49protected:
50 QString buildPath(const QString&p); 50 QString buildPath(const QString&p);
51 QString MHPath; 51 QString MHPath;
52 QString MHName; 52 QString MHName;
53 53
54 void init_storage(); 54 void init_storage();
55 void clean_storage(); 55 void clean_storage();
56 56
57 bool removeMboxfailed; 57 bool removeMboxfailed;
58}; 58};
59 59
60#endif 60#endif
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
index c0b3eec..9de958d 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.cpp
@@ -1,283 +1,284 @@
1#include "nntpwrapper.h" 1#include "nntpwrapper.h"
2#include "logindialog.h" 2#include "logindialog.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4 4
5#include <qfile.h> 5#include <qfile.h>
6 6
7#include <stdlib.h> 7#include <stdlib.h>
8 8
9#include <libetpan/libetpan.h> 9#include <libetpan/libetpan.h>
10 10
11 11
12#define HARD_MSG_SIZE_LIMIT 5242880 12#define HARD_MSG_SIZE_LIMIT 5242880
13 13
14using namespace Opie::Core;
14NNTPwrapper::NNTPwrapper( NNTPaccount *a ) 15NNTPwrapper::NNTPwrapper( NNTPaccount *a )
15: Genericwrapper() { 16: Genericwrapper() {
16 account = a; 17 account = a;
17 m_nntp = NULL; 18 m_nntp = NULL;
18 msgTempName = a->getFileName()+"_msg_cache"; 19 msgTempName = a->getFileName()+"_msg_cache";
19 last_msg_id = 0; 20 last_msg_id = 0;
20} 21}
21 22
22NNTPwrapper::~NNTPwrapper() { 23NNTPwrapper::~NNTPwrapper() {
23 logout(); 24 logout();
24 QFile msg_cache(msgTempName); 25 QFile msg_cache(msgTempName);
25 if (msg_cache.exists()) { 26 if (msg_cache.exists()) {
26 msg_cache.remove(); 27 msg_cache.remove();
27 } 28 }
28} 29}
29 30
30void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) { 31void NNTPwrapper::nntp_progress( size_t current, size_t maximum ) {
31 qDebug( "NNTP: %i of %i", current, maximum ); 32 qDebug( "NNTP: %i of %i", current, maximum );
32} 33}
33 34
34 35
35RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) { 36RecBody NNTPwrapper::fetchBody( const RecMailP &mail ) {
36 int err = NEWSNNTP_NO_ERROR; 37 int err = NEWSNNTP_NO_ERROR;
37 char *message = 0; 38 char *message = 0;
38 size_t length = 0; 39 size_t length = 0;
39 40
40 login(); 41 login();
41 if ( !m_nntp ) { 42 if ( !m_nntp ) {
42 return RecBody(); 43 return RecBody();
43 } 44 }
44 45
45 RecBody body; 46 RecBody body;
46 mailmessage * mailmsg; 47 mailmessage * mailmsg;
47 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { 48 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
48 qDebug("Message to large: %i",mail->Msgsize()); 49 qDebug("Message to large: %i",mail->Msgsize());
49 return body; 50 return body;
50 } 51 }
51 52
52 QFile msg_cache(msgTempName); 53 QFile msg_cache(msgTempName);
53 54
54 cleanMimeCache(); 55 cleanMimeCache();
55 56
56 if (mail->getNumber()!=last_msg_id) { 57 if (mail->getNumber()!=last_msg_id) {
57 if (msg_cache.exists()) { 58 if (msg_cache.exists()) {
58 msg_cache.remove(); 59 msg_cache.remove();
59 } 60 }
60 msg_cache.open(IO_ReadWrite|IO_Truncate); 61 msg_cache.open(IO_ReadWrite|IO_Truncate);
61 last_msg_id = mail->getNumber(); 62 last_msg_id = mail->getNumber();
62 err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); 63 err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg);
63 err = mailmessage_fetch(mailmsg,&message,&length); 64 err = mailmessage_fetch(mailmsg,&message,&length);
64 msg_cache.writeBlock(message,length); 65 msg_cache.writeBlock(message,length);
65 } else { 66 } else {
66 QString msg=""; 67 QString msg="";
67 msg_cache.open(IO_ReadOnly); 68 msg_cache.open(IO_ReadOnly);
68 message = new char[4096]; 69 message = new char[4096];
69 memset(message,0,4096); 70 memset(message,0,4096);
70 while (msg_cache.readBlock(message,4095)>0) { 71 while (msg_cache.readBlock(message,4095)>0) {
71 msg+=message; 72 msg+=message;
72 memset(message,0,4096); 73 memset(message,0,4096);
73 } 74 }
74 delete message; 75 delete message;
75 message = (char*)malloc(msg.length()+1*sizeof(char)); 76 message = (char*)malloc(msg.length()+1*sizeof(char));
76 memset(message,0,msg.length()+1); 77 memset(message,0,msg.length()+1);
77 memcpy(message,msg.latin1(),msg.length()); 78 memcpy(message,msg.latin1(),msg.length());
78 /* transform to libetpan stuff */ 79 /* transform to libetpan stuff */
79 mailmsg = mailmessage_new(); 80 mailmsg = mailmessage_new();
80 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 81 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
81 generic_message_t * msg_data; 82 generic_message_t * msg_data;
82 msg_data = (generic_message_t *)mailmsg->msg_data; 83 msg_data = (generic_message_t *)mailmsg->msg_data;
83 msg_data->msg_fetched = 1; 84 msg_data->msg_fetched = 1;
84 msg_data->msg_message = message; 85 msg_data->msg_message = message;
85 msg_data->msg_length = strlen(message); 86 msg_data->msg_length = strlen(message);
86 } 87 }
87 body = parseMail(mailmsg); 88 body = parseMail(mailmsg);
88 89
89 /* clean up */ 90 /* clean up */
90 if (mailmsg) 91 if (mailmsg)
91 mailmessage_free(mailmsg); 92 mailmessage_free(mailmsg);
92 if (message) 93 if (message)
93 free(message); 94 free(message);
94 95
95 return body; 96 return body;
96} 97}
97 98
98 99
99void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::OSmartPointer<RecMail> > &target ) 100void NNTPwrapper::listMessages(const QString & which, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
100{ 101{
101 login(); 102 login();
102 if (!m_nntp) 103 if (!m_nntp)
103 return; 104 return;
104 uint32_t res_messages,res_recent,res_unseen; 105 uint32_t res_messages,res_recent,res_unseen;
105 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen); 106 mailsession_status_folder(m_nntp->sto_session,(char*)which.latin1(),&res_messages,&res_recent,&res_unseen);
106 parseList(target,m_nntp->sto_session,which,true); 107 parseList(target,m_nntp->sto_session,which,true);
107} 108}
108 109
109void NNTPwrapper::login() 110void NNTPwrapper::login()
110{ 111{
111 if (account->getOffline()) 112 if (account->getOffline())
112 return; 113 return;
113 /* we'll hold the line */ 114 /* we'll hold the line */
114 if ( m_nntp != NULL ) 115 if ( m_nntp != NULL )
115 return; 116 return;
116 117
117 const char *server, *user, *pass; 118 const char *server, *user, *pass;
118 QString User,Pass; 119 QString User,Pass;
119 uint16_t port; 120 uint16_t port;
120 int err = NEWSNNTP_NO_ERROR; 121 int err = NEWSNNTP_NO_ERROR;
121 122
122 server = account->getServer().latin1(); 123 server = account->getServer().latin1();
123 port = account->getPort().toUInt(); 124 port = account->getPort().toUInt();
124 125
125 user = pass = 0; 126 user = pass = 0;
126 127
127 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) { 128 if ( ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) && account->getLogin() ) {
128 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 129 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
129 login.show(); 130 login.show();
130 if ( QDialog::Accepted == login.exec() ) { 131 if ( QDialog::Accepted == login.exec() ) {
131 // ok 132 // ok
132 User = login.getUser().latin1(); 133 User = login.getUser().latin1();
133 Pass = login.getPassword().latin1(); 134 Pass = login.getPassword().latin1();
134 } else { 135 } else {
135 // cancel 136 // cancel
136 qDebug( "NNTP: Login canceled" ); 137 qDebug( "NNTP: Login canceled" );
137 return; 138 return;
138 } 139 }
139 } else { 140 } else {
140 User = account->getUser().latin1(); 141 User = account->getUser().latin1();
141 Pass = account->getPassword().latin1(); 142 Pass = account->getPassword().latin1();
142 } 143 }
143 144
144 if (User.isEmpty()) { 145 if (User.isEmpty()) {
145 user=0; 146 user=0;
146 pass = 0; 147 pass = 0;
147 } else { 148 } else {
148 user=User.latin1(); 149 user=User.latin1();
149 pass=Pass.latin1(); 150 pass=Pass.latin1();
150 } 151 }
151 // bool ssl = account->getSSL(); 152 // bool ssl = account->getSSL();
152 153
153 m_nntp=mailstorage_new(NULL); 154 m_nntp=mailstorage_new(NULL);
154 155
155 int conntypeset = account->ConnectionType(); 156 int conntypeset = account->ConnectionType();
156 int conntype = 0; 157 int conntype = 0;
157 if ( conntypeset == 3 ) { 158 if ( conntypeset == 3 ) {
158 conntype = CONNECTION_TYPE_COMMAND; 159 conntype = CONNECTION_TYPE_COMMAND;
159 } else if ( conntypeset == 2 ) { 160 } else if ( conntypeset == 2 ) {
160 conntype = CONNECTION_TYPE_TLS; 161 conntype = CONNECTION_TYPE_TLS;
161 } else if ( conntypeset == 1 ) { 162 } else if ( conntypeset == 1 ) {
162 conntype = CONNECTION_TYPE_STARTTLS; 163 conntype = CONNECTION_TYPE_STARTTLS;
163 } else if ( conntypeset == 0 ) { 164 } else if ( conntypeset == 0 ) {
164 conntype = CONNECTION_TYPE_TRY_STARTTLS; 165 conntype = CONNECTION_TYPE_TRY_STARTTLS;
165 } 166 }
166 167
167 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN, 168 nntp_mailstorage_init(m_nntp,(char*)server, port, NULL, CONNECTION_TYPE_PLAIN, NNTP_AUTH_TYPE_PLAIN,
168 (char*)user,(char*)pass,0,0,0); 169 (char*)user,(char*)pass,0,0,0);
169 170
170 err = mailstorage_connect( m_nntp ); 171 err = mailstorage_connect( m_nntp );
171 172
172 if (err != NEWSNNTP_NO_ERROR) { 173 if (err != NEWSNNTP_NO_ERROR) {
173 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); 174 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
174 // Global::statusMessage(tr("Error initializing folder")); 175 // Global::statusMessage(tr("Error initializing folder"));
175 mailstorage_free(m_nntp); 176 mailstorage_free(m_nntp);
176 m_nntp = 0; 177 m_nntp = 0;
177 178
178 } 179 }
179 180
180} 181}
181 182
182void NNTPwrapper::logout() 183void NNTPwrapper::logout()
183{ 184{
184 int err = NEWSNNTP_NO_ERROR; 185 int err = NEWSNNTP_NO_ERROR;
185 if ( m_nntp == NULL ) 186 if ( m_nntp == NULL )
186 return; 187 return;
187 mailstorage_free(m_nntp); 188 mailstorage_free(m_nntp);
188 m_nntp = 0; 189 m_nntp = 0;
189} 190}
190 191
191QValueList<Opie::OSmartPointer<Folder> >* NNTPwrapper::listFolders() { 192QValueList<Opie::Core::OSmartPointer<Folder> >* NNTPwrapper::listFolders() {
192 193
193 QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<Opie::OSmartPointer<Folder> >(); 194 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >();
194 QStringList groups; 195 QStringList groups;
195 if (account) { 196 if (account) {
196 groups = account->getGroups(); 197 groups = account->getGroups();
197 } 198 }
198 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) { 199 for ( QStringList::Iterator it = groups.begin(); it != groups.end(); ++it ) {
199 folders->append(new Folder((*it),".")); 200 folders->append(new Folder((*it),"."));
200 } 201 }
201 return folders; 202 return folders;
202} 203}
203 204
204/* we made this method in raw nntp access of etpan and not via generic interface 205/* we made this method in raw nntp access of etpan and not via generic interface
205 * 'cause in that case there will be doubled copy operations. eg. the etpan would 206 * 'cause in that case there will be doubled copy operations. eg. the etpan would
206 * copy that stuff into its own structures and we must copy it into useable c++ 207 * copy that stuff into its own structures and we must copy it into useable c++
207 * structures for our frontend. this would not make sense, so it is better to reimplement 208 * structures for our frontend. this would not make sense, so it is better to reimplement
208 * the stuff from generic interface of etpan but copy it direct to qt classes. 209 * the stuff from generic interface of etpan but copy it direct to qt classes.
209 */ 210 */
210QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) { 211QStringList NNTPwrapper::listAllNewsgroups(const QString&mask) {
211 login(); 212 login();
212 QStringList res; 213 QStringList res;
213 clist *result = 0; 214 clist *result = 0;
214 clistcell *current = 0; 215 clistcell *current = 0;
215 newsnntp_group_description *group; 216 newsnntp_group_description *group;
216 217
217 if ( m_nntp ) { 218 if ( m_nntp ) {
218 mailsession * session = m_nntp->sto_session; 219 mailsession * session = m_nntp->sto_session;
219 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session; 220 newsnntp * news = ( ( nntp_session_state_data * )session->sess_data )->nntp_session;
220 int err = NEWSNNTP_NO_ERROR; 221 int err = NEWSNNTP_NO_ERROR;
221 if (mask.isEmpty()) { 222 if (mask.isEmpty()) {
222 err = newsnntp_list(news, &result); 223 err = newsnntp_list(news, &result);
223 } else { 224 } else {
224 /* taken from generic wrapper of etpan */ 225 /* taken from generic wrapper of etpan */
225 QString nmask = mask+".*"; 226 QString nmask = mask+".*";
226 err = newsnntp_list_active(news, nmask.latin1(), &result); 227 err = newsnntp_list_active(news, nmask.latin1(), &result);
227 } 228 }
228 if ( err == NEWSNNTP_NO_ERROR && result) { 229 if ( err == NEWSNNTP_NO_ERROR && result) {
229 for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) { 230 for ( current=clist_begin(result);current!=NULL;current=clist_next(current) ) {
230 group = ( newsnntp_group_description* ) current->data; 231 group = ( newsnntp_group_description* ) current->data;
231 if (!group||!group->grp_name||strlen(group->grp_name)==0) continue; 232 if (!group||!group->grp_name||strlen(group->grp_name)==0) continue;
232 res.append(group->grp_name); 233 res.append(group->grp_name);
233 } 234 }
234 } 235 }
235 } 236 }
236 if (result) { 237 if (result) {
237 newsnntp_list_free(result); 238 newsnntp_list_free(result);
238 } 239 }
239 return res; 240 return res;
240} 241}
241 242
242void NNTPwrapper::answeredMail(const RecMailP&) {} 243void NNTPwrapper::answeredMail(const RecMailP&) {}
243 244
244void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) { 245void NNTPwrapper::statusFolder(folderStat&target_stat,const QString&) {
245 login(); 246 login();
246 target_stat.message_count = 0; 247 target_stat.message_count = 0;
247 target_stat.message_unseen = 0; 248 target_stat.message_unseen = 0;
248 target_stat.message_recent = 0; 249 target_stat.message_recent = 0;
249 if (!m_nntp) 250 if (!m_nntp)
250 return; 251 return;
251 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count, 252 int r = mailsession_status_folder(m_nntp->sto_session,0,&target_stat.message_count,
252 &target_stat.message_recent,&target_stat.message_unseen); 253 &target_stat.message_recent,&target_stat.message_unseen);
253} 254}
254 255
255 256
256encodedString* NNTPwrapper::fetchRawBody(const RecMailP&mail) { 257encodedString* NNTPwrapper::fetchRawBody(const RecMailP&mail) {
257 char*target=0; 258 char*target=0;
258 size_t length=0; 259 size_t length=0;
259 encodedString*res = 0; 260 encodedString*res = 0;
260 mailmessage * mailmsg = 0; 261 mailmessage * mailmsg = 0;
261 int err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg); 262 int err = mailsession_get_message(m_nntp->sto_session, mail->getNumber(), &mailmsg);
262 err = mailmessage_fetch(mailmsg,&target,&length); 263 err = mailmessage_fetch(mailmsg,&target,&length);
263 if (mailmsg) 264 if (mailmsg)
264 mailmessage_free(mailmsg); 265 mailmessage_free(mailmsg);
265 if (target) { 266 if (target) {
266 res = new encodedString(target,length); 267 res = new encodedString(target,length);
267 } 268 }
268 return res; 269 return res;
269} 270}
270 271
271MAILLIB::ATYPE NNTPwrapper::getType()const { 272MAILLIB::ATYPE NNTPwrapper::getType()const {
272 return account->getType(); 273 return account->getType();
273} 274}
274 275
275const QString&NNTPwrapper::getName()const{ 276const QString&NNTPwrapper::getName()const{
276 return account->getAccountName(); 277 return account->getAccountName();
277} 278}
278 279
279void NNTPwrapper::deleteMail(const RecMailP&) { 280void NNTPwrapper::deleteMail(const RecMailP&) {
280} 281}
281 282
282int NNTPwrapper::deleteAllMail(const FolderP&) { 283int NNTPwrapper::deleteAllMail(const FolderP&) {
283} 284}
diff --git a/noncore/net/mail/libmailwrapper/nntpwrapper.h b/noncore/net/mail/libmailwrapper/nntpwrapper.h
index a7e4b95..a87a8e8 100644
--- a/noncore/net/mail/libmailwrapper/nntpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/nntpwrapper.h
@@ -1,48 +1,48 @@
1#ifndef __NNTPWRAPPER 1#ifndef __NNTPWRAPPER
2#define __NNTPWRAPPER 2#define __NNTPWRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "genericwrapper.h" 5#include "genericwrapper.h"
6#include <qstring.h> 6#include <qstring.h>
7#include <libetpan/clist.h> 7#include <libetpan/clist.h>
8 8
9class encodedString; 9class encodedString;
10struct mailstorage; 10struct mailstorage;
11struct mailfolder; 11struct mailfolder;
12 12
13class NNTPwrapper : public Genericwrapper 13class NNTPwrapper : public Genericwrapper
14{ 14{
15 15
16 Q_OBJECT 16 Q_OBJECT
17 17
18public: 18public:
19 NNTPwrapper( NNTPaccount *a ); 19 NNTPwrapper( NNTPaccount *a );
20 virtual ~NNTPwrapper(); 20 virtual ~NNTPwrapper();
21 21
22 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
23 virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); 23 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target );
24 /* should only get the subscribed one */ 24 /* should only get the subscribed one */
25 virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); 25 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
26 /* mailbox will be ignored */ 26 /* mailbox will be ignored */
27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 27 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
28 QStringList listAllNewsgroups(const QString&mask = QString::null); 28 QStringList listAllNewsgroups(const QString&mask = QString::null);
29 virtual void deleteMail(const RecMailP&mail); 29 virtual void deleteMail(const RecMailP&mail);
30 virtual void answeredMail(const RecMailP&mail); 30 virtual void answeredMail(const RecMailP&mail);
31 virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); 31 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
32 32
33 virtual RecBody fetchBody( const RecMailP &mail ); 33 virtual RecBody fetchBody( const RecMailP &mail );
34 virtual encodedString* fetchRawBody(const RecMailP&mail); 34 virtual encodedString* fetchRawBody(const RecMailP&mail);
35 virtual void logout(); 35 virtual void logout();
36 virtual MAILLIB::ATYPE getType()const; 36 virtual MAILLIB::ATYPE getType()const;
37 virtual const QString&getName()const; 37 virtual const QString&getName()const;
38 static void nntp_progress( size_t current, size_t maximum ); 38 static void nntp_progress( size_t current, size_t maximum );
39 39
40protected: 40protected:
41 void login(); 41 void login();
42 NNTPaccount *account; 42 NNTPaccount *account;
43 mailstorage* m_nntp; 43 mailstorage* m_nntp;
44 44
45 45
46}; 46};
47 47
48#endif 48#endif
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
index 6737d6c..f5694fe 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.cpp
@@ -1,256 +1,257 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include "pop3wrapper.h" 2#include "pop3wrapper.h"
3#include "mailtypes.h" 3#include "mailtypes.h"
4#include "logindialog.h" 4#include "logindialog.h"
5#include <libetpan/libetpan.h> 5#include <libetpan/libetpan.h>
6#include <qpe/global.h> 6#include <qpe/global.h>
7#include <qfile.h> 7#include <qfile.h>
8//#include <qstring.h> 8//#include <qstring.h>
9 9
10/* we don't fetch messages larger than 5 MB */ 10/* we don't fetch messages larger than 5 MB */
11#define HARD_MSG_SIZE_LIMIT 5242880 11#define HARD_MSG_SIZE_LIMIT 5242880
12 12
13using namespace Opie::Core;
13POP3wrapper::POP3wrapper( POP3account *a ) 14POP3wrapper::POP3wrapper( POP3account *a )
14: Genericwrapper() { 15: Genericwrapper() {
15 account = a; 16 account = a;
16 m_pop3 = NULL; 17 m_pop3 = NULL;
17 msgTempName = a->getFileName()+"_msg_cache"; 18 msgTempName = a->getFileName()+"_msg_cache";
18 last_msg_id = 0; 19 last_msg_id = 0;
19} 20}
20 21
21POP3wrapper::~POP3wrapper() { 22POP3wrapper::~POP3wrapper() {
22 logout(); 23 logout();
23 QFile msg_cache(msgTempName); 24 QFile msg_cache(msgTempName);
24 if (msg_cache.exists()) { 25 if (msg_cache.exists()) {
25 msg_cache.remove(); 26 msg_cache.remove();
26 } 27 }
27} 28}
28 29
29void POP3wrapper::pop3_progress( size_t current, size_t maximum ) { 30void POP3wrapper::pop3_progress( size_t current, size_t maximum ) {
30 qDebug( "POP3: %i of %i", current, maximum ); 31 qDebug( "POP3: %i of %i", current, maximum );
31} 32}
32 33
33RecBody POP3wrapper::fetchBody( const RecMailP &mail ) { 34RecBody POP3wrapper::fetchBody( const RecMailP &mail ) {
34 int err = MAILPOP3_NO_ERROR; 35 int err = MAILPOP3_NO_ERROR;
35 char *message = 0; 36 char *message = 0;
36 size_t length = 0; 37 size_t length = 0;
37 38
38 login(); 39 login();
39 if ( !m_pop3 ) { 40 if ( !m_pop3 ) {
40 return RecBody(); 41 return RecBody();
41 } 42 }
42 43
43 RecBody body; 44 RecBody body;
44 mailmessage * mailmsg; 45 mailmessage * mailmsg;
45 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) { 46 if (mail->Msgsize()>HARD_MSG_SIZE_LIMIT) {
46 qDebug("Message to large: %i",mail->Msgsize()); 47 qDebug("Message to large: %i",mail->Msgsize());
47 return body; 48 return body;
48 } 49 }
49 50
50 QFile msg_cache(msgTempName); 51 QFile msg_cache(msgTempName);
51 52
52 cleanMimeCache(); 53 cleanMimeCache();
53 54
54 if (mail->getNumber()!=last_msg_id) { 55 if (mail->getNumber()!=last_msg_id) {
55 if (msg_cache.exists()) { 56 if (msg_cache.exists()) {
56 msg_cache.remove(); 57 msg_cache.remove();
57 } 58 }
58 msg_cache.open(IO_ReadWrite|IO_Truncate); 59 msg_cache.open(IO_ReadWrite|IO_Truncate);
59 last_msg_id = mail->getNumber(); 60 last_msg_id = mail->getNumber();
60 err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); 61 err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
61 err = mailmessage_fetch(mailmsg,&message,&length); 62 err = mailmessage_fetch(mailmsg,&message,&length);
62 msg_cache.writeBlock(message,length); 63 msg_cache.writeBlock(message,length);
63 } else { 64 } else {
64 QString msg=""; 65 QString msg="";
65 msg_cache.open(IO_ReadOnly); 66 msg_cache.open(IO_ReadOnly);
66 message = new char[4096]; 67 message = new char[4096];
67 memset(message,0,4096); 68 memset(message,0,4096);
68 while (msg_cache.readBlock(message,4095)>0) { 69 while (msg_cache.readBlock(message,4095)>0) {
69 msg+=message; 70 msg+=message;
70 memset(message,0,4096); 71 memset(message,0,4096);
71 } 72 }
72 delete message; 73 delete message;
73 message = (char*)malloc(msg.length()+1*sizeof(char)); 74 message = (char*)malloc(msg.length()+1*sizeof(char));
74 memset(message,0,msg.length()+1); 75 memset(message,0,msg.length()+1);
75 memcpy(message,msg.latin1(),msg.length()); 76 memcpy(message,msg.latin1(),msg.length());
76 /* transform to libetpan stuff */ 77 /* transform to libetpan stuff */
77 mailmsg = mailmessage_new(); 78 mailmsg = mailmessage_new();
78 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message)); 79 mailmessage_init(mailmsg, NULL, data_message_driver, 0, strlen(message));
79 generic_message_t * msg_data; 80 generic_message_t * msg_data;
80 msg_data = (generic_message_t *)mailmsg->msg_data; 81 msg_data = (generic_message_t *)mailmsg->msg_data;
81 msg_data->msg_fetched = 1; 82 msg_data->msg_fetched = 1;
82 msg_data->msg_message = message; 83 msg_data->msg_message = message;
83 msg_data->msg_length = strlen(message); 84 msg_data->msg_length = strlen(message);
84 } 85 }
85 body = parseMail(mailmsg); 86 body = parseMail(mailmsg);
86 87
87 /* clean up */ 88 /* clean up */
88 if (mailmsg) 89 if (mailmsg)
89 mailmessage_free(mailmsg); 90 mailmessage_free(mailmsg);
90 if (message) 91 if (message)
91 free(message); 92 free(message);
92 93
93 return body; 94 return body;
94} 95}
95 96
96void POP3wrapper::listMessages(const QString &, QValueList<Opie::OSmartPointer<RecMail> > &target ) 97void POP3wrapper::listMessages(const QString &, QValueList<Opie::Core::OSmartPointer<RecMail> > &target )
97{ 98{
98 login(); 99 login();
99 if (!m_pop3) 100 if (!m_pop3)
100 return; 101 return;
101 uint32_t res_messages,res_recent,res_unseen; 102 uint32_t res_messages,res_recent,res_unseen;
102 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen); 103 mailsession_status_folder(m_pop3->sto_session,"INBOX",&res_messages,&res_recent,&res_unseen);
103 parseList(target,m_pop3->sto_session,"INBOX"); 104 parseList(target,m_pop3->sto_session,"INBOX");
104 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages)); 105 Global::statusMessage( tr("Mailbox contains %1 mail(s)").arg(res_messages));
105} 106}
106 107
107void POP3wrapper::login() 108void POP3wrapper::login()
108{ 109{
109 if (account->getOffline()) 110 if (account->getOffline())
110 return; 111 return;
111 /* we'll hold the line */ 112 /* we'll hold the line */
112 if ( m_pop3 != NULL ) 113 if ( m_pop3 != NULL )
113 return; 114 return;
114 115
115 const char *server, *user, *pass; 116 const char *server, *user, *pass;
116 uint16_t port; 117 uint16_t port;
117 int err = MAILPOP3_NO_ERROR; 118 int err = MAILPOP3_NO_ERROR;
118 119
119 server = account->getServer().latin1(); 120 server = account->getServer().latin1();
120 port = account->getPort().toUInt(); 121 port = account->getPort().toUInt();
121 122
122 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) { 123 if ( account->getUser().isEmpty() || account->getPassword().isEmpty() ) {
123 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true ); 124 LoginDialog login( account->getUser(), account->getPassword(), NULL, 0, true );
124 login.show(); 125 login.show();
125 if ( QDialog::Accepted == login.exec() ) { 126 if ( QDialog::Accepted == login.exec() ) {
126 // ok 127 // ok
127 user = login.getUser().latin1(); 128 user = login.getUser().latin1();
128 pass = login.getPassword().latin1(); 129 pass = login.getPassword().latin1();
129 } else { 130 } else {
130 // cancel 131 // cancel
131 qDebug( "POP3: Login canceled" ); 132 qDebug( "POP3: Login canceled" );
132 return; 133 return;
133 } 134 }
134 } else { 135 } else {
135 user = account->getUser().latin1(); 136 user = account->getUser().latin1();
136 pass = account->getPassword().latin1(); 137 pass = account->getPassword().latin1();
137 } 138 }
138 139
139 // bool ssl = account->getSSL(); 140 // bool ssl = account->getSSL();
140 141
141 m_pop3=mailstorage_new(NULL); 142 m_pop3=mailstorage_new(NULL);
142 143
143 int conntypeset = account->ConnectionType(); 144 int conntypeset = account->ConnectionType();
144 int conntype = 0; 145 int conntype = 0;
145 if ( conntypeset == 3 ) { 146 if ( conntypeset == 3 ) {
146 conntype = CONNECTION_TYPE_COMMAND; 147 conntype = CONNECTION_TYPE_COMMAND;
147 } else if ( conntypeset == 2 ) { 148 } else if ( conntypeset == 2 ) {
148 conntype = CONNECTION_TYPE_TLS; 149 conntype = CONNECTION_TYPE_TLS;
149 } else if ( conntypeset == 1 ) { 150 } else if ( conntypeset == 1 ) {
150 conntype = CONNECTION_TYPE_STARTTLS; 151 conntype = CONNECTION_TYPE_STARTTLS;
151 } else if ( conntypeset == 0 ) { 152 } else if ( conntypeset == 0 ) {
152 conntype = CONNECTION_TYPE_TRY_STARTTLS; 153 conntype = CONNECTION_TYPE_TRY_STARTTLS;
153 } 154 }
154 155
155 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN); 156 //(ssl?CONNECTION_TYPE_TLS:CONNECTION_TYPE_PLAIN);
156 157
157 pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN, 158 pop3_mailstorage_init(m_pop3,(char*)server, port, NULL, conntype, POP3_AUTH_TYPE_PLAIN,
158 (char*)user,(char*)pass,0,0,0); 159 (char*)user,(char*)pass,0,0,0);
159 160
160 161
161 err = mailstorage_connect(m_pop3); 162 err = mailstorage_connect(m_pop3);
162 if (err != MAIL_NO_ERROR) { 163 if (err != MAIL_NO_ERROR) {
163 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) ); 164 qDebug( QString( "FEHLERNUMMER %1" ).arg( err ) );
164 Global::statusMessage(tr("Error initializing folder")); 165 Global::statusMessage(tr("Error initializing folder"));
165 mailstorage_free(m_pop3); 166 mailstorage_free(m_pop3);
166 m_pop3 = 0; 167 m_pop3 = 0;
167 } 168 }
168} 169}
169 170
170void POP3wrapper::logout() 171void POP3wrapper::logout()
171{ 172{
172 if ( m_pop3 == NULL ) 173 if ( m_pop3 == NULL )
173 return; 174 return;
174 mailstorage_free(m_pop3); 175 mailstorage_free(m_pop3);
175 m_pop3 = 0; 176 m_pop3 = 0;
176} 177}
177 178
178 179
179QValueList<Opie::OSmartPointer<Folder> >* POP3wrapper::listFolders() { 180QValueList<Opie::Core::OSmartPointer<Folder> >* POP3wrapper::listFolders() {
180 QValueList<Opie::OSmartPointer<Folder> >* folders = new QValueList<FolderP>(); 181 QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<FolderP>();
181 FolderP inb=new Folder("INBOX","/"); 182 FolderP inb=new Folder("INBOX","/");
182 folders->append(inb); 183 folders->append(inb);
183 return folders; 184 return folders;
184} 185}
185 186
186void POP3wrapper::deleteMail(const RecMailP&mail) { 187void POP3wrapper::deleteMail(const RecMailP&mail) {
187 login(); 188 login();
188 if (!m_pop3) 189 if (!m_pop3)
189 return; 190 return;
190 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber()); 191 int err = mailsession_remove_message(m_pop3->sto_session,mail->getNumber());
191 if (err != MAIL_NO_ERROR) { 192 if (err != MAIL_NO_ERROR) {
192 Global::statusMessage(tr("error deleting mail")); 193 Global::statusMessage(tr("error deleting mail"));
193 } 194 }
194} 195}
195 196
196void POP3wrapper::answeredMail(const RecMailP&) {} 197void POP3wrapper::answeredMail(const RecMailP&) {}
197 198
198int POP3wrapper::deleteAllMail(const FolderP&) { 199int POP3wrapper::deleteAllMail(const FolderP&) {
199 login(); 200 login();
200 if (!m_pop3) 201 if (!m_pop3)
201 return 0; 202 return 0;
202 int res = 1; 203 int res = 1;
203 204
204 uint32_t result = 0; 205 uint32_t result = 0;
205 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result); 206 int err = mailsession_messages_number(m_pop3->sto_session,NULL,&result);
206 if (err != MAIL_NO_ERROR) { 207 if (err != MAIL_NO_ERROR) {
207 Global::statusMessage(tr("Error getting folder info")); 208 Global::statusMessage(tr("Error getting folder info"));
208 return 0; 209 return 0;
209 } 210 }
210 for (unsigned int i = 0; i < result; ++i) { 211 for (unsigned int i = 0; i < result; ++i) {
211 err = mailsession_remove_message(m_pop3->sto_session,i+1); 212 err = mailsession_remove_message(m_pop3->sto_session,i+1);
212 if (err != MAIL_NO_ERROR) { 213 if (err != MAIL_NO_ERROR) {
213 Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); 214 Global::statusMessage(tr("Error deleting mail %1").arg(i+1));
214 res=0; 215 res=0;
215 } 216 }
216 break; 217 break;
217 } 218 }
218 return res; 219 return res;
219} 220}
220 221
221void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) { 222void POP3wrapper::statusFolder(folderStat&target_stat,const QString&) {
222 login(); 223 login();
223 target_stat.message_count = 0; 224 target_stat.message_count = 0;
224 target_stat.message_unseen = 0; 225 target_stat.message_unseen = 0;
225 target_stat.message_recent = 0; 226 target_stat.message_recent = 0;
226 if (!m_pop3) 227 if (!m_pop3)
227 return; 228 return;
228 int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count, 229 int r = mailsession_status_folder(m_pop3->sto_session,0,&target_stat.message_count,
229 &target_stat.message_recent,&target_stat.message_unseen); 230 &target_stat.message_recent,&target_stat.message_unseen);
230 if (r != MAIL_NO_ERROR) { 231 if (r != MAIL_NO_ERROR) {
231 qDebug("error getting folter status."); 232 qDebug("error getting folter status.");
232 } 233 }
233} 234}
234 235
235encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) { 236encodedString* POP3wrapper::fetchRawBody(const RecMailP&mail) {
236 char*target=0; 237 char*target=0;
237 size_t length=0; 238 size_t length=0;
238 encodedString*res = 0; 239 encodedString*res = 0;
239 mailmessage * mailmsg = 0; 240 mailmessage * mailmsg = 0;
240 int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg); 241 int err = mailsession_get_message(m_pop3->sto_session, mail->getNumber(), &mailmsg);
241 err = mailmessage_fetch(mailmsg,&target,&length); 242 err = mailmessage_fetch(mailmsg,&target,&length);
242 if (mailmsg) 243 if (mailmsg)
243 mailmessage_free(mailmsg); 244 mailmessage_free(mailmsg);
244 if (target) { 245 if (target) {
245 res = new encodedString(target,length); 246 res = new encodedString(target,length);
246 } 247 }
247 return res; 248 return res;
248} 249}
249 250
250MAILLIB::ATYPE POP3wrapper::getType()const { 251MAILLIB::ATYPE POP3wrapper::getType()const {
251 return account->getType(); 252 return account->getType();
252} 253}
253 254
254const QString&POP3wrapper::getName()const{ 255const QString&POP3wrapper::getName()const{
255 return account->getAccountName(); 256 return account->getAccountName();
256} 257}
diff --git a/noncore/net/mail/libmailwrapper/pop3wrapper.h b/noncore/net/mail/libmailwrapper/pop3wrapper.h
index 31eb6f1..c46b941 100644
--- a/noncore/net/mail/libmailwrapper/pop3wrapper.h
+++ b/noncore/net/mail/libmailwrapper/pop3wrapper.h
@@ -1,42 +1,42 @@
1#ifndef __POP3WRAPPER 1#ifndef __POP3WRAPPER
2#define __POP3WRAPPER 2#define __POP3WRAPPER
3 3
4#include "mailwrapper.h" 4#include "mailwrapper.h"
5#include "genericwrapper.h" 5#include "genericwrapper.h"
6#include <qstring.h> 6#include <qstring.h>
7 7
8class encodedString; 8class encodedString;
9struct mailstorage; 9struct mailstorage;
10struct mailfolder; 10struct mailfolder;
11 11
12class POP3wrapper : public Genericwrapper 12class POP3wrapper : public Genericwrapper
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15 15
16public: 16public:
17 POP3wrapper( POP3account *a ); 17 POP3wrapper( POP3account *a );
18 virtual ~POP3wrapper(); 18 virtual ~POP3wrapper();
19 /* mailbox will be ignored */ 19 /* mailbox will be ignored */
20 virtual void listMessages(const QString & mailbox, QValueList<Opie::OSmartPointer<RecMail> > &target ); 20 virtual void listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target );
21 virtual QValueList<Opie::OSmartPointer<Folder> >* listFolders(); 21 virtual QValueList<Opie::Core::OSmartPointer<Folder> >* listFolders();
22 /* mailbox will be ignored */ 22 /* mailbox will be ignored */
23 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX"); 23 virtual void statusFolder(folderStat&target_stat,const QString & mailbox="INBOX");
24 24
25 virtual void deleteMail(const RecMailP&mail); 25 virtual void deleteMail(const RecMailP&mail);
26 virtual void answeredMail(const RecMailP&mail); 26 virtual void answeredMail(const RecMailP&mail);
27 virtual int deleteAllMail(const Opie::OSmartPointer<Folder>&); 27 virtual int deleteAllMail(const Opie::Core::OSmartPointer<Folder>&);
28 28
29 virtual RecBody fetchBody( const RecMailP &mail ); 29 virtual RecBody fetchBody( const RecMailP &mail );
30 virtual encodedString* fetchRawBody(const RecMailP&mail); 30 virtual encodedString* fetchRawBody(const RecMailP&mail);
31 virtual void logout(); 31 virtual void logout();
32 virtual MAILLIB::ATYPE getType()const; 32 virtual MAILLIB::ATYPE getType()const;
33 virtual const QString&getName()const; 33 virtual const QString&getName()const;
34 static void pop3_progress( size_t current, size_t maximum ); 34 static void pop3_progress( size_t current, size_t maximum );
35 35
36protected: 36protected:
37 void login(); 37 void login();
38 POP3account *account; 38 POP3account *account;
39 mailstorage*m_pop3; 39 mailstorage*m_pop3;
40}; 40};
41 41
42#endif 42#endif
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
index 86673aa..e2cea7a 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.cpp
@@ -1,454 +1,455 @@
1#include "smtpwrapper.h" 1#include "smtpwrapper.h"
2#include "mailwrapper.h" 2#include "mailwrapper.h"
3#include "abstractmail.h" 3#include "abstractmail.h"
4#include "logindialog.h" 4#include "logindialog.h"
5#include "mailtypes.h" 5#include "mailtypes.h"
6#include "sendmailprogress.h" 6#include "sendmailprogress.h"
7 7
8#include <qt.h> 8#include <qt.h>
9 9
10#include <qpe/config.h> 10#include <qpe/config.h>
11#include <qpe/qcopenvelope_qws.h> 11#include <qpe/qcopenvelope_qws.h>
12 12
13#include <libetpan/libetpan.h> 13#include <libetpan/libetpan.h>
14 14
15 15
16using namespace Opie::Core;
16progressMailSend*SMTPwrapper::sendProgress = 0; 17progressMailSend*SMTPwrapper::sendProgress = 0;
17 18
18SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp ) 19SMTPwrapper::SMTPwrapper(SMTPaccount * aSmtp )
19 : Generatemail() 20 : Generatemail()
20{ 21{
21 m_SmtpAccount = aSmtp; 22 m_SmtpAccount = aSmtp;
22 Config cfg( "mail" ); 23 Config cfg( "mail" );
23 cfg.setGroup( "Status" ); 24 cfg.setGroup( "Status" );
24 m_queuedMail = cfg.readNumEntry( "outgoing", 0 ); 25 m_queuedMail = cfg.readNumEntry( "outgoing", 0 );
25 emit queuedMails( m_queuedMail ); 26 emit queuedMails( m_queuedMail );
26 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) ); 27 connect( this, SIGNAL( queuedMails(int) ), this, SLOT( emitQCop(int) ) );
27 m_smtp = 0; 28 m_smtp = 0;
28} 29}
29 30
30SMTPwrapper::~SMTPwrapper() 31SMTPwrapper::~SMTPwrapper()
31{ 32{
32 disc_server(); 33 disc_server();
33} 34}
34 35
35void SMTPwrapper::emitQCop( int queued ) { 36void SMTPwrapper::emitQCop( int queued ) {
36 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" ); 37 QCopEnvelope env( "QPE/Pim", "outgoingMails(int)" );
37 env << queued; 38 env << queued;
38} 39}
39 40
40QString SMTPwrapper::mailsmtpError( int errnum ) { 41QString SMTPwrapper::mailsmtpError( int errnum ) {
41 switch ( errnum ) { 42 switch ( errnum ) {
42 case MAILSMTP_NO_ERROR: 43 case MAILSMTP_NO_ERROR:
43 return tr( "No error" ); 44 return tr( "No error" );
44 case MAILSMTP_ERROR_UNEXPECTED_CODE: 45 case MAILSMTP_ERROR_UNEXPECTED_CODE:
45 return tr( "Unexpected error code" ); 46 return tr( "Unexpected error code" );
46 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE: 47 case MAILSMTP_ERROR_SERVICE_NOT_AVAILABLE:
47 return tr( "Service not available" ); 48 return tr( "Service not available" );
48 case MAILSMTP_ERROR_STREAM: 49 case MAILSMTP_ERROR_STREAM:
49 return tr( "Stream error" ); 50 return tr( "Stream error" );
50 case MAILSMTP_ERROR_HOSTNAME: 51 case MAILSMTP_ERROR_HOSTNAME:
51 return tr( "gethostname() failed" ); 52 return tr( "gethostname() failed" );
52 case MAILSMTP_ERROR_NOT_IMPLEMENTED: 53 case MAILSMTP_ERROR_NOT_IMPLEMENTED:
53 return tr( "Not implemented" ); 54 return tr( "Not implemented" );
54 case MAILSMTP_ERROR_ACTION_NOT_TAKEN: 55 case MAILSMTP_ERROR_ACTION_NOT_TAKEN:
55 return tr( "Error, action not taken" ); 56 return tr( "Error, action not taken" );
56 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION: 57 case MAILSMTP_ERROR_EXCEED_STORAGE_ALLOCATION:
57 return tr( "Data exceeds storage allocation" ); 58 return tr( "Data exceeds storage allocation" );
58 case MAILSMTP_ERROR_IN_PROCESSING: 59 case MAILSMTP_ERROR_IN_PROCESSING:
59 return tr( "Error in processing" ); 60 return tr( "Error in processing" );
60 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED: 61 case MAILSMTP_ERROR_STARTTLS_NOT_SUPPORTED:
61 return tr( "Starttls not supported" ); 62 return tr( "Starttls not supported" );
62 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE: 63 // case MAILSMTP_ERROR_INSUFFISANT_SYSTEM_STORAGE:
63 // return tr( "Insufficient system storage" ); 64 // return tr( "Insufficient system storage" );
64 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE: 65 case MAILSMTP_ERROR_MAILBOX_UNAVAILABLE:
65 return tr( "Mailbox unavailable" ); 66 return tr( "Mailbox unavailable" );
66 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED: 67 case MAILSMTP_ERROR_MAILBOX_NAME_NOT_ALLOWED:
67 return tr( "Mailbox name not allowed" ); 68 return tr( "Mailbox name not allowed" );
68 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND: 69 case MAILSMTP_ERROR_BAD_SEQUENCE_OF_COMMAND:
69 return tr( "Bad command sequence" ); 70 return tr( "Bad command sequence" );
70 case MAILSMTP_ERROR_USER_NOT_LOCAL: 71 case MAILSMTP_ERROR_USER_NOT_LOCAL:
71 return tr( "User not local" ); 72 return tr( "User not local" );
72 case MAILSMTP_ERROR_TRANSACTION_FAILED: 73 case MAILSMTP_ERROR_TRANSACTION_FAILED:
73 return tr( "Transaction failed" ); 74 return tr( "Transaction failed" );
74 case MAILSMTP_ERROR_MEMORY: 75 case MAILSMTP_ERROR_MEMORY:
75 return tr( "Memory error" ); 76 return tr( "Memory error" );
76 case MAILSMTP_ERROR_CONNECTION_REFUSED: 77 case MAILSMTP_ERROR_CONNECTION_REFUSED:
77 return tr( "Connection refused" ); 78 return tr( "Connection refused" );
78 default: 79 default:
79 return tr( "Unknown error code" ); 80 return tr( "Unknown error code" );
80 } 81 }
81} 82}
82 83
83 84
84void SMTPwrapper::progress( size_t current, size_t maximum ) { 85void SMTPwrapper::progress( size_t current, size_t maximum ) {
85 if (SMTPwrapper::sendProgress) { 86 if (SMTPwrapper::sendProgress) {
86 SMTPwrapper::sendProgress->setSingleMail(current, maximum ); 87 SMTPwrapper::sendProgress->setSingleMail(current, maximum );
87 qApp->processEvents(); 88 qApp->processEvents();
88 } 89 }
89} 90}
90 91
91void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) { 92void SMTPwrapper::storeMail(const char*mail, size_t length, const QString&box) {
92 if (!mail) 93 if (!mail)
93 return; 94 return;
94 QString localfolders = AbstractMail::defaultLocalfolder(); 95 QString localfolders = AbstractMail::defaultLocalfolder();
95 AbstractMail*wrap = AbstractMail::getWrapper(localfolders); 96 AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
96 wrap->createMbox(box); 97 wrap->createMbox(box);
97 wrap->storeMessage(mail,length,box); 98 wrap->storeMessage(mail,length,box);
98 delete wrap; 99 delete wrap;
99} 100}
100 101
101void SMTPwrapper::smtpSend( mailmime *mail,bool later) { 102void SMTPwrapper::smtpSend( mailmime *mail,bool later) {
102 clist *rcpts = 0; 103 clist *rcpts = 0;
103 char *from, *data; 104 char *from, *data;
104 size_t size; 105 size_t size;
105 106
106 from = data = 0; 107 from = data = 0;
107 108
108 mailmessage * msg = 0; 109 mailmessage * msg = 0;
109 msg = mime_message_init(mail); 110 msg = mime_message_init(mail);
110 mime_message_set_tmpdir(msg,getenv( "HOME" )); 111 mime_message_set_tmpdir(msg,getenv( "HOME" ));
111 int r = mailmessage_fetch(msg,&data,&size); 112 int r = mailmessage_fetch(msg,&data,&size);
112 mime_message_detach_mime(msg); 113 mime_message_detach_mime(msg);
113 mailmessage_free(msg); 114 mailmessage_free(msg);
114 if (r != MAIL_NO_ERROR || !data) { 115 if (r != MAIL_NO_ERROR || !data) {
115 if (data) 116 if (data)
116 free(data); 117 free(data);
117 qDebug("Error fetching mime..."); 118 qDebug("Error fetching mime...");
118 return; 119 return;
119 } 120 }
120 msg = 0; 121 msg = 0;
121 if (later) { 122 if (later) {
122 storeMail(data,size,"Outgoing"); 123 storeMail(data,size,"Outgoing");
123 if (data) 124 if (data)
124 free( data ); 125 free( data );
125 Config cfg( "mail" ); 126 Config cfg( "mail" );
126 cfg.setGroup( "Status" ); 127 cfg.setGroup( "Status" );
127 cfg.writeEntry( "outgoing", ++m_queuedMail ); 128 cfg.writeEntry( "outgoing", ++m_queuedMail );
128 emit queuedMails( m_queuedMail ); 129 emit queuedMails( m_queuedMail );
129 return; 130 return;
130 } 131 }
131 from = getFrom( mail ); 132 from = getFrom( mail );
132 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields ); 133 rcpts = createRcptList( mail->mm_data.mm_message.mm_fields );
133 smtpSend(from,rcpts,data,size); 134 smtpSend(from,rcpts,data,size);
134 if (data) { 135 if (data) {
135 free(data); 136 free(data);
136 } 137 }
137 if (from) { 138 if (from) {
138 free(from); 139 free(from);
139 } 140 }
140 if (rcpts) 141 if (rcpts)
141 smtp_address_list_free( rcpts ); 142 smtp_address_list_free( rcpts );
142} 143}
143 144
144void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage) 145void SMTPwrapper::storeFailedMail(const char*data,unsigned int size, const char*failuremessage)
145{ 146{
146 if (data) { 147 if (data) {
147 storeMail(data,size,"Sendfailed"); 148 storeMail(data,size,"Sendfailed");
148 } 149 }
149 if (failuremessage) { 150 if (failuremessage) {
150 QMessageBox::critical(0,tr("Error sending mail"), 151 QMessageBox::critical(0,tr("Error sending mail"),
151 tr("<center>%1</center>").arg(failuremessage)); 152 tr("<center>%1</center>").arg(failuremessage));
152 } 153 }
153} 154}
154 155
155int SMTPwrapper::start_smtp_tls() 156int SMTPwrapper::start_smtp_tls()
156{ 157{
157 if (!m_smtp) { 158 if (!m_smtp) {
158 return MAILSMTP_ERROR_IN_PROCESSING; 159 return MAILSMTP_ERROR_IN_PROCESSING;
159 } 160 }
160 int err = mailesmtp_starttls(m_smtp); 161 int err = mailesmtp_starttls(m_smtp);
161 if (err != MAILSMTP_NO_ERROR) return err; 162 if (err != MAILSMTP_NO_ERROR) return err;
162 mailstream_low * low; 163 mailstream_low * low;
163 mailstream_low * new_low; 164 mailstream_low * new_low;
164 low = mailstream_get_low(m_smtp->stream); 165 low = mailstream_get_low(m_smtp->stream);
165 if (!low) { 166 if (!low) {
166 return MAILSMTP_ERROR_IN_PROCESSING; 167 return MAILSMTP_ERROR_IN_PROCESSING;
167 } 168 }
168 int fd = mailstream_low_get_fd(low); 169 int fd = mailstream_low_get_fd(low);
169 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { 170 if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) {
170 mailstream_low_free(low); 171 mailstream_low_free(low);
171 mailstream_set_low(m_smtp->stream, new_low); 172 mailstream_set_low(m_smtp->stream, new_low);
172 } else { 173 } else {
173 return MAILSMTP_ERROR_IN_PROCESSING; 174 return MAILSMTP_ERROR_IN_PROCESSING;
174 } 175 }
175 return err; 176 return err;
176} 177}
177 178
178void SMTPwrapper::connect_server() 179void SMTPwrapper::connect_server()
179{ 180{
180 const char *server, *user, *pass; 181 const char *server, *user, *pass;
181 bool ssl; 182 bool ssl;
182 uint16_t port; 183 uint16_t port;
183 ssl = false; 184 ssl = false;
184 bool try_tls = true; 185 bool try_tls = true;
185 bool force_tls=false; 186 bool force_tls=false;
186 server = user = pass = 0; 187 server = user = pass = 0;
187 QString failuretext = ""; 188 QString failuretext = "";
188 189
189 if (m_smtp || !m_SmtpAccount) { 190 if (m_smtp || !m_SmtpAccount) {
190 return; 191 return;
191 } 192 }
192 server = m_SmtpAccount->getServer().latin1(); 193 server = m_SmtpAccount->getServer().latin1();
193 if ( m_SmtpAccount->ConnectionType() == 2 ) { 194 if ( m_SmtpAccount->ConnectionType() == 2 ) {
194 ssl = true; 195 ssl = true;
195 try_tls = false; 196 try_tls = false;
196 } else if (m_SmtpAccount->ConnectionType() == 1) { 197 } else if (m_SmtpAccount->ConnectionType() == 1) {
197 force_tls = true; 198 force_tls = true;
198 } 199 }
199 int result = 1; 200 int result = 1;
200 port = m_SmtpAccount->getPort().toUInt(); 201 port = m_SmtpAccount->getPort().toUInt();
201 202
202 m_smtp = mailsmtp_new( 20, &progress ); 203 m_smtp = mailsmtp_new( 20, &progress );
203 if ( m_smtp == NULL ) { 204 if ( m_smtp == NULL ) {
204 /* no failure message cause this happens when problems with memory - than we 205 /* no failure message cause this happens when problems with memory - than we
205 we can not display any messagebox */ 206 we can not display any messagebox */
206 return; 207 return;
207 } 208 }
208 209
209 int err = MAILSMTP_NO_ERROR; 210 int err = MAILSMTP_NO_ERROR;
210 qDebug( "Servername %s at port %i", server, port ); 211 qDebug( "Servername %s at port %i", server, port );
211 if ( ssl ) { 212 if ( ssl ) {
212 qDebug( "SSL session" ); 213 qDebug( "SSL session" );
213 err = mailsmtp_ssl_connect( m_smtp, server, port ); 214 err = mailsmtp_ssl_connect( m_smtp, server, port );
214 } else { 215 } else {
215 qDebug( "No SSL session" ); 216 qDebug( "No SSL session" );
216 err = mailsmtp_socket_connect( m_smtp, server, port ); 217 err = mailsmtp_socket_connect( m_smtp, server, port );
217 } 218 }
218 if ( err != MAILSMTP_NO_ERROR ) { 219 if ( err != MAILSMTP_NO_ERROR ) {
219 qDebug("Error init connection"); 220 qDebug("Error init connection");
220 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); 221 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
221 result = 0; 222 result = 0;
222 } 223 }
223 224
224 /* switch to tls after init 'cause there it will send the ehlo */ 225 /* switch to tls after init 'cause there it will send the ehlo */
225 if (result) { 226 if (result) {
226 err = mailsmtp_init( m_smtp ); 227 err = mailsmtp_init( m_smtp );
227 if (err != MAILSMTP_NO_ERROR) { 228 if (err != MAILSMTP_NO_ERROR) {
228 result = 0; 229 result = 0;
229 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err)); 230 failuretext = tr("Error init SMTP connection: %1").arg(mailsmtpError(err));
230 } 231 }
231 } 232 }
232 233
233 if (try_tls) { 234 if (try_tls) {
234 err = start_smtp_tls(); 235 err = start_smtp_tls();
235 if (err != MAILSMTP_NO_ERROR) { 236 if (err != MAILSMTP_NO_ERROR) {
236 try_tls = false; 237 try_tls = false;
237 } else { 238 } else {
238 err = mailesmtp_ehlo(m_smtp); 239 err = mailesmtp_ehlo(m_smtp);
239 } 240 }
240 } 241 }
241 242
242 if (!try_tls && force_tls) { 243 if (!try_tls && force_tls) {
243 result = 0; 244 result = 0;
244 failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err)); 245 failuretext = tr("Error init SMTP tls: %1").arg(mailsmtpError(err));
245 } 246 }
246 247
247 if (result==1 && m_SmtpAccount->getLogin() ) { 248 if (result==1 && m_SmtpAccount->getLogin() ) {
248 qDebug("smtp with auth"); 249 qDebug("smtp with auth");
249 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) { 250 if ( m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty() ) {
250 // get'em 251 // get'em
251 LoginDialog login( m_SmtpAccount->getUser(), 252 LoginDialog login( m_SmtpAccount->getUser(),
252 m_SmtpAccount->getPassword(), NULL, 0, true ); 253 m_SmtpAccount->getPassword(), NULL, 0, true );
253 login.show(); 254 login.show();
254 if ( QDialog::Accepted == login.exec() ) { 255 if ( QDialog::Accepted == login.exec() ) {
255 // ok 256 // ok
256 user = login.getUser().latin1(); 257 user = login.getUser().latin1();
257 pass = login.getPassword().latin1(); 258 pass = login.getPassword().latin1();
258 } else { 259 } else {
259 result = 0; 260 result = 0;
260 failuretext=tr("Login aborted - storing mail to localfolder"); 261 failuretext=tr("Login aborted - storing mail to localfolder");
261 } 262 }
262 } else { 263 } else {
263 user = m_SmtpAccount->getUser().latin1(); 264 user = m_SmtpAccount->getUser().latin1();
264 pass = m_SmtpAccount->getPassword().latin1(); 265 pass = m_SmtpAccount->getPassword().latin1();
265 } 266 }
266 qDebug( "session->auth: %i", m_smtp->auth); 267 qDebug( "session->auth: %i", m_smtp->auth);
267 if (result) { 268 if (result) {
268 err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass ); 269 err = mailsmtp_auth( m_smtp, (char*)user, (char*)pass );
269 if ( err == MAILSMTP_NO_ERROR ) { 270 if ( err == MAILSMTP_NO_ERROR ) {
270 qDebug("auth ok"); 271 qDebug("auth ok");
271 } else { 272 } else {
272 failuretext = tr("Authentification failed"); 273 failuretext = tr("Authentification failed");
273 result = 0; 274 result = 0;
274 } 275 }
275 } 276 }
276 } 277 }
277} 278}
278 279
279void SMTPwrapper::disc_server() 280void SMTPwrapper::disc_server()
280{ 281{
281 if (m_smtp) { 282 if (m_smtp) {
282 mailsmtp_quit( m_smtp ); 283 mailsmtp_quit( m_smtp );
283 mailsmtp_free( m_smtp ); 284 mailsmtp_free( m_smtp );
284 m_smtp = 0; 285 m_smtp = 0;
285 } 286 }
286} 287}
287 288
288int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size ) 289int SMTPwrapper::smtpSend(char*from,clist*rcpts,const char*data,size_t size )
289{ 290{
290 int err,result; 291 int err,result;
291 QString failuretext = ""; 292 QString failuretext = "";
292 293
293 connect_server(); 294 connect_server();
294 295
295 result = 1; 296 result = 1;
296 if (m_smtp) { 297 if (m_smtp) {
297 err = mailsmtp_send( m_smtp, from, rcpts, data, size ); 298 err = mailsmtp_send( m_smtp, from, rcpts, data, size );
298 if ( err != MAILSMTP_NO_ERROR ) { 299 if ( err != MAILSMTP_NO_ERROR ) {
299 failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err)); 300 failuretext=tr("Error sending mail: %1").arg(mailsmtpError(err));
300 result = 0; 301 result = 0;
301 } 302 }
302 } else { 303 } else {
303 result = 0; 304 result = 0;
304 } 305 }
305 306
306 if (!result) { 307 if (!result) {
307 storeFailedMail(data,size,failuretext); 308 storeFailedMail(data,size,failuretext);
308 } else { 309 } else {
309 qDebug( "Mail sent." ); 310 qDebug( "Mail sent." );
310 storeMail(data,size,"Sent"); 311 storeMail(data,size,"Sent");
311 } 312 }
312 return result; 313 return result;
313} 314}
314 315
315void SMTPwrapper::sendMail(const Opie::OSmartPointer<Mail>&mail,bool later ) 316void SMTPwrapper::sendMail(const Opie::Core::OSmartPointer<Mail>&mail,bool later )
316{ 317{
317 mailmime * mimeMail; 318 mailmime * mimeMail;
318 319
319 mimeMail = createMimeMail(mail ); 320 mimeMail = createMimeMail(mail );
320 if ( mimeMail == NULL ) { 321 if ( mimeMail == NULL ) {
321 qDebug( "sendMail: error creating mime mail" ); 322 qDebug( "sendMail: error creating mime mail" );
322 } else { 323 } else {
323 sendProgress = new progressMailSend(); 324 sendProgress = new progressMailSend();
324 sendProgress->show(); 325 sendProgress->show();
325 sendProgress->setMaxMails(1); 326 sendProgress->setMaxMails(1);
326 smtpSend( mimeMail,later); 327 smtpSend( mimeMail,later);
327 qDebug("Clean up done"); 328 qDebug("Clean up done");
328 sendProgress->hide(); 329 sendProgress->hide();
329 delete sendProgress; 330 delete sendProgress;
330 sendProgress = 0; 331 sendProgress = 0;
331 mailmime_free( mimeMail ); 332 mailmime_free( mimeMail );
332 } 333 }
333} 334}
334 335
335int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) { 336int SMTPwrapper::sendQueuedMail(AbstractMail*wrap,const RecMailP&which) {
336 size_t curTok = 0; 337 size_t curTok = 0;
337 mailimf_fields *fields = 0; 338 mailimf_fields *fields = 0;
338 mailimf_field*ffrom = 0; 339 mailimf_field*ffrom = 0;
339 clist *rcpts = 0; 340 clist *rcpts = 0;
340 char*from = 0; 341 char*from = 0;
341 int res = 0; 342 int res = 0;
342 343
343 encodedString * data = wrap->fetchRawBody(which); 344 encodedString * data = wrap->fetchRawBody(which);
344 if (!data) 345 if (!data)
345 return 0; 346 return 0;
346 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields ); 347 int err = mailimf_fields_parse( data->Content(), data->Length(), &curTok, &fields );
347 if (err != MAILIMF_NO_ERROR) { 348 if (err != MAILIMF_NO_ERROR) {
348 delete data; 349 delete data;
349 delete wrap; 350 delete wrap;
350 return 0; 351 return 0;
351 } 352 }
352 353
353 rcpts = createRcptList( fields ); 354 rcpts = createRcptList( fields );
354 ffrom = getField(fields, MAILIMF_FIELD_FROM ); 355 ffrom = getField(fields, MAILIMF_FIELD_FROM );
355 from = getFrom(ffrom); 356 from = getFrom(ffrom);
356 357
357 if (rcpts && from) { 358 if (rcpts && from) {
358 res = smtpSend(from,rcpts,data->Content(),data->Length()); 359 res = smtpSend(from,rcpts,data->Content(),data->Length());
359 } 360 }
360 if (fields) { 361 if (fields) {
361 mailimf_fields_free(fields); 362 mailimf_fields_free(fields);
362 fields = 0; 363 fields = 0;
363 } 364 }
364 if (data) { 365 if (data) {
365 delete data; 366 delete data;
366 } 367 }
367 if (from) { 368 if (from) {
368 free(from); 369 free(from);
369 } 370 }
370 if (rcpts) { 371 if (rcpts) {
371 smtp_address_list_free( rcpts ); 372 smtp_address_list_free( rcpts );
372 } 373 }
373 return res; 374 return res;
374} 375}
375 376
376/* this is a special fun */ 377/* this is a special fun */
377bool SMTPwrapper::flushOutbox() { 378bool SMTPwrapper::flushOutbox() {
378 bool returnValue = true; 379 bool returnValue = true;
379 380
380 qDebug("Sending the queue"); 381 qDebug("Sending the queue");
381 if (!m_SmtpAccount) { 382 if (!m_SmtpAccount) {
382 qDebug("No smtp account given"); 383 qDebug("No smtp account given");
383 return false; 384 return false;
384 } 385 }
385 386
386 bool reset_user_value = false; 387 bool reset_user_value = false;
387 QString localfolders = AbstractMail::defaultLocalfolder(); 388 QString localfolders = AbstractMail::defaultLocalfolder();
388 AbstractMail*wrap = AbstractMail::getWrapper(localfolders); 389 AbstractMail*wrap = AbstractMail::getWrapper(localfolders);
389 if (!wrap) { 390 if (!wrap) {
390 qDebug("memory error"); 391 qDebug("memory error");
391 return false; 392 return false;
392 } 393 }
393 QString oldPw, oldUser; 394 QString oldPw, oldUser;
394 QValueList<RecMailP> mailsToSend; 395 QValueList<RecMailP> mailsToSend;
395 QValueList<RecMailP> mailsToRemove; 396 QValueList<RecMailP> mailsToRemove;
396 QString mbox("Outgoing"); 397 QString mbox("Outgoing");
397 wrap->listMessages(mbox,mailsToSend); 398 wrap->listMessages(mbox,mailsToSend);
398 if (mailsToSend.count()==0) { 399 if (mailsToSend.count()==0) {
399 delete wrap; 400 delete wrap;
400 qDebug("No mails to send"); 401 qDebug("No mails to send");
401 return false; 402 return false;
402 } 403 }
403 404
404 oldPw = m_SmtpAccount->getPassword(); 405 oldPw = m_SmtpAccount->getPassword();
405 oldUser = m_SmtpAccount->getUser(); 406 oldUser = m_SmtpAccount->getUser();
406 if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) { 407 if (m_SmtpAccount->getLogin() && (m_SmtpAccount->getUser().isEmpty() || m_SmtpAccount->getPassword().isEmpty()) ) {
407 // get'em 408 // get'em
408 QString user,pass; 409 QString user,pass;
409 LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true ); 410 LoginDialog login( m_SmtpAccount->getUser(), m_SmtpAccount->getPassword(), NULL, 0, true );
410 login.show(); 411 login.show();
411 if ( QDialog::Accepted == login.exec() ) { 412 if ( QDialog::Accepted == login.exec() ) {
412 // ok 413 // ok
413 user = login.getUser().latin1(); 414 user = login.getUser().latin1();
414 pass = login.getPassword().latin1(); 415 pass = login.getPassword().latin1();
415 reset_user_value = true; 416 reset_user_value = true;
416 m_SmtpAccount->setUser(user); 417 m_SmtpAccount->setUser(user);
417 m_SmtpAccount->setPassword(pass); 418 m_SmtpAccount->setPassword(pass);
418 } else { 419 } else {
419 return true; 420 return true;
420 } 421 }
421 } 422 }
422 423
423 424
424 sendProgress = new progressMailSend(); 425 sendProgress = new progressMailSend();
425 sendProgress->show(); 426 sendProgress->show();
426 sendProgress->setMaxMails(mailsToSend.count()); 427 sendProgress->setMaxMails(mailsToSend.count());
427 428
428 while (mailsToSend.count()>0) { 429 while (mailsToSend.count()>0) {
429 if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) { 430 if (sendQueuedMail(wrap, (*mailsToSend.begin()))==0) {
430 QMessageBox::critical(0,tr("Error sending mail"), 431 QMessageBox::critical(0,tr("Error sending mail"),
431 tr("Error sending queued mail - breaking")); 432 tr("Error sending queued mail - breaking"));
432 returnValue = false; 433 returnValue = false;
433 break; 434 break;
434 } 435 }
435 mailsToRemove.append((*mailsToSend.begin())); 436 mailsToRemove.append((*mailsToSend.begin()));
436 mailsToSend.remove(mailsToSend.begin()); 437 mailsToSend.remove(mailsToSend.begin());
437 sendProgress->setCurrentMails(mailsToRemove.count()); 438 sendProgress->setCurrentMails(mailsToRemove.count());
438 } 439 }
439 if (reset_user_value) { 440 if (reset_user_value) {
440 m_SmtpAccount->setUser(oldUser); 441 m_SmtpAccount->setUser(oldUser);
441 m_SmtpAccount->setPassword(oldPw); 442 m_SmtpAccount->setPassword(oldPw);
442 } 443 }
443 Config cfg( "mail" ); 444 Config cfg( "mail" );
444 cfg.setGroup( "Status" ); 445 cfg.setGroup( "Status" );
445 m_queuedMail = 0; 446 m_queuedMail = 0;
446 cfg.writeEntry( "outgoing", m_queuedMail ); 447 cfg.writeEntry( "outgoing", m_queuedMail );
447 emit queuedMails( m_queuedMail ); 448 emit queuedMails( m_queuedMail );
448 sendProgress->hide(); 449 sendProgress->hide();
449 delete sendProgress; 450 delete sendProgress;
450 sendProgress = 0; 451 sendProgress = 0;
451 wrap->deleteMails(mbox,mailsToRemove); 452 wrap->deleteMails(mbox,mailsToRemove);
452 delete wrap; 453 delete wrap;
453 return returnValue; 454 return returnValue;
454} 455}
diff --git a/noncore/net/mail/libmailwrapper/smtpwrapper.h b/noncore/net/mail/libmailwrapper/smtpwrapper.h
index 71ae35c..6c5bbe8 100644
--- a/noncore/net/mail/libmailwrapper/smtpwrapper.h
+++ b/noncore/net/mail/libmailwrapper/smtpwrapper.h
@@ -1,63 +1,63 @@
1// -*- Mode: C++; -*- 1// -*- Mode: C++; -*-
2#ifndef SMTPwrapper_H 2#ifndef SMTPwrapper_H
3#define SMTPwrapper_H 3#define SMTPwrapper_H
4 4
5#include <qpe/applnk.h> 5#include <qpe/applnk.h>
6 6
7#include <qbitarray.h> 7#include <qbitarray.h>
8#include <qdatetime.h> 8#include <qdatetime.h>
9#include <libetpan/clist.h> 9#include <libetpan/clist.h>
10 10
11#include "settings.h" 11#include "settings.h"
12#include "generatemail.h" 12#include "generatemail.h"
13 13
14#include <opie2/osmartpointer.h> 14#include <opie2/osmartpointer.h>
15 15
16class SMTPaccount; 16class SMTPaccount;
17class AbstractMail; 17class AbstractMail;
18 18
19class SMTPwrapper : public Generatemail 19class SMTPwrapper : public Generatemail
20{ 20{
21 Q_OBJECT 21 Q_OBJECT
22 22
23public: 23public:
24 SMTPwrapper(SMTPaccount * aSmtp); 24 SMTPwrapper(SMTPaccount * aSmtp);
25 virtual ~SMTPwrapper(); 25 virtual ~SMTPwrapper();
26 void sendMail(const Opie::OSmartPointer<Mail>& mail,bool later=false ); 26 void sendMail(const Opie::Core::OSmartPointer<Mail>& mail,bool later=false );
27 bool flushOutbox(); 27 bool flushOutbox();
28 28
29 static progressMailSend*sendProgress; 29 static progressMailSend*sendProgress;
30 30
31signals: 31signals:
32 void queuedMails( int ); 32 void queuedMails( int );
33 33
34protected: 34protected:
35 mailsmtp *m_smtp; 35 mailsmtp *m_smtp;
36 SMTPaccount * m_SmtpAccount; 36 SMTPaccount * m_SmtpAccount;
37 37
38 void connect_server(); 38 void connect_server();
39 void disc_server(); 39 void disc_server();
40 int start_smtp_tls(); 40 int start_smtp_tls();
41 41
42 42
43 void smtpSend( mailmime *mail,bool later); 43 void smtpSend( mailmime *mail,bool later);
44 44
45 static void storeMail(const char*mail, size_t length, const QString&box); 45 static void storeMail(const char*mail, size_t length, const QString&box);
46 static QString mailsmtpError( int err ); 46 static QString mailsmtpError( int err );
47 static void progress( size_t current, size_t maximum ); 47 static void progress( size_t current, size_t maximum );
48 48
49 int smtpSend(char*from,clist*rcpts,const char*data,size_t size); 49 int smtpSend(char*from,clist*rcpts,const char*data,size_t size);
50 50
51 void storeMail(mailmime*mail, const QString&box); 51 void storeMail(mailmime*mail, const QString&box);
52 52
53 int sendQueuedMail(AbstractMail*wrap,const Opie::OSmartPointer<RecMail>&which); 53 int sendQueuedMail(AbstractMail*wrap,const Opie::Core::OSmartPointer<RecMail>&which);
54 void storeFailedMail(const char*data,unsigned int size, const char*failuremessage); 54 void storeFailedMail(const char*data,unsigned int size, const char*failuremessage);
55 55
56 int m_queuedMail; 56 int m_queuedMail;
57 57
58protected slots: 58protected slots:
59 void emitQCop( int queued ); 59 void emitQCop( int queued );
60 60
61}; 61};
62 62
63#endif 63#endif
diff --git a/noncore/net/mail/libmailwrapper/storemail.cpp b/noncore/net/mail/libmailwrapper/storemail.cpp
index 595e7fc..914a11d 100644
--- a/noncore/net/mail/libmailwrapper/storemail.cpp
+++ b/noncore/net/mail/libmailwrapper/storemail.cpp
@@ -1,90 +1,91 @@
1#include "storemail.h" 1#include "storemail.h"
2#include "mailwrapper.h" 2#include "mailwrapper.h"
3#include "settings.h" 3#include "settings.h"
4#include "abstractmail.h" 4#include "abstractmail.h"
5 5
6#include <libetpan/libetpan.h> 6#include <libetpan/libetpan.h>
7 7
8#include <qstring.h> 8#include <qstring.h>
9 9
10#include <stdlib.h> 10#include <stdlib.h>
11 11
12using namespace Opie::Core;
12Storemail::Storemail(Account*aAccount,const QString&aFolder) 13Storemail::Storemail(Account*aAccount,const QString&aFolder)
13 : Generatemail() 14 : Generatemail()
14{ 15{
15 wrapper = 0; 16 wrapper = 0;
16 m_Account = aAccount; 17 m_Account = aAccount;
17 m_tfolder = aFolder; 18 m_tfolder = aFolder;
18 wrapper = AbstractMail::getWrapper(m_Account); 19 wrapper = AbstractMail::getWrapper(m_Account);
19 if (wrapper) { 20 if (wrapper) {
20 wrapper->createMbox(m_tfolder); 21 wrapper->createMbox(m_tfolder);
21 } 22 }
22} 23}
23 24
24Storemail::Storemail(const QString&dir,const QString&aFolder) 25Storemail::Storemail(const QString&dir,const QString&aFolder)
25 : Generatemail() 26 : Generatemail()
26{ 27{
27 wrapper = 0; 28 wrapper = 0;
28 m_Account = 0; 29 m_Account = 0;
29 m_tfolder = aFolder; 30 m_tfolder = aFolder;
30 wrapper = AbstractMail::getWrapper(dir); 31 wrapper = AbstractMail::getWrapper(dir);
31 if (wrapper) { 32 if (wrapper) {
32 wrapper->createMbox(m_tfolder); 33 wrapper->createMbox(m_tfolder);
33 } 34 }
34} 35}
35 36
36Storemail::Storemail(const QString&aFolder) 37Storemail::Storemail(const QString&aFolder)
37 : Generatemail() 38 : Generatemail()
38{ 39{
39 wrapper = 0; 40 wrapper = 0;
40 m_Account = 0; 41 m_Account = 0;
41 m_tfolder = aFolder; 42 m_tfolder = aFolder;
42 wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder()); 43 wrapper = AbstractMail::getWrapper(AbstractMail::defaultLocalfolder());
43 if (wrapper) { 44 if (wrapper) {
44 wrapper->createMbox(m_tfolder); 45 wrapper->createMbox(m_tfolder);
45 } 46 }
46} 47}
47 48
48Storemail::~Storemail() 49Storemail::~Storemail()
49{ 50{
50} 51}
51 52
52int Storemail::storeMail(const Opie::OSmartPointer<Mail>&mail) 53int Storemail::storeMail(const Opie::Core::OSmartPointer<Mail>&mail)
53{ 54{
54 if (!wrapper) return 0; 55 if (!wrapper) return 0;
55 int ret = 1; 56 int ret = 1;
56 57
57 mailmime * mimeMail = 0; 58 mailmime * mimeMail = 0;
58 mimeMail = createMimeMail(mail ); 59 mimeMail = createMimeMail(mail );
59 if ( mimeMail == NULL ) { 60 if ( mimeMail == NULL ) {
60 qDebug( "storeMail: error creating mime mail" ); 61 qDebug( "storeMail: error creating mime mail" );
61 return 0; 62 return 0;
62 } 63 }
63 char *data; 64 char *data;
64 size_t size; 65 size_t size;
65 data = 0; 66 data = 0;
66 67
67 mailmessage * msg = 0; 68 mailmessage * msg = 0;
68 msg = mime_message_init(mimeMail); 69 msg = mime_message_init(mimeMail);
69 mime_message_set_tmpdir(msg,getenv( "HOME" )); 70 mime_message_set_tmpdir(msg,getenv( "HOME" ));
70 int r = mailmessage_fetch(msg,&data,&size); 71 int r = mailmessage_fetch(msg,&data,&size);
71 mime_message_detach_mime(msg); 72 mime_message_detach_mime(msg);
72 mailmessage_free(msg); 73 mailmessage_free(msg);
73 msg = 0; 74 msg = 0;
74 if (r != MAIL_NO_ERROR || !data) { 75 if (r != MAIL_NO_ERROR || !data) {
75 qDebug("Error fetching mime..."); 76 qDebug("Error fetching mime...");
76 ret = 0; 77 ret = 0;
77 } 78 }
78 79
79 if (ret) { 80 if (ret) {
80 wrapper->storeMessage(data,size,m_tfolder); 81 wrapper->storeMessage(data,size,m_tfolder);
81 } 82 }
82 83
83 if (data) { 84 if (data) {
84 free(data); 85 free(data);
85 } 86 }
86 if (mimeMail) { 87 if (mimeMail) {
87 mailmime_free( mimeMail ); 88 mailmime_free( mimeMail );
88 } 89 }
89 return ret; 90 return ret;
90} 91}
diff --git a/noncore/net/mail/libmailwrapper/storemail.h b/noncore/net/mail/libmailwrapper/storemail.h
index 80c7431..4433de0 100644
--- a/noncore/net/mail/libmailwrapper/storemail.h
+++ b/noncore/net/mail/libmailwrapper/storemail.h
@@ -1,29 +1,29 @@
1#ifndef __STORE_MAIL_H 1#ifndef __STORE_MAIL_H
2#define __STORE_MAIL_H 2#define __STORE_MAIL_H
3 3
4#include <qpe/applnk.h> 4#include <qpe/applnk.h>
5 5
6#include "generatemail.h" 6#include "generatemail.h"
7 7
8class Account; 8class Account;
9class Mail; 9class Mail;
10class AbstractMail; 10class AbstractMail;
11 11
12class Storemail : public Generatemail 12class Storemail : public Generatemail
13{ 13{
14 Q_OBJECT 14 Q_OBJECT
15public: 15public:
16 Storemail(Account*aAccount,const QString&aFolder); 16 Storemail(Account*aAccount,const QString&aFolder);
17 Storemail(const QString&dir,const QString&aFolder); 17 Storemail(const QString&dir,const QString&aFolder);
18 Storemail(const QString&aFolder); 18 Storemail(const QString&aFolder);
19 virtual ~Storemail(); 19 virtual ~Storemail();
20 20
21 int storeMail(const Opie::OSmartPointer<Mail>&mail); 21 int storeMail(const Opie::Core::OSmartPointer<Mail>&mail);
22 22
23protected: 23protected:
24 Account* m_Account; 24 Account* m_Account;
25 QString m_tfolder; 25 QString m_tfolder;
26 AbstractMail*wrapper; 26 AbstractMail*wrapper;
27}; 27};
28 28
29#endif 29#endif
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro
index 005a839..926cdbd 100644
--- a/noncore/net/mail/mail.pro
+++ b/noncore/net/mail/mail.pro
@@ -1,66 +1,66 @@
1CONFIG += qt warn_on debug quick-app 1CONFIG += qt warn_on debug quick-app
2 2
3HEADERS = defines.h \ 3HEADERS = defines.h \
4 editaccounts.h \ 4 editaccounts.h \
5 composemail.h \ 5 composemail.h \
6 accountview.h \ 6 accountview.h \
7 accountitem.h \ 7 accountitem.h \
8 mainwindow.h \ 8 mainwindow.h \
9 viewmail.h \ 9 viewmail.h \
10 viewmailbase.h \ 10 viewmailbase.h \
11 opiemail.h \ 11 opiemail.h \
12 mailistviewitem.h \ 12 mailistviewitem.h \
13 settingsdialog.h \ 13 settingsdialog.h \
14 statuswidget.h \ 14 statuswidget.h \
15 newmaildir.h \ 15 newmaildir.h \
16 selectstore.h \ 16 selectstore.h \
17 selectsmtp.h \ 17 selectsmtp.h \
18 nntpgroups.h \ 18 nntpgroups.h \
19 nntpgroupsdlg.h 19 nntpgroupsdlg.h
20 20
21SOURCES = main.cpp \ 21SOURCES = main.cpp \
22 opiemail.cpp \ 22 opiemail.cpp \
23 mainwindow.cpp \ 23 mainwindow.cpp \
24 accountview.cpp \ 24 accountview.cpp \
25 accountitem.cpp \ 25 accountitem.cpp \
26 composemail.cpp \ 26 composemail.cpp \
27 addresspicker.cpp \ 27 addresspicker.cpp \
28 editaccounts.cpp \ 28 editaccounts.cpp \
29 viewmail.cpp \ 29 viewmail.cpp \
30 viewmailbase.cpp \ 30 viewmailbase.cpp \
31 mailistviewitem.cpp \ 31 mailistviewitem.cpp \
32 settingsdialog.cpp \ 32 settingsdialog.cpp \
33 statuswidget.cpp \ 33 statuswidget.cpp \
34 newmaildir.cpp \ 34 newmaildir.cpp \
35 selectstore.cpp \ 35 selectstore.cpp \
36 selectsmtp.cpp \ 36 selectsmtp.cpp \
37 nntpgroups.cpp \ 37 nntpgroups.cpp \
38 nntpgroupsdlg.cpp 38 nntpgroupsdlg.cpp
39 39
40INTERFACES = editaccountsui.ui \ 40INTERFACES = editaccountsui.ui \
41 selectmailtypeui.ui \ 41 selectmailtypeui.ui \
42 imapconfigui.ui \ 42 imapconfigui.ui \
43 pop3configui.ui \ 43 pop3configui.ui \
44 nntpconfigui.ui \ 44 nntpconfigui.ui \
45 smtpconfigui.ui \ 45 smtpconfigui.ui \
46 addresspickerui.ui \ 46 addresspickerui.ui \
47 composemailui.ui \ 47 composemailui.ui \
48 settingsdialogui.ui \ 48 settingsdialogui.ui \
49 statuswidgetui.ui \ 49 statuswidgetui.ui \
50 newmaildirui.ui \ 50 newmaildirui.ui \
51 selectstoreui.ui \ 51 selectstoreui.ui \
52 nntpgroupsui.ui 52 nntpgroupsui.ui
53 53
54 54
55INCLUDEPATH += $(OPIEDIR)/include 55INCLUDEPATH += $(OPIEDIR)/include /usr/local/include
56 56
57CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) 57CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
58contains( CONFTEST, y ){ 58contains( CONFTEST, y ){
59 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lopiedb2 -lmailwrapper -liconv 59 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lopiedb2 -lmailwrapper -liconv
60}else{ 60}else{
61 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lopiedb2 -lmailwrapper 61 LIBS += -lqpe -lopieui2 -lopiecore2 -lopiepim2 -lopiedb2 -lmailwrapper
62} 62}
63 63
64TARGET = opiemail 64TARGET = opiemail
65 65
66include ( $(OPIEDIR)/include.pro ) 66include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/mail/main.cpp b/noncore/net/mail/main.cpp
index 54ac7fb..4942083 100644
--- a/noncore/net/mail/main.cpp
+++ b/noncore/net/mail/main.cpp
@@ -1,5 +1,7 @@
1#include <opie2/oapplicationfactory.h> 1#include <opie2/oapplicationfactory.h>
2 2
3#include "opiemail.h" 3#include "opiemail.h"
4 4
5using namespace Opie::Core;
6using namespace Opie::Core;
5OPIE_EXPORT_APP( OApplicationFactory<OpieMail> ) 7OPIE_EXPORT_APP( OApplicationFactory<OpieMail> )
diff --git a/noncore/net/mail/taskbarapplet/mailapplet.cpp b/noncore/net/mail/taskbarapplet/mailapplet.cpp
index de32007..f672a36 100644
--- a/noncore/net/mail/taskbarapplet/mailapplet.cpp
+++ b/noncore/net/mail/taskbarapplet/mailapplet.cpp
@@ -1,145 +1,145 @@
1#include <qpainter.h> 1#include <qpainter.h>
2#include <qtimer.h> 2#include <qtimer.h>
3 3
4#include <qpe/qcopenvelope_qws.h> 4#include <qpe/qcopenvelope_qws.h>
5#include <qpe/resource.h> 5#include <qpe/resource.h>
6#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qpe/applnk.h> 7#include <qpe/applnk.h>
8 8
9#include <opie2/odevice.h> 9#include <opie2/odevice.h>
10 10
11#include <libmailwrapper/settings.h> 11#include <libmailwrapper/settings.h>
12 12
13#include "mailapplet.h" 13#include "mailapplet.h"
14 14
15using namespace Opie; 15using namespace Opie::Core;
16 16
17MailApplet::MailApplet( QWidget *parent ) 17MailApplet::MailApplet( QWidget *parent )
18: QWidget( parent ) { 18: QWidget( parent ) {
19 19
20 m_config = new Config( "mail" ); 20 m_config = new Config( "mail" );
21 m_config->setGroup( "Applet" ); 21 m_config->setGroup( "Applet" );
22 22
23 setFixedWidth( AppLnk::smallIconSize() ); 23 setFixedWidth( AppLnk::smallIconSize() );
24 setFixedHeight( AppLnk::smallIconSize() ); 24 setFixedHeight( AppLnk::smallIconSize() );
25 25
26 hide(); 26 hide();
27 27
28 m_newMails = 0; 28 m_newMails = 0;
29 m_statusMail = 0l; 29 m_statusMail = 0l;
30 30
31 if ( !m_config->readBoolEntry( "Disabled", false ) ) { 31 if ( !m_config->readBoolEntry( "Disabled", false ) ) {
32 // delay 5 sec until the whole mail backend gets started .-) 32 // delay 5 sec until the whole mail backend gets started .-)
33 QTimer::singleShot( 5000, this, SLOT( startup() ) ); 33 QTimer::singleShot( 5000, this, SLOT( startup() ) );
34 } 34 }
35 repaint( true ); 35 repaint( true );
36} 36}
37 37
38 38
39MailApplet::~MailApplet() { 39MailApplet::~MailApplet() {
40 if ( m_statusMail ) 40 if ( m_statusMail )
41 delete m_statusMail; 41 delete m_statusMail;
42 if ( m_config ) 42 if ( m_config )
43 delete m_config; 43 delete m_config;
44} 44}
45 45
46void MailApplet::paintEvent( QPaintEvent* ) { 46void MailApplet::paintEvent( QPaintEvent* ) {
47 QPainter p( this ); 47 QPainter p( this );
48 p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) ); 48 p.drawPixmap( 0, 0, Resource::loadPixmap( "mail/inbox" ) );
49 QFont f( "vera", AppLnk::smallIconSize() ); 49 QFont f( "vera", AppLnk::smallIconSize() );
50 QFontMetrics fm( f ); 50 QFontMetrics fm( f );
51 p.setFont( f ); 51 p.setFont( f );
52 p.setPen( Qt::blue ); 52 p.setPen( Qt::blue );
53 p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) ); 53 p.drawText( AppLnk::smallIconSize()/3, AppLnk::smallIconSize() - 2, QString::number( m_newMails ) );
54 return; 54 return;
55 55
56} 56}
57 57
58void MailApplet::mouseReleaseEvent( QMouseEvent* e ) { 58void MailApplet::mouseReleaseEvent( QMouseEvent* e ) {
59 slotClicked(); 59 slotClicked();
60} 60}
61 61
62void MailApplet::slotClicked() { 62void MailApplet::slotClicked() {
63 QCopEnvelope e( "QPE/System", "execute(QString)" ); 63 QCopEnvelope e( "QPE/System", "execute(QString)" );
64 e << QString( "opiemail" ); 64 e << QString( "opiemail" );
65 65
66 ODevice *device = ODevice::inst(); 66 ODevice *device = ODevice::inst();
67 if ( !device-> ledList().isEmpty() ) { 67 if ( !device-> ledList().isEmpty() ) {
68 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 68 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
69 69
70 device->setLedState( led, Led_Off ); 70 device->setLedState( led, Led_Off );
71 } 71 }
72 72
73 if (m_statusMail) 73 if (m_statusMail)
74 m_statusMail->reset_status(); 74 m_statusMail->reset_status();
75 75
76 hide(); 76 hide();
77} 77}
78 78
79void MailApplet::startup() { 79void MailApplet::startup() {
80 Settings *settings = new Settings(); 80 Settings *settings = new Settings();
81 QList<Account> ma = settings->getAccounts(); 81 QList<Account> ma = settings->getAccounts();
82 m_statusMail = new StatusMail( ma ); 82 m_statusMail = new StatusMail( ma );
83 delete settings; 83 delete settings;
84 84
85 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 85 m_intervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
86 m_intervalTimer = new QTimer(); 86 m_intervalTimer = new QTimer();
87 m_intervalTimer->start( m_intervalMs ); 87 m_intervalTimer->start( m_intervalMs );
88 connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) ); 88 connect( m_intervalTimer, SIGNAL( timeout() ), this, SLOT( slotCheck() ) );
89} 89}
90 90
91void MailApplet::slotCheck() { 91void MailApplet::slotCheck() {
92 // Check wether the check interval has been changed. 92 // Check wether the check interval has been changed.
93 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000; 93 int newIntervalMs = m_config->readNumEntry( "CheckEvery", 5 ) * 60000;
94 if ( newIntervalMs != m_intervalMs ) { 94 if ( newIntervalMs != m_intervalMs ) {
95 m_intervalTimer->changeInterval( newIntervalMs ); 95 m_intervalTimer->changeInterval( newIntervalMs );
96 m_intervalMs = newIntervalMs; 96 m_intervalMs = newIntervalMs;
97 } 97 }
98 98
99 if (m_statusMail == 0) { 99 if (m_statusMail == 0) {
100 return; 100 return;
101 } 101 }
102 102
103 folderStat stat; 103 folderStat stat;
104 m_statusMail->check_current_stat( stat ); 104 m_statusMail->check_current_stat( stat );
105 int newMailsOld = m_newMails; 105 int newMailsOld = m_newMails;
106 m_newMails = stat.message_unseen; 106 m_newMails = stat.message_unseen;
107 qDebug( QString( "test %1" ).arg( m_newMails ) ); 107 qDebug( QString( "test %1" ).arg( m_newMails ) );
108 if ( m_newMails > 0 && newMailsOld != m_newMails ) { 108 if ( m_newMails > 0 && newMailsOld != m_newMails ) {
109 ODevice *device = ODevice::inst(); 109 ODevice *device = ODevice::inst();
110 if ( isHidden() ) 110 if ( isHidden() )
111 show(); 111 show();
112 if ( m_config->readBoolEntry( "BlinkLed", true ) ) { 112 if ( m_config->readBoolEntry( "BlinkLed", true ) ) {
113 if ( !device->ledList().isEmpty() ) { 113 if ( !device->ledList().isEmpty() ) {
114 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 114 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
115 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); 115 device->setLedState( led, device->ledStateList( led ).contains( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On );
116 } 116 }
117 } 117 }
118 if ( m_config->readBoolEntry( "PlaySound", false ) ) 118 if ( m_config->readBoolEntry( "PlaySound", false ) )
119 device->playAlarmSound(); 119 device->playAlarmSound();
120 120
121 Config cfg( "mail" ); 121 Config cfg( "mail" );
122 cfg.setGroup( "Status" ); 122 cfg.setGroup( "Status" );
123 cfg.writeEntry( "newMails", m_newMails ); 123 cfg.writeEntry( "newMails", m_newMails );
124 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 124 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
125 env << m_newMails; 125 env << m_newMails;
126 repaint( true ); 126 repaint( true );
127 127
128 } else { 128 } else {
129 ODevice *device = ODevice::inst(); 129 ODevice *device = ODevice::inst();
130 if ( !isHidden() ) 130 if ( !isHidden() )
131 hide(); 131 hide();
132 if ( !device->ledList().isEmpty() ) { 132 if ( !device->ledList().isEmpty() ) {
133 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0]; 133 OLed led = ( device->ledList().contains( Led_Mail ) ) ? Led_Mail : device->ledList()[0];
134 device->setLedState( led, Led_Off ); 134 device->setLedState( led, Led_Off );
135 } 135 }
136 136
137 if ( newMailsOld != m_newMails ) { 137 if ( newMailsOld != m_newMails ) {
138 Config cfg( "mail" ); 138 Config cfg( "mail" );
139 cfg.setGroup( "Status" ); 139 cfg.setGroup( "Status" );
140 cfg.writeEntry( "newMails", m_newMails ); 140 cfg.writeEntry( "newMails", m_newMails );
141 QCopEnvelope env( "QPE/Pim", "newMails(int)" ); 141 QCopEnvelope env( "QPE/Pim", "newMails(int)" );
142 env << m_newMails; 142 env << m_newMails;
143 } 143 }
144 } 144 }
145} 145}
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp
index 894a386..f00d2cb 100644
--- a/noncore/net/mail/viewmail.cpp
+++ b/noncore/net/mail/viewmail.cpp
@@ -1,415 +1,416 @@
1#include "composemail.h" 1#include "composemail.h"
2#include "viewmail.h" 2#include "viewmail.h"
3 3
4/* OPIE */ 4/* OPIE */
5#include <libmailwrapper/settings.h> 5#include <libmailwrapper/settings.h>
6#include <libmailwrapper/abstractmail.h> 6#include <libmailwrapper/abstractmail.h>
7#include <libmailwrapper/mailtypes.h> 7#include <libmailwrapper/mailtypes.h>
8 8
9#include <opie2/ofiledialog.h> 9#include <opie2/ofiledialog.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12 12
13/* QT */ 13/* QT */
14#include <qtextbrowser.h> 14#include <qtextbrowser.h>
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16#include <qtextstream.h> 16#include <qtextstream.h>
17#include <qaction.h> 17#include <qaction.h>
18#include <qpopupmenu.h> 18#include <qpopupmenu.h>
19#include <qfile.h> 19#include <qfile.h>
20 20
21using namespace Opie::Ui;
21AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 22AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
22 const QString&fsize,int num,const QValueList<int>&path) 23 const QString&fsize,int num,const QValueList<int>&path)
23 : QListViewItem(parent,after),_partNum(num) 24 : QListViewItem(parent,after),_partNum(num)
24{ 25{
25 _path=path; 26 _path=path;
26 setText(0, mime); 27 setText(0, mime);
27 setText(1, desc); 28 setText(1, desc);
28 setText(2, file); 29 setText(2, file);
29 setText(3, fsize); 30 setText(3, fsize);
30} 31}
31 32
32AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, 33AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file,
33 const QString&fsize,int num,const QValueList<int>&path) 34 const QString&fsize,int num,const QValueList<int>&path)
34 : QListViewItem(parent,after),_partNum(num) 35 : QListViewItem(parent,after),_partNum(num)
35{ 36{
36 _path=path; 37 _path=path;
37 setText(0, mime); 38 setText(0, mime);
38 setText(1, desc); 39 setText(1, desc);
39 setText(2, file); 40 setText(2, file);
40 setText(3, fsize); 41 setText(3, fsize);
41} 42}
42 43
43bool AttachItem::isParentof(const QValueList<int>&path) 44bool AttachItem::isParentof(const QValueList<int>&path)
44{ 45{
45 /* if not set, then no parent */ 46 /* if not set, then no parent */
46 if (path.count()==0||_path.count()==0) return false; 47 if (path.count()==0||_path.count()==0) return false;
47 /* the parent must have one digit less then a child */ 48 /* the parent must have one digit less then a child */
48 if (path.count()!=_path.count()+1) return false; 49 if (path.count()!=_path.count()+1) return false;
49 for (unsigned int i=0; i < _path.count();++i) 50 for (unsigned int i=0; i < _path.count();++i)
50 { 51 {
51 if (_path[i]!=path[i]) return false; 52 if (_path[i]!=path[i]) return false;
52 } 53 }
53 return true; 54 return true;
54} 55}
55 56
56AttachItem* ViewMail::searchParent(const QValueList<int>&path) 57AttachItem* ViewMail::searchParent(const QValueList<int>&path)
57{ 58{
58 QListViewItemIterator it( attachments ); 59 QListViewItemIterator it( attachments );
59 for ( ; it.current(); ++it ) 60 for ( ; it.current(); ++it )
60 { 61 {
61 AttachItem*ati = (AttachItem*)it.current(); 62 AttachItem*ati = (AttachItem*)it.current();
62 if (ati->isParentof(path)) return ati; 63 if (ati->isParentof(path)) return ati;
63 } 64 }
64 return 0; 65 return 0;
65} 66}
66 67
67AttachItem* ViewMail::lastChild(AttachItem*parent) 68AttachItem* ViewMail::lastChild(AttachItem*parent)
68{ 69{
69 if (!parent) return 0; 70 if (!parent) return 0;
70 AttachItem* item = (AttachItem*)parent->firstChild(); 71 AttachItem* item = (AttachItem*)parent->firstChild();
71 if (!item) return item; 72 if (!item) return item;
72 AttachItem*temp=0; 73 AttachItem*temp=0;
73 while( (temp=(AttachItem*)item->nextSibling())) 74 while( (temp=(AttachItem*)item->nextSibling()))
74 { 75 {
75 item = temp; 76 item = temp;
76 } 77 }
77 return item; 78 return item;
78} 79}
79 80
80void ViewMail::setBody( RecBody body ) 81void ViewMail::setBody( RecBody body )
81{ 82{
82 83
83 m_body = body; 84 m_body = body;
84 m_mail[2] = body.Bodytext(); 85 m_mail[2] = body.Bodytext();
85 attachbutton->setEnabled(body.Parts().count()>0); 86 attachbutton->setEnabled(body.Parts().count()>0);
86 attachments->setEnabled(body.Parts().count()>0); 87 attachments->setEnabled(body.Parts().count()>0);
87 if (body.Parts().count()==0) 88 if (body.Parts().count()==0)
88 { 89 {
89 return; 90 return;
90 } 91 }
91 AttachItem * curItem=0; 92 AttachItem * curItem=0;
92 AttachItem * parentItem = 0; 93 AttachItem * parentItem = 0;
93 QString type=body.Description().Type()+"/"+body.Description().Subtype(); 94 QString type=body.Description().Type()+"/"+body.Description().Subtype();
94 QString desc,fsize; 95 QString desc,fsize;
95 double s = body.Description().Size(); 96 double s = body.Description().Size();
96 int w; 97 int w;
97 w=0; 98 w=0;
98 99
99 while (s>1024) 100 while (s>1024)
100 { 101 {
101 s/=1024; 102 s/=1024;
102 ++w; 103 ++w;
103 if (w>=2) break; 104 if (w>=2) break;
104 } 105 }
105 106
106 QString q=""; 107 QString q="";
107 switch(w) 108 switch(w)
108 { 109 {
109 case 1: 110 case 1:
110 q="k"; 111 q="k";
111 break; 112 break;
112 case 2: 113 case 2:
113 q="M"; 114 q="M";
114 break; 115 break;
115 default: 116 default:
116 break; 117 break;
117 } 118 }
118 119
119 { 120 {
120 /* I did not found a method to make a CONTENT reset on a QTextStream 121 /* I did not found a method to make a CONTENT reset on a QTextStream
121 so I use this construct that the stream will re-constructed in each 122 so I use this construct that the stream will re-constructed in each
122 loop. To let it work, the textstream is packed into a own area of 123 loop. To let it work, the textstream is packed into a own area of
123 code is it will be destructed after finishing its small job. 124 code is it will be destructed after finishing its small job.
124 */ 125 */
125 QTextOStream o(&fsize); 126 QTextOStream o(&fsize);
126 if (w>0) o.precision(2); else o.precision(0); 127 if (w>0) o.precision(2); else o.precision(0);
127 o.setf(QTextStream::fixed); 128 o.setf(QTextStream::fixed);
128 o << s << " " << q << "Byte"; 129 o << s << " " << q << "Byte";
129 } 130 }
130 131
131 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist()); 132 curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body.Description().Positionlist());
132 QString filename = ""; 133 QString filename = "";
133 134
134 for (unsigned int i = 0; i < body.Parts().count();++i) 135 for (unsigned int i = 0; i < body.Parts().count();++i)
135 { 136 {
136 filename = ""; 137 filename = "";
137 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype(); 138 type = body.Parts()[i].Type()+"/"+body.Parts()[i].Subtype();
138 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin(); 139 part_plist_t::ConstIterator it = body.Parts()[i].Parameters().begin();
139 for (;it!=body.Parts()[i].Parameters().end();++it) 140 for (;it!=body.Parts()[i].Parameters().end();++it)
140 { 141 {
141 qDebug(it.key()); 142 qDebug(it.key());
142 if (it.key().lower()=="name") 143 if (it.key().lower()=="name")
143 { 144 {
144 filename=it.data(); 145 filename=it.data();
145 } 146 }
146 } 147 }
147 s = body.Parts()[i].Size(); 148 s = body.Parts()[i].Size();
148 w = 0; 149 w = 0;
149 while (s>1024) 150 while (s>1024)
150 { 151 {
151 s/=1024; 152 s/=1024;
152 ++w; 153 ++w;
153 if (w>=2) break; 154 if (w>=2) break;
154 } 155 }
155 switch(w) 156 switch(w)
156 { 157 {
157 case 1: 158 case 1:
158 q="k"; 159 q="k";
159 break; 160 break;
160 case 2: 161 case 2:
161 q="M"; 162 q="M";
162 break; 163 break;
163 default: 164 default:
164 q=""; 165 q="";
165 break; 166 break;
166 } 167 }
167 QTextOStream o(&fsize); 168 QTextOStream o(&fsize);
168 if (w>0) o.precision(2); else o.precision(0); 169 if (w>0) o.precision(2); else o.precision(0);
169 o.setf(QTextStream::fixed); 170 o.setf(QTextStream::fixed);
170 o << s << " " << q << "Byte"; 171 o << s << " " << q << "Byte";
171 desc = body.Parts()[i].Description(); 172 desc = body.Parts()[i].Description();
172 parentItem = searchParent(body.Parts()[i].Positionlist()); 173 parentItem = searchParent(body.Parts()[i].Positionlist());
173 if (parentItem) 174 if (parentItem)
174 { 175 {
175 AttachItem*temp = lastChild(parentItem); 176 AttachItem*temp = lastChild(parentItem);
176 if (temp) curItem = temp; 177 if (temp) curItem = temp;
177 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 178 curItem=new AttachItem(parentItem,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
178 attachments->setRootIsDecorated(true); 179 attachments->setRootIsDecorated(true);
179 curItem = parentItem; 180 curItem = parentItem;
180 } 181 }
181 else 182 else
182 { 183 {
183 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist()); 184 curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i,body.Parts()[i].Positionlist());
184 } 185 }
185 } 186 }
186} 187}
187 188
188 189
189void ViewMail::slotShowHtml( bool state ) 190void ViewMail::slotShowHtml( bool state )
190{ 191{
191 m_showHtml = state; 192 m_showHtml = state;
192 setText(); 193 setText();
193} 194}
194 195
195void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) 196void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int )
196{ 197{
197 if (!item ) 198 if (!item )
198 return; 199 return;
199 200
200 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 201 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
201 { 202 {
202 setText(); 203 setText();
203 return; 204 return;
204 } 205 }
205 QPopupMenu *menu = new QPopupMenu(); 206 QPopupMenu *menu = new QPopupMenu();
206 int ret=0; 207 int ret=0;
207 208
208 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" ) 209 if ( item->text( 0 ).left( 5 ) == "text/" || item->text(0)=="message/rfc822" )
209 { 210 {
210 menu->insertItem( tr( "Show Text" ), 1 ); 211 menu->insertItem( tr( "Show Text" ), 1 );
211 } 212 }
212 menu->insertItem( tr( "Save Attachment" ), 0 ); 213 menu->insertItem( tr( "Save Attachment" ), 0 );
213 menu->insertSeparator(1); 214 menu->insertSeparator(1);
214 215
215 ret = menu->exec( point, 0 ); 216 ret = menu->exec( point, 0 );
216 217
217 switch(ret) 218 switch(ret)
218 { 219 {
219 case 0: 220 case 0:
220 { 221 {
221 MimeTypes types; 222 MimeTypes types;
222 types.insert( "all", "*" ); 223 types.insert( "all", "*" );
223 QString str = Opie::OFileDialog::getSaveFileName( 1, 224 QString str = OFileDialog::getSaveFileName( 1,
224 "/", item->text( 2 ) , types, 0 ); 225 "/", item->text( 2 ) , types, 0 );
225 226
226 if( !str.isEmpty() ) 227 if( !str.isEmpty() )
227 { 228 {
228 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); 229 encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] );
229 if (content) 230 if (content)
230 { 231 {
231 QFile output(str); 232 QFile output(str);
232 output.open(IO_WriteOnly); 233 output.open(IO_WriteOnly);
233 output.writeBlock(content->Content(),content->Length()); 234 output.writeBlock(content->Content(),content->Length());
234 output.close(); 235 output.close();
235 delete content; 236 delete content;
236 } 237 }
237 } 238 }
238 } 239 }
239 break ; 240 break ;
240 241
241 case 1: 242 case 1:
242 if ( ( ( AttachItem* )item )->Partnumber() == -1 ) 243 if ( ( ( AttachItem* )item )->Partnumber() == -1 )
243 { 244 {
244 setText(); 245 setText();
245 } 246 }
246 else 247 else
247 { 248 {
248 if ( m_recMail->Wrapper() != 0l ) 249 if ( m_recMail->Wrapper() != 0l )
249 { // make sure that there is a wrapper , even after delete or simular actions 250 { // make sure that there is a wrapper , even after delete or simular actions
250 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); 251 browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body.Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) );
251 } 252 }
252 } 253 }
253 break; 254 break;
254 } 255 }
255 delete menu; 256 delete menu;
256} 257}
257 258
258 259
259void ViewMail::setMail( RecMailP mail ) 260void ViewMail::setMail( RecMailP mail )
260{ 261{
261 262
262 m_recMail = mail; 263 m_recMail = mail;
263 264
264 m_mail[0] = mail->getFrom(); 265 m_mail[0] = mail->getFrom();
265 m_mail[1] = mail->getSubject(); 266 m_mail[1] = mail->getSubject();
266 m_mail[3] = mail->getDate(); 267 m_mail[3] = mail->getDate();
267 m_mail[4] = mail->Msgid(); 268 m_mail[4] = mail->Msgid();
268 269
269 m_mail2[0] = mail->To(); 270 m_mail2[0] = mail->To();
270 m_mail2[1] = mail->CC(); 271 m_mail2[1] = mail->CC();
271 m_mail2[2] = mail->Bcc(); 272 m_mail2[2] = mail->Bcc();
272 273
273 setText(); 274 setText();
274} 275}
275 276
276 277
277 278
278ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) 279ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl)
279 : ViewMailBase(parent, name, fl), _inLoop(false) 280 : ViewMailBase(parent, name, fl), _inLoop(false)
280{ 281{
281 m_gotBody = false; 282 m_gotBody = false;
282 deleted = false; 283 deleted = false;
283 284
284 connect( reply, SIGNAL(activated()), SLOT(slotReply())); 285 connect( reply, SIGNAL(activated()), SLOT(slotReply()));
285 connect( forward, SIGNAL(activated()), SLOT(slotForward())); 286 connect( forward, SIGNAL(activated()), SLOT(slotForward()));
286 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); 287 connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) );
287 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); 288 connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) );
288 289
289 attachments->setEnabled(m_gotBody); 290 attachments->setEnabled(m_gotBody);
290 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); 291 connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) );
291 292
292 readConfig(); 293 readConfig();
293 attachments->setSorting(-1); 294 attachments->setSorting(-1);
294} 295}
295 296
296void ViewMail::readConfig() 297void ViewMail::readConfig()
297{ 298{
298 Config cfg( "mail" ); 299 Config cfg( "mail" );
299 cfg.setGroup( "Settings" ); 300 cfg.setGroup( "Settings" );
300 m_showHtml = cfg.readBoolEntry( "showHtml", false ); 301 m_showHtml = cfg.readBoolEntry( "showHtml", false );
301 showHtml->setOn( m_showHtml ); 302 showHtml->setOn( m_showHtml );
302} 303}
303 304
304void ViewMail::setText() 305void ViewMail::setText()
305{ 306{
306 307
307 QString toString; 308 QString toString;
308 QString ccString; 309 QString ccString;
309 QString bccString; 310 QString bccString;
310 311
311 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) 312 for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it )
312 { 313 {
313 toString += (*it); 314 toString += (*it);
314 } 315 }
315 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) 316 for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it )
316 { 317 {
317 ccString += (*it); 318 ccString += (*it);
318 } 319 }
319 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) 320 for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it )
320 { 321 {
321 bccString += (*it); 322 bccString += (*it);
322 } 323 }
323 324
324 setCaption( caption().arg( m_mail[0] ) ); 325 setCaption( caption().arg( m_mail[0] ) );
325 326
326 m_mailHtml = "<html><body>" 327 m_mailHtml = "<html><body>"
327 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" 328 "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>"
328 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" 329 "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>"
329 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" 330 "</td></tr><tr bgcolor=\"#EEEEE6\"><td>"
330 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" 331 "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>"
331 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + 332 "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" +
332 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" 333 tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>"
333 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + 334 "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] +
334 "</td></tr></table><font face=fixed>"; 335 "</td></tr></table><font face=fixed>";
335 336
336 if ( !m_showHtml ) 337 if ( !m_showHtml )
337 { 338 {
338 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); 339 browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" );
339 } 340 }
340 else 341 else
341 { 342 {
342 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); 343 browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" );
343 } 344 }
344 // remove later in favor of a real handling 345 // remove later in favor of a real handling
345 m_gotBody = true; 346 m_gotBody = true;
346} 347}
347 348
348 349
349ViewMail::~ViewMail() 350ViewMail::~ViewMail()
350{ 351{
351 m_recMail->Wrapper()->cleanMimeCache(); 352 m_recMail->Wrapper()->cleanMimeCache();
352 hide(); 353 hide();
353} 354}
354 355
355void ViewMail::hide() 356void ViewMail::hide()
356{ 357{
357 QWidget::hide(); 358 QWidget::hide();
358 359
359 if (_inLoop) 360 if (_inLoop)
360 { 361 {
361 _inLoop = false; 362 _inLoop = false;
362 qApp->exit_loop(); 363 qApp->exit_loop();
363 364
364 } 365 }
365 366
366} 367}
367 368
368void ViewMail::exec() 369void ViewMail::exec()
369{ 370{
370 show(); 371 show();
371 372
372 if (!_inLoop) 373 if (!_inLoop)
373 { 374 {
374 _inLoop = true; 375 _inLoop = true;
375 qApp->enter_loop(); 376 qApp->enter_loop();
376 } 377 }
377 378
378} 379}
379 380
380QString ViewMail::deHtml(const QString &string) 381QString ViewMail::deHtml(const QString &string)
381{ 382{
382 QString string_ = string; 383 QString string_ = string;
383 string_.replace(QRegExp("&"), "&amp;"); 384 string_.replace(QRegExp("&"), "&amp;");
384 string_.replace(QRegExp("<"), "&lt;"); 385 string_.replace(QRegExp("<"), "&lt;");
385 string_.replace(QRegExp(">"), "&gt;"); 386 string_.replace(QRegExp(">"), "&gt;");
386 string_.replace(QRegExp("\\n"), "<br>"); 387 string_.replace(QRegExp("\\n"), "<br>");
387 return string_; 388 return string_;
388} 389}
389 390
390void ViewMail::slotReply() 391void ViewMail::slotReply()
391{ 392{
392 if (!m_gotBody) 393 if (!m_gotBody)
393 { 394 {
394 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok")); 395 QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot reply yet."), tr("Ok"));
395 return; 396 return;
396 } 397 }
397 398
398 QString rtext; 399 QString rtext;
399 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose 400 rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose
400 .arg( m_mail[0] ) 401 .arg( m_mail[0] )
401 .arg( m_mail[3] ); 402 .arg( m_mail[3] );
402 403
403 QString text = m_mail[2]; 404 QString text = m_mail[2];
404 QStringList lines = QStringList::split(QRegExp("\\n"), text); 405 QStringList lines = QStringList::split(QRegExp("\\n"), text);
405 QStringList::Iterator it; 406 QStringList::Iterator it;
406 for (it = lines.begin(); it != lines.end(); it++) 407 for (it = lines.begin(); it != lines.end(); it++)
407 { 408 {
408 rtext += "> " + *it + "\n"; 409 rtext += "> " + *it + "\n";
409 } 410 }
410 rtext += "\n"; 411 rtext += "\n";
411 412
412 QString prefix; 413 QString prefix;
413 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; 414 if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = "";
414 else prefix = "Re: "; // no i18n on purpose 415 else prefix = "Re: "; // no i18n on purpose
415 416
diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp
index c2bf08c..cbb98cc 100644
--- a/noncore/net/mail/viewmailbase.cpp
+++ b/noncore/net/mail/viewmailbase.cpp
@@ -1,89 +1,89 @@
1#include <qtextbrowser.h> 1#include <qtextbrowser.h>
2#include <qlistview.h> 2#include <qlistview.h>
3#include <qaction.h> 3#include <qaction.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qvbox.h> 5#include <qvbox.h>
6 6
7#include <qpe/qpetoolbar.h> 7#include <qtoolbar.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10 10
11#include "viewmailbase.h" 11#include "viewmailbase.h"
12//#include "opendiag.h" 12//#include "opendiag.h"
13 13
14ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) 14ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
15 : QMainWindow(parent, name, fl) 15 : QMainWindow(parent, name, fl)
16{ 16{
17 setCaption(tr("E-Mail by %1")); 17 setCaption(tr("E-Mail by %1"));
18 setToolBarsMovable(false); 18 setToolBarsMovable(false);
19 19
20 toolbar = new QToolBar(this); 20 toolbar = new QToolBar(this);
21 menubar = new QMenuBar( toolbar ); 21 menubar = new QMenuBar( toolbar );
22 mailmenu = new QPopupMenu( menubar ); 22 mailmenu = new QPopupMenu( menubar );
23 menubar->insertItem( tr( "Mail" ), mailmenu ); 23 menubar->insertItem( tr( "Mail" ), mailmenu );
24 24
25 toolbar->setHorizontalStretchable(true); 25 toolbar->setHorizontalStretchable(true);
26 addToolBar(toolbar); 26 addToolBar(toolbar);
27 27
28 QLabel *spacer = new QLabel(toolbar); 28 QLabel *spacer = new QLabel(toolbar);
29 spacer->setBackgroundMode(QWidget::PaletteButton); 29 spacer->setBackgroundMode(QWidget::PaletteButton);
30 toolbar->setStretchableWidget(spacer); 30 toolbar->setStretchableWidget(spacer);
31 31
32 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); 32 reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this);
33 reply->addTo(toolbar); 33 reply->addTo(toolbar);
34 reply->addTo(mailmenu); 34 reply->addTo(mailmenu);
35 35
36 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); 36 forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this);
37 forward->addTo(toolbar); 37 forward->addTo(toolbar);
38 forward->addTo(mailmenu); 38 forward->addTo(mailmenu);
39 39
40 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); 40 attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
41 attachbutton->addTo(toolbar); 41 attachbutton->addTo(toolbar);
42 attachbutton->addTo(mailmenu); 42 attachbutton->addTo(mailmenu);
43 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); 43 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
44 44
45 45
46 showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true ); 46 showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/html" ) ), 0, 0, this, 0, true );
47 showHtml->addTo( toolbar ); 47 showHtml->addTo( toolbar );
48 showHtml->addTo( mailmenu ); 48 showHtml->addTo( mailmenu );
49 49
50 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this); 50 deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("trash")), 0, 0, this);
51 deleteMail->addTo(toolbar); 51 deleteMail->addTo(toolbar);
52 deleteMail->addTo(mailmenu); 52 deleteMail->addTo(mailmenu);
53 53
54 QVBox *view = new QVBox(this); 54 QVBox *view = new QVBox(this);
55 setCentralWidget(view); 55 setCentralWidget(view);
56 56
57 attachments = new QListView(view); 57 attachments = new QListView(view);
58 attachments->setMinimumHeight(90); 58 attachments->setMinimumHeight(90);
59 attachments->setMaximumHeight(90); 59 attachments->setMaximumHeight(90);
60 attachments->setAllColumnsShowFocus(true); 60 attachments->setAllColumnsShowFocus(true);
61 attachments->addColumn("Mime Type", 60); 61 attachments->addColumn("Mime Type", 60);
62 attachments->addColumn(tr("Description"), 100); 62 attachments->addColumn(tr("Description"), 100);
63 attachments->addColumn(tr("Filename"), 80); 63 attachments->addColumn(tr("Filename"), 80);
64 attachments->addColumn(tr("Size"), 80); 64 attachments->addColumn(tr("Size"), 80);
65 attachments->setSorting(-1); 65 attachments->setSorting(-1);
66 attachments->hide(); 66 attachments->hide();
67 67
68 browser = new QTextBrowser(view); 68 browser = new QTextBrowser(view);
69 69
70 //openDiag = new OpenDiag(view); 70 //openDiag = new OpenDiag(view);
71 //openDiag->hide(); 71 //openDiag->hide();
72 72
73} 73}
74 74
75void ViewMailBase::slotChangeAttachview(bool state) 75void ViewMailBase::slotChangeAttachview(bool state)
76{ 76{
77 if (state) attachments->show(); 77 if (state) attachments->show();
78 else attachments->hide(); 78 else attachments->hide();
79} 79}
80 80
81void ViewMailBase::keyPressEvent ( QKeyEvent * e ) 81void ViewMailBase::keyPressEvent ( QKeyEvent * e )
82{ 82{
83 if( e->key()==Qt::Key_Escape ) { 83 if( e->key()==Qt::Key_Escape ) {
84 close(); 84 close();
85 e->accept(); 85 e->accept();
86 return; 86 return;
87 } 87 }
88 QWidget::keyPressEvent(e); 88 QWidget::keyPressEvent(e);
89} 89}
diff --git a/noncore/net/opieftp/main.cpp b/noncore/net/opieftp/main.cpp
index d9da4b2..330ca52 100644
--- a/noncore/net/opieftp/main.cpp
+++ b/noncore/net/opieftp/main.cpp
@@ -1,16 +1,18 @@
1 1
2/*************************************************************************** 2/***************************************************************************
3
3 main.cpp - description 4 main.cpp - description
4 ------------------- 5 -------------------
5 begin : March 10, 2002 6 begin : March 10, 2002
6 copyright : (C) 2002 by llornkcor 7 copyright : (C) 2002 by llornkcor
7 email : ljp@llornkcor.com 8 email : ljp@llornkcor.com
8 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. * 12 * (at your option) any later version. *
12 ***************************************************************************/ 13 ***************************************************************************/
13#include <opie2/oapplicationfactory.h> 14#include <opie2/oapplicationfactory.h>
14#include "opieftp.h" 15#include "opieftp.h"
15 16
17using namespace Opie::Core;
16OPIE_EXPORT_APP( OApplicationFactory<OpieFtp> ) 18OPIE_EXPORT_APP( OApplicationFactory<OpieFtp> )
diff --git a/noncore/net/opieirc/config.in b/noncore/net/opieirc/config.in
index 7c6949d..38fa347 100644
--- a/noncore/net/opieirc/config.in
+++ b/noncore/net/opieirc/config.in
@@ -1,4 +1,4 @@
1 config OPIEIRC 1 config OPIEIRC
2 boolean "opie-irc (chat via your favorite IRC server)" 2 boolean "opie-irc (chat via your favorite IRC server)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIEUI2 && LIBQTAUX
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
index f69d2c4..13fcc24 100644
--- a/noncore/net/opieirc/ircsettings.cpp
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -1,108 +1,110 @@
1 1
2#include "ircsettings.h" 2#include "ircsettings.h"
3#include "irctab.h" 3#include "irctab.h"
4 4
5/* OPIE */ 5/* OPIE */
6#include <opie/ocolorbutton.h> 6#include <opie2/ocolorbutton.h>
7#include <opie/otabwidget.h> 7#include <opie2/otabwidget.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9 9
10/* QT */ 10/* QT */
11#include <qvalidator.h> 11#include <qvalidator.h>
12#include <qwhatsthis.h> 12#include <qwhatsthis.h>
13 13
14using namespace Opie;
15using namespace Opie::Ui;
14IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) 16IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
15{ 17{
16 setCaption(tr("Settings") ); 18 setCaption(tr("Settings") );
17 m_config = new Config("OpieIRC"); 19 m_config = new Config("OpieIRC");
18 m_config->setGroup("OpieIRC"); 20 m_config->setGroup("OpieIRC");
19 QHBoxLayout *l = new QHBoxLayout(this, 2, 2); 21 QHBoxLayout *l = new QHBoxLayout(this, 2, 2);
20 OTabWidget *tw = new OTabWidget(this); 22 OTabWidget *tw = new OTabWidget(this);
21 l->addWidget(tw); 23 l->addWidget(tw);
22 /* General Configuration */ 24 /* General Configuration */
23 QWidget *genwidget = new QWidget(tw); 25 QWidget *genwidget = new QWidget(tw);
24 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); 26 QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0);
25 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); 27 QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
26 layout->addWidget(label, 0, 0); 28 layout->addWidget(label, 0, 0);
27 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); 29 m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
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")); 30 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"));
29 QIntValidator *validator = new QIntValidator(this); 31 QIntValidator *validator = new QIntValidator(this);
30 validator->setTop(10000); 32 validator->setTop(10000);
31 validator->setBottom(0); 33 validator->setBottom(0);
32 m_lines->setValidator(validator); 34 m_lines->setValidator(validator);
33 layout->addWidget(m_lines, 0, 1); 35 layout->addWidget(m_lines, 0, 1);
34 tw->addTab(genwidget, "opieirc/settings", tr("General")); 36 tw->addTab(genwidget, "opieirc/settings", tr("General"));
35 37
36 /* Color configuration */ 38 /* Color configuration */
37 QScrollView *view = new QScrollView(this); 39 QScrollView *view = new QScrollView(this);
38 view->setResizePolicy(QScrollView::AutoOneFit); 40 view->setResizePolicy(QScrollView::AutoOneFit);
39 view->setFrameStyle( QFrame::NoFrame ); 41 view->setFrameStyle( QFrame::NoFrame );
40 QWidget *widget = new QWidget(view->viewport()); 42 QWidget *widget = new QWidget(view->viewport());
41 view->addChild(widget); 43 view->addChild(widget);
42 layout = new QGridLayout(widget, 7, 2, 5, 0); 44 layout = new QGridLayout(widget, 7, 2, 5, 0);
43 label = new QLabel(tr("Background color :"), widget); 45 label = new QLabel(tr("Background color :"), widget);
44 layout->addWidget(label, 0, 0); 46 layout->addWidget(label, 0, 0);
45 m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); 47 m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF"));
46 QWhatsThis::add(m_background, tr("Background color to be used in chats")); 48 QWhatsThis::add(m_background, tr("Background color to be used in chats"));
47 layout->addWidget(m_background, 0, 1); 49 layout->addWidget(m_background, 0, 1);
48 label = new QLabel(tr("Normal text color :"), widget); 50 label = new QLabel(tr("Normal text color :"), widget);
49 layout->addWidget(label, 1, 0); 51 layout->addWidget(label, 1, 0);
50 m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); 52 m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000"));
51 QWhatsThis::add(m_text, tr("Text color to be used in chats")); 53 QWhatsThis::add(m_text, tr("Text color to be used in chats"));
52 layout->addWidget(m_text, 1, 1); 54 layout->addWidget(m_text, 1, 1);
53 label = new QLabel(tr("Error color :"), widget); 55 label = new QLabel(tr("Error color :"), widget);
54 layout->addWidget(label, 2, 0); 56 layout->addWidget(label, 2, 0);
55 m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); 57 m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000"));
56 QWhatsThis::add(m_error, tr("Text color to be used to display errors")); 58 QWhatsThis::add(m_error, tr("Text color to be used to display errors"));
57 layout->addWidget(m_error, 2, 1); 59 layout->addWidget(m_error, 2, 1);
58 label = new QLabel(tr("Text written by yourself :"), widget); 60 label = new QLabel(tr("Text written by yourself :"), widget);
59 layout->addWidget(label, 3, 0); 61 layout->addWidget(label, 3, 0);
60 m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); 62 m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000"));
61 QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); 63 QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself"));
62 layout->addWidget(m_self, 3, 1); 64 layout->addWidget(m_self, 3, 1);
63 label = new QLabel(tr("Text written by others :"), widget); 65 label = new QLabel(tr("Text written by others :"), widget);
64 layout->addWidget(label, 4, 0); 66 layout->addWidget(label, 4, 0);
65 m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); 67 m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB"));
66 QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); 68 QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others"));
67 layout->addWidget(m_other, 4, 1); 69 layout->addWidget(m_other, 4, 1);
68 label = new QLabel(tr("Text written by the server :"), widget); 70 label = new QLabel(tr("Text written by the server :"), widget);
69 layout->addWidget(label, 5, 0); 71 layout->addWidget(label, 5, 0);
70 m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); 72 m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF"));
71 QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); 73 QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server"));
72 layout->addWidget(m_server, 5, 1); 74 layout->addWidget(m_server, 5, 1);
73 label = new QLabel(tr("Notifications :"), widget); 75 label = new QLabel(tr("Notifications :"), widget);
74 layout->addWidget(label, 6, 0); 76 layout->addWidget(label, 6, 0);
75 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); 77 m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300"));
76 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); 78 QWhatsThis::add(m_notification, tr("Text color to be used to display notifications"));
77 layout->addWidget(m_notification, 6, 1); 79 layout->addWidget(m_notification, 6, 1);
78 tw->addTab(view, "opieirc/colors", tr("Colors")); 80 tw->addTab(view, "opieirc/colors", tr("Colors"));
79 tw->setCurrentTab( genwidget ); 81 tw->setCurrentTab( genwidget );
80 82
81 QPEApplication::showDialog( this ); 83 QPEApplication::showDialog( this );
82} 84}
83 85
84void IRCSettings::accept() 86void IRCSettings::accept()
85{ 87{
86 IRCTab::m_backgroundColor = m_background->color().name(); 88 IRCTab::m_backgroundColor = m_background->color().name();
87 IRCTab::m_textColor = m_text->color().name(); 89 IRCTab::m_textColor = m_text->color().name();
88 IRCTab::m_errorColor = m_error->color().name(); 90 IRCTab::m_errorColor = m_error->color().name();
89 IRCTab::m_selfColor = m_self->color().name(); 91 IRCTab::m_selfColor = m_self->color().name();
90 IRCTab::m_otherColor = m_other->color().name(); 92 IRCTab::m_otherColor = m_other->color().name();
91 IRCTab::m_serverColor = m_server->color().name(); 93 IRCTab::m_serverColor = m_server->color().name();
92 IRCTab::m_notificationColor = m_notification->color().name(); 94 IRCTab::m_notificationColor = m_notification->color().name();
93 IRCTab::m_maxLines = m_lines->text().toInt(); 95 IRCTab::m_maxLines = m_lines->text().toInt();
94 m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor); 96 m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor);
95 m_config->writeEntry("TextColor", IRCTab::m_textColor); 97 m_config->writeEntry("TextColor", IRCTab::m_textColor);
96 m_config->writeEntry("ErrorColor", IRCTab::m_errorColor); 98 m_config->writeEntry("ErrorColor", IRCTab::m_errorColor);
97 m_config->writeEntry("SelfColor", IRCTab::m_selfColor); 99 m_config->writeEntry("SelfColor", IRCTab::m_selfColor);
98 m_config->writeEntry("OtherColor", IRCTab::m_otherColor); 100 m_config->writeEntry("OtherColor", IRCTab::m_otherColor);
99 m_config->writeEntry("ServerColor", IRCTab::m_serverColor); 101 m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
100 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); 102 m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
101 m_config->writeEntry("Lines", m_lines->text()); 103 m_config->writeEntry("Lines", m_lines->text());
102 QDialog::accept(); 104 QDialog::accept();
103} 105}
104 106
105IRCSettings::~IRCSettings() 107IRCSettings::~IRCSettings()
106{ 108{
107 delete m_config; 109 delete m_config;
108} 110}
diff --git a/noncore/net/opieirc/ircsettings.h b/noncore/net/opieirc/ircsettings.h
index cb8d896..56e667b 100644
--- a/noncore/net/opieirc/ircsettings.h
+++ b/noncore/net/opieirc/ircsettings.h
@@ -1,49 +1,51 @@
1/* 1/*
2 OpieIRC - An embedded IRC client 2 OpieIRC - An embedded IRC client
3 Copyright (C) 2002 Wenzel Jakob 3 Copyright (C) 2002 Wenzel Jakob
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18
19*/ 19*/
20 20
21#ifndef __IRCSETTINGS_H 21#ifndef __IRCSETTINGS_H
22#define __IRCSETTINGS_H 22#define __IRCSETTINGS_H
23 23
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qdialog.h> 25#include <qdialog.h>
26#include <qlineedit.h> 26#include <qlineedit.h>
27 27
28namespace Opie {
28class OColorButton; 29class OColorButton;
30}
29 31
30class IRCSettings : public QDialog { 32class IRCSettings : public QDialog {
31 Q_OBJECT 33 Q_OBJECT
32public: 34public:
33 IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0); 35 IRCSettings(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags f = 0);
34 ~IRCSettings(); 36 ~IRCSettings();
35protected slots: 37protected slots:
36 void accept(); 38 void accept();
37protected: 39protected:
38 Config *m_config; 40 Config *m_config;
39 OColorButton *m_background; 41 Opie::OColorButton *m_background;
40 OColorButton *m_text; 42 Opie::OColorButton *m_text;
41 OColorButton *m_error; 43 Opie::OColorButton *m_error;
42 OColorButton *m_self; 44 Opie::OColorButton *m_self;
43 OColorButton *m_server; 45 Opie::OColorButton *m_server;
44 OColorButton *m_other; 46 Opie::OColorButton *m_other;
45 OColorButton *m_notification; 47 Opie::OColorButton *m_notification;
46 QLineEdit *m_lines; 48 QLineEdit *m_lines;
47}; 49};
48 50
49#endif /* __IRCSETTINGS_H */ 51#endif /* __IRCSETTINGS_H */
diff --git a/noncore/net/opieirc/main.cpp b/noncore/net/opieirc/main.cpp
index da38024..f3cbecc 100644
--- a/noncore/net/opieirc/main.cpp
+++ b/noncore/net/opieirc/main.cpp
@@ -1,6 +1,7 @@
1#include "mainwindow.h" 1#include "mainwindow.h"
2 2
3#include <opie/oapplicationfactory.h> 3#include <opie2/oapplicationfactory.h>
4 4
5 5
6using namespace Opie::Core;
6OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) 7OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro
index 537f810..9039ff8 100644
--- a/noncore/net/opieirc/opieirc.pro
+++ b/noncore/net/opieirc/opieirc.pro
@@ -1,25 +1,25 @@
1 CONFIG = qt warn_on release quick-app 1 CONFIG = qt warn_on release quick-app
2 HEADERS = ircchannel.h ircconnection.h \ 2 HEADERS = ircchannel.h ircconnection.h \
3 ircmessage.h \ 3 ircmessage.h \
4 ircmessageparser.h ircoutput.h \ 4 ircmessageparser.h ircoutput.h \
5 ircperson.h ircserver.h ircsession.h \ 5 ircperson.h ircserver.h ircsession.h \
6 mainwindow.h irctab.h ircservertab.h \ 6 mainwindow.h irctab.h ircservertab.h \
7 ircchanneltab.h ircchannellist.h \ 7 ircchanneltab.h ircchannellist.h \
8 ircserverlist.h ircservereditor.h \ 8 ircserverlist.h ircservereditor.h \
9 ircquerytab.h ircsettings.h ircmisc.h 9 ircquerytab.h ircsettings.h ircmisc.h
10 SOURCES = ircchannel.cpp ircconnection.cpp \ 10 SOURCES = ircchannel.cpp ircconnection.cpp \
11 ircmessage.cpp \ 11 ircmessage.cpp \
12 ircmessageparser.cpp ircoutput.cpp \ 12 ircmessageparser.cpp ircoutput.cpp \
13 ircperson.cpp ircserver.cpp \ 13 ircperson.cpp ircserver.cpp \
14 ircsession.cpp main.cpp mainwindow.cpp \ 14 ircsession.cpp main.cpp mainwindow.cpp \
15 irctab.cpp ircservertab.cpp \ 15 irctab.cpp ircservertab.cpp \
16 ircchanneltab.cpp ircchannellist.cpp \ 16 ircchanneltab.cpp ircchannellist.cpp \
17 ircserverlist.cpp ircservereditor.cpp \ 17 ircserverlist.cpp ircservereditor.cpp \
18 ircquerytab.cpp ircsettings.cpp ircmisc.cpp 18 ircquerytab.cpp ircsettings.cpp ircmisc.cpp
19INCLUDEPATH += $(OPIEDIR)/include 19INCLUDEPATH += $(OPIEDIR)/include
20 DEPENDPATH+= $(OPIEDIR)/include 20 DEPENDPATH+= $(OPIEDIR)/include
21LIBS += -lqpe -lopie 21LIBS += -lqpe -lopieui2 -lqtaux2
22 22
23 TARGET= opieirc 23 TARGET= opieirc
24 24
25include ( $(OPIEDIR)/include.pro ) 25include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index 817936d..93b2c67 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -1,221 +1,221 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de> 3             .=l. Copyright (c) 2002 Maximilian Reiss <max.reiss@gmx.de>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB. 22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30#include "bluezapplet.h" 30#include "bluezapplet.h"
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36 36
37#include <opie/odevice.h> 37#include <opie2/odevice.h>
38 38
39#include <qpoint.h> 39#include <qpoint.h>
40#include <qpainter.h> 40#include <qpainter.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qpixmap.h> 43#include <qpixmap.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qtimer.h> 45#include <qtimer.h>
46#include <qpopupmenu.h> 46#include <qpopupmenu.h>
47 47
48#include <device.h> 48#include <device.h>
49 49
50using namespace Opie; 50using namespace Opie;
51 51
52namespace OpieTooth { 52namespace OpieTooth {
53 53
54 BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) { 54 BluezApplet::BluezApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) {
55 setFixedHeight( 18 ); 55 setFixedHeight( 18 );
56 setFixedWidth( 14 ); 56 setFixedWidth( 14 );
57 bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" ); 57 bluezOnPixmap = Resource::loadPixmap( "bluetoothapplet/bluezon" );
58 bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" ); 58 bluezOffPixmap = Resource::loadPixmap( "bluetoothapplet/bluezoff" );
59 // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" ); 59 // bluezDiscoveryOnPixmap = Resource::loadPixmap( "bluetoothapplet/magglass" );
60 startTimer(4000); 60 startTimer(4000);
61 btDevice = 0; 61 btDevice = 0;
62 bluezactive = false; 62 bluezactive = false;
63 bluezDiscoveryActive = false; 63 bluezDiscoveryActive = false;
64 64
65 } 65 }
66 66
67 BluezApplet::~BluezApplet() { 67 BluezApplet::~BluezApplet() {
68 if ( btDevice ) { 68 if ( btDevice ) {
69 delete btDevice; 69 delete btDevice;
70 } 70 }
71 } 71 }
72 72
73 bool BluezApplet::checkBluezStatus() { 73 bool BluezApplet::checkBluezStatus() {
74 if (btDevice) { 74 if (btDevice) {
75 if (btDevice->isLoaded() ) { 75 if (btDevice->isLoaded() ) {
76 return true; 76 return true;
77 } else { 77 } else {
78 return false; 78 return false;
79 } 79 }
80 } else { 80 } else {
81 return false; 81 return false;
82 } 82 }
83 } 83 }
84 84
85 int BluezApplet::setBluezStatus(int c) { 85 int BluezApplet::setBluezStatus(int c) {
86 86
87 if ( c == 1 ) { 87 if ( c == 1 ) {
88 switch ( ODevice::inst()->model() ) { 88 switch ( ODevice::inst()->model() ) {
89 case Model_iPAQ_H39xx: 89 case Model_iPAQ_H39xx:
90 btDevice = new Device( "/dev/tts/1", "bcsp", "921600" ); 90 btDevice = new Device( "/dev/tts/1", "bcsp", "921600" );
91 break; 91 break;
92 92
93 case Model_iPAQ_H5xxx: 93 case Model_iPAQ_H5xxx:
94 btDevice = new Device( "/dev/tts/1", "any", "921600" ); 94 btDevice = new Device( "/dev/tts/1", "any", "921600" );
95 break; 95 break;
96 96
97 default: 97 default:
98 btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" ); 98 btDevice = new Device( "/dev/ttySB0", "bcsp", "230400" );
99 break; 99 break;
100 } 100 }
101 } else { 101 } else {
102 if ( btDevice ) { 102 if ( btDevice ) {
103 delete btDevice; 103 delete btDevice;
104 btDevice = 0; 104 btDevice = 0;
105 } 105 }
106 } 106 }
107 return 0; 107 return 0;
108 } 108 }
109 109
110 int BluezApplet::checkBluezDiscoveryStatus() { 110 int BluezApplet::checkBluezDiscoveryStatus() {
111 } 111 }
112 112
113 int BluezApplet::setBluezDiscoveryStatus(int d) { 113 int BluezApplet::setBluezDiscoveryStatus(int d) {
114 } 114 }
115 115
116 void BluezApplet::mousePressEvent( QMouseEvent *) { 116 void BluezApplet::mousePressEvent( QMouseEvent *) {
117 117
118 QPopupMenu *menu = new QPopupMenu(); 118 QPopupMenu *menu = new QPopupMenu();
119 QPopupMenu *signal = new QPopupMenu(); 119 QPopupMenu *signal = new QPopupMenu();
120 int ret=0; 120 int ret=0;
121 121
122 /* Refresh active state */ 122 /* Refresh active state */
123 timerEvent( 0 ); 123 timerEvent( 0 );
124 124
125 125
126 if (bluezactive) { 126 if (bluezactive) {
127 menu->insertItem( tr("Disable Bluetooth"), 0 ); 127 menu->insertItem( tr("Disable Bluetooth"), 0 );
128 } else { 128 } else {
129 menu->insertItem( tr("Enable Bluetooth"), 1 ); 129 menu->insertItem( tr("Enable Bluetooth"), 1 );
130 } 130 }
131 131
132 menu->insertItem( tr("Launch manager"), 2 ); 132 menu->insertItem( tr("Launch manager"), 2 );
133 133
134 menu->insertSeparator(6); 134 menu->insertSeparator(6);
135 //menu->insertItem( tr("Signal strength"), signal, 5); 135 //menu->insertItem( tr("Signal strength"), signal, 5);
136 //menu->insertSeparator(8); 136 //menu->insertSeparator(8);
137 137
138 if (bluezDiscoveryActive) { 138 if (bluezDiscoveryActive) {
139 menu->insertItem( tr("Disable discovery"), 3 ); 139 menu->insertItem( tr("Disable discovery"), 3 );
140 } else { 140 } else {
141 menu->insertItem( tr("Enable discovery"), 4 ); 141 menu->insertItem( tr("Enable discovery"), 4 );
142 } 142 }
143 143
144 144
145 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) ); 145 QPoint p = mapToGlobal( QPoint(1, -menu->sizeHint().height()-1) );
146 ret = menu->exec(p, 0); 146 ret = menu->exec(p, 0);
147 147
148 switch(ret) { 148 switch(ret) {
149 case 0: 149 case 0:
150 setBluezStatus(0); 150 setBluezStatus(0);
151 timerEvent( 0 ); 151 timerEvent( 0 );
152 break; 152 break;
153 case 1: 153 case 1:
154 setBluezStatus(1); 154 setBluezStatus(1);
155 timerEvent( 0 ); 155 timerEvent( 0 );
156 break; 156 break;
157 case 2: 157 case 2:
158 // start bluetoothmanager 158 // start bluetoothmanager
159 launchManager(); 159 launchManager();
160 timerEvent( 0 ); 160 timerEvent( 0 );
161 break; 161 break;
162 case 3: 162 case 3:
163 setBluezDiscoveryStatus(0); 163 setBluezDiscoveryStatus(0);
164 timerEvent( 0 ); 164 timerEvent( 0 );
165 break; 165 break;
166 case 4: 166 case 4:
167 setBluezDiscoveryStatus(1); 167 setBluezDiscoveryStatus(1);
168 timerEvent(0 ); 168 timerEvent(0 );
169 break; 169 break;
170 //case 7: 170 //case 7:
171 // With table of currently-detected devices. 171 // With table of currently-detected devices.
172 } 172 }
173 173
174 delete signal; 174 delete signal;
175 delete menu; 175 delete menu;
176 } 176 }
177 177
178 178
179/** 179/**
180 * Launches the bluetooth manager 180 * Launches the bluetooth manager
181 */ 181 */
182 void BluezApplet::launchManager() { 182 void BluezApplet::launchManager() {
183 QCopEnvelope e("QPE/System", "execute(QString)"); 183 QCopEnvelope e("QPE/System", "execute(QString)");
184 e << QString("bluetooth-manager"); 184 e << QString("bluetooth-manager");
185 } 185 }
186 186
187/** 187/**
188 * Refresh timer 188 * Refresh timer
189 * @param the timer event 189 * @param the timer event
190 */ 190 */
191 void BluezApplet::timerEvent( QTimerEvent * ) { 191 void BluezApplet::timerEvent( QTimerEvent * ) {
192 bool oldactive = bluezactive; 192 bool oldactive = bluezactive;
193 int olddiscovery = bluezDiscoveryActive; 193 int olddiscovery = bluezDiscoveryActive;
194 194
195 bluezactive = checkBluezStatus(); 195 bluezactive = checkBluezStatus();
196 bluezDiscoveryActive = checkBluezDiscoveryStatus(); 196 bluezDiscoveryActive = checkBluezDiscoveryStatus();
197 197
198 if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) { 198 if ((bluezactive != oldactive) || (bluezDiscoveryActive != olddiscovery)) {
199 update(); 199 update();
200 } 200 }
201 } 201 }
202 202
203/** 203/**
204 * Implementation of the paint event 204 * Implementation of the paint event
205 * @param the QPaintEvent 205 * @param the QPaintEvent
206 */ 206 */
207 void BluezApplet::paintEvent( QPaintEvent* ) { 207 void BluezApplet::paintEvent( QPaintEvent* ) {
208 QPainter p(this); 208 QPainter p(this);
209 qDebug("paint bluetooth pixmap"); 209 qDebug("paint bluetooth pixmap");
210 210
211 if (bluezactive > 0) { 211 if (bluezactive > 0) {
212 p.drawPixmap( 0, 1, bluezOnPixmap ); 212 p.drawPixmap( 0, 1, bluezOnPixmap );
213 } else { 213 } else {
214 p.drawPixmap( 0, 1, bluezOffPixmap ); 214 p.drawPixmap( 0, 1, bluezOffPixmap );
215 } 215 }
216 216
217 if (bluezDiscoveryActive > 0) { 217 if (bluezDiscoveryActive > 0) {
218 p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap ); 218 p.drawPixmap( 0, 1, bluezDiscoveryOnPixmap );
219 } 219 }
220 } 220 }
221}; 221};
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index bae1c47..d913853 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -1,151 +1,153 @@
1 1
2#include <signal.h> 2#include <signal.h>
3 3
4#include <opie/oprocess.h> 4#include <opie2/oprocess.h>
5 5
6#include "device.h" 6#include "device.h"
7 7
8using namespace OpieTooth; 8using namespace OpieTooth;
9 9
10using namespace Opie::Core;
11using namespace Opie::Core;
10namespace { 12namespace {
11 int parsePid( const QCString& par ){ 13 int parsePid( const QCString& par ){
12 int id=0; 14 int id=0;
13 QString string( par ); 15 QString string( par );
14 QStringList list = QStringList::split( '\n', string ); 16 QStringList list = QStringList::split( '\n', string );
15 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 17 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
16 qWarning("parsePID: %s", (*it).latin1() ); 18 qWarning("parsePID: %s", (*it).latin1() );
17 if( !(*it).startsWith("CSR") ){ 19 if( !(*it).startsWith("CSR") ){
18 id = (*it).toInt(); 20 id = (*it).toInt();
19 break; 21 break;
20 } 22 }
21 } 23 }
22 return id; 24 return id;
23 } 25 }
24} 26}
25 27
26Device::Device(const QString &device, const QString &mode, const QString &speed ) 28Device::Device(const QString &device, const QString &mode, const QString &speed )
27 : QObject(0, "device") { 29 : QObject(0, "device") {
28 30
29 qWarning("OpieTooth::Device create" ); 31 qWarning("OpieTooth::Device create" );
30 m_hci = 0; 32 m_hci = 0;
31 m_process = 0; 33 m_process = 0;
32 m_attached = false; 34 m_attached = false;
33 m_device = device; 35 m_device = device;
34 m_mode = mode; 36 m_mode = mode;
35 m_speed = speed; 37 m_speed = speed;
36 attach(); 38 attach();
37} 39}
38Device::~Device(){ 40Device::~Device(){
39 detach(); 41 detach();
40} 42}
41void Device::attach(){ 43void Device::attach(){
42 qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() ); 44 qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() );
43 if(m_process == 0 ){ 45 if(m_process == 0 ){
44 m_output.resize(0); 46 m_output.resize(0);
45 qWarning("new process to create" ); 47 qWarning("new process to create" );
46 m_process = new OProcess(); 48 m_process = new OProcess();
47 *m_process << "hciattach"; 49 *m_process << "hciattach";
48 *m_process << "-p"; 50 *m_process << "-p";
49 *m_process << m_device << m_mode << m_speed; 51 *m_process << m_device << m_mode << m_speed;
50 connect(m_process, SIGNAL( processExited(OProcess*) ), 52 connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
51 this, SLOT( slotExited(OProcess* ) ) ); 53 this, SLOT( slotExited(OProcess* ) ) );
52 connect(m_process, SIGNAL( receivedStdout(OProcess*, char*, int) ), 54 connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ),
53 this, SLOT(slotStdOut(OProcess*,char*,int ) ) ); 55 this, SLOT(slotStdOut(OProcess*,char*,int ) ) );
54 connect(m_process, SIGNAL(receivedStderr(OProcess*, char*, int ) ), 56 connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ),
55 this, SLOT(slotStdErr(OProcess*,char*,int) ) ); 57 this, SLOT(slotStdErr(OProcess*,char*,int) ) );
56 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ 58 if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){
57 qWarning("Could not start" ); 59 qWarning("Could not start" );
58 delete m_process; 60 delete m_process;
59 m_process = 0; 61 m_process = 0;
60 } 62 }
61 }; 63 };
62} 64}
63void Device::detach(){ 65void Device::detach(){
64 delete m_hci; 66 delete m_hci;
65 delete m_process; 67 delete m_process;
66 // kill the pid we got 68 // kill the pid we got
67 if(m_attached ){ 69 if(m_attached ){
68 //kill the pid 70 //kill the pid
69 qWarning( "killing" ); 71 qWarning( "killing" );
70 kill(pid, 9); 72 kill(pid, 9);
71 } 73 }
72 qWarning("detached" ); 74 qWarning("detached" );
73} 75}
74bool Device::isLoaded()const{ 76bool Device::isLoaded()const{
75 return m_attached; 77 return m_attached;
76} 78}
77QString Device::devName()const { 79QString Device::devName()const {
78 return QString::fromLatin1("hci0"); 80 return QString::fromLatin1("hci0");
79}; 81};
80void Device::slotExited( OProcess* proc) 82void Device::slotExited( OProcess* proc)
81{ 83{
82 qWarning("prcess exited" ); 84 qWarning("prcess exited" );
83 if(proc== m_process ){ 85 if(proc== m_process ){
84 qWarning("proc == m_process" ); 86 qWarning("proc == m_process" );
85 if( m_process->normalExit() ){ // normal exit 87 if( m_process->normalExit() ){ // normal exit
86 qWarning("normalExit" ); 88 qWarning("normalExit" );
87 int ret = m_process->exitStatus(); 89 int ret = m_process->exitStatus();
88 if( ret == 0 ){ // attached 90 if( ret == 0 ){ // attached
89 qWarning("attached" ); 91 qWarning("attached" );
90 qWarning("Output: %s", m_output.data() ); 92 qWarning("Output: %s", m_output.data() );
91 pid = parsePid( m_output ); 93 pid = parsePid( m_output );
92 qWarning("Pid = %d", pid ); 94 qWarning("Pid = %d", pid );
93 // now hciconfig hci0 up ( determine hciX FIXME) 95 // now hciconfig hci0 up ( determine hciX FIXME)
94 // and call hciconfig hci0 up 96 // and call hciconfig hci0 up
95 // FIXME hardcoded to hci0 now :( 97 // FIXME hardcoded to hci0 now :(
96 m_hci = new OProcess( ); 98 m_hci = new OProcess( );
97 *m_hci << "hciconfig"; 99 *m_hci << "hciconfig";
98 *m_hci << "hci0 up"; 100 *m_hci << "hci0 up";
99 connect(m_hci, SIGNAL( processExited(OProcess*) ), 101 connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
100 this, SLOT( slotExited(OProcess* ) ) ); 102 this, SLOT( slotExited(OProcess* ) ) );
101 if(!m_hci->start() ){ 103 if(!m_hci->start() ){
102 qWarning("could not start" ); 104 qWarning("could not start" );
103 m_attached = false; 105 m_attached = false;
104 emit device("hci0", false ); 106 emit device("hci0", false );
105 } 107 }
106 }else{ 108 }else{
107 qWarning("crass" ); 109 qWarning("crass" );
108 m_attached = false; 110 m_attached = false;
109 emit device("hci0", false ); 111 emit device("hci0", false );
110 112
111 } 113 }
112 } 114 }
113 delete m_process; 115 delete m_process;
114 m_process = 0; 116 m_process = 0;
115 }else if(proc== m_hci ){ 117 }else if(proc== m_hci ){
116 qWarning("M HCI exited" ); 118 qWarning("M HCI exited" );
117 if( m_hci->normalExit() ){ 119 if( m_hci->normalExit() ){
118 qWarning("normal exit" ); 120 qWarning("normal exit" );
119 int ret = m_hci->exitStatus(); 121 int ret = m_hci->exitStatus();
120 if( ret == 0 ){ 122 if( ret == 0 ){
121 qWarning("attached really really attached" ); 123 qWarning("attached really really attached" );
122 m_attached = true; 124 m_attached = true;
123 emit device("hci0", true ); 125 emit device("hci0", true );
124 }else{ 126 }else{
125 qWarning( "failed" ); 127 qWarning( "failed" );
126 emit device("hci0", false ); 128 emit device("hci0", false );
127 m_attached = false; 129 m_attached = false;
128 } 130 }
129 }// normal exit 131 }// normal exit
130 delete m_hci; 132 delete m_hci;
131 m_hci = 0; 133 m_hci = 0;
132 } 134 }
133} 135}
134void Device::slotStdOut(OProcess* proc, char* chars, int len) 136void Device::slotStdOut(OProcess* proc, char* chars, int len)
135{ 137{
136 qWarning("std out" ); 138 qWarning("std out" );
137 if( len <1 ){ 139 if( len <1 ){
138 qWarning( "len < 1 " ); 140 qWarning( "len < 1 " );
139 return; 141 return;
140 } 142 }
141 if(proc == m_process ){ 143 if(proc == m_process ){
142 QCString string( chars, len+1 ); // \0 == +1 144 QCString string( chars, len+1 ); // \0 == +1
143 qWarning("output: %s", string.data() ); 145 qWarning("output: %s", string.data() );
144 m_output.append( string.data() ); 146 m_output.append( string.data() );
145 } 147 }
146} 148}
147void Device::slotStdErr(OProcess* proc, char* chars, int len) 149void Device::slotStdErr(OProcess* proc, char* chars, int len)
148{ 150{
149 qWarning("std err" ); 151 qWarning("std err" );
150 slotStdOut( proc, chars, len ); 152 slotStdOut( proc, chars, len );
151} 153}
diff --git a/noncore/net/opietooth/lib/device.h b/noncore/net/opietooth/lib/device.h
index ce7fccc..f3339fc 100644
--- a/noncore/net/opietooth/lib/device.h
+++ b/noncore/net/opietooth/lib/device.h
@@ -1,88 +1,88 @@
1 1
2#ifndef OpieToothDevice_H 2#ifndef OpieToothDevice_H
3#define OpieToothDevice_H 3#define OpieToothDevice_H
4 4
5#include <qobject.h> 5#include <qobject.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8 8
9#include <sys/types.h> 9#include <sys/types.h>
10 10
11class OProcess; 11namespace Opie {namespace Core {class Opie::Core::OProcess;}}
12namespace OpieTooth { 12namespace OpieTooth {
13 /** 13 /**
14 * Device takes care of attaching serial 14 * Device takes care of attaching serial
15 * devices to the blueZ stack. 15 * devices to the blueZ stack.
16 * After attaching it hciconfig ups it 16 * After attaching it hciconfig ups it
17 */ 17 */
18 class Device : public QObject { 18 class Device : public QObject {
19 19
20 Q_OBJECT 20 Q_OBJECT
21 21
22 public: 22 public:
23 23
24 /** 24 /**
25 * Brings up an device. 25 * Brings up an device.
26 * Usage example: new Device(/dev/ttySB0, csr) 26 * Usage example: new Device(/dev/ttySB0, csr)
27 * 27 *
28 * @param &device QString the device name 28 * @param &device QString the device name
29 * @param &mode QString the mode 29 * @param &mode QString the mode
30 * @param &speed QString the speed of the device, can be left blank 30 * @param &speed QString the speed of the device, can be left blank
31 */ 31 */
32 Device(const QString &device, const QString& mode, const QString& speed); 32 Device(const QString &device, const QString& mode, const QString& speed);
33 33
34 /** 34 /**
35 * unloads the device 35 * unloads the device
36 */ 36 */
37 ~Device(); 37 ~Device();
38 38
39 /** 39 /**
40 * attach the device 40 * attach the device
41 */ 41 */
42 void attach(); 42 void attach();
43 43
44 /** 44 /**
45 * detach the device 45 * detach the device
46 */ 46 */
47 void detach(); 47 void detach();
48 48
49 /** 49 /**
50 * Is the device loaded? 50 * Is the device loaded?
51 * @return bool, if the device is loaded 51 * @return bool, if the device is loaded
52 */ 52 */
53 bool isLoaded()const; 53 bool isLoaded()const;
54 54
55 /** 55 /**
56 * Returns the device name 56 * Returns the device name
57 * @return QString, the device name 57 * @return QString, the device name
58 */ 58 */
59 QString devName()const ; // hci0 59 QString devName()const ; // hci0
60 60
61 signals: 61 signals:
62 62
63 /** 63 /**
64 * Signals devicename and up status 64 * Signals devicename and up status
65 * @return &device QString, Devicename 65 * @return &device QString, Devicename
66 * @return up bool, if the device is up or not. 66 * @return up bool, if the device is up or not.
67 */ 67 */
68 void device(const QString& device, bool up ); 68 void device(const QString& device, bool up );
69 private slots: 69 private slots:
70 virtual void slotExited( OProcess* ); 70 virtual void slotExited( Opie::Core::OProcess* );
71 virtual void slotStdOut(OProcess*, char*, int ); 71 virtual void slotStdOut(Opie::Core::OProcess*, char*, int );
72 virtual void slotStdErr(OProcess*, char*, int ); 72 virtual void slotStdErr(Opie::Core::OProcess*, char*, int );
73 private: 73 private:
74 class Private; 74 class Private;
75 Private *d; 75 Private *d;
76 QString m_device; 76 QString m_device;
77 bool m_attached:1; 77 bool m_attached:1;
78 OProcess* m_hci; 78 Opie::Core::OProcess* m_hci;
79 OProcess* m_process; 79 Opie::Core::OProcess* m_process;
80 QString m_devId; 80 QString m_devId;
81 QString m_mode; 81 QString m_mode;
82 QString m_speed; 82 QString m_speed;
83 pid_t pid; 83 pid_t pid;
84 QCString m_output; 84 QCString m_output;
85 }; 85 };
86}; 86};
87 87
88#endif 88#endif
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index c89d325..56156a8 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -1,334 +1,336 @@
1 1
2 2
3#include <opie/oprocess.h> 3#include <opie2/oprocess.h>
4 4
5#include "parser.h" 5#include "parser.h"
6#include "manager.h" 6#include "manager.h"
7 7
8 8
9using namespace OpieTooth; 9using namespace OpieTooth;
10 10
11using namespace Opie::Core;
12using namespace Opie::Core;
11Manager::Manager( const QString& dev ) 13Manager::Manager( const QString& dev )
12 : QObject() 14 : QObject()
13{ 15{
14 qWarning("created"); 16 qWarning("created");
15 m_device = dev; 17 m_device = dev;
16 m_hcitool = 0; 18 m_hcitool = 0;
17 m_sdp = 0; 19 m_sdp = 0;
18} 20}
19Manager::Manager( Device* /*dev*/ ) 21Manager::Manager( Device* /*dev*/ )
20 : QObject() 22 : QObject()
21{ 23{
22 m_hcitool = 0; 24 m_hcitool = 0;
23 m_sdp = 0; 25 m_sdp = 0;
24} 26}
25Manager::Manager() 27Manager::Manager()
26 : QObject() 28 : QObject()
27{ 29{
28 m_hcitool = 0; 30 m_hcitool = 0;
29 m_sdp = 0; 31 m_sdp = 0;
30} 32}
31Manager::~Manager(){ 33Manager::~Manager(){
32 delete m_hcitool; 34 delete m_hcitool;
33 delete m_sdp; 35 delete m_sdp;
34} 36}
35void Manager::setDevice( const QString& dev ){ 37void Manager::setDevice( const QString& dev ){
36 m_device = dev; 38 m_device = dev;
37} 39}
38void Manager::setDevice( Device* /*dev*/ ){ 40void Manager::setDevice( Device* /*dev*/ ){
39 41
40} 42}
41void Manager::isAvailable( const QString& device ){ 43void Manager::isAvailable( const QString& device ){
42 OProcess* l2ping = new OProcess(); 44 OProcess* l2ping = new OProcess();
43 l2ping->setName( device.latin1() ); 45 l2ping->setName( device.latin1() );
44 *l2ping << "l2ping" << "-c1" << device; 46 *l2ping << "l2ping" << "-c1" << device;
45 connect(l2ping, SIGNAL(processExited(OProcess* ) ), 47 connect(l2ping, SIGNAL(processExited(Opie::Core::OProcess* ) ),
46 this, SLOT(slotProcessExited(OProcess*) ) ); 48 this, SLOT(slotProcessExited(OProcess*) ) );
47 if (!l2ping->start() ) { 49 if (!l2ping->start() ) {
48 emit available( device, false ); 50 emit available( device, false );
49 delete l2ping; 51 delete l2ping;
50 } 52 }
51 53
52} 54}
53 55
54void Manager::isAvailable( Device* /*dev*/ ){ 56void Manager::isAvailable( Device* /*dev*/ ){
55 57
56 58
57} 59}
58void Manager::searchDevices( const QString& device ){ 60void Manager::searchDevices( const QString& device ){
59 qWarning("search devices"); 61 qWarning("search devices");
60 OProcess* hcitool = new OProcess(); 62 OProcess* hcitool = new OProcess();
61 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 63 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
62 *hcitool << "hcitool" << "scan"; 64 *hcitool << "hcitool" << "scan";
63 connect( hcitool, SIGNAL(processExited(OProcess*) ) , 65 connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) ,
64 this, SLOT(slotHCIExited(OProcess* ) ) ); 66 this, SLOT(slotHCIExited(OProcess* ) ) );
65 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 67 connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
66 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); 68 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
67 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 69 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
68 qWarning("could not start"); 70 qWarning("could not start");
69 RemoteDevice::ValueList list; 71 RemoteDevice::ValueList list;
70 emit foundDevices( device, list ); 72 emit foundDevices( device, list );
71 delete hcitool; 73 delete hcitool;
72 } 74 }
73} 75}
74 76
75void Manager::searchDevices(Device* /*d*/ ){ 77void Manager::searchDevices(Device* /*d*/ ){
76 78
77 79
78} 80}
79void Manager::addService(const QString& name ){ 81void Manager::addService(const QString& name ){
80 OProcess proc; 82 OProcess proc;
81 proc << "sdptool" << "add" << name; 83 proc << "sdptool" << "add" << name;
82 bool bo = true; 84 bool bo = true;
83 if (!proc.start(OProcess::DontCare ) ) 85 if (!proc.start(OProcess::DontCare ) )
84 bo = false; 86 bo = false;
85 emit addedService( name, bo ); 87 emit addedService( name, bo );
86} 88}
87void Manager::addServices(const QStringList& list){ 89void Manager::addServices(const QStringList& list){
88 QStringList::ConstIterator it; 90 QStringList::ConstIterator it;
89 for (it = list.begin(); it != list.end(); ++it ) 91 for (it = list.begin(); it != list.end(); ++it )
90 addService( (*it) ); 92 addService( (*it) );
91} 93}
92void Manager::removeService( const QString& name ){ 94void Manager::removeService( const QString& name ){
93 OProcess prc; 95 OProcess prc;
94 prc << "sdptool" << "del" << name; 96 prc << "sdptool" << "del" << name;
95 bool bo = true; 97 bool bo = true;
96 if (!prc.start(OProcess::DontCare ) ) 98 if (!prc.start(OProcess::DontCare ) )
97 bo = false; 99 bo = false;
98 emit removedService( name, bo ); 100 emit removedService( name, bo );
99} 101}
100void Manager::removeServices( const QStringList& list){ 102void Manager::removeServices( const QStringList& list){
101 QStringList::ConstIterator it; 103 QStringList::ConstIterator it;
102 for (it = list.begin(); it != list.end(); ++it ) 104 for (it = list.begin(); it != list.end(); ++it )
103 removeService( (*it) ); 105 removeService( (*it) );
104} 106}
105void Manager::searchServices( const QString& remDevice ){ 107void Manager::searchServices( const QString& remDevice ){
106 OProcess *m_sdp =new OProcess(); 108 OProcess *m_sdp =new OProcess();
107 *m_sdp << "sdptool" << "browse" << remDevice; 109 *m_sdp << "sdptool" << "browse" << remDevice;
108 m_sdp->setName( remDevice.latin1() ); 110 m_sdp->setName( remDevice.latin1() );
109 qWarning("search Services for %s", remDevice.latin1() ); 111 qWarning("search Services for %s", remDevice.latin1() );
110 connect(m_sdp, SIGNAL(processExited(OProcess*) ), 112 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ),
111 this, SLOT(slotSDPExited(OProcess* ) ) ); 113 this, SLOT(slotSDPExited(OProcess* ) ) );
112 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 114 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
113 this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); 115 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
114 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 116 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
115 qWarning("could not start sdptool" ); 117 qWarning("could not start sdptool" );
116 delete m_sdp; 118 delete m_sdp;
117 Services::ValueList list; 119 Services::ValueList list;
118 emit foundServices( remDevice, list ); 120 emit foundServices( remDevice, list );
119 } 121 }
120} 122}
121void Manager::searchServices( const RemoteDevice& dev){ 123void Manager::searchServices( const RemoteDevice& dev){
122 searchServices( dev.mac() ); 124 searchServices( dev.mac() );
123} 125}
124QString Manager::toDevice( const QString& /*mac*/ ){ 126QString Manager::toDevice( const QString& /*mac*/ ){
125 return QString::null; 127 return QString::null;
126} 128}
127QString Manager::toMac( const QString &/*device*/ ){ 129QString Manager::toMac( const QString &/*device*/ ){
128 return QString::null; 130 return QString::null;
129} 131}
130void Manager::slotProcessExited(OProcess* proc ) { 132void Manager::slotProcessExited(OProcess* proc ) {
131 bool conn= false; 133 bool conn= false;
132 if (proc->normalExit() && proc->exitStatus() == 0 ) 134 if (proc->normalExit() && proc->exitStatus() == 0 )
133 conn = true; 135 conn = true;
134 136
135 QString name = QString::fromLatin1(proc->name() ); 137 QString name = QString::fromLatin1(proc->name() );
136 emit available( name, conn ); 138 emit available( name, conn );
137 delete proc; 139 delete proc;
138} 140}
139void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 141void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
140{ 142{
141 QCString str(ch, len+1 ); 143 QCString str(ch, len+1 );
142 qWarning("SDP:%s", str.data() ); 144 qWarning("SDP:%s", str.data() );
143 QMap<QString, QString>::Iterator it; 145 QMap<QString, QString>::Iterator it;
144 it = m_out.find(proc->name() ); 146 it = m_out.find(proc->name() );
145 QString string; 147 QString string;
146 if ( it != m_out.end() ) { 148 if ( it != m_out.end() ) {
147 string = it.data(); 149 string = it.data();
148 } 150 }
149 string.append( str ); 151 string.append( str );
150 m_out.replace( proc->name(), string ); 152 m_out.replace( proc->name(), string );
151 153
152} 154}
153void Manager::slotSDPExited( OProcess* proc) 155void Manager::slotSDPExited( OProcess* proc)
154{ 156{
155 qWarning("proc name %s", proc->name() ); 157 qWarning("proc name %s", proc->name() );
156 Services::ValueList list; 158 Services::ValueList list;
157 if (proc->normalExit() ) { 159 if (proc->normalExit() ) {
158 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 160 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
159 if ( it != m_out.end() ) { 161 if ( it != m_out.end() ) {
160 qWarning("found process" ); 162 qWarning("found process" );
161 list = parseSDPOutput( it.data() ); 163 list = parseSDPOutput( it.data() );
162 m_out.remove( it ); 164 m_out.remove( it );
163 } 165 }
164 } 166 }
165 emit foundServices( proc->name(), list ); 167 emit foundServices( proc->name(), list );
166 delete proc; 168 delete proc;
167} 169}
168Services::ValueList Manager::parseSDPOutput( const QString& out ) { 170Services::ValueList Manager::parseSDPOutput( const QString& out ) {
169 Services::ValueList list; 171 Services::ValueList list;
170 qWarning("parsing output" ); 172 qWarning("parsing output" );
171 Parser parser( out ); 173 Parser parser( out );
172 list = parser.services(); 174 list = parser.services();
173 return list; 175 return list;
174} 176}
175 177
176void Manager::slotHCIExited(OProcess* proc ) { 178void Manager::slotHCIExited(OProcess* proc ) {
177 qWarning("process exited"); 179 qWarning("process exited");
178 RemoteDevice::ValueList list; 180 RemoteDevice::ValueList list;
179 if (proc->normalExit() ) { 181 if (proc->normalExit() ) {
180 qWarning("normalExit %s", proc->name() ); 182 qWarning("normalExit %s", proc->name() );
181 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 183 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
182 if (it != m_devices.end() ) { 184 if (it != m_devices.end() ) {
183 qWarning("!= end ;)"); 185 qWarning("!= end ;)");
184 list = parseHCIOutput( it.data() ); 186 list = parseHCIOutput( it.data() );
185 m_devices.remove( it ); 187 m_devices.remove( it );
186 } 188 }
187 } 189 }
188 emit foundDevices( proc->name(), list ); 190 emit foundDevices( proc->name(), list );
189 delete proc; 191 delete proc;
190} 192}
191void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 193void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
192 QCString str( ch, len+1 ); 194 QCString str( ch, len+1 );
193 qWarning("hci: %s", str.data() ); 195 qWarning("hci: %s", str.data() );
194 QMap<QString, QString>::Iterator it; 196 QMap<QString, QString>::Iterator it;
195 it = m_devices.find( proc->name() ); 197 it = m_devices.find( proc->name() );
196 qWarning("proc->name %s", proc->name() ); 198 qWarning("proc->name %s", proc->name() );
197 QString string; 199 QString string;
198 if (it != m_devices.end() ) { 200 if (it != m_devices.end() ) {
199 qWarning("slotHCIOut "); 201 qWarning("slotHCIOut ");
200 string = it.data(); 202 string = it.data();
201 } 203 }
202 string.append( str ); 204 string.append( str );
203 205
204 m_devices.replace( proc->name(), string ); 206 m_devices.replace( proc->name(), string );
205} 207}
206RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { 208RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
207 qWarning("parseHCI %s", output.latin1() ); 209 qWarning("parseHCI %s", output.latin1() );
208 RemoteDevice::ValueList list; 210 RemoteDevice::ValueList list;
209 QStringList strList = QStringList::split('\n', output ); 211 QStringList strList = QStringList::split('\n', output );
210 QStringList::Iterator it; 212 QStringList::Iterator it;
211 QString str; 213 QString str;
212 for ( it = strList.begin(); it != strList.end(); ++it ) { 214 for ( it = strList.begin(); it != strList.end(); ++it ) {
213 str = (*it).stripWhiteSpace(); 215 str = (*it).stripWhiteSpace();
214 qWarning("OpieTooth %s", str.latin1() ); 216 qWarning("OpieTooth %s", str.latin1() );
215 int pos = str.findRev(':' ); 217 int pos = str.findRev(':' );
216 if ( pos > 0 ) { 218 if ( pos > 0 ) {
217 QString mac = str.left(17 ); 219 QString mac = str.left(17 );
218 str.remove( 0, 17 ); 220 str.remove( 0, 17 );
219 qWarning("mac %s", mac.latin1() ); 221 qWarning("mac %s", mac.latin1() );
220 qWarning("rest:%s", str.latin1() ); 222 qWarning("rest:%s", str.latin1() );
221 RemoteDevice rem( mac , str.stripWhiteSpace() ); 223 RemoteDevice rem( mac , str.stripWhiteSpace() );
222 list.append( rem ); 224 list.append( rem );
223 } 225 }
224 } 226 }
225 return list; 227 return list;
226} 228}
227 229
228////// hcitool cc and hcitool con 230////// hcitool cc and hcitool con
229 231
230/** 232/**
231 * Create it on the stack as don't care 233 * Create it on the stack as don't care
232 * so we don't need to care for it 234 * so we don't need to care for it
233 * cause hcitool gets reparented 235 * cause hcitool gets reparented
234 */ 236 */
235void Manager::connectTo( const QString& mac) { 237void Manager::connectTo( const QString& mac) {
236 OProcess proc; 238 OProcess proc;
237 proc << "hcitool"; 239 proc << "hcitool";
238 proc << "cc"; 240 proc << "cc";
239 proc << mac; 241 proc << mac;
240 proc.start(OProcess::DontCare); // the lib does not care at this point 242 proc.start(OProcess::DontCare); // the lib does not care at this point
241} 243}
242 244
243 245
244void Manager::searchConnections() { 246void Manager::searchConnections() {
245 qWarning("searching connections?"); 247 qWarning("searching connections?");
246 OProcess* proc = new OProcess(); 248 OProcess* proc = new OProcess();
247 m_hcitoolCon = QString::null; 249 m_hcitoolCon = QString::null;
248 250
249 connect(proc, SIGNAL(processExited(OProcess*) ), 251 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
250 this, SLOT(slotConnectionExited( OProcess*) ) ); 252 this, SLOT(slotConnectionExited( OProcess*) ) );
251 connect(proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), 253 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
252 this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); 254 this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) );
253 *proc << "hcitool"; 255 *proc << "hcitool";
254 *proc << "con"; 256 *proc << "con";
255 257
256 if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 258 if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
257 ConnectionState::ValueList list; 259 ConnectionState::ValueList list;
258 emit connections( list ); 260 emit connections( list );
259 delete proc; 261 delete proc;
260 } 262 }
261} 263}
262void Manager::slotConnectionExited( OProcess* proc ) { 264void Manager::slotConnectionExited( OProcess* proc ) {
263 ConnectionState::ValueList list; 265 ConnectionState::ValueList list;
264 list = parseConnections( m_hcitoolCon ); 266 list = parseConnections( m_hcitoolCon );
265 emit connections(list ); 267 emit connections(list );
266 delete proc; 268 delete proc;
267} 269}
268void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) { 270void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) {
269 QCString str(cha, len ); 271 QCString str(cha, len );
270 m_hcitoolCon.append( str ); 272 m_hcitoolCon.append( str );
271 //delete proc; 273 //delete proc;
272} 274}
273ConnectionState::ValueList Manager::parseConnections( const QString& out ) { 275ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
274 ConnectionState::ValueList list2; 276 ConnectionState::ValueList list2;
275 QStringList list = QStringList::split('\n', out ); 277 QStringList list = QStringList::split('\n', out );
276 QStringList::Iterator it; 278 QStringList::Iterator it;
277 // remove the first line ( "Connections:") 279 // remove the first line ( "Connections:")
278 it = list.begin(); 280 it = list.begin();
279 it = list.remove( it ); 281 it = list.remove( it );
280 for (; it != list.end(); ++it ) { 282 for (; it != list.end(); ++it ) {
281 QString row = (*it).stripWhiteSpace(); 283 QString row = (*it).stripWhiteSpace();
282 QStringList value = QStringList::split(' ', row ); 284 QStringList value = QStringList::split(' ', row );
283 qWarning("0: %s", value[0].latin1() ); 285 qWarning("0: %s", value[0].latin1() );
284 qWarning("1: %s", value[1].latin1() ); 286 qWarning("1: %s", value[1].latin1() );
285 qWarning("2: %s", value[2].latin1() ); 287 qWarning("2: %s", value[2].latin1() );
286 qWarning("3: %s", value[3].latin1() ); 288 qWarning("3: %s", value[3].latin1() );
287 qWarning("4: %s", value[4].latin1() ); 289 qWarning("4: %s", value[4].latin1() );
288 qWarning("5: %s", value[5].latin1() ); 290 qWarning("5: %s", value[5].latin1() );
289 qWarning("6: %s", value[6].latin1() ); 291 qWarning("6: %s", value[6].latin1() );
290 qWarning("7: %s", value[7].latin1() ); 292 qWarning("7: %s", value[7].latin1() );
291 qWarning("8: %s", value[8].latin1() ); 293 qWarning("8: %s", value[8].latin1() );
292 ConnectionState con; 294 ConnectionState con;
293 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); 295 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
294 con.setConnectionMode( value[1] ); 296 con.setConnectionMode( value[1] );
295 con.setMac( value[2] ); 297 con.setMac( value[2] );
296 con.setHandle( value[4].toInt() ); 298 con.setHandle( value[4].toInt() );
297 con.setState( value[6].toInt() ); 299 con.setState( value[6].toInt() );
298 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); 300 con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client );
299 list2.append( con ); 301 list2.append( con );
300 } 302 }
301 return list2; 303 return list2;
302} 304}
303 305
304void Manager::signalStrength( const QString &mac ) { 306void Manager::signalStrength( const QString &mac ) {
305 307
306 OProcess* sig_proc = new OProcess(); 308 OProcess* sig_proc = new OProcess();
307 309
308 connect(sig_proc, SIGNAL(processExited(OProcess*) ), 310 connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
309 this, SLOT(slotSignalStrengthExited( OProcess*) ) ); 311 this, SLOT(slotSignalStrengthExited( OProcess*) ) );
310 connect(sig_proc, SIGNAL(receivedStdout(OProcess*, char*, int) ), 312 connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
311 this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); 313 this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) );
312 *sig_proc << "hcitool"; 314 *sig_proc << "hcitool";
313 *sig_proc << "lq"; 315 *sig_proc << "lq";
314 *sig_proc << mac; 316 *sig_proc << mac;
315 317
316 sig_proc->setName( mac.latin1() ); 318 sig_proc->setName( mac.latin1() );
317 319
318 if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 320 if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
319 emit signalStrength( mac, "-1" ); 321 emit signalStrength( mac, "-1" );
320 delete sig_proc; 322 delete sig_proc;
321 } 323 }
322} 324}
323 325
324void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) { 326void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) {
325 QCString str(cha, len ); 327 QCString str(cha, len );
326 QString temp = QString(str).stripWhiteSpace(); 328 QString temp = QString(str).stripWhiteSpace();
327 QStringList value = QStringList::split(' ', temp ); 329 QStringList value = QStringList::split(' ', temp );
328 emit signalStrength( proc->name(), value[2].latin1() ); 330 emit signalStrength( proc->name(), value[2].latin1() );
329} 331}
330 332
331 333
332void Manager::slotSignalStrengthExited( OProcess* proc ) { 334void Manager::slotSignalStrengthExited( OProcess* proc ) {
333 delete proc; 335 delete proc;
334} 336}
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h
index abc8ba1..9b1c714 100644
--- a/noncore/net/opietooth/lib/manager.h
+++ b/noncore/net/opietooth/lib/manager.h
@@ -1,173 +1,173 @@
1 1
2#ifndef OpieToothManager_H 2#ifndef OpieToothManager_H
3#define OpieToothManager_H 3#define OpieToothManager_H
4 4
5#include <qobject.h> 5#include <qobject.h>
6#include <qstring.h> 6#include <qstring.h>
7#include <qmap.h> 7#include <qmap.h>
8#include <qvaluelist.h> 8#include <qvaluelist.h>
9 9
10#include "connection.h" 10#include "connection.h"
11#include "remotedevice.h" 11#include "remotedevice.h"
12#include "services.h" 12#include "services.h"
13 13
14class OProcess; 14namespace Opie {namespace Core {class Opie::Core::OProcess;}}
15namespace OpieTooth { 15namespace OpieTooth {
16 class Device; 16 class Device;
17 /** Manager manages a blueZ device (hci0 for example) 17 /** Manager manages a blueZ device (hci0 for example)
18 * without Manager you can control the things you 18 * without Manager you can control the things you
19 * could do from command line in a OO and asynchronus 19 * could do from command line in a OO and asynchronus
20 * way. 20 * way.
21 */ 21 */
22 class Manager : public QObject { 22 class Manager : public QObject {
23 Q_OBJECT 23 Q_OBJECT
24 public: 24 public:
25 /** c'tor whichs create a new Manager 25 /** c'tor whichs create a new Manager
26 * @param device is the device to use. Either a mac or blueZ device name 26 * @param device is the device to use. Either a mac or blueZ device name
27 * 27 *
28 */ 28 */
29 Manager( const QString &device ); 29 Manager( const QString &device );
30 30
31 /** c'tor 31 /** c'tor
32 * @param dev The Device to be managed 32 * @param dev The Device to be managed
33 * We don't care of Device so you need to delete it 33 * We don't care of Device so you need to delete it
34 */ 34 */
35 Manager( Device* dev ); 35 Manager( Device* dev );
36 36
37 /** 37 /**
38 * c'tor 38 * c'tor
39 */ 39 */
40 Manager(); 40 Manager();
41 41
42 ~Manager(); 42 ~Manager();
43 43
44 /** Set the manager to control a new device 44 /** Set the manager to control a new device
45 * @param device the new device to control (hci0 ) 45 * @param device the new device to control (hci0 )
46 */ 46 */
47 void setDevice( const QString& device ); 47 void setDevice( const QString& device );
48 48
49 /** 49 /**
50 * Convience functions for setting a new device 50 * Convience functions for setting a new device
51 */ 51 */
52 void setDevice( Device *dev ); 52 void setDevice( Device *dev );
53 53
54 /** 54 /**
55 * Wether or not a device is connected. The function 55 * Wether or not a device is connected. The function
56 * is asynchron 56 * is asynchron
57 * If device is empty it will take the currently managed 57 * If device is empty it will take the currently managed
58 * device and see if it's up 58 * device and see if it's up
59 * for Remote devices it will ping and see. 59 * for Remote devices it will ping and see.
60 * @param either mac or hciX 60 * @param either mac or hciX
61 */ 61 */
62 void isAvailable(const QString& device= QString::null ); 62 void isAvailable(const QString& device= QString::null );
63 63
64 /** 64 /**
65 * same as above 65 * same as above
66 */ 66 */
67 void isAvailable(Device *dev ); 67 void isAvailable(Device *dev );
68 68
69 /** this searchs for devices reachable from the 69 /** this searchs for devices reachable from the
70 * currently managed device 70 * currently managed device
71 * or from device if @param device is not empty 71 * or from device if @param device is not empty
72 */ 72 */
73 void searchDevices(const QString& device= QString::null ); 73 void searchDevices(const QString& device= QString::null );
74 /** same as above 74 /** same as above
75 * 75 *
76 */ 76 */
77 void searchDevices(Device *d ); 77 void searchDevices(Device *d );
78 78
79 /** 79 /**
80 * This will add the service @param name 80 * This will add the service @param name
81 * to the sdpd daemon 81 * to the sdpd daemon
82 * It will start the daemon if necessary 82 * It will start the daemon if necessary
83 */ 83 */
84 void addService(const QString &name ); 84 void addService(const QString &name );
85 85
86 /** 86 /**
87 * This will add the services @param names 87 * This will add the services @param names
88 * to the sdpd daemon 88 * to the sdpd daemon
89 * It will start the daemon if necessary 89 * It will start the daemon if necessary
90 */ 90 */
91 void addServices( const QStringList& names ); 91 void addServices( const QStringList& names );
92 92
93 /** 93 /**
94 * This removes a service from the sdps 94 * This removes a service from the sdps
95 */ 95 */
96 void removeService(const QString &name ); 96 void removeService(const QString &name );
97 97
98 /** 98 /**
99 * Removes a list from the sdpd 99 * Removes a list from the sdpd
100 */ 100 */
101 void removeServices(const QStringList& ); 101 void removeServices(const QStringList& );
102 102
103 /** 103 /**
104 * search for services on a remote device 104 * search for services on a remote device
105 * 105 *
106 */ 106 */
107 void searchServices( const QString& remDevice ); 107 void searchServices( const QString& remDevice );
108 108
109 /** 109 /**
110 * search for services on a remote device 110 * search for services on a remote device
111 */ 111 */
112 void searchServices( const RemoteDevice& ); 112 void searchServices( const RemoteDevice& );
113 113
114 /** 114 /**
115 * Starts to connect to the device 115 * Starts to connect to the device
116 * in @param 116 * in @param
117 */ 117 */
118 void connectTo(const QString& ); 118 void connectTo(const QString& );
119 119
120 /** 120 /**
121 * Searches for active connections 121 * Searches for active connections
122 * the result is emitted with the 122 * the result is emitted with the
123 * connections signal 123 * connections signal
124 */ 124 */
125 void searchConnections(); 125 void searchConnections();
126 126
127 void signalStrength( const QString &mac ); 127 void signalStrength( const QString &mac );
128//// not implemented yet 128//// not implemented yet
129 /*static*/ QString toDevice( const QString& mac ); 129 /*static*/ QString toDevice( const QString& mac );
130 /*static*/ QString toMac( const QString &device ); 130 /*static*/ QString toMac( const QString &device );
131//// not implemented yet over 131//// not implemented yet over
132 132
133 signals: 133 signals:
134 // device either mac or dev name 134 // device either mac or dev name
135 // the first device is the device which you access 135 // the first device is the device which you access
136 void available( const QString& device, bool connected ); 136 void available( const QString& device, bool connected );
137 void addedService( const QString& service, bool added ); 137 void addedService( const QString& service, bool added );
138 void removedService( const QString& service, bool removed ); 138 void removedService( const QString& service, bool removed );
139 void foundServices( const QString& device, Services::ValueList ); 139 void foundServices( const QString& device, Services::ValueList );
140 void foundDevices( const QString& device, RemoteDevice::ValueList ); 140 void foundDevices( const QString& device, RemoteDevice::ValueList );
141 void connections( ConnectionState::ValueList ); 141 void connections( ConnectionState::ValueList );
142 void signalStrength( const QString& mac, const QString& strengh ); 142 void signalStrength( const QString& mac, const QString& strengh );
143 143
144private slots: 144private slots:
145 void slotProcessExited(OProcess* ); 145 void slotProcessExited(Opie::Core::OProcess* );
146 146
147 void slotSDPExited(OProcess*); 147 void slotSDPExited(Opie::Core::OProcess*);
148 void slotSDPOut(OProcess*, char*, int); 148 void slotSDPOut(Opie::Core::OProcess*, char*, int);
149 149
150 void slotHCIExited(OProcess* ); 150 void slotHCIExited(Opie::Core::OProcess* );
151 void slotHCIOut(OProcess*, char*, int ); 151 void slotHCIOut(Opie::Core::OProcess*, char*, int );
152 152
153 void slotConnectionExited(OProcess* ); 153 void slotConnectionExited(Opie::Core::OProcess* );
154 void slotConnectionOutput(OProcess*, char*, int ); 154 void slotConnectionOutput(Opie::Core::OProcess*, char*, int );
155 155
156 void slotSignalStrengthOutput( OProcess*, char*, int ); 156 void slotSignalStrengthOutput( Opie::Core::OProcess*, char*, int );
157 void slotSignalStrengthExited( OProcess* ); 157 void slotSignalStrengthExited( Opie::Core::OProcess* );
158 private: 158 private:
159 Services::ValueList parseSDPOutput( const QString& ); 159 Services::ValueList parseSDPOutput( const QString& );
160 RemoteDevice::ValueList parseHCIOutput( const QString& ); 160 RemoteDevice::ValueList parseHCIOutput( const QString& );
161 ConnectionState::ValueList parseConnections( const QString& ); 161 ConnectionState::ValueList parseConnections( const QString& );
162 OProcess *m_hcitool; 162 Opie::Core::OProcess *m_hcitool;
163 OProcess *m_sdp; // not only one 163 Opie::Core::OProcess *m_sdp; // not only one
164 QString m_device; 164 QString m_device;
165 QMap<QString, int> m_signalStrength; 165 QMap<QString, int> m_signalStrength;
166 QMap<QString, QString> m_out; 166 QMap<QString, QString> m_out;
167 QMap<QString, QString> m_devices; 167 QMap<QString, QString> m_devices;
168 QMap<OProcess*, QString> m_signalMac; 168 QMap<Opie::Core::OProcess*, QString> m_signalMac;
169 QString m_hcitoolCon; 169 QString m_hcitoolCon;
170 }; 170 };
171}; 171};
172 172
173#endif 173#endif
diff --git a/noncore/net/opietooth/lib/startdunconnection.cpp b/noncore/net/opietooth/lib/startdunconnection.cpp
index c3850eb..90ef04a 100644
--- a/noncore/net/opietooth/lib/startdunconnection.cpp
+++ b/noncore/net/opietooth/lib/startdunconnection.cpp
@@ -1,67 +1,69 @@
1 1
2#include "startdunconnection.h" 2#include "startdunconnection.h"
3 3
4using namespace OpieTooth; 4using namespace OpieTooth;
5 5
6 6
7using namespace Opie::Core;
8using namespace Opie::Core;
7StartDunConnection::StartDunConnection() { 9StartDunConnection::StartDunConnection() {
8 m_dunConnect = 0l; 10 m_dunConnect = 0l;
9 setConnectionType(); 11 setConnectionType();
10} 12}
11 13
12StartDunConnection::~StartDunConnection() { 14StartDunConnection::~StartDunConnection() {
13 delete m_dunConnect; 15 delete m_dunConnect;
14} 16}
15 17
16StartDunConnection::StartDunConnection( QString mac ) { 18StartDunConnection::StartDunConnection( QString mac ) {
17 m_dunConnect = 0l; 19 m_dunConnect = 0l;
18 m_mac = mac; 20 m_mac = mac;
19 setConnectionType(); 21 setConnectionType();
20} 22}
21 23
22void StartDunConnection::setName( QString name ) { 24void StartDunConnection::setName( QString name ) {
23 m_name = name; 25 m_name = name;
24} 26}
25 27
26QString StartDunConnection::name() { 28QString StartDunConnection::name() {
27 return m_name; 29 return m_name;
28} 30}
29 31
30void StartDunConnection::setConnectionType() { 32void StartDunConnection::setConnectionType() {
31 m_connectionType = Pan; 33 m_connectionType = Pan;
32} 34}
33 35
34StartConnection::ConnectionType StartDunConnection::type() { 36StartConnection::ConnectionType StartDunConnection::type() {
35 return m_connectionType; 37 return m_connectionType;
36} 38}
37 39
38void StartDunConnection::start() { 40void StartDunConnection::start() {
39 m_dunConnect = new OProcess(); 41 m_dunConnect = new OProcess();
40 *m_dunConnect << "dund" << "--listen" << "--connect" << m_mac; 42 *m_dunConnect << "dund" << "--listen" << "--connect" << m_mac;
41 43
42 connect( m_dunConnect, SIGNAL( processExited(OProcess*) ) , 44 connect( m_dunConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) ,
43 this, SLOT( slotExited(OProcess*) ) ); 45 this, SLOT( slotExited(OProcess*) ) );
44 connect( m_dunConnect, SIGNAL( receivedStdout(OProcess*,char*,int) ), 46 connect( m_dunConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
45 this, SLOT( slotStdOut(OProcess*,char*,int) ) ); 47 this, SLOT( slotStdOut(OProcess*,char*,int) ) );
46 if (!m_dunConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { 48 if (!m_dunConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
47 qWarning( "could not start" ); 49 qWarning( "could not start" );
48 delete m_dunConnect; 50 delete m_dunConnect;
49 } 51 }
50} 52}
51 53
52 54
53void StartDunConnection::slotExited( OProcess* proc ) { 55void StartDunConnection::slotExited( OProcess* proc ) {
54 delete m_dunConnect; 56 delete m_dunConnect;
55} 57}
56 58
57void StartDunConnection::slotStdOut(OProcess* proc, char* chars, int len) 59void StartDunConnection::slotStdOut(OProcess* proc, char* chars, int len)
58{} 60{}
59 61
60 62
61void StartDunConnection::stop() { 63void StartDunConnection::stop() {
62 if ( m_dunConnect ) { 64 if ( m_dunConnect ) {
63 delete m_dunConnect; 65 delete m_dunConnect;
64 m_dunConnect = 0l; 66 m_dunConnect = 0l;
65 } 67 }
66} 68}
67 69
diff --git a/noncore/net/opietooth/lib/startdunconnection.h b/noncore/net/opietooth/lib/startdunconnection.h
index 43a852a..f6107f6 100644
--- a/noncore/net/opietooth/lib/startdunconnection.h
+++ b/noncore/net/opietooth/lib/startdunconnection.h
@@ -1,40 +1,40 @@
1#ifndef startdunconnection_h 1#ifndef startdunconnection_h
2#define startdunconnection_h 2#define startdunconnection_h
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "connection.h" 5#include "connection.h"
6#include <opie/oprocess.h> 6#include <opie2/oprocess.h>
7 7
8namespace OpieTooth { 8namespace OpieTooth {
9 9
10 class StartDunConnection : StartConnection { 10 class StartDunConnection : StartConnection {
11 11
12 Q_OBJECT 12 Q_OBJECT
13 13
14 public: 14 public:
15 StartDunConnection(); 15 StartDunConnection();
16 StartDunConnection( QString mac ); 16 StartDunConnection( QString mac );
17 ~StartDunConnection(); 17 ~StartDunConnection();
18 18
19 QString name(); 19 QString name();
20 void setName( QString name ); 20 void setName( QString name );
21 StartConnection::ConnectionType type(); 21 StartConnection::ConnectionType type();
22 void setConnectionType( ); 22 void setConnectionType( );
23 void start(); 23 void start();
24 void stop(); 24 void stop();
25 25
26 private: 26 private:
27 QString m_name; 27 QString m_name;
28 QString m_mac; 28 QString m_mac;
29 ConnectionType m_connectionType; 29 ConnectionType m_connectionType;
30 OProcess* m_dunConnect; 30 Opie::Core::OProcess* m_dunConnect;
31 31
32 private slots: 32 private slots:
33 void slotExited( OProcess* proc ); 33 void slotExited( Opie::Core::OProcess* proc );
34 void slotStdOut( OProcess* proc, char* chars, int len ); 34 void slotStdOut( Opie::Core::OProcess* proc, char* chars, int len );
35 }; 35 };
36 36
37 37
38} 38}
39 39
40#endif 40#endif
diff --git a/noncore/net/opietooth/lib/startpanconnection.cpp b/noncore/net/opietooth/lib/startpanconnection.cpp
index a42b407..fef35d9 100644
--- a/noncore/net/opietooth/lib/startpanconnection.cpp
+++ b/noncore/net/opietooth/lib/startpanconnection.cpp
@@ -1,82 +1,84 @@
1 1
2#include "startpanconnection.h" 2#include "startpanconnection.h"
3 3
4using namespace OpieTooth; 4using namespace OpieTooth;
5 5
6 6
7using namespace Opie::Core;
8using namespace Opie::Core;
7StartPanConnection::StartPanConnection() { 9StartPanConnection::StartPanConnection() {
8 m_panConnect = 0l; 10 m_panConnect = 0l;
9 setConnectionType(); 11 setConnectionType();
10} 12}
11 13
12StartPanConnection::~StartPanConnection() { 14StartPanConnection::~StartPanConnection() {
13 delete m_panConnect; 15 delete m_panConnect;
14} 16}
15 17
16StartPanConnection::StartPanConnection( QString mac ) { 18StartPanConnection::StartPanConnection( QString mac ) {
17 m_panConnect = 0l; 19 m_panConnect = 0l;
18 m_mac = mac; 20 m_mac = mac;
19 setConnectionType(); 21 setConnectionType();
20} 22}
21 23
22void StartPanConnection::setName( QString name ) { 24void StartPanConnection::setName( QString name ) {
23 m_name = name; 25 m_name = name;
24} 26}
25 27
26QString StartPanConnection::name() { 28QString StartPanConnection::name() {
27 return m_name; 29 return m_name;
28} 30}
29 31
30void StartPanConnection::setConnectionType() { 32void StartPanConnection::setConnectionType() {
31 m_connectionType = Pan; 33 m_connectionType = Pan;
32} 34}
33 35
34StartConnection::ConnectionType StartPanConnection::type() { 36StartConnection::ConnectionType StartPanConnection::type() {
35 return m_connectionType; 37 return m_connectionType;
36} 38}
37 39
38void StartPanConnection::start() { 40void StartPanConnection::start() {
39 m_panConnect = new OProcess(); 41 m_panConnect = new OProcess();
40 qDebug( "IM START " + m_mac ); 42 qDebug( "IM START " + m_mac );
41 *m_panConnect << "pand" << "--connect" << m_mac; 43 *m_panConnect << "pand" << "--connect" << m_mac;
42 44
43 connect( m_panConnect, SIGNAL( processExited(OProcess*) ) , 45 connect( m_panConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) ,
44 this, SLOT( slotExited(OProcess*) ) ); 46 this, SLOT( slotExited(OProcess*) ) );
45 connect( m_panConnect, SIGNAL( receivedStdout(OProcess*,char*,int) ), 47 connect( m_panConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
46 this, SLOT( slotStdOut(OProcess*,char*,int) ) ); 48 this, SLOT( slotStdOut(OProcess*,char*,int) ) );
47 if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { 49 if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
48 qWarning( "could not start" ); 50 qWarning( "could not start" );
49 delete m_panConnect; 51 delete m_panConnect;
50 } 52 }
51} 53}
52 54
53 55
54void StartPanConnection::slotExited( OProcess* proc ) { 56void StartPanConnection::slotExited( OProcess* proc ) {
55 delete m_panConnect; 57 delete m_panConnect;
56 m_panConnect = 0l; 58 m_panConnect = 0l;
57} 59}
58 60
59void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len) 61void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len)
60{} 62{}
61 63
62 64
63void StartPanConnection::stop() { 65void StartPanConnection::stop() {
64 if ( m_panConnect ) { 66 if ( m_panConnect ) {
65 delete m_panConnect; 67 delete m_panConnect;
66 m_panConnect = 0l; 68 m_panConnect = 0l;
67 } 69 }
68 m_panConnect = new OProcess(); 70 m_panConnect = new OProcess();
69 qDebug("IM STOP " + m_mac); 71 qDebug("IM STOP " + m_mac);
70 72
71 *m_panConnect << "pand" << "--kill" << m_mac; 73 *m_panConnect << "pand" << "--kill" << m_mac;
72 74
73 connect( m_panConnect, SIGNAL( processExited(OProcess*) ) , 75 connect( m_panConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) ,
74 this, SLOT( slotExited(OProcess*) ) ); 76 this, SLOT( slotExited(OProcess*) ) );
75 connect( m_panConnect, SIGNAL( receivedStdout(OProcess*,char*,int) ), 77 connect( m_panConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ),
76 this, SLOT( slotStdOut(OProcess*,char*,int) ) ); 78 this, SLOT( slotStdOut(OProcess*,char*,int) ) );
77 if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { 79 if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
78 qWarning( "could not stop" ); 80 qWarning( "could not stop" );
79 delete m_panConnect; 81 delete m_panConnect;
80 } 82 }
81} 83}
82 84
diff --git a/noncore/net/opietooth/lib/startpanconnection.h b/noncore/net/opietooth/lib/startpanconnection.h
index 7e5bd95..e12dad0 100644
--- a/noncore/net/opietooth/lib/startpanconnection.h
+++ b/noncore/net/opietooth/lib/startpanconnection.h
@@ -1,40 +1,40 @@
1#ifndef startpanconnection_h 1#ifndef startpanconnection_h
2#define startpanconnection_h 2#define startpanconnection_h
3 3
4#include <qobject.h> 4#include <qobject.h>
5#include "connection.h" 5#include "connection.h"
6#include <opie/oprocess.h> 6#include <opie2/oprocess.h>
7 7
8namespace OpieTooth { 8namespace OpieTooth {
9 9
10 class StartPanConnection : StartConnection { 10 class StartPanConnection : StartConnection {
11 11
12 Q_OBJECT 12 Q_OBJECT
13 13
14 public: 14 public:
15 StartPanConnection(); 15 StartPanConnection();
16 StartPanConnection( QString mac ); 16 StartPanConnection( QString mac );
17 ~StartPanConnection(); 17 ~StartPanConnection();
18 18
19 QString name(); 19 QString name();
20 void setName( QString name ); 20 void setName( QString name );
21 StartConnection::ConnectionType type(); 21 StartConnection::ConnectionType type();
22 void setConnectionType( ); 22 void setConnectionType( );
23 void start(); 23 void start();
24 void stop(); 24 void stop();
25 25
26 private: 26 private:
27 QString m_name; 27 QString m_name;
28 QString m_mac; 28 QString m_mac;
29 ConnectionType m_connectionType; 29 ConnectionType m_connectionType;
30 OProcess* m_panConnect; 30 Opie::Core::OProcess* m_panConnect;
31 31
32 private slots: 32 private slots:
33 void slotExited( OProcess* proc ); 33 void slotExited( Opie::Core::OProcess* proc );
34 void slotStdOut( OProcess* proc, char* chars, int len ); 34 void slotStdOut( Opie::Core::OProcess* proc, char* chars, int len );
35 }; 35 };
36 36
37 37
38} 38}
39 39
40#endif 40#endif
diff --git a/noncore/net/opietooth/manager/main.cpp b/noncore/net/opietooth/manager/main.cpp
index 82aeebd..a96f128 100644
--- a/noncore/net/opietooth/manager/main.cpp
+++ b/noncore/net/opietooth/manager/main.cpp
@@ -1,25 +1,27 @@
1/* 1/*
2using namespace Opie::Core;
3using namespace Opie::Core;
2 * main.cpp 4 * main.cpp
3 * 5 *
4 * --------------------- 6 * ---------------------
5 * 7 *
6 * begin : Sun 10 17:20:00 CEST 2002 8 * begin : Sun 10 17:20:00 CEST 2002
7 * copyright : (c) 2002 by Maximilian Reiß 9 * copyright : (c) 2002 by Maximilian Reiß
8 * email : max.reiss@gmx.de 10 * email : max.reiss@gmx.de
9 * 11 *
10 */ 12 */
11/*************************************************************************** 13/***************************************************************************
12 * * 14 * *
13 * This program is free software; you can redistribute it and/or modify * 15 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 16 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 17 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 18 * (at your option) any later version. *
17 * * 19 * *
18 ***************************************************************************/ 20 ***************************************************************************/
19 21
20#include "bluebase.h" 22#include "bluebase.h"
21#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
22#include <opie/oapplicationfactory.h> 24#include <opie2/oapplicationfactory.h>
23 25
24OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::BlueBase> ) 26OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::BlueBase> )
25 27
diff --git a/noncore/net/opietooth/manager/obexdialog.cpp b/noncore/net/opietooth/manager/obexdialog.cpp
index 46a0e3d..1ef862a 100644
--- a/noncore/net/opietooth/manager/obexdialog.cpp
+++ b/noncore/net/opietooth/manager/obexdialog.cpp
@@ -1,86 +1,89 @@
1 1
2#include "obexdialog.h" 2#include "obexdialog.h"
3#include <qpushbutton.h> 3#include <qpushbutton.h>
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qfileinfo.h> 8#include <qfileinfo.h>
9 9
10#include <qpe/resource.h> 10#include <qpe/resource.h>
11 11
12#include <opie/oprocess.h> 12#include <opie2/oprocess.h>
13#include <opie/ofiledialog.h> 13#include <opie2/ofiledialog.h>
14 14
15using namespace OpieTooth; 15using namespace OpieTooth;
16 16
17using namespace Opie::Core;
18using namespace Opie::Ui;
19using namespace Opie::Core;
17ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) 20ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device )
18 : QDialog( parent, name, modal, fl ) { 21 : QDialog( parent, name, modal, fl ) {
19 22
20 if ( !name ) 23 if ( !name )
21 setName( "ObexDialog" ); 24 setName( "ObexDialog" );
22 setCaption( tr( "beam files " ) ) ; 25 setCaption( tr( "beam files " ) ) ;
23 26
24 m_device = device; 27 m_device = device;
25 28
26 layout = new QVBoxLayout( this ); 29 layout = new QVBoxLayout( this );
27 30
28 QLabel* info = new QLabel( this ); 31 QLabel* info = new QLabel( this );
29 info->setText( tr("Which file should be beamed?") ); 32 info->setText( tr("Which file should be beamed?") );
30 33
31 cmdLine = new QLineEdit( this ); 34 cmdLine = new QLineEdit( this );
32 35
33 QPushButton *browserButton; 36 QPushButton *browserButton;
34 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 37 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
35 connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) ); 38 connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) );
36 39
37 chNameLine = new QLineEdit( this ); 40 chNameLine = new QLineEdit( this );
38 41
39 sendButton = new QPushButton( this ); 42 sendButton = new QPushButton( this );
40 sendButton->setText( tr( "Send" ) ); 43 sendButton->setText( tr( "Send" ) );
41 44
42 layout->addWidget(info); 45 layout->addWidget(info);
43 layout->addWidget(cmdLine); 46 layout->addWidget(cmdLine);
44 layout->addWidget(browserButton); 47 layout->addWidget(browserButton);
45 layout->addWidget(chNameLine); 48 layout->addWidget(chNameLine);
46 layout->addWidget(sendButton); 49 layout->addWidget(sendButton);
47 50
48 connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); 51 connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) );
49 52
50} 53}
51 54
52ObexDialog::~ObexDialog() { 55ObexDialog::~ObexDialog() {
53} 56}
54 57
55void ObexDialog::browse() { 58void ObexDialog::browse() {
56 59
57 MimeTypes types; 60 MimeTypes types;
58 QStringList all; 61 QStringList all;
59 all << "*/*"; 62 all << "*/*";
60 types.insert("All Files", all ); 63 types.insert("All Files", all );
61 64
62 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 65 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
63 cmdLine->setText( str ); 66 cmdLine->setText( str );
64 67
65} 68}
66 69
67void ObexDialog::sendData() { 70void ObexDialog::sendData() {
68 QString fileURL = cmdLine->text(); 71 QString fileURL = cmdLine->text();
69 QString file = QFileInfo( fileURL ).fileName(); 72 QString file = QFileInfo( fileURL ).fileName();
70 QString modifiedName = chNameLine->text(); 73 QString modifiedName = chNameLine->text();
71 74
72 // vom popupmenu beziehen 75 // vom popupmenu beziehen
73 OProcess* obexSend = new OProcess(); 76 OProcess* obexSend = new OProcess();
74 if ( !modifiedName.isEmpty() ) { 77 if ( !modifiedName.isEmpty() ) {
75 *obexSend << "ussp-push" << m_device << fileURL << modifiedName; 78 *obexSend << "ussp-push" << m_device << fileURL << modifiedName;
76 } else { 79 } else {
77 *obexSend << "ussp-push" << m_device << fileURL << file; 80 *obexSend << "ussp-push" << m_device << fileURL << file;
78 } 81 }
79 if (!obexSend->start(OProcess::DontCare, OProcess::AllOutput) ) { 82 if (!obexSend->start(OProcess::DontCare, OProcess::AllOutput) ) {
80 qWarning("could not start"); 83 qWarning("could not start");
81 delete obexSend; 84 delete obexSend;
82 } 85 }
83 86
84 87
85 88
86} 89}
diff --git a/noncore/net/opietooth/manager/obexdialog.h b/noncore/net/opietooth/manager/obexdialog.h
index b3d5e6d..d5b5682 100644
--- a/noncore/net/opietooth/manager/obexdialog.h
+++ b/noncore/net/opietooth/manager/obexdialog.h
@@ -1,39 +1,39 @@
1#ifndef OBEXDIALOG_H 1#ifndef OBEXDIALOG_H
2#define OBEXDIALOG_H 2#define OBEXDIALOG_H
3 3
4 4
5#include <qdialog.h> 5#include <qdialog.h>
6#include <opie/oprocess.h> 6#include <opie2/oprocess.h>
7 7
8class QVBoxLayout; 8class QVBoxLayout;
9class QPushButton; 9class QPushButton;
10class QMultiLineEdit; 10class QMultiLineEdit;
11class QLineEdit; 11class QLineEdit;
12 12
13 13
14namespace OpieTooth { 14namespace OpieTooth {
15 15
16 class ObexDialog : public QDialog { 16 class ObexDialog : public QDialog {
17 17
18 Q_OBJECT 18 Q_OBJECT
19 19
20 public: 20 public:
21 ObexDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0); 21 ObexDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0);
22 ~ObexDialog(); 22 ~ObexDialog();
23 23
24 24
25private slots: 25private slots:
26 void browse(); 26 void browse();
27 void sendData(); 27 void sendData();
28 28
29 protected: 29 protected:
30 QVBoxLayout* layout; 30 QVBoxLayout* layout;
31 QLineEdit* cmdLine; 31 QLineEdit* cmdLine;
32 QLineEdit* chNameLine; 32 QLineEdit* chNameLine;
33 QPushButton* sendButton; 33 QPushButton* sendButton;
34 private: 34 private:
35 // Device that is used 35 // Device that is used
36 QString m_device; 36 QString m_device;
37 }; 37 };
38} 38}
39#endif 39#endif
diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp
index 4e58552..870e7fd 100644
--- a/noncore/net/opietooth/manager/pppdialog.cpp
+++ b/noncore/net/opietooth/manager/pppdialog.cpp
@@ -1,68 +1,70 @@
1 1
2#include "pppdialog.h" 2#include "pppdialog.h"
3#include <qpushbutton.h> 3#include <qpushbutton.h>
4#include <qmultilineedit.h> 4#include <qmultilineedit.h>
5#include <qlineedit.h> 5#include <qlineedit.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <opie/oprocess.h> 8#include <opie2/oprocess.h>
9 9
10using namespace OpieTooth; 10using namespace OpieTooth;
11 11
12using namespace Opie::Core;
13using namespace Opie::Core;
12PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) 14PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device )
13 : QDialog( parent, name, modal, fl ) { 15 : QDialog( parent, name, modal, fl ) {
14 16
15 if ( !name ) 17 if ( !name )
16 setName( "PPPDialog" ); 18 setName( "PPPDialog" );
17 setCaption( tr( "ppp connection " ) ) ; 19 setCaption( tr( "ppp connection " ) ) ;
18 20
19 m_device = device; 21 m_device = device;
20 22
21 layout = new QVBoxLayout( this ); 23 layout = new QVBoxLayout( this );
22 24
23 QLabel* info = new QLabel( this ); 25 QLabel* info = new QLabel( this );
24 info->setText( tr("Enter an ppp script name:") ); 26 info->setText( tr("Enter an ppp script name:") );
25 27
26 cmdLine = new QLineEdit( this ); 28 cmdLine = new QLineEdit( this );
27 29
28 outPut = new QMultiLineEdit( this ); 30 outPut = new QMultiLineEdit( this );
29 QFont outPut_font( outPut->font() ); 31 QFont outPut_font( outPut->font() );
30 outPut_font.setPointSize( 8 ); 32 outPut_font.setPointSize( 8 );
31 outPut->setFont( outPut_font ); 33 outPut->setFont( outPut_font );
32 outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); 34 outPut->setWordWrap( QMultiLineEdit::WidgetWidth );
33 35
34 connectButton = new QPushButton( this ); 36 connectButton = new QPushButton( this );
35 connectButton->setText( tr( "Connect" ) ); 37 connectButton->setText( tr( "Connect" ) );
36 38
37 layout->addWidget(info); 39 layout->addWidget(info);
38 layout->addWidget(cmdLine); 40 layout->addWidget(cmdLine);
39 layout->addWidget(outPut); 41 layout->addWidget(outPut);
40 layout->addWidget(connectButton); 42 layout->addWidget(connectButton);
41 43
42 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); 44 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) );
43 45
44} 46}
45 47
46PPPDialog::~PPPDialog() { 48PPPDialog::~PPPDialog() {
47} 49}
48 50
49void PPPDialog::connectToDevice() { 51void PPPDialog::connectToDevice() {
50 outPut->clear(); 52 outPut->clear();
51 // vom popupmenu beziehen 53 // vom popupmenu beziehen
52 QString connectScript = "/etc/ppp/peers/" + cmdLine->text(); 54 QString connectScript = "/etc/ppp/peers/" + cmdLine->text();
53 OProcess* pppDial = new OProcess(); 55 OProcess* pppDial = new OProcess();
54 *pppDial << "pppd" << m_device << "call" << connectScript; 56 *pppDial << "pppd" << m_device << "call" << connectScript;
55 connect( pppDial, SIGNAL(receivedStdout(OProcess*,char*,int) ), 57 connect( pppDial, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int) ),
56 this, SLOT(fillOutPut(OProcess*,char*,int) ) ); 58 this, SLOT(fillOutPut(OProcess*,char*,int) ) );
57 if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) { 59 if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) {
58 qWarning("could not start"); 60 qWarning("could not start");
59 delete pppDial; 61 delete pppDial;
60 } 62 }
61} 63}
62 64
63void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) { 65void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) {
64 QCString str(cha, len ); 66 QCString str(cha, len );
65 outPut->insertLine( str ); 67 outPut->insertLine( str );
66 delete pppDial; 68 delete pppDial;
67} 69}
68 70
diff --git a/noncore/net/opietooth/manager/pppdialog.h b/noncore/net/opietooth/manager/pppdialog.h
index bb8b734..05894e2 100644
--- a/noncore/net/opietooth/manager/pppdialog.h
+++ b/noncore/net/opietooth/manager/pppdialog.h
@@ -1,37 +1,37 @@
1#ifndef PPPDIALOG_H 1#ifndef PPPDIALOG_H
2#define PPPDIALOG_H 2#define PPPDIALOG_H
3 3
4 4
5#include <qdialog.h> 5#include <qdialog.h>
6#include <opie/oprocess.h> 6#include <opie2/oprocess.h>
7 7
8class QVBoxLayout; 8class QVBoxLayout;
9class QPushButton; 9class QPushButton;
10class QMultiLineEdit; 10class QMultiLineEdit;
11class QLineEdit; 11class QLineEdit;
12 12
13 13
14namespace OpieTooth { 14namespace OpieTooth {
15 15
16 class PPPDialog : public QDialog { 16 class PPPDialog : public QDialog {
17 17
18 Q_OBJECT 18 Q_OBJECT
19 19
20 public: 20 public:
21 PPPDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0); 21 PPPDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0);
22 ~PPPDialog(); 22 ~PPPDialog();
23 23
24 private slots: 24 private slots:
25 void connectToDevice(); 25 void connectToDevice();
26 void fillOutPut( OProcess* pppDial, char* cha, int len ); 26 void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len );
27 protected: 27 protected:
28 QVBoxLayout* layout; 28 QVBoxLayout* layout;
29 QLineEdit* cmdLine; 29 QLineEdit* cmdLine;
30 QPushButton* connectButton; 30 QPushButton* connectButton;
31 QMultiLineEdit* outPut; 31 QMultiLineEdit* outPut;
32 32
33 private: 33 private:
34 QString m_device; 34 QString m_device;
35 }; 35 };
36} 36}
37#endif 37#endif
diff --git a/noncore/net/ubrowser/main.cpp b/noncore/net/ubrowser/main.cpp
index 0488cfd..0736f1f 100644
--- a/noncore/net/ubrowser/main.cpp
+++ b/noncore/net/ubrowser/main.cpp
@@ -1,24 +1,26 @@
1/* 1/*
2Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing 2Opie-uBrowser. a very small web browser, using on QTextBrowser for html display/parsing
3Copyright (C) 2002 Thomas Stephens 3Copyright (C) 2002 Thomas Stephens
4 4
5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public 5This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later 6License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7version. 7version.
8 8
9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 9This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 10implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11Public License for more details. 11Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free 13You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15*/ 15*/
16 16
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18 18
19#include "mainview.h" 19#include "mainview.h"
20 20
21#include <opie/oapplicationfactory.h> 21#include <opie2/oapplicationfactory.h>
22 22
23
24using namespace Opie::Core;
23OPIE_EXPORT_APP( OApplicationFactory<MainView> ) 25OPIE_EXPORT_APP( OApplicationFactory<MainView> )
24 26
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index 95b03d0..da39113 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -1,237 +1,243 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20/* OPIE */ 20/* OPIE */
21#include <opie2/onetwork.h> 21#include <opie2/onetwork.h>
22#ifdef QWS 22#ifdef QWS
23#include <opie2/oapplication.h> 23#include <opie2/oapplication.h>
24#include <opie2/oconfig.h> 24#include <opie2/oconfig.h>
25#include <opie2/odevice.h> 25#include <opie2/odevice.h>
26using namespace Opie; 26using namespace Opie;
27#endif 27#endif
28 28
29/* QT */ 29/* QT */
30#include <qapplication.h> 30#include <qapplication.h>
31#include <qcheckbox.h> 31#include <qcheckbox.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qlineedit.h> 34#include <qlineedit.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qtabwidget.h> 38#include <qtabwidget.h>
39#include <qtoolbutton.h> 39#include <qtoolbutton.h>
40#include <qspinbox.h> 40#include <qspinbox.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42 42
43/* POSIX */ 43/* POSIX */
44#include <assert.h> 44#include <assert.h>
45 45
46using namespace Opie::Core;
47using namespace Opie::Net;
48using namespace Opie::Core;
49using namespace Opie::Net;
50using namespace Opie::Core;
51using namespace Opie::Net;
46WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 52WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
47 53
48WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 54WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
49 :WellenreiterConfigBase( parent, name, true, f ) 55 :WellenreiterConfigBase( parent, name, true, f )
50{ 56{
51 _devicetype[ "cisco" ] = DEVTYPE_CISCO; 57 _devicetype[ "cisco" ] = DEVTYPE_CISCO;
52 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; 58 _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG;
53 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; 59 _devicetype[ "hostap" ] = DEVTYPE_HOSTAP;
54 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; 60 _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO;
55 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; 61 _devicetype[ "<manual>" ] = DEVTYPE_MANUAL;
56 _devicetype[ "<file>" ] = DEVTYPE_FILE; 62 _devicetype[ "<file>" ] = DEVTYPE_FILE;
57 63
58 // gather possible interface names from ONetwork 64 // gather possible interface names from ONetwork
59 ONetwork* net = ONetwork::instance(); 65 ONetwork* net = ONetwork::instance();
60 ONetwork::InterfaceIterator it = net->iterator(); 66 ONetwork::InterfaceIterator it = net->iterator();
61 while ( it.current() ) 67 while ( it.current() )
62 { 68 {
63 if ( it.current()->isWireless() ) 69 if ( it.current()->isWireless() )
64 interfaceName->insertItem( it.current()->name() ); 70 interfaceName->insertItem( it.current()->name() );
65 ++it; 71 ++it;
66 } 72 }
67 73
68 load(); 74 load();
69 75
70 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here 76 #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here
71 QPushButton* okButton = new QPushButton( "ok", this ); 77 QPushButton* okButton = new QPushButton( "ok", this );
72 okButton->show(); 78 okButton->show();
73 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui 79 WellenreiterConfigBaseLayout->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui
74 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 80 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
75 #endif 81 #endif
76 82
77 WellenreiterConfigWindow::_instance = this; 83 WellenreiterConfigWindow::_instance = this;
78 84
79 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); 85 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
80 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); 86 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) );
81 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); 87 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) );
82 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); 88 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) );
83 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); 89 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) );
84 90
85 // make the checkbox 'channelAll' control all other channels 91 // make the checkbox 'channelAll' control all other channels
86 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); 92 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) );
87 93
88 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); 94 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) );
89 95
90 // hide tab4 (parse) until Wellenreiter 1.2 96 // hide tab4 (parse) until Wellenreiter 1.2
91 tab->removePage( tab_4 ); 97 tab->removePage( tab_4 );
92}; 98};
93 99
94 100
95void WellenreiterConfigWindow::accept() 101void WellenreiterConfigWindow::accept()
96{ 102{
97 save(); 103 save();
98 QDialog::accept(); 104 QDialog::accept();
99} 105}
100 106
101 107
102WellenreiterConfigWindow::~WellenreiterConfigWindow() 108WellenreiterConfigWindow::~WellenreiterConfigWindow()
103{ 109{
104} 110}
105 111
106 112
107void WellenreiterConfigWindow::performAutodetection() 113void WellenreiterConfigWindow::performAutodetection()
108{ 114{
109 //TODO: insert modal splash screen here 115 //TODO: insert modal splash screen here
110 // and sleep a second, so that it looks 116 // and sleep a second, so that it looks
111 // like we're actually doing something fancy... ;-) 117 // like we're actually doing something fancy... ;-)
112 118
113 qDebug( "WellenreiterConfigWindow::performAutodetection()" ); 119 qDebug( "WellenreiterConfigWindow::performAutodetection()" );
114 120
115 // try to guess device type 121 // try to guess device type
116 QFile m( "/proc/modules" ); 122 QFile m( "/proc/modules" );
117 if ( m.open( IO_ReadOnly ) ) 123 if ( m.open( IO_ReadOnly ) )
118 { 124 {
119 int devicetype(0); 125 int devicetype(0);
120 QString line; 126 QString line;
121 QTextStream modules( &m ); 127 QTextStream modules( &m );
122 while( !modules.atEnd() && !devicetype ) 128 while( !modules.atEnd() && !devicetype )
123 { 129 {
124 modules >> line; 130 modules >> line;
125 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; 131 if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO;
126 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; 132 else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP;
127 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; 133 else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG;
128 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; 134 else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO;
129 } 135 }
130 if ( devicetype ) 136 if ( devicetype )
131 { 137 {
132 deviceType->setCurrentItem( devicetype ); 138 deviceType->setCurrentItem( devicetype );
133 _guess = devicetype; 139 _guess = devicetype;
134 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); 140 qDebug( "Wellenreiter: guessed device type to be #%d", devicetype );
135 } 141 }
136 } 142 }
137} 143}
138 144
139 145
140int WellenreiterConfigWindow::driverType() const 146int WellenreiterConfigWindow::driverType() const
141{ 147{
142 QString name = deviceType->currentText(); 148 QString name = deviceType->currentText();
143 if ( _devicetype.contains( name ) ) 149 if ( _devicetype.contains( name ) )
144 { 150 {
145 return _devicetype[name]; 151 return _devicetype[name];
146 } 152 }
147 else 153 else
148 { 154 {
149 return 0; 155 return 0;
150 } 156 }
151}; 157};
152 158
153 159
154int WellenreiterConfigWindow::hoppingInterval() const 160int WellenreiterConfigWindow::hoppingInterval() const
155{ 161{
156 return hopInterval->cleanText().toInt(); 162 return hopInterval->cleanText().toInt();
157} 163}
158 164
159 165
160bool WellenreiterConfigWindow::usePrismHeader() const 166bool WellenreiterConfigWindow::usePrismHeader() const
161{ 167{
162 return prismHeader->isChecked(); 168 return prismHeader->isChecked();
163} 169}
164 170
165 171
166bool WellenreiterConfigWindow::isChannelChecked( int channel ) const 172bool WellenreiterConfigWindow::isChannelChecked( int channel ) const
167{ 173{
168 switch ( channel ) 174 switch ( channel )
169 { 175 {
170 case 1: return channel1->isOn(); 176 case 1: return channel1->isOn();
171 case 2: return channel2->isOn(); 177 case 2: return channel2->isOn();
172 case 3: return channel3->isOn(); 178 case 3: return channel3->isOn();
173 case 4: return channel4->isOn(); 179 case 4: return channel4->isOn();
174 case 5: return channel5->isOn(); 180 case 5: return channel5->isOn();
175 case 6: return channel6->isOn(); 181 case 6: return channel6->isOn();
176 case 7: return channel7->isOn(); 182 case 7: return channel7->isOn();
177 case 8: return channel8->isOn(); 183 case 8: return channel8->isOn();
178 case 9: return channel9->isOn(); 184 case 9: return channel9->isOn();
179 case 10: return channel10->isOn(); 185 case 10: return channel10->isOn();
180 case 11: return channel11->isOn(); 186 case 11: return channel11->isOn();
181 case 12: return channel12->isOn(); 187 case 12: return channel12->isOn();
182 case 13: return channel13->isOn(); 188 case 13: return channel13->isOn();
183 case 14: return channel14->isOn(); 189 case 14: return channel14->isOn();
184 } 190 }
185} 191}
186 192
187 193
188void WellenreiterConfigWindow::changedDeviceType(int t) 194void WellenreiterConfigWindow::changedDeviceType(int t)
189{ 195{
190 if ( t != DEVTYPE_FILE ) return; 196 if ( t != DEVTYPE_FILE ) return;
191 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); 197 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false);
192 if ( !name.isEmpty() && QFile::exists( name ) ) 198 if ( !name.isEmpty() && QFile::exists( name ) )
193 { 199 {
194 interfaceName->insertItem( name ); 200 interfaceName->insertItem( name );
195 interfaceName->setCurrentItem( interfaceName->count()-1 ); 201 interfaceName->setCurrentItem( interfaceName->count()-1 );
196 } 202 }
197 else 203 else
198 { 204 {
199 deviceType->setCurrentItem( _guess ); 205 deviceType->setCurrentItem( _guess );
200 } 206 }
201 207
202} 208}
203 209
204 210
205void WellenreiterConfigWindow::synchronizeActionsAndScripts() 211void WellenreiterConfigWindow::synchronizeActionsAndScripts()
206{ 212{
207 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide(); 213 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide();
208 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide(); 214 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide();
209 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide(); 215 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide();
210 216
211 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 ); 217 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 );
212 //newClientScript->setEnabled( newClientAction->currentItem() == 4 ); 218 //newClientScript->setEnabled( newClientAction->currentItem() == 4 );
213 //newStationScript->setEnabled( newStationAction->currentItem() == 4 ); 219 //newStationScript->setEnabled( newStationAction->currentItem() == 4 );
214} 220}
215 221
216 222
217void WellenreiterConfigWindow::changedNetworkAction(int t) 223void WellenreiterConfigWindow::changedNetworkAction(int t)
218{ 224{
219 synchronizeActionsAndScripts(); 225 synchronizeActionsAndScripts();
220} 226}
221 227
222 228
223void WellenreiterConfigWindow::changedClientAction(int t) 229void WellenreiterConfigWindow::changedClientAction(int t)
224{ 230{
225 synchronizeActionsAndScripts(); 231 synchronizeActionsAndScripts();
226} 232}
227 233
228 234
229void WellenreiterConfigWindow::changedStationAction(int t) 235void WellenreiterConfigWindow::changedStationAction(int t)
230{ 236{
231 synchronizeActionsAndScripts(); 237 synchronizeActionsAndScripts();
232} 238}
233 239
234 240
235void WellenreiterConfigWindow::getCaptureFileNameClicked() 241void WellenreiterConfigWindow::getCaptureFileNameClicked()
236{ 242{
237 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); 243 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true);
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 7dcc583..6bbc39b 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -1,110 +1,113 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "mainwindow.h" 16#include "mainwindow.h"
17#ifdef QWS 17#ifdef QWS
18#include <opie2/oapplication.h> 18#include <opie2/oapplication.h>
19#include <opie2/oprocess.h> 19#include <opie2/oprocess.h>
20#else 20#else
21#include <qapplication.h> 21#include <qapplication.h>
22#endif 22#endif
23 23
24#include <qmessagebox.h> 24#include <qmessagebox.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26 26
27#include <errno.h> 27#include <errno.h>
28#include <signal.h> 28#include <signal.h>
29#include <string.h> 29#include <string.h>
30#include <unistd.h> 30#include <unistd.h>
31 31
32using namespace Opie::Core;
33using namespace Opie::Core;
34using namespace Opie::Core;
32int main( int argc, char **argv ) 35int main( int argc, char **argv )
33{ 36{
34 #ifdef QWS 37 #ifdef QWS
35 OApplication a( argc, argv, "Wellenreiter II" ); 38 OApplication a( argc, argv, "Wellenreiter II" );
36 #else 39 #else
37 QApplication a( argc, argv ); 40 QApplication a( argc, argv );
38 #endif 41 #endif
39 WellenreiterMainWindow* w = new WellenreiterMainWindow(); 42 WellenreiterMainWindow* w = new WellenreiterMainWindow();
40 #ifdef QWS 43 #ifdef QWS
41 a.showMainWidget( w ); 44 a.showMainWidget( w );
42 #else 45 #else
43 a.setMainWidget( w ); 46 a.setMainWidget( w );
44 w->setCaption( "Wellenreiter II" ); 47 w->setCaption( "Wellenreiter II" );
45 w->show(); 48 w->show();
46 #endif 49 #endif
47 50
48 a.processEvents(); // show the window before doing the safety checks 51 a.processEvents(); // show the window before doing the safety checks
49 int result = -1; 52 int result = -1;
50 static int killed = false; 53 static int killed = false;
51 54
52 bool check = true; 55 bool check = true;
53 for ( int i = 1; i < argc; ++i ) 56 for ( int i = 1; i < argc; ++i )
54 { 57 {
55 qDebug( "Wellenreiter::main() parsing argument %d = '%s'", i, argv[i] ); 58 qDebug( "Wellenreiter::main() parsing argument %d = '%s'", i, argv[i] );
56 if ( !strcmp( "-nocheck", argv[i] ) ) 59 if ( !strcmp( "-nocheck", argv[i] ) )
57 { 60 {
58 qDebug( "-nocheck found" ); 61 qDebug( "-nocheck found" );
59 check = false; 62 check = false;
60 break; 63 break;
61 } 64 }
62 } 65 }
63 66
64 if ( check ) 67 if ( check )
65 { 68 {
66 // root check 69 // root check
67 if ( getuid() ) 70 if ( getuid() )
68 { 71 {
69 qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); 72 qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) );
70 result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" 73 result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n"
71 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), 74 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ),
72 QMessageBox::Yes, QMessageBox::No ); 75 QMessageBox::Yes, QMessageBox::No );
73 if ( result == QMessageBox::No ) return -1; 76 if ( result == QMessageBox::No ) return -1;
74 } 77 }
75 78
76 int dhcpid = OProcess::processPID( "dhcpc" ); 79 int dhcpid = OProcess::processPID( "dhcpc" );
77 80
78 if ( dhcpid ) 81 if ( dhcpid )
79 { 82 {
80 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" 83 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n"
81 "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ), 84 "(PID = %1)\nThis can severly limit scanning!\nShould I kill it for you?" ).arg( dhcpid ),
82 QMessageBox::Yes, QMessageBox::No ); 85 QMessageBox::Yes, QMessageBox::No );
83 if ( result == QMessageBox::Yes ) 86 if ( result == QMessageBox::Yes )
84 { 87 {
85 if ( -1 == ::kill( dhcpid, SIGTERM ) ) 88 if ( -1 == ::kill( dhcpid, SIGTERM ) )
86 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); 89 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) );
87 else 90 else
88 killed = true; 91 killed = true;
89 } 92 }
90 } 93 }
91 } 94 }
92 95
93 a.exec(); 96 a.exec();
94 97
95 if ( check ) 98 if ( check )
96 { 99 {
97 100
98 if ( killed ) 101 if ( killed )
99 { 102 {
100 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); 103 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No );
101 if ( result == QMessageBox::Yes ) 104 if ( result == QMessageBox::Yes )
102 { 105 {
103 ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); 106 ::system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) );
104 } 107 }
105 } 108 }
106 109
107 delete w; 110 delete w;
108 } 111 }
109 return 0; 112 return 0;
110} 113}
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp
index 5cc0daf..7add6cd 100644
--- a/noncore/net/wellenreiter/gui/mainwindow.cpp
+++ b/noncore/net/wellenreiter/gui/mainwindow.cpp
@@ -1,245 +1,250 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "configwindow.h" 16#include "configwindow.h"
17#include "gps.h" 17#include "gps.h"
18#include "logwindow.h" 18#include "logwindow.h"
19#include "packetview.h" 19#include "packetview.h"
20#include "mainwindow.h" 20#include "mainwindow.h"
21#include "wellenreiter.h" 21#include "wellenreiter.h"
22#include "scanlist.h" 22#include "scanlist.h"
23 23
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qdatastream.h> 25#include <qdatastream.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qfileinfo.h> 27#include <qfileinfo.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qiconset.h> 31#include <qiconset.h>
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qstatusbar.h> 36#include <qstatusbar.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qtextstream.h> 38#include <qtextstream.h>
39#include <qtoolbutton.h> 39#include <qtoolbutton.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41 41
42#ifdef QWS 42#ifdef QWS
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44#include <opie2/ofiledialog.h> 44#include <opie2/ofiledialog.h>
45using namespace Opie; 45using namespace Opie;
46#else 46#else
47#include "resource.h" 47#include "resource.h"
48#include <qapplication.h> 48#include <qapplication.h>
49#include <qfiledialog.h> 49#include <qfiledialog.h>
50#endif 50#endif
51 51
52#include <unistd.h> 52#include <unistd.h>
53 53
54using namespace Opie::Ui;
55using namespace Opie::Net;
56using namespace Opie::Ui;
57using namespace Opie::Net;
58using namespace Opie::Net;
54WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f ) 59WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * name, WFlags f )
55 :QMainWindow( parent, name, f ) 60 :QMainWindow( parent, name, f )
56{ 61{
57 cw = new WellenreiterConfigWindow( this ); 62 cw = new WellenreiterConfigWindow( this );
58 mw = new Wellenreiter( this ); 63 mw = new Wellenreiter( this );
59 mw->setConfigWindow( cw ); 64 mw->setConfigWindow( cw );
60 setCentralWidget( mw ); 65 setCentralWidget( mw );
61 66
62 // setup application icon 67 // setup application icon
63 68
64 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) ); 69 setIcon( Resource::loadPixmap( "wellenreiter/appicon-trans" ) );
65 #ifndef QWS 70 #ifndef QWS
66 setIconText( "Wellenreiter/X11" ); 71 setIconText( "Wellenreiter/X11" );
67 #endif 72 #endif
68 73
69 // setup tool buttons 74 // setup tool buttons
70 75
71 startButton = new QToolButton( 0 ); 76 startButton = new QToolButton( 0 );
72 QWhatsThis::add( startButton, tr( "Click here to start scanning." ) ); 77 QWhatsThis::add( startButton, tr( "Click here to start scanning." ) );
73 #ifdef QWS 78 #ifdef QWS
74 startButton->setAutoRaise( true ); 79 startButton->setAutoRaise( true );
75 #endif 80 #endif
76 startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) ); 81 startButton->setIconSet( Resource::loadIconSet( "wellenreiter/SearchIcon" ) );
77 startButton->setEnabled( false ); 82 startButton->setEnabled( false );
78 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); 83 connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) );
79 84
80 stopButton = new QToolButton( 0 ); 85 stopButton = new QToolButton( 0 );
81 QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) ); 86 QWhatsThis::add( stopButton, tr( "Click here to stop scanning." ) );
82 #ifdef QWS 87 #ifdef QWS
83 stopButton->setAutoRaise( true ); 88 stopButton->setAutoRaise( true );
84 #endif 89 #endif
85 stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) ); 90 stopButton->setIconSet( Resource::loadIconSet( "wellenreiter/CancelIcon" ) );
86 stopButton->setEnabled( false ); 91 stopButton->setEnabled( false );
87 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); 92 connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) );
88 93
89 QToolButton* d = new QToolButton( 0 ); 94 QToolButton* d = new QToolButton( 0 );
90 QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ), 95 QWhatsThis::add( d, tr( "Click here to open the configure dialog." ) ),
91 #ifdef QWS 96 #ifdef QWS
92 d->setAutoRaise( true ); 97 d->setAutoRaise( true );
93 #endif 98 #endif
94 d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) ); 99 d->setIconSet( Resource::loadIconSet( "wellenreiter/SettingsIcon" ) );
95 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) ); 100 connect( d, SIGNAL( clicked() ), this, SLOT( showConfigure() ) );
96 101
97 uploadButton = new QToolButton( 0 ); 102 uploadButton = new QToolButton( 0 );
98 QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) ); 103 QWhatsThis::add( uploadButton, tr( "Click here to upload a capture session." ) );
99 #ifdef QWS 104 #ifdef QWS
100 uploadButton->setAutoRaise( true ); 105 uploadButton->setAutoRaise( true );
101 #endif 106 #endif
102 uploadButton->setIconSet( Resource::loadIconSet( "up" ) ); 107 uploadButton->setIconSet( Resource::loadIconSet( "up" ) );
103 uploadButton->setEnabled( false ); 108 uploadButton->setEnabled( false );
104 //uploadButton->setEnabled( true ); // DEBUGGING 109 //uploadButton->setEnabled( true ); // DEBUGGING
105 connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) ); 110 connect( uploadButton, SIGNAL( clicked() ), this, SLOT( uploadSession() ) );
106 111
107 // setup menu bar 112 // setup menu bar
108 113
109 int id; 114 int id;
110 115
111 QMenuBar* mb = menuBar(); 116 QMenuBar* mb = menuBar();
112 117
113 QPopupMenu* fileSave = new QPopupMenu( mb ); 118 QPopupMenu* fileSave = new QPopupMenu( mb );
114 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) ); 119 fileSave->insertItem( tr( "&Session..." ), this, SLOT( fileSaveSession() ) );
115 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) ); 120 fileSave->insertItem( tr( "&Text Log..." ), this, SLOT( fileSaveLog() ) );
116 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) ); 121 fileSave->insertItem( tr( "&Hex Log..." ), this, SLOT( fileSaveHex() ) );
117 122
118 QPopupMenu* fileLoad = new QPopupMenu( mb ); 123 QPopupMenu* fileLoad = new QPopupMenu( mb );
119 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) ); 124 fileLoad->insertItem( tr( "&Session..." ), this, SLOT( fileLoadSession() ) );
120 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) ); 125 //fileLoad->insertItem( "&Log", this, SLOT( fileLoadLog() ) );
121 126
122 QPopupMenu* file = new QPopupMenu( mb ); 127 QPopupMenu* file = new QPopupMenu( mb );
123 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) ); 128 file->insertItem( tr( "&New" ), this, SLOT( fileNew() ) );
124 id = file->insertItem( tr( "&Load" ), fileLoad ); 129 id = file->insertItem( tr( "&Load" ), fileLoad );
125 file->insertItem( tr( "&Save" ), fileSave ); 130 file->insertItem( tr( "&Save" ), fileSave );
126 file->insertSeparator(); 131 file->insertSeparator();
127 uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) ); 132 uploadID = file->insertItem( tr( "&Upload Session" ), this, SLOT( uploadSession() ) );
128 file->insertSeparator(); 133 file->insertSeparator();
129 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) ); 134 file->insertItem( tr( "&Exit" ), qApp, SLOT( quit() ) );
130 135
131 QPopupMenu* sniffer = new QPopupMenu( mb ); 136 QPopupMenu* sniffer = new QPopupMenu( mb );
132 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) ); 137 sniffer->insertItem( tr( "&Configure..." ), this, SLOT( showConfigure() ) );
133 sniffer->insertSeparator(); 138 sniffer->insertSeparator();
134 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) ); 139 startID = sniffer->insertItem( tr( "&Start" ), mw, SLOT( startClicked() ) );
135 sniffer->setItemEnabled( startID, false ); 140 sniffer->setItemEnabled( startID, false );
136 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) ); 141 stopID = sniffer->insertItem( tr( "Sto&p" ), mw, SLOT( stopClicked() ) );
137 sniffer->setItemEnabled( stopID, false ); 142 sniffer->setItemEnabled( stopID, false );
138 143
139 QPopupMenu* view = new QPopupMenu( mb ); 144 QPopupMenu* view = new QPopupMenu( mb );
140 view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) ); 145 view->insertItem( tr( "&Expand All" ), this, SLOT( viewExpandAll() ) );
141 view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) ); 146 view->insertItem( tr( "&Collapse All" ), this, SLOT( viewCollapseAll() ) );
142 147
143 QPopupMenu* demo = new QPopupMenu( mb ); 148 QPopupMenu* demo = new QPopupMenu( mb );
144 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) ); 149 demo->insertItem( tr( "&Add something" ), this, SLOT( demoAddStations() ) );
145 //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) ); 150 //demo->insertItem( tr( "&Read from GPSd" ), this, SLOT( demoReadFromGps() ) );
146 151
147 id = mb->insertItem( tr( "&File" ), file ); 152 id = mb->insertItem( tr( "&File" ), file );
148 153
149 id = mb->insertItem( tr( "&View" ), view ); 154 id = mb->insertItem( tr( "&View" ), view );
150 //mb->setItemEnabled( id, false ); 155 //mb->setItemEnabled( id, false );
151 156
152 id = mb->insertItem( tr( "&Sniffer" ), sniffer ); 157 id = mb->insertItem( tr( "&Sniffer" ), sniffer );
153 158
154 id = mb->insertItem( tr( "&Demo" ), demo ); 159 id = mb->insertItem( tr( "&Demo" ), demo );
155 mb->setItemEnabled( id, true ); 160 mb->setItemEnabled( id, true );
156 mb->setItemEnabled( uploadID, false ); 161 mb->setItemEnabled( uploadID, false );
157 162
158 #ifdef QWS 163 #ifdef QWS
159 mb->insertItem( startButton ); 164 mb->insertItem( startButton );
160 mb->insertItem( stopButton ); 165 mb->insertItem( stopButton );
161 mb->insertItem( uploadButton ); 166 mb->insertItem( uploadButton );
162 mb->insertItem( d ); 167 mb->insertItem( d );
163 #else // Qt3 changed the insertion order. It's now totally random :( 168 #else // Qt3 changed the insertion order. It's now totally random :(
164 mb->insertItem( d ); 169 mb->insertItem( d );
165 mb->insertItem( uploadButton ); 170 mb->insertItem( uploadButton );
166 mb->insertItem( stopButton ); 171 mb->insertItem( stopButton );
167 mb->insertItem( startButton ); 172 mb->insertItem( startButton );
168 #endif 173 #endif
169 174
170 updateToolButtonState(); 175 updateToolButtonState();
171 176
172 // setup status bar (for now only on X11) 177 // setup status bar (for now only on X11)
173 178
174 #ifndef QWS 179 #ifndef QWS
175 statusBar()->message( tr( "Ready." ) ); 180 statusBar()->message( tr( "Ready." ) );
176 #endif 181 #endif
177 182
178 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); 183 connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) );
179 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); 184 connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) );
180}; 185};
181 186
182 187
183 188
184void WellenreiterMainWindow::showConfigure() 189void WellenreiterMainWindow::showConfigure()
185{ 190{
186 qDebug( "show configure..." ); 191 qDebug( "show configure..." );
187 cw->setCaption( tr( "Configure" ) ); 192 cw->setCaption( tr( "Configure" ) );
188 int result = QPEApplication::execDialog( cw ); 193 int result = QPEApplication::execDialog( cw );
189 194
190 if ( result ) updateToolButtonState(); 195 if ( result ) updateToolButtonState();
191} 196}
192 197
193 198
194void WellenreiterMainWindow::updateToolButtonState() 199void WellenreiterMainWindow::updateToolButtonState()
195{ 200{
196 const QString& interface = cw->interfaceName->currentText(); 201 const QString& interface = cw->interfaceName->currentText();
197 const int cardtype = cw->driverType(); 202 const int cardtype = cw->driverType();
198 203
199 if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) 204 if ( ( interface != "<select>" ) && ( cardtype != 0 ) )
200 { 205 {
201 startButton->setEnabled( true ); 206 startButton->setEnabled( true );
202 menuBar()->setItemEnabled( startID, true ); 207 menuBar()->setItemEnabled( startID, true );
203 } 208 }
204 else 209 else
205 { 210 {
206 startButton->setEnabled( false ); 211 startButton->setEnabled( false );
207 menuBar()->setItemEnabled( startID, false ); 212 menuBar()->setItemEnabled( startID, false );
208 } 213 }
209} 214}
210 215
211 216
212void WellenreiterMainWindow::changedSniffingState() 217void WellenreiterMainWindow::changedSniffingState()
213{ 218{
214 startButton->setEnabled( !mw->sniffing ); 219 startButton->setEnabled( !mw->sniffing );
215 menuBar()->setItemEnabled( startID, !mw->sniffing ); 220 menuBar()->setItemEnabled( startID, !mw->sniffing );
216 stopButton->setEnabled( mw->sniffing ); 221 stopButton->setEnabled( mw->sniffing );
217 menuBar()->setItemEnabled( stopID, mw->sniffing ); 222 menuBar()->setItemEnabled( stopID, mw->sniffing );
218 223
219 if ( !mw->sniffing ) 224 if ( !mw->sniffing )
220 { 225 {
221 menuBar()->setItemEnabled( uploadID, true ); 226 menuBar()->setItemEnabled( uploadID, true );
222 uploadButton->setEnabled( true ); 227 uploadButton->setEnabled( true );
223 } 228 }
224} 229}
225 230
226 231
227WellenreiterMainWindow::~WellenreiterMainWindow() 232WellenreiterMainWindow::~WellenreiterMainWindow()
228{ 233{
229 qDebug( "Wellenreiter: bye." ); 234 qDebug( "Wellenreiter: bye." );
230}; 235};
231 236
232 237
233void WellenreiterMainWindow::demoAddStations() 238void WellenreiterMainWindow::demoAddStations()
234{ 239{
235 //mw = 0; // test SIGSEGV handling 240 //mw = 0; // test SIGSEGV handling
236 241
237 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) ); 242 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:00:20:EF:A6:43"), true, 6, 80, GpsLocation( 39.8794, -94.0936) );
238 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) ); 243 mw->netView()->addNewItem( "managed", "Vanille", OMacAddress::fromString("00:30:6D:EF:A6:23"), true, 11, 10, GpsLocation( 0.0, 0.0 ) );
239 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) ); 244 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:03:F8:E7:16:22"), false, 3, 10, GpsLocation( 5.5, 2.3 ) );
240 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) ); 245 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:04:01:E7:56:62"), false, 3, 15, GpsLocation( 2.3, 5.5 ) );
241 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) ); 246 mw->netView()->addNewItem( "adhoc", "ELAN", OMacAddress::fromString("00:05:8E:E7:56:E2"), false, 3, 20, GpsLocation( -10.0, -20.5 ) );
242} 247}
243 248
244 249
245void WellenreiterMainWindow::demoReadFromGps() 250void WellenreiterMainWindow::demoReadFromGps()
diff --git a/noncore/net/wellenreiter/gui/packetview.cpp b/noncore/net/wellenreiter/gui/packetview.cpp
index ef5d020..8312e71 100644
--- a/noncore/net/wellenreiter/gui/packetview.cpp
+++ b/noncore/net/wellenreiter/gui/packetview.cpp
@@ -1,68 +1,71 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "packetview.h" 16#include "packetview.h"
17 17
18/* OPIE */ 18/* OPIE */
19#include <opie2/opcap.h> 19#include <opie2/opcap.h>
20 20
21/* QT */ 21/* QT */
22#include <qtextview.h> 22#include <qtextview.h>
23#include <qspinbox.h> 23#include <qspinbox.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qlist.h> 26#include <qlist.h>
27 27
28using namespace Opie::Net;
29using namespace Opie::Net;
30using namespace Opie::Net;
28PacketView::PacketView( QWidget * parent, const char * name, WFlags f ) 31PacketView::PacketView( QWidget * parent, const char * name, WFlags f )
29 :QFrame( parent, name, f ) 32 :QFrame( parent, name, f )
30{ 33{
31 _number = new QSpinBox( this ); 34 _number = new QSpinBox( this );
32 _number->setPrefix( "Packet # " ); 35 _number->setPrefix( "Packet # " );
33 _label = new QLabel( this ); 36 _label = new QLabel( this );
34 _label->setText( "eth0 2004/03/08 - 00:00:21" ); 37 _label->setText( "eth0 2004/03/08 - 00:00:21" );
35 _list = new QLabel( this ); 38 _list = new QLabel( this );
36 _hex = new QTextView( this ); 39 _hex = new QTextView( this );
37 40
38 QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 ); 41 QVBoxLayout* vb = new QVBoxLayout( this, 2, 2 );
39 QHBoxLayout* hb = new QHBoxLayout( vb, 2 ); 42 QHBoxLayout* hb = new QHBoxLayout( vb, 2 );
40 hb->addWidget( _label ); 43 hb->addWidget( _label );
41 hb->addWidget( _number ); 44 hb->addWidget( _number );
42 vb->addWidget( _list ); 45 vb->addWidget( _list );
43 vb->addWidget( _hex ); 46 vb->addWidget( _hex );
44 47
45 _packets.setAutoDelete( true ); 48 _packets.setAutoDelete( true );
46 49
47 _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" ); 50 _list->setText( "<b>[ 802.11 [ LLC [ IP [ UDP [ DHCP ] ] ] ] ]</b>" );
48}; 51};
49 52
50void PacketView::add( OPacket* p ) 53void PacketView::add( OPacket* p )
51{ 54{
52 _packets.append( p ); 55 _packets.append( p );
53}; 56};
54 57
55const QString PacketView::getLog() const 58const QString PacketView::getLog() const
56{ 59{
57} 60}
58 61
59void PacketView::clear() 62void PacketView::clear()
60{ 63{
61 _packets.clear(); 64 _packets.clear();
62 _number->setMinValue( 0 ); 65 _number->setMinValue( 0 );
63 _number->setMaxValue( 0 ); 66 _number->setMaxValue( 0 );
64 _label->setText( "---" ); 67 _label->setText( "---" );
65 _list->setText( " <b>-- no Packet available --</b> " ); 68 _list->setText( " <b>-- no Packet available --</b> " );
66 _hex->setText( " <i>-- no Packet available --</i> " ); 69 _hex->setText( " <i>-- no Packet available --</i> " );
67} 70}
68 71
diff --git a/noncore/net/wellenreiter/gui/packetview.h b/noncore/net/wellenreiter/gui/packetview.h
index b5f2b26..1ac19bb 100644
--- a/noncore/net/wellenreiter/gui/packetview.h
+++ b/noncore/net/wellenreiter/gui/packetview.h
@@ -1,49 +1,49 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef PACKETVIEW_H 16#ifndef PACKETVIEW_H
17#define PACKETVIEW_H 17#define PACKETVIEW_H
18 18
19#include <qlist.h> 19#include <qlist.h>
20#include <qframe.h> 20#include <qframe.h>
21 21
22class QString; 22class QString;
23class QSpinBox; 23class QSpinBox;
24class QLabel; 24class QLabel;
25class QTextView; 25class QTextView;
26class OPacket; 26namespace Opie {namespace Net {class Opie::Net::OPacket;}}
27 27
28class PacketView: public QFrame 28class PacketView: public QFrame
29{ 29{
30 30
31 public: 31 public:
32 PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 ); 32 PacketView( QWidget * parent = 0, const char * name = "PacketView", WFlags f = 0 );
33 33
34 void add( OPacket* p ); 34 void add( Opie::Net::OPacket* p );
35 const QString getLog() const; 35 const QString getLog() const;
36 void clear(); 36 void clear();
37 37
38 protected: 38 protected:
39 39
40 QSpinBox* _number; 40 QSpinBox* _number;
41 QLabel* _label; 41 QLabel* _label;
42 QLabel* _list; 42 QLabel* _list;
43 QTextView* _hex; 43 QTextView* _hex;
44 QList<OPacket> _packets; 44 QList<Opie::Net::OPacket> _packets;
45 45
46}; 46};
47 47
48#endif 48#endif
49 49
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp
index 6005818..3b7120a 100644
--- a/noncore/net/wellenreiter/gui/scanlist.cpp
+++ b/noncore/net/wellenreiter/gui/scanlist.cpp
@@ -1,240 +1,246 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "scanlist.h" 16#include "scanlist.h"
17#include "configwindow.h" 17#include "configwindow.h"
18#include "logwindow.h" 18#include "logwindow.h"
19 19
20#include <assert.h> 20#include <assert.h>
21#include <qcursor.h> 21#include <qcursor.h>
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#endif 28#endif
29 29
30#ifdef QWS 30#ifdef QWS
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#else 32#else
33#include "resource.h" 33#include "resource.h"
34#endif 34#endif
35 35
36const int col_type = 0; 36const int col_type = 0;
37const int col_essid = 0; 37const int col_essid = 0;
38const int col_sig = 1; 38const int col_sig = 1;
39const int col_ap = 2; 39const int col_ap = 2;
40const int col_channel = 3; 40const int col_channel = 3;
41const int col_wep = 4; 41const int col_wep = 4;
42const int col_traffic = 5; 42const int col_traffic = 5;
43const int col_ip = 6; 43const int col_ip = 6;
44const int col_manuf = 7; 44const int col_manuf = 7;
45const int col_firstseen = 8; 45const int col_firstseen = 8;
46const int col_lastseen = 9; 46const int col_lastseen = 9;
47const int col_location = 10; 47const int col_location = 10;
48 48
49using namespace Opie::Net;
50using namespace Opie::Ui;
51using namespace Opie::Net;
52using namespace Opie::Ui;
53using namespace Opie::Ui;
54using namespace Opie::Net;
49MScanListView::MScanListView( QWidget* parent, const char* name ) 55MScanListView::MScanListView( QWidget* parent, const char* name )
50 :OListView( parent, name ) 56 :OListView( parent, name )
51{ 57{
52 setFrameShape( QListView::StyledPanel ); 58 setFrameShape( QListView::StyledPanel );
53 setFrameShadow( QListView::Sunken ); 59 setFrameShadow( QListView::Sunken );
54 60
55 addColumn( tr( "Net/Station" ) ); 61 addColumn( tr( "Net/Station" ) );
56 setColumnAlignment( col_essid, AlignLeft || AlignVCenter ); 62 setColumnAlignment( col_essid, AlignLeft || AlignVCenter );
57 addColumn( tr( "#" ) ); 63 addColumn( tr( "#" ) );
58 setColumnAlignment( col_sig, AlignCenter ); 64 setColumnAlignment( col_sig, AlignCenter );
59 addColumn( tr( "MAC" ) ); 65 addColumn( tr( "MAC" ) );
60 setColumnAlignment( col_ap, AlignCenter ); 66 setColumnAlignment( col_ap, AlignCenter );
61 addColumn( tr( "Chn" ) ); 67 addColumn( tr( "Chn" ) );
62 setColumnAlignment( col_channel, AlignCenter ); 68 setColumnAlignment( col_channel, AlignCenter );
63 addColumn( tr( "W" ) ); 69 addColumn( tr( "W" ) );
64 setColumnAlignment( col_wep, AlignCenter ); 70 setColumnAlignment( col_wep, AlignCenter );
65 addColumn( tr( "T" ) ); 71 addColumn( tr( "T" ) );
66 setColumnAlignment( col_traffic, AlignCenter ); 72 setColumnAlignment( col_traffic, AlignCenter );
67 addColumn( tr( "IP" ) ); 73 addColumn( tr( "IP" ) );
68 setColumnAlignment( col_ip, AlignCenter ); 74 setColumnAlignment( col_ip, AlignCenter );
69 addColumn( tr( "Manufacturer" ) ); 75 addColumn( tr( "Manufacturer" ) );
70 setColumnAlignment( col_manuf, AlignCenter ); 76 setColumnAlignment( col_manuf, AlignCenter );
71 addColumn( tr( "First Seen" ) ); 77 addColumn( tr( "First Seen" ) );
72 setColumnAlignment( col_firstseen, AlignCenter ); 78 setColumnAlignment( col_firstseen, AlignCenter );
73 addColumn( tr( "Last Seen" ) ); 79 addColumn( tr( "Last Seen" ) );
74 setColumnAlignment( col_lastseen, AlignCenter ); 80 setColumnAlignment( col_lastseen, AlignCenter );
75 addColumn( tr( "Location" ) ); 81 addColumn( tr( "Location" ) );
76 setColumnAlignment( col_location, AlignCenter ); 82 setColumnAlignment( col_location, AlignCenter );
77 setRootIsDecorated( true ); 83 setRootIsDecorated( true );
78 setAllColumnsShowFocus( true ); 84 setAllColumnsShowFocus( true );
79 85
80 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), 86 connect( this, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ),
81 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) ); 87 this, SLOT( contextMenuRequested(QListViewItem*,const QPoint&,int) ) );
82 88
83 #ifdef QWS 89 #ifdef QWS
84 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 90 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
85 #endif 91 #endif
86 92
87}; 93};
88 94
89 95
90MScanListView::~MScanListView() 96MScanListView::~MScanListView()
91{ 97{
92}; 98};
93 99
94 100
95OListViewItem* MScanListView::childFactory() 101OListViewItem* MScanListView::childFactory()
96{ 102{
97 return new MScanListItem( this ); 103 return new MScanListItem( this );
98} 104}
99 105
100 106
101void MScanListView::serializeTo( QDataStream& s) const 107void MScanListView::serializeTo( QDataStream& s) const
102{ 108{
103 qDebug( "serializing MScanListView" ); 109 qDebug( "serializing MScanListView" );
104 OListView::serializeTo( s ); 110 OListView::serializeTo( s );
105} 111}
106 112
107 113
108void MScanListView::serializeFrom( QDataStream& s) 114void MScanListView::serializeFrom( QDataStream& s)
109{ 115{
110 qDebug( "serializing MScanListView" ); 116 qDebug( "serializing MScanListView" );
111 OListView::serializeFrom( s ); 117 OListView::serializeFrom( s );
112} 118}
113 119
114 120
115void MScanListView::addNewItem( const QString& type, 121void MScanListView::addNewItem( const QString& type,
116 const QString& essid, 122 const QString& essid,
117 const OMacAddress& mac, 123 const OMacAddress& mac,
118 bool wep, 124 bool wep,
119 int channel, 125 int channel,
120 int signal, 126 int signal,
121 const GpsLocation& loc, 127 const GpsLocation& loc,
122 bool probe ) 128 bool probe )
123{ 129{
124 QString macaddr = mac.toString(true); 130 QString macaddr = mac.toString(true);
125 131
126 #ifdef DEBUG 132 #ifdef DEBUG
127 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type, 133 qDebug( "MScanList::addNewItem( %s / %s / %s [%d]", (const char*) type,
128 (const char*) essid, (const char*) macaddr, channel ); 134 (const char*) essid, (const char*) macaddr, channel );
129 #endif 135 #endif
130 136
131 // search, if we already have seen this net 137 // search, if we already have seen this net
132 138
133 QString s; 139 QString s;
134 MScanListItem* network; 140 MScanListItem* network;
135 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() ); 141 MScanListItem* item = static_cast<MScanListItem*> ( firstChild() );
136 142
137 while ( item && ( item->text( col_essid ) != essid ) ) 143 while ( item && ( item->text( col_essid ) != essid ) )
138 { 144 {
139 #ifdef DEBUG 145 #ifdef DEBUG
140 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) ); 146 qDebug( "itemtext: %s", (const char*) item->text( col_essid ) );
141 #endif 147 #endif
142 item = static_cast<MScanListItem*> ( item->nextSibling() ); 148 item = static_cast<MScanListItem*> ( item->nextSibling() );
143 } 149 }
144 if ( item ) 150 if ( item )
145 { 151 {
146 // we have already seen this net, check all childs if MAC exists 152 // we have already seen this net, check all childs if MAC exists
147 153
148 network = item; 154 network = item;
149 155
150 item = static_cast<MScanListItem*> ( item->firstChild() ); 156 item = static_cast<MScanListItem*> ( item->firstChild() );
151 assert( item ); // this shouldn't fail 157 assert( item ); // this shouldn't fail
152 158
153 while ( item && ( item->text( col_ap ) != macaddr ) ) 159 while ( item && ( item->text( col_ap ) != macaddr ) )
154 { 160 {
155 #ifdef DEBUG 161 #ifdef DEBUG
156 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) ); 162 qDebug( "subitemtext: %s", (const char*) item->text( col_ap ) );
157 #endif 163 #endif
158 item = static_cast<MScanListItem*> ( item->nextSibling() ); 164 item = static_cast<MScanListItem*> ( item->nextSibling() );
159 } 165 }
160 166
161 if ( item ) 167 if ( item )
162 { 168 {
163 // we have already seen this item, it's a dupe 169 // we have already seen this item, it's a dupe
164 #ifdef DEBUG 170 #ifdef DEBUG
165 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr ); 171 qDebug( "%s is a dupe - ignoring...", (const char*) macaddr );
166 #endif 172 #endif
167 item->receivedBeacon(); 173 item->receivedBeacon();
168 return; 174 return;
169 } 175 }
170 } 176 }
171 else 177 else
172 { 178 {
173 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid ); 179 s.sprintf( "(i) New network: ESSID '%s'", (const char*) essid );
174 MLogWindow::logwindow()->log( s ); 180 MLogWindow::logwindow()->log( s );
175 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe ); 181 network = new MScanListItem( this, "network", essid, QString::null, 0, 0, 0, probe );
176 } 182 }
177 183
178 184
179 // insert new station as child from network 185 // insert new station as child from network
180 // no essid to reduce clutter, maybe later we have a nick or stationname to display!? 186 // no essid to reduce clutter, maybe later we have a nick or stationname to display!?
181 187
182 #ifdef DEBUG 188 #ifdef DEBUG
183 qDebug( "inserting new station %s", (const char*) macaddr ); 189 qDebug( "inserting new station %s", (const char*) macaddr );
184 #endif 190 #endif
185 191
186 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal ); 192 MScanListItem* station = new MScanListItem( network, type, "", macaddr, wep, channel, signal );
187 station->setManufacturer( mac.manufacturer() ); 193 station->setManufacturer( mac.manufacturer() );
188 station->setLocation( loc.dmsPosition() ); 194 station->setLocation( loc.dmsPosition() );
189 195
190 if ( type == "managed" ) 196 if ( type == "managed" )
191 { 197 {
192 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel ); 198 s.sprintf( "(i) New Access Point in '%s' [%d]", (const char*) essid, channel );
193 } 199 }
194 else 200 else
195 { 201 {
196 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel ); 202 s.sprintf( "(i) New AdHoc station in '%s' [%d]", (const char*) essid, channel );
197 } 203 }
198 MLogWindow::logwindow()->log( s ); 204 MLogWindow::logwindow()->log( s );
199} 205}
200 206
201 207
202void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type ) 208void MScanListView::addIfNotExisting( MScanListItem* network, const OMacAddress& addr, const QString& type )
203{ 209{
204 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() ); 210 MScanListItem* subitem = static_cast<MScanListItem*>( network->firstChild() );
205 211
206 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) ) 212 while ( subitem && ( subitem->text( col_ap ) != addr.toString(true) ) )
207 { 213 {
208 #ifdef DEBUG 214 #ifdef DEBUG
209 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) ); 215 qDebug( "subitemtext: %s", (const char*) subitem->text( col_ap ) );
210 #endif 216 #endif
211 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() ); 217 subitem = static_cast<MScanListItem*> ( subitem->nextSibling() );
212 } 218 }
213 219
214 if ( subitem ) 220 if ( subitem )
215 { 221 {
216 // we have already seen this item, it's a dupe 222 // we have already seen this item, it's a dupe
217 #ifdef DEBUG 223 #ifdef DEBUG
218 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) ); 224 qDebug( "%s is a dupe - ignoring...", (const char*) addr.toString(true) );
219 #endif 225 #endif
220 subitem->receivedBeacon(); //FIXME: sent data bit 226 subitem->receivedBeacon(); //FIXME: sent data bit
221 return; 227 return;
222 } 228 }
223 229
224 // Hey, it seems to be a new item :-D 230 // Hey, it seems to be a new item :-D
225 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 ); 231 MScanListItem* station = new MScanListItem( network, type, /* network->text( col_essid ) */ "", addr.toString(true), false, -1, -1 );
226 station->setManufacturer( addr.manufacturer() ); 232 station->setManufacturer( addr.manufacturer() );
227 233
228 QString s; 234 QString s;
229 if ( type == "station" ) 235 if ( type == "station" )
230 { 236 {
231 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 237 s.sprintf( "(i) New Station in '%s' [xx]", (const char*) network->text( col_essid ) );
232 } 238 }
233 else 239 else
234 { 240 {
235 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) ); 241 s.sprintf( "(i) New Wireless Station in '%s' [xx]", (const char*) network->text( col_essid ) );
236 } 242 }
237 MLogWindow::logwindow()->log( s ); 243 MLogWindow::logwindow()->log( s );
238} 244}
239 245
240 246
diff --git a/noncore/net/wellenreiter/gui/scanlist.h b/noncore/net/wellenreiter/gui/scanlist.h
index ab870c2..6a80f70 100644
--- a/noncore/net/wellenreiter/gui/scanlist.h
+++ b/noncore/net/wellenreiter/gui/scanlist.h
@@ -1,140 +1,140 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef SCANLIST_H 16#ifndef SCANLIST_H
17#define SCANLIST_H 17#define SCANLIST_H
18 18
19#include "gps.h" 19#include "gps.h"
20 20
21/* OPIE */ 21/* OPIE */
22#include <opie2/olistview.h> 22#include <opie2/olistview.h>
23#include <opie2/onetutils.h> 23#include <opie2/onetutils.h>
24 24
25/* QT */ 25/* QT */
26#include <qtextstream.h> 26#include <qtextstream.h>
27 27
28class QString; 28class QString;
29class MScanListItem; 29class MScanListItem;
30 30
31class MScanListView: public OListView 31class MScanListView: public Opie::Ui::OListView
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 34
35 public: 35 public:
36 MScanListView( QWidget* parent = 0, const char* name = 0 ); 36 MScanListView( QWidget* parent = 0, const char* name = 0 );
37 virtual ~MScanListView(); 37 virtual ~MScanListView();
38 38
39 virtual OListViewItem* childFactory(); 39 virtual Opie::Ui::OListViewItem* childFactory();
40 virtual void serializeTo( QDataStream& s ) const; 40 virtual void serializeTo( QDataStream& s ) const;
41 virtual void serializeFrom( QDataStream& s ); 41 virtual void serializeFrom( QDataStream& s );
42 42
43 public slots: 43 public slots:
44 void addNewItem( const QString& type, const QString&, const OMacAddress&, bool, int, int, const GpsLocation&, bool = false ); 44 void addNewItem( const QString& type, const QString&, const Opie::Net::OMacAddress&, bool, int, int, const GpsLocation&, bool = false );
45 void addService( const QString& name, const OMacAddress& macaddr, const QString& ip ); 45 void addService( const QString& name, const Opie::Net::OMacAddress& macaddr, const QString& ip );
46 46
47 void fromDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 47 void fromDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via );
48 void toDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 48 void toDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via );
49 void WDStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& viaFrom, const OMacAddress& viaTo ); 49 void WDStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& viaFrom, const Opie::Net::OMacAddress& viaTo );
50 void IBSStraffic( const OMacAddress& from, const OMacAddress& to, const OMacAddress& via ); 50 void IBSStraffic( const Opie::Net::OMacAddress& from, const Opie::Net::OMacAddress& to, const Opie::Net::OMacAddress& via );
51 51
52 void identify( const OMacAddress&, const QString& ipaddr ); 52 void identify( const Opie::Net::OMacAddress&, const QString& ipaddr );
53 53
54 void contextMenuRequested( QListViewItem* item, const QPoint&, int ); 54 void contextMenuRequested( QListViewItem* item, const QPoint&, int );
55 55
56 signals: 56 signals:
57 void rightButtonClicked(QListViewItem*,const QPoint&,int); 57 void rightButtonClicked(QListViewItem*,const QPoint&,int);
58 void joinNetwork( const QString&, const QString&, int, const QString& ); 58 void joinNetwork( const QString&, const QString&, int, const QString& );
59 59
60 protected: 60 protected:
61 void addIfNotExisting( MScanListItem* parent, const OMacAddress& addr, const QString& type = "station" ); 61 void addIfNotExisting( MScanListItem* parent, const Opie::Net::OMacAddress& addr, const QString& type = "station" );
62 62
63}; 63};
64 64
65//****************************** MScanListItem **************************************************************** 65//****************************** MScanListItem ****************************************************************
66 66
67class MScanListItem: public OListViewItem 67class MScanListItem: public Opie::Ui::OListViewItem
68{ 68{
69 public: 69 public:
70 MScanListItem::MScanListItem( QListView* parent, 70 MScanListItem::MScanListItem( QListView* parent,
71 const QString& type = "unknown", 71 const QString& type = "unknown",
72 const QString& essid = "unknown", 72 const QString& essid = "unknown",
73 const QString& macaddr = "unknown", 73 const QString& macaddr = "unknown",
74 bool wep = false, 74 bool wep = false,
75 int channel = 0, 75 int channel = 0,
76 int signal = 0, 76 int signal = 0,
77 bool probed = false ); 77 bool probed = false );
78 78
79 MScanListItem::MScanListItem( QListViewItem* parent, 79 MScanListItem::MScanListItem( QListViewItem* parent,
80 const QString& type = "unknown", 80 const QString& type = "unknown",
81 const QString& essid = "unknown", 81 const QString& essid = "unknown",
82 const QString& macaddr = "unknown", 82 const QString& macaddr = "unknown",
83 bool wep = false, 83 bool wep = false,
84 int channel = 0, 84 int channel = 0,
85 int signal = 0 ); 85 int signal = 0 );
86 86
87 87
88 protected: 88 protected:
89 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed ); 89 virtual void decorateItem( QString type, QString essid, QString macaddr, bool wep, int channel, int signal, bool probed );
90 90
91 public: 91 public:
92 QString type; 92 QString type;
93 93
94 public: 94 public:
95 //const QString& type() { return _type; }; 95 //const QString& type() { return _type; };
96 const QString& essid() const; 96 const QString& essid() const;
97 const QString& macaddr() { return _macaddr; }; 97 const QString& macaddr() { return _macaddr; };
98 bool wep() { return _wep; }; 98 bool wep() { return _wep; };
99 int channel() { return _channel; }; 99 int channel() { return _channel; };
100 int signal() { return _signal; }; 100 int signal() { return _signal; };
101 int beacons() { return _beacons; }; 101 int beacons() { return _beacons; };
102 102
103 void setSignal( int signal ) { /* TODO */ }; 103 void setSignal( int signal ) { /* TODO */ };
104 void receivedBeacon(); 104 void receivedBeacon();
105 105
106 void setManufacturer( const QString& manufacturer ); 106 void setManufacturer( const QString& manufacturer );
107 void setLocation( const QString& location ); 107 void setLocation( const QString& location );
108 108
109 virtual OListViewItem* childFactory(); 109 virtual Opie::Ui::OListViewItem* childFactory();
110 virtual void serializeTo( QDataStream& s ) const; 110 virtual void serializeTo( QDataStream& s ) const;
111 virtual void serializeFrom( QDataStream& s ); 111 virtual void serializeFrom( QDataStream& s );
112 112
113 private: 113 private:
114 QString _type; 114 QString _type;
115 QString _essid; 115 QString _essid;
116 QString _macaddr; 116 QString _macaddr;
117 bool _wep; 117 bool _wep;
118 int _channel; 118 int _channel;
119 int _signal; 119 int _signal;
120 int _beacons; 120 int _beacons;
121 121
122}; 122};
123 123
124//****************************** MScanListViewFactory **************************************************************** 124//****************************** MScanListViewFactory ****************************************************************
125 125
126/* 126/*
127 127
128class MScanListViewFactory : public OListViewFactory 128class MScanListViewFactory : public Opie::Ui::OListViewFactory
129{ 129{
130public: 130public:
131 virtual QListView* listViewFactory(); 131 virtual QListView* listViewFactory();
132 virtual QListViewItem* listViewItemFactory( QListView* lv ); 132 virtual QListViewItem* listViewItemFactory( QListView* lv );
133 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi ); 133 virtual QListViewItem* listViewItemFactory( QListViewItem* lvi );
134 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text ); 134 virtual void setColumnText( int depth, QListViewItem* lvi, int column, const QString& text );
135 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text ); 135 virtual void setCustomData( int depth, QListViewItem* lvi, const QString& text );
136} 136}
137*/ 137*/
138 138
139#endif 139#endif
140 140
diff --git a/noncore/net/wellenreiter/gui/statwindow.cpp b/noncore/net/wellenreiter/gui/statwindow.cpp
index 48e4847..e3c6bbe 100644
--- a/noncore/net/wellenreiter/gui/statwindow.cpp
+++ b/noncore/net/wellenreiter/gui/statwindow.cpp
@@ -1,43 +1,46 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "statwindow.h" 16#include "statwindow.h"
17#include <opie2/olistview.h> 17#include <opie2/olistview.h>
18 18
19using namespace Opie::Ui;
20using namespace Opie::Ui;
21using namespace Opie::Ui;
19MStatWindow::MStatWindow( QWidget * parent, const char * name, WFlags f ) 22MStatWindow::MStatWindow( QWidget * parent, const char * name, WFlags f )
20 :QVBox( parent, name, f ) 23 :QVBox( parent, name, f )
21{ 24{
22 table = new OListView( this ); 25 table = new OListView( this );
23 table->addColumn( tr( "Protocol" ) ); 26 table->addColumn( tr( "Protocol" ) );
24 table->addColumn( tr( "Count" ) ); 27 table->addColumn( tr( "Count" ) );
25 table->setItemMargin( 2 ); 28 table->setItemMargin( 2 );
26}; 29};
27 30
28 31
29void MStatWindow::updateCounter( const QString& protocol, int counter ) 32void MStatWindow::updateCounter( const QString& protocol, int counter )
30{ 33{
31 QListViewItemIterator it( table ); 34 QListViewItemIterator it( table );
32 for ( ; it.current(); ++it ) 35 for ( ; it.current(); ++it )
33 { 36 {
34 if ( it.current()->text( 0 ) == protocol ) 37 if ( it.current()->text( 0 ) == protocol )
35 { 38 {
36 it.current()->setText( 1, QString::number( counter ) ); 39 it.current()->setText( 1, QString::number( counter ) );
37 return; 40 return;
38 } 41 }
39 } 42 }
40 43
41 new OListViewItem( table, protocol, QString::number( counter ) ); 44 new OListViewItem( table, protocol, QString::number( counter ) );
42} 45}
43 46
diff --git a/noncore/net/wellenreiter/gui/statwindow.h b/noncore/net/wellenreiter/gui/statwindow.h
index b9057e7..e11247b 100644
--- a/noncore/net/wellenreiter/gui/statwindow.h
+++ b/noncore/net/wellenreiter/gui/statwindow.h
@@ -1,43 +1,43 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef STATWINDOW_H 16#ifndef STATWINDOW_H
17#define STATWINDOW_H 17#define STATWINDOW_H
18 18
19#include <qvbox.h> 19#include <qvbox.h>
20 20
21class QString; 21class QString;
22class OListView; 22namespace Opie {namespace Ui {class Opie::Ui::OListView;}}
23 23
24class MStatWindow: public QVBox 24class MStatWindow: public QVBox
25{ 25{
26 Q_OBJECT 26 Q_OBJECT
27 27
28 public: 28 public:
29 MStatWindow( QWidget * parent = 0, const char * name = "MStatWindow", WFlags f = 0 ); 29 MStatWindow( QWidget * parent = 0, const char * name = "MStatWindow", WFlags f = 0 );
30 30
31 void log( QString text ); 31 void log( QString text );
32 const QString getLog() const; 32 const QString getLog() const;
33 void clear(); 33 void clear();
34 34
35 void updateCounter( const QString&, int ); 35 void updateCounter( const QString&, int );
36 36
37 protected: 37 protected:
38 OListView* table; 38 Opie::Ui::OListView* table;
39 39
40}; 40};
41 41
42#endif 42#endif
43 43
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index ce416e5..e8d9de7 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,255 +1,261 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12***********************************************************************/ 12***********************************************************************/
13 13
14// Local 14// Local
15 15
16#include "gps.h" 16#include "gps.h"
17#include "wellenreiter.h" 17#include "wellenreiter.h"
18#include "scanlist.h" 18#include "scanlist.h"
19#include "logwindow.h" 19#include "logwindow.h"
20#include "packetview.h" 20#include "packetview.h"
21#include "configwindow.h" 21#include "configwindow.h"
22#include "statwindow.h" 22#include "statwindow.h"
23#include "graphwindow.h" 23#include "graphwindow.h"
24#include "protolistview.h" 24#include "protolistview.h"
25 25
26// Opie 26// Opie
27 27
28#ifdef QWS 28#ifdef QWS
29#include <opie2/oapplication.h> 29#include <opie2/oapplication.h>
30#include <opie2/odevice.h> 30#include <opie2/odevice.h>
31#else 31#else
32#include <qapplication.h> 32#include <qapplication.h>
33#endif 33#endif
34#include <opie2/omanufacturerdb.h> 34#include <opie2/omanufacturerdb.h>
35#include <opie2/onetwork.h> 35#include <opie2/onetwork.h>
36#include <opie2/opcap.h> 36#include <opie2/opcap.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38using namespace Opie; 38using namespace Opie;
39 39
40// Qt 40// Qt
41 41
42#include <qcheckbox.h> 42#include <qcheckbox.h>
43#include <qcombobox.h> 43#include <qcombobox.h>
44#include <qdatetime.h> 44#include <qdatetime.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qmessagebox.h> 47#include <qmessagebox.h>
48#include <qobjectlist.h> 48#include <qobjectlist.h>
49#include <qregexp.h> 49#include <qregexp.h>
50#include <qspinbox.h> 50#include <qspinbox.h>
51#include <qtimer.h> 51#include <qtimer.h>
52#include <qtoolbutton.h> 52#include <qtoolbutton.h>
53#include <qmainwindow.h> 53#include <qmainwindow.h>
54 54
55// Standard 55// Standard
56 56
57#include <assert.h> 57#include <assert.h>
58#include <errno.h> 58#include <errno.h>
59#include <unistd.h> 59#include <unistd.h>
60#include <string.h> 60#include <string.h>
61#include <sys/types.h> 61#include <sys/types.h>
62#include <stdlib.h> 62#include <stdlib.h>
63 63
64using namespace Opie::Core;
65using namespace Opie::Net;
66using namespace Opie::Net;
67using namespace Opie::Core;
68using namespace Opie::Net;
69using namespace Opie::Core;
64Wellenreiter::Wellenreiter( QWidget* parent ) 70Wellenreiter::Wellenreiter( QWidget* parent )
65 : WellenreiterBase( parent, 0, 0 ), 71 : WellenreiterBase( parent, 0, 0 ),
66 sniffing( false ), iface( 0 ), configwindow( 0 ) 72 sniffing( false ), iface( 0 ), configwindow( 0 )
67{ 73{
68 74
69 logwindow->log( "(i) Wellenreiter has been started." ); 75 logwindow->log( "(i) Wellenreiter has been started." );
70 76
71 // 77 //
72 // detect operating system 78 // detect operating system
73 // 79 //
74 80
75 #ifdef QWS 81 #ifdef QWS
76 QString sys; 82 QString sys;
77 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() ); 83 sys.sprintf( "(i) Running on '%s'.", (const char*) ODevice::inst()->systemString() );
78 _system = ODevice::inst()->system(); 84 _system = ODevice::inst()->system();
79 logwindow->log( sys ); 85 logwindow->log( sys );
80 #endif 86 #endif
81 87
82 netview->setColumnWidthMode( 1, QListView::Manual ); 88 netview->setColumnWidthMode( 1, QListView::Manual );
83 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ), 89 connect( netview, SIGNAL( joinNetwork(const QString&,const QString&,int,const QString&) ),
84 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) ); 90 this, SLOT( joinNetwork(const QString&,const QString&,int,const QString&) ) );
85 pcap = new OPacketCapturer(); 91 pcap = new OPacketCapturer();
86 92
87 gps = new GPS( this ); 93 gps = new GPS( this );
88 94
89 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) ); 95 QTimer::singleShot( 1000, this, SLOT( initialTimer() ) );
90 96
91} 97}
92 98
93 99
94Wellenreiter::~Wellenreiter() 100Wellenreiter::~Wellenreiter()
95{ 101{
96 delete pcap; 102 delete pcap;
97} 103}
98 104
99 105
100void Wellenreiter::initialTimer() 106void Wellenreiter::initialTimer()
101{ 107{
102 qDebug( "Wellenreiter::preloading manufacturer database..." ); 108 qDebug( "Wellenreiter::preloading manufacturer database..." );
103 OManufacturerDB::instance(); 109 OManufacturerDB::instance();
104} 110}
105 111
106 112
107void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw ) 113void Wellenreiter::setConfigWindow( WellenreiterConfigWindow* cw )
108{ 114{
109 configwindow = cw; 115 configwindow = cw;
110} 116}
111 117
112 118
113void Wellenreiter::channelHopped(int c) 119void Wellenreiter::channelHopped(int c)
114{ 120{
115 QString title = "Wellenreiter II -scan- ["; 121 QString title = "Wellenreiter II -scan- [";
116 QString left; 122 QString left;
117 if ( c > 1 ) left.fill( '.', c-1 ); 123 if ( c > 1 ) left.fill( '.', c-1 );
118 title.append( left ); 124 title.append( left );
119 title.append( '|' ); 125 title.append( '|' );
120 if ( c < iface->channels() ) 126 if ( c < iface->channels() )
121 { 127 {
122 QString right; 128 QString right;
123 right.fill( '.', iface->channels()-c ); 129 right.fill( '.', iface->channels()-c );
124 title.append( right ); 130 title.append( right );
125 } 131 }
126 title.append( "]" ); 132 title.append( "]" );
127 //title.append( QString().sprintf( " %02d", c ) ); 133 //title.append( QString().sprintf( " %02d", c ) );
128 assert( parent() ); 134 assert( parent() );
129 ( (QMainWindow*) parent() )->setCaption( title ); 135 ( (QMainWindow*) parent() )->setCaption( title );
130} 136}
131 137
132 138
133void Wellenreiter::handleNotification( OPacket* p ) 139void Wellenreiter::handleNotification( OPacket* p )
134{ 140{
135 QObjectList* l = p->queryList(); 141 QObjectList* l = p->queryList();
136 QObjectListIt it( *l ); 142 QObjectListIt it( *l );
137 QObject* o; 143 QObject* o;
138 144
139 while ( (o = it.current()) != 0 ) 145 while ( (o = it.current()) != 0 )
140 { 146 {
141 QString name = it.current()->name(); 147 QString name = it.current()->name();
142 if ( configwindow->parsePackets->isProtocolChecked( name ) ) 148 if ( configwindow->parsePackets->isProtocolChecked( name ) )
143 { 149 {
144 QString action = configwindow->parsePackets->protocolAction( name ); 150 QString action = configwindow->parsePackets->protocolAction( name );
145 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 151 qDebug( "parsePacket-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
146 doAction( action, name, p ); 152 doAction( action, name, p );
147 } 153 }
148 else 154 else
149 { 155 {
150 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name ); 156 qDebug( "protocol '%s' not checked in parsePackets.", (const char*) name );
151 } 157 }
152 ++it; 158 ++it;
153 } 159 }
154} 160}
155 161
156 162
157void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage ) 163void Wellenreiter::handleManagementFrame( OPacket* p, OWaveLanManagementPacket* manage )
158{ 164{
159 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage ); 165 if ( manage->managementType() == "Beacon" ) handleManagementFrameBeacon( p, manage );
160 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage ); 166 else if ( manage->managementType() == "ProbeRequest" ) handleManagementFrameProbeRequest( p, manage );
161 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage ); 167 else if ( manage->managementType() == "ProbeResponse" ) handleManagementFrameProbeResponse( p, manage );
162 else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() ); 168 else qWarning( "Wellenreiter::handleManagementFrame(): '%s' - please handle me!", (const char*) manage->managementType() );
163} 169}
164 170
165 171
166void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request ) 172void Wellenreiter::handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* request )
167{ 173{
168 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 174 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
169 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 175 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
170 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 176 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
171 int channel = ds ? ds->channel() : -1; 177 int channel = ds ? ds->channel() : -1;
172 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 178 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
173 179
174 GpsLocation loc( -111, -111 ); 180 GpsLocation loc( -111, -111 );
175 if ( configwindow->enableGPS->isChecked() ) 181 if ( configwindow->enableGPS->isChecked() )
176 { 182 {
177 // TODO: add check if GPS is working!? 183 // TODO: add check if GPS is working!?
178 qDebug( "Wellenreiter::gathering GPS data..." ); 184 qDebug( "Wellenreiter::gathering GPS data..." );
179 loc = gps->position(); 185 loc = gps->position();
180 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); 186 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
181 } 187 }
182 188
183 if ( essid.length() ) 189 if ( essid.length() )
184 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ ); 190 netView()->addNewItem( "adhoc", essid, header->macAddress2(), false /* should check FrameControl field */, -1, 0, loc, true /* only probed */ );
185 qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" ); 191 qDebug( "Wellenreiter::invalid frame [possibly noise] detected!" );
186} 192}
187 193
188 194
189void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response ) 195void Wellenreiter::handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* response )
190{ 196{
191} 197}
192 198
193 199
194void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon ) 200void Wellenreiter::handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* beacon )
195{ 201{
196 QString type; 202 QString type;
197 if ( beacon->canIBSS() ) 203 if ( beacon->canIBSS() )
198 { 204 {
199 type = "adhoc"; 205 type = "adhoc";
200 } 206 }
201 else if ( beacon->canESS() ) 207 else if ( beacon->canESS() )
202 { 208 {
203 type = "managed"; 209 type = "managed";
204 } 210 }
205 else 211 else
206 { 212 {
207 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" ); 213 qWarning( "Wellenreiter::invalid frame [possibly noise] detected!" );
208 return; 214 return;
209 } 215 }
210 216
211 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) ); 217 OWaveLanManagementSSID* ssid = static_cast<OWaveLanManagementSSID*>( p->child( "802.11 SSID" ) );
212 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>"); 218 QString essid = ssid ? ssid->ID( true /* decloak */ ) : QString("<unknown>");
213 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) ); 219 OWaveLanManagementDS* ds = static_cast<OWaveLanManagementDS*>( p->child( "802.11 DS" ) );
214 int channel = ds ? ds->channel() : -1; 220 int channel = ds ? ds->channel() : -1;
215 221
216 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 222 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
217 223
218 GpsLocation loc( -111, -111 ); 224 GpsLocation loc( -111, -111 );
219 if ( configwindow->enableGPS->isChecked() ) 225 if ( configwindow->enableGPS->isChecked() )
220 { 226 {
221 // TODO: add check if GPS is working!? 227 // TODO: add check if GPS is working!?
222 qDebug( "Wellenreiter::gathering GPS data..." ); 228 qDebug( "Wellenreiter::gathering GPS data..." );
223 loc = gps->position(); 229 loc = gps->position();
224 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() ); 230 qDebug( "Wellenreiter::GPS data received is ( %f , %f ) - dms string = '%s'", loc.latitude(), loc.longitude(), loc.dmsPosition().latin1() );
225 } 231 }
226 232
227 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc ); 233 netView()->addNewItem( type, essid, header->macAddress2(), beacon->canPrivacy(), channel, 0, loc );
228 234
229 // update graph window 235 // update graph window
230 if ( ds ) 236 if ( ds )
231 { 237 {
232 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) ); 238 OPrismHeaderPacket* prism = static_cast<OPrismHeaderPacket*>( p->child( "Prism" ) );
233 if ( prism ) 239 if ( prism )
234 graphwindow->traffic( ds->channel(), prism->signalStrength() ); 240 graphwindow->traffic( ds->channel(), prism->signalStrength() );
235 else 241 else
236 graphwindow->traffic( ds->channel(), 95 ); 242 graphwindow->traffic( ds->channel(), 95 );
237 } 243 }
238} 244}
239 245
240 246
241void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control ) 247void Wellenreiter::handleControlFrame( OPacket* p, OWaveLanControlPacket* control )
242{ 248{
243 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) ); 249 OWaveLanPacket* header = static_cast<OWaveLanPacket*>( p->child( "802.11" ) );
244 250
245 if ( control->controlType() == "Acknowledge" ) 251 if ( control->controlType() == "Acknowledge" )
246 { 252 {
247 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) ); 253 netView()->addNewItem( "adhoc", "<unknown>", header->macAddress1(), false, -1, 0, GpsLocation( -111, -111 ) );
248 } 254 }
249 else 255 else
250 { 256 {
251 qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() ); 257 qDebug( "Wellenreiter::handleControlFrame - please handle %s in a future version! :D", (const char*) control->controlType() );
252 } 258 }
253} 259}
254 260
255 261
@@ -257,467 +263,467 @@ void Wellenreiter::handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAdd
257{ 263{
258 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" ); 264 OWaveLanPacket* wlan = (OWaveLanPacket*) p->child( "802.11" );
259 if ( wlan->fromDS() && !wlan->toDS() ) 265 if ( wlan->fromDS() && !wlan->toDS() )
260 { 266 {
261 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 267 netView()->fromDStraffic( wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
262 from = wlan->macAddress3(); 268 from = wlan->macAddress3();
263 to = wlan->macAddress2(); 269 to = wlan->macAddress2();
264 } 270 }
265 else if ( !wlan->fromDS() && wlan->toDS() ) 271 else if ( !wlan->fromDS() && wlan->toDS() )
266 { 272 {
267 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() ); 273 netView()->toDStraffic( wlan->macAddress2(), wlan->macAddress3(), wlan->macAddress1() );
268 from = wlan->macAddress2(); 274 from = wlan->macAddress2();
269 to = wlan->macAddress3(); 275 to = wlan->macAddress3();
270 } 276 }
271 else if ( wlan->fromDS() && wlan->toDS() ) 277 else if ( wlan->fromDS() && wlan->toDS() )
272 { 278 {
273 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() ); 279 netView()->WDStraffic( wlan->macAddress4(), wlan->macAddress3(), wlan->macAddress1(), wlan->macAddress2() );
274 from = wlan->macAddress4(); 280 from = wlan->macAddress4();
275 to = wlan->macAddress3(); 281 to = wlan->macAddress3();
276 } 282 }
277 else 283 else
278 { 284 {
279 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() ); 285 netView()->IBSStraffic( wlan->macAddress2(), wlan->macAddress1(), wlan->macAddress3() );
280 from = wlan->macAddress2(); 286 from = wlan->macAddress2();
281 to = wlan->macAddress1(); 287 to = wlan->macAddress1();
282 } 288 }
283} 289}
284 290
285 291
286void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ) 292void Wellenreiter::handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to )
287{ 293{
288 from = data->sourceAddress(); 294 from = data->sourceAddress();
289 to = data->destinationAddress(); 295 to = data->destinationAddress();
290 296
291 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) ); 297 netView()->addNewItem( "station", "<wired>", from, false, -1, 0, GpsLocation( -111, -111 ) );
292} 298}
293 299
294 300
295void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest ) 301void Wellenreiter::handleARPData( OPacket* p, OARPPacket*, OMacAddress& source, OMacAddress& dest )
296{ 302{
297 OARPPacket* arp = (OARPPacket*) p->child( "ARP" ); 303 OARPPacket* arp = (OARPPacket*) p->child( "ARP" );
298 if ( arp ) 304 if ( arp )
299 { 305 {
300 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() ); 306 qDebug( "Received ARP traffic (type '%s'): ", (const char*) arp->type() );
301 if ( arp->type() == "REQUEST" ) 307 if ( arp->type() == "REQUEST" )
302 { 308 {
303 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 309 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
304 } 310 }
305 else if ( arp->type() == "REPLY" ) 311 else if ( arp->type() == "REPLY" )
306 { 312 {
307 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() ); 313 netView()->identify( arp->senderMacAddress(), arp->senderIPV4Address().toString() );
308 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() ); 314 netView()->identify( arp->targetMacAddress(), arp->targetIPV4Address().toString() );
309 } 315 }
310 } 316 }
311} 317}
312 318
313 319
314void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest ) 320void Wellenreiter::handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& source, OMacAddress& dest )
315{ 321{
316 //TODO: Implement more IP based protocols 322 //TODO: Implement more IP based protocols
317 323
318 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" ); 324 ODHCPPacket* dhcp = (ODHCPPacket*) p->child( "DHCP" );
319 if ( dhcp ) 325 if ( dhcp )
320 { 326 {
321 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() ); 327 qDebug( "Received DHCP '%s' packet", (const char*) dhcp->type() );
322 if ( dhcp->type() == "OFFER" ) 328 if ( dhcp->type() == "OFFER" )
323 { 329 {
324 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() ); 330 qDebug( "DHCP: '%s' ('%s') seems to be a DHCP server.", (const char*) source.toString(), (const char*) dhcp->serverAddress().toString() );
325 netView()->identify( source, dhcp->serverAddress().toString() ); 331 netView()->identify( source, dhcp->serverAddress().toString() );
326 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() ); 332 netView()->addService( "DHCP", source, dhcp->serverAddress().toString() );
327 } 333 }
328 else if ( dhcp->type() == "ACK" ) 334 else if ( dhcp->type() == "ACK" )
329 { 335 {
330 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() ); 336 qDebug( "DHCP: '%s' ('%s') accepted the offered DHCP address.", (const char*) dhcp->clientMacAddress().toString(), (const char*) dhcp->yourAddress().toString() );
331 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() ); 337 netView()->identify( dhcp->clientMacAddress(), dhcp->yourAddress().toString() );
332 } 338 }
333 } 339 }
334} 340}
335 341
336 342
337QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol ) 343QObject* Wellenreiter::childIfToParse( OPacket* p, const QString& protocol )
338{ 344{
339 if ( configwindow->parsePackets->isProtocolChecked( protocol ) ) 345 if ( configwindow->parsePackets->isProtocolChecked( protocol ) )
340 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" ) 346 if ( configwindow->parsePackets->protocolAction( protocol ) == "Discard!" )
341 return 0; 347 return 0;
342 348
343 return p->child( protocol ); 349 return p->child( protocol );
344} 350}
345 351
346 352
347bool Wellenreiter::checkDumpPacket( OPacket* p ) 353bool Wellenreiter::checkDumpPacket( OPacket* p )
348{ 354{
349 // go through all child packets and see if one is inside the child hierarchy for p 355 // go through all child packets and see if one is inside the child hierarchy for p
350 // if so, do what the user requested (protocolAction), e.g. pass or discard 356 // if so, do what the user requested (protocolAction), e.g. pass or discard
351 if ( !configwindow->writeCaptureFile->isChecked() ) 357 if ( !configwindow->writeCaptureFile->isChecked() )
352 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter 358 return true; // semantic change - we're logging anyway now to /tmp/wellenreiter
353 359
354 QObjectList* l = p->queryList(); 360 QObjectList* l = p->queryList();
355 QObjectListIt it( *l ); 361 QObjectListIt it( *l );
356 QObject* o; 362 QObject* o;
357 363
358 while ( (o = it.current()) != 0 ) 364 while ( (o = it.current()) != 0 )
359 { 365 {
360 QString name = it.current()->name(); 366 QString name = it.current()->name();
361 if ( configwindow->capturePackets->isProtocolChecked( name ) ) 367 if ( configwindow->capturePackets->isProtocolChecked( name ) )
362 { 368 {
363 QString action = configwindow->capturePackets->protocolAction( name ); 369 QString action = configwindow->capturePackets->protocolAction( name );
364 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action ); 370 qDebug( "capturePackets-action for '%s' seems to be '%s'", (const char*) name, (const char*) action );
365 if ( action == "Discard" ) 371 if ( action == "Discard" )
366 { 372 {
367 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) ); 373 logwindow->log( QString().sprintf( "(i) dump-discarding of '%s' packet requested.", (const char*) name ) );
368 return false; 374 return false;
369 } 375 }
370 } 376 }
371 else 377 else
372 { 378 {
373 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name ); 379 qDebug( "protocol '%s' not checked in capturePackets.", (const char*) name );
374 } 380 }
375 ++it; 381 ++it;
376 } 382 }
377 return true; 383 return true;
378} 384}
379 385
380 386
381void Wellenreiter::receivePacket( OPacket* p ) 387void Wellenreiter::receivePacket( OPacket* p )
382{ 388{
383 hexWindow()->add( p ); 389 hexWindow()->add( p );
384 390
385 if ( checkDumpPacket( p ) ) 391 if ( checkDumpPacket( p ) )
386 { 392 {
387 pcap->dump( p ); 393 pcap->dump( p );
388 } 394 }
389 395
390 // check for a management frame 396 // check for a management frame
391 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) ); 397 OWaveLanManagementPacket* manage = static_cast<OWaveLanManagementPacket*>( childIfToParse( p, "802.11 Management" ) );
392 if ( manage ) 398 if ( manage )
393 { 399 {
394 handleManagementFrame( p, manage ); 400 handleManagementFrame( p, manage );
395 return; 401 return;
396 } 402 }
397 403
398 // check for a control frame 404 // check for a control frame
399 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) ); 405 OWaveLanControlPacket* control = static_cast<OWaveLanControlPacket*>( childIfToParse( p, "802.11 Control" ) );
400 if ( control ) 406 if ( control )
401 { 407 {
402 handleControlFrame( p, control ); 408 handleControlFrame( p, control );
403 return; 409 return;
404 } 410 }
405 411
406 OMacAddress source; 412 OMacAddress source;
407 OMacAddress dest; 413 OMacAddress dest;
408 414
409 //TODO: WEP check here 415 //TODO: WEP check here
410 416
411 // check for a wireless data frame 417 // check for a wireless data frame
412 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) ); 418 OWaveLanDataPacket* wlan = static_cast<OWaveLanDataPacket*>( childIfToParse( p, "802.11 Data" ) );
413 if ( wlan ) 419 if ( wlan )
414 { 420 {
415 handleWlanData( p, wlan, source, dest ); 421 handleWlanData( p, wlan, source, dest );
416 } 422 }
417 423
418 // check for a wired data frame 424 // check for a wired data frame
419 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) ); 425 OEthernetPacket* eth = static_cast<OEthernetPacket*>( childIfToParse( p, "Ethernet" ) );
420 if ( eth ) 426 if ( eth )
421 { 427 {
422 handleEthernetData( p, eth, source, dest ); 428 handleEthernetData( p, eth, source, dest );
423 } 429 }
424 430
425 // check for an arp frame since arp frames come in two flavours: 431 // check for an arp frame since arp frames come in two flavours:
426 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't. 432 // 802.11 encapsulates ARP data within IP packets while wired ethernet doesn't.
427 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) ); 433 OARPPacket* arp = static_cast<OARPPacket*>( childIfToParse( p, "ARP" ) );
428 if ( arp ) 434 if ( arp )
429 { 435 {
430 handleARPData( p, arp, source, dest ); 436 handleARPData( p, arp, source, dest );
431 } 437 }
432 438
433 // check for a ip frame 439 // check for a ip frame
434 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) ); 440 OIPPacket* ip = static_cast<OIPPacket*>( childIfToParse( p, "IP" ) );
435 if ( ip ) 441 if ( ip )
436 { 442 {
437 handleIPData( p, ip, source, dest ); 443 handleIPData( p, ip, source, dest );
438 } 444 }
439 445
440 //handleNotification( p ); 446 //handleNotification( p );
441 447
442} 448}
443 449
444 450
445void Wellenreiter::stopClicked() 451void Wellenreiter::stopClicked()
446{ 452{
447 if ( iface ) 453 if ( iface )
448 { 454 {
449 disconnect( SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 455 disconnect( SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
450 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 456 disconnect( SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
451 iface->setChannelHopping(); // stop hopping channels 457 iface->setChannelHopping(); // stop hopping channels
452 } 458 }
453 else 459 else
454 killTimers(); 460 killTimers();
455 461
456 pcap->close(); 462 pcap->close();
457 sniffing = false; 463 sniffing = false;
458 464
459 if ( iface ) 465 if ( iface )
460 { 466 {
461 // switch off monitor mode 467 // switch off monitor mode
462 iface->setMode( "managed" ); 468 iface->setMode( "managed" );
463 // switch off promisc flag 469 // switch off promisc flag
464 iface->setPromiscuousMode( false ); 470 iface->setPromiscuousMode( false );
465 471
466 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess 472 system( "cardctl reset; sleep 1" ); //FIXME: Use OProcess
467 } 473 }
468 474
469 logwindow->log( "(i) Stopped Scanning." ); 475 logwindow->log( "(i) Stopped Scanning." );
470 assert( parent() ); 476 assert( parent() );
471 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" ); 477 ( (QMainWindow*) parent() )->setCaption( "Wellenreiter II" );
472 478
473 // message the user 479 // message the user
474 QMessageBox::information( this, "Wellenreiter II", 480 QMessageBox::information( this, "Wellenreiter II",
475 tr( "Your wireless card\nshould now be usable again." ) ); 481 tr( "Your wireless card\nshould now be usable again." ) );
476 482
477 sniffing = false; 483 sniffing = false;
478 emit( stoppedSniffing() ); 484 emit( stoppedSniffing() );
479 485
480 #ifdef QWS 486 #ifdef QWS
481 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 487 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
482 { 488 {
483 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 489 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
484 } 490 }
485 #else 491 #else
486 #warning FIXME: setScreenSaverMode is not operational on the X11 build 492 #warning FIXME: setScreenSaverMode is not operational on the X11 build
487 #endif 493 #endif
488 494
489 // print out statistics 495 // print out statistics
490 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it ) 496 for( QMap<QString,int>::ConstIterator it = pcap->statistics().begin(); it != pcap->statistics().end(); ++it )
491 statwindow->updateCounter( it.key(), it.data() ); 497 statwindow->updateCounter( it.key(), it.data() );
492} 498}
493 499
494 500
495void Wellenreiter::startClicked() 501void Wellenreiter::startClicked()
496{ 502{
497 // get configuration from config window 503 // get configuration from config window
498 504
499 const QString& interface = configwindow->interfaceName->currentText(); 505 const QString& interface = configwindow->interfaceName->currentText();
500 const int cardtype = configwindow->driverType(); 506 const int cardtype = configwindow->driverType();
501 const int interval = configwindow->hoppingInterval(); 507 const int interval = configwindow->hoppingInterval();
502 508
503 if ( ( interface == "" ) || ( cardtype == 0 ) ) 509 if ( ( interface == "" ) || ( cardtype == 0 ) )
504 { 510 {
505 QMessageBox::information( this, "Wellenreiter II", 511 QMessageBox::information( this, "Wellenreiter II",
506 tr( "Your device is not\nproperly configured. Please reconfigure!" ) ); 512 tr( "Your device is not\nproperly configured. Please reconfigure!" ) );
507 return; 513 return;
508 } 514 }
509 515
510 // configure device 516 // configure device
511 ONetwork* net = ONetwork::instance(); 517 ONetwork* net = ONetwork::instance();
512 518
513 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces 519 // TODO: check if interface is wireless and support sniffing for non-wireless interfaces
514 520
515 if ( !net->isPresent( interface ) ) 521 if ( !net->isPresent( interface ) )
516 { 522 {
517 QMessageBox::information( this, "Wellenreiter II", 523 QMessageBox::information( this, "Wellenreiter II",
518 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) ); 524 tr( "The configured device (%1)\nis not available on this system\n. Please reconfigure!" ).arg( interface ) );
519 return; 525 return;
520 } 526 }
521 527
522 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless! 528 iface = static_cast<OWirelessNetworkInterface*>(net->interface( interface )); // fails if network is not wireless!
523 assert( iface ); 529 assert( iface );
524 530
525 // bring device UP 531 // bring device UP
526 if ( cardtype != DEVTYPE_FILE ) 532 if ( cardtype != DEVTYPE_FILE )
527 { 533 {
528 iface->setUp( true ); 534 iface->setUp( true );
529 if ( !iface->isUp() ) 535 if ( !iface->isUp() )
530 { 536 {
531 QMessageBox::warning( this, "Wellenreiter II", 537 QMessageBox::warning( this, "Wellenreiter II",
532 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) ); 538 tr( "Can't bring interface '%1' up:\n" ).arg( iface->name() ) + strerror( errno ) );
533 return; 539 return;
534 } 540 }
535 } 541 }
536 // set monitor mode 542 // set monitor mode
537 bool usePrism = configwindow->usePrismHeader(); 543 bool usePrism = configwindow->usePrismHeader();
538 544
539 switch ( cardtype ) 545 switch ( cardtype )
540 { 546 {
541 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break; 547 case DEVTYPE_CISCO: iface->setMonitoring( new OCiscoMonitoringInterface( iface, usePrism ) ); break;
542 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break; 548 case DEVTYPE_WLAN_NG: iface->setMonitoring( new OWlanNGMonitoringInterface( iface, usePrism ) ); break;
543 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break; 549 case DEVTYPE_HOSTAP: iface->setMonitoring( new OHostAPMonitoringInterface( iface, usePrism ) ); break;
544 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break; 550 case DEVTYPE_ORINOCO: iface->setMonitoring( new OOrinocoMonitoringInterface( iface, usePrism ) ); break;
545 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break; 551 case DEVTYPE_MANUAL: QMessageBox::information( this, "Wellenreiter II", tr( "Bring your device into\nmonitor mode now." ) ); break;
546 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break; 552 case DEVTYPE_FILE: qDebug( "Wellenreiter: Capturing from file '%s'", (const char*) interface ); break;
547 default: assert( 0 ); // shouldn't reach this 553 default: assert( 0 ); // shouldn't reach this
548 } 554 }
549 555
550 // switch device into monitor mode 556 // switch device into monitor mode
551 if ( cardtype < DEVTYPE_FILE ) 557 if ( cardtype < DEVTYPE_FILE )
552 { 558 {
553 if ( cardtype != DEVTYPE_MANUAL ) 559 if ( cardtype != DEVTYPE_MANUAL )
554 iface->setMode( "monitor" ); 560 iface->setMode( "monitor" );
555 if ( iface->mode() != "monitor" ) 561 if ( iface->mode() != "monitor" )
556 { 562 {
557 if ( QMessageBox::warning( this, "Wellenreiter II", 563 if ( QMessageBox::warning( this, "Wellenreiter II",
558 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) + 564 tr( "Can't set interface '%1'\ninto monitor mode:\n" ).arg( iface->name() ) + strerror( errno ) +
559 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) 565 tr( "\nContinue with limited functionality?" ), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
560 return; 566 return;
561 } 567 }
562 } 568 }
563 569
564 // open GPS device 570 // open GPS device
565 if ( configwindow->enableGPS->isChecked() ) 571 if ( configwindow->enableGPS->isChecked() )
566 { 572 {
567 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 573 qDebug( "Wellenreiter:GPS enabled @ %s:%d", (const char*) configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
568 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() ); 574 gps->open( configwindow->gpsdHost->currentText(), configwindow->gpsdPort->value() );
569 } 575 }
570 576
571 // open pcap and start sniffing 577 // open pcap and start sniffing
572 578
573 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file? 579 if ( configwindow->writeCaptureFile->isChecked() ) // write to a user specified capture file?
574 { 580 {
575 dumpname = configwindow->captureFileName->text(); 581 dumpname = configwindow->captureFileName->text();
576 if ( dumpname.isEmpty() ) dumpname = "captureFile"; 582 if ( dumpname.isEmpty() ) dumpname = "captureFile";
577 dumpname.append( '-' ); 583 dumpname.append( '-' );
578 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) ); 584 dumpname.append( QTime::currentTime().toString().replace( QRegExp( ":" ), "-" ) );
579 dumpname.append( ".wellenreiter" ); 585 dumpname.append( ".wellenreiter" );
580 } 586 }
581 else // write it anyway ;) 587 else // write it anyway ;)
582 { 588 {
583 dumpname = "/var/log/dump.wellenreiter"; 589 dumpname = "/var/log/dump.wellenreiter";
584 } 590 }
585 591
586 if ( cardtype != DEVTYPE_FILE ) 592 if ( cardtype != DEVTYPE_FILE )
587 pcap->open( interface ); 593 pcap->open( interface );
588 else 594 else
589 pcap->open( QFile( interface ) ); 595 pcap->open( QFile( interface ) );
590 596
591 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname ); 597 qDebug( "Wellenreiter:: dumping to %s", (const char*) dumpname );
592 pcap->openDumpFile( dumpname ); 598 pcap->openDumpFile( dumpname );
593 599
594 if ( !pcap->isOpen() ) 600 if ( !pcap->isOpen() )
595 { 601 {
596 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg( 602 QMessageBox::warning( this, "Wellenreiter II", tr( "Can't open packet capturer for\n'%1':\n" ).arg(
597 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) )); 603 cardtype == DEVTYPE_FILE ? (const char*) interface : iface->name() ) + QString(strerror( errno ) ));
598 return; 604 return;
599 } 605 }
600 606
601 // set capturer to non-blocking mode 607 // set capturer to non-blocking mode
602 pcap->setBlocking( false ); 608 pcap->setBlocking( false );
603 609
604 // start channel hopper 610 // start channel hopper
605 if ( cardtype != DEVTYPE_FILE ) 611 if ( cardtype != DEVTYPE_FILE )
606 { 612 {
607 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) ); 613 logwindow->log( QString().sprintf( "(i) Starting channel hopper (d=%d ms)", configwindow->hopInterval->value() ) );
608 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window 614 iface->setChannelHopping( configwindow->hopInterval->value() ); //use interval from config window
609 } 615 }
610 616
611 if ( cardtype != DEVTYPE_FILE ) 617 if ( cardtype != DEVTYPE_FILE )
612 { 618 {
613 // connect socket notifier and start channel hopper 619 // connect socket notifier and start channel hopper
614 connect( pcap, SIGNAL( receivedPacket(OPacket*) ), this, SLOT( receivePacket(OPacket*) ) ); 620 connect( pcap, SIGNAL( receivedPacket(Opie::Net::OPacket*) ), this, SLOT( receivePacket(Opie::Net::OPacket*) ) );
615 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) ); 621 connect( iface->channelHopper(), SIGNAL( hopped(int) ), this, SLOT( channelHopped(int) ) );
616 } 622 }
617 else 623 else
618 { 624 {
619 // start timer for reading packets 625 // start timer for reading packets
620 startTimer( 100 ); 626 startTimer( 100 );
621 } 627 }
622 628
623 logwindow->log( "(i) Started Scanning." ); 629 logwindow->log( "(i) Started Scanning." );
624 sniffing = true; 630 sniffing = true;
625 631
626 #ifdef QWS 632 #ifdef QWS
627 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() ) 633 if ( WellenreiterConfigWindow::instance()->disablePM->isChecked() )
628 { 634 {
629 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 635 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
630 } 636 }
631 #else 637 #else
632 #warning FIXME: setScreenSaverMode is not operational on the X11 build 638 #warning FIXME: setScreenSaverMode is not operational on the X11 build
633 #endif 639 #endif
634 640
635 emit( startedSniffing() ); 641 emit( startedSniffing() );
636 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title 642 if ( cardtype != DEVTYPE_FILE ) channelHopped( 6 ); // set title
637 else 643 else
638 { 644 {
639 assert( parent() ); 645 assert( parent() );
640 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) ); 646 ( (QMainWindow*) parent() )->setCaption( tr( "Wellenreiter II - replaying capture file..." ) );
641 } 647 }
642} 648}
643 649
644 650
645void Wellenreiter::timerEvent( QTimerEvent* ) 651void Wellenreiter::timerEvent( QTimerEvent* )
646{ 652{
647 qDebug( "Wellenreiter::timerEvent()" ); 653 qDebug( "Wellenreiter::timerEvent()" );
648 OPacket* p = pcap->next(); 654 OPacket* p = pcap->next();
649 if ( !p ) // no more packets available 655 if ( !p ) // no more packets available
650 { 656 {
651 stopClicked(); 657 stopClicked();
652 } 658 }
653 else 659 else
654 { 660 {
655 receivePacket( p ); 661 receivePacket( p );
656 delete p; 662 delete p;
657 } 663 }
658} 664}
659 665
660 666
661void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p ) 667void Wellenreiter::doAction( const QString& action, const QString& protocol, OPacket* p )
662{ 668{
663 #ifdef QWS 669 #ifdef QWS
664 if ( action == "TouchSound" ) 670 if ( action == "TouchSound" )
665 ODevice::inst()->playTouchSound(); 671 ODevice::inst()->playTouchSound();
666 else if ( action == "AlarmSound" ) 672 else if ( action == "AlarmSound" )
667 ODevice::inst()->playAlarmSound(); 673 ODevice::inst()->playAlarmSound();
668 else if ( action == "KeySound" ) 674 else if ( action == "KeySound" )
669 ODevice::inst()->playKeySound(); 675 ODevice::inst()->playKeySound();
670 else if ( action == "LedOn" ) 676 else if ( action == "LedOn" )
671 ODevice::inst()->setLedState( Led_Mail, Led_On ); 677 ODevice::inst()->setLedState( Led_Mail, Led_On );
672 else if ( action == "LedOff" ) 678 else if ( action == "LedOff" )
673 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 679 ODevice::inst()->setLedState( Led_Mail, Led_Off );
674 else if ( action == "LogMessage" ) 680 else if ( action == "LogMessage" )
675 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 681 logwindow->log( QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
676 else if ( action == "MessageBox" ) 682 else if ( action == "MessageBox" )
677 QMessageBox::information( this, "Notification!", 683 QMessageBox::information( this, "Notification!",
678 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) ); 684 QString().sprintf( "Got packet with protocol '%s'", (const char*) protocol ) );
679 #else 685 #else
680 #warning Actions do not work with Qt/X11 yet 686 #warning Actions do not work with Qt/X11 yet
681 #endif 687 #endif
682} 688}
683 689
684void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr) 690void Wellenreiter::joinNetwork(const QString& type, const QString& essid, int channel, const QString& macaddr)
685{ 691{
686 #ifdef QWS 692 #ifdef QWS
687 if ( !iface ) 693 if ( !iface )
688 { 694 {
689 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) ); 695 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "No wireless\ninterface available." ) );
690 return; 696 return;
691 } 697 }
692 698
693 if ( sniffing ) 699 if ( sniffing )
694 { 700 {
695 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) ); 701 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Stop sniffing before\njoining a net." ) );
696 return; 702 return;
697 } 703 }
698 704
699 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s", 705 qDebug( "joinNetwork() with Interface %s: %s, %s, %d, %s",
700 (const char*) iface->name(), 706 (const char*) iface->name(),
701 (const char*) type, 707 (const char*) type,
702 (const char*) essid, 708 (const char*) essid,
703 channel, 709 channel,
704 (const char*) macaddr ); 710 (const char*) macaddr );
705 711
706 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" ); 712 QCopEnvelope msg( "QPE/Application/networksettings", "wlan(QString,QString,QString)" );
707 int count = 3; 713 int count = 3;
708 qDebug("sending %d messages",count); 714 qDebug("sending %d messages",count);
709 msg << QString("count") << QString::number(count); 715 msg << QString("count") << QString::number(count);
710 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() ); 716 qDebug("msg >%s< Mode >%s<", iface->name(),type.latin1() );
711 msg << QString(iface->name()) << QString("Mode") << type; 717 msg << QString(iface->name()) << QString("Mode") << type;
712 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1()); 718 qDebug("msg >%s< essid >%s<", iface->name(),essid.latin1());
713 msg << QString(iface->name()) << QString("ESSID") << essid; 719 msg << QString(iface->name()) << QString("ESSID") << essid;
714 qDebug("msg >%s< channel >%d<", iface->name(),channel); 720 qDebug("msg >%s< channel >%d<", iface->name(),channel);
715 msg << QString(iface->name()) << QString("Channel") << channel; 721 msg << QString(iface->name()) << QString("Channel") << channel;
716// qDebug("msg >%s< mac >%s<", iface->name(),macaddr); 722// qDebug("msg >%s< mac >%s<", iface->name(),macaddr);
717// msg << QString(iface->name()) << QString("MacAddr") << macaddr; 723// msg << QString(iface->name()) << QString("MacAddr") << macaddr;
718 #else 724 #else
719 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) ); 725 QMessageBox::warning( this, tr( "Can't do that!" ), tr( "Function only available on Embedded build" ) );
720 #endif 726 #endif
721 727
722} 728}
723 729
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index d02813b..83299c9 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,107 +1,107 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
5** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
6** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
7** packaging of this file. 7** packaging of this file.
8** 8**
9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11** 11**
12**********************************************************************/ 12**********************************************************************/
13 13
14#ifndef WELLENREITER_H 14#ifndef WELLENREITER_H
15#define WELLENREITER_H 15#define WELLENREITER_H
16 16
17#include "wellenreiterbase.h" 17#include "wellenreiterbase.h"
18 18
19#ifdef QWS 19#ifdef QWS
20#include <opie2/odevice.h> 20#include <opie2/odevice.h>
21using namespace Opie;
22#endif 21#endif
23 22
24class QTimerEvent; 23class QTimerEvent;
25class QPixmap; 24class QPixmap;
26class OPacket; 25namespace Opie {namespace Net {class Opie::Net::OPacket;}}
27class OWaveLanManagementPacket; 26namespace Opie {namespace Net {class Opie::Net::OWaveLanManagementPacket;}}
28class OWaveLanControlPacket; 27namespace Opie {namespace Net {class Opie::Net::OWaveLanControlPacket;}}
29class OWaveLanDataPacket; 28namespace Opie {namespace Net {class Opie::Net::OWaveLanDataPacket;}}
30class OEthernetPacket; 29namespace Opie {namespace Net {class Opie::Net::OEthernetPacket;}}
31class OARPPacket; 30namespace Opie {namespace Net {class Opie::Net::OARPPacket;}}
32class OMacAddress; 31namespace Opie {namespace Net {class Opie::Net::OMacAddress;}}
33class OIPPacket; 32namespace Opie {namespace Net {class Opie::Net::OIPPacket;}}
34class OPacketCapturer; 33namespace Opie {namespace Net {class Opie::Net::OPacket;}}
35class OWirelessNetworkInterface; 34namespace Opie {namespace Net {class Opie::Net::OWirelessNetworkInterface;}}
35namespace Opie {namespace Net {class Opie::Net::OPacketCapturer;}}
36class PacketView; 36class PacketView;
37class WellenreiterConfigWindow; 37class WellenreiterConfigWindow;
38class MLogWindow; 38class MLogWindow;
39class GPS; 39class GPS;
40 40
41class Wellenreiter : public WellenreiterBase { 41class Wellenreiter : public WellenreiterBase {
42 Q_OBJECT 42 Q_OBJECT
43 43
44 public: 44 public:
45 Wellenreiter( QWidget* parent = 0 ); 45 Wellenreiter( QWidget* parent = 0 );
46 ~Wellenreiter(); 46 ~Wellenreiter();
47 47
48 void setConfigWindow( WellenreiterConfigWindow* cw ); 48 void setConfigWindow( WellenreiterConfigWindow* cw );
49 MScanListView* netView() const { return netview; }; 49 MScanListView* netView() const { return netview; };
50 MLogWindow* logWindow() const { return logwindow; }; 50 MLogWindow* logWindow() const { return logwindow; };
51 PacketView* hexWindow() const { return hexwindow; }; 51 PacketView* hexWindow() const { return hexwindow; };
52 bool isDaemonRunning() const { return sniffing; }; 52 bool isDaemonRunning() const { return sniffing; };
53 QString captureFileName() const { return dumpname; }; 53 QString captureFileName() const { return dumpname; };
54 54
55 public: 55 public:
56 bool sniffing; 56 bool sniffing;
57 57
58 protected: 58 protected:
59 virtual void timerEvent( QTimerEvent* ); 59 virtual void timerEvent( QTimerEvent* );
60 60
61 public slots: 61 public slots:
62 void initialTimer(); 62 void initialTimer();
63 63
64 void channelHopped(int); 64 void channelHopped(int);
65 void receivePacket(OPacket*); 65 void receivePacket(Opie::Net::OPacket*);
66 void startClicked(); 66 void startClicked();
67 void stopClicked(); 67 void stopClicked();
68 68
69 void joinNetwork(const QString&,const QString&,int,const QString&); 69 void joinNetwork(const QString&,const QString&,int,const QString&);
70 70
71 signals: 71 signals:
72 void startedSniffing(); 72 void startedSniffing();
73 void stoppedSniffing(); 73 void stoppedSniffing();
74 74
75 private: 75 private:
76 void handleManagementFrame( OPacket* p, OWaveLanManagementPacket* ); 76 void handleManagementFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
77 void handleManagementFrameBeacon( OPacket* p, OWaveLanManagementPacket* ); 77 void handleManagementFrameBeacon( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
78 void handleManagementFrameProbeRequest( OPacket* p, OWaveLanManagementPacket* ); 78 void handleManagementFrameProbeRequest( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
79 void handleManagementFrameProbeResponse( OPacket* p, OWaveLanManagementPacket* ); 79 void handleManagementFrameProbeResponse( Opie::Net::OPacket* p, Opie::Net::OWaveLanManagementPacket* );
80 void handleControlFrame( OPacket* p, OWaveLanControlPacket* control ); 80 void handleControlFrame( Opie::Net::OPacket* p, Opie::Net::OWaveLanControlPacket* control );
81 void handleWlanData( OPacket* p, OWaveLanDataPacket* data, OMacAddress& from, OMacAddress& to ); 81 void handleWlanData( Opie::Net::OPacket* p, Opie::Net::OWaveLanDataPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
82 void handleEthernetData( OPacket* p, OEthernetPacket* data, OMacAddress& from, OMacAddress& to ); 82 void handleEthernetData( Opie::Net::OPacket* p, Opie::Net::OEthernetPacket* data, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
83 void handleARPData( OPacket* p, OARPPacket* arp, OMacAddress& from, OMacAddress& to ); 83 void handleARPData( Opie::Net::OPacket* p, Opie::Net::OARPPacket* arp, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
84 void handleIPData( OPacket* p, OIPPacket* ip, OMacAddress& from, OMacAddress& to ); 84 void handleIPData( Opie::Net::OPacket* p, Opie::Net::OIPPacket* ip, Opie::Net::OMacAddress& from, Opie::Net::OMacAddress& to );
85 void handleNotification( OPacket* p ); 85 void handleNotification( Opie::Net::OPacket* p );
86 void doAction( const QString& action, const QString& protocol, OPacket* p ); 86 void doAction( const QString& action, const QString& protocol, Opie::Net::OPacket* p );
87 QObject* childIfToParse( OPacket* p, const QString& protocol ); 87 QObject* childIfToParse( Opie::Net::OPacket* p, const QString& protocol );
88 bool checkDumpPacket( OPacket* p ); 88 bool checkDumpPacket( Opie::Net::OPacket* p );
89 89
90 private: 90 private:
91 #ifdef QWS 91 #ifdef QWS
92 OSystem _system; // Opie Operating System identifier 92 Opie::Core::OSystem _system; // Opie Operating System identifier
93 #endif 93 #endif
94 94
95 QString dumpname; 95 QString dumpname;
96 OWirelessNetworkInterface* iface; 96 Opie::Net::OWirelessNetworkInterface* iface;
97 OPacketCapturer* pcap; 97 Opie::Net::OPacketCapturer* pcap;
98 WellenreiterConfigWindow* configwindow; 98 WellenreiterConfigWindow* configwindow;
99 GPS* gps; 99 GPS* gps;
100 100
101 //void readConfig(); 101 //void readConfig();
102 //void writeConfig(); 102 //void writeConfig();
103}; 103};
104 104
105 105
106 106
107#endif 107#endif
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
index 3d0595d..f035e89 100644
--- a/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiterbase.cpp
@@ -1,177 +1,180 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16#include "wellenreiterbase.h" 16#include "wellenreiterbase.h"
17 17
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qlayout.h> 19#include <qlayout.h>
20 20
21#include "logwindow.h" 21#include "logwindow.h"
22#include "packetview.h" 22#include "packetview.h"
23#include "scanlist.h" 23#include "scanlist.h"
24#include "statwindow.h" 24#include "statwindow.h"
25#include "graphwindow.h" 25#include "graphwindow.h"
26 26
27#ifdef QWS 27#ifdef QWS
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <opie2/otabwidget.h> 29#include <opie2/otabwidget.h>
30using namespace Opie; 30using namespace Opie;
31#else 31#else
32#include "resource.h" 32#include "resource.h"
33#include <qtabwidget.h> 33#include <qtabwidget.h>
34#endif 34#endif
35 35
36 36
37/* 37/*
38 * Constructs a WellenreiterBase which is a child of 'parent', with the 38 * Constructs a WellenreiterBase which is a child of 'parent', with the
39 * name 'name' and widget flags set to 'f' 39 * name 'name' and widget flags set to 'f'
40 */ 40 */
41using namespace Opie::Ui;
42using namespace Opie::Ui;
43using namespace Opie::Ui;
41WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl ) 44WellenreiterBase::WellenreiterBase( QWidget* parent, const char* name, WFlags fl )
42 : QWidget( parent, name, fl ) 45 : QWidget( parent, name, fl )
43{ 46{
44 //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) ); 47 //ani1 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot0" ) );
45 //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) ); 48 //ani2 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot90" ) );
46 //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) ); 49 //ani3 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot180" ) );
47 //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) ); 50 //ani4 = new QPixmap( Resource::loadPixmap( "wellenreiter/networks_rot270" ) );
48 51
49 if ( !name ) 52 if ( !name )
50 setName( "WellenreiterBase" ); 53 setName( "WellenreiterBase" );
51 resize( 191, 294 ); 54 resize( 191, 294 );
52#ifdef QWS 55#ifdef QWS
53 setCaption( tr( "Wellenreiter/Opie" ) ); 56 setCaption( tr( "Wellenreiter/Opie" ) );
54#else 57#else
55 setCaption( tr( "Wellenreiter/X11" ) ); 58 setCaption( tr( "Wellenreiter/X11" ) );
56#endif 59#endif
57 WellenreiterBaseLayout = new QVBoxLayout( this ); 60 WellenreiterBaseLayout = new QVBoxLayout( this );
58 WellenreiterBaseLayout->setSpacing( 2 ); 61 WellenreiterBaseLayout->setSpacing( 2 );
59 WellenreiterBaseLayout->setMargin( 0 ); 62 WellenreiterBaseLayout->setMargin( 0 );
60#ifdef QWS 63#ifdef QWS
61 TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global ); 64 TabWidget = new OTabWidget( this, "TabWidget", OTabWidget::Global );
62#else 65#else
63 TabWidget = new QTabWidget( this, "TabWidget" ); 66 TabWidget = new QTabWidget( this, "TabWidget" );
64#endif 67#endif
65 ap = new QWidget( TabWidget, "ap" ); 68 ap = new QWidget( TabWidget, "ap" );
66 apLayout = new QVBoxLayout( ap ); 69 apLayout = new QVBoxLayout( ap );
67 apLayout->setSpacing( 2 ); 70 apLayout->setSpacing( 2 );
68 apLayout->setMargin( 2 ); 71 apLayout->setMargin( 2 );
69 72
70 //--------- NETVIEW TAB -------------- 73 //--------- NETVIEW TAB --------------
71 74
72 netview = new MScanListView( ap ); 75 netview = new MScanListView( ap );
73 apLayout->addWidget( netview ); 76 apLayout->addWidget( netview );
74 77
75 //--------- GRAPH TAB -------------- 78 //--------- GRAPH TAB --------------
76 79
77 graphwindow = new MGraphWindow( TabWidget, "Graph" ); 80 graphwindow = new MGraphWindow( TabWidget, "Graph" );
78 81
79 //--------- LOG TAB -------------- 82 //--------- LOG TAB --------------
80 83
81 logwindow = new MLogWindow( TabWidget, "Log" ); 84 logwindow = new MLogWindow( TabWidget, "Log" );
82 85
83 //--------- HEX TAB -------------- 86 //--------- HEX TAB --------------
84 87
85 hexwindow = new PacketView( TabWidget, "Hex" ); 88 hexwindow = new PacketView( TabWidget, "Hex" );
86 89
87 //--------- STAT TAB -------------- 90 //--------- STAT TAB --------------
88 91
89 statwindow = new MStatWindow( TabWidget, "Stat" ); 92 statwindow = new MStatWindow( TabWidget, "Stat" );
90 93
91 //--------- ABOUT TAB -------------- 94 //--------- ABOUT TAB --------------
92 95
93 about = new QWidget( TabWidget, "about" ); 96 about = new QWidget( TabWidget, "about" );
94 aboutLayout = new QGridLayout( about ); 97 aboutLayout = new QGridLayout( about );
95 aboutLayout->setSpacing( 6 ); 98 aboutLayout->setSpacing( 6 );
96 aboutLayout->setMargin( 11 ); 99 aboutLayout->setMargin( 11 );
97 100
98 PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" ); 101 PixmapLabel1_3_2 = new QLabel( about, "PixmapLabel1_3_2" );
99 PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) ); 102 PixmapLabel1_3_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, PixmapLabel1_3_2->sizePolicy().hasHeightForWidth() ) );
100 PixmapLabel1_3_2->setFrameShape( QLabel::Panel ); 103 PixmapLabel1_3_2->setFrameShape( QLabel::Panel );
101 PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken ); 104 PixmapLabel1_3_2->setFrameShadow( QLabel::Sunken );
102 PixmapLabel1_3_2->setLineWidth( 2 ); 105 PixmapLabel1_3_2->setLineWidth( 2 );
103 PixmapLabel1_3_2->setMargin( 0 ); 106 PixmapLabel1_3_2->setMargin( 0 );
104 PixmapLabel1_3_2->setMidLineWidth( 0 ); 107 PixmapLabel1_3_2->setMidLineWidth( 0 );
105 PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) ); 108 PixmapLabel1_3_2->setPixmap( Resource::loadPixmap( "wellenreiter/logo" ) );
106 PixmapLabel1_3_2->setScaledContents( TRUE ); 109 PixmapLabel1_3_2->setScaledContents( TRUE );
107 PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) ); 110 PixmapLabel1_3_2->setAlignment( int( QLabel::AlignCenter ) );
108 111
109 aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 ); 112 aboutLayout->addWidget( PixmapLabel1_3_2, 0, 0 );
110 113
111 TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" ); 114 TextLabel1_4_2 = new QLabel( about, "TextLabel1_4_2" );
112 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); 115 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() );
113 TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); 116 TextLabel1_4_2_font.setFamily( "adobe-helvetica" );
114 TextLabel1_4_2_font.setPointSize( 10 ); 117 TextLabel1_4_2_font.setPointSize( 10 );
115 TextLabel1_4_2->setFont( TextLabel1_4_2_font ); 118 TextLabel1_4_2->setFont( TextLabel1_4_2_font );
116 TextLabel1_4_2->setText( tr( "<p align=center>\n" 119 TextLabel1_4_2->setText( tr( "<p align=center>\n"
117"<hr>\n" 120"<hr>\n"
118"Michael 'Mickey' Lauer<br><hr>\n" 121"Michael 'Mickey' Lauer<br><hr>\n"
119"Max Moser<br>\n" 122"Max Moser<br>\n"
120"Martin J. Muench<br>\n" 123"Martin J. Muench<br>\n"
121"<b>www.wellenreiter.net</b>\n" 124"<b>www.wellenreiter.net</b>\n"
122"</p>" ) ); 125"</p>" ) );
123 TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) ); 126 TextLabel1_4_2->setAlignment( int( QLabel::AlignCenter ) );
124 127
125 aboutLayout->addWidget( TextLabel1_4_2, 1, 0 ); 128 aboutLayout->addWidget( TextLabel1_4_2, 1, 0 );
126 129
127#ifdef QWS 130#ifdef QWS
128 TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) ); 131 TabWidget->addTab( ap, "wellenreiter/networks", tr( "Nets" ) );
129 TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) ); 132 TabWidget->addTab( graphwindow, "wellenreiter/graph", tr( "Graph" ) );
130 TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) ); 133 TabWidget->addTab( logwindow, "wellenreiter/log", tr( "Log" ) );
131 TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) ); 134 TabWidget->addTab( hexwindow, "wellenreiter/hex", tr( "Hex" ) );
132 TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) ); 135 TabWidget->addTab( statwindow, "wellenreiter/stat", tr( "Stat" ) );
133 TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) ); 136 TabWidget->addTab( about, "wellenreiter/about", tr( "About" ) );
134#else 137#else
135 TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) ); 138 TabWidget->addTab( ap, /* "wellenreiter/networks", */ tr( "Networks" ) );
136 TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) ); 139 TabWidget->addTab( graphwindow, /* "wellenreiter/graph", */ tr( "Graph" ) );
137 TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) ); 140 TabWidget->addTab( logwindow, /* "wellenreiter/log", */ tr( "Log" ) );
138 TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) ); 141 TabWidget->addTab( hexwindow, /* "wellenreiter/hex", */ tr( "Hex" ) );
139 TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) ); 142 TabWidget->addTab( statwindow, /* "wellenreiter/hex", */ tr( "Stat" ) );
140 TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) ); 143 TabWidget->addTab( about, /* "wellenreiter/about", */ tr( "About" ) );
141#endif 144#endif
142 WellenreiterBaseLayout->addWidget( TabWidget ); 145 WellenreiterBaseLayout->addWidget( TabWidget );
143 146
144#ifdef QWS 147#ifdef QWS
145 TabWidget->setCurrentTab( tr( "Nets" ) ); 148 TabWidget->setCurrentTab( tr( "Nets" ) );
146#endif 149#endif
147 150
148} 151}
149 152
150/* 153/*
151 * Destroys the object and frees any allocated resources 154 * Destroys the object and frees any allocated resources
152 */ 155 */
153WellenreiterBase::~WellenreiterBase() 156WellenreiterBase::~WellenreiterBase()
154{ 157{
155 // no need to delete child widgets, Qt does it all for us 158 // no need to delete child widgets, Qt does it all for us
156} 159}
157 160
158/* 161/*
159 * Main event handler. Reimplemented to handle application 162 * Main event handler. Reimplemented to handle application
160 * font changes 163 * font changes
161 */ 164 */
162bool WellenreiterBase::event( QEvent* ev ) 165bool WellenreiterBase::event( QEvent* ev )
163{ 166{
164 bool ret = QWidget::event( ev ); 167 bool ret = QWidget::event( ev );
165 if ( ev->type() == QEvent::ApplicationFontChange ) { 168 if ( ev->type() == QEvent::ApplicationFontChange ) {
166 //QFont Log_2_font( Log_2->font() ); 169 //QFont Log_2_font( Log_2->font() );
167 //Log_2_font.setFamily( "adobe-courier" ); 170 //Log_2_font.setFamily( "adobe-courier" );
168 //Log_2_font.setPointSize( 8 ); 171 //Log_2_font.setPointSize( 8 );
169 //Log_2->setFont( Log_2_font ); 172 //Log_2->setFont( Log_2_font );
170 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() ); 173 QFont TextLabel1_4_2_font( TextLabel1_4_2->font() );
171 TextLabel1_4_2_font.setFamily( "adobe-helvetica" ); 174 TextLabel1_4_2_font.setFamily( "adobe-helvetica" );
172 TextLabel1_4_2_font.setPointSize( 10 ); 175 TextLabel1_4_2_font.setPointSize( 10 );
173 TextLabel1_4_2->setFont( TextLabel1_4_2_font ); 176 TextLabel1_4_2->setFont( TextLabel1_4_2_font );
174 } 177 }
175 return ret; 178 return ret;
176} 179}
177 180
diff --git a/noncore/net/wellenreiter/gui/wellenreiterbase.h b/noncore/net/wellenreiter/gui/wellenreiterbase.h
index 126aad2..e40b699 100644
--- a/noncore/net/wellenreiter/gui/wellenreiterbase.h
+++ b/noncore/net/wellenreiter/gui/wellenreiterbase.h
@@ -1,77 +1,77 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Wellenreiter II. 4** This file is part of Wellenreiter II.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef WELLENREITERBASE_H 16#ifndef WELLENREITERBASE_H
17#define WELLENREITERBASE_H 17#define WELLENREITERBASE_H
18 18
19#include <qvariant.h> 19#include <qvariant.h>
20#include <qwidget.h> 20#include <qwidget.h>
21class QVBoxLayout; 21class QVBoxLayout;
22class QHBoxLayout; 22class QHBoxLayout;
23class QGridLayout; 23class QGridLayout;
24class QLabel; 24class QLabel;
25class MScanListView; 25class MScanListView;
26class MScanListItem; 26class MScanListItem;
27class QPushButton; 27class QPushButton;
28class MLogWindow; 28class MLogWindow;
29class MStatWindow; 29class MStatWindow;
30class MGraphWindow; 30class MGraphWindow;
31class PacketView; 31class PacketView;
32 32
33#ifdef QWS 33#ifdef QWS
34#include <opie2/otabwidget.h> 34#include <opie2/otabwidget.h>
35using namespace Opie; 35using namespace Opie;
36#else 36#else
37class QTabWidget; 37class QTabWidget;
38#endif 38#endif
39 39
40class WellenreiterBase : public QWidget 40class WellenreiterBase : public QWidget
41{ 41{
42 Q_OBJECT 42 Q_OBJECT
43 43
44public: 44public:
45 WellenreiterBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 45 WellenreiterBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
46 ~WellenreiterBase(); 46 ~WellenreiterBase();
47 47
48#ifdef QWS 48#ifdef QWS
49 OTabWidget* TabWidget; 49 Opie::Ui::OTabWidget* TabWidget;
50#else 50#else
51 QTabWidget* TabWidget; 51 QTabWidget* TabWidget;
52#endif 52#endif
53 QWidget* ap; 53 QWidget* ap;
54 MScanListView* netview; 54 MScanListView* netview;
55 MLogWindow* logwindow; 55 MLogWindow* logwindow;
56 PacketView* hexwindow; 56 PacketView* hexwindow;
57 MStatWindow* statwindow; 57 MStatWindow* statwindow;
58 MGraphWindow* graphwindow; 58 MGraphWindow* graphwindow;
59 QWidget* about; 59 QWidget* about;
60 QLabel* PixmapLabel1_3_2; 60 QLabel* PixmapLabel1_3_2;
61 QLabel* TextLabel1_4_2; 61 QLabel* TextLabel1_4_2;
62 62
63protected: 63protected:
64 QVBoxLayout* WellenreiterBaseLayout; 64 QVBoxLayout* WellenreiterBaseLayout;
65 QVBoxLayout* apLayout; 65 QVBoxLayout* apLayout;
66 QGridLayout* aboutLayout; 66 QGridLayout* aboutLayout;
67 bool event( QEvent* ); 67 bool event( QEvent* );
68 68
69 QPixmap* ani1; 69 QPixmap* ani1;
70 QPixmap* ani2; 70 QPixmap* ani2;
71 QPixmap* ani3; 71 QPixmap* ani3;
72 QPixmap* ani4; 72 QPixmap* ani4;
73 73
74 74
75}; 75};
76 76
77#endif // WELLENREITERBASE_H 77#endif // WELLENREITERBASE_H