summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp2
-rw-r--r--libkdepim/ksyncmanager.cpp71
-rw-r--r--libkdepim/ksyncmanager.h3
-rw-r--r--libkdepim/libkdepim.pro15
4 files changed, 87 insertions, 4 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 59be506..f376e6c 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,1319 +1,1321 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#else 40#else
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qprocess.h> 42#include <qprocess.h>
43#endif 43#endif
44 44
45#include <kstaticdeleter.h> 45#include <kstaticdeleter.h>
46#include <kmessagebox.h> 46#include <kmessagebox.h>
47 47
48 48
49#include "externalapphandler.h" 49#include "externalapphandler.h"
50 50
51#include "kpimglobalprefs.h" 51#include "kpimglobalprefs.h"
52 52
53//uncomment line to get debug output 53//uncomment line to get debug output
54//#define DEBUG_EXT_APP_HANDLER 54//#define DEBUG_EXT_APP_HANDLER
55 55
56/********************************************************************************* 56/*********************************************************************************
57 * 57 *
58 ********************************************************************************/ 58 ********************************************************************************/
59 59
60 60
61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
63{ 63{
64 //sourceMessage passes later three parameters: sourceChannel, uid, param1 64 //sourceMessage passes later three parameters: sourceChannel, uid, param1
65 if (_usedSourceParameters == 0) 65 if (_usedSourceParameters == 0)
66 _sourceMessageParameters = "QString,QString)"; 66 _sourceMessageParameters = "QString,QString)";
67 else if (_usedSourceParameters == 1) 67 else if (_usedSourceParameters == 1)
68 _sourceMessageParameters = "(QString,QString,QString)"; 68 _sourceMessageParameters = "(QString,QString,QString)";
69 else if (_usedSourceParameters == 2) 69 else if (_usedSourceParameters == 2)
70 _sourceMessageParameters = "(QString,QString,QString,QString)"; 70 _sourceMessageParameters = "(QString,QString,QString,QString)";
71 else if (_usedSourceParameters == 3) 71 else if (_usedSourceParameters == 3)
72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 72 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
73} 73}
74 74
75/*********************************************************************************/ 75/*********************************************************************************/
76 76
77QCopTransferItem::QCopTransferItem() 77QCopTransferItem::QCopTransferItem()
78{ 78{
79} 79}
80 80
81/*********************************************************************************/ 81/*********************************************************************************/
82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 82bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
83{ 83{
84 84
85#ifndef DESKTOP_VERSION 85#ifndef DESKTOP_VERSION
86 //sourceMessage passes two parameters: sourceChannel, uid 86 //sourceMessage passes two parameters: sourceChannel, uid
87 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 87 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
88#ifdef DEBUG_EXT_APP_HANDLER 88#ifdef DEBUG_EXT_APP_HANDLER
89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 89 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); 90 qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
91#endif 91#endif
92 92
93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 93 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
94 94
95 e << _sourceChannel << uid; 95 e << _sourceChannel << uid;
96 96
97 if (_usedSourceParameters == 1) 97 if (_usedSourceParameters == 1)
98 e << param1; 98 e << param1;
99 else if (_usedSourceParameters == 2) 99 else if (_usedSourceParameters == 2)
100 e << param1 << param2; 100 e << param1 << param2;
101 else if (_usedSourceParameters == 3) 101 else if (_usedSourceParameters == 3)
102 e << param1 << param2 << param3; 102 e << param1 << param2 << param3;
103 103
104 qApp->processEvents(); 104 qApp->processEvents();
105 105
106 return true; 106 return true;
107 107
108#else 108#else
109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 109 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
110 return false; 110 return false;
111#endif 111#endif
112 112
113} 113}
114 114
115 115
116/*********************************************************************************/ 116/*********************************************************************************/
117void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 117void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
118{ 118{
119 119
120 if ( !sourceChannel.isEmpty()) 120 if ( !sourceChannel.isEmpty())
121 _sourceChannel = sourceChannel; 121 _sourceChannel = sourceChannel;
122} 122}
123 123
124 124
125/*********************************************************************************/ 125/*********************************************************************************/
126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 126bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
127{ 127{
128 128
129 // copied from old mail2 129 // copied from old mail2
130/* 130/*
131 static int ii = 0; 131 static int ii = 0;
132 132
133 // block second call 133 // block second call
134 if ( ii < 2 ) { 134 if ( ii < 2 ) {
135 ++ii; 135 ++ii;
136 if ( ii > 1 ) { 136 if ( ii > 1 ) {
137 qDebug("qcop call blocked "); 137 qDebug("qcop call blocked ");
138 return true; 138 return true;
139 } 139 }
140 } 140 }
141*/ 141*/
142 142
143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 143// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
144 144
145 //we are in the target and get a request from the source 145 //we are in the target and get a request from the source
146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 146 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
147 { 147 {
148 148
149 QDataStream stream( data, IO_ReadOnly ); 149 QDataStream stream( data, IO_ReadOnly );
150 150
151 151
152 QString sourceChannel; 152 QString sourceChannel;
153 QString uid; 153 QString uid;
154 QString param1; 154 QString param1;
155 QString param2; 155 QString param2;
156 QString param3; 156 QString param3;
157 157
158 stream >> sourceChannel >> uid; 158 stream >> sourceChannel >> uid;
159 159
160 if (_usedSourceParameters == 0) 160 if (_usedSourceParameters == 0)
161 { 161 {
162 emit receivedMessageFromSource(sourceChannel, uid); 162 emit receivedMessageFromSource(sourceChannel, uid);
163 } 163 }
164 else if (_usedSourceParameters == 1) 164 else if (_usedSourceParameters == 1)
165 { 165 {
166 stream >> param1; 166 stream >> param1;
167 emit receivedMessageFromSource(sourceChannel, uid, param1); 167 emit receivedMessageFromSource(sourceChannel, uid, param1);
168 } 168 }
169 else if (_usedSourceParameters == 2) 169 else if (_usedSourceParameters == 2)
170 { 170 {
171 stream >> param1 >> param2; 171 stream >> param1 >> param2;
172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 172 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
173 } 173 }
174 else if (_usedSourceParameters == 3) 174 else if (_usedSourceParameters == 3)
175 { 175 {
176 stream >> param1 >> param2 >> param3; 176 stream >> param1 >> param2 >> param3;
177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 177 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
178 } 178 }
179 179
180 return true; 180 return true;
181 } 181 }
182 182
183 return false; 183 return false;
184} 184}
185 185
186 186
187/********************************************************************************* 187/*********************************************************************************
188 * 188 *
189 ********************************************************************************/ 189 ********************************************************************************/
190 190
191 191
192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 192QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 193 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
194{ 194{
195 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 195 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
196 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 196 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
197} 197}
198 198
199/*********************************************************************************/ 199/*********************************************************************************/
200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 200bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
201{ 201{
202#ifndef DESKTOP_VERSION 202#ifndef DESKTOP_VERSION
203 //targetMessage passes two parameters: uid, map 203 //targetMessage passes two parameters: uid, map
204 QString targetMessage = _targetMessage + _targetMessageParameters; 204 QString targetMessage = _targetMessage + _targetMessageParameters;
205 205
206#ifdef DEBUG_EXT_APP_HANDLER 206#ifdef DEBUG_EXT_APP_HANDLER
207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 207 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 208 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
209#endif 209#endif
210 210
211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 211 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
212 //US we need no names in the To field. The emailadresses are enough 212 //US we need no names in the To field. The emailadresses are enough
213 213
214 e << uid << nameEmailMap; 214 e << uid << nameEmailMap;
215 215
216 qApp->processEvents(); 216 qApp->processEvents();
217 217
218 return true; 218 return true;
219 219
220#else 220#else
221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 221 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
222 return false; 222 return false;
223#endif 223#endif
224 224
225} 225}
226 226
227 227
228/*********************************************************************************/ 228/*********************************************************************************/
229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 229bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
230{ 230{
231 bool res = QCopTransferItem::appMessage( cmsg, data ); 231 bool res = QCopTransferItem::appMessage( cmsg, data );
232 232
233 if (res == false) 233 if (res == false)
234 { 234 {
235 QDataStream stream( data, IO_ReadOnly ); 235 QDataStream stream( data, IO_ReadOnly );
236 236
237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 237// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
238 238
239 //we are in the source and get an answer from the target 239 //we are in the source and get an answer from the target
240 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 240 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
241 { 241 {
242 QMap<QString,QString> adrMap; 242 QMap<QString,QString> adrMap;
243 QString uid; 243 QString uid;
244 244
245 stream >> uid >> adrMap; 245 stream >> uid >> adrMap;
246 246
247 emit receivedMessageFromTarget(uid, adrMap); 247 emit receivedMessageFromTarget(uid, adrMap);
248 248
249 249
250 return true; 250 return true;
251 } 251 }
252 } 252 }
253 253
254 return false; 254 return false;
255} 255}
256 256
257 257
258/********************************************************************************* 258/*********************************************************************************
259 * 259 *
260 ********************************************************************************/ 260 ********************************************************************************/
261 261
262QCopListTransferItem::~QCopListTransferItem() 262QCopListTransferItem::~QCopListTransferItem()
263{ 263{
264 264
265} 265}
266 266
267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 267QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 268 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
269{ 269{
270 //targetMessage returns later two parameters: uid, and three lists 270 //targetMessage returns later two parameters: uid, and three lists
271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 271 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
272} 272}
273 273
274/*********************************************************************************/ 274/*********************************************************************************/
275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 275bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
276{ 276{
277#ifndef DESKTOP_VERSION 277#ifndef DESKTOP_VERSION
278 //targetMessage passes two parameters: uid, map 278 //targetMessage passes two parameters: uid, map
279 QString targetMessage = _targetMessage + _targetMessageParameters; 279 QString targetMessage = _targetMessage + _targetMessageParameters;
280 280
281#ifdef DEBUG_EXT_APP_HANDLER 281#ifdef DEBUG_EXT_APP_HANDLER
282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 282 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 283 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
284 284
285 285
286 for ( int i = 0; i < list3.count(); i++) 286 for ( int i = 0; i < list3.count(); i++)
287 qDebug("listentry list3: %s",list3[i].latin1()); 287 qDebug("listentry list3: %s",list3[i].latin1());
288#endif 288#endif
289 289
290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 290 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
291 //US we need no names in the To field. The emailadresses are enough 291 //US we need no names in the To field. The emailadresses are enough
292 292
293 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 293 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
294 294
295 qApp->processEvents(); 295 qApp->processEvents();
296 296
297 return true; 297 return true;
298 298
299#else 299#else
300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 300 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
301 return false; 301 return false;
302#endif 302#endif
303 303
304} 304}
305 305
306 306
307/*********************************************************************************/ 307/*********************************************************************************/
308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 308bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
309{ 309{
310 bool res = QCopTransferItem::appMessage( cmsg, data ); 310 bool res = QCopTransferItem::appMessage( cmsg, data );
311#ifdef DEBUG_EXT_APP_HANDLER 311#ifdef DEBUG_EXT_APP_HANDLER
312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 312 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
313#endif 313#endif
314 314
315 if (res == false) 315 if (res == false)
316 { 316 {
317 QDataStream stream( data, IO_ReadOnly ); 317 QDataStream stream( data, IO_ReadOnly );
318 318
319#ifdef DEBUG_EXT_APP_HANDLER 319#ifdef DEBUG_EXT_APP_HANDLER
320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 320 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
321#endif 321#endif
322 322
323 //we are in the source and get an answer from the target 323 //we are in the source and get an answer from the target
324 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 324 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
325 { 325 {
326 QStringList list1; 326 QStringList list1;
327 QStringList list2; 327 QStringList list2;
328 QStringList list3; 328 QStringList list3;
329 QStringList list4; 329 QStringList list4;
330 QStringList list5; 330 QStringList list5;
331 QStringList list6; 331 QStringList list6;
332 QString uid; 332 QString uid;
333 333
334#ifdef DEBUG_EXT_APP_HANDLER 334#ifdef DEBUG_EXT_APP_HANDLER
335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 335 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
336#endif 336#endif
337 337
338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 338 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 339 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
340 340
341 341
342 return true; 342 return true;
343 } 343 }
344 } 344 }
345 345
346 return false; 346 return false;
347} 347}
348 348
349 349
350 350
351/********************************************************************************* 351/*********************************************************************************
352 * 352 *
353 ********************************************************************************/ 353 ********************************************************************************/
354 354
355 355
356ExternalAppHandler *ExternalAppHandler::sInstance = 0; 356ExternalAppHandler *ExternalAppHandler::sInstance = 0;
357static KStaticDeleter<ExternalAppHandler> staticDeleter; 357static KStaticDeleter<ExternalAppHandler> staticDeleter;
358 358
359ExternalAppHandler::ExternalAppHandler() 359ExternalAppHandler::ExternalAppHandler()
360{ 360{
361 mDefaultItems.setAutoDelete(true); 361 mDefaultItems.setAutoDelete(true);
362 362
363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 363 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 364 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 365 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
366 366
367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 367//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 369//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
370 370
371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 371 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
372 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 372 connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
373 373
374 374
375 375
376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 376 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 377 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 378 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
379 379
380 380
381} 381}
382 382
383ExternalAppHandler::~ExternalAppHandler() 383ExternalAppHandler::~ExternalAppHandler()
384{ 384{
385 delete mNameEmailUidListFromKAPITransfer; 385 delete mNameEmailUidListFromKAPITransfer;
386 //delete mFindByEmailFromKAPITransfer; 386 //delete mFindByEmailFromKAPITransfer;
387 delete mDisplayDetails; 387 delete mDisplayDetails;
388 delete mBirthdayListFromKAPITransfer; 388 delete mBirthdayListFromKAPITransfer;
389} 389}
390 390
391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 391void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
392 const QStringList& nameList, 392 const QStringList& nameList,
393 const QStringList& emailList, 393 const QStringList& emailList,
394 const QStringList& uidList, 394 const QStringList& uidList,
395 const QStringList&, 395 const QStringList&,
396 const QStringList&, 396 const QStringList&,
397 const QStringList& ) 397 const QStringList& )
398{ 398{
399 // this method is a conevnient way to reduce the number of parameters I have to pass 399 // this method is a conevnient way to reduce the number of parameters I have to pass
400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 400 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
401} 401}
402 402
403 403
404void ExternalAppHandler::loadConfig() 404void ExternalAppHandler::loadConfig()
405{ 405{
406 406
407 mDefaultItems.clear(); 407 mDefaultItems.clear();
408 mEmailAppAvailable = UNDEFINED; 408 mEmailAppAvailable = UNDEFINED;
409 mPhoneAppAvailable = UNDEFINED; 409 mPhoneAppAvailable = UNDEFINED;
410 mFaxAppAvailable = UNDEFINED; 410 mFaxAppAvailable = UNDEFINED;
411 mSMSAppAvailable = UNDEFINED; 411 mSMSAppAvailable = UNDEFINED;
412 mPagerAppAvailable = UNDEFINED; 412 mPagerAppAvailable = UNDEFINED;
413 mSIPAppAvailable = UNDEFINED; 413 mSIPAppAvailable = UNDEFINED;
414 414
415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
417 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 417 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
418 418
419 //if qtopiapath is not set, fallback to qt 419 //if qtopiapath is not set, fallback to qt
420 if (qtopiapath.isEmpty()) 420 if (qtopiapath.isEmpty())
421 qtopiapath = qtpath; 421 qtopiapath = qtpath;
422 422
423 //if opiepath is not set, fallback to qtopia 423 //if opiepath is not set, fallback to qtopia
424 if (opiepath.isEmpty()) 424 if (opiepath.isEmpty())
425 opiepath = qtopiapath; 425 opiepath = qtopiapath;
426 426
427 427
428 428
429 //mailclients 429 //mailclients
430 QString mailmsg1 = "writeMail(QString,QString)"; 430 QString mailmsg1 = "writeMail(QString,QString)";
431 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 431 QString mailmsg2 = "writeMail(QMap(QString,QString))";
432 432
433 QString undefined = ""; 433 QString undefined = "";
434 434
435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
437 437
438#ifdef DESKTOP_VERSION 438#ifdef DESKTOP_VERSION
439 QString appPath; 439 QString appPath;
440#ifdef _WIN32_ 440#ifdef _WIN32_
441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; 441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe";
442#else 442#else
443 appPath = "/usr/bin/thunderbird"; 443 appPath = "/usr/bin/thunderbird";
444#endif 444#endif
445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); 445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1");
446 446
447#ifdef _WIN32_ 447#ifdef _WIN32_
448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; 448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe";
449#else 449#else
450 appPath = "/usr/bin/mozilla"; 450 appPath = "/usr/bin/mozilla";
451#endif 451#endif
452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); 452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1");
453 453
454 454
455 455
456#else 456#else
457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
458 ( QFile::exists( opiepath + "/bin/ompi" )) || 458 ( QFile::exists( opiepath + "/bin/ompi" )) ||
459 ( QFile::exists( qtpath + "/bin/ompi" ))) 459 ( QFile::exists( qtpath + "/bin/ompi" )))
460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
461 461
462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
463 ( QFile::exists( qtpath + "/bin/qtmail" ))) 463 ( QFile::exists( qtpath + "/bin/qtmail" )))
464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
465 465
466 if ( QFile::exists( opiepath + "/bin/opiemail" )) 466 if ( QFile::exists( opiepath + "/bin/opiemail" ))
467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
468 468
469 if ( QFile::exists( opiepath + "/bin/mailit" )) 469 if ( QFile::exists( opiepath + "/bin/mailit" ))
470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
471#endif 471#endif
472 472
473 473
474 //phoneclients 474 //phoneclients
475 475
476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
479 ( QFile::exists( opiepath + "/bin/kppi" ))) 479 ( QFile::exists( opiepath + "/bin/kppi" )))
480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
481 481
482 //faxclients 482 //faxclients
483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
485 485
486 //smsclients 486 //smsclients
487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
489 489
490 //pagerclients 490 //pagerclients
491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
493 493
494 //sipclients 494 //sipclients
495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); 496 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined);
497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 497 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
498 ( QFile::exists( opiepath + "/bin/kppi" ))) 498 ( QFile::exists( opiepath + "/bin/kppi" )))
499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 499 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
500 500
501} 501}
502 502
503ExternalAppHandler *ExternalAppHandler::instance() 503ExternalAppHandler *ExternalAppHandler::instance()
504{ 504{
505 if ( !sInstance ) { 505 if ( !sInstance ) {
506 sInstance = staticDeleter.setObject( new ExternalAppHandler() ); 506 sInstance = staticDeleter.setObject( new ExternalAppHandler() );
507 sInstance->loadConfig(); 507 sInstance->loadConfig();
508 } 508 }
509 509
510 return sInstance; 510 return sInstance;
511} 511}
512 512
513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) 513void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
514{ 514{
515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); 515 DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); 516 // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
517 mDefaultItems.append(dai); 517 mDefaultItems.append(dai);
518} 518}
519 519
520 520
521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) 521QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
522{ 522{
523 QList<DefaultAppItem> list; 523 QList<DefaultAppItem> list;
524 524
525 DefaultAppItem* dai; 525 DefaultAppItem* dai;
526 526
527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
528 { 528 {
529 if (dai->_type == type) 529 if (dai->_type == type)
530 list.append(dai); 530 list.append(dai);
531 } 531 }
532 532
533 return list; 533 return list;
534} 534}
535 535
536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
537{ 537{
538 DefaultAppItem* dai; 538 DefaultAppItem* dai;
539 539
540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
541 { 541 {
542 if (dai->_type == type && dai->_id == clientid) 542 if (dai->_type == type && dai->_id == clientid)
543 return dai; 543 return dai;
544 } 544 }
545 545
546 return 0; 546 return 0;
547} 547}
548 548
549bool ExternalAppHandler::isEmailAppAvailable() 549bool ExternalAppHandler::isEmailAppAvailable()
550{ 550{
551 551
552 if (mEmailAppAvailable == UNDEFINED) 552 if (mEmailAppAvailable == UNDEFINED)
553 { 553 {
554 int client = KPimGlobalPrefs::instance()->mEmailClient; 554 int client = KPimGlobalPrefs::instance()->mEmailClient;
555 if (client == KPimGlobalPrefs::NONE_EMC) 555 if (client == KPimGlobalPrefs::NONE_EMC)
556 mEmailAppAvailable = UNAVAILABLE; 556 mEmailAppAvailable = UNAVAILABLE;
557 else 557 else
558 mEmailAppAvailable = AVAILABLE; 558 mEmailAppAvailable = AVAILABLE;
559 } 559 }
560 return (mEmailAppAvailable == AVAILABLE); 560 return (mEmailAppAvailable == AVAILABLE);
561 561
562} 562}
563 563
564bool ExternalAppHandler::isSMSAppAvailable() 564bool ExternalAppHandler::isSMSAppAvailable()
565{ 565{
566#ifndef DESKTOP_VERSION 566#ifndef DESKTOP_VERSION
567 if (mSMSAppAvailable == UNDEFINED) 567 if (mSMSAppAvailable == UNDEFINED)
568 { 568 {
569 int client = KPimGlobalPrefs::instance()->mSMSClient; 569 int client = KPimGlobalPrefs::instance()->mSMSClient;
570 if (client == KPimGlobalPrefs::NONE_SMC) 570 if (client == KPimGlobalPrefs::NONE_SMC)
571 mSMSAppAvailable = UNAVAILABLE; 571 mSMSAppAvailable = UNAVAILABLE;
572 else 572 else
573 mSMSAppAvailable = AVAILABLE; 573 mSMSAppAvailable = AVAILABLE;
574 } 574 }
575 575
576 return (mSMSAppAvailable == AVAILABLE); 576 return (mSMSAppAvailable == AVAILABLE);
577#else //DESKTOP_VERSION 577#else //DESKTOP_VERSION
578 return false; 578 return false;
579#endif //DESKTOP_VERSION 579#endif //DESKTOP_VERSION
580} 580}
581 581
582bool ExternalAppHandler::isPhoneAppAvailable() 582bool ExternalAppHandler::isPhoneAppAvailable()
583{ 583{
584#ifndef DESKTOP_VERSION 584#ifndef DESKTOP_VERSION
585 if (mPhoneAppAvailable == UNDEFINED) 585 if (mPhoneAppAvailable == UNDEFINED)
586 { 586 {
587 int client = KPimGlobalPrefs::instance()->mPhoneClient; 587 int client = KPimGlobalPrefs::instance()->mPhoneClient;
588 if (client == KPimGlobalPrefs::NONE_PHC) 588 if (client == KPimGlobalPrefs::NONE_PHC)
589 mPhoneAppAvailable = UNAVAILABLE; 589 mPhoneAppAvailable = UNAVAILABLE;
590 else 590 else
591 mPhoneAppAvailable = AVAILABLE; 591 mPhoneAppAvailable = AVAILABLE;
592 } 592 }
593 593
594 return (mPhoneAppAvailable == AVAILABLE); 594 return (mPhoneAppAvailable == AVAILABLE);
595#else //DESKTOP_VERSION 595#else //DESKTOP_VERSION
596 return false; 596 return false;
597#endif //DESKTOP_VERSION 597#endif //DESKTOP_VERSION
598} 598}
599 599
600bool ExternalAppHandler::isFaxAppAvailable() 600bool ExternalAppHandler::isFaxAppAvailable()
601{ 601{
602#ifndef DESKTOP_VERSION 602#ifndef DESKTOP_VERSION
603 if (mFaxAppAvailable == UNDEFINED) 603 if (mFaxAppAvailable == UNDEFINED)
604 { 604 {
605 int client = KPimGlobalPrefs::instance()->mFaxClient; 605 int client = KPimGlobalPrefs::instance()->mFaxClient;
606 if (client == KPimGlobalPrefs::NONE_FAC) 606 if (client == KPimGlobalPrefs::NONE_FAC)
607 mFaxAppAvailable = UNAVAILABLE; 607 mFaxAppAvailable = UNAVAILABLE;
608 else 608 else
609 mFaxAppAvailable = AVAILABLE; 609 mFaxAppAvailable = AVAILABLE;
610 } 610 }
611 611
612 return (mFaxAppAvailable == AVAILABLE); 612 return (mFaxAppAvailable == AVAILABLE);
613#else //DESKTOP_VERSION 613#else //DESKTOP_VERSION
614 return false; 614 return false;
615#endif //DESKTOP_VERSION 615#endif //DESKTOP_VERSION
616} 616}
617 617
618bool ExternalAppHandler::isPagerAppAvailable() 618bool ExternalAppHandler::isPagerAppAvailable()
619{ 619{
620#ifndef DESKTOP_VERSION 620#ifndef DESKTOP_VERSION
621 if (mPagerAppAvailable == UNDEFINED) 621 if (mPagerAppAvailable == UNDEFINED)
622 { 622 {
623 int client = KPimGlobalPrefs::instance()->mPagerClient; 623 int client = KPimGlobalPrefs::instance()->mPagerClient;
624 if (client == KPimGlobalPrefs::NONE_PAC) 624 if (client == KPimGlobalPrefs::NONE_PAC)
625 mPagerAppAvailable = UNAVAILABLE; 625 mPagerAppAvailable = UNAVAILABLE;
626 else 626 else
627 mPagerAppAvailable = AVAILABLE; 627 mPagerAppAvailable = AVAILABLE;
628 } 628 }
629 629
630 return (mPagerAppAvailable == AVAILABLE); 630 return (mPagerAppAvailable == AVAILABLE);
631#else //DESKTOP_VERSION 631#else //DESKTOP_VERSION
632 return false; 632 return false;
633#endif //DESKTOP_VERSION 633#endif //DESKTOP_VERSION
634} 634}
635 635
636 636
637bool ExternalAppHandler::isSIPAppAvailable() 637bool ExternalAppHandler::isSIPAppAvailable()
638{ 638{
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 if (mSIPAppAvailable == UNDEFINED) 640 if (mSIPAppAvailable == UNDEFINED)
641 { 641 {
642 int client = KPimGlobalPrefs::instance()->mSipClient; 642 int client = KPimGlobalPrefs::instance()->mSipClient;
643 if (client == KPimGlobalPrefs::NONE_SIC) 643 if (client == KPimGlobalPrefs::NONE_SIC)
644 mSIPAppAvailable = UNAVAILABLE; 644 mSIPAppAvailable = UNAVAILABLE;
645 else 645 else
646 mSIPAppAvailable = AVAILABLE; 646 mSIPAppAvailable = AVAILABLE;
647 } 647 }
648 648
649 return (mSIPAppAvailable == AVAILABLE); 649 return (mSIPAppAvailable == AVAILABLE);
650#else //DESKTOP_VERSION 650#else //DESKTOP_VERSION
651 return false; 651 return false;
652#endif //DESKTOP_VERSION 652#endif //DESKTOP_VERSION
653} 653}
654 654
655/************************************************************************** 655/**************************************************************************
656 * 656 *
657 **************************************************************************/ 657 **************************************************************************/
658 658
659 659
660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) 660//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) 661bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
662{ 662{
663 663
664#ifndef DESKTOP_VERSION 664#ifndef DESKTOP_VERSION
665 QString channel; 665 QString channel;
666 QString message2; 666 QString message2;
667 QString parameters2; 667 QString parameters2;
668 668
669 669
670 int client = KPimGlobalPrefs::instance()->mEmailClient; 670 int client = KPimGlobalPrefs::instance()->mEmailClient;
671 if (client == KPimGlobalPrefs::OTHER_EMC) 671 if (client == KPimGlobalPrefs::OTHER_EMC)
672 { 672 {
673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 673 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; 674 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 675 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
676 } 676 }
677 else 677 else
678 { 678 {
679 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 679 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
680 if (!dai) 680 if (!dai)
681 { 681 {
682 qDebug("could not find configured email application."); 682 qDebug("could not find configured email application.");
683 return false; 683 return false;
684 } 684 }
685 channel = dai->_channel; 685 channel = dai->_channel;
686 message2 = dai->_message2; 686 message2 = dai->_message2;
687 parameters2 = dai->_parameters2; 687 parameters2 = dai->_parameters2;
688 } 688 }
689 689
690 //first check if one of the mailers need the emails right in the message. 690 //first check if one of the mailers need the emails right in the message.
691 message2 = translateMessage(message2, emails, urls); 691 message2 = translateMessage(message2, emails, urls);
692 692
693 693
694#ifdef DEBUG_EXT_APP_HANDLER 694#ifdef DEBUG_EXT_APP_HANDLER
695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
697#endif 697#endif
698 698
699 699
700 QCopEnvelope e(channel.latin1(), message2.latin1()); 700 QCopEnvelope e(channel.latin1(), message2.latin1());
701 //US we need no names in the To field. The emailadresses are enough 701 //US we need no names in the To field. The emailadresses are enough
702 702
703 passParameters(&e, parameters2, emails, urls); 703 passParameters(&e, parameters2, emails, urls);
704 704
705 705
706 706
707#else 707#else
708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); 708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1());
709 709
710 QString channel; 710 QString channel;
711 QString message2; 711 QString message2;
712 QString parameters2; 712 QString parameters2;
713 QString message; 713 QString message;
714 QString parameters; 714 QString parameters;
715 715
716 716
717 int client = KPimGlobalPrefs::instance()->mEmailClient; 717 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC) 718 if (client == KPimGlobalPrefs::OTHER_EMC)
719 { 719 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 721 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2; 722 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage2;
723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 723 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2; 724 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters2;
725 } 725 }
726 else 726 else
727 { 727 {
728 DefaultAppItem* dai = getDefaultItem(EMAIL, client); 728 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
729 if (!dai) 729 if (!dai)
730 { 730 {
731 qDebug("could not find configured email application."); 731 qDebug("could not find configured email application.");
732 return false; 732 return false;
733 } 733 }
734 channel = dai->_channel; 734 channel = dai->_channel;
735 message2 = dai->_message2; 735 message2 = dai->_message2;
736 parameters2 = dai->_parameters2; 736 parameters2 = dai->_parameters2;
737 message = dai->_message; 737 message = dai->_message;
738 parameters = dai->_parameters; 738 parameters = dai->_parameters;
739 } 739 }
740 740
741 //first check if one of the mailers need the emails right in the message. 741 //first check if one of the mailers need the emails right in the message.
742 message2 = translateMessage(message2, emails, urls); 742 message2 = translateMessage(message2, emails, urls);
743#ifdef DEBUG_EXT_APP_HANDLER 743#ifdef DEBUG_EXT_APP_HANDLER
744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 744 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 745 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
746#endif 746#endif
747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); 747 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
748 //KMessageBox::sorry( 0, message2 ); 748 //KMessageBox::sorry( 0, message2 );
749 QProcess * proc = new QProcess( this ); 749 QProcess * proc = new QProcess( this );
750 int i = 0; 750 int i = 0;
751 proc->addArgument( channel ); 751 proc->addArgument( channel );
752 752
753 if ( message.find (" " ) > 0 ) { 753 if ( message.find (" " ) > 0 ) {
754 QStringList list = QStringList::split( " ", message ); 754 QStringList list = QStringList::split( " ", message );
755 int i = 0; 755 int i = 0;
756 while ( i < list.count ( ) ) { 756 while ( i < list.count ( ) ) {
757 //qDebug("add%sdd ",list[i].latin1() ); 757 //qDebug("add%sdd ",list[i].latin1() );
758 proc->addArgument( list[i] ); 758 proc->addArgument( list[i] );
759 //KMessageBox::sorry( 0,list[i]); 759 //KMessageBox::sorry( 0,list[i]);
760 ++i; 760 ++i;
761 } 761 }
762 } else { 762 } else {
763 proc->addArgument(message ); 763 proc->addArgument(message );
764 //KMessageBox::sorry( 0, message ); 764 //KMessageBox::sorry( 0, message );
765 765
766 } 766 }
767 767
768 parameters2 = translateMessage(parameters2, urls, "" ); 768 parameters2 = translateMessage(parameters2, urls, "" );
769 QString arg = "to='%1'"; 769 QString arg = "to='%1'";
770 arg = arg.arg( emails ) + ","+parameters2;; 770 arg = arg.arg( emails ) + ","+parameters2;;
771 771
772 //KMessageBox::sorry( 0,arg ); 772 //KMessageBox::sorry( 0,arg );
773 //qDebug("2add%sdd ",arg.latin1() ); 773 //qDebug("2add%sdd ",arg.latin1() );
774 proc->addArgument( arg); 774 proc->addArgument( arg);
775 proc->launch(""); 775 proc->launch("");
776#endif 776#endif
777 777
778 return true; 778 return true;
779} 779}
780 780
781/************************************************************************** 781/**************************************************************************
782 * 782 *
783 **************************************************************************/ 783 **************************************************************************/
784 784
785 785
786//calls the emailapplication and creates a mail with parameter emails as recipients 786//calls the emailapplication and creates a mail with parameter emails as recipients
787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 787bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
788{ 788{
789 789
790 QString channel; 790 QString channel;
791 QString message; 791 QString message;
792 QString parameters; 792 QString parameters;
793 793
794 794
795 int client = KPimGlobalPrefs::instance()->mEmailClient; 795 int client = KPimGlobalPrefs::instance()->mEmailClient;
796 if (client == KPimGlobalPrefs::OTHER_EMC) 796 if (client == KPimGlobalPrefs::OTHER_EMC)
797 { 797 {
798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 798 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 799 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 800 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
801 } 801 }
802 else 802 else
803 { 803 {
804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 804 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
805 if (!dai) 805 if (!dai)
806 { 806 {
807 qDebug("could not find configured email application."); 807 qDebug("could not find configured email application.");
808 return false; 808 return false;
809 } 809 }
810 channel = dai->_channel; 810 channel = dai->_channel;
811 message = dai->_message; 811 message = dai->_message;
812 parameters = dai->_parameters; 812 parameters = dai->_parameters;
813 } 813 }
814 814
815#ifdef DESKTOP_VERSION 815#ifdef DESKTOP_VERSION
816 //message = channel + " " +message + " \""+ parameters + "\""; 816 //message = channel + " " +message + " \""+ parameters + "\"";
817#endif 817#endif
818 //first check if one of the mailers need the emails right in the message. 818 //first check if one of the mailers need the emails right in the message.
819 message = translateMessage(message, name, emailadress); 819 message = translateMessage(message, name, emailadress);
820 820
821#ifdef DEBUG_EXT_APP_HANDLER 821#ifdef DEBUG_EXT_APP_HANDLER
822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 822 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 823 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
824#endif 824#endif
825 825
826#ifndef DESKTOP_VERSION 826#ifndef DESKTOP_VERSION
827 QCopEnvelope e(channel.latin1(), message.latin1()); 827 QCopEnvelope e(channel.latin1(), message.latin1());
828 //US we need no names in the To field. The emailadresses are enough 828 //US we need no names in the To field. The emailadresses are enough
829 829
830 passParameters(&e, parameters, name, emailadress); 830 passParameters(&e, parameters, name, emailadress);
831#else // DESKTOP_VERSION 831#else // DESKTOP_VERSION
832 832
833 //KMessageBox::sorry( 0,channel ); 833 //KMessageBox::sorry( 0,channel );
834 QProcess * proc = new QProcess( this ); 834 QProcess * proc = new QProcess( this );
835 proc->addArgument( channel ); 835 proc->addArgument( channel );
836 if ( message.find (" " ) > 0 ) { 836 if ( message.find (" " ) > 0 ) {
837 QStringList list = QStringList::split( " ", message ); 837 QStringList list = QStringList::split( " ", message );
838 int i = 0; 838 int i = 0;
839 while ( i < list.count ( ) ) { 839 while ( i < list.count ( ) ) {
840 //qDebug("add%sdd ",list[i].latin1() ); 840 //qDebug("add%sdd ",list[i].latin1() );
841 proc->addArgument( list[i] ); 841 proc->addArgument( list[i] );
842 //KMessageBox::sorry( 0,list[i]); 842 //KMessageBox::sorry( 0,list[i]);
843 ++i; 843 ++i;
844 } 844 }
845 } else { 845 } else {
846 proc->addArgument(message ); 846 proc->addArgument(message );
847 847
848 } 848 }
849 parameters = translateMessage(parameters, name, emailadress); 849 parameters = translateMessage(parameters, name, emailadress);
850
851 //KMessageBox::information(0,parameters);
850 proc->addArgument( parameters ); 852 proc->addArgument( parameters );
851 proc->launch(""); 853 proc->launch("");
852#endif 854#endif
853 855
854 return true; 856 return true;
855} 857}
856 858
857/************************************************************************** 859/**************************************************************************
858 * 860 *
859 **************************************************************************/ 861 **************************************************************************/
860 862
861//calls the emailapplication and creates a mail with parameter as recipients 863//calls the emailapplication and creates a mail with parameter as recipients
862// parameters format is 864// parameters format is
863// NAME <EMAIL>:SUBJECT 865// NAME <EMAIL>:SUBJECT
864bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 866bool ExternalAppHandler::mailToOneContact( const QString& adressline )
865{ 867{
866 QString line = adressline; 868 QString line = adressline;
867 869
868 int first = line.find( "<"); 870 int first = line.find( "<");
869 int last = line.find( ">"); 871 int last = line.find( ">");
870 QString name = line.left(first); 872 QString name = line.left(first);
871 QString emailadress = line.mid(first+1, last-first-1); 873 QString emailadress = line.mid(first+1, last-first-1);
872 874
873 //Subject can not be handled right now. 875 //Subject can not be handled right now.
874 return mailToOneContact( name, emailadress ); 876 return mailToOneContact( name, emailadress );
875 877
876} 878}
877 879
878 880
879/************************************************************************** 881/**************************************************************************
880 * 882 *
881 **************************************************************************/ 883 **************************************************************************/
882 884
883//calls the phoneapplication with the number 885//calls the phoneapplication with the number
884bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 886bool ExternalAppHandler::callByPhone( const QString& phonenumber )
885{ 887{
886#ifndef DESKTOP_VERSION 888#ifndef DESKTOP_VERSION
887 QString channel; 889 QString channel;
888 QString message; 890 QString message;
889 QString parameters; 891 QString parameters;
890 892
891 893
892 int client = KPimGlobalPrefs::instance()->mPhoneClient; 894 int client = KPimGlobalPrefs::instance()->mPhoneClient;
893 if (client == KPimGlobalPrefs::OTHER_PHC) 895 if (client == KPimGlobalPrefs::OTHER_PHC)
894 { 896 {
895 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 897 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
896 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 898 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
897 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 899 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
898 } 900 }
899 else 901 else
900 { 902 {
901 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 903 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
902 if (!dai) 904 if (!dai)
903 { 905 {
904 qDebug("could not find configured phone application."); 906 qDebug("could not find configured phone application.");
905 return false; 907 return false;
906 } 908 }
907 channel = dai->_channel; 909 channel = dai->_channel;
908 message = dai->_message; 910 message = dai->_message;
909 parameters = dai->_parameters; 911 parameters = dai->_parameters;
910 } 912 }
911 913
912 914
913 //first check if one of the mailers need the emails right in the message. 915 //first check if one of the mailers need the emails right in the message.
914 message = translateMessage(message, phonenumber, ""); 916 message = translateMessage(message, phonenumber, "");
915 917
916 918
917#ifdef DEBUG_EXT_APP_HANDLER 919#ifdef DEBUG_EXT_APP_HANDLER
918 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 920 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
919 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 921 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
920#endif 922#endif
921 923
922 QCopEnvelope e(channel.latin1(), message.latin1()); 924 QCopEnvelope e(channel.latin1(), message.latin1());
923 //US we need no names in the To field. The emailadresses are enough 925 //US we need no names in the To field. The emailadresses are enough
924 926
925 passParameters(&e, parameters, phonenumber, ""); 927 passParameters(&e, parameters, phonenumber, "");
926 928
927 929
928#else 930#else
929 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 931 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
930#endif 932#endif
931 933
932 934
933 return true; 935 return true;
934} 936}
935 937
936/************************************************************************** 938/**************************************************************************
937 * 939 *
938 **************************************************************************/ 940 **************************************************************************/
939 941
940//calls the smsapplication with the number 942//calls the smsapplication with the number
941bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 943bool ExternalAppHandler::callBySMS( const QString& phonenumber )
942{ 944{
943#ifndef DESKTOP_VERSION 945#ifndef DESKTOP_VERSION
944 QString channel; 946 QString channel;
945 QString message; 947 QString message;
946 QString parameters; 948 QString parameters;
947 949
948 950
949 int client = KPimGlobalPrefs::instance()->mSMSClient; 951 int client = KPimGlobalPrefs::instance()->mSMSClient;
950 if (client == KPimGlobalPrefs::OTHER_SMC) 952 if (client == KPimGlobalPrefs::OTHER_SMC)
951 { 953 {
952 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 954 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
953 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 955 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
954 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 956 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
955 } 957 }
956 else 958 else
957 { 959 {
958 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 960 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
959 if (!dai) 961 if (!dai)
960 { 962 {
961 qDebug("could not find configured sms application."); 963 qDebug("could not find configured sms application.");
962 return false; 964 return false;
963 } 965 }
964 channel = dai->_channel; 966 channel = dai->_channel;
965 message = dai->_message; 967 message = dai->_message;
966 parameters = dai->_parameters; 968 parameters = dai->_parameters;
967 } 969 }
968 970
969 971
970 //first check if one of the mailers need the emails right in the message. 972 //first check if one of the mailers need the emails right in the message.
971 message = translateMessage(message, phonenumber, ""); 973 message = translateMessage(message, phonenumber, "");
972 974
973 975
974#ifdef DEBUG_EXT_APP_HANDLER 976#ifdef DEBUG_EXT_APP_HANDLER
975 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 977 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
976 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 978 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
977#endif 979#endif
978 980
979 QCopEnvelope e(channel.latin1(), message.latin1()); 981 QCopEnvelope e(channel.latin1(), message.latin1());
980 //US we need no names in the To field. The emailadresses are enough 982 //US we need no names in the To field. The emailadresses are enough
981 983
982 passParameters(&e, parameters, phonenumber, ""); 984 passParameters(&e, parameters, phonenumber, "");
983 985
984 986
985#else 987#else
986 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 988 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
987#endif 989#endif
988 990
989 991
990 return true; 992 return true;
991} 993}
992 994
993/************************************************************************** 995/**************************************************************************
994 * 996 *
995 **************************************************************************/ 997 **************************************************************************/
996 998
997//calls the pagerapplication with the number 999//calls the pagerapplication with the number
998bool ExternalAppHandler::callByPager( const QString& pagernumber ) 1000bool ExternalAppHandler::callByPager( const QString& pagernumber )
999{ 1001{
1000#ifndef DESKTOP_VERSION 1002#ifndef DESKTOP_VERSION
1001 QString channel; 1003 QString channel;
1002 QString message; 1004 QString message;
1003 QString parameters; 1005 QString parameters;
1004 1006
1005 1007
1006 int client = KPimGlobalPrefs::instance()->mPagerClient; 1008 int client = KPimGlobalPrefs::instance()->mPagerClient;
1007 if (client == KPimGlobalPrefs::OTHER_PAC) 1009 if (client == KPimGlobalPrefs::OTHER_PAC)
1008 { 1010 {
1009 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 1011 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
1010 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 1012 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
1011 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 1013 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
1012 } 1014 }
1013 else 1015 else
1014 { 1016 {
1015 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 1017 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
1016 if (!dai) 1018 if (!dai)
1017 { 1019 {
1018 qDebug("could not find configured pager application."); 1020 qDebug("could not find configured pager application.");
1019 return false; 1021 return false;
1020 } 1022 }
1021 channel = dai->_channel; 1023 channel = dai->_channel;
1022 message = dai->_message; 1024 message = dai->_message;
1023 parameters = dai->_parameters; 1025 parameters = dai->_parameters;
1024 } 1026 }
1025 1027
1026 1028
1027 //first check if one of the mailers need the emails right in the message. 1029 //first check if one of the mailers need the emails right in the message.
1028 message = translateMessage(message, pagernumber, ""); 1030 message = translateMessage(message, pagernumber, "");
1029 1031
1030 1032
1031#ifdef DEBUG_EXT_APP_HANDLER 1033#ifdef DEBUG_EXT_APP_HANDLER
1032 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1034 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1033 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 1035 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
1034#endif 1036#endif
1035 1037
1036 QCopEnvelope e(channel.latin1(), message.latin1()); 1038 QCopEnvelope e(channel.latin1(), message.latin1());
1037 //US we need no names in the To field. The emailadresses are enough 1039 //US we need no names in the To field. The emailadresses are enough
1038 1040
1039 passParameters(&e, parameters, pagernumber, ""); 1041 passParameters(&e, parameters, pagernumber, "");
1040 1042
1041 1043
1042#else 1044#else
1043 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 1045 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
1044#endif 1046#endif
1045 1047
1046 1048
1047 return true; 1049 return true;
1048} 1050}
1049 1051
1050/************************************************************************** 1052/**************************************************************************
1051 * 1053 *
1052 **************************************************************************/ 1054 **************************************************************************/
1053 1055
1054//calls the faxapplication with the number 1056//calls the faxapplication with the number
1055bool ExternalAppHandler::callByFax( const QString& faxnumber ) 1057bool ExternalAppHandler::callByFax( const QString& faxnumber )
1056{ 1058{
1057#ifndef DESKTOP_VERSION 1059#ifndef DESKTOP_VERSION
1058 QString channel; 1060 QString channel;
1059 QString message; 1061 QString message;
1060 QString parameters; 1062 QString parameters;
1061 1063
1062 1064
1063 int client = KPimGlobalPrefs::instance()->mFaxClient; 1065 int client = KPimGlobalPrefs::instance()->mFaxClient;
1064 if (client == KPimGlobalPrefs::OTHER_FAC) 1066 if (client == KPimGlobalPrefs::OTHER_FAC)
1065 { 1067 {
1066 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 1068 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
1067 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 1069 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
1068 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 1070 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
1069 } 1071 }
1070 else 1072 else
1071 { 1073 {
1072 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 1074 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
1073 if (!dai) 1075 if (!dai)
1074 { 1076 {
1075 qDebug("could not find configured fax application."); 1077 qDebug("could not find configured fax application.");
1076 return false; 1078 return false;
1077 } 1079 }
1078 channel = dai->_channel; 1080 channel = dai->_channel;
1079 message = dai->_message; 1081 message = dai->_message;
1080 parameters = dai->_parameters; 1082 parameters = dai->_parameters;
1081 } 1083 }
1082 1084
1083 1085
1084 //first check if one of the mailers need the emails right in the message. 1086 //first check if one of the mailers need the emails right in the message.
1085 message = translateMessage(message, faxnumber, ""); 1087 message = translateMessage(message, faxnumber, "");
1086 1088
1087 1089
1088#ifdef DEBUG_EXT_APP_HANDLER 1090#ifdef DEBUG_EXT_APP_HANDLER
1089 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1091 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1090 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 1092 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
1091#endif 1093#endif
1092 1094
1093 QCopEnvelope e(channel.latin1(), message.latin1()); 1095 QCopEnvelope e(channel.latin1(), message.latin1());
1094 //US we need no names in the To field. The emailadresses are enough 1096 //US we need no names in the To field. The emailadresses are enough
1095 1097
1096 passParameters(&e, parameters, faxnumber, ""); 1098 passParameters(&e, parameters, faxnumber, "");
1097 1099
1098 1100
1099#else 1101#else
1100 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 1102 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
1101#endif 1103#endif
1102 1104
1103 1105
1104 return true; 1106 return true;
1105} 1107}
1106 1108
1107/************************************************************************** 1109/**************************************************************************
1108 * 1110 *
1109 **************************************************************************/ 1111 **************************************************************************/
1110 1112
1111//calls the sipapplication with the number 1113//calls the sipapplication with the number
1112bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 1114bool ExternalAppHandler::callBySIP( const QString& sipnumber )
1113{ 1115{
1114#ifndef DESKTOP_VERSION 1116#ifndef DESKTOP_VERSION
1115 QString channel; 1117 QString channel;
1116 QString message; 1118 QString message;
1117 QString parameters; 1119 QString parameters;
1118 1120
1119 1121
1120 int client = KPimGlobalPrefs::instance()->mSipClient; 1122 int client = KPimGlobalPrefs::instance()->mSipClient;
1121 if (client == KPimGlobalPrefs::OTHER_SIC) 1123 if (client == KPimGlobalPrefs::OTHER_SIC)
1122 { 1124 {
1123 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1125 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1124 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1126 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1125 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1127 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1126 } 1128 }
1127 else 1129 else
1128 { 1130 {
1129 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1131 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1130 if (!dai) 1132 if (!dai)
1131 { 1133 {
1132 qDebug("could not find configured sip application."); 1134 qDebug("could not find configured sip application.");
1133 return false; 1135 return false;
1134 } 1136 }
1135 channel = dai->_channel; 1137 channel = dai->_channel;
1136 message = dai->_message; 1138 message = dai->_message;
1137 parameters = dai->_parameters; 1139 parameters = dai->_parameters;
1138 } 1140 }
1139 1141
1140 1142
1141 //first check if one of the sip apps need the emails right in the message. 1143 //first check if one of the sip apps need the emails right in the message.
1142 message = translateMessage(message, sipnumber, ""); 1144 message = translateMessage(message, sipnumber, "");
1143 1145
1144 1146
1145#ifdef DEBUG_EXT_APP_HANDLER 1147#ifdef DEBUG_EXT_APP_HANDLER
1146 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1148 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1147 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1149 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1148#endif 1150#endif
1149 1151
1150 QCopEnvelope e(channel.latin1(), message.latin1()); 1152 QCopEnvelope e(channel.latin1(), message.latin1());
1151 //US we need no names in the To field. The emailadresses are enough 1153 //US we need no names in the To field. The emailadresses are enough
1152 1154
1153 passParameters(&e, parameters, sipnumber, ""); 1155 passParameters(&e, parameters, sipnumber, "");
1154 1156
1155 1157
1156#else 1158#else
1157 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1159 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1158#endif 1160#endif
1159 1161
1160 1162
1161 return true; 1163 return true;
1162} 1164}
1163 1165
1164 1166
1165/************************************************************************** 1167/**************************************************************************
1166 * 1168 *
1167 **************************************************************************/ 1169 **************************************************************************/
1168 1170
1169 1171
1170QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1172QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1171{ 1173{
1172 message = message.replace( QRegExp("%1"), param1 ); 1174 message = message.replace( QRegExp("%1"), param1 );
1173 return message.replace( QRegExp("%2"), param2 ); 1175 return message.replace( QRegExp("%2"), param2 );
1174} 1176}
1175 1177
1176/************************************************************************** 1178/**************************************************************************
1177 * 1179 *
1178 **************************************************************************/ 1180 **************************************************************************/
1179 1181
1180void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1182void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1181{ 1183{
1182#ifndef DESKTOP_VERSION 1184#ifndef DESKTOP_VERSION
1183 QMap<QString, QString> valmap; 1185 QMap<QString, QString> valmap;
1184 bool useValMap = false; 1186 bool useValMap = false;
1185 1187
1186 // first extract all parts of the parameters. 1188 // first extract all parts of the parameters.
1187 QStringList paramlist = QStringList::split(";", parameters); 1189 QStringList paramlist = QStringList::split(";", parameters);
1188 1190
1189 //Now check how many parts we have. 1191 //Now check how many parts we have.
1190 //=0 :no params to pass 1192 //=0 :no params to pass
1191 //>0 :parameters to pass 1193 //>0 :parameters to pass
1192 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1194 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1193 { 1195 {
1194 QString param = (*it); 1196 QString param = (*it);
1195 QStringList keyvallist = QStringList::split("=", param); 1197 QStringList keyvallist = QStringList::split("=", param);
1196 1198
1197 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1199 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1198 QStringList::Iterator it2 = keyvallist.begin(); 1200 QStringList::Iterator it2 = keyvallist.begin();
1199 QString key = (*it2); 1201 QString key = (*it2);
1200 key = key.replace( QRegExp("%1"), param1 ); 1202 key = key.replace( QRegExp("%1"), param1 );
1201 key = key.replace( QRegExp("%2"), param2 ); 1203 key = key.replace( QRegExp("%2"), param2 );
1202 ++it2; 1204 ++it2;
1203 1205
1204 if(it2 != keyvallist.end()) 1206 if(it2 != keyvallist.end())
1205 { 1207 {
1206 QString value = (*it2); 1208 QString value = (*it2);
1207 value = value.replace( QRegExp("%1"), param1 ); 1209 value = value.replace( QRegExp("%1"), param1 );
1208 value = value.replace( QRegExp("%2"), param2 ); 1210 value = value.replace( QRegExp("%2"), param2 );
1209 1211
1210 valmap.insert(key, value); 1212 valmap.insert(key, value);
1211 useValMap = true; 1213 useValMap = true;
1212 } 1214 }
1213 else 1215 else
1214 { 1216 {
1215 // qDebug("pass parameter << %s", key.latin1()); 1217 // qDebug("pass parameter << %s", key.latin1());
1216 (*e) << key; 1218 (*e) << key;
1217 } 1219 }
1218 } 1220 }
1219 1221
1220 if (useValMap == true) 1222 if (useValMap == true)
1221 (*e) << valmap; 1223 (*e) << valmap;
1222 1224
1223#endif 1225#endif
1224 1226
1225} 1227}
1226 1228
1227 1229
1228 1230
1229/************************************************************************** 1231/**************************************************************************
1230 * 1232 *
1231 **************************************************************************/ 1233 **************************************************************************/
1232 1234
1233void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1235void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
1234{ 1236{
1235 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); 1237 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
1236 if ( cmsg == "nextView()" ) { 1238 if ( cmsg == "nextView()" ) {
1237 qDebug("nextView()"); 1239 qDebug("nextView()");
1238 QTimer::singleShot( 0, this, SIGNAL ( nextView() )); 1240 QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
1239 return; 1241 return;
1240 } 1242 }
1241 if ( cmsg == "callContactdialog()" ) { 1243 if ( cmsg == "callContactdialog()" ) {
1242 qDebug("callContactdialog()"); 1244 qDebug("callContactdialog()");
1243 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); 1245 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
1244 return; 1246 return;
1245 } 1247 }
1246 if ( cmsg == "doRingSync" ) { 1248 if ( cmsg == "doRingSync" ) {
1247 qDebug("doRingSync"); 1249 qDebug("doRingSync");
1248 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); 1250 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
1249 return; 1251 return;
1250 } 1252 }
1251 1253
1252 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1254 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1253 if (!res) 1255 if (!res)
1254 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1256 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1255 1257
1256 if (!res) 1258 if (!res)
1257 res = mDisplayDetails->appMessage( cmsg, data ); 1259 res = mDisplayDetails->appMessage( cmsg, data );
1258 1260
1259// if (!res) 1261// if (!res)
1260// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1262// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1261} 1263}
1262 1264
1263 1265
1264 1266
1265bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1267bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1266{ 1268{
1267 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1269 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1268 // maybe we are sending to KA/Pi fom a different worldd... 1270 // maybe we are sending to KA/Pi fom a different worldd...
1269 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application 1271 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application
1270 // for that reason we send the current QApplication::desktop()->width() to KA/Pi 1272 // for that reason we send the current QApplication::desktop()->width() to KA/Pi
1271 //qDebug("UID %s ", sessionuid.latin1()); 1273 //qDebug("UID %s ", sessionuid.latin1());
1272 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); 1274 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() ));
1273 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1275 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1274} 1276}
1275 1277
1276bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1278bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1277{ 1279{
1278 QStringList list4, list5, list6; 1280 QStringList list4, list5, list6;
1279 1281
1280 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1282 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1281 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1283 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1282} 1284}
1283 1285
1284bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1286bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1285{ 1287{
1286 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1288 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1287 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1289 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1288} 1290}
1289 1291
1290bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1292bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1291{ 1293{
1292 QStringList list4, list5, list6; 1294 QStringList list4, list5, list6;
1293 1295
1294 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1296 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1295 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1297 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1296} 1298}
1297 1299
1298bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1300bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1299{ 1301{
1300 mDisplayDetails->setSourceChannel(""); 1302 mDisplayDetails->setSourceChannel("");
1301 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1303 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1302} 1304}
1303 1305
1304bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1306bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1305{ 1307{
1306 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1308 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1307 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1309 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1308} 1310}
1309 1311
1310bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 1312bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
1311{ 1313{
1312 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1314 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1313 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1315 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1314} 1316}
1315 1317
1316 1318
1317 1319
1318 1320
1319 1321
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index b7929ec..5708dfc 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1816 +1,1883 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52#include <qapplication.h> 52#include <qapplication.h>
53 53
54#include <klocale.h> 54#include <klocale.h>
55#include <kglobal.h> 55#include <kglobal.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58 58
59QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
60 60
61 61
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 64{
65 mServerSocket = 0; 65 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
67 bar->setCaption (""); 67 bar->setCaption ("");
68 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
69 69
70 70
71} 71}
72 72
73KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
74{ 74{
75 delete bar; 75 delete bar;
76} 76}
77 77
78void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
79{ 79{
80 mDefFileName = s ; 80 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 82 enableQuick( false );
83} 83}
84 84
85void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
86{ 86{
87 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 88 mSyncMenu->clear();
89 89
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 100 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 102 }
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
129 temp->writeConfig(&config); 129 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
131 temp->writeConfig(&config); 131 temp->writeConfig(&config);
132 config.setGroup("General"); 132 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
159 QDir app_dir; 159 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
164 } 164 }
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
169 } 169 }
170#endif 170#endif
171 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
173} 173}
174void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = ""; 199 mCurrentResourceLocal = "";
200 emit multiResourceSyncStart( false ); 200 emit multiResourceSyncStart( false );
201 if ( action == 5000 ) 201 if ( action == 5000 )
202 return; 202 return;
203 mSyncWithDesktop = false; 203 mSyncWithDesktop = false;
204 if ( action == 0 ) { 204 if ( action == 0 ) {
205 205
206 // seems to be a Qt2 event handling bug 206 // seems to be a Qt2 event handling bug
207 // syncmenu.clear causes a segfault at first time 207 // syncmenu.clear causes a segfault at first time
208 // when we call it after the main event loop, it is ok 208 // when we call it after the main event loop, it is ok
209 // same behaviour when calling OM/Pi via QCOP for the first time 209 // same behaviour when calling OM/Pi via QCOP for the first time
210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 210 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
211 //confSync(); 211 //confSync();
212 212
213 return; 213 return;
214 } 214 }
215 if ( action == 1 ) { 215 if ( action == 1 ) {
216 multiSync( true ); 216 multiSync( true );
217 return; 217 return;
218 } 218 }
219 if ( action == 2 ) { 219 if ( action == 2 ) {
220 enableQuick(); 220 enableQuick();
221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 221 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
222 return; 222 return;
223 } 223 }
224 if ( action == 3 ) { 224 if ( action == 3 ) {
225 delete mServerSocket; 225 delete mServerSocket;
226 mServerSocket = 0; 226 mServerSocket = 0;
227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 227 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
228 return; 228 return;
229 } 229 }
230 230
231 if (blockSave()) 231 if (blockSave())
232 return; 232 return;
233 233
234 setBlockSave(true); 234 setBlockSave(true);
235 bool silent = false; 235 bool silent = false;
236 if ( action == 999 ) { 236 if ( action == 999 ) {
237 //special mode for silent syncing 237 //special mode for silent syncing
238 action = 1000; 238 action = 1000;
239 silent = true; 239 silent = true;
240 } 240 }
241 241
242 mCurrentSyncProfile = action - 1000 ; 242 mCurrentSyncProfile = action - 1000 ;
243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 243 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
244 mCurrentSyncName = mLocalMachineName ; 244 mCurrentSyncName = mLocalMachineName ;
245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 245 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
246 KSyncProfile* temp = new KSyncProfile (); 246 KSyncProfile* temp = new KSyncProfile ();
247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 247 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
248 temp->readConfig(&config); 248 temp->readConfig(&config);
249 if (silent) { 249 if (silent) {
250 mAskForPreferences = false; 250 mAskForPreferences = false;
251 mShowSyncSummary = false; 251 mShowSyncSummary = false;
252 mWriteBackFile = true; 252 mWriteBackFile = true;
253 mSyncAlgoPrefs = 2;// take newest 253 mSyncAlgoPrefs = 2;// take newest
254 } 254 }
255 else { 255 else {
256 mAskForPreferences = temp->getAskForPreferences(); 256 mAskForPreferences = temp->getAskForPreferences();
257 mShowSyncSummary = temp->getShowSummaryAfterSync(); 257 mShowSyncSummary = temp->getShowSummaryAfterSync();
258 mWriteBackFile = temp->getWriteBackFile(); 258 mWriteBackFile = temp->getWriteBackFile();
259 mSyncAlgoPrefs = temp->getSyncPrefs(); 259 mSyncAlgoPrefs = temp->getSyncPrefs();
260 } 260 }
261 mWriteBackExistingOnly = temp->getWriteBackExisting(); 261 mWriteBackExistingOnly = temp->getWriteBackExisting();
262 mIsKapiFile = temp->getIsKapiFile(); 262 mIsKapiFile = temp->getIsKapiFile();
263 mWriteBackInFuture = 0; 263 mWriteBackInFuture = 0;
264 if ( temp->getWriteBackFuture() ) { 264 if ( temp->getWriteBackFuture() ) {
265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 265 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
266 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 266 mWriteBackInPast = temp->getWriteBackPastWeeks( );
267 } 267 }
268 mFilterInCal = temp->getFilterInCal(); 268 mFilterInCal = temp->getFilterInCal();
269 mFilterOutCal = temp->getFilterOutCal(); 269 mFilterOutCal = temp->getFilterOutCal();
270 mFilterInAB = temp->getFilterInAB(); 270 mFilterInAB = temp->getFilterInAB();
271 mFilterOutAB = temp->getFilterOutAB(); 271 mFilterOutAB = temp->getFilterOutAB();
272 272
273 if ( action == 1000 ) { 273 if ( action == 1000 ) {
274 mIsKapiFile = false; 274 mIsKapiFile = false;
275#ifdef DESKTOP_VERSION 275#ifdef DESKTOP_VERSION
276 syncKDE(); 276 syncKDE();
277#else 277#else
278 syncSharp(); 278 syncSharp();
279#endif 279#endif
280 280
281 } else if ( action == 1001 ) { 281 } else if ( action == 1001 ) {
282 syncLocalFile(); 282 syncLocalFile();
283 283
284 } else if ( action == 1002 ) { 284 } else if ( action == 1002 ) {
285 mWriteBackFile = false; 285 mWriteBackFile = false;
286 mAskForPreferences = false; 286 mAskForPreferences = false;
287 mShowSyncSummary = false; 287 mShowSyncSummary = false;
288 mSyncAlgoPrefs = 3; 288 mSyncAlgoPrefs = 3;
289 quickSyncLocalFile(); 289 quickSyncLocalFile();
290 290
291 } else if ( action >= 1003 ) { 291 } else if ( action >= 1003 ) {
292 if ( temp->getIsLocalFileSync() ) { 292 if ( temp->getIsLocalFileSync() ) {
293 switch(mTargetApp) 293 switch(mTargetApp)
294 { 294 {
295 case (KAPI): 295 case (KAPI):
296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 296 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 297 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
298 break; 298 break;
299 case (KOPI): 299 case (KOPI):
300 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 300 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 301 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
302 break; 302 break;
303 case (PWMPI): 303 case (PWMPI):
304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 304 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 305 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
306 break; 306 break;
307 default: 307 default:
308 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 308 qDebug("KSM::slotSyncMenu: invalid apptype selected");
309 break; 309 break;
310 310
311 } 311 }
312 } else { 312 } else {
313 if ( temp->getIsPhoneSync() ) { 313 if ( temp->getIsPhoneSync() ) {
314 mPhoneDevice = temp->getPhoneDevice( ) ; 314 mPhoneDevice = temp->getPhoneDevice( ) ;
315 mPhoneConnection = temp->getPhoneConnection( ); 315 mPhoneConnection = temp->getPhoneConnection( );
316 mPhoneModel = temp->getPhoneModel( ); 316 mPhoneModel = temp->getPhoneModel( );
317 syncPhone(); 317 syncPhone();
318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) { 318 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
319 mSpecificResources.clear(); 319 mSpecificResources.clear();
320 if ( mTargetApp == KAPI ) { 320 if ( mTargetApp == KAPI ) {
321 if ( temp->getIsPiSyncSpec() ) 321 if ( temp->getIsPiSyncSpec() )
322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 322 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
323 mPassWordPiSync = temp->getRemotePwAB(); 323 mPassWordPiSync = temp->getRemotePwAB();
324 mActiveSyncPort = temp->getRemotePortAB(); 324 mActiveSyncPort = temp->getRemotePortAB();
325 mActiveSyncIP = temp->getRemoteIPAB(); 325 mActiveSyncIP = temp->getRemoteIPAB();
326 } else if ( mTargetApp == KOPI ) { 326 } else if ( mTargetApp == KOPI ) {
327 if ( temp->getIsPiSyncSpec() ) 327 if ( temp->getIsPiSyncSpec() )
328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 328 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
329 mPassWordPiSync = temp->getRemotePw(); 329 mPassWordPiSync = temp->getRemotePw();
330 mActiveSyncPort = temp->getRemotePort(); 330 mActiveSyncPort = temp->getRemotePort();
331 mActiveSyncIP = temp->getRemoteIP(); 331 mActiveSyncIP = temp->getRemoteIP();
332 } else { 332 } else {
333 mPassWordPiSync = temp->getRemotePwPWM(); 333 mPassWordPiSync = temp->getRemotePwPWM();
334 mActiveSyncPort = temp->getRemotePortPWM(); 334 mActiveSyncPort = temp->getRemotePortPWM();
335 mActiveSyncIP = temp->getRemoteIPPWM(); 335 mActiveSyncIP = temp->getRemoteIPPWM();
336 } 336 }
337 syncPi(); 337 syncPi();
338 while ( !mPisyncFinished ) { 338 while ( !mPisyncFinished ) {
339 //qDebug("waiting "); 339 //qDebug("waiting ");
340 qApp->processEvents(); 340 qApp->processEvents();
341 } 341 }
342 } else 342 } else
343 syncRemote( temp ); 343 syncRemote( temp );
344 344
345 } 345 }
346 } 346 }
347 delete temp; 347 delete temp;
348 setBlockSave(false); 348 setBlockSave(false);
349} 349}
350 350
351void KSyncManager::enableQuick( bool ask ) 351void KSyncManager::enableQuick( bool ask )
352{ 352{
353 bool autoStart; 353 bool autoStart;
354 bool changed = false; 354 bool changed = false;
355 if ( ask ) { 355 if ( ask ) {
356 QDialog dia ( 0, "input-dialog", true ); 356 QDialog dia ( 0, "input-dialog", true );
357 QLineEdit lab ( &dia ); 357 QLineEdit lab ( &dia );
358 QVBoxLayout lay( &dia ); 358 QVBoxLayout lay( &dia );
359 lab.setText( mPrefs->mPassiveSyncPort ); 359 lab.setText( mPrefs->mPassiveSyncPort );
360 lay.setMargin(7); 360 lay.setMargin(7);
361 lay.setSpacing(7); 361 lay.setSpacing(7);
362 int po = 9197+mTargetApp; 362 int po = 9197+mTargetApp;
363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 363 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
364 lay.addWidget( &label); 364 lay.addWidget( &label);
365 lay.addWidget( &lab); 365 lay.addWidget( &lab);
366 366
367 QLineEdit lepw ( &dia ); 367 QLineEdit lepw ( &dia );
368 lepw.setText( mPrefs->mPassiveSyncPw ); 368 lepw.setText( mPrefs->mPassiveSyncPw );
369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 369 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
370 lay.addWidget( &label2); 370 lay.addWidget( &label2);
371 lay.addWidget( &lepw); 371 lay.addWidget( &lepw);
372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 372 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
373 lay.addWidget( &autostart); 373 lay.addWidget( &autostart);
374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 374 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
375#ifdef DESKTOP_VERSION 375#ifdef DESKTOP_VERSION
376#ifdef _WIN32_ 376#ifdef _WIN32_
377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
378 syncdesktop.hide();// not implemented! 378 syncdesktop.hide();// not implemented!
379#else 379#else
380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 380 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
381#endif 381#endif
382 lay.addWidget( &syncdesktop); 382 lay.addWidget( &syncdesktop);
383#else 383#else
384 mPrefs->mPassiveSyncWithDesktop = false; 384 mPrefs->mPassiveSyncWithDesktop = false;
385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 385 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
386 syncdesktop.hide(); 386 syncdesktop.hide();
387#endif 387#endif
388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 388 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
389 389
390 QPushButton pb ( "OK", &dia); 390 QPushButton pb ( "OK", &dia);
391 lay.addWidget( &pb ); 391 lay.addWidget( &pb );
392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 392 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
393 dia.resize( 230,120 ); 393 dia.resize( 230,120 );
394 dia.setCaption( i18n("Enter port for Pi-Sync") ); 394 dia.setCaption( i18n("Enter port for Pi-Sync") );
395 dia.show(); 395 dia.show();
396#ifndef DESKTOP_VERSION 396#ifndef DESKTOP_VERSION
397 int dw = QApplication::desktop()->width(); 397 int dw = QApplication::desktop()->width();
398 int dh = QApplication::desktop()->height(); 398 int dh = QApplication::desktop()->height();
399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 399 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
400#endif 400#endif
401 if ( ! dia.exec() ) 401 if ( ! dia.exec() )
402 return; 402 return;
403 dia.hide(); 403 dia.hide();
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 405 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
406 changed = true; 406 changed = true;
407 mPrefs->mPassiveSyncPw = lepw.text(); 407 mPrefs->mPassiveSyncPw = lepw.text();
408 } 408 }
409 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 409 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
410 mPrefs->mPassiveSyncPort = lab.text(); 410 mPrefs->mPassiveSyncPort = lab.text();
411 changed = true; 411 changed = true;
412 } 412 }
413 autoStart = autostart.isChecked(); 413 autoStart = autostart.isChecked();
414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 414 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
415 changed = true; 415 changed = true;
416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 416 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
417 } 417 }
418 } 418 }
419 else 419 else
420 autoStart = mPrefs->mPassiveSyncAutoStart; 420 autoStart = mPrefs->mPassiveSyncAutoStart;
421 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 421 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
422 changed = true; 422 changed = true;
423 bool ok; 423 bool ok;
424 mPrefs->mPassiveSyncAutoStart = false; 424 mPrefs->mPassiveSyncAutoStart = false;
425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 425 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
426 if ( ! ok || port_t > 65535 ) { 426 if ( ! ok || port_t > 65535 ) {
427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 427 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
428 return; 428 return;
429 } 429 }
430 Q_UINT16 port = port_t; 430 Q_UINT16 port = port_t;
431 //qDebug("port %d ", port); 431 //qDebug("port %d ", port);
432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 432 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
433 mServerSocket->setFileName( defaultFileName() );//bbb 433 mServerSocket->setFileName( defaultFileName() );//bbb
434 if ( !mServerSocket->ok() ) { 434 if ( !mServerSocket->ok() ) {
435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 435 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
436 delete mServerSocket; 436 delete mServerSocket;
437 mServerSocket = 0; 437 mServerSocket = 0;
438 return; 438 return;
439 } 439 }
440 mPrefs->mPassiveSyncAutoStart = autoStart; 440 mPrefs->mPassiveSyncAutoStart = autoStart;
441 if ( changed ) { 441 if ( changed ) {
442 mPrefs->writeConfig(); 442 mPrefs->writeConfig();
443 } 443 }
444 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 444 //connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
445 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 445 //connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); 446 connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) );
447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); 447 connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) );
448} 448}
449void KSyncManager::displayErrorPort() 449void KSyncManager::displayErrorPort()
450{ 450{
451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 451 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
452} 452}
453void KSyncManager::syncLocalFile() 453void KSyncManager::syncLocalFile()
454{ 454{
455 455
456 QString fn =mPrefs->mLastSyncedLocalFile; 456 QString fn =mPrefs->mLastSyncedLocalFile;
457 QString ext; 457 QString ext;
458 458
459 switch(mTargetApp) 459 switch(mTargetApp)
460 { 460 {
461 case (KAPI): 461 case (KAPI):
462 ext = "(*.vcf)"; 462 ext = "(*.vcf)";
463 break; 463 break;
464 case (KOPI): 464 case (KOPI):
465 ext = "(*.ics/*.vcs)"; 465 ext = "(*.ics/*.vcs)";
466 break; 466 break;
467 case (PWMPI): 467 case (PWMPI):
468 ext = "(*.pwm)"; 468 ext = "(*.pwm)";
469 break; 469 break;
470 default: 470 default:
471 qDebug("KSM::syncLocalFile: invalid apptype selected"); 471 qDebug("KSM::syncLocalFile: invalid apptype selected");
472 break; 472 break;
473 473
474 } 474 }
475 475
476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 476 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
477 if ( fn == "" ) 477 if ( fn == "" )
478 return; 478 return;
479 if ( syncWithFile( fn, false ) ) { 479 if ( syncWithFile( fn, false ) ) {
480 qDebug("KSM::syncLocalFile() successful "); 480 qDebug("KSM::syncLocalFile() successful ");
481 } 481 }
482 482
483} 483}
484 484
485bool KSyncManager::syncWithFile( QString fn , bool quick ) 485bool KSyncManager::syncWithFile( QString fn , bool quick )
486{ 486{
487 bool ret = false; 487 bool ret = false;
488 QFileInfo info; 488 QFileInfo info;
489 info.setFile( fn ); 489 info.setFile( fn );
490 QString mess; 490 QString mess;
491 if ( !info. exists() ) { 491 if ( !info. exists() ) {
492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 492 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
493 QMessageBox::warning( mParent, i18n("Warning!"), 493 QMessageBox::warning( mParent, i18n("Warning!"),
494 mess ); 494 mess );
495 return ret; 495 return ret;
496 } 496 }
497 int result = 0; 497 int result = 0;
498 if ( !quick ) { 498 if ( !quick ) {
499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 499 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
500 result = QMessageBox::warning( mParent, i18n("Warning!"), 500 result = QMessageBox::warning( mParent, i18n("Warning!"),
501 mess, 501 mess,
502 i18n("Sync"), i18n("Cancel"), 0, 502 i18n("Sync"), i18n("Cancel"), 0,
503 0, 1 ); 503 0, 1 );
504 if ( result ) 504 if ( result )
505 return false; 505 return false;
506 } 506 }
507 if ( mAskForPreferences ) 507 if ( mAskForPreferences )
508 if ( !edit_sync_options()) { 508 if ( !edit_sync_options()) {
509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 509 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
510 return false; 510 return false;
511 } 511 }
512 if ( result == 0 ) { 512 if ( result == 0 ) {
513 //qDebug("Now sycing ... "); 513 //qDebug("Now sycing ... ");
514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) ) 514 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 515 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
516 else 516 else
517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 517 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
518 if ( ! quick ) 518 if ( ! quick )
519 mPrefs->mLastSyncedLocalFile = fn; 519 mPrefs->mLastSyncedLocalFile = fn;
520 } 520 }
521 return ret; 521 return ret;
522} 522}
523 523
524void KSyncManager::quickSyncLocalFile() 524void KSyncManager::quickSyncLocalFile()
525{ 525{
526 526
527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 527 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
528 qDebug("KSM::quick syncLocalFile() successful "); 528 qDebug("KSM::quick syncLocalFile() successful ");
529 529
530 } 530 }
531} 531}
532 532
533void KSyncManager::multiSync( bool askforPrefs ) 533void KSyncManager::multiSync( bool askforPrefs )
534{ 534{
535 if (blockSave()) 535 if (blockSave())
536 return; 536 return;
537 setBlockSave(true); 537 setBlockSave(true);
538 mCurrentResourceLocal = ""; 538 mCurrentResourceLocal = "";
539 if ( askforPrefs ) { 539 if ( askforPrefs ) {
540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 540 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 541 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
542 question, 542 question,
543 i18n("Yes"), i18n("No"), 543 i18n("Yes"), i18n("No"),
544 0, 0 ) != 0 ) { 544 0, 0 ) != 0 ) {
545 setBlockSave(false); 545 setBlockSave(false);
546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 546 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
547 return; 547 return;
548 } 548 }
549 } 549 }
550 mCurrentSyncDevice = i18n("Multiple profiles") ; 550 mCurrentSyncDevice = i18n("Multiple profiles") ;
551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 551 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
552 if ( askforPrefs ) { 552 if ( askforPrefs ) {
553 if ( !edit_sync_options()) { 553 if ( !edit_sync_options()) {
554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 554 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
555 return; 555 return;
556 } 556 }
557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 557 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
558 } 558 }
559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 559 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
560 qApp->processEvents(); 560 qApp->processEvents();
561 int num = ringSync() ; 561 int num = ringSync() ;
562 if ( num > 1 ) 562 if ( num > 1 )
563 ringSync(); 563 ringSync();
564 setBlockSave(false); 564 setBlockSave(false);
565 if ( num ) 565 if ( num )
566 emit save(); 566 emit save();
567 if ( num ) 567 if ( num )
568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 568 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
569 else 569 else
570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 570 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
571 return; 571 return;
572} 572}
573 573
574int KSyncManager::ringSync() 574int KSyncManager::ringSync()
575{ 575{
576 emit multiResourceSyncStart( false ); 576 emit multiResourceSyncStart( false );
577 int syncedProfiles = 0; 577 int syncedProfiles = 0;
578 unsigned int i; 578 unsigned int i;
579 QTime timer; 579 QTime timer;
580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 580 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
581 QStringList syncProfileNames = mSyncProfileNames; 581 QStringList syncProfileNames = mSyncProfileNames;
582 KSyncProfile* temp = new KSyncProfile (); 582 KSyncProfile* temp = new KSyncProfile ();
583 mAskForPreferences = false; 583 mAskForPreferences = false;
584 mCurrentResourceLocal = ""; 584 mCurrentResourceLocal = "";
585 for ( i = 0; i < syncProfileNames.count(); ++i ) { 585 for ( i = 0; i < syncProfileNames.count(); ++i ) {
586 mCurrentSyncProfile = i; 586 mCurrentSyncProfile = i;
587 temp->setName(syncProfileNames[mCurrentSyncProfile]); 587 temp->setName(syncProfileNames[mCurrentSyncProfile]);
588 temp->readConfig(&config); 588 temp->readConfig(&config);
589 589
590 bool includeInRingSync = false; 590 bool includeInRingSync = false;
591 switch(mTargetApp) 591 switch(mTargetApp)
592 { 592 {
593 case (KAPI): 593 case (KAPI):
594 includeInRingSync = temp->getIncludeInRingSyncAB(); 594 includeInRingSync = temp->getIncludeInRingSyncAB();
595 break; 595 break;
596 case (KOPI): 596 case (KOPI):
597 includeInRingSync = temp->getIncludeInRingSync(); 597 includeInRingSync = temp->getIncludeInRingSync();
598 break; 598 break;
599 case (PWMPI): 599 case (PWMPI):
600 includeInRingSync = temp->getIncludeInRingSyncPWM(); 600 includeInRingSync = temp->getIncludeInRingSyncPWM();
601 break; 601 break;
602 default: 602 default:
603 qDebug("KSM::ringSync: invalid apptype selected"); 603 qDebug("KSM::ringSync: invalid apptype selected");
604 break; 604 break;
605 605
606 } 606 }
607 607
608 608
609 if ( includeInRingSync && ( i < 1 || i > 2 )) { 609 if ( includeInRingSync && ( i < 1 || i > 2 )) {
610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 610 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
611 ++syncedProfiles; 611 ++syncedProfiles;
612 mSyncWithDesktop = false; 612 mSyncWithDesktop = false;
613 // mAskForPreferences = temp->getAskForPreferences(); 613 // mAskForPreferences = temp->getAskForPreferences();
614 mWriteBackFile = temp->getWriteBackFile(); 614 mWriteBackFile = temp->getWriteBackFile();
615 mWriteBackExistingOnly = temp->getWriteBackExisting(); 615 mWriteBackExistingOnly = temp->getWriteBackExisting();
616 mIsKapiFile = temp->getIsKapiFile(); 616 mIsKapiFile = temp->getIsKapiFile();
617 mWriteBackInFuture = 0; 617 mWriteBackInFuture = 0;
618 if ( temp->getWriteBackFuture() ) { 618 if ( temp->getWriteBackFuture() ) {
619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 619 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
620 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 620 mWriteBackInPast = temp->getWriteBackPastWeeks( );
621 } 621 }
622 mFilterInCal = temp->getFilterInCal(); 622 mFilterInCal = temp->getFilterInCal();
623 mFilterOutCal = temp->getFilterOutCal(); 623 mFilterOutCal = temp->getFilterOutCal();
624 mFilterInAB = temp->getFilterInAB(); 624 mFilterInAB = temp->getFilterInAB();
625 mFilterOutAB = temp->getFilterOutAB(); 625 mFilterOutAB = temp->getFilterOutAB();
626 mShowSyncSummary = false; 626 mShowSyncSummary = false;
627 mCurrentSyncDevice = syncProfileNames[i] ; 627 mCurrentSyncDevice = syncProfileNames[i] ;
628 mCurrentSyncName = mLocalMachineName; 628 mCurrentSyncName = mLocalMachineName;
629 if ( i == 0 ) { 629 if ( i == 0 ) {
630 mIsKapiFile = false; 630 mIsKapiFile = false;
631#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
632 syncKDE(); 632 syncKDE();
633#else 633#else
634 syncSharp(); 634 syncSharp();
635#endif 635#endif
636 } else { 636 } else {
637 if ( temp->getIsLocalFileSync() ) { 637 if ( temp->getIsLocalFileSync() ) {
638 switch(mTargetApp) 638 switch(mTargetApp)
639 { 639 {
640 case (KAPI): 640 case (KAPI):
641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
643 break; 643 break;
644 case (KOPI): 644 case (KOPI):
645 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
647 break; 647 break;
648 case (PWMPI): 648 case (PWMPI):
649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 649 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 650 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
651 break; 651 break;
652 default: 652 default:
653 qDebug("KSM: invalid apptype selected"); 653 qDebug("KSM: invalid apptype selected");
654 break; 654 break;
655 } 655 }
656 } else { 656 } else {
657 if ( temp->getIsPhoneSync() ) { 657 if ( temp->getIsPhoneSync() ) {
658 mPhoneDevice = temp->getPhoneDevice( ) ; 658 mPhoneDevice = temp->getPhoneDevice( ) ;
659 mPhoneConnection = temp->getPhoneConnection( ); 659 mPhoneConnection = temp->getPhoneConnection( );
660 mPhoneModel = temp->getPhoneModel( ); 660 mPhoneModel = temp->getPhoneModel( );
661 syncPhone(); 661 syncPhone();
662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) { 662 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
663 mSpecificResources.clear(); 663 mSpecificResources.clear();
664 if ( mTargetApp == KAPI ) { 664 if ( mTargetApp == KAPI ) {
665 if ( temp->getIsPiSyncSpec() ) 665 if ( temp->getIsPiSyncSpec() )
666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true ); 666 mSpecificResources = QStringList::split( ":", temp->getResSpecKapi(),true );
667 mPassWordPiSync = temp->getRemotePwAB(); 667 mPassWordPiSync = temp->getRemotePwAB();
668 mActiveSyncPort = temp->getRemotePortAB(); 668 mActiveSyncPort = temp->getRemotePortAB();
669 mActiveSyncIP = temp->getRemoteIPAB(); 669 mActiveSyncIP = temp->getRemoteIPAB();
670 } else if ( mTargetApp == KOPI ) { 670 } else if ( mTargetApp == KOPI ) {
671 if ( temp->getIsPiSyncSpec() ) 671 if ( temp->getIsPiSyncSpec() )
672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true ); 672 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi(),true );
673 mPassWordPiSync = temp->getRemotePw(); 673 mPassWordPiSync = temp->getRemotePw();
674 mActiveSyncPort = temp->getRemotePort(); 674 mActiveSyncPort = temp->getRemotePort();
675 mActiveSyncIP = temp->getRemoteIP(); 675 mActiveSyncIP = temp->getRemoteIP();
676 } else { 676 } else {
677 mPassWordPiSync = temp->getRemotePwPWM(); 677 mPassWordPiSync = temp->getRemotePwPWM();
678 mActiveSyncPort = temp->getRemotePortPWM(); 678 mActiveSyncPort = temp->getRemotePortPWM();
679 mActiveSyncIP = temp->getRemoteIPPWM(); 679 mActiveSyncIP = temp->getRemoteIPPWM();
680 } 680 }
681 syncPi(); 681 syncPi();
682 while ( !mPisyncFinished ) { 682 while ( !mPisyncFinished ) {
683 //qDebug("waiting "); 683 //qDebug("waiting ");
684 qApp->processEvents(); 684 qApp->processEvents();
685 } 685 }
686 timer.start(); 686 timer.start();
687 while ( timer.elapsed () < 2000 ) { 687 while ( timer.elapsed () < 2000 ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 } 689 }
690 } else 690 } else
691 syncRemote( temp, false ); 691 syncRemote( temp, false );
692 692
693 } 693 }
694 } 694 }
695 timer.start(); 695 timer.start();
696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 696 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
697 while ( timer.elapsed () < 2000 ) { 697 while ( timer.elapsed () < 2000 ) {
698 qApp->processEvents(); 698 qApp->processEvents();
699#ifndef _WIN32_ 699#ifndef _WIN32_
700 sleep (1); 700 sleep (1);
701#endif 701#endif
702 } 702 }
703 703
704 } 704 }
705 705
706 } 706 }
707 delete temp; 707 delete temp;
708 return syncedProfiles; 708 return syncedProfiles;
709} 709}
710 710
711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 711void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
712{ 712{
713 QString question; 713 QString question;
714 if ( ask ) { 714 if ( ask ) {
715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 715 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
716 if ( QMessageBox::information( mParent, i18n("Sync"), 716 if ( QMessageBox::information( mParent, i18n("Sync"),
717 question, 717 question,
718 i18n("Yes"), i18n("No"), 718 i18n("Yes"), i18n("No"),
719 0, 0 ) != 0 ) 719 0, 0 ) != 0 )
720 return; 720 return;
721 } 721 }
722 722
723 QString preCommand; 723 QString preCommand;
724 QString localTempFile; 724 QString localTempFile;
725 QString postCommand; 725 QString postCommand;
726 726
727 switch(mTargetApp) 727 switch(mTargetApp)
728 { 728 {
729 case (KAPI): 729 case (KAPI):
730 preCommand = prof->getPreSyncCommandAB(); 730 preCommand = prof->getPreSyncCommandAB();
731 postCommand = prof->getPostSyncCommandAB(); 731 postCommand = prof->getPostSyncCommandAB();
732 localTempFile = prof->getLocalTempFileAB(); 732 localTempFile = prof->getLocalTempFileAB();
733 break; 733 break;
734 case (KOPI): 734 case (KOPI):
735 preCommand = prof->getPreSyncCommand(); 735 preCommand = prof->getPreSyncCommand();
736 postCommand = prof->getPostSyncCommand(); 736 postCommand = prof->getPostSyncCommand();
737 localTempFile = prof->getLocalTempFile(); 737 localTempFile = prof->getLocalTempFile();
738 break; 738 break;
739 case (PWMPI): 739 case (PWMPI):
740 preCommand = prof->getPreSyncCommandPWM(); 740 preCommand = prof->getPreSyncCommandPWM();
741 postCommand = prof->getPostSyncCommandPWM(); 741 postCommand = prof->getPostSyncCommandPWM();
742 localTempFile = prof->getLocalTempFilePWM(); 742 localTempFile = prof->getLocalTempFilePWM();
743 break; 743 break;
744 default: 744 default:
745 qDebug("KSM::syncRemote: invalid apptype selected"); 745 qDebug("KSM::syncRemote: invalid apptype selected");
746 break; 746 break;
747 } 747 }
748 748
749 749
750 int fi; 750 int fi;
751 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 751 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
752 QString pwd = getPassword(); 752 QString pwd = getPassword();
753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 753 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
754 754
755 } 755 }
756 int maxlen = 30; 756 int maxlen = 30;
757 if ( QApplication::desktop()->width() > 320 ) 757 if ( QApplication::desktop()->width() > 320 )
758 maxlen += 25; 758 maxlen += 25;
759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
760 int result = system ( preCommand ); 760 int result = system ( preCommand );
761 // 0 : okay 761 // 0 : okay
762 // 256: no such file or dir 762 // 256: no such file or dir
763 // 763 //
764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 764 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
765 if ( result != 0 ) { 765 if ( result != 0 ) {
766 unsigned int len = maxlen; 766 unsigned int len = maxlen;
767 while ( len < preCommand.length() ) { 767 while ( len < preCommand.length() ) {
768 preCommand.insert( len , "\n" ); 768 preCommand.insert( len , "\n" );
769 len += maxlen +2; 769 len += maxlen +2;
770 } 770 }
771 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ; 771 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
772 QMessageBox::information( mParent, i18n("Sync - ERROR"), 772 QMessageBox::information( mParent, i18n("Sync - ERROR"),
773 question, 773 question,
774 i18n("Okay!")) ; 774 i18n("Okay!")) ;
775 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 775 mParent->topLevelWidget()->setCaption ("KDE-Pim");
776 return; 776 return;
777 } 777 }
778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 778 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 779 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
780 780
781 if ( syncWithFile( localTempFile, true ) ) { 781 if ( syncWithFile( localTempFile, true ) ) {
782 782
783 if ( mWriteBackFile ) { 783 if ( mWriteBackFile ) {
784 int fi; 784 int fi;
785 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 785 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
786 QString pwd = getPassword(); 786 QString pwd = getPassword();
787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 787 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
788 788
789 } 789 }
790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 790 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
791 result = system ( postCommand ); 791 result = system ( postCommand );
792 qDebug("KSM::Sync:Writing back file result: %d ", result); 792 qDebug("KSM::Sync:Writing back file result: %d ", result);
793 if ( result != 0 ) { 793 if ( result != 0 ) {
794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 794 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
795 return; 795 return;
796 } else { 796 } else {
797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 797 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
798 } 798 }
799 } 799 }
800 } 800 }
801 return; 801 return;
802} 802}
803bool KSyncManager::edit_pisync_options() 803bool KSyncManager::edit_pisync_options()
804{ 804{
805 QDialog dia( mParent, "dia", true ); 805 QDialog dia( mParent, "dia", true );
806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 806 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
807 QVBoxLayout lay ( &dia ); 807 QVBoxLayout lay ( &dia );
808 lay.setSpacing( 5 ); 808 lay.setSpacing( 5 );
809 lay.setMargin( 3 ); 809 lay.setMargin( 3 );
810 QLabel lab1 ( i18n("Password for remote access:"), &dia); 810 QLabel lab1 ( i18n("Password for remote access:"), &dia);
811 lay.addWidget( &lab1 ); 811 lay.addWidget( &lab1 );
812 QLineEdit le1 (&dia ); 812 QLineEdit le1 (&dia );
813 lay.addWidget( &le1 ); 813 lay.addWidget( &le1 );
814 QLabel lab2 ( i18n("Remote IP address:"), &dia); 814 QLabel lab2 ( i18n("Remote IP address:"), &dia);
815 lay.addWidget( &lab2 ); 815 lay.addWidget( &lab2 );
816 QLineEdit le2 (&dia ); 816 QLineEdit le2 (&dia );
817 lay.addWidget( &le2 ); 817 lay.addWidget( &le2 );
818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 818 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
819 lay.addWidget( &lab3 ); 819 lay.addWidget( &lab3 );
820 QLineEdit le3 (&dia ); 820 QLineEdit le3 (&dia );
821 lay.addWidget( &le3 ); 821 lay.addWidget( &le3 );
822 QPushButton pb ( "OK", &dia); 822 QPushButton pb ( "OK", &dia);
823 lay.addWidget( &pb ); 823 lay.addWidget( &pb );
824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 824 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
825 le1.setText( mPassWordPiSync ); 825 le1.setText( mPassWordPiSync );
826 le2.setText( mActiveSyncIP ); 826 le2.setText( mActiveSyncIP );
827 le3.setText( mActiveSyncPort ); 827 le3.setText( mActiveSyncPort );
828 if ( dia.exec() ) { 828 if ( dia.exec() ) {
829 mPassWordPiSync = le1.text(); 829 mPassWordPiSync = le1.text();
830 mActiveSyncPort = le3.text(); 830 mActiveSyncPort = le3.text();
831 mActiveSyncIP = le2.text(); 831 mActiveSyncIP = le2.text();
832 return true; 832 return true;
833 } 833 }
834 return false; 834 return false;
835} 835}
836bool KSyncManager::edit_sync_options() 836bool KSyncManager::edit_sync_options()
837{ 837{
838 838
839 QDialog dia( mParent, "dia", true ); 839 QDialog dia( mParent, "dia", true );
840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 840 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 841 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
842 QVBoxLayout lay ( &dia ); 842 QVBoxLayout lay ( &dia );
843 lay.setSpacing( 2 ); 843 lay.setSpacing( 2 );
844 lay.setMargin( 3 ); 844 lay.setMargin( 3 );
845 lay.addWidget(&gr); 845 lay.addWidget(&gr);
846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 846 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 847 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 848 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 849 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 850 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 851 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
852 //QRadioButton both( i18n("Take both on conflict"), &gr ); 852 //QRadioButton both( i18n("Take both on conflict"), &gr );
853 QPushButton pb ( "OK", &dia); 853 QPushButton pb ( "OK", &dia);
854 lay.addWidget( &pb ); 854 lay.addWidget( &pb );
855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 855 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
856 switch ( mSyncAlgoPrefs ) { 856 switch ( mSyncAlgoPrefs ) {
857 case 0: 857 case 0:
858 loc.setChecked( true); 858 loc.setChecked( true);
859 break; 859 break;
860 case 1: 860 case 1:
861 rem.setChecked( true ); 861 rem.setChecked( true );
862 break; 862 break;
863 case 2: 863 case 2:
864 newest.setChecked( true); 864 newest.setChecked( true);
865 break; 865 break;
866 case 3: 866 case 3:
867 ask.setChecked( true); 867 ask.setChecked( true);
868 break; 868 break;
869 case 4: 869 case 4:
870 f_loc.setChecked( true); 870 f_loc.setChecked( true);
871 break; 871 break;
872 case 5: 872 case 5:
873 f_rem.setChecked( true); 873 f_rem.setChecked( true);
874 break; 874 break;
875 case 6: 875 case 6:
876 // both.setChecked( true); 876 // both.setChecked( true);
877 break; 877 break;
878 default: 878 default:
879 break; 879 break;
880 } 880 }
881 if ( dia.exec() ) { 881 if ( dia.exec() ) {
882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 882 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
883 return true; 883 return true;
884 } 884 }
885 return false; 885 return false;
886} 886}
887 887
888QString KSyncManager::getPassword( ) 888QString KSyncManager::getPassword( )
889{ 889{
890 QString retfile = ""; 890 QString retfile = "";
891 QDialog dia ( mParent, "input-dialog", true ); 891 QDialog dia ( mParent, "input-dialog", true );
892 QLineEdit lab ( &dia ); 892 QLineEdit lab ( &dia );
893 lab.setEchoMode( QLineEdit::Password ); 893 lab.setEchoMode( QLineEdit::Password );
894 QVBoxLayout lay( &dia ); 894 QVBoxLayout lay( &dia );
895 lay.setMargin(7); 895 lay.setMargin(7);
896 lay.setSpacing(7); 896 lay.setSpacing(7);
897 lay.addWidget( &lab); 897 lay.addWidget( &lab);
898 dia.setFixedSize( 230,50 ); 898 dia.setFixedSize( 230,50 );
899 dia.setCaption( i18n("Enter password") ); 899 dia.setCaption( i18n("Enter password") );
900 QPushButton pb ( "OK", &dia); 900 QPushButton pb ( "OK", &dia);
901 lay.addWidget( &pb ); 901 lay.addWidget( &pb );
902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 902 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
903 dia.show(); 903 dia.show();
904 int res = dia.exec(); 904 int res = dia.exec();
905 if ( res ) 905 if ( res )
906 retfile = lab.text(); 906 retfile = lab.text();
907 dia.hide(); 907 dia.hide();
908 qApp->processEvents(); 908 qApp->processEvents();
909 return retfile; 909 return retfile;
910 910
911} 911}
912 912
913 913
914void KSyncManager::confSync() 914void KSyncManager::confSync()
915{ 915{
916 static KSyncPrefsDialog* sp = 0; 916 static KSyncPrefsDialog* sp = 0;
917 if ( ! sp ) { 917 if ( ! sp ) {
918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 918 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
919 } 919 }
920 sp->usrReadConfig(); 920 sp->usrReadConfig();
921#ifndef DESKTOP_VERSION 921#ifndef DESKTOP_VERSION
922 sp->showMaximized(); 922 sp->showMaximized();
923#else 923#else
924 sp->show(); 924 sp->show();
925#endif 925#endif
926 sp->exec(); 926 sp->exec();
927 QStringList oldSyncProfileNames = mSyncProfileNames; 927 QStringList oldSyncProfileNames = mSyncProfileNames;
928 mSyncProfileNames = sp->getSyncProfileNames(); 928 mSyncProfileNames = sp->getSyncProfileNames();
929 mLocalMachineName = sp->getLocalMachineName (); 929 mLocalMachineName = sp->getLocalMachineName ();
930 uint ii; 930 uint ii;
931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 931 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 932 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 933 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
934 } 934 }
935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 935 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
936} 936}
937void KSyncManager::syncOL()
938{
939 mSyncWithDesktop = true;
940 emit save();
941 switch(mTargetApp)
942 {
943 case (KAPI):
944 {
945 syncExternalApplication("ol");
946 }
947 break;
948 case (KOPI):
949 {
950#ifdef DESKTOP_VERSION
951 QString command = "kdecaldump33";
952 QString commandfile = "kdecaldump33";
953 QString commandpath = qApp->applicationDirPath () + "/";
954#else
955 QString command = "kdecaldump33";
956 QString commandfile = "kdecaldump33";
957 QString commandpath = QDir::homeDirPath ()+"/";
958#endif
959 if ( ! QFile::exists ( commandpath+commandfile ) )
960 command = commandfile;
961 else
962 command = commandpath+commandfile;
963
964 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
965 int result = system ( command.latin1());
966 qDebug("Cal dump 33 command call result result: %d ", result);
967 if ( result != 0 ) {
968 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
969 commandfile = "kdecaldump34";
970 if ( ! QFile::exists ( commandpath+commandfile ) )
971 command = commandfile;
972 else
973 command = commandpath+commandfile;
974 result = system ( command.latin1());
975 qDebug("Cal dump 34 command call result result: %d ", result);
976 if ( result != 0 ) {
977 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
978 return;
979 }
980 }
981 if ( syncWithFile( fileName,true ) ) {
982 if ( mWriteBackFile ) {
983 command += " --read";
984 system ( command.latin1());
985 }
986 }
987
988 }
989 break;
990 case (PWMPI):
991
992 break;
993 default:
994 qDebug("KSM::slotSyncMenu: invalid apptype selected");
995 break;
996
997 }
998}
937void KSyncManager::syncKDE() 999void KSyncManager::syncKDE()
938{ 1000{
1001#ifdef _WIN32_
1002 syncOL();
1003#else
1004
939 mSyncWithDesktop = true; 1005 mSyncWithDesktop = true;
940 emit save(); 1006 emit save();
941 switch(mTargetApp) 1007 switch(mTargetApp)
942 { 1008 {
943 case (KAPI): 1009 case (KAPI):
944 { 1010 {
945#ifdef DESKTOP_VERSION 1011#ifdef DESKTOP_VERSION
946 QString command = "kdeabdump33"; 1012 QString command = "kdeabdump33";
947 QString commandfile = "kdeabdump33"; 1013 QString commandfile = "kdeabdump33";
948 QString commandpath = qApp->applicationDirPath () + "/"; 1014 QString commandpath = qApp->applicationDirPath () + "/";
949#else 1015#else
950 QString command = "kdeabdump33"; 1016 QString command = "kdeabdump33";
951 QString commandfile = "kdeabdump33"; 1017 QString commandfile = "kdeabdump33";
952 QString commandpath = QDir::homeDirPath ()+"/"; 1018 QString commandpath = QDir::homeDirPath ()+"/";
953#endif 1019#endif
954 if ( ! QFile::exists ( commandpath+commandfile ) ) 1020 if ( ! QFile::exists ( commandpath+commandfile ) )
955 command = commandfile; 1021 command = commandfile;
956 else 1022 else
957 command = commandpath+commandfile; 1023 command = commandpath+commandfile;
958 1024
959 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 1025 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
960 int result = system ( command.latin1()); 1026 int result = system ( command.latin1());
961 qDebug("AB dump 33 command call result: %d ", result); 1027 qDebug("AB dump 33 command call result: %d ", result);
962 if ( result != 0 ) { 1028 if ( result != 0 ) {
963 qDebug("Calling AB dump version 33 failed. Trying 34... "); 1029 qDebug("Calling AB dump version 33 failed. Trying 34... ");
964 commandfile = "kdeabdump34"; 1030 commandfile = "kdeabdump34";
965 if ( ! QFile::exists ( commandpath+commandfile ) ) 1031 if ( ! QFile::exists ( commandpath+commandfile ) )
966 command = commandfile; 1032 command = commandfile;
967 else 1033 else
968 command = commandpath+commandfile; 1034 command = commandpath+commandfile;
969 result = system ( command.latin1()); 1035 result = system ( command.latin1());
970 qDebug("AB dump 34 command call result: %d ", result); 1036 qDebug("AB dump 34 command call result: %d ", result);
971 if ( result != 0 ) { 1037 if ( result != 0 ) {
972 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1038 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
973 return; 1039 return;
974 } 1040 }
975 } 1041 }
976 if ( syncWithFile( fileName,true ) ) { 1042 if ( syncWithFile( fileName,true ) ) {
977 if ( mWriteBackFile ) { 1043 if ( mWriteBackFile ) {
978 command += " --read"; 1044 command += " --read";
979 system ( command.latin1()); 1045 system ( command.latin1());
980 } 1046 }
981 } 1047 }
982 1048
983 } 1049 }
984 break; 1050 break;
985 case (KOPI): 1051 case (KOPI):
986 { 1052 {
987#ifdef DESKTOP_VERSION 1053#ifdef DESKTOP_VERSION
988 QString command = "kdecaldump33"; 1054 QString command = "kdecaldump33";
989 QString commandfile = "kdecaldump33"; 1055 QString commandfile = "kdecaldump33";
990 QString commandpath = qApp->applicationDirPath () + "/"; 1056 QString commandpath = qApp->applicationDirPath () + "/";
991#else 1057#else
992 QString command = "kdecaldump33"; 1058 QString command = "kdecaldump33";
993 QString commandfile = "kdecaldump33"; 1059 QString commandfile = "kdecaldump33";
994 QString commandpath = QDir::homeDirPath ()+"/"; 1060 QString commandpath = QDir::homeDirPath ()+"/";
995#endif 1061#endif
996 if ( ! QFile::exists ( commandpath+commandfile ) ) 1062 if ( ! QFile::exists ( commandpath+commandfile ) )
997 command = commandfile; 1063 command = commandfile;
998 else 1064 else
999 command = commandpath+commandfile; 1065 command = commandpath+commandfile;
1000 1066
1001 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 1067 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
1002 int result = system ( command.latin1()); 1068 int result = system ( command.latin1());
1003 qDebug("Cal dump 33 command call result result: %d ", result); 1069 qDebug("Cal dump 33 command call result result: %d ", result);
1004 if ( result != 0 ) { 1070 if ( result != 0 ) {
1005 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 1071 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
1006 commandfile = "kdecaldump34"; 1072 commandfile = "kdecaldump34";
1007 if ( ! QFile::exists ( commandpath+commandfile ) ) 1073 if ( ! QFile::exists ( commandpath+commandfile ) )
1008 command = commandfile; 1074 command = commandfile;
1009 else 1075 else
1010 command = commandpath+commandfile; 1076 command = commandpath+commandfile;
1011 result = system ( command.latin1()); 1077 result = system ( command.latin1());
1012 qDebug("Cal dump 34 command call result result: %d ", result); 1078 qDebug("Cal dump 34 command call result result: %d ", result);
1013 if ( result != 0 ) { 1079 if ( result != 0 ) {
1014 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1080 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1015 return; 1081 return;
1016 } 1082 }
1017 } 1083 }
1018 if ( syncWithFile( fileName,true ) ) { 1084 if ( syncWithFile( fileName,true ) ) {
1019 if ( mWriteBackFile ) { 1085 if ( mWriteBackFile ) {
1020 command += " --read"; 1086 command += " --read";
1021 system ( command.latin1()); 1087 system ( command.latin1());
1022 } 1088 }
1023 } 1089 }
1024 1090
1025 } 1091 }
1026 break; 1092 break;
1027 case (PWMPI): 1093 case (PWMPI):
1028 1094
1029 break; 1095 break;
1030 default: 1096 default:
1031 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1097 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1032 break; 1098 break;
1033 1099
1034 } 1100 }
1101#endif
1035} 1102}
1036 1103
1037void KSyncManager::syncSharp() 1104void KSyncManager::syncSharp()
1038{ 1105{
1039 1106
1040 if ( ! syncExternalApplication("sharp") ) 1107 if ( ! syncExternalApplication("sharp") )
1041 qDebug("KSM::ERROR sync sharp "); 1108 qDebug("KSM::ERROR sync sharp ");
1042} 1109}
1043 1110
1044bool KSyncManager::syncExternalApplication(QString resource) 1111bool KSyncManager::syncExternalApplication(QString resource)
1045{ 1112{
1046 1113
1047 emit save(); 1114 emit save();
1048 1115
1049 if ( mAskForPreferences ) 1116 if ( mAskForPreferences )
1050 if ( !edit_sync_options()) { 1117 if ( !edit_sync_options()) {
1051 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1118 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1052 return false; 1119 return false;
1053 } 1120 }
1054 1121
1055 qDebug("KSM::Sync extern %s", resource.latin1()); 1122 qDebug("KSM::Sync extern %s", resource.latin1());
1056 1123
1057 bool syncOK = mImplementation->syncExternal(this, resource); 1124 bool syncOK = mImplementation->syncExternal(this, resource);
1058 1125
1059 return syncOK; 1126 return syncOK;
1060 1127
1061} 1128}
1062 1129
1063void KSyncManager::syncPhone() 1130void KSyncManager::syncPhone()
1064{ 1131{
1065 1132
1066 syncExternalApplication("phone"); 1133 syncExternalApplication("phone");
1067 1134
1068} 1135}
1069 1136
1070void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1137void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1071{ 1138{
1072 if (!bar->isVisible()) 1139 if (!bar->isVisible())
1073 { 1140 {
1074 int w = 300; 1141 int w = 300;
1075 if ( QApplication::desktop()->width() < 320 ) 1142 if ( QApplication::desktop()->width() < 320 )
1076 w = 220; 1143 w = 220;
1077 int h = bar->sizeHint().height() ; 1144 int h = bar->sizeHint().height() ;
1078 int dw = QApplication::desktop()->width(); 1145 int dw = QApplication::desktop()->width();
1079 int dh = QApplication::desktop()->height(); 1146 int dh = QApplication::desktop()->height();
1080 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1147 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1081 bar->setCaption (caption); 1148 bar->setCaption (caption);
1082 bar->setTotalSteps ( total ) ; 1149 bar->setTotalSteps ( total ) ;
1083 bar->show(); 1150 bar->show();
1084 } 1151 }
1085 bar->raise(); 1152 bar->raise();
1086 bar->setProgress( percentage ); 1153 bar->setProgress( percentage );
1087 qApp->processEvents(); 1154 qApp->processEvents();
1088} 1155}
1089 1156
1090void KSyncManager::hideProgressBar() 1157void KSyncManager::hideProgressBar()
1091{ 1158{
1092 bar->hide(); 1159 bar->hide();
1093 qApp->processEvents(); 1160 qApp->processEvents();
1094} 1161}
1095 1162
1096bool KSyncManager::isProgressBarCanceled() 1163bool KSyncManager::isProgressBarCanceled()
1097{ 1164{
1098 return !bar->isVisible(); 1165 return !bar->isVisible();
1099} 1166}
1100 1167
1101QString KSyncManager::syncFileName() 1168QString KSyncManager::syncFileName()
1102{ 1169{
1103 1170
1104 QString fn = "tempfile"; 1171 QString fn = "tempfile";
1105 switch(mTargetApp) 1172 switch(mTargetApp)
1106 { 1173 {
1107 case (KAPI): 1174 case (KAPI):
1108 fn = "tempsyncab.vcf"; 1175 fn = "tempsyncab.vcf";
1109 break; 1176 break;
1110 case (KOPI): 1177 case (KOPI):
1111 fn = "tempsynccal.ics"; 1178 fn = "tempsynccal.ics";
1112 break; 1179 break;
1113 case (PWMPI): 1180 case (PWMPI):
1114 fn = "tempsyncpw.pwm"; 1181 fn = "tempsyncpw.pwm";
1115 break; 1182 break;
1116 default: 1183 default:
1117 break; 1184 break;
1118 } 1185 }
1119#ifdef DESKTOP_VERSION 1186#ifdef DESKTOP_VERSION
1120 return locateLocal( "tmp", fn ); 1187 return locateLocal( "tmp", fn );
1121#else 1188#else
1122 return (QString( "/tmp/" )+ fn ); 1189 return (QString( "/tmp/" )+ fn );
1123#endif 1190#endif
1124} 1191}
1125 1192
1126void KSyncManager::syncPi() 1193void KSyncManager::syncPi()
1127{ 1194{
1128 mIsKapiFile = true; 1195 mIsKapiFile = true;
1129 mPisyncFinished = false; 1196 mPisyncFinished = false;
1130 qApp->processEvents(); 1197 qApp->processEvents();
1131 if ( mAskForPreferences ) 1198 if ( mAskForPreferences )
1132 if ( !edit_pisync_options()) { 1199 if ( !edit_pisync_options()) {
1133 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1200 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1134 mPisyncFinished = true; 1201 mPisyncFinished = true;
1135 return; 1202 return;
1136 } 1203 }
1137 bool ok; 1204 bool ok;
1138 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1205 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1139 if ( ! ok ) { 1206 if ( ! ok ) {
1140 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1207 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1141 mPisyncFinished = true; 1208 mPisyncFinished = true;
1142 return; 1209 return;
1143 } 1210 }
1144 mCurrentResourceLocal = ""; 1211 mCurrentResourceLocal = "";
1145 mCurrentResourceRemote = ""; 1212 mCurrentResourceRemote = "";
1146 if ( mSpecificResources.count() ) { 1213 if ( mSpecificResources.count() ) {
1147 uint lastSyncRes = mSpecificResources.count()/2; 1214 uint lastSyncRes = mSpecificResources.count()/2;
1148 int ccc = mSpecificResources.count()-1; 1215 int ccc = mSpecificResources.count()-1;
1149 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) { 1216 while ( lastSyncRes > 0 && ccc > 0 && mSpecificResources[ ccc ].isEmpty() ) {
1150 --ccc; 1217 --ccc;
1151 --lastSyncRes; 1218 --lastSyncRes;
1152 //qDebug ( "KSM: sync pi %d",ccc ); 1219 //qDebug ( "KSM: sync pi %d",ccc );
1153 } 1220 }
1154 uint startLocal = 0; 1221 uint startLocal = 0;
1155 uint startRemote = mSpecificResources.count()/2; 1222 uint startRemote = mSpecificResources.count()/2;
1156 emit multiResourceSyncStart( true ); 1223 emit multiResourceSyncStart( true );
1157 while ( startLocal < mSpecificResources.count()/2 ) { 1224 while ( startLocal < mSpecificResources.count()/2 ) {
1158 if ( startLocal+1 >= lastSyncRes ) 1225 if ( startLocal+1 >= lastSyncRes )
1159 emit multiResourceSyncStart( false ); 1226 emit multiResourceSyncStart( false );
1160 mPisyncFinished = false; 1227 mPisyncFinished = false;
1161 mCurrentResourceLocal = mSpecificResources[ startLocal ]; 1228 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1162 mCurrentResourceRemote = mSpecificResources[ startRemote ]; 1229 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1163 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1230 //qDebug ( "KSM: AAASyncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1164 if ( !mCurrentResourceRemote.isEmpty() ) { 1231 if ( !mCurrentResourceRemote.isEmpty() ) {
1165 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() ); 1232 qDebug ( "KSM: Syncing resources: Local: %s --- Remote: %s ",mCurrentResourceLocal.latin1(), mCurrentResourceRemote.latin1() );
1166 1233
1167 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1234 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1168 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1235 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1169 commandSocket->readFile( syncFileName() ); 1236 commandSocket->readFile( syncFileName() );
1170 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) ); 1237 mParent->topLevelWidget()->setCaption( i18n("Syncing %1 <-> %2").arg( mCurrentResourceLocal ).arg( mCurrentResourceRemote ) );
1171 while ( !mPisyncFinished ) { 1238 while ( !mPisyncFinished ) {
1172 //qDebug("waiting "); 1239 //qDebug("waiting ");
1173 qApp->processEvents(); 1240 qApp->processEvents();
1174 } 1241 }
1175 if ( startLocal+1 < mSpecificResources.count()/2 ) { 1242 if ( startLocal+1 < mSpecificResources.count()/2 ) {
1176 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") ); 1243 mParent->topLevelWidget()->setCaption( i18n("Waiting a second before syncing next resource...") );
1177 QTime timer; 1244 QTime timer;
1178 timer.start(); 1245 timer.start();
1179 while ( timer.elapsed () < 1000 ) { 1246 while ( timer.elapsed () < 1000 ) {
1180 qApp->processEvents(); 1247 qApp->processEvents();
1181 } 1248 }
1182 } 1249 }
1183 } 1250 }
1184 ++startRemote; 1251 ++startRemote;
1185 ++startLocal; 1252 ++startLocal;
1186 mAskForPreferences = false; 1253 mAskForPreferences = false;
1187 } 1254 }
1188 mPisyncFinished = true; 1255 mPisyncFinished = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") ); 1256 mParent->topLevelWidget()->setCaption( i18n("Multi-resource Pi-sync finished") );
1190 } else { 1257 } else {
1191 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1258 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1192 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1259 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1193 commandSocket->readFile( syncFileName() ); 1260 commandSocket->readFile( syncFileName() );
1194 } 1261 }
1195} 1262}
1196 1263
1197void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1264void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1198{ 1265{
1199 //enum { success, errorW, errorR, quiet }; 1266 //enum { success, errorW, errorR, quiet };
1200 1267
1201 1268
1202 1269
1203 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1270 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1204 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1271 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1205 if ( state == KCommandSocket::errorPW ) 1272 if ( state == KCommandSocket::errorPW )
1206 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1273 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1207 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1274 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1208 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1275 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1209 else if ( state == KCommandSocket::errorCA ) 1276 else if ( state == KCommandSocket::errorCA )
1210 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1277 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1211 else if ( state == KCommandSocket::errorFI ) 1278 else if ( state == KCommandSocket::errorFI )
1212 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1279 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1213 else if ( state == KCommandSocket::errorED ) 1280 else if ( state == KCommandSocket::errorED )
1214 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1281 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1215 else if ( state == KCommandSocket::errorUN ) 1282 else if ( state == KCommandSocket::errorUN )
1216 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1283 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1217 delete s; 1284 delete s;
1218 if ( state == KCommandSocket::errorR ) { 1285 if ( state == KCommandSocket::errorR ) {
1219 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1286 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1220 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1287 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1221 commandSocket->sendStop(); 1288 commandSocket->sendStop();
1222 } 1289 }
1223 mPisyncFinished = true; 1290 mPisyncFinished = true;
1224 return; 1291 return;
1225 1292
1226 } else if ( state == KCommandSocket::errorW ) { 1293 } else if ( state == KCommandSocket::errorW ) {
1227 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1294 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1228 mPisyncFinished = true; 1295 mPisyncFinished = true;
1229 1296
1230 } else if ( state == KCommandSocket::successR ) { 1297 } else if ( state == KCommandSocket::successR ) {
1231 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1298 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1232 1299
1233 } else if ( state == KCommandSocket::successW ) { 1300 } else if ( state == KCommandSocket::successW ) {
1234 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1301 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1235 mPisyncFinished = true; 1302 mPisyncFinished = true;
1236 } else if ( state == KCommandSocket::quiet ){ 1303 } else if ( state == KCommandSocket::quiet ){
1237 qDebug("KSS: quiet "); 1304 qDebug("KSS: quiet ");
1238 mPisyncFinished = true; 1305 mPisyncFinished = true;
1239 } else { 1306 } else {
1240 qDebug("KSS: Error: unknown state: %d ", state); 1307 qDebug("KSS: Error: unknown state: %d ", state);
1241 mPisyncFinished = true; 1308 mPisyncFinished = true;
1242 } 1309 }
1243 1310
1244 delete s; 1311 delete s;
1245} 1312}
1246 1313
1247void KSyncManager::readFileFromSocket() 1314void KSyncManager::readFileFromSocket()
1248{ 1315{
1249 QString fileName = syncFileName(); 1316 QString fileName = syncFileName();
1250 bool syncOK = true; 1317 bool syncOK = true;
1251 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1318 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1252 if ( ! syncWithFile( fileName , true ) ) { 1319 if ( ! syncWithFile( fileName , true ) ) {
1253 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1320 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1254 syncOK = false; 1321 syncOK = false;
1255 } 1322 }
1256 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1323 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1257 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1324 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1258 if ( mWriteBackFile && syncOK ) { 1325 if ( mWriteBackFile && syncOK ) {
1259 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1326 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1260 commandSocket->writeFile( fileName ); 1327 commandSocket->writeFile( fileName );
1261 } 1328 }
1262 else { 1329 else {
1263 commandSocket->sendStop(); 1330 commandSocket->sendStop();
1264 if ( syncOK ) 1331 if ( syncOK )
1265 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1332 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1266 mPisyncFinished = true; 1333 mPisyncFinished = true;
1267 } 1334 }
1268} 1335}
1269 1336
1270KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1337KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1271{ 1338{
1272 mPendingConnect = 0; 1339 mPendingConnect = 0;
1273 mPassWord = pw; 1340 mPassWord = pw;
1274 mSocket = 0; 1341 mSocket = 0;
1275 mSyncActionDialog = 0; 1342 mSyncActionDialog = 0;
1276 blockRC = false; 1343 blockRC = false;
1277 mErrorMessage = 0; 1344 mErrorMessage = 0;
1278} 1345}
1279void KServerSocket::waitForSocketFinish() 1346void KServerSocket::waitForSocketFinish()
1280{ 1347{
1281 if ( mSocket ) { 1348 if ( mSocket ) {
1282 //qDebug("KSS:: waiting for finish operation"); 1349 //qDebug("KSS:: waiting for finish operation");
1283 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1350 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1284 return; 1351 return;
1285 } 1352 }
1286 mSocket = new QSocket( this ); 1353 mSocket = new QSocket( this );
1287 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1354 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1288 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1355 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1289 mSocket->setSocket( mPendingConnect ); 1356 mSocket->setSocket( mPendingConnect );
1290 mPendingConnect = 0; 1357 mPendingConnect = 0;
1291} 1358}
1292void KServerSocket::newConnection ( int socket ) 1359void KServerSocket::newConnection ( int socket )
1293{ 1360{
1294 // qDebug("KServerSocket:New connection %d ", socket); 1361 // qDebug("KServerSocket:New connection %d ", socket);
1295 if ( mPendingConnect ) { 1362 if ( mPendingConnect ) {
1296 qDebug("KSS::Error : new Connection"); 1363 qDebug("KSS::Error : new Connection");
1297 return; 1364 return;
1298 } 1365 }
1299 if ( mSocket ) { 1366 if ( mSocket ) {
1300 mPendingConnect = socket; 1367 mPendingConnect = socket;
1301 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish())); 1368 QTimer::singleShot( 250, this , SLOT ( waitForSocketFinish()));
1302 return; 1369 return;
1303 qDebug("KSS::newConnection Socket deleted! "); 1370 qDebug("KSS::newConnection Socket deleted! ");
1304 delete mSocket; 1371 delete mSocket;
1305 mSocket = 0; 1372 mSocket = 0;
1306 } 1373 }
1307 mPendingConnect = 0; 1374 mPendingConnect = 0;
1308 mSocket = new QSocket( this ); 1375 mSocket = new QSocket( this );
1309 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1376 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1310 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1377 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1311 mSocket->setSocket( socket ); 1378 mSocket->setSocket( socket );
1312} 1379}
1313 1380
1314void KServerSocket::discardClient() 1381void KServerSocket::discardClient()
1315{ 1382{
1316 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1383 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1317} 1384}
1318void KServerSocket::deleteSocket() 1385void KServerSocket::deleteSocket()
1319{ 1386{
1320 //qDebug("KSS::deleteSocket"); 1387 //qDebug("KSS::deleteSocket");
1321 if ( mSocket ) { 1388 if ( mSocket ) {
1322 delete mSocket; 1389 delete mSocket;
1323 mSocket = 0; 1390 mSocket = 0;
1324 } 1391 }
1325 if ( mErrorMessage ) 1392 if ( mErrorMessage )
1326 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1393 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1327} 1394}
1328void KServerSocket::readClient() 1395void KServerSocket::readClient()
1329{ 1396{
1330 if ( blockRC ) 1397 if ( blockRC )
1331 return; 1398 return;
1332 if ( mSocket == 0 ) { 1399 if ( mSocket == 0 ) {
1333 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1400 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1334 return; 1401 return;
1335 } 1402 }
1336 if ( mErrorMessage ) { 1403 if ( mErrorMessage ) {
1337 mErrorMessage = 999; 1404 mErrorMessage = 999;
1338 error_connect("ERROR_ED\r\n\r\n"); 1405 error_connect("ERROR_ED\r\n\r\n");
1339 return; 1406 return;
1340 } 1407 }
1341 mResource = ""; 1408 mResource = "";
1342 mErrorMessage = 0; 1409 mErrorMessage = 0;
1343 //qDebug("KServerSocket::readClient()"); 1410 //qDebug("KServerSocket::readClient()");
1344 if ( mSocket->canReadLine() ) { 1411 if ( mSocket->canReadLine() ) {
1345 QString line = mSocket->readLine(); 1412 QString line = mSocket->readLine();
1346 //qDebug("KServerSocket readline: %s ", line.latin1()); 1413 //qDebug("KServerSocket readline: %s ", line.latin1());
1347 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1414 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1348 if ( tokens[0] == "GET" ) { 1415 if ( tokens[0] == "GET" ) {
1349 if ( tokens[1] == mPassWord ) { 1416 if ( tokens[1] == mPassWord ) {
1350 //emit sendFile( mSocket ); 1417 //emit sendFile( mSocket );
1351 bool ok = false; 1418 bool ok = false;
1352 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1419 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1353 if ( ok ) { 1420 if ( ok ) {
1354 KSyncManager::mRequestedSyncEvent = dt; 1421 KSyncManager::mRequestedSyncEvent = dt;
1355 } 1422 }
1356 else 1423 else
1357 KSyncManager::mRequestedSyncEvent = QDateTime(); 1424 KSyncManager::mRequestedSyncEvent = QDateTime();
1358 mResource =tokens[3]; 1425 mResource =tokens[3];
1359 send_file(); 1426 send_file();
1360 } 1427 }
1361 else { 1428 else {
1362 mErrorMessage = 1; 1429 mErrorMessage = 1;
1363 error_connect("ERROR_PW\r\n\r\n"); 1430 error_connect("ERROR_PW\r\n\r\n");
1364 } 1431 }
1365 } 1432 }
1366 if ( tokens[0] == "PUT" ) { 1433 if ( tokens[0] == "PUT" ) {
1367 if ( tokens[1] == mPassWord ) { 1434 if ( tokens[1] == mPassWord ) {
1368 //emit getFile( mSocket ); 1435 //emit getFile( mSocket );
1369 blockRC = true; 1436 blockRC = true;
1370 mResource =tokens[2]; 1437 mResource =tokens[2];
1371 get_file(); 1438 get_file();
1372 } 1439 }
1373 else { 1440 else {
1374 mErrorMessage = 2; 1441 mErrorMessage = 2;
1375 error_connect("ERROR_PW\r\n\r\n"); 1442 error_connect("ERROR_PW\r\n\r\n");
1376 end_connect(); 1443 end_connect();
1377 } 1444 }
1378 } 1445 }
1379 if ( tokens[0] == "STOP" ) { 1446 if ( tokens[0] == "STOP" ) {
1380 //emit endConnect(); 1447 //emit endConnect();
1381 end_connect(); 1448 end_connect();
1382 } 1449 }
1383 } 1450 }
1384} 1451}
1385void KServerSocket::displayErrorMessage() 1452void KServerSocket::displayErrorMessage()
1386{ 1453{
1387 if ( mErrorMessage == 1 ) { 1454 if ( mErrorMessage == 1 ) {
1388 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1455 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1389 mErrorMessage = 0; 1456 mErrorMessage = 0;
1390 } 1457 }
1391 else if ( mErrorMessage == 2 ) { 1458 else if ( mErrorMessage == 2 ) {
1392 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1459 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1393 mErrorMessage = 0; 1460 mErrorMessage = 0;
1394 } 1461 }
1395} 1462}
1396void KServerSocket::error_connect( QString errmess ) 1463void KServerSocket::error_connect( QString errmess )
1397{ 1464{
1398 QTextStream os( mSocket ); 1465 QTextStream os( mSocket );
1399 os.setEncoding( QTextStream::Latin1 ); 1466 os.setEncoding( QTextStream::Latin1 );
1400 os << errmess ; 1467 os << errmess ;
1401 mSocket->close(); 1468 mSocket->close();
1402 if ( mSocket->state() == QSocket::Idle ) { 1469 if ( mSocket->state() == QSocket::Idle ) {
1403 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1470 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1404 } 1471 }
1405} 1472}
1406void KServerSocket::end_connect() 1473void KServerSocket::end_connect()
1407{ 1474{
1408 delete mSyncActionDialog; 1475 delete mSyncActionDialog;
1409 mSyncActionDialog = 0; 1476 mSyncActionDialog = 0;
1410} 1477}
1411void KServerSocket::send_file() 1478void KServerSocket::send_file()
1412{ 1479{
1413 //qDebug("MainWindow::sendFile(QSocket* s) "); 1480 //qDebug("MainWindow::sendFile(QSocket* s) ");
1414 if ( mSyncActionDialog ) 1481 if ( mSyncActionDialog )
1415 delete mSyncActionDialog; 1482 delete mSyncActionDialog;
1416 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1483 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1417 mSyncActionDialog->setCaption(i18n("Received sync request")); 1484 mSyncActionDialog->setCaption(i18n("Received sync request"));
1418 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1485 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1419 label->setAlignment ( Qt::AlignHCenter ); 1486 label->setAlignment ( Qt::AlignHCenter );
1420 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1487 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1421 lay->addWidget( label); 1488 lay->addWidget( label);
1422 lay->setMargin(7); 1489 lay->setMargin(7);
1423 lay->setSpacing(7); 1490 lay->setSpacing(7);
1424 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1491 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1425 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1492 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1426 //secs = 333; 1493 //secs = 333;
1427 if ( secs < 0 ) 1494 if ( secs < 0 )
1428 secs = secs * (-1); 1495 secs = secs * (-1);
1429 if ( secs > 30 ) 1496 if ( secs > 30 )
1430 //if ( true ) 1497 //if ( true )
1431 { 1498 {
1432 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1499 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1433 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1500 QLabel* label = new QLabel( warning, mSyncActionDialog );
1434 label->setAlignment ( Qt::AlignHCenter ); 1501 label->setAlignment ( Qt::AlignHCenter );
1435 lay->addWidget( label); 1502 lay->addWidget( label);
1436 if ( secs > 180 ) 1503 if ( secs > 180 )
1437 { 1504 {
1438 if ( secs > 300 ) { 1505 if ( secs > 300 ) {
1439 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1506 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1440 qDebug("KSS::Sync cancelled ,cs"); 1507 qDebug("KSS::Sync cancelled ,cs");
1441 mErrorMessage = 0; 1508 mErrorMessage = 0;
1442 end_connect(); 1509 end_connect();
1443 error_connect("ERROR_CA\r\n\r\n"); 1510 error_connect("ERROR_CA\r\n\r\n");
1444 return ; 1511 return ;
1445 } 1512 }
1446 } 1513 }
1447 QFont f = label->font(); 1514 QFont f = label->font();
1448 f.setPointSize ( f.pointSize() *2 ); 1515 f.setPointSize ( f.pointSize() *2 );
1449 f. setBold (true ); 1516 f. setBold (true );
1450 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1517 QLabel* label = new QLabel( warning, mSyncActionDialog );
1451 label->setFont( f ); 1518 label->setFont( f );
1452 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1519 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1453 label->setText( warning ); 1520 label->setText( warning );
1454 label->setAlignment ( Qt::AlignHCenter ); 1521 label->setAlignment ( Qt::AlignHCenter );
1455 lay->addWidget( label); 1522 lay->addWidget( label);
1456 mSyncActionDialog->setFixedSize( 230, 300); 1523 mSyncActionDialog->setFixedSize( 230, 300);
1457 } else { 1524 } else {
1458 mSyncActionDialog->setFixedSize( 230, 200); 1525 mSyncActionDialog->setFixedSize( 230, 200);
1459 } 1526 }
1460 } else { 1527 } else {
1461 mSyncActionDialog->setFixedSize( 230, 120); 1528 mSyncActionDialog->setFixedSize( 230, 120);
1462 } 1529 }
1463 } else 1530 } else
1464 mSyncActionDialog->setFixedSize( 230, 120); 1531 mSyncActionDialog->setFixedSize( 230, 120);
1465 mSyncActionDialog->show(); 1532 mSyncActionDialog->show();
1466 mSyncActionDialog->raise(); 1533 mSyncActionDialog->raise();
1467 emit request_file(mResource); 1534 emit request_file(mResource);
1468 //emit request_file(); 1535 //emit request_file();
1469 qApp->processEvents(); 1536 qApp->processEvents();
1470 QString fileName = mFileName; 1537 QString fileName = mFileName;
1471 QFile file( fileName ); 1538 QFile file( fileName );
1472 if (!file.open( IO_ReadOnly ) ) { 1539 if (!file.open( IO_ReadOnly ) ) {
1473 mErrorMessage = 0; 1540 mErrorMessage = 0;
1474 end_connect(); 1541 end_connect();
1475 error_connect("ERROR_FI\r\n\r\n"); 1542 error_connect("ERROR_FI\r\n\r\n");
1476 return ; 1543 return ;
1477 } 1544 }
1478 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1545 mSyncActionDialog->setCaption( i18n("Sending file...") );
1479 QTextStream ts( &file ); 1546 QTextStream ts( &file );
1480 ts.setEncoding( QTextStream::Latin1 ); 1547 ts.setEncoding( QTextStream::Latin1 );
1481 1548
1482 QTextStream os( mSocket ); 1549 QTextStream os( mSocket );
1483 os.setEncoding( QTextStream::Latin1 ); 1550 os.setEncoding( QTextStream::Latin1 );
1484 while ( ! ts.atEnd() ) { 1551 while ( ! ts.atEnd() ) {
1485 os << ts.readLine() << "\r\n"; 1552 os << ts.readLine() << "\r\n";
1486 } 1553 }
1487 os << "\r\n"; 1554 os << "\r\n";
1488 //os << ts.read(); 1555 //os << ts.read();
1489 file.close(); 1556 file.close();
1490 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1557 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1491 mSocket->close(); 1558 mSocket->close();
1492 if ( mSocket->state() == QSocket::Idle ) 1559 if ( mSocket->state() == QSocket::Idle )
1493 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1560 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1494} 1561}
1495void KServerSocket::get_file() 1562void KServerSocket::get_file()
1496{ 1563{
1497 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1564 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1498 1565
1499 piTime.start(); 1566 piTime.start();
1500 piFileString = ""; 1567 piFileString = "";
1501 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1568 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1502} 1569}
1503 1570
1504 1571
1505void KServerSocket::readBackFileFromSocket() 1572void KServerSocket::readBackFileFromSocket()
1506{ 1573{
1507 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1574 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1508 while ( mSocket->canReadLine () ) { 1575 while ( mSocket->canReadLine () ) {
1509 piTime.restart(); 1576 piTime.restart();
1510 QString line = mSocket->readLine (); 1577 QString line = mSocket->readLine ();
1511 piFileString += line; 1578 piFileString += line;
1512 //qDebug("readline: %s ", line.latin1()); 1579 //qDebug("readline: %s ", line.latin1());
1513 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1580 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1514 1581
1515 } 1582 }
1516 if ( piTime.elapsed () < 3000 ) { 1583 if ( piTime.elapsed () < 3000 ) {
1517 // wait for more 1584 // wait for more
1518 //qDebug("waitformore "); 1585 //qDebug("waitformore ");
1519 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1586 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1520 return; 1587 return;
1521 } 1588 }
1522 QString fileName = mFileName; 1589 QString fileName = mFileName;
1523 QFile file ( fileName ); 1590 QFile file ( fileName );
1524 if (!file.open( IO_WriteOnly ) ) { 1591 if (!file.open( IO_WriteOnly ) ) {
1525 delete mSyncActionDialog; 1592 delete mSyncActionDialog;
1526 mSyncActionDialog = 0; 1593 mSyncActionDialog = 0;
1527 qDebug("KSS:Error open read back file "); 1594 qDebug("KSS:Error open read back file ");
1528 piFileString = ""; 1595 piFileString = "";
1529 emit file_received( false, mResource); 1596 emit file_received( false, mResource);
1530 emit file_received( false); 1597 emit file_received( false);
1531 blockRC = false; 1598 blockRC = false;
1532 return ; 1599 return ;
1533 1600
1534 } 1601 }
1535 1602
1536 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1603 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1537 QTextStream ts ( &file ); 1604 QTextStream ts ( &file );
1538 ts.setEncoding( QTextStream::Latin1 ); 1605 ts.setEncoding( QTextStream::Latin1 );
1539 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1606 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1540 ts << piFileString; 1607 ts << piFileString;
1541 mSocket->close(); 1608 mSocket->close();
1542 if ( mSocket->state() == QSocket::Idle ) 1609 if ( mSocket->state() == QSocket::Idle )
1543 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1610 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1544 file.close(); 1611 file.close();
1545 piFileString = ""; 1612 piFileString = "";
1546 emit file_received( true, mResource ); 1613 emit file_received( true, mResource );
1547 emit file_received( true); 1614 emit file_received( true);
1548 delete mSyncActionDialog; 1615 delete mSyncActionDialog;
1549 mSyncActionDialog = 0; 1616 mSyncActionDialog = 0;
1550 blockRC = false; 1617 blockRC = false;
1551 1618
1552} 1619}
1553 1620
1554KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1621KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1555{ 1622{
1556 mRemoteResource = remres; 1623 mRemoteResource = remres;
1557 if ( mRemoteResource.isEmpty() ) 1624 if ( mRemoteResource.isEmpty() )
1558 mRemoteResource = "ALL"; 1625 mRemoteResource = "ALL";
1559 else 1626 else
1560 mRemoteResource.replace (QRegExp (" "),"_" ); 1627 mRemoteResource.replace (QRegExp (" "),"_" );
1561 mPassWord = password; 1628 mPassWord = password;
1562 mSocket = 0; 1629 mSocket = 0;
1563 mFirst = false; 1630 mFirst = false;
1564 mFirstLine = true; 1631 mFirstLine = true;
1565 mPort = port; 1632 mPort = port;
1566 mHost = host; 1633 mHost = host;
1567 tlw = cap; 1634 tlw = cap;
1568 mRetVal = quiet; 1635 mRetVal = quiet;
1569 mTimerSocket = new QTimer ( this ); 1636 mTimerSocket = new QTimer ( this );
1570 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1637 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1571 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1638 mConnectProgress.setCaption( i18n("Pi-Sync") );
1572 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1639 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1573 mConnectCount = -1; 1640 mConnectCount = -1;
1574} 1641}
1575void KCommandSocket::sendFileRequest() 1642void KCommandSocket::sendFileRequest()
1576{ 1643{
1577 if ( tlw ) 1644 if ( tlw )
1578 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1645 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1579 mConnectProgress.hide(); 1646 mConnectProgress.hide();
1580 mConnectCount = 300;mConnectMax = 300; 1647 mConnectCount = 300;mConnectMax = 300;
1581 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1648 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1582 mConnectProgress.setLabelText( i18n("Waiting for remote file...") ); 1649 mConnectProgress.setLabelText( i18n("Waiting for remote file...") );
1583 mTimerSocket->start( 100, true ); 1650 mTimerSocket->start( 100, true );
1584 QTextStream os( mSocket ); 1651 QTextStream os( mSocket );
1585 os.setEncoding( QTextStream::Latin1 ); 1652 os.setEncoding( QTextStream::Latin1 );
1586 1653
1587 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1654 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1588 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n"; 1655 os << "GET " << mPassWord << curDt << " " << mRemoteResource << "\r\n\r\n";
1589} 1656}
1590 1657
1591void KCommandSocket::readFile( QString fn ) 1658void KCommandSocket::readFile( QString fn )
1592{ 1659{
1593 if ( !mSocket ) { 1660 if ( !mSocket ) {
1594 mSocket = new QSocket( this ); 1661 mSocket = new QSocket( this );
1595 //qDebug("KCS: read file - new socket"); 1662 //qDebug("KCS: read file - new socket");
1596 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1663 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1597 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1664 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1598 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1665 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1599 } 1666 }
1600 mFileString = ""; 1667 mFileString = "";
1601 mFileName = fn; 1668 mFileName = fn;
1602 mFirst = true; 1669 mFirst = true;
1603 if ( tlw ) 1670 if ( tlw )
1604 tlw->setCaption( i18n("Trying to connect to remote...") ); 1671 tlw->setCaption( i18n("Trying to connect to remote...") );
1605 mConnectCount = 30;mConnectMax = 30; 1672 mConnectCount = 30;mConnectMax = 30;
1606 mTimerSocket->start( 1000, true ); 1673 mTimerSocket->start( 1000, true );
1607 mSocket->connectToHost( mHost, mPort ); 1674 mSocket->connectToHost( mHost, mPort );
1608 //qDebug("KCS: Waiting for connection"); 1675 //qDebug("KCS: Waiting for connection");
1609} 1676}
1610void KCommandSocket::updateConnectDialog() 1677void KCommandSocket::updateConnectDialog()
1611{ 1678{
1612 1679
1613 if ( mConnectCount == mConnectMax ) { 1680 if ( mConnectCount == mConnectMax ) {
1614 //qDebug("MAXX %d", mConnectMax); 1681 //qDebug("MAXX %d", mConnectMax);
1615 mConnectProgress.setTotalSteps ( 30 ); 1682 mConnectProgress.setTotalSteps ( 30 );
1616 mConnectProgress.show(); 1683 mConnectProgress.show();
1617 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1684 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1618 } 1685 }
1619 //qDebug("updateConnectDialog() %d", mConnectCount); 1686 //qDebug("updateConnectDialog() %d", mConnectCount);
1620 mConnectProgress.raise(); 1687 mConnectProgress.raise();
1621 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1688 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1622 --mConnectCount; 1689 --mConnectCount;
1623 if ( mConnectCount > 0 ) 1690 if ( mConnectCount > 0 )
1624 mTimerSocket->start( 1000, true ); 1691 mTimerSocket->start( 1000, true );
1625 else 1692 else
1626 deleteSocket(); 1693 deleteSocket();
1627 1694
1628} 1695}
1629void KCommandSocket::writeFile( QString fileName ) 1696void KCommandSocket::writeFile( QString fileName )
1630{ 1697{
1631 if ( !mSocket ) { 1698 if ( !mSocket ) {
1632 mSocket = new QSocket( this ); 1699 mSocket = new QSocket( this );
1633 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1700 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1634 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1701 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1635 } 1702 }
1636 mFileName = fileName ; 1703 mFileName = fileName ;
1637 mConnectCount = 30;mConnectMax = 30; 1704 mConnectCount = 30;mConnectMax = 30;
1638 mTimerSocket->start( 1000, true ); 1705 mTimerSocket->start( 1000, true );
1639 mSocket->connectToHost( mHost, mPort ); 1706 mSocket->connectToHost( mHost, mPort );
1640} 1707}
1641void KCommandSocket::writeFileToSocket() 1708void KCommandSocket::writeFileToSocket()
1642{ 1709{
1643 mTimerSocket->stop(); 1710 mTimerSocket->stop();
1644 QFile file2( mFileName ); 1711 QFile file2( mFileName );
1645 if (!file2.open( IO_ReadOnly ) ) { 1712 if (!file2.open( IO_ReadOnly ) ) {
1646 mConnectProgress.hide(); 1713 mConnectProgress.hide();
1647 mConnectCount = -1; 1714 mConnectCount = -1;
1648 mRetVal= errorW; 1715 mRetVal= errorW;
1649 mSocket->close(); 1716 mSocket->close();
1650 if ( mSocket->state() == QSocket::Idle ) 1717 if ( mSocket->state() == QSocket::Idle )
1651 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1718 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1652 return ; 1719 return ;
1653 } 1720 }
1654 mConnectProgress.setTotalSteps ( file2.size() ); 1721 mConnectProgress.setTotalSteps ( file2.size() );
1655 mConnectProgress.show(); 1722 mConnectProgress.show();
1656 int count = 0; 1723 int count = 0;
1657 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1724 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1658 mConnectProgress.setProgress( count ); 1725 mConnectProgress.setProgress( count );
1659 mConnectProgress.blockSignals( true ); 1726 mConnectProgress.blockSignals( true );
1660 QTextStream ts2( &file2 ); 1727 QTextStream ts2( &file2 );
1661 ts2.setEncoding( QTextStream::Latin1 ); 1728 ts2.setEncoding( QTextStream::Latin1 );
1662 QTextStream os2( mSocket ); 1729 QTextStream os2( mSocket );
1663 os2.setEncoding( QTextStream::Latin1 ); 1730 os2.setEncoding( QTextStream::Latin1 );
1664 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";; 1731 os2 << "PUT " << mPassWord << " " << mRemoteResource << "\r\n\r\n";;
1665 int byteCount = 0; 1732 int byteCount = 0;
1666 int byteMax = file2.size()/53; 1733 int byteMax = file2.size()/53;
1667 while ( ! ts2.atEnd() ) { 1734 while ( ! ts2.atEnd() ) {
1668 qApp->processEvents(); 1735 qApp->processEvents();
1669 if ( byteCount > byteMax ) { 1736 if ( byteCount > byteMax ) {
1670 byteCount = 0; 1737 byteCount = 0;
1671 mConnectProgress.setProgress( count ); 1738 mConnectProgress.setProgress( count );
1672 } 1739 }
1673 QString temp = ts2.readLine(); 1740 QString temp = ts2.readLine();
1674 count += temp.length(); 1741 count += temp.length();
1675 byteCount += temp.length(); 1742 byteCount += temp.length();
1676 os2 << temp << "\r\n"; 1743 os2 << temp << "\r\n";
1677 } 1744 }
1678 file2.close(); 1745 file2.close();
1679 mConnectProgress.hide(); 1746 mConnectProgress.hide();
1680 mConnectCount = -1; 1747 mConnectCount = -1;
1681 os2 << "\r\n"; 1748 os2 << "\r\n";
1682 mRetVal= successW; 1749 mRetVal= successW;
1683 mSocket->close(); 1750 mSocket->close();
1684 if ( mSocket->state() == QSocket::Idle ) 1751 if ( mSocket->state() == QSocket::Idle )
1685 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1752 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1686 mConnectProgress.blockSignals( false ); 1753 mConnectProgress.blockSignals( false );
1687} 1754}
1688void KCommandSocket::sendStop() 1755void KCommandSocket::sendStop()
1689{ 1756{
1690 if ( !mSocket ) { 1757 if ( !mSocket ) {
1691 mSocket = new QSocket( this ); 1758 mSocket = new QSocket( this );
1692 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1759 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1693 } 1760 }
1694 mSocket->connectToHost( mHost, mPort ); 1761 mSocket->connectToHost( mHost, mPort );
1695 QTextStream os2( mSocket ); 1762 QTextStream os2( mSocket );
1696 os2.setEncoding( QTextStream::Latin1 ); 1763 os2.setEncoding( QTextStream::Latin1 );
1697 os2 << "STOP\r\n\r\n"; 1764 os2 << "STOP\r\n\r\n";
1698 mSocket->close(); 1765 mSocket->close();
1699 if ( mSocket->state() == QSocket::Idle ) 1766 if ( mSocket->state() == QSocket::Idle )
1700 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1767 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1701} 1768}
1702 1769
1703void KCommandSocket::startReadFileFromSocket() 1770void KCommandSocket::startReadFileFromSocket()
1704{ 1771{
1705 if ( ! mFirst ) 1772 if ( ! mFirst )
1706 return; 1773 return;
1707 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1774 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1708 mFirst = false; 1775 mFirst = false;
1709 mFileString = ""; 1776 mFileString = "";
1710 mTime.start(); 1777 mTime.start();
1711 mFirstLine = true; 1778 mFirstLine = true;
1712 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1779 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1713 1780
1714} 1781}
1715void KCommandSocket::readFileFromSocket() 1782void KCommandSocket::readFileFromSocket()
1716{ 1783{
1717 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1784 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1718 while ( mSocket->canReadLine () ) { 1785 while ( mSocket->canReadLine () ) {
1719 mTime.restart(); 1786 mTime.restart();
1720 QString line = mSocket->readLine (); 1787 QString line = mSocket->readLine ();
1721 if ( mFirstLine ) { 1788 if ( mFirstLine ) {
1722 mFirstLine = false; 1789 mFirstLine = false;
1723 if ( line.left( 6 ) == "ERROR_" ) { 1790 if ( line.left( 6 ) == "ERROR_" ) {
1724 mTimerSocket->stop(); 1791 mTimerSocket->stop();
1725 mConnectCount = -1; 1792 mConnectCount = -1;
1726 if ( line.left( 8 ) == "ERROR_PW" ) { 1793 if ( line.left( 8 ) == "ERROR_PW" ) {
1727 mRetVal = errorPW; 1794 mRetVal = errorPW;
1728 deleteSocket(); 1795 deleteSocket();
1729 return ; 1796 return ;
1730 } 1797 }
1731 if ( line.left( 8 ) == "ERROR_CA" ) { 1798 if ( line.left( 8 ) == "ERROR_CA" ) {
1732 mRetVal = errorCA; 1799 mRetVal = errorCA;
1733 deleteSocket(); 1800 deleteSocket();
1734 return ; 1801 return ;
1735 } 1802 }
1736 if ( line.left( 8 ) == "ERROR_FI" ) { 1803 if ( line.left( 8 ) == "ERROR_FI" ) {
1737 mRetVal = errorFI; 1804 mRetVal = errorFI;
1738 deleteSocket(); 1805 deleteSocket();
1739 return ; 1806 return ;
1740 } 1807 }
1741 if ( line.left( 8 ) == "ERROR_ED" ) { 1808 if ( line.left( 8 ) == "ERROR_ED" ) {
1742 mRetVal = errorED; 1809 mRetVal = errorED;
1743 deleteSocket(); 1810 deleteSocket();
1744 return ; 1811 return ;
1745 } 1812 }
1746 mRetVal = errorUN; 1813 mRetVal = errorUN;
1747 deleteSocket(); 1814 deleteSocket();
1748 return ; 1815 return ;
1749 } 1816 }
1750 } 1817 }
1751 mFileString += line; 1818 mFileString += line;
1752 //qDebug("readline: %s ", line.latin1()); 1819 //qDebug("readline: %s ", line.latin1());
1753 } 1820 }
1754 if ( mTime.elapsed () < 3000 ) { 1821 if ( mTime.elapsed () < 3000 ) {
1755 // wait for more 1822 // wait for more
1756 //qDebug("waitformore "); 1823 //qDebug("waitformore ");
1757 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1824 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1758 return; 1825 return;
1759 } 1826 }
1760 mTimerSocket->stop(); 1827 mTimerSocket->stop();
1761 mConnectCount = -1; 1828 mConnectCount = -1;
1762 mConnectProgress.hide(); 1829 mConnectProgress.hide();
1763 QString fileName = mFileName; 1830 QString fileName = mFileName;
1764 QFile file ( fileName ); 1831 QFile file ( fileName );
1765 if (!file.open( IO_WriteOnly ) ) { 1832 if (!file.open( IO_WriteOnly ) ) {
1766 mFileString = ""; 1833 mFileString = "";
1767 mRetVal = errorR; 1834 mRetVal = errorR;
1768 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1835 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1769 deleteSocket(); 1836 deleteSocket();
1770 return ; 1837 return ;
1771 1838
1772 } 1839 }
1773 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1840 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1774 QTextStream ts ( &file ); 1841 QTextStream ts ( &file );
1775 ts.setEncoding( QTextStream::Latin1 ); 1842 ts.setEncoding( QTextStream::Latin1 );
1776 ts << mFileString; 1843 ts << mFileString;
1777 file.close(); 1844 file.close();
1778 mFileString = ""; 1845 mFileString = "";
1779 mRetVal = successR; 1846 mRetVal = successR;
1780 mSocket->close(); 1847 mSocket->close();
1781 // if state is not idle, deleteSocket(); is called via 1848 // if state is not idle, deleteSocket(); is called via
1782 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1849 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1783 if ( mSocket->state() == QSocket::Idle ) 1850 if ( mSocket->state() == QSocket::Idle )
1784 deleteSocket(); 1851 deleteSocket();
1785} 1852}
1786 1853
1787void KCommandSocket::deleteSocket() 1854void KCommandSocket::deleteSocket()
1788{ 1855{
1789 //qDebug("KCommandSocket::deleteSocket() "); 1856 //qDebug("KCommandSocket::deleteSocket() ");
1790 mConnectProgress.hide(); 1857 mConnectProgress.hide();
1791 1858
1792 if ( mConnectCount >= 0 ) { 1859 if ( mConnectCount >= 0 ) {
1793 mTimerSocket->stop(); 1860 mTimerSocket->stop();
1794 mRetVal = errorTO; 1861 mRetVal = errorTO;
1795 qDebug("KCS::Connection to remote host timed out"); 1862 qDebug("KCS::Connection to remote host timed out");
1796 if ( mSocket ) { 1863 if ( mSocket ) {
1797 mSocket->close(); 1864 mSocket->close();
1798 //if ( mSocket->state() == QSocket::Idle ) 1865 //if ( mSocket->state() == QSocket::Idle )
1799 // deleteSocket(); 1866 // deleteSocket();
1800 delete mSocket; 1867 delete mSocket;
1801 mSocket = 0; 1868 mSocket = 0;
1802 } 1869 }
1803 if ( mConnectCount == 0 ) 1870 if ( mConnectCount == 0 )
1804 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1871 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1805 else if ( tlw ) 1872 else if ( tlw )
1806 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1873 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1807 emit commandFinished( this, mRetVal ); 1874 emit commandFinished( this, mRetVal );
1808 return; 1875 return;
1809 } 1876 }
1810 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1877 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1811 if ( mSocket) 1878 if ( mSocket)
1812 delete mSocket; 1879 delete mSocket;
1813 mSocket = 0; 1880 mSocket = 0;
1814 //qDebug("commandFinished "); 1881 //qDebug("commandFinished ");
1815 emit commandFinished( this, mRetVal ); 1882 emit commandFinished( this, mRetVal );
1816} 1883}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 04cdade..71d17e9 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,249 +1,248 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32#include <qprogressdialog.h> 32#include <qprogressdialog.h>
33#include <kdialog.h> 33#include <kdialog.h>
34 34
35class QPopupMenu; 35class QPopupMenu;
36class KSyncProfile; 36class KSyncProfile;
37class KPimPrefs; 37class KPimPrefs;
38class QWidget; 38class QWidget;
39class KSyncManager; 39class KSyncManager;
40class KSyncInterface; 40class KSyncInterface;
41class QProgressBar; 41class QProgressBar;
42 42
43 43
44class KServerSocket : public QServerSocket 44class KServerSocket : public QServerSocket
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
50 50
51 void newConnection ( int socket ) ; 51 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 52 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 53 signals:
54 void file_received( bool ); 54 void file_received( bool );
55 void request_file(); 55 void request_file();
56 void file_received( bool, const QString &); 56 void file_received( bool, const QString &);
57 void request_file(const QString &); 57 void request_file(const QString &);
58 void saveFile(); 58 void saveFile();
59 void endConnect(); 59 void endConnect();
60 private slots: 60 private slots:
61 void waitForSocketFinish(); 61 void waitForSocketFinish();
62 void discardClient(); 62 void discardClient();
63 void deleteSocket(); 63 void deleteSocket();
64 void readClient(); 64 void readClient();
65 void displayErrorMessage(); 65 void displayErrorMessage();
66 void readBackFileFromSocket(); 66 void readBackFileFromSocket();
67 private : 67 private :
68 int mPendingConnect; 68 int mPendingConnect;
69 QString mResource; 69 QString mResource;
70 int mErrorMessage; 70 int mErrorMessage;
71 bool blockRC; 71 bool blockRC;
72 void send_file(); 72 void send_file();
73 void get_file(); 73 void get_file();
74 void end_connect(); 74 void end_connect();
75 void error_connect( QString ); 75 void error_connect( QString );
76 QDialog* mSyncActionDialog; 76 QDialog* mSyncActionDialog;
77 QSocket* mSocket; 77 QSocket* mSocket;
78 QString mPassWord; 78 QString mPassWord;
79 QString mFileName; 79 QString mFileName;
80 QTime piTime; 80 QTime piTime;
81 QString piFileString; 81 QString piFileString;
82}; 82};
83 83
84class KCommandSocket : public QObject 84class KCommandSocket : public QObject
85{ 85{
86 Q_OBJECT 86 Q_OBJECT
87 public: 87 public:
88 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 88 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
89 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 89 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
90 void readFile( QString ); 90 void readFile( QString );
91 void writeFile( QString ); 91 void writeFile( QString );
92 void sendStop(); 92 void sendStop();
93 93
94 private slots : 94 private slots :
95 void sendFileRequest(); 95 void sendFileRequest();
96 void updateConnectDialog(); 96 void updateConnectDialog();
97 97
98 signals: 98 signals:
99 void commandFinished( KCommandSocket*, int ); 99 void commandFinished( KCommandSocket*, int );
100 private slots: 100 private slots:
101 void startReadFileFromSocket(); 101 void startReadFileFromSocket();
102 void readFileFromSocket(); 102 void readFileFromSocket();
103 void deleteSocket(); 103 void deleteSocket();
104 void writeFileToSocket(); 104 void writeFileToSocket();
105 private : 105 private :
106 QString mRemoteResource; 106 QString mRemoteResource;
107 int mConnectCount; 107 int mConnectCount;
108 int mConnectMax; 108 int mConnectMax;
109 KProgressDialog mConnectProgress; 109 KProgressDialog mConnectProgress;
110 QWidget* tlw; 110 QWidget* tlw;
111 QSocket* mSocket; 111 QSocket* mSocket;
112 QString mPassWord; 112 QString mPassWord;
113 Q_UINT16 mPort; 113 Q_UINT16 mPort;
114 QString mHost; 114 QString mHost;
115 QString mFileName; 115 QString mFileName;
116 QTimer* mTimerSocket; 116 QTimer* mTimerSocket;
117 int mRetVal; 117 int mRetVal;
118 QTime mTime; 118 QTime mTime;
119 QString mFileString; 119 QString mFileString;
120 bool mFirst; 120 bool mFirst;
121 bool mFirstLine; 121 bool mFirstLine;
122}; 122};
123 123
124 124
125class KSyncManager : public QObject 125class KSyncManager : public QObject
126{ 126{
127 Q_OBJECT 127 Q_OBJECT
128 128
129 public: 129 public:
130 enum TargetApp { 130 enum TargetApp {
131 KOPI = 0, 131 KOPI = 0,
132 KAPI = 1, 132 KAPI = 1,
133 PWMPI = 2 }; 133 PWMPI = 2 };
134 134
135 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 135 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
136 ~KSyncManager() ; 136 ~KSyncManager() ;
137 137
138 void multiSync( bool askforPrefs ); 138 void multiSync( bool askforPrefs );
139 bool blockSave() { return mBlockSaveFlag; } 139 bool blockSave() { return mBlockSaveFlag; }
140 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 140 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
141 void setDefaultFileName( QString s) ; 141 void setDefaultFileName( QString s) ;
142 QString defaultFileName() { return mDefFileName ;} 142 QString defaultFileName() { return mDefFileName ;}
143 QString syncFileName(); 143 QString syncFileName();
144 void enableQuick( bool ask = true); 144 void enableQuick( bool ask = true);
145 145
146 bool syncWithDesktop () { return mSyncWithDesktop;} 146 bool syncWithDesktop () { return mSyncWithDesktop;}
147 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 147 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
148 QString getCurrentSyncName() { return mCurrentSyncName; } 148 QString getCurrentSyncName() { return mCurrentSyncName; }
149 149
150 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 150 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
151 void hideProgressBar(); 151 void hideProgressBar();
152 bool isProgressBarCanceled(); 152 bool isProgressBarCanceled();
153 153
154 // sync stuff 154 // sync stuff
155 QString mLocalMachineName; 155 QString mLocalMachineName;
156 QStringList mExternSyncProfiles; 156 QStringList mExternSyncProfiles;
157 QStringList mSyncProfileNames; 157 QStringList mSyncProfileNames;
158 bool mAskForPreferences; 158 bool mAskForPreferences;
159 bool mShowSyncSummary; 159 bool mShowSyncSummary;
160 bool mIsKapiFile; 160 bool mIsKapiFile;
161 bool mWriteBackExistingOnly; 161 bool mWriteBackExistingOnly;
162 int mSyncAlgoPrefs; 162 int mSyncAlgoPrefs;
163 bool mWriteBackFile; 163 bool mWriteBackFile;
164 int mWriteBackInFuture; 164 int mWriteBackInFuture;
165 int mWriteBackInPast; 165 int mWriteBackInPast;
166 QString mPhoneDevice; 166 QString mPhoneDevice;
167 QString mPhoneConnection; 167 QString mPhoneConnection;
168 QString mPhoneModel; 168 QString mPhoneModel;
169 QString mPassWordPiSync; 169 QString mPassWordPiSync;
170 QString mActiveSyncPort; 170 QString mActiveSyncPort;
171 QString mActiveSyncIP ; 171 QString mActiveSyncIP ;
172 QString mFilterInCal; 172 QString mFilterInCal;
173 QString mFilterOutCal; 173 QString mFilterOutCal;
174 QString mFilterInAB; 174 QString mFilterInAB;
175 QString mFilterOutAB; 175 QString mFilterOutAB;
176 static QDateTime mRequestedSyncEvent; 176 static QDateTime mRequestedSyncEvent;
177 177
178 signals: 178 signals:
179 void save(); 179 void save();
180 void request_file(); 180 void request_file();
181 void getFile( bool ); 181 void getFile( bool );
182 void getFile( bool, const QString &); 182 void getFile( bool, const QString &);
183 void request_file(const QString &); 183 void request_file(const QString &);
184 void multiResourceSyncStart( bool ); 184 void multiResourceSyncStart( bool );
185 185
186 public slots: 186 public slots:
187 void slotSyncMenu( int ); 187 void slotSyncMenu( int );
188 void slotClearMenu( int action ); 188 void slotClearMenu( int action );
189 void deleteCommandSocket(KCommandSocket*s, int state); 189 void deleteCommandSocket(KCommandSocket*s, int state);
190 void readFileFromSocket(); 190 void readFileFromSocket();
191 void fillSyncMenu(); 191 void fillSyncMenu();
192 192
193 private: 193 private:
194 void syncPi(); 194 void syncPi();
195 KServerSocket * mServerSocket; 195 KServerSocket * mServerSocket;
196 KPimPrefs* mPrefs; 196 KPimPrefs* mPrefs;
197 QString mDefFileName; 197 QString mDefFileName;
198 QString mCurrentSyncDevice; 198 QString mCurrentSyncDevice;
199 QString mCurrentSyncName; 199 QString mCurrentSyncName;
200 void quickSyncLocalFile(); 200 void quickSyncLocalFile();
201 bool syncWithFile( QString fn , bool quick ); 201 bool syncWithFile( QString fn , bool quick );
202 void syncLocalFile(); 202 void syncLocalFile();
203 void syncPhone(); 203 void syncPhone();
204 void syncSharp(); 204 void syncSharp();
205 void syncKDE(); 205 void syncKDE();
206 void syncOL();
206 bool syncExternalApplication(QString); 207 bool syncExternalApplication(QString);
207 int mCurrentSyncProfile ; 208 int mCurrentSyncProfile ;
208 void syncRemote( KSyncProfile* prof, bool ask = true); 209 void syncRemote( KSyncProfile* prof, bool ask = true);
209 bool edit_sync_options(); 210 bool edit_sync_options();
210 bool edit_pisync_options(); 211 bool edit_pisync_options();
211 int ringSync(); 212 int ringSync();
212 QString getPassword( ); 213 QString getPassword( );
213 bool mPisyncFinished; 214 bool mPisyncFinished;
214 QStringList mSpecificResources; 215 QStringList mSpecificResources;
215 QString mCurrentResourceLocal; 216 QString mCurrentResourceLocal;
216 QString mCurrentResourceRemote; 217 QString mCurrentResourceRemote;
217 bool mBlockSaveFlag; 218 bool mBlockSaveFlag;
218 QWidget* mParent; 219 QWidget* mParent;
219 KSyncInterface* mImplementation; 220 KSyncInterface* mImplementation;
220 TargetApp mTargetApp; 221 TargetApp mTargetApp;
221 QPopupMenu* mSyncMenu; 222 QPopupMenu* mSyncMenu;
222 QProgressBar* bar; 223 QProgressBar* bar;
223 bool mSyncWithDesktop; 224 bool mSyncWithDesktop;
224 225
225private slots: 226private slots:
226 void displayErrorPort(); 227 void displayErrorPort();
227 void confSync(); 228 void confSync();
228 229
229 230
230}; 231};
231 232
232 233
233class KSyncInterface 234class KSyncInterface
234{ 235{
235 public : 236 public :
236 virtual void removeSyncInfo( QString syncProfile) = 0; 237 virtual void removeSyncInfo( QString syncProfile) = 0;
237 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0; 238 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
238 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/) 239 virtual bool syncExternal(KSyncManager* /*manager*/, QString /*resource*/)
239 { 240 {
240 // empty implementation, because some syncable applications do not 241 // empty implementation, because some syncable applications do not
241 // have an external(sharpdtm) syncmode, like pwmanager. 242 // have an external(sharpdtm) syncmode, like pwmanager.
242 return false; 243 return false;
243 } 244 }
244
245
246}; 245};
247 246
248 247
249#endif 248#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 84af7ad..7160d0e 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,61 +1,76 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = microkdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kpimprefs.h \ 30 kpimprefs.h \
31 kpimglobalprefs.h \ 31 kpimglobalprefs.h \
32 kprefsdialog.h \ 32 kprefsdialog.h \
33 kprefswidget.h \ 33 kprefswidget.h \
34 ksyncmanager.h \ 34 ksyncmanager.h \
35 ksyncprofile.h \ 35 ksyncprofile.h \
36 ksyncprefsdialog.h \ 36 ksyncprefsdialog.h \
37 kcmconfigs/kcmkdepimconfig.h \ 37 kcmconfigs/kcmkdepimconfig.h \
38 kcmconfigs/kdepimconfigwidget.h \ 38 kcmconfigs/kdepimconfigwidget.h \
39 phoneaccess.h 39 phoneaccess.h
40 40
41SOURCES = \ 41SOURCES = \
42 categoryeditdialog.cpp \ 42 categoryeditdialog.cpp \
43 categoryeditdialog_base.cpp \ 43 categoryeditdialog_base.cpp \
44 categoryselectdialog.cpp \ 44 categoryselectdialog.cpp \
45 categoryselectdialog_base.cpp \ 45 categoryselectdialog_base.cpp \
46 externalapphandler.cpp \ 46 externalapphandler.cpp \
47 kdateedit.cpp \ 47 kdateedit.cpp \
48 kdatepicker.cpp \ 48 kdatepicker.cpp \
49 kinputdialog.cpp \ 49 kinputdialog.cpp \
50 kpimprefs.cpp \ 50 kpimprefs.cpp \
51 kpimglobalprefs.cpp \ 51 kpimglobalprefs.cpp \
52 kprefsdialog.cpp \ 52 kprefsdialog.cpp \
53 kprefswidget.cpp \ 53 kprefswidget.cpp \
54 ksyncmanager.cpp \ 54 ksyncmanager.cpp \
55 ksyncprofile.cpp \ 55 ksyncprofile.cpp \
56 ksyncprefsdialog.cpp \ 56 ksyncprefsdialog.cpp \
57 kcmconfigs/kcmkdepimconfig.cpp \ 57 kcmconfigs/kcmkdepimconfig.cpp \
58 kcmconfigs/kdepimconfigwidget.cpp \ 58 kcmconfigs/kdepimconfigwidget.cpp \
59 phoneaccess.cpp 59 phoneaccess.cpp
60 60
61win32: {
61 62
63#olimport section
64importol {
65debug: {
66LIBS += mfc71ud.lib
67}
68release: {
69LIBS += mfc71u.lib
70}
71DEFINES += _OL_IMPORT_
72HEADERS += ol_access.h
73SOURCES += ol_access.cpp
74#olimport section end
75}
76}