summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-08-09 17:00:23 (UTC)
committer kergoth <kergoth>2003-08-09 17:00:23 (UTC)
commitc33d5ec60361238e50a4a9d6e0eec03e396dce60 (patch) (unidiff)
tree31c0c85dc4262044db90c7918014bc45265ef420
parent78c296d534589835801fb6374ac9d43d44b2b1c9 (diff)
downloadopie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.zip
opie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.tar.gz
opie-c33d5ec60361238e50a4a9d6e0eec03e396dce60.tar.bz2
Merge from BRANCH_1_0
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mailit/config.in2
-rw-r--r--noncore/net/mailit/popclient.cpp57
-rw-r--r--noncore/net/mailit/resource.cpp136
-rw-r--r--noncore/net/mailit/resource.h80
-rw-r--r--noncore/net/mailit/smtpclient.cpp6
-rw-r--r--noncore/net/mailit/viewatt.cpp24
-rw-r--r--noncore/net/opieftp/opieftp.pro2
-rw-r--r--noncore/net/opieirc/config.in2
-rw-r--r--noncore/net/opieirc/ircchannellist.cpp11
-rw-r--r--noncore/net/opieirc/ircchannellist.h1
-rw-r--r--noncore/net/opieirc/ircchanneltab.cpp1
-rw-r--r--noncore/net/opieirc/ircmessageparser.cpp23
-rw-r--r--noncore/net/opieirc/ircservertab.cpp26
-rw-r--r--noncore/net/opieirc/ircsession.cpp4
-rw-r--r--noncore/net/opieirc/ircsession.h1
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.cc1
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.h13
-rw-r--r--noncore/net/opietooth/blue-pin/pindlgbase.ui244
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp2
-rw-r--r--noncore/net/ubrowser/httpfactory.cpp12
-rw-r--r--noncore/net/ubrowser/mainview.cpp6
-rw-r--r--noncore/net/ubrowser/opie-ubrowser.control10
-rw-r--r--noncore/unsupported/mailit/config.in2
-rw-r--r--noncore/unsupported/mailit/popclient.cpp57
-rw-r--r--noncore/unsupported/mailit/resource.cpp136
-rw-r--r--noncore/unsupported/mailit/resource.h80
-rw-r--r--noncore/unsupported/mailit/smtpclient.cpp6
-rw-r--r--noncore/unsupported/mailit/viewatt.cpp24
28 files changed, 334 insertions, 635 deletions
diff --git a/noncore/net/mailit/config.in b/noncore/net/mailit/config.in
index 142b840..2b56b5f 100644
--- a/noncore/net/mailit/config.in
+++ b/noncore/net/mailit/config.in
@@ -1,4 +1,4 @@
1 config MAILIT 1 config MAILIT
2 boolean "opie-mailit (a simple POP3 email client)" 2 boolean "mailit"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) 4 depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/net/mailit/popclient.cpp b/noncore/net/mailit/popclient.cpp
index 5da3bcb..1df6b2b 100644
--- a/noncore/net/mailit/popclient.cpp
+++ b/noncore/net/mailit/popclient.cpp
@@ -1,331 +1,332 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "popclient.h" 20#include "popclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22//#define APOP_TEST 22//#define APOP_TEST
23 23
24extern "C" { 24extern "C" {
25#include "md5.h" 25#include "md5.h"
26} 26}
27 27
28#include <qcstring.h> 28#include <qcstring.h>
29 29
30PopClient::PopClient() 30PopClient::PopClient()
31{ 31{
32 32
33 socket = new QSocket(this, "popClient"); 33 socket = new QSocket(this, "popClient");
34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
37 37
38 stream = new QTextStream(socket); 38 stream = new QTextStream(socket);
39 39
40 receiving = FALSE; 40 receiving = FALSE;
41 synchronize = FALSE; 41 synchronize = FALSE;
42 lastSync = 0; 42 lastSync = 0;
43 headerLimit = 0; 43 headerLimit = 0;
44 mailList = 0;
44 preview = FALSE; 45 preview = FALSE;
45} 46}
46 47
47PopClient::~PopClient() 48PopClient::~PopClient()
48{ 49{
49 delete socket; 50 delete socket;
50 delete stream; 51 delete stream;
51} 52}
52 53
53void PopClient::newConnection(const QString &target, int port) 54void PopClient::newConnection(const QString &target, int port)
54{ 55{
55 if (receiving) { 56 if (receiving) {
56 qWarning("socket in use, connection refused"); 57 qWarning("socket in use, connection refused");
57 return; 58 return;
58 } 59 }
59 60
60 status = Init; 61 status = Init;
61 62
62 socket->connectToHost(target, port); 63 socket->connectToHost(target, port);
63 receiving = TRUE; 64 receiving = TRUE;
64 //selected = FALSE; 65 //selected = FALSE;
65 66
66 emit updateStatus(tr("DNS lookup")); 67 emit updateStatus(tr("DNS lookup"));
67} 68}
68 69
69void PopClient::setAccount(const QString &popUser, const QString &popPasswd) 70void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 71{
71 popUserName = popUser; 72 popUserName = popUser;
72 popPassword = popPasswd; 73 popPassword = popPasswd;
73} 74}
74 75
75void PopClient::setSynchronize(int lastCount) 76void PopClient::setSynchronize(int lastCount)
76{ 77{
77 synchronize = TRUE; 78 synchronize = TRUE;
78 lastSync = lastCount; 79 lastSync = lastCount;
79} 80}
80 81
81void PopClient::removeSynchronize() 82void PopClient::removeSynchronize()
82{ 83{
83 synchronize = FALSE; 84 synchronize = FALSE;
84 lastSync = 0; 85 lastSync = 0;
85} 86}
86 87
87void PopClient::headersOnly(bool headers, int limit) 88void PopClient::headersOnly(bool headers, int limit)
88{ 89{
89 preview = headers; 90 preview = headers;
90 headerLimit = limit; 91 headerLimit = limit;
91} 92}
92 93
93void PopClient::setSelectedMails(MailList *list) 94void PopClient::setSelectedMails(MailList *list)
94{ 95{
95 selected = TRUE; 96 selected = TRUE;
96 mailList = list; 97 mailList = list;
97} 98}
98 99
99void PopClient::connectionEstablished() 100void PopClient::connectionEstablished()
100{ 101{
101 emit updateStatus(tr("Connection established")); 102 emit updateStatus(tr("Connection established"));
102} 103}
103 104
104void PopClient::errorHandling(int status) 105void PopClient::errorHandling(int status)
105{ 106{
106 errorHandlingWithMsg( status, QString::null ); 107 errorHandlingWithMsg( status, QString::null );
107} 108}
108void PopClient::errorHandlingWithMsg(int status, const QString & Msg ) 109void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
109{ 110{
110 emit updateStatus(tr("Error Occured")); 111 emit updateStatus(tr("Error Occured"));
111 emit errorOccurred(status, Msg); 112 emit errorOccurred(status, Msg);
112 socket->close(); 113 socket->close();
113 receiving = FALSE; 114 receiving = FALSE;
114} 115}
115 116
116void PopClient::incomingData() 117void PopClient::incomingData()
117{ 118{
118 QString response, temp, temp2, timeStamp; 119 QString response, temp, temp2, timeStamp;
119 QString md5Source; 120 QString md5Source;
120 int start, end; 121 int start, end;
121// char *md5Digest; 122// char *md5Digest;
122 char md5Digest[16]; 123 char md5Digest[16];
123// if ( !socket->canReadLine() ) 124// if ( !socket->canReadLine() )
124// return; 125// return;
125 126
126 127
127 response = socket->readLine(); 128 response = socket->readLine();
128 129
129 switch(status) { 130 switch(status) {
130 //logging in 131 //logging in
131 case Init: { 132 case Init: {
132#ifdef APOP_TEST 133#ifdef APOP_TEST
133 start = response.find('<',0); 134 start = response.find('<',0);
134 end = response.find('>', start); 135 end = response.find('>', start);
135 if( start >= 0 && end > start ) 136 if( start >= 0 && end > start )
136 { 137 {
137 timeStamp = response.mid( start , end - start + 1); 138 timeStamp = response.mid( start , end - start + 1);
138 md5Source = timeStamp + popPassword; 139 md5Source = timeStamp + popPassword;
139 140
140 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); 141 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
141 142
142 for(int j =0;j < MD5_DIGEST_LENGTH ;j++) 143 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
143 { 144 {
144 printf("%x", md5Digest[j]); 145 printf("%x", md5Digest[j]);
145 } 146 }
146 printf("\n"); 147 printf("\n");
147// qDebug(md5Digest); 148// qDebug(md5Digest);
148 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; 149 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
149 // qDebug("%s", stream); 150 // qDebug("%s", stream);
150 status = Stat; 151 status = Stat;
151 } 152 }
152 else 153 else
153#endif 154#endif
154 { 155 {
155 timeStamp = ""; 156 timeStamp = "";
156 *stream << "USER " << popUserName << "\r\n"; 157 *stream << "USER " << popUserName << "\r\n";
157 status = Pass; 158 status = Pass;
158 } 159 }
159 160
160 break; 161 break;
161 } 162 }
162 163
163 case Pass: { 164 case Pass: {
164 *stream << "PASS " << popPassword << "\r\n"; 165 *stream << "PASS " << popPassword << "\r\n";
165 status = Stat; 166 status = Stat;
166 167
167 break; 168 break;
168 } 169 }
169 //ask for number of messages 170 //ask for number of messages
170 case Stat: { 171 case Stat: {
171 if (response[0] == '+') { 172 if (response[0] == '+') {
172 *stream << "STAT" << "\r\n"; 173 *stream << "STAT" << "\r\n";
173 status = Mcnt; 174 status = Mcnt;
174 } else errorHandlingWithMsg(ErrLoginFailed, response); 175 } else errorHandlingWithMsg(ErrLoginFailed, response);
175 break; 176 break;
176 } 177 }
177 //get count of messages, eg "+OK 4 900.." -> int 4 178 //get count of messages, eg "+OK 4 900.." -> int 4
178 case Mcnt: { 179 case Mcnt: {
179 if (response[0] == '+') { 180 if (response[0] == '+') {
180 temp = response.replace(0, 4, ""); 181 temp = response.replace(0, 4, "");
181 int x = temp.find(" ", 0); 182 int x = temp.find(" ", 0);
182 temp.truncate((uint) x); 183 temp.truncate((uint) x);
183 newMessages = temp.toInt(); 184 newMessages = temp.toInt();
184 messageCount = 1; 185 messageCount = 1;
185 status = List; 186 status = List;
186 187
187 if (synchronize) { 188 if (synchronize) {
188 //messages deleted from server, reload all 189 //messages deleted from server, reload all
189 if (newMessages < lastSync) 190 if (newMessages < lastSync)
190 lastSync = 0; 191 lastSync = 0;
191 messageCount = 1; 192 messageCount = 1;
192 } 193 }
193 194
194 if (selected) { 195 if (selected && mailList ) {
195 int *ptr = mailList->first(); 196 int *ptr = mailList->first();
196 if (ptr != 0) { 197 if (ptr != 0) {
197 newMessages++; //to ensure no early jumpout 198 newMessages++; //to ensure no early jumpout
198 messageCount = *ptr; 199 messageCount = *ptr;
199 } else newMessages = 0; 200 } else newMessages = 0;
200 } 201 }
201 202
202 } else errorHandlingWithMsg(ErrUnknownResponse, response); 203 } else errorHandlingWithMsg(ErrUnknownResponse, response);
203 } 204 }
204 //Read message number x, count upwards to messageCount 205 //Read message number x, count upwards to messageCount
205 case List: { 206 case List: {
206 if (messageCount <= newMessages) { 207 if (messageCount <= newMessages) {
207 *stream << "LIST " << messageCount << "\r\n"; 208 *stream << "LIST " << messageCount << "\r\n";
208 status = Size; 209 status = Size;
209 temp2.setNum(newMessages - lastSync); 210 temp2.setNum(newMessages - lastSync);
210 temp.setNum(messageCount - lastSync); 211 temp.setNum(messageCount - lastSync);
211 if (!selected) { 212 if (!selected) {
212 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 213 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
213 } else { 214 } else {
214 //completing a previously closed transfer 215 //completing a previously closed transfer
215 /* if ( (messageCount - lastSync) <= 0) { 216 /* if ( (messageCount - lastSync) <= 0) {
216 temp.setNum(messageCount); 217 temp.setNum(messageCount);
217 emit updateStatus(tr("Previous message ") + temp); 218 emit updateStatus(tr("Previous message ") + temp);
218 } else {*/ 219 } else {*/
219 emit updateStatus(tr("Completing message ") + temp); 220 emit updateStatus(tr("Completing message ") + temp);
220 //} 221 //}
221 } 222 }
222 break; 223 break;
223 } else { 224 } else {
224 emit updateStatus(tr("No new Messages")); 225 emit updateStatus(tr("No new Messages"));
225 status = Quit; 226 status = Quit;
226 } 227 }
227 } 228 }
228 //get size of message, eg "500 characters in message.." -> int 500 229 //get size of message, eg "500 characters in message.." -> int 500
229 case Size: { 230 case Size: {
230 if (status != Quit) { //because of idiotic switch 231 if (status != Quit) { //because of idiotic switch
231 if (response[0] == '+') { 232 if (response[0] == '+') {
232 temp = response.replace(0, 4, ""); 233 temp = response.replace(0, 4, "");
233 int x = temp.find(" ", 0); 234 int x = temp.find(" ", 0);
234 temp = temp.right(temp.length() - ((uint) x + 1) ); 235 temp = temp.right(temp.length() - ((uint) x + 1) );
235 mailSize = temp.toInt(); 236 mailSize = temp.toInt();
236 emit currentMailSize(mailSize); 237 emit currentMailSize(mailSize);
237 238
238 status = Retr; 239 status = Retr;
239 } else { 240 } else {
240 //qWarning(response); 241 //qWarning(response);
241 errorHandlingWithMsg(ErrUnknownResponse, response); 242 errorHandlingWithMsg(ErrUnknownResponse, response);
242 } 243 }
243 } 244 }
244 } 245 }
245 //Read message number x, count upwards to messageCount 246 //Read message number x, count upwards to messageCount
246 case Retr: { 247 case Retr: {
247 if (status != Quit) { 248 if (status != Quit) {
248 if ((selected)||(mailSize <= headerLimit)) 249 if ((selected)||(mailSize <= headerLimit))
249 { 250 {
250 *stream << "RETR " << messageCount << "\r\n"; 251 *stream << "RETR " << messageCount << "\r\n";
251 } else { //only header 252 } else { //only header
252 *stream << "TOP " << messageCount << " 0\r\n"; 253 *stream << "TOP " << messageCount << " 0\r\n";
253 } 254 }
254 messageCount++; 255 messageCount++;
255 status = Ignore; 256 status = Ignore;
256 break; 257 break;
257 } } 258 } }
258 case Ignore: { 259 case Ignore: {
259 if (status != Quit) { //because of idiotic switch 260 if (status != Quit) { //because of idiotic switch
260 if (response[0] == '+') { 261 if (response[0] == '+') {
261 message = ""; 262 message = "";
262 status = Read; 263 status = Read;
263 if (!socket->canReadLine()) //sync. problems 264 if (!socket->canReadLine()) //sync. problems
264 break; 265 break;
265 response = socket->readLine(); 266 response = socket->readLine();
266 } else errorHandlingWithMsg(ErrUnknownResponse, response); 267 } else errorHandlingWithMsg(ErrUnknownResponse, response);
267 } 268 }
268 } 269 }
269 //add all incoming lines to body. When size is reached, send 270 //add all incoming lines to body. When size is reached, send
270 //message, and go back to read new message 271 //message, and go back to read new message
271 case Read: { 272 case Read: {
272 if (status != Quit) { //because of idiotic switch 273 if (status != Quit) { //because of idiotic switch
273 message += response; 274 message += response;
274 while ( socket->canReadLine() ) { 275 while ( socket->canReadLine() ) {
275 response = socket->readLine(); 276 response = socket->readLine();
276 message += response; 277 message += response;
277 } 278 }
278 emit downloadedSize(message.length()); 279 emit downloadedSize(message.length());
279 int x = message.find("\r\n.\r\n",-5); 280 int x = message.find("\r\n.\r\n",-5);
280 if (x == -1) { 281 if (x == -1) {
281 break; 282 break;
282 } else { //message reach entire size 283 } else { //message reach entire size
283 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active 284 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
284 { 285 {
285 emit newMessage(message, messageCount-1, mailSize, TRUE); 286 emit newMessage(message, messageCount-1, mailSize, TRUE);
286 } else { //incomplete mail downloaded 287 } else { //incomplete mail downloaded
287 emit newMessage(message, messageCount-1, mailSize, FALSE); 288 emit newMessage(message, messageCount-1, mailSize, FALSE);
288 } 289 }
289 290
290 if ((messageCount > newMessages)||(selected)) //last message ? 291 if ((messageCount > newMessages)||(selected)) //last message ?
291 { 292 {
292 status = Quit; 293 status = Quit;
293 if (selected) { //grab next from queue 294 if (selected) { //grab next from queue
294 newMessages--; 295 newMessages--;
295 status = Quit; 296 status = Quit;
296 } 297 }
297 } 298 }
298 else 299 else
299 { 300 {
300 *stream << "LIST " << messageCount << "\r\n"; 301 *stream << "LIST " << messageCount << "\r\n";
301 status = Size; 302 status = Size;
302 temp2.setNum(newMessages - lastSync); 303 temp2.setNum(newMessages - lastSync);
303 temp.setNum(messageCount - lastSync); 304 temp.setNum(messageCount - lastSync);
304 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 305 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
305 306
306 break; 307 break;
307 } 308 }
308 } 309 }
309 } 310 }
310 if (status != Quit) 311 if (status != Quit)
311 break; 312 break;
312 } 313 }
313 case Quit: { 314 case Quit: {
314 *stream << "Quit\r\n"; 315 *stream << "Quit\r\n";
315 status = Done; 316 status = Done;
316 int newM = newMessages - lastSync; 317 int newM = newMessages - lastSync;
317 if (newM > 0) { 318 if (newM > 0) {
318 temp.setNum(newM); 319 temp.setNum(newM);
319 emit updateStatus(temp + tr(" new messages")); 320 emit updateStatus(temp + tr(" new messages"));
320 } else { 321 } else {
321 emit updateStatus(tr("No new messages")); 322 emit updateStatus(tr("No new messages"));
322 } 323 }
323 324
324 socket->close(); 325 socket->close();
325 receiving = FALSE; 326 receiving = FALSE;
326 emit mailTransfered(newM); 327 emit mailTransfered(newM);
327 break; 328 break;
328 } 329 }
329 } 330 }
330 331
331} 332}
diff --git a/noncore/net/mailit/resource.cpp b/noncore/net/mailit/resource.cpp
deleted file mode 100644
index dc19880..0000000
--- a/noncore/net/mailit/resource.cpp
+++ b/dev/null
@@ -1,136 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "qpeapplication.h"
22#include "resource.h"
23#include <qdir.h>
24#include <qfile.h>
25#include <qregexp.h>
26#include <qpixmapcache.h>
27#include <qpainter.h>
28
29#include "inlinepics_p.h"
30
31/*!
32 \class Resource resource.h
33 \brief The Resource class provides access to named resources.
34
35 The resources may be provided from files or other sources.
36*/
37
38/*!
39 \fn Resource::Resource()
40 \internal
41*/
42
43/*!
44 Returns the QPixmap named \a pix. You should avoid including
45 any filename type extension (eg. .png, .xpm).
46*/
47QPixmap Resource::loadPixmap( const QString &pix )
48{
49 QPixmap pm;
50 QString key="QPE_"+pix;
51 if ( !QPixmapCache::find(key,pm) ) {
52 pm.convertFromImage(loadImage(pix));
53 QPixmapCache::insert(key,pm);
54 }
55 return pm;
56}
57
58/*!
59 Returns the QBitmap named \a pix. You should avoid including
60 any filename type extension (eg. .png, .xpm).
61*/
62QBitmap Resource::loadBitmap( const QString &pix )
63{
64 QBitmap bm;
65 bm = loadPixmap(pix);
66 return bm;
67}
68
69/*!
70 Returns the filename of a pixmap named \a pix. You should avoid including
71 any filename type extension (eg. .png, .xpm).
72
73 Normally you will use loadPixmap() rather than this function.
74*/
75QString Resource::findPixmap( const QString &pix )
76{
77 QString picsPath = QPEApplication::qpeDir() + "pics/";
78
79 if ( QFile( picsPath + pix + ".png").exists() )
80 return picsPath + pix + ".png";
81 else if ( QFile( picsPath + pix + ".xpm").exists() )
82 return picsPath + pix + ".xpm";
83 else if ( QFile( picsPath + pix ).exists() )
84 return picsPath + pix;
85
86 //qDebug("Cannot find pixmap: %s", pix.latin1());
87 return QString();
88}
89
90/*!
91 Returns a sound file for a sound named \a name.
92 You should avoid including any filename type extension (eg. .wav, .au, .mp3).
93*/
94QString Resource::findSound( const QString &name )
95{
96 QString picsPath = QPEApplication::qpeDir() + "sounds/";
97
98 QString result;
99 if ( QFile( (result = picsPath + name + ".wav") ).exists() )
100 return result;
101
102 return QString();
103}
104
105/*!
106 Returns a list of all sound names.
107*/
108QStringList Resource::allSounds()
109{
110 QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" );
111 QStringList entries = resourcedir.entryList();
112 QStringList result;
113 for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i)
114 result.append((*i).replace(QRegExp("\\.wav"),""));
115 return result;
116}
117
118/*!
119 Returns the QImage named \a name. You should avoid including
120 any filename type extension (eg. .png, .xpm).
121*/
122QImage Resource::loadImage( const QString &name)
123{
124 QImage img = qembed_findImage(name.latin1());
125 if ( img.isNull() )
126 return QImage(findPixmap(name));
127 return img;
128}
129
130/*!
131 \fn QIconSet Resource::loadIconSet( const QString &name )
132
133 Returns a QIconSet for the pixmap named \a name. A disabled icon is
134 generated that conforms to the Qtopia look & feel. You should avoid
135 including any filename type extension (eg. .png, .xpm).
136*/
diff --git a/noncore/net/mailit/resource.h b/noncore/net/mailit/resource.h
deleted file mode 100644
index 982c58a..0000000
--- a/noncore/net/mailit/resource.h
+++ b/dev/null
@@ -1,80 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef PIXMAPLOADER_H
21#define PIXMAPLOADER_H
22
23#include <qimage.h>
24#include <qbitmap.h>
25#include <qiconset.h>
26#include <qstringlist.h>
27
28class Resource
29{
30public:
31 Resource() {}
32
33 static QImage loadImage( const QString &name);
34
35 static QPixmap loadPixmap( const QString &name );
36 static QBitmap loadBitmap( const QString &name );
37 static QString findPixmap( const QString &name );
38
39 static QIconSet loadIconSet( const QString &name );
40
41 static QString findSound( const QString &name );
42 static QStringList allSounds();
43};
44
45// Inline for compatibility with SHARP ROMs
46inline QIconSet Resource::loadIconSet( const QString &pix )
47{
48 QImage img = loadImage( pix );
49 QPixmap pm;
50 pm.convertFromImage( img );
51 QIconSet is( pm );
52 QIconSet::Size size = pm.width() <= 22 ? QIconSet::Small : QIconSet::Large;
53
54 QPixmap dpm = loadPixmap( pix + "_disabled" );
55
56 #ifndef QT_NO_DEPTH_32// have alpha-blended pixmaps
57 if ( dpm.isNull() ) {
58 QImage dimg( img.width(), img.height(), 32 );
59 for ( int y = 0; y < img.height(); y++ ) {
60 for ( int x = 0; x < img.width(); x++ ) {
61 QRgb p = img.pixel( x, y );
62 uint a = (p & 0xff000000) / 3;
63 p = (p & 0x00ffffff) | (a & 0xff000000);
64 dimg.setPixel( x, y, p );
65 }
66 }
67
68 dimg.setAlphaBuffer( TRUE );
69 dpm.convertFromImage( dimg );
70 }
71#endif
72
73 if ( !dpm.isNull() )
74 is.setPixmap( dpm, size, QIconSet::Disabled );
75
76 return is;
77}
78
79
80#endif
diff --git a/noncore/net/mailit/smtpclient.cpp b/noncore/net/mailit/smtpclient.cpp
index 5b5ef52..51ca50b 100644
--- a/noncore/net/mailit/smtpclient.cpp
+++ b/noncore/net/mailit/smtpclient.cpp
@@ -1,170 +1,170 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "smtpclient.h" 20#include "smtpclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22 22
23SmtpClient::SmtpClient() 23SmtpClient::SmtpClient()
24{ 24{
25 socket = new QSocket(this, "smtpClient"); 25 socket = new QSocket(this, "smtpClient");
26 stream = new QTextStream(socket); 26 stream = new QTextStream(socket);
27 mailList.setAutoDelete(TRUE); 27 mailList.setAutoDelete(TRUE);
28 28
29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32 32
33 sending = FALSE; 33 sending = FALSE;
34} 34}
35 35
36SmtpClient::~SmtpClient() 36SmtpClient::~SmtpClient()
37{ 37{
38 delete socket; 38 delete socket;
39 delete stream; 39 delete stream;
40} 40}
41 41
42void SmtpClient::newConnection(const QString &target, int port) 42void SmtpClient::newConnection(const QString &target, int port)
43{ 43{
44 if (sending) { 44 if (sending) {
45 qWarning("socket in use, connection refused"); 45 qWarning("socket in use, connection refused");
46 return; 46 return;
47 } 47 }
48 48
49 status = Init; 49 status = Init;
50 sending = TRUE; 50 sending = TRUE;
51 socket->connectToHost(target, port); 51 socket->connectToHost(target, port);
52 52
53 emit updateStatus(tr("DNS lookup")); 53 emit updateStatus(tr("DNS lookup"));
54} 54}
55 55
56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body) 56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{ 57{
58 RawEmail *mail = new RawEmail; 58 RawEmail *mail = new RawEmail;
59 59
60 mail->from = from; 60 mail->from = from;
61 mail->subject = subject; 61 mail->subject = subject;
62 mail->to = to; 62 mail->to = to;
63 mail->body = body; 63 mail->body = body;
64 64
65 mailList.append(mail); 65 mailList.append(mail);
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
69{ 69{
70 emit updateStatus(tr("Connection established")); 70 emit updateStatus(tr("Connection established"));
71 71
72} 72}
73 73
74void SmtpClient::errorHandling(int status) 74void SmtpClient::errorHandling(int status)
75{ 75{
76 errorHandlingWithMsg( status, QString::null ); 76 errorHandlingWithMsg( status, QString::null );
77} 77}
78 78
79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg ) 79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
80{ 80{
81 emit errorOccurred(status, EMsg ); 81 emit errorOccurred(status, EMsg );
82 socket->close(); 82 socket->close();
83 mailList.clear(); 83 mailList.clear();
84 sending = FALSE; 84 sending = FALSE;
85} 85}
86 86
87void SmtpClient::incomingData() 87void SmtpClient::incomingData()
88{ 88{
89 QString response; 89 QString response;
90 90
91 if (!socket->canReadLine()) 91 if (!socket->canReadLine())
92 return; 92 return;
93 93
94 response = socket->readLine(); 94 response = socket->readLine();
95 switch(status) { 95 switch(status) {
96 case Init: { 96 case Init: {
97 if (response[0] == '2') { 97 if (response[0] == '2') {
98 status = From; 98 status = From;
99 mailPtr = mailList.first(); 99 mailPtr = mailList.first();
100 *stream << "HELO there\r\n"; 100 *stream << "HELO there\r\n";
101 } else errorHandlingWithMsg(ErrUnknownResponse,response); 101 } else errorHandlingWithMsg(ErrUnknownResponse,response);
102 break; 102 break;
103 } 103 }
104 case From: { 104 case From: {
105 if (response[0] == '2') { 105 if (response[0] == '2') {
106 qDebug(mailPtr->from); 106 qDebug(mailPtr->from);
107 *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; 107 *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
108 status = Recv; 108 status = Recv;
109 } else errorHandlingWithMsg(ErrUnknownResponse, response ); 109 } else errorHandlingWithMsg(ErrUnknownResponse, response );
110 break; 110 break;
111 } 111 }
112 case Recv: { 112 case Recv: {
113 if (response[0] == '2') { 113 if (response[0] == '2') {
114 it = mailPtr->to.begin(); 114 it = mailPtr->to.begin();
115 if (it == NULL) { 115 if (it == NULL) {
116 errorHandlingWithMsg(ErrUnknownResponse,response); 116 errorHandlingWithMsg(ErrUnknownResponse,response);
117 } 117 }
118 *stream << "RCPT TO: <" << *it << ">\r\n"; 118 *stream << "RCPT TO: " << *it << "\r\n";
119 status = MRcv; 119 status = MRcv;
120 } else errorHandlingWithMsg(ErrUnknownResponse,response); 120 } else errorHandlingWithMsg(ErrUnknownResponse,response);
121 break; 121 break;
122 } 122 }
123 case MRcv: { 123 case MRcv: {
124 if (response[0] == '2') { 124 if (response[0] == '2') {
125 it++; 125 it++;
126 if ( it != mailPtr->to.end() ) { 126 if ( it != mailPtr->to.end() ) {
127 *stream << "RCPT TO: <" << *it << ">\r\n"; 127 *stream << "RCPT TO: " << *it << "\r\n";
128 break; 128 break;
129 } else { 129 } else {
130 status = Data; 130 status = Data;
131 } 131 }
132 } else errorHandlingWithMsg(ErrUnknownResponse,response); 132 } else errorHandlingWithMsg(ErrUnknownResponse,response);
133 } 133 }
134 case Data: { 134 case Data: {
135 if (response[0] == '2') { 135 if (response[0] == '2') {
136 *stream << "DATA\r\n"; 136 *stream << "DATA\r\n";
137 status = Body; 137 status = Body;
138 emit updateStatus(tr("Sending: ") + mailPtr->subject); 138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
139 139
140 } else errorHandlingWithMsg(ErrUnknownResponse,response); 140 } else errorHandlingWithMsg(ErrUnknownResponse,response);
141 break; 141 break;
142 } 142 }
143 case Body: { 143 case Body: {
144 if (response[0] == '3') { 144 if (response[0] == '3') {
145 *stream << mailPtr->body << "\r\n.\r\n"; 145 *stream << mailPtr->body << "\r\n.\r\n";
146 mailPtr = mailList.next(); 146 mailPtr = mailList.next();
147 if (mailPtr != NULL) { 147 if (mailPtr != NULL) {
148 status = From; 148 status = From;
149 } else { 149 } else {
150 status = Quit; 150 status = Quit;
151 } 151 }
152 } else errorHandlingWithMsg(ErrUnknownResponse,response); 152 } else errorHandlingWithMsg(ErrUnknownResponse,response);
153 break; 153 break;
154 } 154 }
155 case Quit: { 155 case Quit: {
156 if (response[0] == '2') { 156 if (response[0] == '2') {
157 *stream << "QUIT\r\n"; 157 *stream << "QUIT\r\n";
158 status = Done; 158 status = Done;
159 QString temp; 159 QString temp;
160 temp.setNum(mailList.count()); 160 temp.setNum(mailList.count());
161 emit updateStatus(tr("Sent ") + temp + tr(" messages")); 161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
162 emit mailSent(); 162 emit mailSent();
163 mailList.clear(); 163 mailList.clear();
164 sending = FALSE; 164 sending = FALSE;
165 socket->close(); 165 socket->close();
166 } else errorHandlingWithMsg(ErrUnknownResponse,response); 166 } else errorHandlingWithMsg(ErrUnknownResponse,response);
167 break; 167 break;
168 } 168 }
169 } 169 }
170} 170}
diff --git a/noncore/net/mailit/viewatt.cpp b/noncore/net/mailit/viewatt.cpp
index 293e137..3515ba5 100644
--- a/noncore/net/mailit/viewatt.cpp
+++ b/noncore/net/mailit/viewatt.cpp
@@ -1,121 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "resource.h" 20#include <qpe/resource.h>
21#include "viewatt.h" 21#include "viewatt.h"
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25 25
26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) 26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
27 : QMainWindow(parent, name, f) 27 : QMainWindow(parent, name, f)
28{ 28{
29 setCaption(tr("Exploring attatchments")); 29 setCaption(tr("Exploring attatchments"));
30 30
31 setToolBarsMovable( FALSE ); 31 setToolBarsMovable( FALSE );
32 bar = new QToolBar(this); 32 bar = new QToolBar(this);
33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); 33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); 34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents")); 35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
36 36
37 listView = new QListView(this, "AttView"); 37 listView = new QListView(this, "AttView");
38 listView->addColumn( tr("Attatchment") ); 38 listView->addColumn( tr("Attatchment") );
39 listView->addColumn( tr("Type") ); 39 listView->addColumn( tr("Type") );
40 listView->addColumn( tr("Installed") ); 40 listView->addColumn( tr("Installed") );
41 setCentralWidget(listView); 41 setCentralWidget(listView);
42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail")); 42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
43} 43}
44 44
45void ViewAtt::update(Email *mailIn, bool inbox) 45void ViewAtt::update(Email *mailIn, bool inbox)
46{ 46{
47 QListViewItem *item; 47 QListViewItem *item;
48 Enclosure *ePtr; 48 Enclosure *ePtr;
49
50 49
51 50
51
52 listView->clear(); 52 listView->clear();
53 if (inbox) { 53 if (inbox) {
54 bar->clear(); 54 bar->clear();
55 installButton->addTo( bar ); 55 installButton->addTo( bar );
56 bar->show(); 56 bar->show();
57 } else { 57 } else {
58 bar->hide(); 58 bar->hide();
59 } 59 }
60 60
61 mail = mailIn; 61 mail = mailIn;
62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
63 63
64 QString isInstalled = tr("No"); 64 QString isInstalled = tr("No");
65 if (ePtr->installed) 65 if (ePtr->installed)
66 isInstalled = tr("Yes"); 66 isInstalled = tr("Yes");
67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); 67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
68 68
69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; 69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
70 70
71 MimeType mt(mtypeDef); 71 MimeType mt(mtypeDef);
72 72
73 item->setPixmap(0, mt.pixmap()); 73 item->setPixmap(0, mt.pixmap());
74 74
75 /* 75 /*
76 if (ePtr->contentType == "TEXT") { 76 if (ePtr->contentType == "TEXT") {
77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); 77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
78 actions->addTo(bar); 78 actions->addTo(bar);
79 } 79 }
80 if (ePtr->contentType == "AUDIO") { 80 if (ePtr->contentType == "AUDIO") {
81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); 81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
82 actions->addTo(bar); 82 actions->addTo(bar);
83 item->setPixmap(0, Resource::loadPixmap("play")); 83 item->setPixmap(0, Resource::loadPixmap("play"));
84 } 84 }
85 if (ePtr->contentType == "IMAGE") { 85 if (ePtr->contentType == "IMAGE") {
86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); 86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
87 actions->addTo(bar); 87 actions->addTo(bar);
88 item->setPixmap(0, Resource::loadPixmap("pixmap")); 88 item->setPixmap(0, Resource::loadPixmap("pixmap"));
89 }*/ 89 }*/
90 } 90 }
91} 91}
92 92
93void ViewAtt::install() 93void ViewAtt::install()
94{ 94{
95 Enclosure *ePtr, *selPtr; 95 Enclosure *ePtr, *selPtr;
96 QListViewItem *item; 96 QListViewItem *item;
97 QString filename; 97 QString filename;
98 DocLnk d; 98 DocLnk d;
99 99
100 item = listView->selectedItem(); 100 item = listView->selectedItem();
101 if (item != NULL) { 101 if (item != NULL) {
102 filename = item->text(0); 102 filename = item->text(0);
103 selPtr = NULL; 103 selPtr = NULL;
104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
105 if (ePtr->originalName == filename) 105 if (ePtr->originalName == filename)
106 selPtr = ePtr; 106 selPtr = ePtr;
107 } 107 }
108 108
109 if (selPtr == NULL) { 109 if (selPtr == NULL) {
110 qWarning("Internal error, file is not installed to documents"); 110 qWarning("Internal error, file is not installed to documents");
111 return; 111 return;
112 } 112 }
113 113
114 d.setName(selPtr->originalName); 114 d.setName(selPtr->originalName);
115 d.setFile(selPtr->path + selPtr->name); 115 d.setFile(selPtr->path + selPtr->name);
116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); 116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
117 d.writeLink(); 117 d.writeLink();
118 selPtr->installed = TRUE; 118 selPtr->installed = TRUE;
119 item->setText(2, tr("Yes")); 119 item->setText(2, tr("Yes"));
120 } 120 }
121} 121}
diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro
index dbccd98..ac16819 100644
--- a/noncore/net/opieftp/opieftp.pro
+++ b/noncore/net/opieftp/opieftp.pro
@@ -1,31 +1,31 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG += qt warn_on release 2CONFIG += qt warn_on release
3HEADERS = opieftp.h inputDialog.h ftplib.h 3HEADERS = opieftp.h inputDialog.h
4SOURCES = opieftp.cpp inputDialog.cpp main.cpp 4SOURCES = opieftp.cpp inputDialog.cpp main.cpp
5TARGET = opieftp 5TARGET = opieftp
6DESTDIR = $(OPIEDIR)/bin 6DESTDIR = $(OPIEDIR)/bin
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lftplib 9LIBS += -lqpe -lftplib
10 10
11TRANSLATIONS = ../../../i18n/de/opieftp.ts \ 11TRANSLATIONS = ../../../i18n/de/opieftp.ts \
12 ../../../i18n/nl/opieftp.ts \ 12 ../../../i18n/nl/opieftp.ts \
13 ../../../i18n/da/opieftp.ts \ 13 ../../../i18n/da/opieftp.ts \
14 ../../../i18n/xx/opieftp.ts \ 14 ../../../i18n/xx/opieftp.ts \
15 ../../../i18n/en/opieftp.ts \ 15 ../../../i18n/en/opieftp.ts \
16 ../../../i18n/es/opieftp.ts \ 16 ../../../i18n/es/opieftp.ts \
17 ../../../i18n/fr/opieftp.ts \ 17 ../../../i18n/fr/opieftp.ts \
18 ../../../i18n/hu/opieftp.ts \ 18 ../../../i18n/hu/opieftp.ts \
19 ../../../i18n/ja/opieftp.ts \ 19 ../../../i18n/ja/opieftp.ts \
20 ../../../i18n/ko/opieftp.ts \ 20 ../../../i18n/ko/opieftp.ts \
21 ../../../i18n/no/opieftp.ts \ 21 ../../../i18n/no/opieftp.ts \
22 ../../../i18n/pl/opieftp.ts \ 22 ../../../i18n/pl/opieftp.ts \
23 ../../../i18n/pt/opieftp.ts \ 23 ../../../i18n/pt/opieftp.ts \
24 ../../../i18n/pt_BR/opieftp.ts \ 24 ../../../i18n/pt_BR/opieftp.ts \
25 ../../../i18n/sl/opieftp.ts \ 25 ../../../i18n/sl/opieftp.ts \
26 ../../../i18n/zh_CN/opieftp.ts \ 26 ../../../i18n/zh_CN/opieftp.ts \
27 ../../../i18n/zh_TW/opieftp.ts 27 ../../../i18n/zh_TW/opieftp.ts
28 28
29 29
30 30
31include ( $(OPIEDIR)/include.pro ) 31include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/net/opieirc/config.in b/noncore/net/opieirc/config.in
index 30184a9..7c6949d 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 "opieirc" 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 ) && LIBOPIE
diff --git a/noncore/net/opieirc/ircchannellist.cpp b/noncore/net/opieirc/ircchannellist.cpp
index e592d05..566b223 100644
--- a/noncore/net/opieirc/ircchannellist.cpp
+++ b/noncore/net/opieirc/ircchannellist.cpp
@@ -1,37 +1,48 @@
1#include <qpe/resource.h> 1#include <qpe/resource.h>
2#include <qpixmap.h> 2#include <qpixmap.h>
3#include "ircchannellist.h" 3#include "ircchannellist.h"
4 4
5IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) { 5IRCChannelList::IRCChannelList(IRCChannel *channel, QWidget *parent, const char *name, WFlags f) : QListBox(parent, name, f) {
6 m_channel = channel; 6 m_channel = channel;
7} 7}
8 8
9void IRCChannelList::update() { 9void IRCChannelList::update() {
10 QPixmap op = Resource::loadPixmap("opieirc/op"); 10 QPixmap op = Resource::loadPixmap("opieirc/op");
11 QPixmap hop = Resource::loadPixmap("opieirc/hop"); 11 QPixmap hop = Resource::loadPixmap("opieirc/hop");
12 QPixmap voice = Resource::loadPixmap("opieirc/voice"); 12 QPixmap voice = Resource::loadPixmap("opieirc/voice");
13 QListIterator<IRCChannelPerson> it = m_channel->people(); 13 QListIterator<IRCChannelPerson> it = m_channel->people();
14 clear(); 14 clear();
15 for (; it.current(); ++it) { 15 for (; it.current(); ++it) {
16 IRCChannelPerson *person = it.current(); 16 IRCChannelPerson *person = it.current();
17 if (person->flags & PERSON_FLAG_OP) { 17 if (person->flags & PERSON_FLAG_OP) {
18 insertItem(op, person->person->nick()); 18 insertItem(op, person->person->nick());
19 } else if (person->flags & PERSON_FLAG_HALFOP) { 19 } else if (person->flags & PERSON_FLAG_HALFOP) {
20 insertItem(op, person->person->nick()); 20 insertItem(op, person->person->nick());
21 } else if (person->flags & PERSON_FLAG_VOICE) { 21 } else if (person->flags & PERSON_FLAG_VOICE) {
22 insertItem(voice, person->person->nick()); 22 insertItem(voice, person->person->nick());
23 } else { 23 } else {
24 insertItem(person->person->nick()); 24 insertItem(person->person->nick());
25 } 25 }
26 } 26 }
27 sort(); 27 sort();
28} 28}
29 29
30 30
31bool IRCChannelList::hasPerson(QString nick) { 31bool IRCChannelList::hasPerson(QString nick) {
32 for (unsigned int i=0; i<count(); i++) { 32 for (unsigned int i=0; i<count(); i++) {
33 if (text(i) == nick) 33 if (text(i) == nick)
34 return TRUE; 34 return TRUE;
35 } 35 }
36 return FALSE; 36 return FALSE;
37} 37}
38
39bool IRCChannelList::removePerson(QString nick) {
40 for (unsigned int i=0; i<count(); i++) {
41 if (text(i) == nick){
42 removeItem(i);
43 return TRUE;
44 }
45 }
46 return FALSE;
47}
48
diff --git a/noncore/net/opieirc/ircchannellist.h b/noncore/net/opieirc/ircchannellist.h
index fa3c8cd..deab649 100644
--- a/noncore/net/opieirc/ircchannellist.h
+++ b/noncore/net/opieirc/ircchannellist.h
@@ -1,36 +1,37 @@
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 __IRCCHANNELLIST_H 21#ifndef __IRCCHANNELLIST_H
22#define __IRCCHANNELLIST_H 22#define __IRCCHANNELLIST_H
23 23
24#include <qlistbox.h> 24#include <qlistbox.h>
25#include "ircchannel.h" 25#include "ircchannel.h"
26 26
27class IRCChannelList : public QListBox { 27class IRCChannelList : public QListBox {
28public: 28public:
29 IRCChannelList(IRCChannel *channel, QWidget *parent = 0, const char *name = 0, WFlags f = 0); 29 IRCChannelList(IRCChannel *channel, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
30 void update(); 30 void update();
31 bool hasPerson(QString nick); 31 bool hasPerson(QString nick);
32 bool removePerson(QString nick);
32protected: 33protected:
33 IRCChannel *m_channel; 34 IRCChannel *m_channel;
34}; 35};
35 36
36#endif /* __IRCCHANNELLIST_H */ 37#endif /* __IRCCHANNELLIST_H */
diff --git a/noncore/net/opieirc/ircchanneltab.cpp b/noncore/net/opieirc/ircchanneltab.cpp
index beb8bce..2b8b65e 100644
--- a/noncore/net/opieirc/ircchanneltab.cpp
+++ b/noncore/net/opieirc/ircchanneltab.cpp
@@ -1,166 +1,167 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/resource.h> 2#include <qpe/resource.h>
3#include <qcursor.h> 3#include <qcursor.h>
4#include <qwhatsthis.h> 4#include <qwhatsthis.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include "ircchanneltab.h" 6#include "ircchanneltab.h"
7#include "ircservertab.h" 7#include "ircservertab.h"
8 8
9IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 9IRCChannelTab::IRCChannelTab(IRCChannel *channel, IRCServerTab *parentTab, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
10 m_mainWindow = mainWindow; 10 m_mainWindow = mainWindow;
11 m_parentTab = parentTab; 11 m_parentTab = parentTab;
12 m_channel = channel; 12 m_channel = channel;
13 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>"); 13 m_description->setText(tr("Talking on channel") + " <b>" + channel->channelname() + "</b>");
14 QHBox *hbox = new QHBox(this); 14 QHBox *hbox = new QHBox(this);
15 m_textview = new QTextView(hbox); 15 m_textview = new QTextView(hbox);
16 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 16 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
17 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 17 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
18 m_listVisible = TRUE; 18 m_listVisible = TRUE;
19 m_listButton = new QPushButton(">", m_textview); 19 m_listButton = new QPushButton(">", m_textview);
20 m_textview->setCornerWidget(m_listButton); 20 m_textview->setCornerWidget(m_listButton);
21 m_textview->setTextFormat(RichText); 21 m_textview->setTextFormat(RichText);
22 QWhatsThis::add(m_textview, tr("Channel discussion")); 22 QWhatsThis::add(m_textview, tr("Channel discussion"));
23 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList())); 23 connect(m_listButton, SIGNAL(clicked()), this, SLOT(toggleList()));
24 m_list = new IRCChannelList(m_channel, hbox); 24 m_list = new IRCChannelList(m_channel, hbox);
25 m_list->update(); 25 m_list->update();
26 m_list->setMaximumWidth(LISTWIDTH); 26 m_list->setMaximumWidth(LISTWIDTH);
27 m_field = new IRCHistoryLineEdit(this); 27 m_field = new IRCHistoryLineEdit(this);
28 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion")); 28 QWhatsThis::add(m_field, tr("Type your message here to participate in the channel discussion"));
29 m_popup = new QPopupMenu(m_list); 29 m_popup = new QPopupMenu(m_list);
30 m_lines = 0; 30 m_lines = 0;
31 /* Required so that embedded-style "right" clicks work */ 31 /* Required so that embedded-style "right" clicks work */
32 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold); 32 QPEApplication::setStylusOperation(m_list->viewport(), QPEApplication::RightOnHold);
33 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &))); 33 connect(m_list, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint&)), this, SLOT(mouseButtonPressed(int, QListBoxItem *, const QPoint &)));
34 /* Construct the popup menu */ 34 /* Construct the popup menu */
35 QPopupMenu *ctcpMenu = new QPopupMenu(m_list); 35 QPopupMenu *ctcpMenu = new QPopupMenu(m_list);
36 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu); 36 m_popup->insertItem(Resource::loadPixmap("opieirc/ctcp"), tr("CTCP"), ctcpMenu);
37 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery())); 37 m_popup->insertItem(Resource::loadPixmap("opieirc/query"), tr("Query"), this, SLOT(popupQuery()));
38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing())); 38 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/ping"), tr("Ping"), this, SLOT(popupPing()));
39 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion())); 39 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/version"), tr("Version"), this, SLOT(popupVersion()));
40 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois())); 40 ctcpMenu->insertItem(Resource::loadPixmap("opieirc/whois"), tr("Whois"), this, SLOT(popupWhois()));
41 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 41 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
42 m_layout->add(hbox); 42 m_layout->add(hbox);
43 hbox->show(); 43 hbox->show();
44 m_layout->add(m_field); 44 m_layout->add(m_field);
45 m_field->setFocus(); 45 m_field->setFocus();
46 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 46 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
47 settingsChanged(); 47 settingsChanged();
48} 48}
49 49
50void IRCChannelTab::scrolling(){ 50void IRCChannelTab::scrolling(){
51 m_textview->ensureVisible(0, m_textview->contentsHeight()); 51 m_textview->ensureVisible(0, m_textview->contentsHeight());
52} 52}
53 53
54void IRCChannelTab::appendText(QString text) { 54void IRCChannelTab::appendText(QString text) {
55 /* not using append because it creates layout problems */ 55 /* not using append because it creates layout problems */
56 QString txt = m_textview->text() + text + "\n"; 56 QString txt = m_textview->text() + text + "\n";
57 if (m_maxLines > 0 && m_lines >= m_maxLines) { 57 if (m_maxLines > 0 && m_lines >= m_maxLines) {
58 int firstBreak = txt.find('\n'); 58 int firstBreak = txt.find('\n');
59 if (firstBreak != -1) { 59 if (firstBreak != -1) {
60 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 60 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
61 } 61 }
62 } else { 62 } else {
63 m_lines++; 63 m_lines++;
64 } 64 }
65 m_textview->ensureVisible(0, m_textview->contentsHeight());
65 m_textview->setText(txt); 66 m_textview->setText(txt);
66 m_textview->ensureVisible(0, m_textview->contentsHeight()); 67 m_textview->ensureVisible(0, m_textview->contentsHeight());
67 emit changed(this); 68 emit changed(this);
68} 69}
69 70
70IRCChannelTab::~IRCChannelTab() { 71IRCChannelTab::~IRCChannelTab() {
71 m_parentTab->removeChannelTab(this); 72 m_parentTab->removeChannelTab(this);
72} 73}
73 74
74void IRCChannelTab::processCommand() { 75void IRCChannelTab::processCommand() {
75 QString text = m_field->text(); 76 QString text = m_field->text();
76 if (text.length()>0) { 77 if (text.length()>0) {
77 if (session()->isSessionActive()) { 78 if (session()->isSessionActive()) {
78 if (text.startsWith("/") && !text.startsWith("//")) { 79 if (text.startsWith("/") && !text.startsWith("//")) {
79 /* Command mode */ 80 /* Command mode */
80 m_parentTab->executeCommand(this, text);; 81 m_parentTab->executeCommand(this, text);;
81 } else { 82 } else {
82 if (text.startsWith("//")) 83 if (text.startsWith("//"))
83 text = text.right(text.length()-1); 84 text = text.right(text.length()-1);
84 session()->sendMessage(m_channel, m_field->text()); 85 session()->sendMessage(m_channel, m_field->text());
85 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>"); 86 appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_selfColor + "\">"+m_parentTab->server()->nick()+"</font><font color=\"" + m_textColor + "\">&gt; "+IRCOutput::toHTML(m_field->text())+"</font><br>");
86 } 87 }
87 } else { 88 } else {
88 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>"); 89 appendText("<font color=\"" + m_errorColor + "\">"+tr("Disconnected")+"</font><br>");
89 } 90 }
90 } 91 }
91 m_field->clear(); 92 m_field->clear();
92} 93}
93 94
94void IRCChannelTab::settingsChanged() { 95void IRCChannelTab::settingsChanged() {
95 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 96 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
96 m_lines = 0; 97 m_lines = 0;
97} 98}
98 99
99void IRCChannelTab::toggleList() { 100void IRCChannelTab::toggleList() {
100 if (m_listVisible) { 101 if (m_listVisible) {
101 m_list->setMaximumWidth(0); 102 m_list->setMaximumWidth(0);
102 m_listButton->setText("<"); 103 m_listButton->setText("<");
103 } else { 104 } else {
104 m_list->setMaximumWidth(LISTWIDTH); 105 m_list->setMaximumWidth(LISTWIDTH);
105 m_listButton->setText(">"); 106 m_listButton->setText(">");
106 } 107 }
107 m_listVisible = !m_listVisible; 108 m_listVisible = !m_listVisible;
108} 109}
109 110
110void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) { 111void IRCChannelTab::mouseButtonPressed(int mouse, QListBoxItem *, const QPoint &point) {
111 switch (mouse) { 112 switch (mouse) {
112 case 1: 113 case 1:
113 break; 114 break;
114 case 2: 115 case 2:
115 m_popup->popup(point); 116 m_popup->popup(point);
116 break; 117 break;
117 }; 118 };
118} 119}
119 120
120void IRCChannelTab::popupQuery() { 121void IRCChannelTab::popupQuery() {
121 if (m_list->currentItem() != -1) { 122 if (m_list->currentItem() != -1) {
122 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text()); 123 IRCPerson *person = session()->getPerson(m_list->item(m_list->currentItem())->text());
123 if (person) { 124 if (person) {
124 IRCQueryTab *tab = m_parentTab->getTabForQuery(person); 125 IRCQueryTab *tab = m_parentTab->getTabForQuery(person);
125 if (!tab) { 126 if (!tab) {
126 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent()); 127 tab = new IRCQueryTab(person, m_parentTab, m_mainWindow, (QWidget *)parent());
127 m_parentTab->addQueryTab(tab); 128 m_parentTab->addQueryTab(tab);
128 m_mainWindow->addTab(tab); 129 m_mainWindow->addTab(tab);
129 } 130 }
130 } 131 }
131 } 132 }
132} 133}
133 134
134void IRCChannelTab::popupPing() { 135void IRCChannelTab::popupPing() {
135 //HAHA, no wonder these don't work 136 //HAHA, no wonder these don't work
136} 137}
137 138
138void IRCChannelTab::popupVersion() { 139void IRCChannelTab::popupVersion() {
139} 140}
140 141
141void IRCChannelTab::popupWhois() { 142void IRCChannelTab::popupWhois() {
142} 143}
143 144
144QString IRCChannelTab::title() { 145QString IRCChannelTab::title() {
145 return m_channel->channelname(); 146 return m_channel->channelname();
146} 147}
147 148
148IRCSession *IRCChannelTab::session() { 149IRCSession *IRCChannelTab::session() {
149 return m_parentTab->session(); 150 return m_parentTab->session();
150} 151}
151 152
152void IRCChannelTab::remove() { 153void IRCChannelTab::remove() {
153 if (session()->isSessionActive()) { 154 if (session()->isSessionActive()) {
154 session()->part(m_channel); 155 session()->part(m_channel);
155 } else { 156 } else {
156 m_mainWindow->killTab(this); 157 m_mainWindow->killTab(this);
157 } 158 }
158} 159}
159 160
160IRCChannel *IRCChannelTab::channel() { 161IRCChannel *IRCChannelTab::channel() {
161 return m_channel; 162 return m_channel;
162} 163}
163 164
164IRCChannelList *IRCChannelTab::list() { 165IRCChannelList *IRCChannelTab::list() {
165 return m_list; 166 return m_list;
166} 167}
diff --git a/noncore/net/opieirc/ircmessageparser.cpp b/noncore/net/opieirc/ircmessageparser.cpp
index 6b88f34..400ff41 100644
--- a/noncore/net/opieirc/ircmessageparser.cpp
+++ b/noncore/net/opieirc/ircmessageparser.cpp
@@ -1,521 +1,536 @@
1#include <qtextstream.h> 1#include <qtextstream.h>
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4 4
5/* Lookup table for literal commands */ 5/* Lookup table for literal commands */
6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = { 6IRCLiteralMessageParserStruct IRCMessageParser::literalParserProcTable[] = {
7 { "PING", FUNC(parseLiteralPing) }, 7 { "PING", FUNC(parseLiteralPing) },
8 { "NOTICE", FUNC(parseLiteralNotice) }, 8 { "NOTICE", FUNC(parseLiteralNotice) },
9 { "JOIN", FUNC(parseLiteralJoin) }, 9 { "JOIN", FUNC(parseLiteralJoin) },
10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) }, 10 { "PRIVMSG", FUNC(parseLiteralPrivMsg) },
11 { "NICK", FUNC(parseLiteralNick) }, 11 { "NICK", FUNC(parseLiteralNick) },
12 { "PART", FUNC(parseLiteralPart) }, 12 { "PART", FUNC(parseLiteralPart) },
13 { "QUIT", FUNC(parseLiteralQuit) }, 13 { "QUIT", FUNC(parseLiteralQuit) },
14 { "ERROR", FUNC(parseLiteralError) }, 14 { "ERROR", FUNC(parseLiteralError) },
15 { "ERROR:", FUNC(parseLiteralError) }, 15 { "ERROR:", FUNC(parseLiteralError) },
16 { "MODE", FUNC(parseLiteralMode) }, 16 { "MODE", FUNC(parseLiteralMode) },
17 { "KICK", FUNC(parseLiteralKick) }, 17 { "KICK", FUNC(parseLiteralKick) },
18 { "TOPIC", FUNC(parseLiteralTopic) }, 18 { "TOPIC", FUNC(parseLiteralTopic) },
19 { 0 , 0 } 19 { 0 , 0 }
20}; 20};
21 21
22/* Lookup table for literal commands */ 22/* Lookup table for literal commands */
23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = { 23IRCCTCPMessageParserStruct IRCMessageParser::ctcpParserProcTable[] = {
24 { "PING", FUNC(parseCTCPPing) }, 24 { "PING", FUNC(parseCTCPPing) },
25 { "VERSION", FUNC(parseCTCPVersion) }, 25 { "VERSION", FUNC(parseCTCPVersion) },
26 { "ACTION", FUNC(parseCTCPAction) }, 26 { "ACTION", FUNC(parseCTCPAction) },
27 { 0 , 0 } 27 { 0 , 0 }
28}; 28};
29 29
30/* Lookup table for numerical commands */ 30/* Lookup table for numerical commands */
31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = { 31IRCNumericalMessageParserStruct IRCMessageParser::numericalParserProcTable[] = {
32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME 32 { 1, FUNC(parseNumerical001) }, // RPL_WELCOME
33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST 33 { 2, FUNC(parseNumerical002) }, // RPL_YOURHOST
34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED 34 { 3, FUNC(parseNumerical003) }, // RPL_CREATED
35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO 35 { 4, FUNC(parseNumerical004) }, // RPL_MYINFO
36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL 36 { 5, FUNC(parseNumerical005) }, // RPL_BOUNCE, RPL_PROTOCTL
37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT 37 { 251, FUNC(parseNumericalStats) }, // RPL_LUSERCLIENT
38 { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP 38 { 252, FUNC(parseNumericalStats) }, // RPL_LUSEROP
39 { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS 39 { 265, FUNC(parseNumericalStats) }, // RPL_LOCALUSERS
40 { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS 40 { 266, FUNC(parseNumericalStats) }, // RPL_GLOBALUSERS
41 { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN 41 { 250, FUNC(parseNumericalStats) }, // RPL_STATSCONN
42 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS 42 { 254, FUNC(nullFunc)}, // RPL_LUSERCHANNELS
43 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME 43 { 255, FUNC(parseNumericalStats) }, // RPL_LUSERNAME
44 { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC 44 { 332, FUNC(parseNumericalTopic) }, // RPL_TOPIC
45 { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME 45 { 333, FUNC(parseNumericalTopicWhoTime) }, // RPL_TOPICWHOTIME
46 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY 46 { 353, FUNC(parseNumericalNames) }, // RPL_NAMREPLY
47 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES 47 { 366, FUNC(parseNumericalEndOfNames) }, // RPL_ENDOFNAMES
48 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART 48 { 375, FUNC(parseNumericalStats) }, // RPL_MOTDSTART
49 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD 49 { 372, FUNC(parseNumericalStats) }, // RPL_MOTD
50 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD 50 { 376, FUNC(parseNumericalStats) }, // RPL_ENDOFMOTD
51 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2 51 { 377, FUNC(parseNumericalStats) }, // RPL_MOTD2
52 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3 52 { 378, FUNC(parseNumericalStats) }, // RPL_MOTD3
53 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK 53 { 401, FUNC(parseNumericalNoSuchNick) }, // ERR_NOSUCHNICK
54 { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK 54 { 406, FUNC(parseNumericalNoSuchNick) }, // ERR_WASNOSUCHNICK
55 { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND 55 { 412, FUNC(parseNumericalStats) }, // ERR_NOTEXTTOSEND
56 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE 56 { 433, FUNC(parseNumericalNicknameInUse) }, // ERR_NICKNAMEINUSE
57 { 0, 0 } 57 { 0, 0 }
58}; 58};
59 59
60IRCMessageParser::IRCMessageParser(IRCSession *session) { 60IRCMessageParser::IRCMessageParser(IRCSession *session) {
61 m_session = session; 61 m_session = session;
62} 62}
63 63
64void IRCMessageParser::parse(IRCMessage *message) { 64void IRCMessageParser::parse(IRCMessage *message) {
65 /* Find out what kind of message we have here and call the appropriate handler using 65 /* Find out what kind of message we have here and call the appropriate handler using
66 the parser tables. If no handler can be found, print out an error message */ 66 the parser tables. If no handler can be found, print out an error message */
67 if (message->isNumerical()) { 67 if (message->isNumerical()) {
68 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) { 68 for (int i=0; i<numericalParserProcTable[i].commandNumber; i++) {
69 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) { 69 if (message->commandNumber() == numericalParserProcTable[i].commandNumber) {
70 (this->*(numericalParserProcTable[i].proc))(message); 70 (this->*(numericalParserProcTable[i].proc))(message);
71 return; 71 return;
72 } 72 }
73 } 73 }
74 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) ))); 74 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled numeric command: %1").arg( QString::number(message->commandNumber()) )));
75 } else if (message->isCTCP()) { 75 } else if (message->isCTCP()) {
76 for (int i=0; ctcpParserProcTable[i].commandName; i++) { 76 for (int i=0; ctcpParserProcTable[i].commandName; i++) {
77 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) { 77 if (message->ctcpCommand() == ctcpParserProcTable[i].commandName) {
78 (this->*(ctcpParserProcTable[i].proc))(message); 78 (this->*(ctcpParserProcTable[i].proc))(message);
79 return; 79 return;
80 } 80 }
81 } 81 }
82 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) ); 82 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled ctcp command: %1").arg( message->ctcpCommand())) );
83 } else { 83 } else {
84 for (int i=0; literalParserProcTable[i].commandName; i++) { 84 for (int i=0; literalParserProcTable[i].commandName; i++) {
85 if (message->command() == literalParserProcTable[i].commandName) { 85 if (message->command() == literalParserProcTable[i].commandName) {
86 (this->*(literalParserProcTable[i].proc))(message); 86 (this->*(literalParserProcTable[i].proc))(message);
87 return; 87 return;
88 } 88 }
89 } 89 }
90 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) )); 90 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received unhandled literal command: %1").arg( message->command()) ));
91 } 91 }
92} 92}
93 93
94void IRCMessageParser::nullFunc(IRCMessage *) { 94void IRCMessageParser::nullFunc(IRCMessage *) {
95 /* Do nothing */ 95 /* Do nothing */
96} 96}
97 97
98void IRCMessageParser::parseLiteralPing(IRCMessage *message) { 98void IRCMessageParser::parseLiteralPing(IRCMessage *message) {
99 m_session->m_connection->sendLine("PONG " + message->allParameters()); 99 m_session->m_connection->sendLine("PONG " + message->allParameters());
100} 100}
101 101
102void IRCMessageParser::parseLiteralNotice(IRCMessage *message) { 102void IRCMessageParser::parseLiteralNotice(IRCMessage *message) {
103 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 103 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
104} 104}
105 105
106void IRCMessageParser::parseLiteralJoin(IRCMessage *message) { 106void IRCMessageParser::parseLiteralJoin(IRCMessage *message) {
107 QString channelName = message->param(0).lower(); 107 QString channelName = message->param(0).lower();
108 IRCPerson mask(message->prefix()); 108 IRCPerson mask(message->prefix());
109 IRCChannel *channel = m_session->getChannel(channelName); 109 IRCChannel *channel = m_session->getChannel(channelName);
110 if (!channel) { 110 if (!channel) {
111 /* We joined */ 111 /* We joined */
112 if (mask.nick() == m_session->m_server->nick()) { 112 if (mask.nick() == m_session->m_server->nick()) {
113 channel = new IRCChannel(channelName); 113 channel = new IRCChannel(channelName);
114 m_session->addChannel(channel); 114 m_session->addChannel(channel);
115 } else { 115 } else {
116 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?"))); 116 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nonexistant channel join - desynchronized?")));
117 } 117 }
118 } else { 118 } else {
119 /* Someone else joined */ 119 /* Someone else joined */
120 if (mask.nick() != m_session->m_server->nick()) { 120 if (mask.nick() != m_session->m_server->nick()) {
121 if (!channel->getPerson(mask.nick())) { 121 if (!channel->getPerson(mask.nick())) {
122 IRCChannelPerson *chanperson = new IRCChannelPerson(); 122 IRCChannelPerson *chanperson = new IRCChannelPerson();
123 IRCPerson *person = m_session->getPerson(mask.nick()); 123 IRCPerson *person = m_session->getPerson(mask.nick());
124 if (!person) { 124 if (!person) {
125 person = new IRCPerson(message->prefix()); 125 person = new IRCPerson(message->prefix());
126 m_session->addPerson(person); 126 m_session->addPerson(person);
127 } 127 }
128 chanperson->flags = 0; 128 chanperson->flags = 0;
129 chanperson->person = person; 129 chanperson->person = person;
130 channel->addPerson(chanperson); 130 channel->addPerson(chanperson);
131 IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName )); 131 IRCOutput output(OUTPUT_OTHERJOIN ,tr("%1 joined channel %2").arg( mask.nick() ).arg( channelName ));
132 output.addParam(channel); 132 output.addParam(channel);
133 output.addParam(chanperson); 133 output.addParam(chanperson);
134 emit outputReady(output); 134 emit outputReady(output);
135 } else { 135 } else {
136 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?"))); 136 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Person has already joined the channel - desynchronized?")));
137 } 137 }
138 } else { 138 } else {
139 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?"))); 139 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("You already joined the channel - desynchronized?")));
140 } 140 }
141 } 141 }
142} 142}
143 143
144void IRCMessageParser::parseLiteralPart(IRCMessage *message) { 144void IRCMessageParser::parseLiteralPart(IRCMessage *message) {
145 QString channelName = message->param(0).lower(); 145 QString channelName = message->param(0).lower();
146 IRCChannel *channel = m_session->getChannel(channelName); 146 IRCChannel *channel = m_session->getChannel(channelName);
147 IRCPerson mask(message->prefix()); 147 IRCPerson mask(message->prefix());
148 if (channel) { 148 if (channel) {
149 if (mask.nick() == m_session->m_server->nick()) { 149 if (mask.nick() == m_session->m_server->nick()) {
150 m_session->removeChannel(channel); 150 m_session->removeChannel(channel);
151 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName )); 151 IRCOutput output(OUTPUT_SELFPART, tr("You left channel %1").arg( channelName ));
152 output.addParam(channel); 152 output.addParam(channel);
153 emit outputReady(output); 153 emit outputReady(output);
154 delete channel; 154 delete channel;
155 } else { 155 } else {
156 IRCChannelPerson *person = channel->getPerson(mask.nick()); 156 IRCChannelPerson *person = channel->getPerson(mask.nick());
157 if (person) { 157 if (person) {
158 channel->removePerson(person); 158 channel->removePerson(person);
159 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) ); 159 IRCOutput output(OUTPUT_OTHERPART, tr("%1 left channel %2").arg( mask.nick() ).arg( channelName) );
160 output.addParam(channel); 160 output.addParam(channel);
161 output.addParam(person); 161 output.addParam(person);
162 emit outputReady(output); 162 emit outputReady(output);
163 delete person; 163 delete person;
164 } else { 164 } else {
165 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?"))); 165 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Parting person not found - desynchronized?")));
166 } 166 }
167 } 167 }
168 } else { 168 } else {
169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?"))); 169 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel for part not found - desynchronized?")));
170 } 170 }
171} 171}
172 172
173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) { 173void IRCMessageParser::parseLiteralPrivMsg(IRCMessage *message) {
174 if (m_session->m_server->nick() == message->param(0)) { 174 if (m_session->m_server->nick() == message->param(0)) {
175 /* IRC Query message detected, verify sender and display it */ 175 /* IRC Query message detected, verify sender and display it */
176 IRCPerson mask(message->prefix()); 176 IRCPerson mask(message->prefix());
177 IRCPerson *person = m_session->getPerson(mask.nick()); 177 IRCPerson *person = m_session->getPerson(mask.nick());
178 if (!person) { 178 if (!person) {
179 /* Person not yet known, create and add to the current session */ 179 /* Person not yet known, create and add to the current session */
180 person = new IRCPerson(message->prefix()); 180 person = new IRCPerson(message->prefix());
181 m_session->addPerson(person); 181 m_session->addPerson(person);
182 } 182 }
183 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1)); 183 IRCOutput output(OUTPUT_QUERYPRIVMSG, message->param(1));
184 output.addParam(person); 184 output.addParam(person);
185 emit outputReady(output); 185 emit outputReady(output);
186 } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') { 186 } else if (message->param(0).at(0) == '#' || message->param(0).at(0) == '+') {
187 /* IRC Channel message detected, verify sender, channel and display it */ 187 /* IRC Channel message detected, verify sender, channel and display it */
188 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 188 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
189 if (channel) { 189 if (channel) {
190 IRCPerson mask(message->prefix()); 190 IRCPerson mask(message->prefix());
191 IRCChannelPerson *person = channel->getPerson(mask.nick()); 191 IRCChannelPerson *person = channel->getPerson(mask.nick());
192 if (person) { 192 if (person) {
193 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1)); 193 IRCOutput output(OUTPUT_CHANPRIVMSG, message->param(1));
194 output.addParam(channel); 194 output.addParam(channel);
195 output.addParam(person); 195 output.addParam(person);
196 emit outputReady(output); 196 emit outputReady(output);
197 } else { 197 } else {
198 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender"))); 198 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown sender")));
199 } 199 }
200 } else { 200 } else {
201 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) )); 201 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Channel message with unknown channel %1").arg(message->param(0).lower()) ));
202 } 202 }
203 } else { 203 } else {
204 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type"))); 204 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Received PRIVMSG of unknown type")));
205 } 205 }
206} 206}
207 207
208void IRCMessageParser::parseLiteralNick(IRCMessage *message) { 208void IRCMessageParser::parseLiteralNick(IRCMessage *message) {
209
209 IRCPerson mask(message->prefix()); 210 IRCPerson mask(message->prefix());
210 211 /* this way of handling nick changes really sucks */
211 if (mask.nick() == m_session->m_server->nick()) { 212 if (mask.nick() == m_session->m_server->nick()) {
212 /* We are changing our nickname */ 213 /* We are changing our nickname */
213 m_session->m_server->setNick(message->param(0)); 214 m_session->m_server->setNick(message->param(0));
214 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0))); 215 IRCOutput output(OUTPUT_NICKCHANGE, tr("You are now known as %1").arg( message->param(0)));
215 output.addParam(0); 216 output.addParam(0);
216 emit outputReady(output); 217 emit outputReady(output);
217 } else { 218 } else {
218 /* Someone else is */ 219 /* Someone else is */
219 IRCPerson *person = m_session->getPerson(mask.nick()); 220 IRCPerson *person = m_session->getPerson(mask.nick());
220 if (person) { 221 if (person) {
221 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0 ))); 222 //IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
222 output.addParam(person); 223
223 emit outputReady(output); 224 /* new code starts here -- this removes the person from all channels */
225 QList<IRCChannel> channels;
226 m_session->getChannelsByPerson(person, channels);
227 QListIterator<IRCChannel> it(channels);
228 for (;it.current(); ++it) {
229 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
230 it.current()->removePerson(chanperson);
231 chanperson->person->setNick(message->param(0));
232 it.current()->addPerson(chanperson);
233 IRCOutput output(OUTPUT_NICKCHANGE, tr("%1 is now known as %2").arg( mask.nick() ).arg( message->param(0)));
234 output.addParam(person);
235 emit outputReady(output);
236 }
237 /* new code ends here */
224 } else { 238 } else {
225 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person"))); 239 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname change of an unknown person")));
226 } 240 }
227 } 241 }
228} 242}
229 243
230void IRCMessageParser::parseLiteralQuit(IRCMessage *message) { 244void IRCMessageParser::parseLiteralQuit(IRCMessage *message) {
231 IRCPerson mask(message->prefix()); 245 IRCPerson mask(message->prefix());
232 IRCPerson *person = m_session->getPerson(mask.nick()); 246 IRCPerson *person = m_session->getPerson(mask.nick());
233 if (person) { 247 if (person) {
234 QList<IRCChannel> channels; 248 QList<IRCChannel> channels;
235 m_session->getChannelsByPerson(person, channels); 249 m_session->getChannelsByPerson(person, channels);
236 QListIterator<IRCChannel> it(channels); 250 QListIterator<IRCChannel> it(channels);
237 for (;it.current(); ++it) { 251 for (;it.current(); ++it) {
238 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick()); 252 IRCChannelPerson *chanperson = it.current()->getPerson(mask.nick());
239 it.current()->removePerson(chanperson); 253 it.current()->removePerson(chanperson);
240 delete chanperson; 254 delete chanperson;
241 } 255 }
242 m_session->removePerson(person); 256 m_session->removePerson(person);
243 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) )); 257 IRCOutput output(OUTPUT_QUIT, tr("%1 has quit (%2)" ).arg( mask.nick() ).arg( message->param(0) ));
244 output.addParam(person); 258 output.addParam(person);
245 emit outputReady(output); 259 emit outputReady(output);
246 delete person; 260 delete person;
247 } else { 261 } else {
248 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?"))); 262 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person quit - desynchronized?")));
249 } 263 }
250} 264}
251 265
252void IRCMessageParser::parseLiteralTopic(IRCMessage *message) { 266void IRCMessageParser::parseLiteralTopic(IRCMessage *message) {
253 IRCPerson mask(message->prefix()); 267 IRCPerson mask(message->prefix());
254 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 268 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
255 if (channel) { 269 if (channel) {
256 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\""); 270 IRCOutput output(OUTPUT_TOPIC, mask.nick() + tr(" changed topic to ") + "\"" + message->param(1) + "\"");
257 output.addParam(channel); 271 output.addParam(channel);
258 emit outputReady(output); 272 emit outputReady(output);
259 } else { 273 } else {
260 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?"))); 274 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel topic - desynchronized?")));
261 } 275 }
262} 276}
263 277
264void IRCMessageParser::parseLiteralError(IRCMessage *message) { 278void IRCMessageParser::parseLiteralError(IRCMessage *message) {
265 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters())); 279 emit outputReady(IRCOutput(OUTPUT_ERROR, message->allParameters()));
266} 280}
267 281
268void IRCMessageParser::parseCTCPPing(IRCMessage *message) { 282void IRCMessageParser::parseCTCPPing(IRCMessage *message) {
269 IRCPerson mask(message->prefix()); 283 IRCPerson mask(message->prefix());
270 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters()); 284 m_session->m_connection->sendCTCP(mask.nick(), "PING " + message->allParameters());
271 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick())); 285 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP PING from ")+mask.nick()));
272} 286}
273 287
274void IRCMessageParser::parseCTCPVersion(IRCMessage *message) { 288void IRCMessageParser::parseCTCPVersion(IRCMessage *message) {
275 IRCPerson mask(message->prefix()); 289 IRCPerson mask(message->prefix());
276 m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR); 290 m_session->m_connection->sendCTCP(mask.nick(), APP_VERSION " " APP_COPYSTR);
277 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick())); 291 emit outputReady(IRCOutput(OUTPUT_CTCP, tr("Received a CTCP VERSION from ")+mask.nick()));
278} 292}
279 293
280void IRCMessageParser::parseCTCPAction(IRCMessage *message) { 294void IRCMessageParser::parseCTCPAction(IRCMessage *message) {
281 IRCPerson mask(message->prefix()); 295 IRCPerson mask(message->prefix());
282 QString dest = message->ctcpDestination(); 296 QString dest = message->ctcpDestination();
283 if (dest.startsWith("#")) { 297 if (dest.startsWith("#")) {
284 IRCChannel *channel = m_session->getChannel(dest.lower()); 298 IRCChannel *channel = m_session->getChannel(dest.lower());
285 if (channel) { 299 if (channel) {
286 IRCChannelPerson *person = channel->getPerson(mask.nick()); 300 IRCChannelPerson *person = channel->getPerson(mask.nick());
287 if (person) { 301 if (person) {
288 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0)); 302 IRCOutput output(OUTPUT_CHANACTION, "*" + mask.nick() + message->param(0));
289 output.addParam(channel); 303 output.addParam(channel);
290 output.addParam(person); 304 output.addParam(person);
291 emit outputReady(output); 305 emit outputReady(output);
292 } else { 306 } else {
293 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?"))); 307 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown person - Desynchronized?")));
294 } 308 }
295 } else { 309 } else {
296 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?"))); 310 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with unknown channel - Desynchronized?")));
297 } 311 }
298 } else { 312 } else {
299 if (message->ctcpDestination() == m_session->m_server->nick()) { 313 if (message->ctcpDestination() == m_session->m_server->nick()) {
300 IRCPerson *person = m_session->getPerson(mask.nick()); 314 IRCPerson *person = m_session->getPerson(mask.nick());
301 if (!person) { 315 if (!person) {
302 /* Person not yet known, create and add to the current session */ 316 /* Person not yet known, create and add to the current session */
303 person = new IRCPerson(message->prefix()); 317 person = new IRCPerson(message->prefix());
304 m_session->addPerson(person); 318 m_session->addPerson(person);
305 } 319 }
306 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0)); 320 IRCOutput output(OUTPUT_QUERYACTION, "*" + mask.nick() + message->param(0));
307 output.addParam(person); 321 output.addParam(person);
308 emit outputReady(output); 322 emit outputReady(output);
309 } else { 323 } else {
310 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient"))); 324 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("CTCP ACTION with bad recipient")));
311 } 325 }
312 } 326 }
313} 327}
314 328
315void IRCMessageParser::parseLiteralMode(IRCMessage *message) { 329void IRCMessageParser::parseLiteralMode(IRCMessage *message) {
316 IRCPerson mask(message->prefix()); 330 IRCPerson mask(message->prefix());
317 331
318 if (message->param(0).startsWith("#")) { 332 if (message->param(0).startsWith("#")) {
319 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 333 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
320 if (channel) { 334 if (channel) {
321 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1); 335 QString temp, parameters = message->allParameters().right(message->allParameters().length() - channel->channelname().length() - 1);
322 QTextIStream stream(&parameters); 336 QTextIStream stream(&parameters);
323 bool set = FALSE; 337 bool set = FALSE;
324 while (!stream.atEnd()) { 338 while (!stream.atEnd()) {
325 stream >> temp; 339 stream >> temp;
326 if (temp.startsWith("+")) { 340 if (temp.startsWith("+")) {
327 set = TRUE; 341 set = TRUE;
328 temp = temp.right(1); 342 temp = temp.right(1);
329 } else if (temp.startsWith("-")) { 343 } else if (temp.startsWith("-")) {
330 set = FALSE; 344 set = FALSE;
331 temp = temp.right(1); 345 temp = temp.right(1);
332 } else { 346 } else {
333 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type"))); 347 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change has unknown type")));
334 return; 348 return;
335 } 349 }
336 if (temp == "o") { 350 if (temp == "o") {
337 stream >> temp; 351 stream >> temp;
338 IRCChannelPerson *person = channel->getPerson(temp); 352 IRCChannelPerson *person = channel->getPerson(temp);
339 if (person) { 353 if (person) {
340 if (set) { 354 if (set) {
341 person->flags |= PERSON_FLAG_OP; 355 person->flags |= PERSON_FLAG_OP;
342 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick())); 356 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives channel operator status to " + person->person->nick()));
343 output.addParam(channel); 357 output.addParam(channel);
344 output.addParam(person); 358 output.addParam(person);
345 emit outputReady(output); 359 emit outputReady(output);
346 } else { 360 } else {
347 person->flags &= 0xFFFF - PERSON_FLAG_OP; 361 person->flags &= 0xFFFF - PERSON_FLAG_OP;
348 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick())); 362 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes channel operator status from " + person->person->nick()));
349 output.addParam(channel); 363 output.addParam(channel);
350 output.addParam(person); 364 output.addParam(person);
351 emit outputReady(output); 365 emit outputReady(output);
352 } 366 }
353 } else { 367 } else {
354 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 368 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
355 } 369 }
356 } else if (temp == "v") { 370 } else if (temp == "v") {
357 stream >> temp; 371 stream >> temp;
358 IRCChannelPerson *person = channel->getPerson(temp); 372 IRCChannelPerson *person = channel->getPerson(temp);
359 if (person) { 373 if (person) {
360 if (set) { 374 if (set) {
361 person->flags |= PERSON_FLAG_VOICE; 375 person->flags |= PERSON_FLAG_VOICE;
362 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick())); 376 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" gives voice to " + person->person->nick()));
363 output.addParam(channel); 377 output.addParam(channel);
364 output.addParam(person); 378 output.addParam(person);
365 emit outputReady(output); 379 emit outputReady(output);
366 } else { 380 } else {
367 person->flags &= 0xFFFF - PERSON_FLAG_VOICE; 381 person->flags &= 0xFFFF - PERSON_FLAG_VOICE;
368 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick())); 382 IRCOutput output(OUTPUT_CHANPERSONMODE, mask.nick() + tr(" removes voice from " + person->person->nick()));
369 output.addParam(channel); 383 output.addParam(channel);
370 output.addParam(person); 384 output.addParam(person);
371 emit outputReady(output); 385 emit outputReady(output);
372 } 386 }
373 } else { 387 } else {
374 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?"))); 388 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown person - Desynchronized?")));
375 } 389 }
376 } else { 390 } else {
377 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag"))); 391 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown flag")));
378 } 392 }
379 } 393 }
380 } else { 394 } else {
381 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?"))); 395 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Mode change with unknown kannel - Desynchronized?")));
382 } 396 }
383 } else { 397 } else {
384 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet"))); 398 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("User modes not supported yet")));
385 } 399 }
386} 400}
387 401
388void IRCMessageParser::parseLiteralKick(IRCMessage *message) { 402void IRCMessageParser::parseLiteralKick(IRCMessage *message) {
389 IRCPerson mask(message->prefix()); 403 IRCPerson mask(message->prefix());
390 IRCChannel *channel = m_session->getChannel(message->param(0).lower()); 404 IRCChannel *channel = m_session->getChannel(message->param(0).lower());
391 if (channel) { 405 if (channel) {
392 IRCChannelPerson *person = channel->getPerson(message->param(1)); 406 IRCChannelPerson *person = channel->getPerson(message->param(1));
393 if (person) { 407 if (person) {
394 if (person->person->nick() == m_session->m_server->nick()) { 408 if (person->person->nick() == m_session->m_server->nick()) {
395 m_session->removeChannel(channel); 409 m_session->removeChannel(channel);
396 IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")"); 410 IRCOutput output(OUTPUT_SELFKICK, tr("You were kicked from ") + channel->channelname() + tr(" by ") + mask.nick() + " (" + message->param(2) + ")");
397 output.addParam(channel); 411 output.addParam(channel);
398 emit outputReady(output); 412 emit outputReady(output);
399 } else { 413 } else {
414 /* someone else got kicked */
400 channel->removePerson(person); 415 channel->removePerson(person);
401 IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")"); 416 IRCOutput output(OUTPUT_OTHERKICK, person->person->nick() + tr(" was kicked from ") + channel->channelname() + tr(" by ") + mask.nick()+ " (" + message->param(2) + ")");
402 output.addParam(channel); 417 output.addParam(channel);
403 output.addParam(person); 418 output.addParam(person);
404 emit outputReady(output); 419 emit outputReady(output);
405 } 420 }
406 } else { 421 } else {
407 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?"))); 422 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown person kick - desynchronized?")));
408 } 423 }
409 } else { 424 } else {
410 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?"))); 425 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Unknown channel kick - desynchronized?")));
411 } 426 }
412} 427}
413 428
414void IRCMessageParser::parseNumerical001(IRCMessage *message) { 429void IRCMessageParser::parseNumerical001(IRCMessage *message) {
415 /* Welcome to IRC message, display */ 430 /* Welcome to IRC message, display */
416 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 431 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
417} 432}
418 433
419void IRCMessageParser::parseNumerical002(IRCMessage *message) { 434void IRCMessageParser::parseNumerical002(IRCMessage *message) {
420 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 435 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
421} 436}
422 437
423void IRCMessageParser::parseNumerical003(IRCMessage *message) { 438void IRCMessageParser::parseNumerical003(IRCMessage *message) {
424 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 439 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
425} 440}
426 441
427void IRCMessageParser::parseNumerical004(IRCMessage *message) { 442void IRCMessageParser::parseNumerical004(IRCMessage *message) {
428 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 443 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
429} 444}
430 445
431void IRCMessageParser::parseNumerical005(IRCMessage *message) { 446void IRCMessageParser::parseNumerical005(IRCMessage *message) {
432 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters())); 447 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->allParameters()));
433} 448}
434 449
435void IRCMessageParser::parseNumericalStats(IRCMessage *message) { 450void IRCMessageParser::parseNumericalStats(IRCMessage *message) {
436 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1))); 451 emit outputReady(IRCOutput(OUTPUT_SERVERMESSAGE, message->param(1)));
437} 452}
438 453
439void IRCMessageParser::parseNumericalNames(IRCMessage *message) { 454void IRCMessageParser::parseNumericalNames(IRCMessage *message) {
440 /* Name list sent when joining a channel */ 455 /* Name list sent when joining a channel */
441 IRCChannel *channel = m_session->getChannel(message->param(2).lower()); 456 IRCChannel *channel = m_session->getChannel(message->param(2).lower());
442 if (channel != 0) { 457 if (channel != 0) {
443 QString people = message->param(3); 458 QString people = message->param(3);
444 QTextIStream stream(&people); 459 QTextIStream stream(&people);
445 QString temp; 460 QString temp;
446 461
447 while (!stream.atEnd()) { 462 while (!stream.atEnd()) {
448 stream >> temp; 463 stream >> temp;
449 464
450 char flagch = temp.at(0).latin1(); 465 char flagch = temp.at(0).latin1();
451 int flag = 0; 466 int flag = 0;
452 QString nick; 467 QString nick;
453 /* Parse person flags */ 468 /* Parse person flags */
454 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') { 469 if (flagch == '@' || flagch == '+' || flagch=='%' || flagch == '*') {
455 470
456 nick = temp.right(temp.length()-1); 471 nick = temp.right(temp.length()-1);
457 switch (flagch) { 472 switch (flagch) {
458 case '@': flag = PERSON_FLAG_OP; break; 473 case '@': flag = PERSON_FLAG_OP; break;
459 case '+': flag = PERSON_FLAG_VOICE; break; 474 case '+': flag = PERSON_FLAG_VOICE; break;
460 case '%': flag = PERSON_FLAG_HALFOP; break; 475 case '%': flag = PERSON_FLAG_HALFOP; break;
461 default : flag = 0; break; 476 default : flag = 0; break;
462 } 477 }
463 } else { 478 } else {
464 nick = temp; 479 nick = temp;
465 } 480 }
466 481
467 IRCChannelPerson *chan_person = new IRCChannelPerson(); 482 IRCChannelPerson *chan_person = new IRCChannelPerson();
468 IRCPerson *person = m_session->getPerson(nick); 483 IRCPerson *person = m_session->getPerson(nick);
469 if (person == 0) { 484 if (person == 0) {
470 person = new IRCPerson(); 485 person = new IRCPerson();
471 person->setNick(nick); 486 person->setNick(nick);
472 m_session->addPerson(person); 487 m_session->addPerson(person);
473 } 488 }
474 chan_person->person = person; 489 chan_person->person = person;
475 chan_person->flags = flag; 490 chan_person->flags = flag;
476 channel->addPerson(chan_person); 491 channel->addPerson(chan_person);
477 } 492 }
478 } else { 493 } else {
479 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); 494 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
480 } 495 }
481} 496}
482 497
483void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) { 498void IRCMessageParser::parseNumericalEndOfNames(IRCMessage *message) {
484 /* Done syncing to channel */ 499 /* Done syncing to channel */
485 IRCChannel *channel = m_session->getChannel(message->param(1).lower()); 500 IRCChannel *channel = m_session->getChannel(message->param(1).lower());
486 if (channel) { 501 if (channel) {
487 channel->setHasPeople(TRUE); 502 channel->setHasPeople(TRUE);
488 /* Yes, we want the names before anything happens inside the GUI */ 503 /* Yes, we want the names before anything happens inside the GUI */
489 IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname()); 504 IRCOutput output(OUTPUT_SELFJOIN, tr("You joined channel ") + channel->channelname());
490 output.addParam(channel); 505 output.addParam(channel);
491 emit outputReady(output); 506 emit outputReady(output);
492 } else { 507 } else {
493 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel"))); 508 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Server message with unknown channel")));
494 } 509 }
495} 510}
496 511
497 512
498void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) { 513void IRCMessageParser::parseNumericalNicknameInUse(IRCMessage *) {
499 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname"))); 514 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("Nickname is in use, please reconnect with a different nickname")));
500 m_session->endSession(); 515 m_session->endSession();
501} 516}
502 517
503void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) { 518void IRCMessageParser::parseNumericalNoSuchNick(IRCMessage *) {
504 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname"))); 519 emit outputReady(IRCOutput(OUTPUT_ERROR, tr("No such nickname")));
505} 520}
506 521
507void IRCMessageParser::parseNumericalTopic(IRCMessage *message) { 522void IRCMessageParser::parseNumericalTopic(IRCMessage *message) {
508 IRCChannel *channel = m_session->getChannel(message->param(1).lower()); 523 IRCChannel *channel = m_session->getChannel(message->param(1).lower());
509 if (channel) { 524 if (channel) {
510 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\"")); 525 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + channel->channelname() + " is \"" + message->param(2) + "\""));
511 output.addParam(channel); 526 output.addParam(channel);
512 emit outputReady(output); 527 emit outputReady(output);
513 } else { 528 } else {
514 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\"")); 529 IRCOutput output(OUTPUT_TOPIC, tr("Topic for channel " + message->param(1) + " is \"" + message->param(2) + "\""));
515 output.addParam(0); 530 output.addParam(0);
516 emit outputReady(output); 531 emit outputReady(output);
517 } 532 }
518} 533}
519 534
520void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) { 535void IRCMessageParser::parseNumericalTopicWhoTime(IRCMessage *) {
521} 536}
diff --git a/noncore/net/opieirc/ircservertab.cpp b/noncore/net/opieirc/ircservertab.cpp
index 1d9520a..2c28507 100644
--- a/noncore/net/opieirc/ircservertab.cpp
+++ b/noncore/net/opieirc/ircservertab.cpp
@@ -1,368 +1,374 @@
1#include <qpe/config.h> 1#include <qpe/config.h>
2#include <qtextstream.h> 2#include <qtextstream.h>
3#include <qwhatsthis.h> 3#include <qwhatsthis.h>
4#include "ircservertab.h" 4#include "ircservertab.h"
5 5
6IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) { 6IRCServerTab::IRCServerTab(IRCServer server, MainWindow *mainWindow, QWidget *parent, const char *name, WFlags f) : IRCTab(parent, name, f) {
7 m_server = server; 7 m_server = server;
8 m_session = new IRCSession(&m_server); 8 m_session = new IRCSession(&m_server);
9 m_mainWindow = mainWindow; 9 m_mainWindow = mainWindow;
10 m_close = FALSE; 10 m_close = FALSE;
11 m_lines = 0; 11 m_lines = 0;
12 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>"); 12 m_description->setText(tr("Connection to")+" <b>" + server.hostname() + ":" + QString::number(server.port()) + "</b>");
13 m_textview = new QTextView(this); 13 m_textview = new QTextView(this);
14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff); 14 m_textview->setHScrollBarMode(QScrollView::AlwaysOff);
15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn); 15 m_textview->setVScrollBarMode(QScrollView::AlwaysOn);
16 m_textview->setTextFormat(RichText); 16 m_textview->setTextFormat(RichText);
17 QWhatsThis::add(m_textview, tr("Server messages")); 17 QWhatsThis::add(m_textview, tr("Server messages"));
18 m_layout->add(m_textview); 18 m_layout->add(m_textview);
19 m_field = new IRCHistoryLineEdit(this); 19 m_field = new IRCHistoryLineEdit(this);
20 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help")); 20 QWhatsThis::add(m_field, tr("Type commands here. A list of available commands can be found inside the OpieIRC help"));
21 m_layout->add(m_field); 21 m_layout->add(m_field);
22 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand())); 22 connect(m_field, SIGNAL(returnPressed()), this, SLOT(processCommand()));
23 m_field->setFocus(); 23 m_field->setFocus();
24 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput))); 24 connect(m_session, SIGNAL(outputReady(IRCOutput)), this, SLOT(display(IRCOutput)));
25 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling())); 25 connect(m_mainWindow, SIGNAL(updateScroll()), this, SLOT(scrolling()));
26 settingsChanged(); 26 settingsChanged();
27} 27}
28 28
29void IRCServerTab::scrolling(){ 29void IRCServerTab::scrolling(){
30 m_textview->ensureVisible(0, m_textview->contentsHeight()); 30 m_textview->ensureVisible(0, m_textview->contentsHeight());
31} 31}
32 32
33 33
34void IRCServerTab::appendText(QString text) { 34void IRCServerTab::appendText(QString text) {
35 /* not using append because it creates layout problems */ 35 /* not using append because it creates layout problems */
36 QString txt = m_textview->text() + text + "\n"; 36 QString txt = m_textview->text() + text + "\n";
37 if (m_maxLines > 0 && m_lines >= m_maxLines) { 37 if (m_maxLines > 0 && m_lines >= m_maxLines) {
38 int firstBreak = txt.find('\n'); 38 int firstBreak = txt.find('\n');
39 if (firstBreak != -1) { 39 if (firstBreak != -1) {
40 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1)); 40 txt = "<qt bgcolor=\"" + m_backgroundColor + "\"/>" + txt.right(txt.length() - (firstBreak + 1));
41 } 41 }
42 } else { 42 } else {
43 m_lines++; 43 m_lines++;
44 } 44 }
45 m_textview->setText(txt); 45 m_textview->setText(txt);
46 m_textview->ensureVisible(0, m_textview->contentsHeight()); 46 m_textview->ensureVisible(0, m_textview->contentsHeight());
47 emit changed(this); 47 emit changed(this);
48} 48}
49 49
50IRCServerTab::~IRCServerTab() { 50IRCServerTab::~IRCServerTab() {
51 delete m_session; 51 delete m_session;
52} 52}
53 53
54void IRCServerTab::removeChannelTab(IRCChannelTab *tab) { 54void IRCServerTab::removeChannelTab(IRCChannelTab *tab) {
55 m_channelTabs.remove(tab); 55 m_channelTabs.remove(tab);
56} 56}
57 57
58void IRCServerTab::removeQueryTab(IRCQueryTab *tab) { 58void IRCServerTab::removeQueryTab(IRCQueryTab *tab) {
59 m_queryTabs.remove(tab); 59 m_queryTabs.remove(tab);
60} 60}
61 61
62void IRCServerTab::addQueryTab(IRCQueryTab *tab) { 62void IRCServerTab::addQueryTab(IRCQueryTab *tab) {
63 m_queryTabs.append(tab); 63 m_queryTabs.append(tab);
64} 64}
65 65
66QString IRCServerTab::title() { 66QString IRCServerTab::title() {
67 return "Server"; 67 return "Server";
68} 68}
69 69
70IRCSession *IRCServerTab::session() { 70IRCSession *IRCServerTab::session() {
71 return m_session; 71 return m_session;
72} 72}
73/* 73/*
74QString *IRCServerTab::mynick() { 74QString *IRCServerTab::mynick() {
75 return (*m_server->nick()); 75 return (*m_server->nick());
76} */ 76} */
77 77
78IRCServer *IRCServerTab::server() { 78IRCServer *IRCServerTab::server() {
79 return &m_server; 79 return &m_server;
80} 80}
81 81
82void IRCServerTab::settingsChanged() { 82void IRCServerTab::settingsChanged() {
83 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>"); 83 m_textview->setText("<qt bgcolor=\"" + m_backgroundColor + "\"/>");
84 m_lines = 0; 84 m_lines = 0;
85} 85}
86 86
87void IRCServerTab::executeCommand(IRCTab *tab, QString line) { 87void IRCServerTab::executeCommand(IRCTab *tab, QString line) {
88 QTextIStream stream(&line); 88 QTextIStream stream(&line);
89 QString command; 89 QString command;
90 stream >> command; 90 stream >> command;
91 command = command.upper().right(command.length()-1); 91 command = command.upper().right(command.length()-1);
92 92
93 //JOIN 93 //JOIN
94 if (command == "JOIN" || command == "J") { 94 if (command == "JOIN" || command == "J") {
95 QString channel; 95 QString channel;
96 stream >> channel; 96 stream >> channel;
97 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) { 97 if (channel.length() > 0 && (channel.startsWith("#") || channel.startsWith("+"))) {
98 m_session->join(channel); 98 m_session->join(channel);
99 } else { 99 } else {
100 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>"); 100 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown channel format!</font><br>");
101 } 101 }
102 } 102 }
103 103
104 //KICK 104 //KICK
105 else if (command == "KICK"){ 105 else if (command == "KICK"){
106 QString nickname; 106 QString nickname;
107 stream >> nickname; 107 stream >> nickname;
108 if (nickname.length() > 0) { 108 if (nickname.length() > 0) {
109 if (line.length() > 7 + nickname.length()) { 109 if (line.length() > 7 + nickname.length()) {
110 QString text = line.right(line.length()-nickname.length()-7); 110 QString text = line.right(line.length()-nickname.length()-7);
111 IRCPerson person; 111 IRCPerson person;
112 person.setNick(nickname); 112 person.setNick(nickname);
113 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text); 113 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
114 } else { 114 } else {
115 IRCPerson person; 115 IRCPerson person;
116 person.setNick(nickname); 116 person.setNick(nickname);
117 m_session->kick(((IRCChannelTab *)tab)->channel(), &person); 117 m_session->kick(((IRCChannelTab *)tab)->channel(), &person);
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 else if (command == "OP"){ 122 else if (command == "OP"){
123 QString nickname; 123 QString nickname;
124 stream >> nickname; 124 stream >> nickname;
125 if (nickname.length() > 0) { 125 if (nickname.length() > 0) {
126 if (line.length() > 7 + nickname.length()) { 126 QString text = line.right(line.length()-nickname.length()-5);
127 QString text = line.right(line.length()-nickname.length()-7);
128 IRCPerson person;
129 person.setNick(nickname);
130 m_session->kick(((IRCChannelTab *)tab)->channel(), &person, text);
131 } else {
132 IRCPerson person; 127 IRCPerson person;
133 person.setNick(nickname); 128 person.setNick(nickname);
134 m_session->kick(((IRCChannelTab *)tab)->channel(), &person); 129 m_session->op(((IRCChannelTab *)tab)->channel(), &person);
135 } 130 }
136 } 131 }
137 }
138 132
139 //SEND MODES 133 //SEND MODES
140 else if (command == "MODE"){ 134 else if (command == "MODE"){
141 QString text = line.right(line.length()-6); 135 QString text = line.right(line.length()-6);
142 if (text.length() > 0) { 136 if (text.length() > 0) {
143 m_session->mode(text); 137 m_session->mode(text);
144 } else { 138 } else {
145 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>"); 139 tab->appendText("<font color=\"" + m_errorColor + "\">/mode channel {[+|-]|o|p|s|i|t|n|b|v} [limit] [user] [ban mask]<br>/mode nickname {[+|-]|i|w|s|o}</font><br>");
146 } 140 }
147 } 141 }
148 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want 142 //SEND RAW MESSAGE TO SERVER, COMPLETELY UNCHECKED - anything in the RFC...or really anything you want
149 else if (command == "RAW"){ 143 else if (command == "RAW"){
150 QString text = line.right(line.length()-5); 144 QString text = line.right(line.length()-5);
151 if (text.length() > 0) { 145 if (text.length() > 0) {
152 m_session->raw(text); 146 m_session->raw(text);
153 } 147 }
154 } 148 }
155 else if (command == "SUSPEND"){ 149 else if (command == "SUSPEND"){
156 QString text = line.right(line.length()-9); 150 QString text = line.right(line.length()-9);
157 if (text.upper() == "ON") { 151 if (text.upper() == "ON") {
158 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 152 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
159 } 153 }
160 else if (text.upper() == "OFF"){ 154 else if (text.upper() == "OFF"){
161 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; 155 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
162 } else { 156 } else {
163 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text); 157 tab->appendText("<font color=\"" + m_errorColor + "\">Line: "+ line +"</font><br>Text: "+text);
164 } 158 }
165 } 159 }
166 160
167 else if (command == "QUIT"){ 161 else if (command == "QUIT"){
168 QString text = line.right(line.length()-6); 162 QString text = line.right(line.length()-6);
169 if (text.length() > 0) { 163 if (text.length() > 0) {
170 m_session->quit(text); 164 m_session->quit(text);
171 } else { 165 } else {
172 m_session->quit(); 166 m_session->quit();
173 } 167 }
174 } 168 }
175 169
176 //SEND ACTION 170 //SEND ACTION
177 else if (command == "ME") { 171 else if (command == "ME") {
178 QString text = line.right(line.length()-4); 172 QString text = line.right(line.length()-4);
179 if (text.length() > 0) { 173 if (text.length() > 0) {
180 if (tab->isA("IRCChannelTab")) { 174 if (tab->isA("IRCChannelTab")) {
181 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 175 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
182 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text); 176 m_session->sendAction(((IRCChannelTab *)tab)->channel(), text);
183 } else if (tab->isA("IRCQueryTab")) { 177 } else if (tab->isA("IRCQueryTab")) {
184 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>"); 178 tab->appendText("<font color=\"" + m_selfColor + "\">*" + IRCOutput::toHTML(m_server.nick()) + " " + IRCOutput::toHTML(text) + "</font><br>");
185 m_session->sendAction(((IRCQueryTab *)tab)->person(), text); 179 m_session->sendAction(((IRCQueryTab *)tab)->person(), text);
186 } else { 180 } else {
187 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>"); 181 tab->appendText("<font color=\"" + m_errorColor + "\">Invalid tab for this command</font><br>");
188 } 182 }
189 } 183 }
190 } 184 }
191 //SEND PRIVMSG 185 //SEND PRIVMSG
192 else if (command == "MSG") { 186 else if (command == "MSG") {
193 QString nickname; 187 QString nickname;
194 stream >> nickname; 188 stream >> nickname;
195 if (nickname.length() > 0) { 189 if (nickname.length() > 0) {
196 if (line.length() > 6 + nickname.length()) { 190 if (line.length() > 6 + nickname.length()) {
197 QString text = line.right(line.length()-nickname.length()-6); 191 QString text = line.right(line.length()-nickname.length()-6);
198 IRCPerson person; 192 IRCPerson person;
199 person.setNick(nickname); 193 person.setNick(nickname);
200 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>"); 194 tab->appendText("<font color=\"" + m_textColor + "\">&gt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(nickname)+"</font><font color=\"" + m_textColor + "\">&lt; "+IRCOutput::toHTML(text)+"</font><br>");
201 m_session->sendMessage(&person, text); 195 m_session->sendMessage(&person, text);
202 } 196 }
203 } 197 }
204 } 198 }
205 else { 199 else {
206 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>"); 200 tab->appendText("<font color=\"" + m_errorColor + "\">Unknown command</font><br>");
207 } 201 }
208} 202}
209 203
210void IRCServerTab::processCommand() { 204void IRCServerTab::processCommand() {
211 QString text = m_field->text(); 205 QString text = m_field->text();
212 if (text.startsWith("/") && !text.startsWith("//")) { 206 if (text.startsWith("/") && !text.startsWith("//")) {
213 /* Command mode */ 207 /* Command mode */
214 executeCommand(this, text); 208 executeCommand(this, text);
215 } 209 }
216 m_field->clear(); 210 m_field->clear();
217} 211}
218 212
219void IRCServerTab::doConnect() { 213void IRCServerTab::doConnect() {
220 m_session->beginSession(); 214 m_session->beginSession();
221} 215}
222 216
223void IRCServerTab::remove() { 217void IRCServerTab::remove() {
224 /* Close requested */ 218 /* Close requested */
225 if (m_session->isSessionActive()) { 219 if (m_session->isSessionActive()) {
226 /* While there is a running session */ 220 /* While there is a running session */
227 m_close = TRUE; 221 m_close = TRUE;
228 m_session->endSession(); 222 m_session->endSession();
229 } else { 223 } else {
230 /* Session has previously been closed */ 224 /* Session has previously been closed */
231 m_channelTabs.first(); 225 m_channelTabs.first();
232 while (m_channelTabs.current() != 0) { 226 while (m_channelTabs.current() != 0) {
233 m_mainWindow->killTab(m_channelTabs.current()); 227 m_mainWindow->killTab(m_channelTabs.current());
234 } 228 }
235 m_queryTabs.first(); 229 m_queryTabs.first();
236 while (m_queryTabs.current() != 0) { 230 while (m_queryTabs.current() != 0) {
237 m_mainWindow->killTab(m_queryTabs.current()); 231 m_mainWindow->killTab(m_queryTabs.current());
238 } 232 }
239 m_mainWindow->killTab(this); 233 m_mainWindow->killTab(this);
240 } 234 }
241} 235}
242 236
243IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) { 237IRCChannelTab *IRCServerTab::getTabForChannel(IRCChannel *channel) {
244 QListIterator<IRCChannelTab> it(m_channelTabs); 238 QListIterator<IRCChannelTab> it(m_channelTabs);
245 239
246 for (; it.current(); ++it) { 240 for (; it.current(); ++it) {
247 if (it.current()->channel() == channel) 241 if (it.current()->channel() == channel)
248 return it.current(); 242 return it.current();
249 } 243 }
250 return 0; 244 return 0;
251} 245}
252 246
253IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) { 247IRCQueryTab *IRCServerTab::getTabForQuery(IRCPerson *person) {
254 QListIterator<IRCQueryTab> it(m_queryTabs); 248 QListIterator<IRCQueryTab> it(m_queryTabs);
255 249
256 for (; it.current(); ++it) { 250 for (; it.current(); ++it) {
257 if (it.current()->person()->nick() == person->nick()) 251 if (it.current()->person()->nick() == person->nick())
258 return it.current(); 252 return it.current();
259 } 253 }
260 return 0; 254 return 0;
261} 255}
262 256
263void IRCServerTab::display(IRCOutput output) { 257void IRCServerTab::display(IRCOutput output) {
264 258
265 /* All messages to be displayed inside the GUI get here */ 259 /* All messages to be displayed inside the GUI get here */
266 switch (output.type()) { 260 switch (output.type()) {
267 case OUTPUT_CONNCLOSE: 261 case OUTPUT_CONNCLOSE:
268 if (m_close) { 262 if (m_close) {
269 m_channelTabs.first(); 263 m_channelTabs.first();
270 while (m_channelTabs.current() != 0) { 264 while (m_channelTabs.current() != 0) {
271 m_mainWindow->killTab(m_channelTabs.current()); 265 m_mainWindow->killTab(m_channelTabs.current());
272 } 266 }
273 m_queryTabs.first(); 267 m_queryTabs.first();
274 while (m_queryTabs.current() != 0) { 268 while (m_queryTabs.current() != 0) {
275 m_mainWindow->killTab(m_queryTabs.current()); 269 m_mainWindow->killTab(m_queryTabs.current());
276 } 270 }
277 m_mainWindow->killTab(this); 271 m_mainWindow->killTab(this);
278 } else { 272 } else {
279 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>"); 273 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() +"</font><br>");
280 QListIterator<IRCChannelTab> it(m_channelTabs); 274 QListIterator<IRCChannelTab> it(m_channelTabs);
281 for (; it.current(); ++it) { 275 for (; it.current(); ++it) {
282 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>"); 276 it.current()->appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() +"</font><br>");
283 } 277 }
284 } 278 }
285 break; 279 break;
286 case OUTPUT_SELFJOIN: { 280 case OUTPUT_SELFJOIN: {
287 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 281 IRCChannelTab *channeltab = new IRCChannelTab((IRCChannel *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
288 m_channelTabs.append(channeltab); 282 m_channelTabs.append(channeltab);
289 m_mainWindow->addTab(channeltab); 283 m_mainWindow->addTab(channeltab);
290 } 284 }
291 break; 285 break;
292 case OUTPUT_CHANPRIVMSG: { 286 case OUTPUT_CHANPRIVMSG: {
293 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 287 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
294 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>"); 288 channelTab->appendText("<font color=\"" + m_textColor + "\">&lt;</font><font color=\"" + m_otherColor + "\">"+IRCOutput::toHTML(((IRCChannelPerson *)output.getParam(1))->person->nick())+"</font><font color=\"" + m_textColor + "\">&gt; " + output.htmlMessage()+"</font><br>");
295 } 289 }
296 break; 290 break;
297 case OUTPUT_QUERYACTION: 291 case OUTPUT_QUERYACTION:
298 case OUTPUT_QUERYPRIVMSG: { 292 case OUTPUT_QUERYPRIVMSG: {
299 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0)); 293 IRCQueryTab *queryTab = getTabForQuery((IRCPerson *)output.getParam(0));
300 if (!queryTab) { 294 if (!queryTab) {
301 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent()); 295 queryTab = new IRCQueryTab((IRCPerson *)output.getParam(0), this, m_mainWindow, (QWidget *)parent());
302 m_queryTabs.append(queryTab); 296 m_queryTabs.append(queryTab);
303 m_mainWindow->addTab(queryTab); 297 m_mainWindow->addTab(queryTab);
304 } 298 }
305 queryTab->display(output); 299 queryTab->display(output);
306 } 300 }
307 break; 301 break;
308 case OUTPUT_SELFPART: { 302 case OUTPUT_SELFPART: {
309 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 303 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
310 if (channelTab) 304 if (channelTab)
311 m_mainWindow->killTab(channelTab); 305 m_mainWindow->killTab(channelTab);
312 } 306 }
313 break; 307 break;
314 case OUTPUT_SELFKICK: { 308 case OUTPUT_SELFKICK: {
315 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 309 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
316 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 310 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
317 if (channelTab) 311 if (channelTab)
318 m_mainWindow->killTab(channelTab); 312 m_mainWindow->killTab(channelTab);
319 } 313 }
320 break; 314 break;
321 case OUTPUT_CHANACTION: { 315 case OUTPUT_CHANACTION: {
322 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 316 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
323 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>"); 317 channelTab->appendText("<font color=\"" + m_otherColor + "\">"+output.htmlMessage()+"</font><br>");
324 } 318 }
325 break; 319 break;
326 case OUTPUT_TOPIC: { 320 case OUTPUT_TOPIC: {
327 IRCChannel *channel = (IRCChannel *) output.getParam(0); 321 IRCChannel *channel = (IRCChannel *) output.getParam(0);
328 if (channel) { 322 if (channel) {
329 IRCChannelTab *channelTab = getTabForChannel(channel); 323 IRCChannelTab *channelTab = getTabForChannel(channel);
330 if (channelTab) { 324 if (channelTab) {
331 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 325 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
332 return; 326 return;
333 } 327 }
334 } 328 }
335 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 329 appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
336 } 330 }
337 break; 331 break;
338 case OUTPUT_QUIT: { 332 case OUTPUT_QUIT: {
339 QString nick = ((IRCPerson *)output.getParam(0))->nick(); 333 QString nick = ((IRCPerson *)output.getParam(0))->nick();
340 QListIterator<IRCChannelTab> it(m_channelTabs); 334 QListIterator<IRCChannelTab> it(m_channelTabs);
341 for (; it.current(); ++it) { 335 for (; it.current(); ++it) {
342 if (it.current()->list()->hasPerson(nick)) { 336 if (it.current()->list()->hasPerson(nick)) {
343 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 337 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
344 it.current()->list()->update(); 338 it.current()->list()->update();
345 } 339 }
346 } 340 }
347 } 341 }
348 break; 342 break;
349 case OUTPUT_OTHERJOIN: 343/* case OUTPUT_NICKCHANGE: {
344 //WAS HERE
345 QString nick = ((IRCPerson *)output.getParam(0))->nick();
346 QListIterator<IRCChannelTab> it(m_channelTabs);
347 for (; it.current(); ++it) {
348 if (it.current()->list()->hasPerson(nick)) {
349 it.current()->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
350 it.current()->list()->update();
351 }
352 }
353 }
354 break;
355 */ case OUTPUT_OTHERJOIN:
350 case OUTPUT_OTHERKICK: 356 case OUTPUT_OTHERKICK:
351 case OUTPUT_CHANPERSONMODE: 357 case OUTPUT_CHANPERSONMODE:
352 case OUTPUT_OTHERPART: { 358 case OUTPUT_OTHERPART: {
353 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0)); 359 IRCChannelTab *channelTab = getTabForChannel((IRCChannel *)output.getParam(0));
354 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>"); 360 channelTab->appendText("<font color=\"" + m_notificationColor + "\">"+output.htmlMessage()+"</font><br>");
355 channelTab->list()->update(); 361 channelTab->list()->update();
356 } 362 }
357 break; 363 break;
358 case OUTPUT_CTCP: 364 case OUTPUT_CTCP:
359 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>"); 365 appendText("<font color=\"" + m_notificationColor + "\">" + output.htmlMessage() + "</font><br>");
360 break; 366 break;
361 case OUTPUT_ERROR: 367 case OUTPUT_ERROR:
362 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>"); 368 appendText("<font color=\"" + m_errorColor + "\">" + output.htmlMessage() + "</font><br>");
363 break; 369 break;
364 default: 370 default:
365 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>"); 371 appendText("<font color=\"" + m_serverColor + "\">" + output.htmlMessage() + "</font><br>");
366 break; 372 break;
367 } 373 }
368} 374}
diff --git a/noncore/net/opieirc/ircsession.cpp b/noncore/net/opieirc/ircsession.cpp
index 1cc1ee2..6404d71 100644
--- a/noncore/net/opieirc/ircsession.cpp
+++ b/noncore/net/opieirc/ircsession.cpp
@@ -1,146 +1,150 @@
1#include "ircsession.h" 1#include "ircsession.h"
2#include "ircmessageparser.h" 2#include "ircmessageparser.h"
3#include "ircversion.h" 3#include "ircversion.h"
4 4
5IRCSession::IRCSession(IRCServer *server) { 5IRCSession::IRCSession(IRCServer *server) {
6 m_server = server; 6 m_server = server;
7 m_connection = new IRCConnection(m_server); 7 m_connection = new IRCConnection(m_server);
8 m_parser = new IRCMessageParser(this); 8 m_parser = new IRCMessageParser(this);
9 connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *))); 9 connect(m_connection, SIGNAL(messageArrived(IRCMessage *)), this, SLOT(handleMessage(IRCMessage *)));
10 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 10 connect(m_parser, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
11 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput))); 11 connect(m_connection, SIGNAL(outputReady(IRCOutput)), this, SIGNAL(outputReady(IRCOutput)));
12} 12}
13 13
14IRCSession::~IRCSession() { 14IRCSession::~IRCSession() {
15 /* We want this to get deleted automatically */ 15 /* We want this to get deleted automatically */
16 m_channels.setAutoDelete(TRUE); 16 m_channels.setAutoDelete(TRUE);
17 m_people.setAutoDelete(TRUE); 17 m_people.setAutoDelete(TRUE);
18 18
19 delete m_parser; 19 delete m_parser;
20 delete m_connection; 20 delete m_connection;
21} 21}
22 22
23void IRCSession::beginSession() { 23void IRCSession::beginSession() {
24 m_connection->doConnect(); 24 m_connection->doConnect();
25} 25}
26 26
27void IRCSession::join(QString channelname) { 27void IRCSession::join(QString channelname) {
28 m_connection->sendLine("JOIN "+channelname); 28 m_connection->sendLine("JOIN "+channelname);
29} 29}
30 30
31void IRCSession::quit(){ 31void IRCSession::quit(){
32 m_connection->sendLine("QUIT :[OI] I'm too good to need a reason"); 32 m_connection->sendLine("QUIT :[OI] I'm too good to need a reason");
33} 33}
34 34
35void IRCSession::quit(QString message){ 35void IRCSession::quit(QString message){
36 m_connection->sendLine("QUIT :" + message); 36 m_connection->sendLine("QUIT :" + message);
37} 37}
38 38
39void IRCSession::topic(IRCChannel *channel, QString message){ 39void IRCSession::topic(IRCChannel *channel, QString message){
40 m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message); 40 m_connection->sendLine("TOPIC :" + channel->channelname() + " " + message);
41} 41}
42 42
43void IRCSession::mode(IRCChannel *channel, QString message){ 43void IRCSession::mode(IRCChannel *channel, QString message){
44 m_connection->sendLine("MODE " + channel->channelname() + " " + message); 44 m_connection->sendLine("MODE " + channel->channelname() + " " + message);
45} 45}
46 46
47void IRCSession::mode(IRCPerson *person, QString message){ 47void IRCSession::mode(IRCPerson *person, QString message){
48 m_connection->sendLine("MODE " + person->nick() + " " + message); 48 m_connection->sendLine("MODE " + person->nick() + " " + message);
49} 49}
50 50
51void IRCSession::mode(QString message){ 51void IRCSession::mode(QString message){
52 m_connection->sendLine("MODE " + message); 52 m_connection->sendLine("MODE " + message);
53} 53}
54 54
55void IRCSession::raw(QString message){ 55void IRCSession::raw(QString message){
56 m_connection->sendLine(message); 56 m_connection->sendLine(message);
57} 57}
58 58
59void IRCSession::kick(IRCChannel *channel, IRCPerson *person) { 59void IRCSession::kick(IRCChannel *channel, IRCPerson *person) {
60 m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason"); 60 m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :0wn3d - no reason");
61} 61}
62 62
63void IRCSession::op(IRCChannel *channel, IRCPerson *person) {
64 m_connection->sendLine("MODE "+ channel->channelname() + " +ooo " + person->nick());
65}
66
63void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) { 67void IRCSession::kick(IRCChannel *channel, IRCPerson *person, QString message) {
64 m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message); 68 m_connection->sendLine("KICK "+ channel->channelname() + " " + person->nick() +" :" + message);
65} 69}
66 70
67void IRCSession::sendMessage(IRCPerson *person, QString message) { 71void IRCSession::sendMessage(IRCPerson *person, QString message) {
68 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message); 72 m_connection->sendLine("PRIVMSG " + person->nick() + " :" + message);
69} 73}
70 74
71void IRCSession::sendMessage(IRCChannel *channel, QString message) { 75void IRCSession::sendMessage(IRCChannel *channel, QString message) {
72 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message); 76 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :" + message);
73} 77}
74 78
75void IRCSession::sendAction(IRCChannel *channel, QString message) { 79void IRCSession::sendAction(IRCChannel *channel, QString message) {
76 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001"); 80 m_connection->sendLine("PRIVMSG " + channel->channelname() + " :\001ACTION " + message + "\001");
77} 81}
78 82
79void IRCSession::sendAction(IRCPerson *person, QString message) { 83void IRCSession::sendAction(IRCPerson *person, QString message) {
80 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001"); 84 m_connection->sendLine("PRIVMSG " + person->nick() + " :\001ACTION " + message + "\001");
81} 85}
82 86
83bool IRCSession::isSessionActive() { 87bool IRCSession::isSessionActive() {
84 return m_connection->isConnected(); 88 return m_connection->isConnected();
85} 89}
86 90
87void IRCSession::endSession() { 91void IRCSession::endSession() {
88 if (m_connection->isLoggedIn()) 92 if (m_connection->isLoggedIn())
89 m_connection->sendLine("QUIT :" APP_VERSION); 93 m_connection->sendLine("QUIT :" APP_VERSION);
90 else 94 else
91 m_connection->close(); 95 m_connection->close();
92} 96}
93 97
94void IRCSession::part(IRCChannel *channel) { 98void IRCSession::part(IRCChannel *channel) {
95 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION); 99 m_connection->sendLine("PART " + channel->channelname() + " :" + APP_VERSION);
96} 100}
97 101
98 102
99IRCChannel *IRCSession::getChannel(QString channelname) { 103IRCChannel *IRCSession::getChannel(QString channelname) {
100 QListIterator<IRCChannel> it(m_channels); 104 QListIterator<IRCChannel> it(m_channels);
101 for (; it.current(); ++it) { 105 for (; it.current(); ++it) {
102 if (it.current()->channelname() == channelname) { 106 if (it.current()->channelname() == channelname) {
103 return it.current(); 107 return it.current();
104 } 108 }
105 } 109 }
106 return 0; 110 return 0;
107} 111}
108 112
109IRCPerson *IRCSession::getPerson(QString nickname) { 113IRCPerson *IRCSession::getPerson(QString nickname) {
110 QListIterator<IRCPerson> it(m_people); 114 QListIterator<IRCPerson> it(m_people);
111 for (; it.current(); ++it) { 115 for (; it.current(); ++it) {
112 if (it.current()->nick() == nickname) { 116 if (it.current()->nick() == nickname) {
113 return it.current(); 117 return it.current();
114 } 118 }
115 } 119 }
116 return 0; 120 return 0;
117} 121}
118 122
119void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) { 123void IRCSession::getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels) {
120 QListIterator<IRCChannel> it(m_channels); 124 QListIterator<IRCChannel> it(m_channels);
121 for (; it.current(); ++it) { 125 for (; it.current(); ++it) {
122 if (it.current()->getPerson(person->nick()) != 0) { 126 if (it.current()->getPerson(person->nick()) != 0) {
123 channels.append(it.current()); 127 channels.append(it.current());
124 } 128 }
125 } 129 }
126} 130}
127 131
128void IRCSession::addPerson(IRCPerson *person) { 132void IRCSession::addPerson(IRCPerson *person) {
129 m_people.append(person); 133 m_people.append(person);
130} 134}
131 135
132void IRCSession::addChannel(IRCChannel *channel) { 136void IRCSession::addChannel(IRCChannel *channel) {
133 m_channels.append(channel); 137 m_channels.append(channel);
134} 138}
135 139
136void IRCSession::removeChannel(IRCChannel *channel) { 140void IRCSession::removeChannel(IRCChannel *channel) {
137 m_channels.remove(channel); 141 m_channels.remove(channel);
138} 142}
139 143
140void IRCSession::removePerson(IRCPerson *person) { 144void IRCSession::removePerson(IRCPerson *person) {
141 m_people.remove(person); 145 m_people.remove(person);
142} 146}
143 147
144void IRCSession::handleMessage(IRCMessage *message) { 148void IRCSession::handleMessage(IRCMessage *message) {
145 m_parser->parse(message); 149 m_parser->parse(message);
146} 150}
diff --git a/noncore/net/opieirc/ircsession.h b/noncore/net/opieirc/ircsession.h
index a6a3e50..f6330d8 100644
--- a/noncore/net/opieirc/ircsession.h
+++ b/noncore/net/opieirc/ircsession.h
@@ -1,83 +1,84 @@
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 __IRCSESSION_H 21#ifndef __IRCSESSION_H
22#define __IRCSESSION_H 22#define __IRCSESSION_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qlist.h> 25#include <qlist.h>
26#include "ircserver.h" 26#include "ircserver.h"
27#include "ircconnection.h" 27#include "ircconnection.h"
28#include "ircmessage.h" 28#include "ircmessage.h"
29#include "ircchannel.h" 29#include "ircchannel.h"
30#include "ircoutput.h" 30#include "ircoutput.h"
31 31
32class IRCMessageParser; 32class IRCMessageParser;
33 33
34/* The IRCSession stores all information relating to the connection 34/* The IRCSession stores all information relating to the connection
35 to one IRC server. IRCSession makes it possible to run multiple 35 to one IRC server. IRCSession makes it possible to run multiple
36 IRC server connections from within the same program */ 36 IRC server connections from within the same program */
37 37
38class IRCSession : public QObject { 38class IRCSession : public QObject {
39friend class IRCMessageParser; 39friend class IRCMessageParser;
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 IRCSession(IRCServer *server); 42 IRCSession(IRCServer *server);
43 ~IRCSession(); 43 ~IRCSession();
44 44
45 void join(QString channel); 45 void join(QString channel);
46 void quit(QString message); 46 void quit(QString message);
47 void quit(); 47 void quit();
48 void raw(QString message); 48 void raw(QString message);
49 void topic(IRCChannel *channel, QString message); 49 void topic(IRCChannel *channel, QString message);
50 void mode(IRCChannel *channel, QString message); 50 void mode(IRCChannel *channel, QString message);
51 void mode(IRCPerson *person, QString message); 51 void mode(IRCPerson *person, QString message);
52 void mode(QString message); 52 void mode(QString message);
53 void part(IRCChannel *channel); 53 void part(IRCChannel *channel);
54 void op(IRCChannel *channel, IRCPerson *person);
54 void kick(IRCChannel *channel, IRCPerson *person); 55 void kick(IRCChannel *channel, IRCPerson *person);
55 void kick(IRCChannel *channel, IRCPerson *person, QString message); 56 void kick(IRCChannel *channel, IRCPerson *person, QString message);
56 void beginSession(); 57 void beginSession();
57 bool isSessionActive(); 58 bool isSessionActive();
58 void endSession(); 59 void endSession();
59 void sendMessage(IRCPerson *person, QString message); 60 void sendMessage(IRCPerson *person, QString message);
60 void sendMessage(IRCChannel *channel, QString message); 61 void sendMessage(IRCChannel *channel, QString message);
61 void sendAction(IRCPerson *person, QString message); 62 void sendAction(IRCPerson *person, QString message);
62 void sendAction(IRCChannel *channel, QString message); 63 void sendAction(IRCChannel *channel, QString message);
63 IRCChannel *getChannel(QString channelname); 64 IRCChannel *getChannel(QString channelname);
64 IRCPerson *getPerson(QString nickname); 65 IRCPerson *getPerson(QString nickname);
65protected: 66protected:
66 void addPerson(IRCPerson *person); 67 void addPerson(IRCPerson *person);
67 void addChannel(IRCChannel *channel); 68 void addChannel(IRCChannel *channel);
68 void removeChannel(IRCChannel *channel); 69 void removeChannel(IRCChannel *channel);
69 void removePerson(IRCPerson *person); 70 void removePerson(IRCPerson *person);
70 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels); 71 void getChannelsByPerson(IRCPerson *person, QList<IRCChannel> &channels);
71protected slots: 72protected slots:
72 void handleMessage(IRCMessage *message); 73 void handleMessage(IRCMessage *message);
73signals: 74signals:
74 void outputReady(IRCOutput output); 75 void outputReady(IRCOutput output);
75protected: 76protected:
76 IRCServer *m_server; 77 IRCServer *m_server;
77 IRCConnection *m_connection; 78 IRCConnection *m_connection;
78 IRCMessageParser *m_parser; 79 IRCMessageParser *m_parser;
79 QList<IRCChannel> m_channels; 80 QList<IRCChannel> m_channels;
80 QList<IRCPerson> m_people; 81 QList<IRCPerson> m_people;
81}; 82};
82 83
83#endif /* __IRCSESSION_H */ 84#endif /* __IRCSESSION_H */
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc
index 54f096e..7d60d6c 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.cc
+++ b/noncore/net/opietooth/blue-pin/pindlg.cc
@@ -1,53 +1,54 @@
1 1
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include <qcheckbox.h> 4#include <qcheckbox.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qlineedit.h> 6#include <qlineedit.h>
7#include <qtimer.h> 7#include <qtimer.h>
8 8
9#include <qpe/config.h> 9#include <qpe/config.h>
10 10
11#include "pindlg.h" 11#include "pindlg.h"
12 12
13using namespace OpieTooth; 13using namespace OpieTooth;
14 14
15PinDlg::PinDlg( const QString& status, 15PinDlg::PinDlg( const QString& status,
16 const QString& mac, QWidget* parent, 16 const QString& mac, QWidget* parent,
17 const char* name ) 17 const char* name )
18 : PinDlgBase( parent, name, WType_Modal ) 18 : PinDlgBase( parent, name, WType_Modal )
19{ 19{
20 m_mac = mac; 20 m_mac = mac;
21 test( mac ); 21 test( mac );
22 txtStatus->setText(status); 22 txtStatus->setText(status);
23 showMaximized();
23} 24}
24PinDlg::~PinDlg() { 25PinDlg::~PinDlg() {
25 26
26} 27}
27void PinDlg::setMac( const QString& mac ) { 28void PinDlg::setMac( const QString& mac ) {
28 txtStatus->setText( mac ); 29 txtStatus->setText( mac );
29} 30}
30QString PinDlg::pin() const{ 31QString PinDlg::pin() const{
31 return lnePin->text(); 32 return lnePin->text();
32} 33}
33 34
34void PinDlg::test( const QString& mac ) { 35void PinDlg::test( const QString& mac ) {
35 if (!mac.isEmpty() ) { 36 if (!mac.isEmpty() ) {
36 Config cfg("bluepin"); 37 Config cfg("bluepin");
37 cfg.setGroup(mac); 38 cfg.setGroup(mac);
38 lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); 39 lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) );
39 if ( !lnePin->text().isEmpty() ) { 40 if ( !lnePin->text().isEmpty() ) {
40 //QTimer::singleShot(100, this, SLOT(accept() ) ); 41 //QTimer::singleShot(100, this, SLOT(accept() ) );
41 } 42 }
42 43
43 } 44 }
44 45
45} 46}
46void PinDlg::accept() { 47void PinDlg::accept() {
47 if ( ckbPin->isChecked() ) { 48 if ( ckbPin->isChecked() ) {
48 Config cfg("bluepin"); 49 Config cfg("bluepin");
49 cfg.setGroup(m_mac ); 50 cfg.setGroup(m_mac );
50 cfg.writeEntryCrypt("pin", lnePin->text() ); 51 cfg.writeEntryCrypt("pin", lnePin->text() );
51 } 52 }
52 QDialog::accept(); 53 QDialog::accept();
53} 54}
diff --git a/noncore/net/opietooth/blue-pin/pindlg.h b/noncore/net/opietooth/blue-pin/pindlg.h
index b4f5ff8..5e5a763 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.h
+++ b/noncore/net/opietooth/blue-pin/pindlg.h
@@ -1,26 +1,29 @@
1 1
2 2
3#include <qdialog.h> 3#include <qdialog.h>
4
5#include "pindlgbase.h" 4#include "pindlgbase.h"
6 5
7namespace OpieTooth { 6namespace OpieTooth {
7
8 class PinDlg : public PinDlgBase { 8 class PinDlg : public PinDlgBase {
9 Q_OBJECT 9
10 Q_OBJECT
11
10 public: 12 public:
11 PinDlg(const QString& text, 13 PinDlg(const QString& text,
12 const QString& mac, 14 const QString& mac,
13 QWidget* parent = 0, 15 QWidget* parent = 0,
14 const char* name= 0 ); 16 const char* name= 0 );
15 ~PinDlg(); 17 ~PinDlg();
16 void setMac( const QString& ); 18 void setMac( const QString& );
17 QString pin() const; 19 QString pin() const;
20
18 private: 21 private:
19 void test( const QString& mac ); 22 void test( const QString& mac );
20 QString m_mac; 23 QString m_mac;
21protected slots:
22 void accept();
23 };
24 24
25 protected slots:
26 void accept();
25 27
28 };
26}; 29};
diff --git a/noncore/net/opietooth/blue-pin/pindlgbase.ui b/noncore/net/opietooth/blue-pin/pindlgbase.ui
index 6966a03..889a25e 100644
--- a/noncore/net/opietooth/blue-pin/pindlgbase.ui
+++ b/noncore/net/opietooth/blue-pin/pindlgbase.ui
@@ -1,198 +1,274 @@
1<!DOCTYPE UI><UI> 1<!DOCTYPE UI><UI>
2<class>PinDlgBase</class> 2<class>PinDlgBase</class>
3<author>zecke</author> 3<author>zecke</author>
4<widget> 4<widget>
5 <class>QDialog</class> 5 <class>QDialog</class>
6 <property stdset="1"> 6 <property stdset="1">
7 <name>name</name> 7 <name>name</name>
8 <cstring>Form1</cstring> 8 <cstring>Form1</cstring>
9 </property> 9 </property>
10 <property stdset="1"> 10 <property stdset="1">
11 <name>geometry</name> 11 <name>geometry</name>
12 <rect> 12 <rect>
13 <x>0</x> 13 <x>0</x>
14 <y>0</y> 14 <y>0</y>
15 <width>248</width> 15 <width>258</width>
16 <height>167</height> 16 <height>245</height>
17 </rect> 17 </rect>
18 </property> 18 </property>
19 <property stdset="1"> 19 <property stdset="1">
20 <name>caption</name> 20 <name>caption</name>
21 <string>Please enter pin</string> 21 <string>Please enter pin</string>
22 </property> 22 </property>
23 <grid> 23 <vbox>
24 <property stdset="1"> 24 <property stdset="1">
25 <name>margin</name> 25 <name>margin</name>
26 <number>11</number> 26 <number>11</number>
27 </property> 27 </property>
28 <property stdset="1"> 28 <property stdset="1">
29 <name>spacing</name> 29 <name>spacing</name>
30 <number>6</number> 30 <number>6</number>
31 </property> 31 </property>
32 <widget row="0" column="0" > 32 <widget>
33 <class>QLabel</class>
34 <property stdset="1">
35 <name>name</name>
36 <cstring>txtStatus</cstring>
37 </property>
38 <property stdset="1">
39 <name>text</name>
40 <string></string>
41 </property>
42 <property stdset="1">
43 <name>textFormat</name>
44 <enum>RichText</enum>
45 </property>
46 </widget>
47 <spacer>
48 <property>
49 <name>name</name>
50 <cstring>Spacer4_2</cstring>
51 </property>
52 <property stdset="1">
53 <name>orientation</name>
54 <enum>Vertical</enum>
55 </property>
56 <property stdset="1">
57 <name>sizeType</name>
58 <enum>Expanding</enum>
59 </property>
60 <property>
61 <name>sizeHint</name>
62 <size>
63 <width>20</width>
64 <height>20</height>
65 </size>
66 </property>
67 </spacer>
68 <widget>
33 <class>QLayoutWidget</class> 69 <class>QLayoutWidget</class>
34 <property stdset="1"> 70 <property stdset="1">
35 <name>name</name> 71 <name>name</name>
36 <cstring>Layout6</cstring> 72 <cstring>Layout6</cstring>
37 </property> 73 </property>
38 <grid> 74 <vbox>
39 <property stdset="1"> 75 <property stdset="1">
40 <name>margin</name> 76 <name>margin</name>
41 <number>0</number> 77 <number>0</number>
42 </property> 78 </property>
43 <property stdset="1"> 79 <property stdset="1">
44 <name>spacing</name> 80 <name>spacing</name>
45 <number>6</number> 81 <number>6</number>
46 </property> 82 </property>
47 <widget row="3" column="0" rowspan="1" colspan="3" > 83 <widget>
48 <class>QLineEdit</class> 84 <class>QLabel</class>
49 <property stdset="1"> 85 <property stdset="1">
50 <name>name</name> 86 <name>name</name>
51 <cstring>lnePin</cstring> 87 <cstring>TextLabel3</cstring>
52 </property> 88 </property>
53 <property stdset="1"> 89 <property stdset="1">
54 <name>echoMode</name> 90 <name>text</name>
55 <enum>Password</enum> 91 <string>Please enter PIN:</string>
56 </property> 92 </property>
57 </widget> 93 </widget>
58 <spacer row="5" column="4" > 94 <widget>
59 <property> 95 <class>QLayoutWidget</class>
96 <property stdset="1">
60 <name>name</name> 97 <name>name</name>
61 <cstring>Spacer2</cstring> 98 <cstring>Layout5</cstring>
62 </property> 99 </property>
100 <hbox>
101 <property stdset="1">
102 <name>margin</name>
103 <number>0</number>
104 </property>
105 <property stdset="1">
106 <name>spacing</name>
107 <number>6</number>
108 </property>
109 <widget>
110 <class>QLineEdit</class>
111 <property stdset="1">
112 <name>name</name>
113 <cstring>lnePin</cstring>
114 </property>
115 <property stdset="1">
116 <name>echoMode</name>
117 <enum>Password</enum>
118 </property>
119 </widget>
120 <spacer>
121 <property>
122 <name>name</name>
123 <cstring>Spacer4</cstring>
124 </property>
125 <property stdset="1">
126 <name>orientation</name>
127 <enum>Horizontal</enum>
128 </property>
129 <property stdset="1">
130 <name>sizeType</name>
131 <enum>Fixed</enum>
132 </property>
133 <property>
134 <name>sizeHint</name>
135 <size>
136 <width>21</width>
137 <height>20</height>
138 </size>
139 </property>
140 </spacer>
141 </hbox>
142 </widget>
143 <widget>
144 <class>QCheckBox</class>
63 <property stdset="1"> 145 <property stdset="1">
64 <name>orientation</name> 146 <name>name</name>
65 <enum>Horizontal</enum> 147 <cstring>ckbPin</cstring>
66 </property> 148 </property>
67 <property stdset="1"> 149 <property stdset="1">
68 <name>sizeType</name> 150 <name>text</name>
69 <enum>Fixed</enum> 151 <string>Save pin</string>
70 </property>
71 <property>
72 <name>sizeHint</name>
73 <size>
74 <width>16</width>
75 <height>20</height>
76 </size>
77 </property> 152 </property>
78 </spacer> 153 </widget>
79 <spacer row="5" column="0" > 154 </vbox>
155 </widget>
156 <spacer>
157 <property>
158 <name>name</name>
159 <cstring>Spacer5</cstring>
160 </property>
161 <property stdset="1">
162 <name>orientation</name>
163 <enum>Vertical</enum>
164 </property>
165 <property stdset="1">
166 <name>sizeType</name>
167 <enum>Expanding</enum>
168 </property>
169 <property>
170 <name>sizeHint</name>
171 <size>
172 <width>20</width>
173 <height>20</height>
174 </size>
175 </property>
176 </spacer>
177 <widget>
178 <class>QLayoutWidget</class>
179 <property stdset="1">
180 <name>name</name>
181 <cstring>Layout7</cstring>
182 </property>
183 <hbox>
184 <property stdset="1">
185 <name>margin</name>
186 <number>0</number>
187 </property>
188 <property stdset="1">
189 <name>spacing</name>
190 <number>6</number>
191 </property>
192 <spacer>
80 <property> 193 <property>
81 <name>name</name> 194 <name>name</name>
82 <cstring>Spacer1</cstring> 195 <cstring>Spacer1</cstring>
83 </property> 196 </property>
84 <property stdset="1"> 197 <property stdset="1">
85 <name>orientation</name> 198 <name>orientation</name>
86 <enum>Horizontal</enum> 199 <enum>Horizontal</enum>
87 </property> 200 </property>
88 <property stdset="1"> 201 <property stdset="1">
89 <name>sizeType</name> 202 <name>sizeType</name>
90 <enum>Fixed</enum> 203 <enum>Fixed</enum>
91 </property> 204 </property>
92 <property> 205 <property>
93 <name>sizeHint</name> 206 <name>sizeHint</name>
94 <size> 207 <size>
95 <width>30</width> 208 <width>30</width>
96 <height>20</height> 209 <height>20</height>
97 </size> 210 </size>
98 </property> 211 </property>
99 </spacer> 212 </spacer>
100 <spacer row="3" column="3" > 213 <widget>
101 <property>
102 <name>name</name>
103 <cstring>Spacer4</cstring>
104 </property>
105 <property stdset="1">
106 <name>orientation</name>
107 <enum>Horizontal</enum>
108 </property>
109 <property stdset="1">
110 <name>sizeType</name>
111 <enum>Fixed</enum>
112 </property>
113 <property>
114 <name>sizeHint</name>
115 <size>
116 <width>21</width>
117 <height>20</height>
118 </size>
119 </property>
120 </spacer>
121 <widget row="0" column="0" rowspan="1" colspan="5" >
122 <class>QLabel</class>
123 <property stdset="1">
124 <name>name</name>
125 <cstring>txtStatus</cstring>
126 </property>
127 <property stdset="1">
128 <name>text</name>
129 <string></string>
130 </property>
131 <property stdset="1">
132 <name>textFormat</name>
133 <enum>RichText</enum>
134 </property>
135 </widget>
136 <widget row="2" column="0" rowspan="1" colspan="5" >
137 <class>QLabel</class>
138 <property stdset="1">
139 <name>name</name>
140 <cstring>TextLabel3</cstring>
141 </property>
142 <property stdset="1">
143 <name>text</name>
144 <string>Please enter PIN:</string>
145 </property>
146 </widget>
147 <widget row="5" column="1" >
148 <class>QPushButton</class> 214 <class>QPushButton</class>
149 <property stdset="1"> 215 <property stdset="1">
150 <name>name</name> 216 <name>name</name>
151 <cstring>PushButton1</cstring> 217 <cstring>PushButton1</cstring>
152 </property> 218 </property>
153 <property stdset="1"> 219 <property stdset="1">
154 <name>text</name> 220 <name>text</name>
155 <string>&amp;Ok</string> 221 <string>&amp;Ok</string>
156 </property> 222 </property>
157 </widget> 223 </widget>
158 <widget row="5" column="2" rowspan="1" colspan="2" > 224 <widget>
159 <class>QPushButton</class> 225 <class>QPushButton</class>
160 <property stdset="1"> 226 <property stdset="1">
161 <name>name</name> 227 <name>name</name>
162 <cstring>PushButton2</cstring> 228 <cstring>PushButton2</cstring>
163 </property> 229 </property>
164 <property stdset="1"> 230 <property stdset="1">
165 <name>text</name> 231 <name>text</name>
166 <string>&amp;Cancel</string> 232 <string>&amp;Cancel</string>
167 </property> 233 </property>
168 </widget> 234 </widget>
169 <widget row="4" column="0" rowspan="1" colspan="5" > 235 <spacer>
170 <class>QCheckBox</class> 236 <property>
171 <property stdset="1">
172 <name>name</name> 237 <name>name</name>
173 <cstring>ckbPin</cstring> 238 <cstring>Spacer2</cstring>
174 </property> 239 </property>
175 <property stdset="1"> 240 <property stdset="1">
176 <name>text</name> 241 <name>orientation</name>
177 <string>Save pin</string> 242 <enum>Horizontal</enum>
178 </property> 243 </property>
179 </widget> 244 <property stdset="1">
180 </grid> 245 <name>sizeType</name>
246 <enum>Fixed</enum>
247 </property>
248 <property>
249 <name>sizeHint</name>
250 <size>
251 <width>16</width>
252 <height>20</height>
253 </size>
254 </property>
255 </spacer>
256 </hbox>
181 </widget> 257 </widget>
182 </grid> 258 </vbox>
183</widget> 259</widget>
184<connections> 260<connections>
185 <connection> 261 <connection>
186 <sender>PushButton1</sender> 262 <sender>PushButton1</sender>
187 <signal>clicked()</signal> 263 <signal>clicked()</signal>
188 <receiver>Form1</receiver> 264 <receiver>Form1</receiver>
189 <slot>accept()</slot> 265 <slot>accept()</slot>
190 </connection> 266 </connection>
191 <connection> 267 <connection>
192 <sender>PushButton2</sender> 268 <sender>PushButton2</sender>
193 <signal>clicked()</signal> 269 <signal>clicked()</signal>
194 <receiver>Form1</receiver> 270 <receiver>Form1</receiver>
195 <slot>reject()</slot> 271 <slot>reject()</slot>
196 </connection> 272 </connection>
197</connections> 273</connections>
198</UI> 274</UI>
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 935c11a..54808fa 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,610 +1,610 @@
1/* 1/*
2 * bluebase.cpp * 2 * bluebase.cpp *
3 * --------------------- 3 * ---------------------
4 * 4 *
5 * copyright : (c) 2002 by Maximilian Reiß 5 * copyright : (c) 2002 by Maximilian Reiß
6 * email : max.reiss@gmx.de 6 * email : max.reiss@gmx.de
7 * 7 *
8 */ 8 */
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "bluebase.h" 18#include "bluebase.h"
19#include "scandialog.h" 19#include "scandialog.h"
20#include "hciconfwrapper.h" 20#include "hciconfwrapper.h"
21#include "devicehandler.h" 21#include "devicehandler.h"
22#include "btconnectionitem.h" 22#include "btconnectionitem.h"
23 23
24#include <remotedevice.h> 24#include <remotedevice.h>
25#include <services.h> 25#include <services.h>
26 26
27#include <stdlib.h> 27#include <stdlib.h>
28 28
29#include <qframe.h> 29#include <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qvariant.h> 33#include <qvariant.h>
34#include <qimage.h> 34#include <qimage.h>
35#include <qpixmap.h> 35#include <qpixmap.h>
36#include <qtabwidget.h> 36#include <qtabwidget.h>
37#include <qscrollview.h> 37#include <qscrollview.h>
38#include <qvbox.h> 38#include <qvbox.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qlineedit.h> 41#include <qlineedit.h>
42#include <qlistview.h> 42#include <qlistview.h>
43#include <qdir.h> 43#include <qdir.h>
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qtimer.h> 45#include <qtimer.h>
46#include <qlist.h> 46#include <qlist.h>
47 47
48#include <qpe/qpeapplication.h> 48#include <qpe/qpeapplication.h>
49#include <qpe/resource.h> 49#include <qpe/resource.h>
50#include <qpe/config.h> 50#include <qpe/config.h>
51 51
52 52
53using namespace OpieTooth; 53using namespace OpieTooth;
54 54
55BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) 55BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
56 : BluetoothBase( parent, name, fl ) { 56 : BluetoothBase( parent, name, fl ) {
57 57
58 m_localDevice = new Manager( "hci0" ); 58 m_localDevice = new Manager( "hci0" );
59 59
60 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); 60 connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) );
61 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); 61 connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) );
62 // not good since lib is async 62 // not good since lib is async
63 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), 63 // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ),
64 // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); 64 // this, SLOT( addServicesToDevice( QListViewItem * ) ) );
65 connect( ListView2, SIGNAL( clicked( QListViewItem* )), 65 connect( ListView2, SIGNAL( clicked( QListViewItem* )),
66 this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); 66 this, SLOT( startServiceActionClicked( QListViewItem* ) ) );
67 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), 67 connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ),
68 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); 68 this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
69 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), 69 connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
70 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); 70 this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
71 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), 71 connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
72 this, SLOT( deviceActive( const QString& , bool ) ) ); 72 this, SLOT( deviceActive( const QString& , bool ) ) );
73 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), 73 connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ),
74 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); 74 this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) );
75 connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), 75 connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ),
76 this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); 76 this, SLOT( addSignalStrength( const QString&, const QString& ) ) );
77 77
78 78
79 // let hold be rightButtonClicked() 79 // let hold be rightButtonClicked()
80 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); 80 QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold);
81 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); 81 QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold);
82 82
83 //Load all icons needed 83 //Load all icons needed
84 m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); 84 m_offPix = Resource::loadPixmap( "opietooth/notconnected" );
85 m_onPix = Resource::loadPixmap( "opietooth/connected" ); 85 m_onPix = Resource::loadPixmap( "opietooth/connected" );
86 m_findPix = Resource::loadPixmap( "opietooth/find" ); 86 m_findPix = Resource::loadPixmap( "opietooth/find" );
87 87
88 QPalette pal = this->palette(); 88 QPalette pal = this->palette();
89 QColor col = pal.color( QPalette::Active, QColorGroup::Background ); 89 QColor col = pal.color( QPalette::Active, QColorGroup::Background );
90 pal.setColor( QPalette::Active, QColorGroup::Button, col ); 90 pal.setColor( QPalette::Active, QColorGroup::Button, col );
91 pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); 91 pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
92 pal.setColor( QPalette::Normal, QColorGroup::Button, col ); 92 pal.setColor( QPalette::Normal, QColorGroup::Button, col );
93 pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); 93 pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
94 this->setPalette( pal ); 94 this->setPalette( pal );
95 95
96 setCaption( tr( "Bluetooth Manager" ) ); 96 setCaption( tr( "Bluetooth Manager" ) );
97 97
98 readConfig(); 98 readConfig();
99 initGui(); 99 initGui();
100 100
101 ListView2->setRootIsDecorated(true); 101 ListView2->setRootIsDecorated(true);
102 102
103 103
104 writeToHciConfig(); 104 writeToHciConfig();
105 // search conncetions 105 // search conncetions
106 addConnectedDevices(); 106 addConnectedDevices();
107 addSignalStrength(); 107 addSignalStrength();
108 m_iconLoader = new BTIconLoader(); 108 m_iconLoader = new BTIconLoader();
109 readSavedDevices(); 109 readSavedDevices();
110} 110}
111 111
112/** 112/**
113 * Reads all options from the config file 113 * Reads all options from the config file
114 */ 114 */
115void BlueBase::readConfig() { 115void BlueBase::readConfig() {
116 116
117 Config cfg( "bluetoothmanager" ); 117 Config cfg( "bluetoothmanager" );
118 cfg.setGroup( "bluezsettings" ); 118 cfg.setGroup( "bluezsettings" );
119 119
120 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with 120 m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
121 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak 121 m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
122 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); 122 m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
123 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); 123 m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
124 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); 124 m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
125 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); 125 m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
126} 126}
127 127
128/** 128/**
129 * Writes all options to the config file 129 * Writes all options to the config file
130 */ 130 */
131void BlueBase::writeConfig() { 131void BlueBase::writeConfig() {
132 132
133 Config cfg( "bluetoothmanager" ); 133 Config cfg( "bluetoothmanager" );
134 cfg.setGroup( "bluezsettings" ); 134 cfg.setGroup( "bluezsettings" );
135 135
136 cfg.writeEntry( "name" , m_deviceName ); 136 cfg.writeEntry( "name" , m_deviceName );
137 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); 137 cfg.writeEntryCrypt( "passkey" , m_defaultPasskey );
138 cfg.writeEntry( "useEncryption" , m_useEncryption ); 138 cfg.writeEntry( "useEncryption" , m_useEncryption );
139 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); 139 cfg.writeEntry( "enableAuthentification" , m_enableAuthentification );
140 cfg.writeEntry( "enablePagescan" , m_enablePagescan ); 140 cfg.writeEntry( "enablePagescan" , m_enablePagescan );
141 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); 141 cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan );
142 142
143 writeToHciConfig(); 143 writeToHciConfig();
144} 144}
145 145
146/** 146/**
147 * Modify the hcid.conf file to our needs 147 * Modify the hcid.conf file to our needs
148 */ 148 */
149void BlueBase::writeToHciConfig() { 149void BlueBase::writeToHciConfig() {
150 qWarning("writeToHciConfig"); 150 qWarning("writeToHciConfig");
151 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); 151 HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" );
152 hciconf.load(); 152 hciconf.load();
153 hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); 153 hciconf.setPinHelper( "/opt/QtPalmtop/bin/bluepin" );
154 hciconf.setName( m_deviceName ); 154 hciconf.setName( m_deviceName );
155 hciconf.setEncrypt( m_useEncryption ); 155 hciconf.setEncrypt( m_useEncryption );
156 hciconf.setAuth( m_enableAuthentification ); 156 hciconf.setAuth( m_enableAuthentification );
157 hciconf.setPscan( m_enablePagescan ); 157 hciconf.setPscan( m_enablePagescan );
158 hciconf.setIscan( m_enableInquiryscan ); 158 hciconf.setIscan( m_enableInquiryscan );
159 hciconf.save(); 159 hciconf.save();
160} 160}
161 161
162 162
163/** 163/**
164 * Read the list of allready known devices 164 * Read the list of allready known devices
165 */ 165 */
166void BlueBase::readSavedDevices() { 166void BlueBase::readSavedDevices() {
167 167
168 QValueList<RemoteDevice> loadedDevices; 168 QValueList<RemoteDevice> loadedDevices;
169 DeviceHandler handler; 169 DeviceHandler handler;
170 loadedDevices = handler.load(); 170 loadedDevices = handler.load();
171 171
172 addSearchedDevices( loadedDevices ); 172 addSearchedDevices( loadedDevices );
173} 173}
174 174
175 175
176/** 176/**
177 * Write the list of allready known devices 177 * Write the list of allready known devices
178 */ 178 */
179void BlueBase::writeSavedDevices() { 179void BlueBase::writeSavedDevices() {
180 QListViewItemIterator it( ListView2 ); 180 QListViewItemIterator it( ListView2 );
181 BTListItem* item; 181 BTListItem* item;
182 BTDeviceItem* device; 182 BTDeviceItem* device;
183 RemoteDevice::ValueList list; 183 RemoteDevice::ValueList list;
184 for ( ; it.current(); ++it ) { 184 for ( ; it.current(); ++it ) {
185 item = (BTListItem*)it.current(); 185 item = (BTListItem*)it.current();
186 if(item->typeId() != BTListItem::Device ) 186 if(item->typeId() != BTListItem::Device )
187 continue; 187 continue;
188 device = (BTDeviceItem*)item; 188 device = (BTDeviceItem*)item;
189 189
190 list.append( device->remoteDevice() ); 190 list.append( device->remoteDevice() );
191 } 191 }
192 /* 192 /*
193 * if not empty save the List through DeviceHandler 193 * if not empty save the List through DeviceHandler
194 */ 194 */
195 if ( list.isEmpty() ) 195 if ( list.isEmpty() )
196 return; 196 return;
197 DeviceHandler handler; 197 DeviceHandler handler;
198 handler.save( list ); 198 handler.save( list );
199} 199}
200 200
201 201
202/** 202/**
203 * Set up the gui 203 * Set up the gui
204 */ 204 */
205void BlueBase::initGui() { 205void BlueBase::initGui() {
206 StatusLabel->setText( status() ); // maybe move it to getStatus() 206 StatusLabel->setText( status() ); // maybe move it to getStatus()
207 cryptCheckBox->setChecked( m_useEncryption ); 207 cryptCheckBox->setChecked( m_useEncryption );
208 authCheckBox->setChecked( m_enableAuthentification ); 208 authCheckBox->setChecked( m_enableAuthentification );
209 pagescanCheckBox->setChecked( m_enablePagescan ); 209 pagescanCheckBox->setChecked( m_enablePagescan );
210 inquiryscanCheckBox->setChecked( m_enableInquiryscan ); 210 inquiryscanCheckBox->setChecked( m_enableInquiryscan );
211 deviceNameLine->setText( m_deviceName ); 211 deviceNameLine->setText( m_deviceName );
212 passkeyLine->setText( m_defaultPasskey ); 212 passkeyLine->setText( m_defaultPasskey );
213 // set info tab 213 // set info tab
214 setInfo(); 214 setInfo();
215} 215}
216 216
217 217
218/** 218/**
219 * Get the status informations and returns it 219 * Get the status informations and returns it
220 * @return QString the status informations gathered 220 * @return QString the status informations gathered
221 */ 221 */
222QString BlueBase::status()const{ 222QString BlueBase::status()const{
223 QString infoString = tr( "<b>Device name : </b> Ipaq" ); 223 QString infoString = tr( "<b>Device name : </b> Ipaq" );
224 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); 224 infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" );
225 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); 225 infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" );
226 226
227 return (infoString); 227 return (infoString);
228} 228}
229 229
230 230
231/** 231/**
232 * Read the current values from the gui and invoke writeConfig() 232 * Read the current values from the gui and invoke writeConfig()
233 */ 233 */
234void BlueBase::applyConfigChanges() { 234void BlueBase::applyConfigChanges() {
235 m_deviceName = deviceNameLine->text(); 235 m_deviceName = deviceNameLine->text();
236 m_defaultPasskey = passkeyLine->text(); 236 m_defaultPasskey = passkeyLine->text();
237 m_useEncryption = cryptCheckBox->isChecked(); 237 m_useEncryption = cryptCheckBox->isChecked();
238 m_enableAuthentification = authCheckBox->isChecked(); 238 m_enableAuthentification = authCheckBox->isChecked();
239 m_enablePagescan = pagescanCheckBox->isChecked(); 239 m_enablePagescan = pagescanCheckBox->isChecked();
240 m_enableInquiryscan = inquiryscanCheckBox->isChecked(); 240 m_enableInquiryscan = inquiryscanCheckBox->isChecked();
241 241
242 writeConfig(); 242 writeConfig();
243 243
244 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); 244 QMessageBox::information( this, tr("Test") , tr("Changes were applied.") );
245} 245}
246 246
247/** 247/**
248 * Add fresh found devices from scan dialog to the listing 248 * Add fresh found devices from scan dialog to the listing
249 * 249 *
250 */ 250 */
251void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { 251void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) {
252 BTDeviceItem * deviceItem; 252 BTDeviceItem * deviceItem;
253 QValueList<RemoteDevice>::ConstIterator it; 253 QValueList<RemoteDevice>::ConstIterator it;
254 254
255 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { 255 for( it = newDevices.begin(); it != newDevices.end() ; ++it ) {
256 256
257 if (find( (*it) )) // is already inserted 257 if (find( (*it) )) // is already inserted
258 continue; 258 continue;
259 259
260 deviceItem = new BTDeviceItem( ListView2 , (*it) ); 260 deviceItem = new BTDeviceItem( ListView2 , (*it) );
261 deviceItem->setPixmap( 1, m_findPix ); 261 deviceItem->setPixmap( 1, m_findPix );
262 deviceItem->setExpandable ( true ); 262 deviceItem->setExpandable ( true );
263 263
264 // look if device is avail. atm, async 264 // look if device is avail. atm, async
265 deviceActive( (*it) ); 265 deviceActive( (*it) );
266 266
267 // ggf auch hier? 267 // ggf auch hier?
268 addServicesToDevice( deviceItem ); 268 addServicesToDevice( deviceItem );
269 } 269 }
270} 270}
271 271
272 272
273/** 273/**
274 * Action that is toggled on entrys on click 274 * Action that is toggled on entrys on click
275 */ 275 */
276void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { 276void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) {
277} 277}
278 278
279 279
280/** 280/**
281 * Action that are toggled on hold (mostly QPopups i guess) 281 * Action that are toggled on hold (mostly QPopups i guess)
282 */ 282 */
283void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { 283void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) {
284 if (!item ) 284 if (!item )
285 return; 285 return;
286 286
287 QPopupMenu *menu = new QPopupMenu(); 287 QPopupMenu *menu = new QPopupMenu();
288 int ret=0; 288 int ret=0;
289 289
290 if ( ((BTListItem*)item)->type() == "device") { 290 if ( ((BTListItem*)item)->type() == "device") {
291 291
292 QPopupMenu *groups = new QPopupMenu(); 292 QPopupMenu *groups = new QPopupMenu();
293 293
294 menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); 294 menu->insertItem( ((BTDeviceItem*)item)->name(),0 );
295 menu->insertSeparator(1); 295 menu->insertSeparator(1);
296 menu->insertItem( tr("rescan sevices"), 2); 296 menu->insertItem( tr("rescan sevices"), 2);
297 menu->insertItem( tr("to group"), groups , 3); 297 menu->insertItem( tr("to group"), groups , 3);
298 menu->insertItem( tr("delete"), 4); 298 menu->insertItem( tr("delete"), 4);
299 299
300 ret = menu->exec( point , 0); 300 ret = menu->exec( point , 0);
301 301
302 switch(ret) { 302 switch(ret) {
303 case -1: 303 case -1:
304 break; 304 break;
305 case 2: 305 case 2:
306 addServicesToDevice( (BTDeviceItem*)item ); 306 addServicesToDevice( (BTDeviceItem*)item );
307 break; 307 break;
308 308
309 case 4: 309 case 4:
310 // deletes childs too 310 // deletes childs too
311 delete item; 311 delete item;
312 break; 312 break;
313 } 313 }
314 delete groups; 314 delete groups;
315 315
316 } 316 }
317 317
318 /* 318 /*
319 * We got service sensitive PopupMenus in our factory 319 * We got service sensitive PopupMenus in our factory
320 * We will create one through the factory and will insert 320 * We will create one through the factory and will insert
321 * our Separator + ShowInfo into the menu or create a new 321 * our Separator + ShowInfo into the menu or create a new
322 * one if the factory returns 0 322 * one if the factory returns 0
323 * PopupMenu deletion is kind of weird. 323 * PopupMenu deletion is kind of weird.
324 * If escaped( -1 ) or any of our items were chosen we'll 324 * If escaped( -1 ) or any of our items were chosen we'll
325 * delete the PopupMenu otherwise it's the responsibility of 325 * delete the PopupMenu otherwise it's the responsibility of
326 * the PopupMenu to delete itself 326 * the PopupMenu to delete itself
327 * 327 *
328 */ 328 */
329 else if ( ((BTListItem*)item)->type() == "service") { 329 else if ( ((BTListItem*)item)->type() == "service") {
330 BTServiceItem* service = (BTServiceItem*)item; 330 BTServiceItem* service = (BTServiceItem*)item;
331 QMap<int, QString> list = service->services().classIdList(); 331 QMap<int, QString> list = service->services().classIdList();
332 QMap<int, QString>::Iterator it = list.begin(); 332 QMap<int, QString>::Iterator it = list.begin();
333 QPopupMenu *popup =0l; 333 QPopupMenu *popup =0l;
334 if ( it != list.end() ) { 334 if ( it != list.end() ) {
335 qWarning("Searching id %d %s", it.key(), it.data().latin1() ); 335 qWarning("Searching id %d %s", it.key(), it.data().latin1() );
336 popup = m_popHelper.find( it.key(), 336 popup = m_popHelper.find( it.key(),
337 service->services(), 337 service->services(),
338 (BTDeviceItem*)service->parent() ); 338 (BTDeviceItem*)service->parent() );
339 }else { 339 }else {
340 qWarning("Empty"); 340 qWarning("Empty");
341 } 341 }
342 342
343 if ( popup == 0l ) { 343 if ( popup == 0l ) {
344 qWarning("factory returned 0l"); 344 qWarning("factory returned 0l");
345 popup = new QPopupMenu(); 345 popup = new QPopupMenu();
346 } 346 }
347 int test1 = popup->insertItem( tr("Test1:"), 2); 347 int test1 = popup->insertItem( tr("Test1:"), 2);
348 348
349 ret = popup->exec( point ); 349 ret = popup->exec( point );
350 qWarning("returned from exec() "); 350 qWarning("returned from exec() ");
351 if ( ret == -1 ) { 351 if ( ret == -1 ) {
352 ; 352 ;
353 } else if ( ret == test1 ) { 353 } else if ( ret == test1 ) {
354 ; 354 ;
355 } 355 }
356 delete popup; 356 delete popup;
357 } 357 }
358 delete menu; 358 delete menu;
359} 359}
360 360
361 361
362/** 362/**
363 * Search and display avail. services for a device (on expand from device listing) 363 * Search and display avail. services for a device (on expand from device listing)
364 * @param item the service item returned 364 * @param item the service item returned
365 */ 365 */
366void BlueBase::addServicesToDevice( BTDeviceItem * item ) { 366void BlueBase::addServicesToDevice( BTDeviceItem * item ) {
367 qDebug("addServicesToDevice"); 367 qDebug("addServicesToDevice");
368 // row of mac adress text(3) 368 // row of mac adress text(3)
369 RemoteDevice device = item->remoteDevice(); 369 RemoteDevice device = item->remoteDevice();
370 m_deviceList.insert( item->mac() , item ); 370 m_deviceList.insert( item->mac() , item );
371 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back 371 // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back
372 m_localDevice->searchServices( device ); 372 m_localDevice->searchServices( device );
373} 373}
374 374
375 375
376/** 376/**
377 * Overloaded. This one it the one that is 377 * Overloaded. This one it the one that is
378 ted to the foundServices signal 378 ted to the foundServices signal
379 * @param device the mac address of the remote device 379 * @param device the mac address of the remote device
380 * @param servicesList the list with the service the device has. 380 * @param servicesList the list with the service the device has.
381 */ 381 */
382void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { 382void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) {
383 qDebug("fill services list"); 383 qDebug("fill services list");
384 384
385 QMap<QString,BTDeviceItem*>::Iterator it; 385 QMap<QString,BTDeviceItem*>::Iterator it;
386 BTDeviceItem* deviceItem = 0; 386 BTDeviceItem* deviceItem = 0;
387 387
388 // get the right devices which requested the search 388 // get the right devices which requested the search
389 it = m_deviceList.find( device ); 389 it = m_deviceList.find( device );
390 if( it == m_deviceList.end() ) 390 if( it == m_deviceList.end() )
391 return; 391 return;
392 deviceItem = it.data(); 392 deviceItem = it.data();
393 393
394 // remove previous entries 394 // remove previous entries
395 QList<QListViewItem> tempList; 395 QList<QListViewItem> tempList;
396 tempList.setAutoDelete( true ); 396 tempList.setAutoDelete( true );
397 QListViewItem * child = deviceItem->firstChild(); 397 QListViewItem * child = deviceItem->firstChild();
398 while( child ) { 398 while( child ) {
399 tempList.append( child ); 399 tempList.append( child );
400 child = child->nextSibling(); 400 child = child->nextSibling();
401 } 401 }
402 tempList.clear(); 402 tempList.clear();
403 403
404 QValueList<OpieTooth::Services>::Iterator it2; 404 QValueList<OpieTooth::Services>::Iterator it2;
405 BTServiceItem* serviceItem; 405 BTServiceItem* serviceItem;
406 406
407 407
408 if (!servicesList.isEmpty() ) { 408 if (!servicesList.isEmpty() ) {
409 // add services 409 // add services
410 QMap<int, QString> list; 410 QMap<int, QString> list;
411 QMap<int, QString>::Iterator classIt; 411 QMap<int, QString>::Iterator classIt;
412 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { 412 for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) {
413 serviceItem = new BTServiceItem( deviceItem, (*it2) ); 413 serviceItem = new BTServiceItem( deviceItem, (*it2) );
414 list = (*it2).classIdList(); 414 list = (*it2).classIdList();
415 classIt = list.begin(); 415 classIt = list.begin();
416 int classId=0; 416 int classId=0;
417 if ( classIt != list.end() ) { 417 if ( classIt != list.end() ) {
418 classId = classIt.key(); 418 classId = classIt.key();
419 } 419 }
420 420
421 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); 421 serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) );
422 } 422 }
423 } else { 423 } else {
424 Services s1; 424 Services s1;
425 s1.setServiceName( tr("no services found") ); 425 s1.setServiceName( tr("no services found") );
426 serviceItem = new BTServiceItem( deviceItem, s1 ); 426 serviceItem = new BTServiceItem( deviceItem, s1 );
427 } 427 }
428 // now remove them from the list 428 // now remove them from the list
429 m_deviceList.remove( it ); 429 m_deviceList.remove( it );
430} 430}
431 431
432 432
433 433
434 434
435 435
436void BlueBase::addSignalStrength() { 436void BlueBase::addSignalStrength() {
437 437
438 QListViewItemIterator it( ListView4 ); 438 QListViewItemIterator it( ListView4 );
439 for ( ; it.current(); ++it ) { 439 for ( ; it.current(); ++it ) {
440 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); 440 m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() );
441 } 441 }
442 442
443 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); 443 QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) );
444} 444}
445 445
446void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { 446void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) {
447 447
448 QListViewItemIterator it( ListView4 ); 448 QListViewItemIterator it( ListView4 );
449 for ( ; it.current(); ++it ) { 449 for ( ; it.current(); ++it ) {
450 if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { 450 if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) {
451 ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); 451 ((BTConnectionItem*)it.current() )->setSignalStrength( strength );
452 } 452 }
453 } 453 }
454} 454}
455 455
456/** 456/**
457 * Add the existing connections (pairs) to the connections tab. 457 * Add the existing connections (pairs) to the connections tab.
458 * This one triggers the search 458 * This one triggers the search
459 */ 459 */
460void BlueBase::addConnectedDevices() { 460void BlueBase::addConnectedDevices() {
461 m_localDevice->searchConnections(); 461 m_localDevice->searchConnections();
462} 462}
463 463
464/** 464/**
465 * This adds the found connections to the connection tab. 465 * This adds the found connections to the connection tab.
466 * @param connectionList the ValueList with all current connections 466 * @param connectionList the ValueList with all current connections
467 */ 467 */
468void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { 468void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) {
469 469
470 QValueList<OpieTooth::ConnectionState>::Iterator it; 470 QValueList<OpieTooth::ConnectionState>::Iterator it;
471 BTConnectionItem * connectionItem; 471 BTConnectionItem * connectionItem;
472 472
473 if ( !connectionList.isEmpty() ) { 473 if ( !connectionList.isEmpty() ) {
474 474
475 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 475 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
476 476
477 QListViewItemIterator it2( ListView4 ); 477 QListViewItemIterator it2( ListView4 );
478 bool found = false; 478 bool found = false;
479 for ( ; it2.current(); ++it2 ) { 479 for ( ; it2.current(); ++it2 ) {
480 if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { 480 if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) {
481 found = true; 481 found = true;
482 } 482 }
483 } 483 }
484 484
485 if ( found == false ) { 485 if ( found == false ) {
486 connectionItem = new BTConnectionItem( ListView4, (*it) ); 486 connectionItem = new BTConnectionItem( ListView4, (*it) );
487 487
488 if( m_deviceList.find((*it).mac()).data() ) { 488 if( m_deviceList.find((*it).mac()).data() ) {
489 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); 489 connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() );
490 } 490 }
491 } 491 }
492 492
493 } 493 }
494 494
495 QListViewItemIterator it2( ListView4 ); 495 QListViewItemIterator it2( ListView4 );
496 for ( ; it2.current(); ++it2 ) { 496 for ( ; it2.current(); ++it2 ) {
497 bool found = false; 497 bool found = false;
498 for (it = connectionList.begin(); it != connectionList.end(); ++it) { 498 for (it = connectionList.begin(); it != connectionList.end(); ++it) {
499 if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { 499 if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) {
500 found = true; 500 found = true;
501 } 501 }
502 } 502 }
503 503
504 if ( !found ) { 504 if ( !found ) {
505 delete it2.current(); 505 delete it2.current();
506 } 506 }
507 507
508 } 508 }
509 509
510 510
511 } else { 511 } else {
512 ListView4->clear(); 512 ListView4->clear();
513 ConnectionState con; 513 ConnectionState con;
514 con.setMac( tr("No connections found") ); 514 con.setMac( tr("No connections found") );
515 connectionItem = new BTConnectionItem( ListView4 , con ); 515 connectionItem = new BTConnectionItem( ListView4 , con );
516 } 516 }
517 517
518 // recall connection search after some time 518 // recall connection search after some time
519 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); 519 QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) );
520} 520}
521 521
522 522
523/** 523/**
524 * Find out if a device can currently be reached 524 * Find out if a device can currently be reached
525 * @param device 525 * @param device
526 */ 526 */
527void BlueBase::deviceActive( const RemoteDevice &device ) { 527void BlueBase::deviceActive( const RemoteDevice &device ) {
528 // search by mac, async, gets a signal back 528 // search by mac, async, gets a signal back
529 // We should have a BTDeviceItem there or where does it get added to the map -zecke 529 // We should have a BTDeviceItem there or where does it get added to the map -zecke
530 m_localDevice->isAvailable( device.mac() ); 530 m_localDevice->isAvailable( device.mac() );
531} 531}
532 532
533 533
534/** 534/**
535 * The signal catcher. Set the avail. status on device. 535 * The signal catcher. Set the avail. status on device.
536 * @param device - the mac address 536 * @param device - the mac address
537 * @param connected - if it is avail. or not 537 * @param connected - if it is avail. or not
538 */ 538 */
539void BlueBase::deviceActive( const QString& device, bool connected ) { 539void BlueBase::deviceActive( const QString& device, bool connected ) {
540 qDebug("deviceActive slot"); 540 qDebug("deviceActive slot");
541 541
542 QMap<QString,BTDeviceItem*>::Iterator it; 542 QMap<QString,BTDeviceItem*>::Iterator it;
543 543
544 it = m_deviceList.find( device ); 544 it = m_deviceList.find( device );
545 if( it == m_deviceList.end() ) 545 if( it == m_deviceList.end() )
546 return; 546 return;
547 547
548 BTDeviceItem* deviceItem = it.data(); 548 BTDeviceItem* deviceItem = it.data();
549 549
550 550
551 if ( connected ) { 551 if ( connected ) {
552 deviceItem->setPixmap( 1, m_onPix ); 552 deviceItem->setPixmap( 1, m_onPix );
553 } else { 553 } else {
554 deviceItem->setPixmap( 1, m_offPix ); 554 deviceItem->setPixmap( 1, m_offPix );
555 } 555 }
556 m_deviceList.remove( it ); 556 m_deviceList.remove( it );
557} 557}
558 558
559 559
560/** 560/**
561 * Open the "scan for devices" dialog 561 * Open the "scan for devices" dialog
562 */ 562 */
563void BlueBase::startScan() { 563void BlueBase::startScan() {
564 ScanDialog *scan = new ScanDialog( this, "ScanDialog", 564 ScanDialog *scan = new ScanDialog( this, "ScanDialog",
565 true, WDestructiveClose ); 565 true, WDestructiveClose );
566 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), 566 QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ),
567 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); 567 this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) );
568 568
569 scan->showMaximized(); 569 scan->showMaximized();
570} 570}
571 571
572 572
573/** 573/**
574 * Set the informations about the local device in information Tab 574 * Set the informations about the local device in information Tab
575 */ 575 */
576void BlueBase::setInfo() { 576void BlueBase::setInfo() {
577 StatusLabel->setText( status() ); 577 StatusLabel->setText( status() );
578} 578}
579 579
580 580
581/** 581/**
582 * Decontructor 582 * Decontructor
583 */ 583 */
584BlueBase::~BlueBase() { 584BlueBase::~BlueBase() {
585 writeSavedDevices(); 585 writeSavedDevices();
586 delete m_iconLoader; 586 delete m_iconLoader;
587} 587}
588 588
589 589
590/** 590/**
591 * find searches the ListView for a BTDeviceItem containig 591 * find searches the ListView for a BTDeviceItem containig
592 * the same Device if found return true else false 592 * the same Device if found return true else false
593 * @param dev RemoteDevice to find 593 * @param dev RemoteDevice to find
594 * @return returns true if found 594 * @return returns true if found
595 */ 595 */
596bool BlueBase::find( const RemoteDevice& rem ) { 596bool BlueBase::find( const RemoteDevice& rem ) {
597 QListViewItemIterator it( ListView2 ); 597 QListViewItemIterator it( ListView2 );
598 BTListItem* item; 598 BTListItem* item;
599 BTDeviceItem* device; 599 BTDeviceItem* device;
600 for (; it.current(); ++it ) { 600 for (; it.current(); ++it ) {
601 item = (BTListItem*) it.current(); 601 item = (BTListItem*) it.current();
602 if ( item->typeId() != BTListItem::Device ) 602 if ( item->typeId() != BTListItem::Device )
603 continue; 603 continue;
604 604
605 device = (BTDeviceItem*)item; 605 device = (BTDeviceItem*)item;
606 if ( rem.equals( device->remoteDevice() ) ) 606 if ( rem.equals( device->remoteDevice() ) )
607 return true; 607 return true;
608 } 608 }
609 return false; // not found 609 return false; // not found
610} 610}
diff --git a/noncore/net/ubrowser/httpfactory.cpp b/noncore/net/ubrowser/httpfactory.cpp
index b57149f..369f206 100644
--- a/noncore/net/ubrowser/httpfactory.cpp
+++ b/noncore/net/ubrowser/httpfactory.cpp
@@ -1,376 +1,376 @@
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 "httpfactory.h" 17#include "httpfactory.h"
18 18
19HttpFactory::HttpFactory(QTextBrowser *newBrowser):QMimeSourceFactory() 19HttpFactory::HttpFactory(QTextBrowser *newBrowser):QMimeSourceFactory()
20{ 20{
21 //socket = new QSocket; 21 //socket = new QSocket;
22 text = new QTextDrag; 22 text = new QTextDrag;
23 browser=newBrowser; 23 browser=newBrowser;
24 //comm = new HttpComm(socket, browser); 24 //comm = new HttpComm(socket, browser);
25 image = new QImageDrag; 25 image = new QImageDrag;
26} 26}
27 27
28const QMimeSource * HttpFactory::data(const QString &abs_name) const 28const QMimeSource * HttpFactory::data(const QString &abs_name) const
29{ 29{
30 printf("HttpFactory::data: using absolute data func\n"); 30 printf("HttpFactory::data: using absolute data func\n");
31 31
32 int port=80, addrEnd, portSep; 32 int port=80, addrEnd, portSep;
33 QString host, file, portS, name, tempString; 33 QString host, file, portS, name, tempString;
34 bool done=false, isText=true; 34 bool done=false, isText=true;
35 35
36 //comm->setUp((QString *)&abs_name); 36 //comm->setUp((QString *)&abs_name);
37 37
38 name = abs_name; 38 name = abs_name;
39 //name = name.lower(); 39 //name = name.lower();
40 name = name.stripWhiteSpace(); 40 name = name.stripWhiteSpace();
41 41
42 //printf("%s\n", name.latin1()); 42 //printf("%s\n", name.latin1());
43 43
44 if(name.startsWith("http://")) 44 if(name.startsWith("http://"))
45 { 45 {
46 name = name.remove(0, 7); 46 name = name.remove(0, 7);
47 } 47 }
48 else 48 else
49 { 49 {
50 name.prepend(browser->context()); 50 name.prepend(browser->context());
51 name = name.remove(0, 7); 51 name = name.remove(0, 7);
52 } 52 }
53 53
54 addrEnd = name.find('/'); 54 addrEnd = name.find('/');
55 if(addrEnd == -1) 55 if(addrEnd == -1)
56 { 56 {
57 name += '/'; 57 name += '/';
58 addrEnd = name.length()-1; 58 addrEnd = name.length()-1;
59 } 59 }
60 60
61 host = name; 61 host = name;
62 file = name; 62 file = name;
63 63
64 host.truncate(addrEnd); 64 host.truncate(addrEnd);
65 file.remove(0, addrEnd); 65 file.remove(0, addrEnd);
66 66
67 portSep = host.find(':'); 67 portSep = host.find(':');
68 if(portSep != -1) 68 if(portSep != -1)
69 { 69 {
70 portS=host; 70 portS=host;
71 host.truncate(portSep); 71 host.truncate(portSep);
72 portS.remove(0, portSep+1); 72 portS.remove(0, portSep+1);
73 port = portS.toInt(); 73 port = portS.toInt();
74 } 74 }
75 75
76 //printf("%s %s %d\n", host.latin1(), file.latin1(), port); 76 //printf("%s %s %d\n", host.latin1(), file.latin1(), port);
77 77
78 if(port == 80) 78 if(port == 80)
79 { 79 {
80 portS="80"; 80 portS="80";
81 } 81 }
82 82
83 //if(file.find(".png", file.length()-4) != -1 || file.find(".gif", file.length()-4) != -1 || file.find(".jpg", file.length()-4) != -1) 83 //if(file.find(".png", file.length()-4) != -1 || file.find(".gif", file.length()-4) != -1 || file.find(".jpg", file.length()-4) != -1)
84 //{ 84 //{
85 // isImage=true; 85 // isImage=true;
86 //} 86 //}
87 87
88 //comm->setStuff(host, portS, file, text, image, isImage); 88 //comm->setStuff(host, portS, file, text, image, isImage);
89 89
90 //socket->connectToHost(host, port); 90 //socket->connectToHost(host, port);
91 91
92 int con, bytesSent; 92 int con, bytesSent;
93 struct sockaddr_in serverAddr; 93 struct sockaddr_in serverAddr;
94 struct hostent * serverInfo = gethostbyname( host.latin1() ); 94 struct hostent * serverInfo = gethostbyname( host.latin1() );
95 95
96 if( serverInfo == NULL ) 96 if( serverInfo == NULL )
97 { 97 {
98 QMessageBox *mb = new QMessageBox("Error!", 98 QMessageBox *mb = new QMessageBox(QObject::tr("Error!"),
99 "couldnt find ip address", 99 QObject::tr("IP-Address not found"),
100 QMessageBox::NoIcon, 100 QMessageBox::NoIcon,
101 QMessageBox::Ok, 101 QMessageBox::Ok,
102 QMessageBox::NoButton, 102 QMessageBox::NoButton,
103 QMessageBox::NoButton); 103 QMessageBox::NoButton);
104 mb->exec(); 104 mb->exec();
105 perror("HttpFactory::data:"); 105 perror("HttpFactory::data:");
106 return 0; 106 return 0;
107 } 107 }
108 108
109 QByteArray data; 109 QByteArray data;
110 //printf( "HttpFactory::data: %s\n", inet_ntoa(*((struct in_addr *)serverInfo->h_addr )) ); 110 //printf( "HttpFactory::data: %s\n", inet_ntoa(*((struct in_addr *)serverInfo->h_addr )) );
111 111
112 QString request("GET " + file + " HTTP/1.1\r\nHost: " + host + ':' + portS + "\r\nConnection: close\r\n\r\n"); 112 QString request("GET " + file + " HTTP/1.1\r\nHost: " + host + ':' + portS + "\r\nConnection: close\r\n\r\n");
113 113
114 con = socket( AF_INET, SOCK_STREAM, 0 ); 114 con = socket( AF_INET, SOCK_STREAM, 0 );
115 if( con == -1 ) 115 if( con == -1 )
116 { 116 {
117 QMessageBox *mb = new QMessageBox("Error!", 117 QMessageBox *mb = new QMessageBox(QObject::tr("Error!"),
118 "couldnt create socket", 118 QObject::tr("Error creating socket"),
119 QMessageBox::NoIcon, 119 QMessageBox::NoIcon,
120 QMessageBox::Ok, 120 QMessageBox::Ok,
121 QMessageBox::NoButton, 121 QMessageBox::NoButton,
122 QMessageBox::NoButton); 122 QMessageBox::NoButton);
123 mb->exec(); 123 mb->exec();
124 perror("HttpFactory::data:"); 124 perror("HttpFactory::data:");
125 return 0; 125 return 0;
126 } 126 }
127 127
128 serverAddr.sin_family = AF_INET; 128 serverAddr.sin_family = AF_INET;
129 serverAddr.sin_port = htons( port ); 129 serverAddr.sin_port = htons( port );
130 serverAddr.sin_addr.s_addr = inet_addr( inet_ntoa(*((struct in_addr *)serverInfo->h_addr )) ); 130 serverAddr.sin_addr.s_addr = inet_addr( inet_ntoa(*((struct in_addr *)serverInfo->h_addr )) );
131 memset( &(serverAddr.sin_zero), '\0', 8 ); 131 memset( &(serverAddr.sin_zero), '\0', 8 );
132 132
133 if(::connect( con, (struct sockaddr *)&serverAddr, sizeof(struct sockaddr)) == -1 ) 133 if(::connect( con, (struct sockaddr *)&serverAddr, sizeof(struct sockaddr)) == -1 )
134 { 134 {
135 QMessageBox *mb = new QMessageBox("Error!", 135 QMessageBox *mb = new QMessageBox(QObject::tr("Error!"),
136 "couldnt connect to socket", 136 QObject::tr("Error connecting to socket"),
137 QMessageBox::NoIcon, 137 QMessageBox::NoIcon,
138 QMessageBox::Ok, 138 QMessageBox::Ok,
139 QMessageBox::NoButton, 139 QMessageBox::NoButton,
140 QMessageBox::NoButton); 140 QMessageBox::NoButton);
141 mb->exec(); 141 mb->exec();
142 perror("HttpFactory::data:"); 142 perror("HttpFactory::data:");
143 return 0; 143 return 0;
144 } 144 }
145 145
146 146
147 bytesSent = send( con, request.latin1(), request.length(), 0); 147 bytesSent = send( con, request.latin1(), request.length(), 0);
148 //printf("HttpFactory::data: bytes written: %d out of: %d\n", bytesSent, request.length() ); 148 //printf("HttpFactory::data: bytes written: %d out of: %d\n", bytesSent, request.length() );
149 //printf("HttpFactory::data: request sent:\n%s", request.latin1()); 149 //printf("HttpFactory::data: request sent:\n%s", request.latin1());
150 150
151 data = this->processResponse( con, isText ); 151 data = this->processResponse( con, isText );
152 152
153 ::close( con ); 153 ::close( con );
154 154
155 if(isText) 155 if(isText)
156 { 156 {
157 text->setText( QString( data ) ); 157 text->setText( QString( data ) );
158 return text; 158 return text;
159 } 159 }
160 else 160 else
161 { 161 {
162 image->setImage( QImage( data ) ); 162 image->setImage( QImage( data ) );
163 return image; 163 return image;
164 } 164 }
165} 165}
166 166
167const QMimeSource * HttpFactory::data(const QString &abs_or_rel_name, const QString & context) const 167const QMimeSource * HttpFactory::data(const QString &abs_or_rel_name, const QString & context) const
168{ 168{
169 printf("HttpFactory::data: using relative data func\n"); 169 printf("HttpFactory::data: using relative data func\n");
170 170
171 if(abs_or_rel_name.startsWith(context)) 171 if(abs_or_rel_name.startsWith(context))
172 { 172 {
173 return data(abs_or_rel_name); 173 return data(abs_or_rel_name);
174 } 174 }
175 else 175 else
176 { 176 {
177 return data(context + abs_or_rel_name); 177 return data(context + abs_or_rel_name);
178 } 178 }
179 179
180 return 0; 180 return 0;
181} 181}
182 182
183const QByteArray HttpFactory::processResponse( int sockfd, bool &isText ) const 183const QByteArray HttpFactory::processResponse( int sockfd, bool &isText ) const
184{ 184{
185 QByteArray inputBin( 1 ); 185 QByteArray inputBin( 1 );
186 QByteArray conClosedErr( 27 ); 186 QByteArray conClosedErr( 27 );
187 char conClosedErrMsg[] = "Connection to server closed"; 187 char conClosedErrMsg[] = "Connection to server closed";
188 QString currentLine; 188 QString currentLine;
189 bool done=false, chunked=false; 189 bool done=false, chunked=false;
190 int dataLength = 0; 190 int dataLength = 0;
191 191
192 for( int i = 0; i < 27; i++) 192 for( int i = 0; i < 27; i++)
193 { 193 {
194 conClosedErr[i] = conClosedErrMsg[i]; 194 conClosedErr[i] = conClosedErrMsg[i];
195 } 195 }
196 196
197 while( !done ) 197 while( !done )
198 { 198 {
199 recv( sockfd, inputBin.data(), inputBin.size(), 0 ); 199 recv( sockfd, inputBin.data(), inputBin.size(), 0 );
200 currentLine += *(inputBin.data()); 200 currentLine += *(inputBin.data());
201 201
202 if( *(inputBin.data()) == '\n' ) 202 if( *(inputBin.data()) == '\n' )
203 { 203 {
204 if( currentLine.isEmpty() || currentLine.startsWith( "\r") ) 204 if( currentLine.isEmpty() || currentLine.startsWith( "\r") )
205 { 205 {
206 printf( "HttpFactory::processResponse: end of header\n" ); 206 printf( "HttpFactory::processResponse: end of header\n" );
207 if( chunked ) 207 if( chunked )
208 { 208 {
209 return recieveChunked( sockfd ); 209 return recieveChunked( sockfd );
210 } else { 210 } else {
211 return recieveNormal( sockfd, dataLength ); 211 return recieveNormal( sockfd, dataLength );
212 } 212 }
213 done = true; 213 done = true;
214 } 214 }
215 215
216 if( currentLine.contains( "Transfer-Encoding: chunked", false) >= 1 ) 216 if( currentLine.contains( "Transfer-Encoding: chunked", false) >= 1 )
217 { 217 {
218 chunked = true; 218 chunked = true;
219 // printf( "HttpFactory::processResponse: chunked encoding\n" ); 219 // printf( "HttpFactory::processResponse: chunked encoding\n" );
220 } 220 }
221 221
222 if( currentLine.contains( "Content-Type: text", false ) >= 1 ) 222 if( currentLine.contains( "Content-Type: text", false ) >= 1 )
223 { 223 {
224 isText = true; 224 isText = true;
225 // printf( "HttpFactory::processResponse: content type text\n" ); 225 // printf( "HttpFactory::processResponse: content type text\n" );
226 if( currentLine.contains( "html", false ) >= 1) 226 if( currentLine.contains( "html", false ) >= 1)
227 { 227 {
228 browser->setTextFormat(Qt::RichText); 228 browser->setTextFormat(Qt::RichText);
229 // printf( "HttpFactory::processResponse: content type html\n" ); 229 // printf( "HttpFactory::processResponse: content type html\n" );
230 } 230 }
231 } 231 }
232 232
233 if( currentLine.contains( "Content-Type: image", false ) >= 1 ) 233 if( currentLine.contains( "Content-Type: image", false ) >= 1 )
234 { 234 {
235 isText = false; 235 isText = false;
236 // printf( "HttpFactory::processResponse: content type image\n" ); 236 // printf( "HttpFactory::processResponse: content type image\n" );
237 } 237 }
238 238
239 if( currentLine.contains( "Content-Length", false ) >= 1 ) 239 if( currentLine.contains( "Content-Length", false ) >= 1 )
240 { 240 {
241 currentLine.remove( 0, 16 ); 241 currentLine.remove( 0, 16 );
242 dataLength = currentLine.toInt(); 242 dataLength = currentLine.toInt();
243 // printf( "HttpFactory::processResponse: content length: %d\n", dataLength ); 243 // printf( "HttpFactory::processResponse: content length: %d\n", dataLength );
244 } 244 }
245 245
246 if( currentLine.contains( "404", false ) >= 1 ) 246 if( currentLine.contains( "404", false ) >= 1 )
247 { 247 {
248 // printf( "HttpFactory::processResponse: 404 error\n" ); 248 // printf( "HttpFactory::processResponse: 404 error\n" );
249 return 0; 249 return 0;
250 } 250 }
251 251
252 currentLine = ""; 252 currentLine = "";
253 // printf("HttpFactory::processResponse: reseting currentLine: %s\n", currentLine.latin1() ); 253 // printf("HttpFactory::processResponse: reseting currentLine: %s\n", currentLine.latin1() );
254 } 254 }
255 } 255 }
256} 256}
257 257
258const QByteArray HttpFactory::recieveNormal( int sockfd, int dataLen ) const 258const QByteArray HttpFactory::recieveNormal( int sockfd, int dataLen ) const
259{ 259{
260 //printf( "HttpFactory::recieveNormal: recieving w/out chunked encoding\n" ); 260 //printf( "HttpFactory::recieveNormal: recieving w/out chunked encoding\n" );
261 261
262 QByteArray data( dataLen ); 262 QByteArray data( dataLen );
263 QByteArray temp( dataLen ); 263 QByteArray temp( dataLen );
264 int recieved, i; 264 int recieved, i;
265 265
266 recieved = recv( sockfd, temp.data(), temp.size(), 0 ); 266 recieved = recv( sockfd, temp.data(), temp.size(), 0 );
267 //printf( "HttpFactory::recieveNormal: found some data: %s\n", (char *)temp.data() ); 267 //printf( "HttpFactory::recieveNormal: found some data: %s\n", (char *)temp.data() );
268 for( i = 0; i < recieved; i++ ) 268 for( i = 0; i < recieved; i++ )
269 { 269 {
270 data[i] = temp[i]; 270 data[i] = temp[i];
271 } 271 }
272 dataLen -= recieved; 272 dataLen -= recieved;
273 while( dataLen > 0 ) 273 while( dataLen > 0 )
274 { 274 {
275 recieved = recv( sockfd, temp.data(), temp.size(), 0 ); 275 recieved = recv( sockfd, temp.data(), temp.size(), 0 );
276 dataLen -= recieved; 276 dataLen -= recieved;
277 // printf( "HttpFactory::recieveNormal: found some more data: %s\n", (char *)temp.data() ); 277 // printf( "HttpFactory::recieveNormal: found some more data: %s\n", (char *)temp.data() );
278 for( int j = 0; j < recieved; j++ ) 278 for( int j = 0; j < recieved; j++ )
279 { 279 {
280 data[i] = temp[j]; 280 data[i] = temp[j];
281 i++; 281 i++;
282 } 282 }
283 temp.fill('\0'); 283 temp.fill('\0');
284 } 284 }
285 285
286 //printf( "HttpFactory::recieveNormal: end of data\n" ); 286 //printf( "HttpFactory::recieveNormal: end of data\n" );
287 return data; 287 return data;
288} 288}
289 289
290const QByteArray HttpFactory::recieveChunked( int sockfd ) const 290const QByteArray HttpFactory::recieveChunked( int sockfd ) const
291{ 291{
292 //printf( "HttpFactory::recieveChunked: recieving data with chunked encoding\n" ); 292 //printf( "HttpFactory::recieveChunked: recieving data with chunked encoding\n" );
293 293
294 QByteArray data; 294 QByteArray data;
295 QByteArray temp( 1 ); 295 QByteArray temp( 1 );
296 int recieved, i = 0, cSize = 0; 296 int recieved, i = 0, cSize = 0;
297 QString cSizeS; 297 QString cSizeS;
298 298
299 //printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() ); 299 //printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() );
300 recv( sockfd, temp.data(), temp.size(), 0 ); 300 recv( sockfd, temp.data(), temp.size(), 0 );
301 while( *(temp.data()) != '\n' && *(temp.data()) != ';' ) 301 while( *(temp.data()) != '\n' && *(temp.data()) != ';' )
302 { 302 {
303 // printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() ); 303 // printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() );
304 // printf( "HttpFactory::recieveChunked: temp.data(): %c\n", temp[0] ); 304 // printf( "HttpFactory::recieveChunked: temp.data(): %c\n", temp[0] );
305 cSizeS += temp[0]; 305 cSizeS += temp[0];
306 recv( sockfd, temp.data(), temp.size(), 0 ); 306 recv( sockfd, temp.data(), temp.size(), 0 );
307 } 307 }
308 308
309 //printf( "HttpFactory::recieveChunked: cSizeS: %s\n", cSizeS.latin1() ); 309 //printf( "HttpFactory::recieveChunked: cSizeS: %s\n", cSizeS.latin1() );
310 cSize = cSizeS.toInt( 0, 16 ); 310 cSize = cSizeS.toInt( 0, 16 );
311 //printf( "HttpFactory::recieveChunked: first chunk of size: %d\n", cSize ); 311 //printf( "HttpFactory::recieveChunked: first chunk of size: %d\n", cSize );
312 312
313 if( *(temp.data()) == ';' ) 313 if( *(temp.data()) == ';' )
314 { 314 {
315 while( *(temp.data()) != '\n' ) 315 while( *(temp.data()) != '\n' )
316 { 316 {
317 recv( sockfd, temp.data(), temp.size(), 0 ); 317 recv( sockfd, temp.data(), temp.size(), 0 );
318 } 318 }
319 } 319 }
320 320
321 temp.fill( '\0', cSize ); 321 temp.fill( '\0', cSize );
322 data.fill( '\0', cSize ); 322 data.fill( '\0', cSize );
323 323
324 while( cSize > 0 ) 324 while( cSize > 0 )
325 { 325 {
326 while( cSize > 0 ) 326 while( cSize > 0 )
327 { 327 {
328 recieved = recv( sockfd, temp.data(), temp.size(), 0 ); 328 recieved = recv( sockfd, temp.data(), temp.size(), 0 );
329 cSize -= recieved; 329 cSize -= recieved;
330 for( int j = 0; j < recieved; j++ ) 330 for( int j = 0; j < recieved; j++ )
331 { 331 {
332 data[i] = temp[j]; 332 data[i] = temp[j];
333 i++; 333 i++;
334 } 334 }
335 temp.fill('\0', cSize); 335 temp.fill('\0', cSize);
336 } 336 }
337 337
338 // printf( "HttpFactory::recieveChunked: current data:\n%s", data.data() ); 338 // printf( "HttpFactory::recieveChunked: current data:\n%s", data.data() );
339 339
340 temp.fill('\0', 1); 340 temp.fill('\0', 1);
341 cSizeS = ""; 341 cSizeS = "";
342 cSize = 0; 342 cSize = 0;
343 343
344 recv( sockfd, temp.data(), temp.size(), 0 ); 344 recv( sockfd, temp.data(), temp.size(), 0 );
345 if( *(temp.data()) == '\r' ) 345 if( *(temp.data()) == '\r' )
346 { 346 {
347 recv( sockfd, temp.data(), temp.size(), 0 ); 347 recv( sockfd, temp.data(), temp.size(), 0 );
348 } 348 }
349 recv( sockfd, temp.data(), temp.size(), 0 ); 349 recv( sockfd, temp.data(), temp.size(), 0 );
350 while( *(temp.data()) != '\n' && *(temp.data()) != ';' ) 350 while( *(temp.data()) != '\n' && *(temp.data()) != ';' )
351 { 351 {
352 // printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() ); 352 // printf( "HttpFactory::recieveChunked: temp.size(): %d\n", temp.size() );
353 // printf( "HttpFactory::recieveChunked: temp.data(): %d\n", temp[0] ); 353 // printf( "HttpFactory::recieveChunked: temp.data(): %d\n", temp[0] );
354 cSizeS += temp[0]; 354 cSizeS += temp[0];
355 recv( sockfd, temp.data(), temp.size(), 0 ); 355 recv( sockfd, temp.data(), temp.size(), 0 );
356 } 356 }
357 357
358 // printf( "HttpFactory::recieveChunked: cSizeS: %s\n", cSizeS.latin1() ); 358 // printf( "HttpFactory::recieveChunked: cSizeS: %s\n", cSizeS.latin1() );
359 cSize = cSizeS.toInt( 0, 16 ); 359 cSize = cSizeS.toInt( 0, 16 );
360 // printf( "HttpFactory::recieveChunked: next chunk of size: %d\n", cSize ); 360 // printf( "HttpFactory::recieveChunked: next chunk of size: %d\n", cSize );
361 361
362 if( *(temp.data()) == ';' ) 362 if( *(temp.data()) == ';' )
363 { 363 {
364 while( *(temp.data()) != '\n' ) 364 while( *(temp.data()) != '\n' )
365 { 365 {
366 recv( sockfd, temp.data(), temp.size(), 0 ); 366 recv( sockfd, temp.data(), temp.size(), 0 );
367 } 367 }
368 } 368 }
369 369
370 temp.fill( '\0', cSize ); 370 temp.fill( '\0', cSize );
371 data.resize( data.size() + cSize ); 371 data.resize( data.size() + cSize );
372 } 372 }
373 373
374 //printf( "HttpFactory::recieveChunked: end of data\n" ); 374 //printf( "HttpFactory::recieveChunked: end of data\n" );
375 return data; 375 return data;
376} 376}
diff --git a/noncore/net/ubrowser/mainview.cpp b/noncore/net/ubrowser/mainview.cpp
index f68c5db..9302f05 100644
--- a/noncore/net/ubrowser/mainview.cpp
+++ b/noncore/net/ubrowser/mainview.cpp
@@ -1,121 +1,121 @@
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 17
18#include "mainview.h" 18#include "mainview.h"
19 19
20MainView::MainView(QWidget *parent, const char *name) : QMainWindow(parent, name) 20MainView::MainView(QWidget *parent, const char *name) : QMainWindow(parent, name)
21{ 21{
22 setIcon( Resource::loadPixmap( "remote" ) ); 22 setIcon( Resource::loadPixmap( "remote" ) );
23 setCaption("uBrowser"); 23 setCaption(tr("uBrowser"));
24 24
25 setToolBarsMovable( false ); 25 setToolBarsMovable( false );
26 26
27 QPEToolBar *toolbar = new QPEToolBar(this, "toolbar"); 27 QPEToolBar *toolbar = new QPEToolBar(this, "toolbar");
28 back = new QToolButton(Resource::loadPixmap("ubrowser/back"), 0, 0, 0, 0, toolbar, "back"); 28 back = new QToolButton(Resource::loadPixmap("ubrowser/back"), 0, 0, 0, 0, toolbar, "back");
29 forward = new QToolButton(Resource::loadPixmap("ubrowser/forward"), 0, 0, 0, 0, toolbar, "forward"); 29 forward = new QToolButton(Resource::loadPixmap("ubrowser/forward"), 0, 0, 0, 0, toolbar, "forward");
30 home = new QToolButton(Resource::loadPixmap("ubrowser/home"), 0, 0, 0, 0, toolbar, "home"); 30 home = new QToolButton(Resource::loadPixmap("ubrowser/home"), 0, 0, 0, 0, toolbar, "home");
31 location = new QComboBox(true, toolbar, "location"); 31 location = new QComboBox(true, toolbar, "location");
32 go = new QToolButton(Resource::loadPixmap("ubrowser/go"), 0, 0, 0, 0, toolbar, "go"); 32 go = new QToolButton(Resource::loadPixmap("ubrowser/go"), 0, 0, 0, 0, toolbar, "go");
33 33
34 toolbar->setStretchableWidget(location); 34 toolbar->setStretchableWidget(location);
35 toolbar->setHorizontalStretchable(true); 35 toolbar->setHorizontalStretchable(true);
36 location->setAutoCompletion( true ); 36 location->setAutoCompletion( true );
37 37
38 addToolBar(toolbar); 38 addToolBar(toolbar);
39 39
40 browser = new QTextBrowser(this, "browser"); 40 browser = new QTextBrowser(this, "browser");
41 setCentralWidget(browser); 41 setCentralWidget(browser);
42 42
43//make the button take you to the location 43//make the button take you to the location
44 connect(go, SIGNAL(clicked()), this, SLOT(goClicked()) ); 44 connect(go, SIGNAL(clicked()), this, SLOT(goClicked()) );
45 connect(location->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goClicked()) ); 45 connect(location->lineEdit(), SIGNAL(returnPressed()), this, SLOT(goClicked()) );
46 46
47//make back, forward and home do their thing (isnt QTextBrowser great?) 47//make back, forward and home do their thing (isnt QTextBrowser great?)
48 connect(back, SIGNAL(clicked()), browser, SLOT(backward()) ); 48 connect(back, SIGNAL(clicked()), browser, SLOT(backward()) );
49 connect(forward, SIGNAL(clicked()), browser, SLOT(forward()) ); 49 connect(forward, SIGNAL(clicked()), browser, SLOT(forward()) );
50 connect(home, SIGNAL(clicked()), browser, SLOT(home()) ); 50 connect(home, SIGNAL(clicked()), browser, SLOT(home()) );
51 51
52//make back and forward buttons be enabled, only when you can go back or forward (again, i love QTextBrowser) 52//make back and forward buttons be enabled, only when you can go back or forward (again, i love QTextBrowser)
53//this doesnt seem to work, but doesnt break anything either... 53//this doesnt seem to work, but doesnt break anything either...
54 connect(browser, SIGNAL(backwardAvailable(bool)), back, SLOT(setOn(bool)) ); 54 connect(browser, SIGNAL(backwardAvailable(bool)), back, SLOT(setOn(bool)) );
55 connect(browser, SIGNAL(forwardAvailable(bool)), forward, SLOT(setOn(bool)) ); 55 connect(browser, SIGNAL(forwardAvailable(bool)), forward, SLOT(setOn(bool)) );
56 56
57//notify me when the text of the browser has changed (like when the user clicks a link) 57//notify me when the text of the browser has changed (like when the user clicks a link)
58 connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()) ); 58 connect(browser, SIGNAL(textChanged()), this, SLOT(textChanged()) );
59 59
60 http = new HttpFactory(browser); 60 http = new HttpFactory(browser);
61 61
62 if( qApp->argc() > 1 ) 62 if( qApp->argc() > 1 )
63 { 63 {
64 char **argv = qApp->argv(); 64 char **argv = qApp->argv();
65 int i = 0; 65 int i = 0;
66 QString *openfile = new QString( argv[0] ); 66 QString *openfile = new QString( argv[0] );
67 while( openfile->contains( "ubrowser" ) == 0 && i < qApp->argc() ) 67 while( openfile->contains( "ubrowser" ) == 0 && i < qApp->argc() )
68 { 68 {
69 i++; 69 i++;
70 *openfile = argv[i]; 70 *openfile = argv[i];
71 } 71 }
72 *openfile = argv[i+1]; 72 *openfile = argv[i+1];
73 if( !openfile->startsWith( "http://" ) && !openfile->startsWith( "/" ) ) 73 if( !openfile->startsWith( "http://" ) && !openfile->startsWith( "/" ) )
74 { 74 {
75 openfile->insert( 0, QDir::currentDirPath()+"/" ); 75 openfile->insert( 0, QDir::currentDirPath()+"/" );
76 } 76 }
77 location->setEditText( *openfile ); 77 location->setEditText( *openfile );
78 goClicked(); 78 goClicked();
79 } 79 }
80} 80}
81 81
82void MainView::goClicked() 82void MainView::goClicked()
83{ 83{
84 location->insertItem( location->currentText() ); 84 location->insertItem( location->currentText() );
85 85
86 if(location->currentText().startsWith("http://") ) 86 if(location->currentText().startsWith("http://") )
87 { 87 {
88 location->setEditText(location->currentText().lower()); 88 location->setEditText(location->currentText().lower());
89 browser->setMimeSourceFactory(http); 89 browser->setMimeSourceFactory(http);
90 printf("MainView::goClicked: using http source factory\n"); 90 printf("MainView::goClicked: using http source factory\n");
91 } 91 }
92 else 92 else
93 { 93 {
94 browser->setMimeSourceFactory(QMimeSourceFactory::defaultFactory()); 94 browser->setMimeSourceFactory(QMimeSourceFactory::defaultFactory());
95 printf("MainView::goClicked: using default source factory\n"); 95 printf("MainView::goClicked: using default source factory\n");
96 } 96 }
97 97
98 browser->setSource(location->currentText()); 98 browser->setSource(location->currentText());
99} 99}
100 100
101void MainView::textChanged() 101void MainView::textChanged()
102{ 102{
103 if(browser->documentTitle().isNull()) 103 if(browser->documentTitle().isNull())
104 { 104 {
105 setCaption(browser->source() + " - uBrowser"); 105 setCaption( tr("%1 - uBrowser").arg( browser->source() ) );
106 } 106 }
107 else 107 else
108 { 108 {
109 setCaption(browser->documentTitle() + " - uBrowser"); 109 setCaption(tr(" - uBrowser").arg( browser->documentTitle() ));
110 } 110 }
111 111
112 location->setEditText(browser->source()); 112 location->setEditText(browser->source());
113} 113}
114 114
115void MainView::setDocument( const QString& applnk_filename ) 115void MainView::setDocument( const QString& applnk_filename )
116{ 116{
117 DocLnk *file = new DocLnk( applnk_filename ); 117 DocLnk *file = new DocLnk( applnk_filename );
118 118
119 location->setEditText( file->file() ); 119 location->setEditText( file->file() );
120 goClicked(); 120 goClicked();
121} 121}
diff --git a/noncore/net/ubrowser/opie-ubrowser.control b/noncore/net/ubrowser/opie-ubrowser.control
new file mode 100644
index 0000000..61a6cde
--- a/dev/null
+++ b/noncore/net/ubrowser/opie-ubrowser.control
@@ -0,0 +1,10 @@
1Package: opie-ubrowser
2Files: bin/ubrowser apps/Applications/ubrowser.desktop pics/ubrowser/*.png
3Priority: optional
4Section: opie/applications
5Maintainer: Thomas Stephens <spiralman@softhome.net>
6Architecture: arm
7Version: 0.1-$SUB_VERSION
8Depends: task-opie-minimal
9License: GPL
10Description: a very small web browser
diff --git a/noncore/unsupported/mailit/config.in b/noncore/unsupported/mailit/config.in
index 2b56b5f..142b840 100644
--- a/noncore/unsupported/mailit/config.in
+++ b/noncore/unsupported/mailit/config.in
@@ -1,4 +1,4 @@
1 config MAILIT 1 config MAILIT
2 boolean "mailit" 2 boolean "opie-mailit (a simple POP3 email client)"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) 4 depends ( LIBQPE || LIBQPE-X11 )
diff --git a/noncore/unsupported/mailit/popclient.cpp b/noncore/unsupported/mailit/popclient.cpp
index 5da3bcb..1df6b2b 100644
--- a/noncore/unsupported/mailit/popclient.cpp
+++ b/noncore/unsupported/mailit/popclient.cpp
@@ -1,331 +1,332 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "popclient.h" 20#include "popclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22//#define APOP_TEST 22//#define APOP_TEST
23 23
24extern "C" { 24extern "C" {
25#include "md5.h" 25#include "md5.h"
26} 26}
27 27
28#include <qcstring.h> 28#include <qcstring.h>
29 29
30PopClient::PopClient() 30PopClient::PopClient()
31{ 31{
32 32
33 socket = new QSocket(this, "popClient"); 33 socket = new QSocket(this, "popClient");
34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 34 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 35 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 36 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
37 37
38 stream = new QTextStream(socket); 38 stream = new QTextStream(socket);
39 39
40 receiving = FALSE; 40 receiving = FALSE;
41 synchronize = FALSE; 41 synchronize = FALSE;
42 lastSync = 0; 42 lastSync = 0;
43 headerLimit = 0; 43 headerLimit = 0;
44 mailList = 0;
44 preview = FALSE; 45 preview = FALSE;
45} 46}
46 47
47PopClient::~PopClient() 48PopClient::~PopClient()
48{ 49{
49 delete socket; 50 delete socket;
50 delete stream; 51 delete stream;
51} 52}
52 53
53void PopClient::newConnection(const QString &target, int port) 54void PopClient::newConnection(const QString &target, int port)
54{ 55{
55 if (receiving) { 56 if (receiving) {
56 qWarning("socket in use, connection refused"); 57 qWarning("socket in use, connection refused");
57 return; 58 return;
58 } 59 }
59 60
60 status = Init; 61 status = Init;
61 62
62 socket->connectToHost(target, port); 63 socket->connectToHost(target, port);
63 receiving = TRUE; 64 receiving = TRUE;
64 //selected = FALSE; 65 //selected = FALSE;
65 66
66 emit updateStatus(tr("DNS lookup")); 67 emit updateStatus(tr("DNS lookup"));
67} 68}
68 69
69void PopClient::setAccount(const QString &popUser, const QString &popPasswd) 70void PopClient::setAccount(const QString &popUser, const QString &popPasswd)
70{ 71{
71 popUserName = popUser; 72 popUserName = popUser;
72 popPassword = popPasswd; 73 popPassword = popPasswd;
73} 74}
74 75
75void PopClient::setSynchronize(int lastCount) 76void PopClient::setSynchronize(int lastCount)
76{ 77{
77 synchronize = TRUE; 78 synchronize = TRUE;
78 lastSync = lastCount; 79 lastSync = lastCount;
79} 80}
80 81
81void PopClient::removeSynchronize() 82void PopClient::removeSynchronize()
82{ 83{
83 synchronize = FALSE; 84 synchronize = FALSE;
84 lastSync = 0; 85 lastSync = 0;
85} 86}
86 87
87void PopClient::headersOnly(bool headers, int limit) 88void PopClient::headersOnly(bool headers, int limit)
88{ 89{
89 preview = headers; 90 preview = headers;
90 headerLimit = limit; 91 headerLimit = limit;
91} 92}
92 93
93void PopClient::setSelectedMails(MailList *list) 94void PopClient::setSelectedMails(MailList *list)
94{ 95{
95 selected = TRUE; 96 selected = TRUE;
96 mailList = list; 97 mailList = list;
97} 98}
98 99
99void PopClient::connectionEstablished() 100void PopClient::connectionEstablished()
100{ 101{
101 emit updateStatus(tr("Connection established")); 102 emit updateStatus(tr("Connection established"));
102} 103}
103 104
104void PopClient::errorHandling(int status) 105void PopClient::errorHandling(int status)
105{ 106{
106 errorHandlingWithMsg( status, QString::null ); 107 errorHandlingWithMsg( status, QString::null );
107} 108}
108void PopClient::errorHandlingWithMsg(int status, const QString & Msg ) 109void PopClient::errorHandlingWithMsg(int status, const QString & Msg )
109{ 110{
110 emit updateStatus(tr("Error Occured")); 111 emit updateStatus(tr("Error Occured"));
111 emit errorOccurred(status, Msg); 112 emit errorOccurred(status, Msg);
112 socket->close(); 113 socket->close();
113 receiving = FALSE; 114 receiving = FALSE;
114} 115}
115 116
116void PopClient::incomingData() 117void PopClient::incomingData()
117{ 118{
118 QString response, temp, temp2, timeStamp; 119 QString response, temp, temp2, timeStamp;
119 QString md5Source; 120 QString md5Source;
120 int start, end; 121 int start, end;
121// char *md5Digest; 122// char *md5Digest;
122 char md5Digest[16]; 123 char md5Digest[16];
123// if ( !socket->canReadLine() ) 124// if ( !socket->canReadLine() )
124// return; 125// return;
125 126
126 127
127 response = socket->readLine(); 128 response = socket->readLine();
128 129
129 switch(status) { 130 switch(status) {
130 //logging in 131 //logging in
131 case Init: { 132 case Init: {
132#ifdef APOP_TEST 133#ifdef APOP_TEST
133 start = response.find('<',0); 134 start = response.find('<',0);
134 end = response.find('>', start); 135 end = response.find('>', start);
135 if( start >= 0 && end > start ) 136 if( start >= 0 && end > start )
136 { 137 {
137 timeStamp = response.mid( start , end - start + 1); 138 timeStamp = response.mid( start , end - start + 1);
138 md5Source = timeStamp + popPassword; 139 md5Source = timeStamp + popPassword;
139 140
140 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]); 141 md5_buffer( (char const *)md5Source, md5Source.length(),&md5Digest[0]);
141 142
142 for(int j =0;j < MD5_DIGEST_LENGTH ;j++) 143 for(int j =0;j < MD5_DIGEST_LENGTH ;j++)
143 { 144 {
144 printf("%x", md5Digest[j]); 145 printf("%x", md5Digest[j]);
145 } 146 }
146 printf("\n"); 147 printf("\n");
147// qDebug(md5Digest); 148// qDebug(md5Digest);
148 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n"; 149 *stream << "APOP " << popUserName << " " << md5Digest << "\r\n";
149 // qDebug("%s", stream); 150 // qDebug("%s", stream);
150 status = Stat; 151 status = Stat;
151 } 152 }
152 else 153 else
153#endif 154#endif
154 { 155 {
155 timeStamp = ""; 156 timeStamp = "";
156 *stream << "USER " << popUserName << "\r\n"; 157 *stream << "USER " << popUserName << "\r\n";
157 status = Pass; 158 status = Pass;
158 } 159 }
159 160
160 break; 161 break;
161 } 162 }
162 163
163 case Pass: { 164 case Pass: {
164 *stream << "PASS " << popPassword << "\r\n"; 165 *stream << "PASS " << popPassword << "\r\n";
165 status = Stat; 166 status = Stat;
166 167
167 break; 168 break;
168 } 169 }
169 //ask for number of messages 170 //ask for number of messages
170 case Stat: { 171 case Stat: {
171 if (response[0] == '+') { 172 if (response[0] == '+') {
172 *stream << "STAT" << "\r\n"; 173 *stream << "STAT" << "\r\n";
173 status = Mcnt; 174 status = Mcnt;
174 } else errorHandlingWithMsg(ErrLoginFailed, response); 175 } else errorHandlingWithMsg(ErrLoginFailed, response);
175 break; 176 break;
176 } 177 }
177 //get count of messages, eg "+OK 4 900.." -> int 4 178 //get count of messages, eg "+OK 4 900.." -> int 4
178 case Mcnt: { 179 case Mcnt: {
179 if (response[0] == '+') { 180 if (response[0] == '+') {
180 temp = response.replace(0, 4, ""); 181 temp = response.replace(0, 4, "");
181 int x = temp.find(" ", 0); 182 int x = temp.find(" ", 0);
182 temp.truncate((uint) x); 183 temp.truncate((uint) x);
183 newMessages = temp.toInt(); 184 newMessages = temp.toInt();
184 messageCount = 1; 185 messageCount = 1;
185 status = List; 186 status = List;
186 187
187 if (synchronize) { 188 if (synchronize) {
188 //messages deleted from server, reload all 189 //messages deleted from server, reload all
189 if (newMessages < lastSync) 190 if (newMessages < lastSync)
190 lastSync = 0; 191 lastSync = 0;
191 messageCount = 1; 192 messageCount = 1;
192 } 193 }
193 194
194 if (selected) { 195 if (selected && mailList ) {
195 int *ptr = mailList->first(); 196 int *ptr = mailList->first();
196 if (ptr != 0) { 197 if (ptr != 0) {
197 newMessages++; //to ensure no early jumpout 198 newMessages++; //to ensure no early jumpout
198 messageCount = *ptr; 199 messageCount = *ptr;
199 } else newMessages = 0; 200 } else newMessages = 0;
200 } 201 }
201 202
202 } else errorHandlingWithMsg(ErrUnknownResponse, response); 203 } else errorHandlingWithMsg(ErrUnknownResponse, response);
203 } 204 }
204 //Read message number x, count upwards to messageCount 205 //Read message number x, count upwards to messageCount
205 case List: { 206 case List: {
206 if (messageCount <= newMessages) { 207 if (messageCount <= newMessages) {
207 *stream << "LIST " << messageCount << "\r\n"; 208 *stream << "LIST " << messageCount << "\r\n";
208 status = Size; 209 status = Size;
209 temp2.setNum(newMessages - lastSync); 210 temp2.setNum(newMessages - lastSync);
210 temp.setNum(messageCount - lastSync); 211 temp.setNum(messageCount - lastSync);
211 if (!selected) { 212 if (!selected) {
212 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 213 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
213 } else { 214 } else {
214 //completing a previously closed transfer 215 //completing a previously closed transfer
215 /* if ( (messageCount - lastSync) <= 0) { 216 /* if ( (messageCount - lastSync) <= 0) {
216 temp.setNum(messageCount); 217 temp.setNum(messageCount);
217 emit updateStatus(tr("Previous message ") + temp); 218 emit updateStatus(tr("Previous message ") + temp);
218 } else {*/ 219 } else {*/
219 emit updateStatus(tr("Completing message ") + temp); 220 emit updateStatus(tr("Completing message ") + temp);
220 //} 221 //}
221 } 222 }
222 break; 223 break;
223 } else { 224 } else {
224 emit updateStatus(tr("No new Messages")); 225 emit updateStatus(tr("No new Messages"));
225 status = Quit; 226 status = Quit;
226 } 227 }
227 } 228 }
228 //get size of message, eg "500 characters in message.." -> int 500 229 //get size of message, eg "500 characters in message.." -> int 500
229 case Size: { 230 case Size: {
230 if (status != Quit) { //because of idiotic switch 231 if (status != Quit) { //because of idiotic switch
231 if (response[0] == '+') { 232 if (response[0] == '+') {
232 temp = response.replace(0, 4, ""); 233 temp = response.replace(0, 4, "");
233 int x = temp.find(" ", 0); 234 int x = temp.find(" ", 0);
234 temp = temp.right(temp.length() - ((uint) x + 1) ); 235 temp = temp.right(temp.length() - ((uint) x + 1) );
235 mailSize = temp.toInt(); 236 mailSize = temp.toInt();
236 emit currentMailSize(mailSize); 237 emit currentMailSize(mailSize);
237 238
238 status = Retr; 239 status = Retr;
239 } else { 240 } else {
240 //qWarning(response); 241 //qWarning(response);
241 errorHandlingWithMsg(ErrUnknownResponse, response); 242 errorHandlingWithMsg(ErrUnknownResponse, response);
242 } 243 }
243 } 244 }
244 } 245 }
245 //Read message number x, count upwards to messageCount 246 //Read message number x, count upwards to messageCount
246 case Retr: { 247 case Retr: {
247 if (status != Quit) { 248 if (status != Quit) {
248 if ((selected)||(mailSize <= headerLimit)) 249 if ((selected)||(mailSize <= headerLimit))
249 { 250 {
250 *stream << "RETR " << messageCount << "\r\n"; 251 *stream << "RETR " << messageCount << "\r\n";
251 } else { //only header 252 } else { //only header
252 *stream << "TOP " << messageCount << " 0\r\n"; 253 *stream << "TOP " << messageCount << " 0\r\n";
253 } 254 }
254 messageCount++; 255 messageCount++;
255 status = Ignore; 256 status = Ignore;
256 break; 257 break;
257 } } 258 } }
258 case Ignore: { 259 case Ignore: {
259 if (status != Quit) { //because of idiotic switch 260 if (status != Quit) { //because of idiotic switch
260 if (response[0] == '+') { 261 if (response[0] == '+') {
261 message = ""; 262 message = "";
262 status = Read; 263 status = Read;
263 if (!socket->canReadLine()) //sync. problems 264 if (!socket->canReadLine()) //sync. problems
264 break; 265 break;
265 response = socket->readLine(); 266 response = socket->readLine();
266 } else errorHandlingWithMsg(ErrUnknownResponse, response); 267 } else errorHandlingWithMsg(ErrUnknownResponse, response);
267 } 268 }
268 } 269 }
269 //add all incoming lines to body. When size is reached, send 270 //add all incoming lines to body. When size is reached, send
270 //message, and go back to read new message 271 //message, and go back to read new message
271 case Read: { 272 case Read: {
272 if (status != Quit) { //because of idiotic switch 273 if (status != Quit) { //because of idiotic switch
273 message += response; 274 message += response;
274 while ( socket->canReadLine() ) { 275 while ( socket->canReadLine() ) {
275 response = socket->readLine(); 276 response = socket->readLine();
276 message += response; 277 message += response;
277 } 278 }
278 emit downloadedSize(message.length()); 279 emit downloadedSize(message.length());
279 int x = message.find("\r\n.\r\n",-5); 280 int x = message.find("\r\n.\r\n",-5);
280 if (x == -1) { 281 if (x == -1) {
281 break; 282 break;
282 } else { //message reach entire size 283 } else { //message reach entire size
283 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active 284 if ( (selected)||(mailSize <= headerLimit)) //mail size limit is not used if late download is active
284 { 285 {
285 emit newMessage(message, messageCount-1, mailSize, TRUE); 286 emit newMessage(message, messageCount-1, mailSize, TRUE);
286 } else { //incomplete mail downloaded 287 } else { //incomplete mail downloaded
287 emit newMessage(message, messageCount-1, mailSize, FALSE); 288 emit newMessage(message, messageCount-1, mailSize, FALSE);
288 } 289 }
289 290
290 if ((messageCount > newMessages)||(selected)) //last message ? 291 if ((messageCount > newMessages)||(selected)) //last message ?
291 { 292 {
292 status = Quit; 293 status = Quit;
293 if (selected) { //grab next from queue 294 if (selected) { //grab next from queue
294 newMessages--; 295 newMessages--;
295 status = Quit; 296 status = Quit;
296 } 297 }
297 } 298 }
298 else 299 else
299 { 300 {
300 *stream << "LIST " << messageCount << "\r\n"; 301 *stream << "LIST " << messageCount << "\r\n";
301 status = Size; 302 status = Size;
302 temp2.setNum(newMessages - lastSync); 303 temp2.setNum(newMessages - lastSync);
303 temp.setNum(messageCount - lastSync); 304 temp.setNum(messageCount - lastSync);
304 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2); 305 emit updateStatus(tr("Retrieving ") + temp + "/" + temp2);
305 306
306 break; 307 break;
307 } 308 }
308 } 309 }
309 } 310 }
310 if (status != Quit) 311 if (status != Quit)
311 break; 312 break;
312 } 313 }
313 case Quit: { 314 case Quit: {
314 *stream << "Quit\r\n"; 315 *stream << "Quit\r\n";
315 status = Done; 316 status = Done;
316 int newM = newMessages - lastSync; 317 int newM = newMessages - lastSync;
317 if (newM > 0) { 318 if (newM > 0) {
318 temp.setNum(newM); 319 temp.setNum(newM);
319 emit updateStatus(temp + tr(" new messages")); 320 emit updateStatus(temp + tr(" new messages"));
320 } else { 321 } else {
321 emit updateStatus(tr("No new messages")); 322 emit updateStatus(tr("No new messages"));
322 } 323 }
323 324
324 socket->close(); 325 socket->close();
325 receiving = FALSE; 326 receiving = FALSE;
326 emit mailTransfered(newM); 327 emit mailTransfered(newM);
327 break; 328 break;
328 } 329 }
329 } 330 }
330 331
331} 332}
diff --git a/noncore/unsupported/mailit/resource.cpp b/noncore/unsupported/mailit/resource.cpp
deleted file mode 100644
index dc19880..0000000
--- a/noncore/unsupported/mailit/resource.cpp
+++ b/dev/null
@@ -1,136 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "qpeapplication.h"
22#include "resource.h"
23#include <qdir.h>
24#include <qfile.h>
25#include <qregexp.h>
26#include <qpixmapcache.h>
27#include <qpainter.h>
28
29#include "inlinepics_p.h"
30
31/*!
32 \class Resource resource.h
33 \brief The Resource class provides access to named resources.
34
35 The resources may be provided from files or other sources.
36*/
37
38/*!
39 \fn Resource::Resource()
40 \internal
41*/
42
43/*!
44 Returns the QPixmap named \a pix. You should avoid including
45 any filename type extension (eg. .png, .xpm).
46*/
47QPixmap Resource::loadPixmap( const QString &pix )
48{
49 QPixmap pm;
50 QString key="QPE_"+pix;
51 if ( !QPixmapCache::find(key,pm) ) {
52 pm.convertFromImage(loadImage(pix));
53 QPixmapCache::insert(key,pm);
54 }
55 return pm;
56}
57
58/*!
59 Returns the QBitmap named \a pix. You should avoid including
60 any filename type extension (eg. .png, .xpm).
61*/
62QBitmap Resource::loadBitmap( const QString &pix )
63{
64 QBitmap bm;
65 bm = loadPixmap(pix);
66 return bm;
67}
68
69/*!
70 Returns the filename of a pixmap named \a pix. You should avoid including
71 any filename type extension (eg. .png, .xpm).
72
73 Normally you will use loadPixmap() rather than this function.
74*/
75QString Resource::findPixmap( const QString &pix )
76{
77 QString picsPath = QPEApplication::qpeDir() + "pics/";
78
79 if ( QFile( picsPath + pix + ".png").exists() )
80 return picsPath + pix + ".png";
81 else if ( QFile( picsPath + pix + ".xpm").exists() )
82 return picsPath + pix + ".xpm";
83 else if ( QFile( picsPath + pix ).exists() )
84 return picsPath + pix;
85
86 //qDebug("Cannot find pixmap: %s", pix.latin1());
87 return QString();
88}
89
90/*!
91 Returns a sound file for a sound named \a name.
92 You should avoid including any filename type extension (eg. .wav, .au, .mp3).
93*/
94QString Resource::findSound( const QString &name )
95{
96 QString picsPath = QPEApplication::qpeDir() + "sounds/";
97
98 QString result;
99 if ( QFile( (result = picsPath + name + ".wav") ).exists() )
100 return result;
101
102 return QString();
103}
104
105/*!
106 Returns a list of all sound names.
107*/
108QStringList Resource::allSounds()
109{
110 QDir resourcedir( QPEApplication::qpeDir() + "sounds/", "*.wav" );
111 QStringList entries = resourcedir.entryList();
112 QStringList result;
113 for (QStringList::Iterator i=entries.begin(); i != entries.end(); ++i)
114 result.append((*i).replace(QRegExp("\\.wav"),""));
115 return result;
116}
117
118/*!
119 Returns the QImage named \a name. You should avoid including
120 any filename type extension (eg. .png, .xpm).
121*/
122QImage Resource::loadImage( const QString &name)
123{
124 QImage img = qembed_findImage(name.latin1());
125 if ( img.isNull() )
126 return QImage(findPixmap(name));
127 return img;
128}
129
130/*!
131 \fn QIconSet Resource::loadIconSet( const QString &name )
132
133 Returns a QIconSet for the pixmap named \a name. A disabled icon is
134 generated that conforms to the Qtopia look & feel. You should avoid
135 including any filename type extension (eg. .png, .xpm).
136*/
diff --git a/noncore/unsupported/mailit/resource.h b/noncore/unsupported/mailit/resource.h
deleted file mode 100644
index 982c58a..0000000
--- a/noncore/unsupported/mailit/resource.h
+++ b/dev/null
@@ -1,80 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef PIXMAPLOADER_H
21#define PIXMAPLOADER_H
22
23#include <qimage.h>
24#include <qbitmap.h>
25#include <qiconset.h>
26#include <qstringlist.h>
27
28class Resource
29{
30public:
31 Resource() {}
32
33 static QImage loadImage( const QString &name);
34
35 static QPixmap loadPixmap( const QString &name );
36 static QBitmap loadBitmap( const QString &name );
37 static QString findPixmap( const QString &name );
38
39 static QIconSet loadIconSet( const QString &name );
40
41 static QString findSound( const QString &name );
42 static QStringList allSounds();
43};
44
45// Inline for compatibility with SHARP ROMs
46inline QIconSet Resource::loadIconSet( const QString &pix )
47{
48 QImage img = loadImage( pix );
49 QPixmap pm;
50 pm.convertFromImage( img );
51 QIconSet is( pm );
52 QIconSet::Size size = pm.width() <= 22 ? QIconSet::Small : QIconSet::Large;
53
54 QPixmap dpm = loadPixmap( pix + "_disabled" );
55
56 #ifndef QT_NO_DEPTH_32// have alpha-blended pixmaps
57 if ( dpm.isNull() ) {
58 QImage dimg( img.width(), img.height(), 32 );
59 for ( int y = 0; y < img.height(); y++ ) {
60 for ( int x = 0; x < img.width(); x++ ) {
61 QRgb p = img.pixel( x, y );
62 uint a = (p & 0xff000000) / 3;
63 p = (p & 0x00ffffff) | (a & 0xff000000);
64 dimg.setPixel( x, y, p );
65 }
66 }
67
68 dimg.setAlphaBuffer( TRUE );
69 dpm.convertFromImage( dimg );
70 }
71#endif
72
73 if ( !dpm.isNull() )
74 is.setPixmap( dpm, size, QIconSet::Disabled );
75
76 return is;
77}
78
79
80#endif
diff --git a/noncore/unsupported/mailit/smtpclient.cpp b/noncore/unsupported/mailit/smtpclient.cpp
index 5b5ef52..51ca50b 100644
--- a/noncore/unsupported/mailit/smtpclient.cpp
+++ b/noncore/unsupported/mailit/smtpclient.cpp
@@ -1,170 +1,170 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "smtpclient.h" 20#include "smtpclient.h"
21#include "emailhandler.h" 21#include "emailhandler.h"
22 22
23SmtpClient::SmtpClient() 23SmtpClient::SmtpClient()
24{ 24{
25 socket = new QSocket(this, "smtpClient"); 25 socket = new QSocket(this, "smtpClient");
26 stream = new QTextStream(socket); 26 stream = new QTextStream(socket);
27 mailList.setAutoDelete(TRUE); 27 mailList.setAutoDelete(TRUE);
28 28
29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int))); 29 connect(socket, SIGNAL(error(int)), this, SLOT(errorHandling(int)));
30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); 30 connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished()));
31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData())); 31 connect(socket, SIGNAL(readyRead()), this, SLOT(incomingData()));
32 32
33 sending = FALSE; 33 sending = FALSE;
34} 34}
35 35
36SmtpClient::~SmtpClient() 36SmtpClient::~SmtpClient()
37{ 37{
38 delete socket; 38 delete socket;
39 delete stream; 39 delete stream;
40} 40}
41 41
42void SmtpClient::newConnection(const QString &target, int port) 42void SmtpClient::newConnection(const QString &target, int port)
43{ 43{
44 if (sending) { 44 if (sending) {
45 qWarning("socket in use, connection refused"); 45 qWarning("socket in use, connection refused");
46 return; 46 return;
47 } 47 }
48 48
49 status = Init; 49 status = Init;
50 sending = TRUE; 50 sending = TRUE;
51 socket->connectToHost(target, port); 51 socket->connectToHost(target, port);
52 52
53 emit updateStatus(tr("DNS lookup")); 53 emit updateStatus(tr("DNS lookup"));
54} 54}
55 55
56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body) 56void SmtpClient::addMail(const QString &from, const QString &subject, const QStringList &to, const QString &body)
57{ 57{
58 RawEmail *mail = new RawEmail; 58 RawEmail *mail = new RawEmail;
59 59
60 mail->from = from; 60 mail->from = from;
61 mail->subject = subject; 61 mail->subject = subject;
62 mail->to = to; 62 mail->to = to;
63 mail->body = body; 63 mail->body = body;
64 64
65 mailList.append(mail); 65 mailList.append(mail);
66} 66}
67 67
68void SmtpClient::connectionEstablished() 68void SmtpClient::connectionEstablished()
69{ 69{
70 emit updateStatus(tr("Connection established")); 70 emit updateStatus(tr("Connection established"));
71 71
72} 72}
73 73
74void SmtpClient::errorHandling(int status) 74void SmtpClient::errorHandling(int status)
75{ 75{
76 errorHandlingWithMsg( status, QString::null ); 76 errorHandlingWithMsg( status, QString::null );
77} 77}
78 78
79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg ) 79void SmtpClient::errorHandlingWithMsg(int status, const QString & EMsg )
80{ 80{
81 emit errorOccurred(status, EMsg ); 81 emit errorOccurred(status, EMsg );
82 socket->close(); 82 socket->close();
83 mailList.clear(); 83 mailList.clear();
84 sending = FALSE; 84 sending = FALSE;
85} 85}
86 86
87void SmtpClient::incomingData() 87void SmtpClient::incomingData()
88{ 88{
89 QString response; 89 QString response;
90 90
91 if (!socket->canReadLine()) 91 if (!socket->canReadLine())
92 return; 92 return;
93 93
94 response = socket->readLine(); 94 response = socket->readLine();
95 switch(status) { 95 switch(status) {
96 case Init: { 96 case Init: {
97 if (response[0] == '2') { 97 if (response[0] == '2') {
98 status = From; 98 status = From;
99 mailPtr = mailList.first(); 99 mailPtr = mailList.first();
100 *stream << "HELO there\r\n"; 100 *stream << "HELO there\r\n";
101 } else errorHandlingWithMsg(ErrUnknownResponse,response); 101 } else errorHandlingWithMsg(ErrUnknownResponse,response);
102 break; 102 break;
103 } 103 }
104 case From: { 104 case From: {
105 if (response[0] == '2') { 105 if (response[0] == '2') {
106 qDebug(mailPtr->from); 106 qDebug(mailPtr->from);
107 *stream << "MAIL FROM: <" << mailPtr->from << ">\r\n"; 107 *stream << "MAIL FROM: " << mailPtr->from << "\r\n";
108 status = Recv; 108 status = Recv;
109 } else errorHandlingWithMsg(ErrUnknownResponse, response ); 109 } else errorHandlingWithMsg(ErrUnknownResponse, response );
110 break; 110 break;
111 } 111 }
112 case Recv: { 112 case Recv: {
113 if (response[0] == '2') { 113 if (response[0] == '2') {
114 it = mailPtr->to.begin(); 114 it = mailPtr->to.begin();
115 if (it == NULL) { 115 if (it == NULL) {
116 errorHandlingWithMsg(ErrUnknownResponse,response); 116 errorHandlingWithMsg(ErrUnknownResponse,response);
117 } 117 }
118 *stream << "RCPT TO: <" << *it << ">\r\n"; 118 *stream << "RCPT TO: " << *it << "\r\n";
119 status = MRcv; 119 status = MRcv;
120 } else errorHandlingWithMsg(ErrUnknownResponse,response); 120 } else errorHandlingWithMsg(ErrUnknownResponse,response);
121 break; 121 break;
122 } 122 }
123 case MRcv: { 123 case MRcv: {
124 if (response[0] == '2') { 124 if (response[0] == '2') {
125 it++; 125 it++;
126 if ( it != mailPtr->to.end() ) { 126 if ( it != mailPtr->to.end() ) {
127 *stream << "RCPT TO: <" << *it << ">\r\n"; 127 *stream << "RCPT TO: " << *it << "\r\n";
128 break; 128 break;
129 } else { 129 } else {
130 status = Data; 130 status = Data;
131 } 131 }
132 } else errorHandlingWithMsg(ErrUnknownResponse,response); 132 } else errorHandlingWithMsg(ErrUnknownResponse,response);
133 } 133 }
134 case Data: { 134 case Data: {
135 if (response[0] == '2') { 135 if (response[0] == '2') {
136 *stream << "DATA\r\n"; 136 *stream << "DATA\r\n";
137 status = Body; 137 status = Body;
138 emit updateStatus(tr("Sending: ") + mailPtr->subject); 138 emit updateStatus(tr("Sending: ") + mailPtr->subject);
139 139
140 } else errorHandlingWithMsg(ErrUnknownResponse,response); 140 } else errorHandlingWithMsg(ErrUnknownResponse,response);
141 break; 141 break;
142 } 142 }
143 case Body: { 143 case Body: {
144 if (response[0] == '3') { 144 if (response[0] == '3') {
145 *stream << mailPtr->body << "\r\n.\r\n"; 145 *stream << mailPtr->body << "\r\n.\r\n";
146 mailPtr = mailList.next(); 146 mailPtr = mailList.next();
147 if (mailPtr != NULL) { 147 if (mailPtr != NULL) {
148 status = From; 148 status = From;
149 } else { 149 } else {
150 status = Quit; 150 status = Quit;
151 } 151 }
152 } else errorHandlingWithMsg(ErrUnknownResponse,response); 152 } else errorHandlingWithMsg(ErrUnknownResponse,response);
153 break; 153 break;
154 } 154 }
155 case Quit: { 155 case Quit: {
156 if (response[0] == '2') { 156 if (response[0] == '2') {
157 *stream << "QUIT\r\n"; 157 *stream << "QUIT\r\n";
158 status = Done; 158 status = Done;
159 QString temp; 159 QString temp;
160 temp.setNum(mailList.count()); 160 temp.setNum(mailList.count());
161 emit updateStatus(tr("Sent ") + temp + tr(" messages")); 161 emit updateStatus(tr("Sent ") + temp + tr(" messages"));
162 emit mailSent(); 162 emit mailSent();
163 mailList.clear(); 163 mailList.clear();
164 sending = FALSE; 164 sending = FALSE;
165 socket->close(); 165 socket->close();
166 } else errorHandlingWithMsg(ErrUnknownResponse,response); 166 } else errorHandlingWithMsg(ErrUnknownResponse,response);
167 break; 167 break;
168 } 168 }
169 } 169 }
170} 170}
diff --git a/noncore/unsupported/mailit/viewatt.cpp b/noncore/unsupported/mailit/viewatt.cpp
index 293e137..3515ba5 100644
--- a/noncore/unsupported/mailit/viewatt.cpp
+++ b/noncore/unsupported/mailit/viewatt.cpp
@@ -1,121 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qt Palmtop Environment. 4** This file is part of Qt Palmtop Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "resource.h" 20#include <qpe/resource.h>
21#include "viewatt.h" 21#include "viewatt.h"
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/mimetype.h> 24#include <qpe/mimetype.h>
25 25
26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f) 26ViewAtt::ViewAtt(QWidget *parent, const char *name, WFlags f)
27 : QMainWindow(parent, name, f) 27 : QMainWindow(parent, name, f)
28{ 28{
29 setCaption(tr("Exploring attatchments")); 29 setCaption(tr("Exploring attatchments"));
30 30
31 setToolBarsMovable( FALSE ); 31 setToolBarsMovable( FALSE );
32 bar = new QToolBar(this); 32 bar = new QToolBar(this);
33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 ); 33 installButton = new QAction( tr( "Install" ), Resource::loadPixmap( "exec" ), QString::null, CTRL + Key_C, this, 0 );
34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) ); 34 connect(installButton, SIGNAL(activated()), this, SLOT(install()) );
35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents")); 35 installButton->setWhatsThis(tr("Click here to install the attachment to your Documents"));
36 36
37 listView = new QListView(this, "AttView"); 37 listView = new QListView(this, "AttView");
38 listView->addColumn( tr("Attatchment") ); 38 listView->addColumn( tr("Attatchment") );
39 listView->addColumn( tr("Type") ); 39 listView->addColumn( tr("Type") );
40 listView->addColumn( tr("Installed") ); 40 listView->addColumn( tr("Installed") );
41 setCentralWidget(listView); 41 setCentralWidget(listView);
42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail")); 42 QWhatsThis::add(listView,QWidget::tr("This is an overview about all attachments in the mail"));
43} 43}
44 44
45void ViewAtt::update(Email *mailIn, bool inbox) 45void ViewAtt::update(Email *mailIn, bool inbox)
46{ 46{
47 QListViewItem *item; 47 QListViewItem *item;
48 Enclosure *ePtr; 48 Enclosure *ePtr;
49
50 49
51 50
51
52 listView->clear(); 52 listView->clear();
53 if (inbox) { 53 if (inbox) {
54 bar->clear(); 54 bar->clear();
55 installButton->addTo( bar ); 55 installButton->addTo( bar );
56 bar->show(); 56 bar->show();
57 } else { 57 } else {
58 bar->hide(); 58 bar->hide();
59 } 59 }
60 60
61 mail = mailIn; 61 mail = mailIn;
62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 62 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
63 63
64 QString isInstalled = tr("No"); 64 QString isInstalled = tr("No");
65 if (ePtr->installed) 65 if (ePtr->installed)
66 isInstalled = tr("Yes"); 66 isInstalled = tr("Yes");
67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled); 67 item = new QListViewItem(listView, ePtr->originalName, ePtr->contentType, isInstalled);
68 68
69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute; 69 const QString& mtypeDef=(const QString&) ePtr->contentType+"/"+ePtr->contentAttribute;
70 70
71 MimeType mt(mtypeDef); 71 MimeType mt(mtypeDef);
72 72
73 item->setPixmap(0, mt.pixmap()); 73 item->setPixmap(0, mt.pixmap());
74 74
75 /* 75 /*
76 if (ePtr->contentType == "TEXT") { 76 if (ePtr->contentType == "TEXT") {
77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0); 77 actions = new QAction( tr("View"), Resource::loadPixmap("TextEditor"), QString::null, CTRL + Key_C, this, 0);
78 actions->addTo(bar); 78 actions->addTo(bar);
79 } 79 }
80 if (ePtr->contentType == "AUDIO") { 80 if (ePtr->contentType == "AUDIO") {
81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0); 81 actions = new QAction( tr("Play"), Resource::loadPixmap("SoundPlayer"), QString::null, CTRL + Key_C, this, 0);
82 actions->addTo(bar); 82 actions->addTo(bar);
83 item->setPixmap(0, Resource::loadPixmap("play")); 83 item->setPixmap(0, Resource::loadPixmap("play"));
84 } 84 }
85 if (ePtr->contentType == "IMAGE") { 85 if (ePtr->contentType == "IMAGE") {
86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0); 86 actions = new QAction( tr("Show"), Resource::loadPixmap("pixmap"), QString::null, CTRL + Key_C, this, 0);
87 actions->addTo(bar); 87 actions->addTo(bar);
88 item->setPixmap(0, Resource::loadPixmap("pixmap")); 88 item->setPixmap(0, Resource::loadPixmap("pixmap"));
89 }*/ 89 }*/
90 } 90 }
91} 91}
92 92
93void ViewAtt::install() 93void ViewAtt::install()
94{ 94{
95 Enclosure *ePtr, *selPtr; 95 Enclosure *ePtr, *selPtr;
96 QListViewItem *item; 96 QListViewItem *item;
97 QString filename; 97 QString filename;
98 DocLnk d; 98 DocLnk d;
99 99
100 item = listView->selectedItem(); 100 item = listView->selectedItem();
101 if (item != NULL) { 101 if (item != NULL) {
102 filename = item->text(0); 102 filename = item->text(0);
103 selPtr = NULL; 103 selPtr = NULL;
104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) { 104 for ( ePtr=mail->files.first(); ePtr != 0; ePtr=mail->files.next() ) {
105 if (ePtr->originalName == filename) 105 if (ePtr->originalName == filename)
106 selPtr = ePtr; 106 selPtr = ePtr;
107 } 107 }
108 108
109 if (selPtr == NULL) { 109 if (selPtr == NULL) {
110 qWarning("Internal error, file is not installed to documents"); 110 qWarning("Internal error, file is not installed to documents");
111 return; 111 return;
112 } 112 }
113 113
114 d.setName(selPtr->originalName); 114 d.setName(selPtr->originalName);
115 d.setFile(selPtr->path + selPtr->name); 115 d.setFile(selPtr->path + selPtr->name);
116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute); 116 d.setType(selPtr->contentType + "/" + selPtr->contentAttribute);
117 d.writeLink(); 117 d.writeLink();
118 selPtr->installed = TRUE; 118 selPtr->installed = TRUE;
119 item->setText(2, tr("Yes")); 119 item->setText(2, tr("Yes"));
120 } 120 }
121} 121}