summaryrefslogtreecommitdiffabout
path: root/libkdepim
Unidiff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp12
-rw-r--r--libkdepim/externalapphandler.h1
-rw-r--r--libkdepim/ksyncmanager.cpp18
3 files changed, 20 insertions, 11 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 0e9c5e5..2ce6926 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -1,416 +1,417 @@
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 <qmap.h> 34#include <qmap.h>
34#include <qregexp.h> 35#include <qregexp.h>
35 36
36#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
37#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
38#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
39#else 40#else
40#include <qapplication.h> 41#include <qapplication.h>
41#endif 42#endif
42 43
43#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
44#include <kmessagebox.h> 45#include <kmessagebox.h>
45 46
46 47
47#include "externalapphandler.h" 48#include "externalapphandler.h"
48 49
49#include "kpimglobalprefs.h" 50#include "kpimglobalprefs.h"
50 51
51//uncomment line to get debug output 52//uncomment line to get debug output
52//#define DEBUG_EXT_APP_HANDLER 53//#define DEBUG_EXT_APP_HANDLER
53 54
54/********************************************************************************* 55/*********************************************************************************
55 * 56 *
56 ********************************************************************************/ 57 ********************************************************************************/
57 58
58 59
59QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 60QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
60 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 61 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
61{ 62{
62 //sourceMessage passes later three parameters: sourceChannel, uid, param1 63 //sourceMessage passes later three parameters: sourceChannel, uid, param1
63 if (_usedSourceParameters == 0) 64 if (_usedSourceParameters == 0)
64 _sourceMessageParameters = "QString,QString)"; 65 _sourceMessageParameters = "QString,QString)";
65 else if (_usedSourceParameters == 1) 66 else if (_usedSourceParameters == 1)
66 _sourceMessageParameters = "(QString,QString,QString)"; 67 _sourceMessageParameters = "(QString,QString,QString)";
67 else if (_usedSourceParameters == 2) 68 else if (_usedSourceParameters == 2)
68 _sourceMessageParameters = "(QString,QString,QString,QString)"; 69 _sourceMessageParameters = "(QString,QString,QString,QString)";
69 else if (_usedSourceParameters == 3) 70 else if (_usedSourceParameters == 3)
70 _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; 71 _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
71} 72}
72 73
73/*********************************************************************************/ 74/*********************************************************************************/
74 75
75QCopTransferItem::QCopTransferItem() 76QCopTransferItem::QCopTransferItem()
76{ 77{
77} 78}
78 79
79/*********************************************************************************/ 80/*********************************************************************************/
80bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) 81bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
81{ 82{
82 83
83#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
84 //sourceMessage passes two parameters: sourceChannel, uid 85 //sourceMessage passes two parameters: sourceChannel, uid
85 QString sourceMessage = _sourceMessage + _sourceMessageParameters; 86 QString sourceMessage = _sourceMessage + _sourceMessageParameters;
86#ifdef DEBUG_EXT_APP_HANDLER 87#ifdef DEBUG_EXT_APP_HANDLER
87 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); 88 qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
88 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()); 89 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());
89#endif 90#endif
90 91
91 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); 92 QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
92 93
93 e << _sourceChannel << uid; 94 e << _sourceChannel << uid;
94 95
95 if (_usedSourceParameters == 1) 96 if (_usedSourceParameters == 1)
96 e << param1; 97 e << param1;
97 else if (_usedSourceParameters == 2) 98 else if (_usedSourceParameters == 2)
98 e << param1 << param2; 99 e << param1 << param2;
99 else if (_usedSourceParameters == 3) 100 else if (_usedSourceParameters == 3)
100 e << param1 << param2 << param3; 101 e << param1 << param2 << param3;
101 102
102 qApp->processEvents(); 103 qApp->processEvents();
103 104
104 return true; 105 return true;
105 106
106#else 107#else
107 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 108 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
108 return false; 109 return false;
109#endif 110#endif
110 111
111} 112}
112 113
113 114
114/*********************************************************************************/ 115/*********************************************************************************/
115void QCopTransferItem::setSourceChannel(const QString& sourceChannel) 116void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
116{ 117{
117 118
118 if ( !sourceChannel.isEmpty()) 119 if ( !sourceChannel.isEmpty())
119 _sourceChannel = sourceChannel; 120 _sourceChannel = sourceChannel;
120} 121}
121 122
122 123
123/*********************************************************************************/ 124/*********************************************************************************/
124bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 125bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
125{ 126{
126 127
127 // copied from old mail2 128 // copied from old mail2
128/* 129/*
129 static int ii = 0; 130 static int ii = 0;
130 131
131 // block second call 132 // block second call
132 if ( ii < 2 ) { 133 if ( ii < 2 ) {
133 ++ii; 134 ++ii;
134 if ( ii > 1 ) { 135 if ( ii > 1 ) {
135 qDebug("qcop call blocked "); 136 qDebug("qcop call blocked ");
136 return true; 137 return true;
137 } 138 }
138 } 139 }
139*/ 140*/
140 141
141// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); 142// qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
142 143
143 //we are in the target and get a request from the source 144 //we are in the target and get a request from the source
144 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) 145 if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
145 { 146 {
146 147
147 QDataStream stream( data, IO_ReadOnly ); 148 QDataStream stream( data, IO_ReadOnly );
148 149
149 150
150 QString sourceChannel; 151 QString sourceChannel;
151 QString uid; 152 QString uid;
152 QString param1; 153 QString param1;
153 QString param2; 154 QString param2;
154 QString param3; 155 QString param3;
155 156
156 stream >> sourceChannel >> uid; 157 stream >> sourceChannel >> uid;
157 158
158 if (_usedSourceParameters == 0) 159 if (_usedSourceParameters == 0)
159 { 160 {
160 emit receivedMessageFromSource(sourceChannel, uid); 161 emit receivedMessageFromSource(sourceChannel, uid);
161 } 162 }
162 else if (_usedSourceParameters == 1) 163 else if (_usedSourceParameters == 1)
163 { 164 {
164 stream >> param1; 165 stream >> param1;
165 emit receivedMessageFromSource(sourceChannel, uid, param1); 166 emit receivedMessageFromSource(sourceChannel, uid, param1);
166 } 167 }
167 else if (_usedSourceParameters == 2) 168 else if (_usedSourceParameters == 2)
168 { 169 {
169 stream >> param1 >> param2; 170 stream >> param1 >> param2;
170 emit receivedMessageFromSource(sourceChannel, uid, param1, param2); 171 emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
171 } 172 }
172 else if (_usedSourceParameters == 3) 173 else if (_usedSourceParameters == 3)
173 { 174 {
174 stream >> param1 >> param2 >> param3; 175 stream >> param1 >> param2 >> param3;
175 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); 176 emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
176 } 177 }
177 178
178 return true; 179 return true;
179 } 180 }
180 181
181 return false; 182 return false;
182} 183}
183 184
184 185
185/********************************************************************************* 186/*********************************************************************************
186 * 187 *
187 ********************************************************************************/ 188 ********************************************************************************/
188 189
189 190
190QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 191QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
191 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 192 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
192{ 193{
193 //targetMessage returns later two parameters: uid, and map<qstring,qstring> 194 //targetMessage returns later two parameters: uid, and map<qstring,qstring>
194 _targetMessageParameters = "(QString,QMAP<QString,QString>)"; 195 _targetMessageParameters = "(QString,QMAP<QString,QString>)";
195} 196}
196 197
197/*********************************************************************************/ 198/*********************************************************************************/
198bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) 199bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
199{ 200{
200#ifndef DESKTOP_VERSION 201#ifndef DESKTOP_VERSION
201 //targetMessage passes two parameters: uid, map 202 //targetMessage passes two parameters: uid, map
202 QString targetMessage = _targetMessage + _targetMessageParameters; 203 QString targetMessage = _targetMessage + _targetMessageParameters;
203 204
204#ifdef DEBUG_EXT_APP_HANDLER 205#ifdef DEBUG_EXT_APP_HANDLER
205 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 206 qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
206 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); 207 qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
207#endif 208#endif
208 209
209 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 210 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
210 //US we need no names in the To field. The emailadresses are enough 211 //US we need no names in the To field. The emailadresses are enough
211 212
212 e << uid << nameEmailMap; 213 e << uid << nameEmailMap;
213 214
214 qApp->processEvents(); 215 qApp->processEvents();
215 216
216 return true; 217 return true;
217 218
218#else 219#else
219 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 220 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
220 return false; 221 return false;
221#endif 222#endif
222 223
223} 224}
224 225
225 226
226/*********************************************************************************/ 227/*********************************************************************************/
227bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 228bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
228{ 229{
229 bool res = QCopTransferItem::appMessage( cmsg, data ); 230 bool res = QCopTransferItem::appMessage( cmsg, data );
230 231
231 if (res == false) 232 if (res == false)
232 { 233 {
233 QDataStream stream( data, IO_ReadOnly ); 234 QDataStream stream( data, IO_ReadOnly );
234 235
235// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); 236// qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
236 237
237 //we are in the source and get an answer from the target 238 //we are in the source and get an answer from the target
238 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 239 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
239 { 240 {
240 QMap<QString,QString> adrMap; 241 QMap<QString,QString> adrMap;
241 QString uid; 242 QString uid;
242 243
243 stream >> uid >> adrMap; 244 stream >> uid >> adrMap;
244 245
245 emit receivedMessageFromTarget(uid, adrMap); 246 emit receivedMessageFromTarget(uid, adrMap);
246 247
247 248
248 return true; 249 return true;
249 } 250 }
250 } 251 }
251 252
252 return false; 253 return false;
253} 254}
254 255
255 256
256/********************************************************************************* 257/*********************************************************************************
257 * 258 *
258 ********************************************************************************/ 259 ********************************************************************************/
259 260
260QCopListTransferItem::~QCopListTransferItem() 261QCopListTransferItem::~QCopListTransferItem()
261{ 262{
262 263
263} 264}
264 265
265QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 266QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
266 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) 267 : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
267{ 268{
268 //targetMessage returns later two parameters: uid, and three lists 269 //targetMessage returns later two parameters: uid, and three lists
269 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; 270 _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)";
270} 271}
271 272
272/*********************************************************************************/ 273/*********************************************************************************/
273bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) 274bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6)
274{ 275{
275#ifndef DESKTOP_VERSION 276#ifndef DESKTOP_VERSION
276 //targetMessage passes two parameters: uid, map 277 //targetMessage passes two parameters: uid, map
277 QString targetMessage = _targetMessage + _targetMessageParameters; 278 QString targetMessage = _targetMessage + _targetMessageParameters;
278 279
279#ifdef DEBUG_EXT_APP_HANDLER 280#ifdef DEBUG_EXT_APP_HANDLER
280 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); 281 qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
281 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); 282 qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1());
282 283
283 284
284 for ( int i = 0; i < list3.count(); i++) 285 for ( int i = 0; i < list3.count(); i++)
285 qDebug("listentry list3: %s",list3[i].latin1()); 286 qDebug("listentry list3: %s",list3[i].latin1());
286#endif 287#endif
287 288
288 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); 289 QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
289 //US we need no names in the To field. The emailadresses are enough 290 //US we need no names in the To field. The emailadresses are enough
290 291
291 e << uid << list1 << list2 << list3 << list4 << list5 << list6; 292 e << uid << list1 << list2 << list3 << list4 << list5 << list6;
292 293
293 qApp->processEvents(); 294 qApp->processEvents();
294 295
295 return true; 296 return true;
296 297
297#else 298#else
298 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); 299 KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
299 return false; 300 return false;
300#endif 301#endif
301 302
302} 303}
303 304
304 305
305/*********************************************************************************/ 306/*********************************************************************************/
306bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) 307bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
307{ 308{
308 bool res = QCopTransferItem::appMessage( cmsg, data ); 309 bool res = QCopTransferItem::appMessage( cmsg, data );
309#ifdef DEBUG_EXT_APP_HANDLER 310#ifdef DEBUG_EXT_APP_HANDLER
310 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 311 qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
311#endif 312#endif
312 313
313 if (res == false) 314 if (res == false)
314 { 315 {
315 QDataStream stream( data, IO_ReadOnly ); 316 QDataStream stream( data, IO_ReadOnly );
316 317
317#ifdef DEBUG_EXT_APP_HANDLER 318#ifdef DEBUG_EXT_APP_HANDLER
318 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 319 qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
319#endif 320#endif
320 321
321 //we are in the source and get an answer from the target 322 //we are in the source and get an answer from the target
322 if ((_targetMessage + _targetMessageParameters) == cmsg.data()) 323 if ((_targetMessage + _targetMessageParameters) == cmsg.data())
323 { 324 {
324 QStringList list1; 325 QStringList list1;
325 QStringList list2; 326 QStringList list2;
326 QStringList list3; 327 QStringList list3;
327 QStringList list4; 328 QStringList list4;
328 QStringList list5; 329 QStringList list5;
329 QStringList list6; 330 QStringList list6;
330 QString uid; 331 QString uid;
331 332
332#ifdef DEBUG_EXT_APP_HANDLER 333#ifdef DEBUG_EXT_APP_HANDLER
333 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); 334 qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
334#endif 335#endif
335 336
336 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; 337 stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
337 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); 338 emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
338 339
339 340
340 return true; 341 return true;
341 } 342 }
342 } 343 }
343 344
344 return false; 345 return false;
345} 346}
346 347
347 348
348 349
349/********************************************************************************* 350/*********************************************************************************
350 * 351 *
351 ********************************************************************************/ 352 ********************************************************************************/
352 353
353 354
354ExternalAppHandler *ExternalAppHandler::sInstance = 0; 355ExternalAppHandler *ExternalAppHandler::sInstance = 0;
355static KStaticDeleter<ExternalAppHandler> staticDeleter; 356static KStaticDeleter<ExternalAppHandler> staticDeleter;
356 357
357ExternalAppHandler::ExternalAppHandler() 358ExternalAppHandler::ExternalAppHandler()
358{ 359{
359 mDefaultItems.setAutoDelete(true); 360 mDefaultItems.setAutoDelete(true);
360 361
361 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); 362 mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
362 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); 363 connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&)));
363 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&))); 364 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&)));
364 365
365//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); 366//US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
366//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); 367//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
367//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); 368//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
368 369
369 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); 370 mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
370 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&))); 371 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&)));
371 372
372 373
373 374
374 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); 375 mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList");
375 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); 376 connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&)));
376 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&))); 377 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&)));
377 378
378 379
379} 380}
380 381
381ExternalAppHandler::~ExternalAppHandler() 382ExternalAppHandler::~ExternalAppHandler()
382{ 383{
383 delete mNameEmailUidListFromKAPITransfer; 384 delete mNameEmailUidListFromKAPITransfer;
384 //delete mFindByEmailFromKAPITransfer; 385 //delete mFindByEmailFromKAPITransfer;
385 delete mDisplayDetails; 386 delete mDisplayDetails;
386 delete mBirthdayListFromKAPITransfer; 387 delete mBirthdayListFromKAPITransfer;
387} 388}
388 389
389void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, 390void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid,
390 const QStringList& nameList, 391 const QStringList& nameList,
391 const QStringList& emailList, 392 const QStringList& emailList,
392 const QStringList& uidList, 393 const QStringList& uidList,
393 const QStringList&, 394 const QStringList&,
394 const QStringList&, 395 const QStringList&,
395 const QStringList& ) 396 const QStringList& )
396{ 397{
397 // this method is a conevnient way to reduce the number of parameters I have to pass 398 // this method is a conevnient way to reduce the number of parameters I have to pass
398 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); 399 emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList);
399} 400}
400 401
401 402
402void ExternalAppHandler::loadConfig() 403void ExternalAppHandler::loadConfig()
403{ 404{
404 405
405 mDefaultItems.clear(); 406 mDefaultItems.clear();
406 mEmailAppAvailable = UNDEFINED; 407 mEmailAppAvailable = UNDEFINED;
407 mPhoneAppAvailable = UNDEFINED; 408 mPhoneAppAvailable = UNDEFINED;
408 mFaxAppAvailable = UNDEFINED; 409 mFaxAppAvailable = UNDEFINED;
409 mSMSAppAvailable = UNDEFINED; 410 mSMSAppAvailable = UNDEFINED;
410 mPagerAppAvailable = UNDEFINED; 411 mPagerAppAvailable = UNDEFINED;
411 mSIPAppAvailable = UNDEFINED; 412 mSIPAppAvailable = UNDEFINED;
412 413
413 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 414 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
414 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 415 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
415 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 416 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
416 417
@@ -748,464 +749,469 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e
748#endif 749#endif
749 750
750 751
751 return true; 752 return true;
752} 753}
753 754
754/************************************************************************** 755/**************************************************************************
755 * 756 *
756 **************************************************************************/ 757 **************************************************************************/
757 758
758//calls the emailapplication and creates a mail with parameter as recipients 759//calls the emailapplication and creates a mail with parameter as recipients
759// parameters format is 760// parameters format is
760// NAME <EMAIL>:SUBJECT 761// NAME <EMAIL>:SUBJECT
761bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 762bool ExternalAppHandler::mailToOneContact( const QString& adressline )
762{ 763{
763 QString line = adressline; 764 QString line = adressline;
764 765
765 int first = line.find( "<"); 766 int first = line.find( "<");
766 int last = line.find( ">"); 767 int last = line.find( ">");
767 QString name = line.left(first); 768 QString name = line.left(first);
768 QString emailadress = line.mid(first+1, last-first-1); 769 QString emailadress = line.mid(first+1, last-first-1);
769 770
770 //Subject can not be handled right now. 771 //Subject can not be handled right now.
771 return mailToOneContact( name, emailadress ); 772 return mailToOneContact( name, emailadress );
772 773
773} 774}
774 775
775 776
776/************************************************************************** 777/**************************************************************************
777 * 778 *
778 **************************************************************************/ 779 **************************************************************************/
779 780
780//calls the phoneapplication with the number 781//calls the phoneapplication with the number
781bool ExternalAppHandler::callByPhone( const QString& phonenumber ) 782bool ExternalAppHandler::callByPhone( const QString& phonenumber )
782{ 783{
783#ifndef DESKTOP_VERSION 784#ifndef DESKTOP_VERSION
784 QString channel; 785 QString channel;
785 QString message; 786 QString message;
786 QString parameters; 787 QString parameters;
787 788
788 789
789 int client = KPimGlobalPrefs::instance()->mPhoneClient; 790 int client = KPimGlobalPrefs::instance()->mPhoneClient;
790 if (client == KPimGlobalPrefs::OTHER_PHC) 791 if (client == KPimGlobalPrefs::OTHER_PHC)
791 { 792 {
792 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; 793 channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
793 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; 794 message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
794 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; 795 parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
795 } 796 }
796 else 797 else
797 { 798 {
798 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); 799 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
799 if (!dai) 800 if (!dai)
800 { 801 {
801 qDebug("could not find configured phone application."); 802 qDebug("could not find configured phone application.");
802 return false; 803 return false;
803 } 804 }
804 channel = dai->_channel; 805 channel = dai->_channel;
805 message = dai->_message; 806 message = dai->_message;
806 parameters = dai->_parameters; 807 parameters = dai->_parameters;
807 } 808 }
808 809
809 810
810 //first check if one of the mailers need the emails right in the message. 811 //first check if one of the mailers need the emails right in the message.
811 message = translateMessage(message, phonenumber, ""); 812 message = translateMessage(message, phonenumber, "");
812 813
813 814
814#ifdef DEBUG_EXT_APP_HANDLER 815#ifdef DEBUG_EXT_APP_HANDLER
815 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 816 qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
816 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 817 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
817#endif 818#endif
818 819
819 QCopEnvelope e(channel.latin1(), message.latin1()); 820 QCopEnvelope e(channel.latin1(), message.latin1());
820 //US we need no names in the To field. The emailadresses are enough 821 //US we need no names in the To field. The emailadresses are enough
821 822
822 passParameters(&e, parameters, phonenumber, ""); 823 passParameters(&e, parameters, phonenumber, "");
823 824
824 825
825#else 826#else
826 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); 827 KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) );
827#endif 828#endif
828 829
829 830
830 return true; 831 return true;
831} 832}
832 833
833/************************************************************************** 834/**************************************************************************
834 * 835 *
835 **************************************************************************/ 836 **************************************************************************/
836 837
837//calls the smsapplication with the number 838//calls the smsapplication with the number
838bool ExternalAppHandler::callBySMS( const QString& phonenumber ) 839bool ExternalAppHandler::callBySMS( const QString& phonenumber )
839{ 840{
840#ifndef DESKTOP_VERSION 841#ifndef DESKTOP_VERSION
841 QString channel; 842 QString channel;
842 QString message; 843 QString message;
843 QString parameters; 844 QString parameters;
844 845
845 846
846 int client = KPimGlobalPrefs::instance()->mSMSClient; 847 int client = KPimGlobalPrefs::instance()->mSMSClient;
847 if (client == KPimGlobalPrefs::OTHER_SMC) 848 if (client == KPimGlobalPrefs::OTHER_SMC)
848 { 849 {
849 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; 850 channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
850 message = KPimGlobalPrefs::instance()->mSMSOtherMessage; 851 message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
851 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; 852 parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
852 } 853 }
853 else 854 else
854 { 855 {
855 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); 856 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
856 if (!dai) 857 if (!dai)
857 { 858 {
858 qDebug("could not find configured sms application."); 859 qDebug("could not find configured sms application.");
859 return false; 860 return false;
860 } 861 }
861 channel = dai->_channel; 862 channel = dai->_channel;
862 message = dai->_message; 863 message = dai->_message;
863 parameters = dai->_parameters; 864 parameters = dai->_parameters;
864 } 865 }
865 866
866 867
867 //first check if one of the mailers need the emails right in the message. 868 //first check if one of the mailers need the emails right in the message.
868 message = translateMessage(message, phonenumber, ""); 869 message = translateMessage(message, phonenumber, "");
869 870
870 871
871#ifdef DEBUG_EXT_APP_HANDLER 872#ifdef DEBUG_EXT_APP_HANDLER
872 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 873 qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
873 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); 874 qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
874#endif 875#endif
875 876
876 QCopEnvelope e(channel.latin1(), message.latin1()); 877 QCopEnvelope e(channel.latin1(), message.latin1());
877 //US we need no names in the To field. The emailadresses are enough 878 //US we need no names in the To field. The emailadresses are enough
878 879
879 passParameters(&e, parameters, phonenumber, ""); 880 passParameters(&e, parameters, phonenumber, "");
880 881
881 882
882#else 883#else
883 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); 884 KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) );
884#endif 885#endif
885 886
886 887
887 return true; 888 return true;
888} 889}
889 890
890/************************************************************************** 891/**************************************************************************
891 * 892 *
892 **************************************************************************/ 893 **************************************************************************/
893 894
894//calls the pagerapplication with the number 895//calls the pagerapplication with the number
895bool ExternalAppHandler::callByPager( const QString& pagernumber ) 896bool ExternalAppHandler::callByPager( const QString& pagernumber )
896{ 897{
897#ifndef DESKTOP_VERSION 898#ifndef DESKTOP_VERSION
898 QString channel; 899 QString channel;
899 QString message; 900 QString message;
900 QString parameters; 901 QString parameters;
901 902
902 903
903 int client = KPimGlobalPrefs::instance()->mPagerClient; 904 int client = KPimGlobalPrefs::instance()->mPagerClient;
904 if (client == KPimGlobalPrefs::OTHER_PAC) 905 if (client == KPimGlobalPrefs::OTHER_PAC)
905 { 906 {
906 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; 907 channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
907 message = KPimGlobalPrefs::instance()->mPagerOtherMessage; 908 message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
908 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; 909 parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
909 } 910 }
910 else 911 else
911 { 912 {
912 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); 913 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
913 if (!dai) 914 if (!dai)
914 { 915 {
915 qDebug("could not find configured pager application."); 916 qDebug("could not find configured pager application.");
916 return false; 917 return false;
917 } 918 }
918 channel = dai->_channel; 919 channel = dai->_channel;
919 message = dai->_message; 920 message = dai->_message;
920 parameters = dai->_parameters; 921 parameters = dai->_parameters;
921 } 922 }
922 923
923 924
924 //first check if one of the mailers need the emails right in the message. 925 //first check if one of the mailers need the emails right in the message.
925 message = translateMessage(message, pagernumber, ""); 926 message = translateMessage(message, pagernumber, "");
926 927
927 928
928#ifdef DEBUG_EXT_APP_HANDLER 929#ifdef DEBUG_EXT_APP_HANDLER
929 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 930 qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
930 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); 931 qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
931#endif 932#endif
932 933
933 QCopEnvelope e(channel.latin1(), message.latin1()); 934 QCopEnvelope e(channel.latin1(), message.latin1());
934 //US we need no names in the To field. The emailadresses are enough 935 //US we need no names in the To field. The emailadresses are enough
935 936
936 passParameters(&e, parameters, pagernumber, ""); 937 passParameters(&e, parameters, pagernumber, "");
937 938
938 939
939#else 940#else
940 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); 941 KMessageBox::sorry( 0, i18n( "This version does not support paging." ) );
941#endif 942#endif
942 943
943 944
944 return true; 945 return true;
945} 946}
946 947
947/************************************************************************** 948/**************************************************************************
948 * 949 *
949 **************************************************************************/ 950 **************************************************************************/
950 951
951//calls the faxapplication with the number 952//calls the faxapplication with the number
952bool ExternalAppHandler::callByFax( const QString& faxnumber ) 953bool ExternalAppHandler::callByFax( const QString& faxnumber )
953{ 954{
954#ifndef DESKTOP_VERSION 955#ifndef DESKTOP_VERSION
955 QString channel; 956 QString channel;
956 QString message; 957 QString message;
957 QString parameters; 958 QString parameters;
958 959
959 960
960 int client = KPimGlobalPrefs::instance()->mFaxClient; 961 int client = KPimGlobalPrefs::instance()->mFaxClient;
961 if (client == KPimGlobalPrefs::OTHER_FAC) 962 if (client == KPimGlobalPrefs::OTHER_FAC)
962 { 963 {
963 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; 964 channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
964 message = KPimGlobalPrefs::instance()->mFaxOtherMessage; 965 message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
965 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; 966 parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
966 } 967 }
967 else 968 else
968 { 969 {
969 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); 970 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
970 if (!dai) 971 if (!dai)
971 { 972 {
972 qDebug("could not find configured fax application."); 973 qDebug("could not find configured fax application.");
973 return false; 974 return false;
974 } 975 }
975 channel = dai->_channel; 976 channel = dai->_channel;
976 message = dai->_message; 977 message = dai->_message;
977 parameters = dai->_parameters; 978 parameters = dai->_parameters;
978 } 979 }
979 980
980 981
981 //first check if one of the mailers need the emails right in the message. 982 //first check if one of the mailers need the emails right in the message.
982 message = translateMessage(message, faxnumber, ""); 983 message = translateMessage(message, faxnumber, "");
983 984
984 985
985#ifdef DEBUG_EXT_APP_HANDLER 986#ifdef DEBUG_EXT_APP_HANDLER
986 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 987 qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
987 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); 988 qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
988#endif 989#endif
989 990
990 QCopEnvelope e(channel.latin1(), message.latin1()); 991 QCopEnvelope e(channel.latin1(), message.latin1());
991 //US we need no names in the To field. The emailadresses are enough 992 //US we need no names in the To field. The emailadresses are enough
992 993
993 passParameters(&e, parameters, faxnumber, ""); 994 passParameters(&e, parameters, faxnumber, "");
994 995
995 996
996#else 997#else
997 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); 998 KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
998#endif 999#endif
999 1000
1000 1001
1001 return true; 1002 return true;
1002} 1003}
1003 1004
1004/************************************************************************** 1005/**************************************************************************
1005 * 1006 *
1006 **************************************************************************/ 1007 **************************************************************************/
1007 1008
1008//calls the sipapplication with the number 1009//calls the sipapplication with the number
1009bool ExternalAppHandler::callBySIP( const QString& sipnumber ) 1010bool ExternalAppHandler::callBySIP( const QString& sipnumber )
1010{ 1011{
1011#ifndef DESKTOP_VERSION 1012#ifndef DESKTOP_VERSION
1012 QString channel; 1013 QString channel;
1013 QString message; 1014 QString message;
1014 QString parameters; 1015 QString parameters;
1015 1016
1016 1017
1017 int client = KPimGlobalPrefs::instance()->mSipClient; 1018 int client = KPimGlobalPrefs::instance()->mSipClient;
1018 if (client == KPimGlobalPrefs::OTHER_SIC) 1019 if (client == KPimGlobalPrefs::OTHER_SIC)
1019 { 1020 {
1020 channel = KPimGlobalPrefs::instance()->mSipOtherChannel; 1021 channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
1021 message = KPimGlobalPrefs::instance()->mSipOtherMessage; 1022 message = KPimGlobalPrefs::instance()->mSipOtherMessage;
1022 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; 1023 parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
1023 } 1024 }
1024 else 1025 else
1025 { 1026 {
1026 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); 1027 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
1027 if (!dai) 1028 if (!dai)
1028 { 1029 {
1029 qDebug("could not find configured sip application."); 1030 qDebug("could not find configured sip application.");
1030 return false; 1031 return false;
1031 } 1032 }
1032 channel = dai->_channel; 1033 channel = dai->_channel;
1033 message = dai->_message; 1034 message = dai->_message;
1034 parameters = dai->_parameters; 1035 parameters = dai->_parameters;
1035 } 1036 }
1036 1037
1037 1038
1038 //first check if one of the sip apps need the emails right in the message. 1039 //first check if one of the sip apps need the emails right in the message.
1039 message = translateMessage(message, sipnumber, ""); 1040 message = translateMessage(message, sipnumber, "");
1040 1041
1041 1042
1042#ifdef DEBUG_EXT_APP_HANDLER 1043#ifdef DEBUG_EXT_APP_HANDLER
1043 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 1044 qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
1044 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); 1045 qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
1045#endif 1046#endif
1046 1047
1047 QCopEnvelope e(channel.latin1(), message.latin1()); 1048 QCopEnvelope e(channel.latin1(), message.latin1());
1048 //US we need no names in the To field. The emailadresses are enough 1049 //US we need no names in the To field. The emailadresses are enough
1049 1050
1050 passParameters(&e, parameters, sipnumber, ""); 1051 passParameters(&e, parameters, sipnumber, "");
1051 1052
1052 1053
1053#else 1054#else
1054 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); 1055 KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
1055#endif 1056#endif
1056 1057
1057 1058
1058 return true; 1059 return true;
1059} 1060}
1060 1061
1061 1062
1062/************************************************************************** 1063/**************************************************************************
1063 * 1064 *
1064 **************************************************************************/ 1065 **************************************************************************/
1065 1066
1066 1067
1067QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const 1068QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
1068{ 1069{
1069 message = message.replace( QRegExp("%1"), param1 ); 1070 message = message.replace( QRegExp("%1"), param1 );
1070 return message.replace( QRegExp("%2"), param2 ); 1071 return message.replace( QRegExp("%2"), param2 );
1071} 1072}
1072 1073
1073/************************************************************************** 1074/**************************************************************************
1074 * 1075 *
1075 **************************************************************************/ 1076 **************************************************************************/
1076 1077
1077void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const 1078void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
1078{ 1079{
1079#ifndef DESKTOP_VERSION 1080#ifndef DESKTOP_VERSION
1080 QMap<QString, QString> valmap; 1081 QMap<QString, QString> valmap;
1081 bool useValMap = false; 1082 bool useValMap = false;
1082 1083
1083 // first extract all parts of the parameters. 1084 // first extract all parts of the parameters.
1084 QStringList paramlist = QStringList::split(";", parameters); 1085 QStringList paramlist = QStringList::split(";", parameters);
1085 1086
1086 //Now check how many parts we have. 1087 //Now check how many parts we have.
1087 //=0 :no params to pass 1088 //=0 :no params to pass
1088 //>0 :parameters to pass 1089 //>0 :parameters to pass
1089 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) 1090 for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
1090 { 1091 {
1091 QString param = (*it); 1092 QString param = (*it);
1092 QStringList keyvallist = QStringList::split("=", param); 1093 QStringList keyvallist = QStringList::split("=", param);
1093 1094
1094 //if we have keyvalue pairs, we assume that we pass a map to the envelope 1095 //if we have keyvalue pairs, we assume that we pass a map to the envelope
1095 QStringList::Iterator it2 = keyvallist.begin(); 1096 QStringList::Iterator it2 = keyvallist.begin();
1096 QString key = (*it2); 1097 QString key = (*it2);
1097 key = key.replace( QRegExp("%1"), param1 ); 1098 key = key.replace( QRegExp("%1"), param1 );
1098 key = key.replace( QRegExp("%2"), param2 ); 1099 key = key.replace( QRegExp("%2"), param2 );
1099 ++it2; 1100 ++it2;
1100 1101
1101 if(it2 != keyvallist.end()) 1102 if(it2 != keyvallist.end())
1102 { 1103 {
1103 QString value = (*it2); 1104 QString value = (*it2);
1104 value = value.replace( QRegExp("%1"), param1 ); 1105 value = value.replace( QRegExp("%1"), param1 );
1105 value = value.replace( QRegExp("%2"), param2 ); 1106 value = value.replace( QRegExp("%2"), param2 );
1106 1107
1107 valmap.insert(key, value); 1108 valmap.insert(key, value);
1108 useValMap = true; 1109 useValMap = true;
1109 } 1110 }
1110 else 1111 else
1111 { 1112 {
1112 // qDebug("pass parameter << %s", key.latin1()); 1113 // qDebug("pass parameter << %s", key.latin1());
1113 (*e) << key; 1114 (*e) << key;
1114 } 1115 }
1115 } 1116 }
1116 1117
1117 if (useValMap == true) 1118 if (useValMap == true)
1118 (*e) << valmap; 1119 (*e) << valmap;
1119 1120
1120#endif 1121#endif
1121 1122
1122} 1123}
1123 1124
1124 1125
1125 1126
1126/************************************************************************** 1127/**************************************************************************
1127 * 1128 *
1128 **************************************************************************/ 1129 **************************************************************************/
1129 1130
1130void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) 1131void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
1131{ 1132{
1132 1133 qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
1133 if ( cmsg == "nextView()" ) { 1134 if ( cmsg == "nextView()" ) {
1134 qDebug("nextView()"); 1135 qDebug("nextView()");
1135 emit nextView(); 1136 QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
1136 return; 1137 return;
1137 } 1138 }
1138 if ( cmsg == "callContactdialog()" ) { 1139 if ( cmsg == "callContactdialog()" ) {
1139 qDebug("callContactdialog()"); 1140 qDebug("callContactdialog()");
1140 emit callContactdialog(); 1141 QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
1142 return;
1143 }
1144 if ( cmsg == "doRingSync" ) {
1145 qDebug("doRingSync");
1146 QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
1141 return; 1147 return;
1142 } 1148 }
1143 1149
1144 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1150 bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1145 if (!res) 1151 if (!res)
1146 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); 1152 res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
1147 1153
1148 if (!res) 1154 if (!res)
1149 res = mDisplayDetails->appMessage( cmsg, data ); 1155 res = mDisplayDetails->appMessage( cmsg, data );
1150 1156
1151// if (!res) 1157// if (!res)
1152// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); 1158// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
1153} 1159}
1154 1160
1155 1161
1156 1162
1157bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1163bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1158{ 1164{
1159 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1165 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1160 // maybe we are sending to KA/Pi fom a different worldd... 1166 // maybe we are sending to KA/Pi fom a different worldd...
1161 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application 1167 // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application
1162 // for that reason we send the current QApplication::desktop()->width() to KA/Pi 1168 // for that reason we send the current QApplication::desktop()->width() to KA/Pi
1163 //qDebug("UID %s ", sessionuid.latin1()); 1169 //qDebug("UID %s ", sessionuid.latin1());
1164 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); 1170 //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() ));
1165 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); 1171 return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
1166} 1172}
1167 1173
1168bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1174bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1169{ 1175{
1170 QStringList list4, list5, list6; 1176 QStringList list4, list5, list6;
1171 1177
1172 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); 1178 mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
1173 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1179 return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1174} 1180}
1175 1181
1176bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) 1182bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
1177{ 1183{
1178 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1184 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1179 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); 1185 return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
1180} 1186}
1181 1187
1182bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) 1188bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
1183{ 1189{
1184 QStringList list4, list5, list6; 1190 QStringList list4, list5, list6;
1185 1191
1186 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); 1192 mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
1187 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1193 return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1188} 1194}
1189 1195
1190bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) 1196bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
1191{ 1197{
1192 mDisplayDetails->setSourceChannel(""); 1198 mDisplayDetails->setSourceChannel("");
1193 return mDisplayDetails->sendMessageToTarget("", name, email, uid); 1199 return mDisplayDetails->sendMessageToTarget("", name, email, uid);
1194} 1200}
1195 1201
1196bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) 1202bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
1197{ 1203{
1198 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1204 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1199 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); 1205 return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid);
1200} 1206}
1201 1207
1202bool 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) 1208bool 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)
1203{ 1209{
1204 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); 1210 mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel);
1205 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); 1211 return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6);
1206} 1212}
1207 1213
1208 1214
1209 1215
1210 1216
1211 1217
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index 097f306..b899ad7 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -1,293 +1,294 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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 30
31#ifndef EXTERNALAPPHANDLER_H 31#ifndef EXTERNALAPPHANDLER_H
32#define EXTERNALAPPHANDLER_H 32#define EXTERNALAPPHANDLER_H
33 33
34#include <qobject.h> 34#include <qobject.h>
35#include <qlist.h> 35#include <qlist.h>
36#include <qmap.h> 36#include <qmap.h>
37 37
38class QCopEnvelope; 38class QCopEnvelope;
39 39
40 40
41class ExternalAppHandler; 41class ExternalAppHandler;
42class QCopTransferItem : public QObject 42class QCopTransferItem : public QObject
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 46 QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
47 QCopTransferItem(); 47 QCopTransferItem();
48 48
49 bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); 49 bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null);
50 50
51 void setSourceChannel(const QString& sourceChannel); 51 void setSourceChannel(const QString& sourceChannel);
52 52
53 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 53 virtual bool appMessage( const QCString& msg, const QByteArray& data );
54 54
55 55
56 signals: 56 signals:
57 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); 57 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid);
58 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); 58 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1);
59 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); 59 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2);
60 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); 60 void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3);
61 61
62 public: 62 public:
63 int _usedSourceParameters; 63 int _usedSourceParameters;
64 QString _sourceChannel; 64 QString _sourceChannel;
65 QString _sourceMessage; 65 QString _sourceMessage;
66 QString _sourceMessageParameters; 66 QString _sourceMessageParameters;
67 QString _targetChannel; 67 QString _targetChannel;
68 QString _targetMessage; 68 QString _targetMessage;
69 QString _targetMessageParameters; 69 QString _targetMessageParameters;
70 70
71}; 71};
72 72
73/********************************************************************************* 73/*********************************************************************************
74 * 74 *
75 ********************************************************************************/ 75 ********************************************************************************/
76 76
77class QCopMapTransferItem : public QCopTransferItem 77class QCopMapTransferItem : public QCopTransferItem
78{ 78{
79 Q_OBJECT 79 Q_OBJECT
80 public: 80 public:
81 QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 81 QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
82 82
83 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); 83 bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap);
84 84
85 85
86 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 86 virtual bool appMessage( const QCString& msg, const QByteArray& data );
87 87
88 88
89 signals: 89 signals:
90 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); 90 void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap);
91 91
92}; 92};
93 93
94/********************************************************************************* 94/*********************************************************************************
95 * 95 *
96 ********************************************************************************/ 96 ********************************************************************************/
97 97
98class QCopListTransferItem : public QCopTransferItem 98class QCopListTransferItem : public QCopTransferItem
99{ 99{
100 Q_OBJECT 100 Q_OBJECT
101 public: 101 public:
102 QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); 102 QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
103 ~QCopListTransferItem(); 103 ~QCopListTransferItem();
104 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); 104 bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6);
105 105
106 106
107 virtual bool appMessage( const QCString& msg, const QByteArray& data ); 107 virtual bool appMessage( const QCString& msg, const QByteArray& data );
108 108
109 109
110 signals: 110 signals:
111 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); 111 void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6);
112 112
113}; 113};
114 114
115/********************************************************************************* 115/*********************************************************************************
116 * 116 *
117 ********************************************************************************/ 117 ********************************************************************************/
118 118
119 119
120class DefaultAppItem 120class DefaultAppItem
121{ 121{
122 public: 122 public:
123 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) 123 DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2)
124 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) 124 : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2)
125 {} 125 {}
126 126
127 DefaultAppItem() 127 DefaultAppItem()
128 { } 128 { }
129 129
130 public: 130 public:
131 int _type; 131 int _type;
132 int _id; 132 int _id;
133 QString _label; 133 QString _label;
134 QString _channel; 134 QString _channel;
135 QString _message; 135 QString _message;
136 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; 136 QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ;
137 QString _message2; 137 QString _message2;
138 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; 138 QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ;
139 139
140}; 140};
141 141
142/********************************************************************************* 142/*********************************************************************************
143 * 143 *
144 ********************************************************************************/ 144 ********************************************************************************/
145 145
146class ExternalAppHandler : public QObject 146class ExternalAppHandler : public QObject
147{ 147{
148 Q_OBJECT 148 Q_OBJECT
149 public: 149 public:
150 virtual ~ExternalAppHandler(); 150 virtual ~ExternalAppHandler();
151 151
152 static ExternalAppHandler *instance(); 152 static ExternalAppHandler *instance();
153 153
154 enum Types { 154 enum Types {
155 EMAIL = 0, 155 EMAIL = 0,
156 PHONE = 1, 156 PHONE = 1,
157 SMS = 2, 157 SMS = 2,
158 FAX = 3, 158 FAX = 3,
159 PAGER = 4, 159 PAGER = 4,
160 SIP = 5 160 SIP = 5
161 }; 161 };
162 162
163 enum Availability { 163 enum Availability {
164 UNDEFINED = -1, 164 UNDEFINED = -1,
165 UNAVAILABLE = 0, 165 UNAVAILABLE = 0,
166 AVAILABLE = 1 166 AVAILABLE = 1
167 }; 167 };
168 168
169 //calls the emailapplication with a number of attachments that need to be send. 169 //calls the emailapplication with a number of attachments that need to be send.
170 //either parameter can be left empty. 170 //either parameter can be left empty.
171 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); 171 bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls );
172 172
173 //calls the emailapplication and creates a mail with parameter emailadress as recipients 173 //calls the emailapplication and creates a mail with parameter emailadress as recipients
174 bool mailToOneContact( const QString& name, const QString& emailadress ); 174 bool mailToOneContact( const QString& name, const QString& emailadress );
175 175
176 //calls the emailapplication and creates a mail with parameter as recipients 176 //calls the emailapplication and creates a mail with parameter as recipients
177 // parameters format is 177 // parameters format is
178 // NAME <EMAIL>:SUBJECT 178 // NAME <EMAIL>:SUBJECT
179 bool mailToOneContact( const QString& adressline ); 179 bool mailToOneContact( const QString& adressline );
180 180
181 //calls the phoneapplication with the number 181 //calls the phoneapplication with the number
182 bool callByPhone( const QString& phonenumber ); 182 bool callByPhone( const QString& phonenumber );
183 183
184 //calls the smsapplication with the number 184 //calls the smsapplication with the number
185 bool callBySMS( const QString& phonenumber ); 185 bool callBySMS( const QString& phonenumber );
186 186
187 //calls the pagerapplication with the number 187 //calls the pagerapplication with the number
188 bool callByPager( const QString& pagernumber ); 188 bool callByPager( const QString& pagernumber );
189 189
190 //calls the faxapplication with the number 190 //calls the faxapplication with the number
191 bool callByFax( const QString& faxnumber ); 191 bool callByFax( const QString& faxnumber );
192 192
193 //calls the sipapplication with the number 193 //calls the sipapplication with the number
194 bool callBySIP( const QString& sipnumber ); 194 bool callBySIP( const QString& sipnumber );
195 195
196 bool isEmailAppAvailable(); 196 bool isEmailAppAvailable();
197 bool isSMSAppAvailable(); 197 bool isSMSAppAvailable();
198 bool isPhoneAppAvailable(); 198 bool isPhoneAppAvailable();
199 bool isFaxAppAvailable(); 199 bool isFaxAppAvailable();
200 bool isPagerAppAvailable(); 200 bool isPagerAppAvailable();
201 bool isSIPAppAvailable(); 201 bool isSIPAppAvailable();
202 202
203 203
204 //Call this method on the source when you want to select names from the addressbook by using QCop 204 //Call this method on the source when you want to select names from the addressbook by using QCop
205 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); 205 bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid);
206 //Call this method on the target when you want to return the name/email map to the source (client). 206 //Call this method on the target when you want to return the name/email map to the source (client).
207 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); 207 bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid);
208 208
209 209
210 210
211 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); 211 bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email);
212 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); 212 bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid);
213 213
214 bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); 214 bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid);
215 215
216 216
217 217
218 bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); 218 bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid);
219 bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, 219 bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid,
220 const QStringList& birthdayList, const QStringList& anniversaryList, 220 const QStringList& birthdayList, const QStringList& anniversaryList,
221 const QStringList& realNameList, const QStringList& emailList, 221 const QStringList& realNameList, const QStringList& emailList,
222 const QStringList& assembledNameList, const QStringList& uidList); 222 const QStringList& assembledNameList, const QStringList& uidList);
223 223
224 224
225 //loadConfig clears the cache and checks again if the applications are available or not 225 //loadConfig clears the cache and checks again if the applications are available or not
226 void loadConfig(); 226 void loadConfig();
227 227
228 QList<DefaultAppItem> getAvailableDefaultItems(Types); 228 QList<DefaultAppItem> getAvailableDefaultItems(Types);
229 DefaultAppItem* getDefaultItem(Types, int); 229 DefaultAppItem* getDefaultItem(Types, int);
230 230
231 public slots: 231 public slots:
232 void appMessage( const QCString& msg, const QByteArray& data ); 232 void appMessage( const QCString& msg, const QByteArray& data );
233 233
234 234
235 signals: 235 signals:
236 void callContactdialog(); 236 void callContactdialog();
237 void nextView(); 237 void nextView();
238 void doRingSync();
238 // Emmitted when the target app receives a request from the source app 239 // Emmitted when the target app receives a request from the source app
239 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); 240 void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid);
240 241
241 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi 242 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
242 // The first parameter is a uniqueid. It can be used to identify the event 243 // The first parameter is a uniqueid. It can be used to identify the event
243 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); 244 void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
244 245
245 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); 246 void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email);
246 void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); 247 void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
247 248
248 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 249 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
249 250
250 251
251 // Emmitted when the target app receives a request from the source app 252 // Emmitted when the target app receives a request from the source app
252 void requestForBirthdayList(const QString& sourceChannel, const QString& uid); 253 void requestForBirthdayList(const QString& sourceChannel, const QString& uid);
253 254
254 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi 255 // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
255 // The first parameter is a uniqueid. It can be used to identify the event 256 // The first parameter is a uniqueid. It can be used to identify the event
256 void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, 257 void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList,
257 const QStringList& anniversaryList, const QStringList& realNameList, 258 const QStringList& anniversaryList, const QStringList& realNameList,
258 const QStringList& emailList, const QStringList& assembledNameList, 259 const QStringList& emailList, const QStringList& assembledNameList,
259 const QStringList& uidList); 260 const QStringList& uidList);
260 261
261 262
262 private: 263 private:
263 ExternalAppHandler(); 264 ExternalAppHandler();
264 QList<DefaultAppItem> mDefaultItems; 265 QList<DefaultAppItem> mDefaultItems;
265 266
266 Availability mEmailAppAvailable; 267 Availability mEmailAppAvailable;
267 Availability mPhoneAppAvailable; 268 Availability mPhoneAppAvailable;
268 Availability mFaxAppAvailable; 269 Availability mFaxAppAvailable;
269 Availability mSMSAppAvailable; 270 Availability mSMSAppAvailable;
270 Availability mPagerAppAvailable; 271 Availability mPagerAppAvailable;
271 Availability mSIPAppAvailable; 272 Availability mSIPAppAvailable;
272 273
273 QCopListTransferItem* mNameEmailUidListFromKAPITransfer; 274 QCopListTransferItem* mNameEmailUidListFromKAPITransfer;
274 QCopListTransferItem* mFindByEmailFromKAPITransfer; 275 QCopListTransferItem* mFindByEmailFromKAPITransfer;
275 QCopTransferItem* mDisplayDetails; 276 QCopTransferItem* mDisplayDetails;
276 QCopListTransferItem* mBirthdayListFromKAPITransfer; 277 QCopListTransferItem* mBirthdayListFromKAPITransfer;
277 278
278 279
279 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); 280 void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);
280 281
281 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; 282 QString& translateMessage(QString& message, const QString& param1, const QString& param2) const;
282 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; 283 void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const;
283 284
284 285
285 static ExternalAppHandler *sInstance; 286 static ExternalAppHandler *sInstance;
286 287
287 private slots: 288 private slots:
288 void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); 289 void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& );
289 290
290}; 291};
291 292
292 293
293#endif 294#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index db815d6..038e032 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -140,776 +140,778 @@ void KSyncManager::fillSyncMenu()
140 for ( i = 0; i < prof.count(); ++i ) { 140 for ( i = 0; i < prof.count(); ++i ) {
141 QString insertText = prof[i]; 141 QString insertText = prof[i];
142 if ( i == 0 ) { 142 if ( i == 0 ) {
143#ifdef DESKTOP_VERSION 143#ifdef DESKTOP_VERSION
144#ifdef _WIN32_ 144#ifdef _WIN32_
145 insertText = "OutLook(not_implemented)"; 145 insertText = "OutLook(not_implemented)";
146#else 146#else
147 insertText = "KDE_Desktop"; 147 insertText = "KDE_Desktop";
148#endif 148#endif
149#else 149#else
150 insertText = "Sharp_DTM"; 150 insertText = "Sharp_DTM";
151#endif 151#endif
152 } 152 }
153 mSyncMenu->insertItem( insertText, 1000+i ); 153 mSyncMenu->insertItem( insertText, 1000+i );
154 clearMenu->insertItem( insertText, 1000+i ); 154 clearMenu->insertItem( insertText, 1000+i );
155 if ( i == 2 ) 155 if ( i == 2 )
156 mSyncMenu->insertSeparator(); 156 mSyncMenu->insertSeparator();
157 } 157 }
158 QDir app_dir; 158 QDir app_dir;
159 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 159 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
160 if ( mTargetApp == PWMPI) { 160 if ( mTargetApp == PWMPI) {
161 mSyncMenu->removeItem( 1000 ); 161 mSyncMenu->removeItem( 1000 );
162 clearMenu->removeItem( 1000 ); 162 clearMenu->removeItem( 1000 );
163 } 163 }
164#ifndef DESKTOP_VERSION 164#ifndef DESKTOP_VERSION
165 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 165 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
166 mSyncMenu->removeItem( 1000 ); 166 mSyncMenu->removeItem( 1000 );
167 clearMenu->removeItem( 1000 ); 167 clearMenu->removeItem( 1000 );
168 } 168 }
169#endif 169#endif
170 mSyncMenu->removeItem( 1002 ); 170 mSyncMenu->removeItem( 1002 );
171 clearMenu->removeItem( 1002 ); 171 clearMenu->removeItem( 1002 );
172} 172}
173void KSyncManager::slotClearMenu( int action ) 173void KSyncManager::slotClearMenu( int action )
174{ 174{
175 QString syncDevice; 175 QString syncDevice;
176 if ( action > 999 ) { 176 if ( action > 999 ) {
177 syncDevice = mSyncProfileNames[action - 1000] ; 177 syncDevice = mSyncProfileNames[action - 1000] ;
178 } 178 }
179 179
180 180
181 181
182 int result = 0; 182 int result = 0;
183 QString sd; 183 QString sd;
184 if ( syncDevice.isEmpty() ) 184 if ( syncDevice.isEmpty() )
185 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 185 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
186 else 186 else
187 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 187 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
188 188
189 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 189 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
190 0, 1 ); 190 0, 1 );
191 if ( result ) 191 if ( result )
192 return; 192 return;
193 mImplementation->removeSyncInfo( syncDevice ); 193 mImplementation->removeSyncInfo( syncDevice );
194} 194}
195void KSyncManager::slotSyncMenu( int action ) 195void KSyncManager::slotSyncMenu( int action )
196{ 196{
197 qDebug("KSM::syncaction %d ", action); 197 qDebug("KSM::syncaction %d ", action);
198 if ( action == 5000 ) 198 if ( action == 5000 )
199 return; 199 return;
200 mSyncWithDesktop = false; 200 mSyncWithDesktop = false;
201 if ( action == 0 ) { 201 if ( action == 0 ) {
202 202
203 // seems to be a Qt2 event handling bug 203 // seems to be a Qt2 event handling bug
204 // syncmenu.clear causes a segfault at first time 204 // syncmenu.clear causes a segfault at first time
205 // when we call it after the main event loop, it is ok 205 // when we call it after the main event loop, it is ok
206 // same behaviour when calling OM/Pi via QCOP for the first time 206 // same behaviour when calling OM/Pi via QCOP for the first time
207 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 207 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
208 //confSync(); 208 //confSync();
209 209
210 return; 210 return;
211 } 211 }
212 if ( action == 1 ) { 212 if ( action == 1 ) {
213 multiSync( true ); 213 multiSync( true );
214 return; 214 return;
215 } 215 }
216 if ( action == 2 ) { 216 if ( action == 2 ) {
217 enableQuick(); 217 enableQuick();
218 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 218 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
219 return; 219 return;
220 } 220 }
221 if ( action == 3 ) { 221 if ( action == 3 ) {
222 delete mServerSocket; 222 delete mServerSocket;
223 mServerSocket = 0; 223 mServerSocket = 0;
224 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 224 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
225 return; 225 return;
226 } 226 }
227 227
228 if (blockSave()) 228 if (blockSave())
229 return; 229 return;
230 230
231 setBlockSave(true); 231 setBlockSave(true);
232 bool silent = false; 232 bool silent = false;
233 if ( action == 999 ) { 233 if ( action == 999 ) {
234 //special mode for silent syncing 234 //special mode for silent syncing
235 action = 1000; 235 action = 1000;
236 silent = true; 236 silent = true;
237 } 237 }
238 238
239 mCurrentSyncProfile = action - 1000 ; 239 mCurrentSyncProfile = action - 1000 ;
240 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 240 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
241 mCurrentSyncName = mLocalMachineName ; 241 mCurrentSyncName = mLocalMachineName ;
242 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 242 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
243 KSyncProfile* temp = new KSyncProfile (); 243 KSyncProfile* temp = new KSyncProfile ();
244 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 244 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
245 temp->readConfig(&config); 245 temp->readConfig(&config);
246 if (silent) { 246 if (silent) {
247 mAskForPreferences = false; 247 mAskForPreferences = false;
248 mShowSyncSummary = false; 248 mShowSyncSummary = false;
249 mWriteBackFile = true; 249 mWriteBackFile = true;
250 mSyncAlgoPrefs = 2;// take newest 250 mSyncAlgoPrefs = 2;// take newest
251 } 251 }
252 else { 252 else {
253 mAskForPreferences = temp->getAskForPreferences(); 253 mAskForPreferences = temp->getAskForPreferences();
254 mShowSyncSummary = temp->getShowSummaryAfterSync(); 254 mShowSyncSummary = temp->getShowSummaryAfterSync();
255 mWriteBackFile = temp->getWriteBackFile(); 255 mWriteBackFile = temp->getWriteBackFile();
256 mSyncAlgoPrefs = temp->getSyncPrefs(); 256 mSyncAlgoPrefs = temp->getSyncPrefs();
257 } 257 }
258 mWriteBackExistingOnly = temp->getWriteBackExisting(); 258 mWriteBackExistingOnly = temp->getWriteBackExisting();
259 mIsKapiFile = temp->getIsKapiFile(); 259 mIsKapiFile = temp->getIsKapiFile();
260 mWriteBackInFuture = 0; 260 mWriteBackInFuture = 0;
261 if ( temp->getWriteBackFuture() ) { 261 if ( temp->getWriteBackFuture() ) {
262 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 262 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
263 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 263 mWriteBackInPast = temp->getWriteBackPastWeeks( );
264 } 264 }
265 mFilterInCal = temp->getFilterInCal(); 265 mFilterInCal = temp->getFilterInCal();
266 mFilterOutCal = temp->getFilterOutCal(); 266 mFilterOutCal = temp->getFilterOutCal();
267 mFilterInAB = temp->getFilterInAB(); 267 mFilterInAB = temp->getFilterInAB();
268 mFilterOutAB = temp->getFilterOutAB(); 268 mFilterOutAB = temp->getFilterOutAB();
269 269
270 if ( action == 1000 ) { 270 if ( action == 1000 ) {
271 mIsKapiFile = false; 271 mIsKapiFile = false;
272#ifdef DESKTOP_VERSION 272#ifdef DESKTOP_VERSION
273 syncKDE(); 273 syncKDE();
274#else 274#else
275 syncSharp(); 275 syncSharp();
276#endif 276#endif
277 277
278 } else if ( action == 1001 ) { 278 } else if ( action == 1001 ) {
279 syncLocalFile(); 279 syncLocalFile();
280 280
281 } else if ( action == 1002 ) { 281 } else if ( action == 1002 ) {
282 mWriteBackFile = false; 282 mWriteBackFile = false;
283 mAskForPreferences = false; 283 mAskForPreferences = false;
284 mShowSyncSummary = false; 284 mShowSyncSummary = false;
285 mSyncAlgoPrefs = 3; 285 mSyncAlgoPrefs = 3;
286 quickSyncLocalFile(); 286 quickSyncLocalFile();
287 287
288 } else if ( action >= 1003 ) { 288 } else if ( action >= 1003 ) {
289 if ( temp->getIsLocalFileSync() ) { 289 if ( temp->getIsLocalFileSync() ) {
290 switch(mTargetApp) 290 switch(mTargetApp)
291 { 291 {
292 case (KAPI): 292 case (KAPI):
293 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 293 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
294 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 294 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
295 break; 295 break;
296 case (KOPI): 296 case (KOPI):
297 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 297 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
298 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 298 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
299 break; 299 break;
300 case (PWMPI): 300 case (PWMPI):
301 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 301 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
302 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 302 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
303 break; 303 break;
304 default: 304 default:
305 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 305 qDebug("KSM::slotSyncMenu: invalid apptype selected");
306 break; 306 break;
307 307
308 } 308 }
309 } else { 309 } else {
310 if ( temp->getIsPhoneSync() ) { 310 if ( temp->getIsPhoneSync() ) {
311 mPhoneDevice = temp->getPhoneDevice( ) ; 311 mPhoneDevice = temp->getPhoneDevice( ) ;
312 mPhoneConnection = temp->getPhoneConnection( ); 312 mPhoneConnection = temp->getPhoneConnection( );
313 mPhoneModel = temp->getPhoneModel( ); 313 mPhoneModel = temp->getPhoneModel( );
314 syncPhone(); 314 syncPhone();
315 } else if ( temp->getIsPiSync() ) { 315 } else if ( temp->getIsPiSync() ) {
316 if ( mTargetApp == KAPI ) { 316 if ( mTargetApp == KAPI ) {
317 mPassWordPiSync = temp->getRemotePwAB(); 317 mPassWordPiSync = temp->getRemotePwAB();
318 mActiveSyncPort = temp->getRemotePortAB(); 318 mActiveSyncPort = temp->getRemotePortAB();
319 mActiveSyncIP = temp->getRemoteIPAB(); 319 mActiveSyncIP = temp->getRemoteIPAB();
320 } else if ( mTargetApp == KOPI ) { 320 } else if ( mTargetApp == KOPI ) {
321 mPassWordPiSync = temp->getRemotePw(); 321 mPassWordPiSync = temp->getRemotePw();
322 mActiveSyncPort = temp->getRemotePort(); 322 mActiveSyncPort = temp->getRemotePort();
323 mActiveSyncIP = temp->getRemoteIP(); 323 mActiveSyncIP = temp->getRemoteIP();
324 } else { 324 } else {
325 mPassWordPiSync = temp->getRemotePwPWM(); 325 mPassWordPiSync = temp->getRemotePwPWM();
326 mActiveSyncPort = temp->getRemotePortPWM(); 326 mActiveSyncPort = temp->getRemotePortPWM();
327 mActiveSyncIP = temp->getRemoteIPPWM(); 327 mActiveSyncIP = temp->getRemoteIPPWM();
328 } 328 }
329 syncPi(); 329 syncPi();
330 while ( !mPisyncFinished ) { 330 while ( !mPisyncFinished ) {
331 //qDebug("waiting "); 331 //qDebug("waiting ");
332 qApp->processEvents(); 332 qApp->processEvents();
333 } 333 }
334 } else 334 } else
335 syncRemote( temp ); 335 syncRemote( temp );
336 336
337 } 337 }
338 } 338 }
339 delete temp; 339 delete temp;
340 setBlockSave(false); 340 setBlockSave(false);
341} 341}
342 342
343void KSyncManager::enableQuick( bool ask ) 343void KSyncManager::enableQuick( bool ask )
344{ 344{
345 bool autoStart; 345 bool autoStart;
346 bool changed = false; 346 bool changed = false;
347 if ( ask ) { 347 if ( ask ) {
348 QDialog dia ( 0, "input-dialog", true ); 348 QDialog dia ( 0, "input-dialog", true );
349 QLineEdit lab ( &dia ); 349 QLineEdit lab ( &dia );
350 QVBoxLayout lay( &dia ); 350 QVBoxLayout lay( &dia );
351 lab.setText( mPrefs->mPassiveSyncPort ); 351 lab.setText( mPrefs->mPassiveSyncPort );
352 lay.setMargin(7); 352 lay.setMargin(7);
353 lay.setSpacing(7); 353 lay.setSpacing(7);
354 int po = 9197+mTargetApp; 354 int po = 9197+mTargetApp;
355 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 355 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
356 lay.addWidget( &label); 356 lay.addWidget( &label);
357 lay.addWidget( &lab); 357 lay.addWidget( &lab);
358 358
359 QLineEdit lepw ( &dia ); 359 QLineEdit lepw ( &dia );
360 lepw.setText( mPrefs->mPassiveSyncPw ); 360 lepw.setText( mPrefs->mPassiveSyncPw );
361 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 361 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
362 lay.addWidget( &label2); 362 lay.addWidget( &label2);
363 lay.addWidget( &lepw); 363 lay.addWidget( &lepw);
364 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 364 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
365 lay.addWidget( &autostart); 365 lay.addWidget( &autostart);
366 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 366 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
367#ifdef DESKTOP_VERSION 367#ifdef DESKTOP_VERSION
368#ifdef _WIN32_ 368#ifdef _WIN32_
369 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 369 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
370 syncdesktop.hide();// not implemented! 370 syncdesktop.hide();// not implemented!
371#else 371#else
372 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 372 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
373#endif 373#endif
374 lay.addWidget( &syncdesktop); 374 lay.addWidget( &syncdesktop);
375#else 375#else
376 mPrefs->mPassiveSyncWithDesktop = false; 376 mPrefs->mPassiveSyncWithDesktop = false;
377 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
378 syncdesktop.hide(); 378 syncdesktop.hide();
379#endif 379#endif
380 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 380 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
381 381
382 QPushButton pb ( "OK", &dia); 382 QPushButton pb ( "OK", &dia);
383 lay.addWidget( &pb ); 383 lay.addWidget( &pb );
384 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 384 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
385 dia.resize( 230,120 ); 385 dia.resize( 230,120 );
386 dia.setCaption( i18n("Enter port for Pi-Sync") ); 386 dia.setCaption( i18n("Enter port for Pi-Sync") );
387 dia.show(); 387 dia.show();
388#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
389 int dw = QApplication::desktop()->width(); 389 int dw = QApplication::desktop()->width();
390 int dh = QApplication::desktop()->height(); 390 int dh = QApplication::desktop()->height();
391 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 391 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
392#endif 392#endif
393 if ( ! dia.exec() ) 393 if ( ! dia.exec() )
394 return; 394 return;
395 dia.hide(); 395 dia.hide();
396 qApp->processEvents(); 396 qApp->processEvents();
397 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 397 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
398 changed = true; 398 changed = true;
399 mPrefs->mPassiveSyncPw = lepw.text(); 399 mPrefs->mPassiveSyncPw = lepw.text();
400 } 400 }
401 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 401 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
402 mPrefs->mPassiveSyncPort = lab.text(); 402 mPrefs->mPassiveSyncPort = lab.text();
403 changed = true; 403 changed = true;
404 } 404 }
405 autoStart = autostart.isChecked(); 405 autoStart = autostart.isChecked();
406 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 406 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
407 changed = true; 407 changed = true;
408 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 408 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
409 } 409 }
410 } 410 }
411 else 411 else
412 autoStart = mPrefs->mPassiveSyncAutoStart; 412 autoStart = mPrefs->mPassiveSyncAutoStart;
413 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 413 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
414 changed = true; 414 changed = true;
415 bool ok; 415 bool ok;
416 mPrefs->mPassiveSyncAutoStart = false; 416 mPrefs->mPassiveSyncAutoStart = false;
417 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 417 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
418 if ( ! ok ) { 418 if ( ! ok ) {
419 KMessageBox::information( 0, i18n("No valid port")); 419 KMessageBox::information( 0, i18n("No valid port"));
420 return; 420 return;
421 } 421 }
422 //qDebug("port %d ", port); 422 //qDebug("port %d ", port);
423 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 423 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
424 mServerSocket->setFileName( defaultFileName() );//bbb 424 mServerSocket->setFileName( defaultFileName() );//bbb
425 if ( !mServerSocket->ok() ) { 425 if ( !mServerSocket->ok() ) {
426 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 426 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
427 delete mServerSocket; 427 delete mServerSocket;
428 mServerSocket = 0; 428 mServerSocket = 0;
429 return; 429 return;
430 } 430 }
431 mPrefs->mPassiveSyncAutoStart = autoStart; 431 mPrefs->mPassiveSyncAutoStart = autoStart;
432 if ( changed ) { 432 if ( changed ) {
433 mPrefs->writeConfig(); 433 mPrefs->writeConfig();
434 } 434 }
435 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 435 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
436 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 436 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
437} 437}
438 438
439void KSyncManager::syncLocalFile() 439void KSyncManager::syncLocalFile()
440{ 440{
441 441
442 QString fn =mPrefs->mLastSyncedLocalFile; 442 QString fn =mPrefs->mLastSyncedLocalFile;
443 QString ext; 443 QString ext;
444 444
445 switch(mTargetApp) 445 switch(mTargetApp)
446 { 446 {
447 case (KAPI): 447 case (KAPI):
448 ext = "(*.vcf)"; 448 ext = "(*.vcf)";
449 break; 449 break;
450 case (KOPI): 450 case (KOPI):
451 ext = "(*.ics/*.vcs)"; 451 ext = "(*.ics/*.vcs)";
452 break; 452 break;
453 case (PWMPI): 453 case (PWMPI):
454 ext = "(*.pwm)"; 454 ext = "(*.pwm)";
455 break; 455 break;
456 default: 456 default:
457 qDebug("KSM::syncLocalFile: invalid apptype selected"); 457 qDebug("KSM::syncLocalFile: invalid apptype selected");
458 break; 458 break;
459 459
460 } 460 }
461 461
462 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 462 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
463 if ( fn == "" ) 463 if ( fn == "" )
464 return; 464 return;
465 if ( syncWithFile( fn, false ) ) { 465 if ( syncWithFile( fn, false ) ) {
466 qDebug("KSM::syncLocalFile() successful "); 466 qDebug("KSM::syncLocalFile() successful ");
467 } 467 }
468 468
469} 469}
470 470
471bool KSyncManager::syncWithFile( QString fn , bool quick ) 471bool KSyncManager::syncWithFile( QString fn , bool quick )
472{ 472{
473 bool ret = false; 473 bool ret = false;
474 QFileInfo info; 474 QFileInfo info;
475 info.setFile( fn ); 475 info.setFile( fn );
476 QString mess; 476 QString mess;
477 if ( !info. exists() ) { 477 if ( !info. exists() ) {
478 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 478 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
479 QMessageBox::warning( mParent, i18n("Warning!"), 479 QMessageBox::warning( mParent, i18n("Warning!"),
480 mess ); 480 mess );
481 return ret; 481 return ret;
482 } 482 }
483 int result = 0; 483 int result = 0;
484 if ( !quick ) { 484 if ( !quick ) {
485 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 485 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
486 result = QMessageBox::warning( mParent, i18n("Warning!"), 486 result = QMessageBox::warning( mParent, i18n("Warning!"),
487 mess, 487 mess,
488 i18n("Sync"), i18n("Cancel"), 0, 488 i18n("Sync"), i18n("Cancel"), 0,
489 0, 1 ); 489 0, 1 );
490 if ( result ) 490 if ( result )
491 return false; 491 return false;
492 } 492 }
493 if ( mAskForPreferences ) 493 if ( mAskForPreferences )
494 if ( !edit_sync_options()) { 494 if ( !edit_sync_options()) {
495 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 495 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
496 return false; 496 return false;
497 } 497 }
498 if ( result == 0 ) { 498 if ( result == 0 ) {
499 //qDebug("Now sycing ... "); 499 //qDebug("Now sycing ... ");
500 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 500 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
501 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 501 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
502 else 502 else
503 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 503 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
504 if ( ! quick ) 504 if ( ! quick )
505 mPrefs->mLastSyncedLocalFile = fn; 505 mPrefs->mLastSyncedLocalFile = fn;
506 } 506 }
507 return ret; 507 return ret;
508} 508}
509 509
510void KSyncManager::quickSyncLocalFile() 510void KSyncManager::quickSyncLocalFile()
511{ 511{
512 512
513 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 513 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
514 qDebug("KSM::quick syncLocalFile() successful "); 514 qDebug("KSM::quick syncLocalFile() successful ");
515 515
516 } 516 }
517} 517}
518 518
519void KSyncManager::multiSync( bool askforPrefs ) 519void KSyncManager::multiSync( bool askforPrefs )
520{ 520{
521 if (blockSave()) 521 if (blockSave())
522 return; 522 return;
523 setBlockSave(true); 523 setBlockSave(true);
524 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 524 if ( askforPrefs ) {
525 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 525 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
526 question, 526 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
527 i18n("Yes"), i18n("No"), 527 question,
528 0, 0 ) != 0 ) { 528 i18n("Yes"), i18n("No"),
529 setBlockSave(false); 529 0, 0 ) != 0 ) {
530 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 530 setBlockSave(false);
531 return; 531 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
532 return;
533 }
532 } 534 }
533 mCurrentSyncDevice = i18n("Multiple profiles") ; 535 mCurrentSyncDevice = i18n("Multiple profiles") ;
534 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 536 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
535 if ( askforPrefs ) { 537 if ( askforPrefs ) {
536 if ( !edit_sync_options()) { 538 if ( !edit_sync_options()) {
537 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 539 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
538 return; 540 return;
539 } 541 }
540 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 542 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
541 } 543 }
542 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 544 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
543 qApp->processEvents(); 545 qApp->processEvents();
544 int num = ringSync() ; 546 int num = ringSync() ;
545 if ( num > 1 ) 547 if ( num > 1 )
546 ringSync(); 548 ringSync();
547 setBlockSave(false); 549 setBlockSave(false);
548 if ( num ) 550 if ( num )
549 emit save(); 551 emit save();
550 if ( num ) 552 if ( num )
551 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 553 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
552 else 554 else
553 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 555 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
554 return; 556 return;
555} 557}
556 558
557int KSyncManager::ringSync() 559int KSyncManager::ringSync()
558{ 560{
559 561
560 int syncedProfiles = 0; 562 int syncedProfiles = 0;
561 unsigned int i; 563 unsigned int i;
562 QTime timer; 564 QTime timer;
563 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 565 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
564 QStringList syncProfileNames = mSyncProfileNames; 566 QStringList syncProfileNames = mSyncProfileNames;
565 KSyncProfile* temp = new KSyncProfile (); 567 KSyncProfile* temp = new KSyncProfile ();
566 mAskForPreferences = false; 568 mAskForPreferences = false;
567 for ( i = 0; i < syncProfileNames.count(); ++i ) { 569 for ( i = 0; i < syncProfileNames.count(); ++i ) {
568 mCurrentSyncProfile = i; 570 mCurrentSyncProfile = i;
569 temp->setName(syncProfileNames[mCurrentSyncProfile]); 571 temp->setName(syncProfileNames[mCurrentSyncProfile]);
570 temp->readConfig(&config); 572 temp->readConfig(&config);
571 573
572 bool includeInRingSync = false; 574 bool includeInRingSync = false;
573 switch(mTargetApp) 575 switch(mTargetApp)
574 { 576 {
575 case (KAPI): 577 case (KAPI):
576 includeInRingSync = temp->getIncludeInRingSyncAB(); 578 includeInRingSync = temp->getIncludeInRingSyncAB();
577 break; 579 break;
578 case (KOPI): 580 case (KOPI):
579 includeInRingSync = temp->getIncludeInRingSync(); 581 includeInRingSync = temp->getIncludeInRingSync();
580 break; 582 break;
581 case (PWMPI): 583 case (PWMPI):
582 includeInRingSync = temp->getIncludeInRingSyncPWM(); 584 includeInRingSync = temp->getIncludeInRingSyncPWM();
583 break; 585 break;
584 default: 586 default:
585 qDebug("KSM::ringSync: invalid apptype selected"); 587 qDebug("KSM::ringSync: invalid apptype selected");
586 break; 588 break;
587 589
588 } 590 }
589 591
590 592
591 if ( includeInRingSync && ( i < 1 || i > 2 )) { 593 if ( includeInRingSync && ( i < 1 || i > 2 )) {
592 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 594 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
593 ++syncedProfiles; 595 ++syncedProfiles;
594 mSyncWithDesktop = false; 596 mSyncWithDesktop = false;
595 // mAskForPreferences = temp->getAskForPreferences(); 597 // mAskForPreferences = temp->getAskForPreferences();
596 mWriteBackFile = temp->getWriteBackFile(); 598 mWriteBackFile = temp->getWriteBackFile();
597 mWriteBackExistingOnly = temp->getWriteBackExisting(); 599 mWriteBackExistingOnly = temp->getWriteBackExisting();
598 mIsKapiFile = temp->getIsKapiFile(); 600 mIsKapiFile = temp->getIsKapiFile();
599 mWriteBackInFuture = 0; 601 mWriteBackInFuture = 0;
600 if ( temp->getWriteBackFuture() ) { 602 if ( temp->getWriteBackFuture() ) {
601 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 603 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
602 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 604 mWriteBackInPast = temp->getWriteBackPastWeeks( );
603 } 605 }
604 mFilterInCal = temp->getFilterInCal(); 606 mFilterInCal = temp->getFilterInCal();
605 mFilterOutCal = temp->getFilterOutCal(); 607 mFilterOutCal = temp->getFilterOutCal();
606 mFilterInAB = temp->getFilterInAB(); 608 mFilterInAB = temp->getFilterInAB();
607 mFilterOutAB = temp->getFilterOutAB(); 609 mFilterOutAB = temp->getFilterOutAB();
608 mShowSyncSummary = false; 610 mShowSyncSummary = false;
609 mCurrentSyncDevice = syncProfileNames[i] ; 611 mCurrentSyncDevice = syncProfileNames[i] ;
610 mCurrentSyncName = mLocalMachineName; 612 mCurrentSyncName = mLocalMachineName;
611 if ( i == 0 ) { 613 if ( i == 0 ) {
612 mIsKapiFile = false; 614 mIsKapiFile = false;
613#ifdef DESKTOP_VERSION 615#ifdef DESKTOP_VERSION
614 syncKDE(); 616 syncKDE();
615#else 617#else
616 syncSharp(); 618 syncSharp();
617#endif 619#endif
618 } else { 620 } else {
619 if ( temp->getIsLocalFileSync() ) { 621 if ( temp->getIsLocalFileSync() ) {
620 switch(mTargetApp) 622 switch(mTargetApp)
621 { 623 {
622 case (KAPI): 624 case (KAPI):
623 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 625 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
624 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 626 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
625 break; 627 break;
626 case (KOPI): 628 case (KOPI):
627 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 629 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
628 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 630 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
629 break; 631 break;
630 case (PWMPI): 632 case (PWMPI):
631 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 633 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
632 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 634 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
633 break; 635 break;
634 default: 636 default:
635 qDebug("KSM: invalid apptype selected"); 637 qDebug("KSM: invalid apptype selected");
636 break; 638 break;
637 } 639 }
638 } else { 640 } else {
639 if ( temp->getIsPhoneSync() ) { 641 if ( temp->getIsPhoneSync() ) {
640 mPhoneDevice = temp->getPhoneDevice( ) ; 642 mPhoneDevice = temp->getPhoneDevice( ) ;
641 mPhoneConnection = temp->getPhoneConnection( ); 643 mPhoneConnection = temp->getPhoneConnection( );
642 mPhoneModel = temp->getPhoneModel( ); 644 mPhoneModel = temp->getPhoneModel( );
643 syncPhone(); 645 syncPhone();
644 } else if ( temp->getIsPiSync() ) { 646 } else if ( temp->getIsPiSync() ) {
645 if ( mTargetApp == KAPI ) { 647 if ( mTargetApp == KAPI ) {
646 mPassWordPiSync = temp->getRemotePwAB(); 648 mPassWordPiSync = temp->getRemotePwAB();
647 mActiveSyncPort = temp->getRemotePortAB(); 649 mActiveSyncPort = temp->getRemotePortAB();
648 mActiveSyncIP = temp->getRemoteIPAB(); 650 mActiveSyncIP = temp->getRemoteIPAB();
649 } else if ( mTargetApp == KOPI ) { 651 } else if ( mTargetApp == KOPI ) {
650 mPassWordPiSync = temp->getRemotePw(); 652 mPassWordPiSync = temp->getRemotePw();
651 mActiveSyncPort = temp->getRemotePort(); 653 mActiveSyncPort = temp->getRemotePort();
652 mActiveSyncIP = temp->getRemoteIP(); 654 mActiveSyncIP = temp->getRemoteIP();
653 } else { 655 } else {
654 mPassWordPiSync = temp->getRemotePwPWM(); 656 mPassWordPiSync = temp->getRemotePwPWM();
655 mActiveSyncPort = temp->getRemotePortPWM(); 657 mActiveSyncPort = temp->getRemotePortPWM();
656 mActiveSyncIP = temp->getRemoteIPPWM(); 658 mActiveSyncIP = temp->getRemoteIPPWM();
657 } 659 }
658 syncPi(); 660 syncPi();
659 while ( !mPisyncFinished ) { 661 while ( !mPisyncFinished ) {
660 //qDebug("waiting "); 662 //qDebug("waiting ");
661 qApp->processEvents(); 663 qApp->processEvents();
662 } 664 }
663 timer.start(); 665 timer.start();
664 while ( timer.elapsed () < 2000 ) { 666 while ( timer.elapsed () < 2000 ) {
665 qApp->processEvents(); 667 qApp->processEvents();
666 } 668 }
667 } else 669 } else
668 syncRemote( temp, false ); 670 syncRemote( temp, false );
669 671
670 } 672 }
671 } 673 }
672 timer.start(); 674 timer.start();
673 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 675 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
674 while ( timer.elapsed () < 2000 ) { 676 while ( timer.elapsed () < 2000 ) {
675 qApp->processEvents(); 677 qApp->processEvents();
676#ifndef _WIN32_ 678#ifndef _WIN32_
677 sleep (1); 679 sleep (1);
678#endif 680#endif
679 } 681 }
680 682
681 } 683 }
682 684
683 } 685 }
684 delete temp; 686 delete temp;
685 return syncedProfiles; 687 return syncedProfiles;
686} 688}
687 689
688void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 690void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
689{ 691{
690 QString question; 692 QString question;
691 if ( ask ) { 693 if ( ask ) {
692 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 694 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
693 if ( QMessageBox::information( mParent, i18n("Sync"), 695 if ( QMessageBox::information( mParent, i18n("Sync"),
694 question, 696 question,
695 i18n("Yes"), i18n("No"), 697 i18n("Yes"), i18n("No"),
696 0, 0 ) != 0 ) 698 0, 0 ) != 0 )
697 return; 699 return;
698 } 700 }
699 701
700 QString preCommand; 702 QString preCommand;
701 QString localTempFile; 703 QString localTempFile;
702 QString postCommand; 704 QString postCommand;
703 705
704 switch(mTargetApp) 706 switch(mTargetApp)
705 { 707 {
706 case (KAPI): 708 case (KAPI):
707 preCommand = prof->getPreSyncCommandAB(); 709 preCommand = prof->getPreSyncCommandAB();
708 postCommand = prof->getPostSyncCommandAB(); 710 postCommand = prof->getPostSyncCommandAB();
709 localTempFile = prof->getLocalTempFileAB(); 711 localTempFile = prof->getLocalTempFileAB();
710 break; 712 break;
711 case (KOPI): 713 case (KOPI):
712 preCommand = prof->getPreSyncCommand(); 714 preCommand = prof->getPreSyncCommand();
713 postCommand = prof->getPostSyncCommand(); 715 postCommand = prof->getPostSyncCommand();
714 localTempFile = prof->getLocalTempFile(); 716 localTempFile = prof->getLocalTempFile();
715 break; 717 break;
716 case (PWMPI): 718 case (PWMPI):
717 preCommand = prof->getPreSyncCommandPWM(); 719 preCommand = prof->getPreSyncCommandPWM();
718 postCommand = prof->getPostSyncCommandPWM(); 720 postCommand = prof->getPostSyncCommandPWM();
719 localTempFile = prof->getLocalTempFilePWM(); 721 localTempFile = prof->getLocalTempFilePWM();
720 break; 722 break;
721 default: 723 default:
722 qDebug("KSM::syncRemote: invalid apptype selected"); 724 qDebug("KSM::syncRemote: invalid apptype selected");
723 break; 725 break;
724 } 726 }
725 727
726 728
727 int fi; 729 int fi;
728 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 730 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
729 QString pwd = getPassword(); 731 QString pwd = getPassword();
730 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 732 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
731 733
732 } 734 }
733 int maxlen = 30; 735 int maxlen = 30;
734 if ( QApplication::desktop()->width() > 320 ) 736 if ( QApplication::desktop()->width() > 320 )
735 maxlen += 25; 737 maxlen += 25;
736 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 738 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
737 int fileSize = 0; 739 int fileSize = 0;
738 int result = system ( preCommand ); 740 int result = system ( preCommand );
739 // 0 : okay 741 // 0 : okay
740 // 256: no such file or dir 742 // 256: no such file or dir
741 // 743 //
742 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 744 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
743 if ( result != 0 ) { 745 if ( result != 0 ) {
744 unsigned int len = maxlen; 746 unsigned int len = maxlen;
745 while ( len < preCommand.length() ) { 747 while ( len < preCommand.length() ) {
746 preCommand.insert( len , "\n" ); 748 preCommand.insert( len , "\n" );
747 len += maxlen +2; 749 len += maxlen +2;
748 } 750 }
749 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) ; 751 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) ;
750 QMessageBox::information( mParent, i18n("Sync - ERROR"), 752 QMessageBox::information( mParent, i18n("Sync - ERROR"),
751 question, 753 question,
752 i18n("Okay!")) ; 754 i18n("Okay!")) ;
753 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 755 mParent->topLevelWidget()->setCaption ("KDE-Pim");
754 return; 756 return;
755 } 757 }
756 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 758 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
757 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 759 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
758 760
759 if ( syncWithFile( localTempFile, true ) ) { 761 if ( syncWithFile( localTempFile, true ) ) {
760 762
761 if ( mWriteBackFile ) { 763 if ( mWriteBackFile ) {
762 int fi; 764 int fi;
763 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 765 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
764 QString pwd = getPassword(); 766 QString pwd = getPassword();
765 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 767 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
766 768
767 } 769 }
768 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 770 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
769 result = system ( postCommand ); 771 result = system ( postCommand );
770 qDebug("KSM::Sync:Writing back file result: %d ", result); 772 qDebug("KSM::Sync:Writing back file result: %d ", result);
771 if ( result != 0 ) { 773 if ( result != 0 ) {
772 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 774 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
773 return; 775 return;
774 } else { 776 } else {
775 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 777 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
776 } 778 }
777 } 779 }
778 } 780 }
779 return; 781 return;
780} 782}
781bool KSyncManager::edit_pisync_options() 783bool KSyncManager::edit_pisync_options()
782{ 784{
783 QDialog dia( mParent, "dia", true ); 785 QDialog dia( mParent, "dia", true );
784 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 786 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
785 QVBoxLayout lay ( &dia ); 787 QVBoxLayout lay ( &dia );
786 lay.setSpacing( 5 ); 788 lay.setSpacing( 5 );
787 lay.setMargin( 3 ); 789 lay.setMargin( 3 );
788 QLabel lab1 ( i18n("Password for remote access:"), &dia); 790 QLabel lab1 ( i18n("Password for remote access:"), &dia);
789 lay.addWidget( &lab1 ); 791 lay.addWidget( &lab1 );
790 QLineEdit le1 (&dia ); 792 QLineEdit le1 (&dia );
791 lay.addWidget( &le1 ); 793 lay.addWidget( &le1 );
792 QLabel lab2 ( i18n("Remote IP address:"), &dia); 794 QLabel lab2 ( i18n("Remote IP address:"), &dia);
793 lay.addWidget( &lab2 ); 795 lay.addWidget( &lab2 );
794 QLineEdit le2 (&dia ); 796 QLineEdit le2 (&dia );
795 lay.addWidget( &le2 ); 797 lay.addWidget( &le2 );
796 QLabel lab3 ( i18n("Remote port number:"), &dia); 798 QLabel lab3 ( i18n("Remote port number:"), &dia);
797 lay.addWidget( &lab3 ); 799 lay.addWidget( &lab3 );
798 QLineEdit le3 (&dia ); 800 QLineEdit le3 (&dia );
799 lay.addWidget( &le3 ); 801 lay.addWidget( &le3 );
800 QPushButton pb ( "OK", &dia); 802 QPushButton pb ( "OK", &dia);
801 lay.addWidget( &pb ); 803 lay.addWidget( &pb );
802 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 804 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
803 le1.setText( mPassWordPiSync ); 805 le1.setText( mPassWordPiSync );
804 le2.setText( mActiveSyncIP ); 806 le2.setText( mActiveSyncIP );
805 le3.setText( mActiveSyncPort ); 807 le3.setText( mActiveSyncPort );
806 if ( dia.exec() ) { 808 if ( dia.exec() ) {
807 mPassWordPiSync = le1.text(); 809 mPassWordPiSync = le1.text();
808 mActiveSyncPort = le3.text(); 810 mActiveSyncPort = le3.text();
809 mActiveSyncIP = le2.text(); 811 mActiveSyncIP = le2.text();
810 return true; 812 return true;
811 } 813 }
812 return false; 814 return false;
813} 815}
814bool KSyncManager::edit_sync_options() 816bool KSyncManager::edit_sync_options()
815{ 817{
816 818
817 QDialog dia( mParent, "dia", true ); 819 QDialog dia( mParent, "dia", true );
818 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 820 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
819 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 821 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
820 QVBoxLayout lay ( &dia ); 822 QVBoxLayout lay ( &dia );
821 lay.setSpacing( 2 ); 823 lay.setSpacing( 2 );
822 lay.setMargin( 3 ); 824 lay.setMargin( 3 );
823 lay.addWidget(&gr); 825 lay.addWidget(&gr);
824 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 826 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
825 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 827 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
826 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 828 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
827 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 829 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
828 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 830 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
829 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 831 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
830 //QRadioButton both( i18n("Take both on conflict"), &gr ); 832 //QRadioButton both( i18n("Take both on conflict"), &gr );
831 QPushButton pb ( "OK", &dia); 833 QPushButton pb ( "OK", &dia);
832 lay.addWidget( &pb ); 834 lay.addWidget( &pb );
833 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 835 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
834 switch ( mSyncAlgoPrefs ) { 836 switch ( mSyncAlgoPrefs ) {
835 case 0: 837 case 0:
836 loc.setChecked( true); 838 loc.setChecked( true);
837 break; 839 break;
838 case 1: 840 case 1:
839 rem.setChecked( true ); 841 rem.setChecked( true );
840 break; 842 break;
841 case 2: 843 case 2:
842 newest.setChecked( true); 844 newest.setChecked( true);
843 break; 845 break;
844 case 3: 846 case 3:
845 ask.setChecked( true); 847 ask.setChecked( true);
846 break; 848 break;
847 case 4: 849 case 4:
848 f_loc.setChecked( true); 850 f_loc.setChecked( true);
849 break; 851 break;
850 case 5: 852 case 5:
851 f_rem.setChecked( true); 853 f_rem.setChecked( true);
852 break; 854 break;
853 case 6: 855 case 6:
854 // both.setChecked( true); 856 // both.setChecked( true);
855 break; 857 break;
856 default: 858 default:
857 break; 859 break;
858 } 860 }
859 if ( dia.exec() ) { 861 if ( dia.exec() ) {
860 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 862 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
861 return true; 863 return true;
862 } 864 }
863 return false; 865 return false;
864} 866}
865 867
866QString KSyncManager::getPassword( ) 868QString KSyncManager::getPassword( )
867{ 869{
868 QString retfile = ""; 870 QString retfile = "";
869 QDialog dia ( mParent, "input-dialog", true ); 871 QDialog dia ( mParent, "input-dialog", true );
870 QLineEdit lab ( &dia ); 872 QLineEdit lab ( &dia );
871 lab.setEchoMode( QLineEdit::Password ); 873 lab.setEchoMode( QLineEdit::Password );
872 QVBoxLayout lay( &dia ); 874 QVBoxLayout lay( &dia );
873 lay.setMargin(7); 875 lay.setMargin(7);
874 lay.setSpacing(7); 876 lay.setSpacing(7);
875 lay.addWidget( &lab); 877 lay.addWidget( &lab);
876 dia.setFixedSize( 230,50 ); 878 dia.setFixedSize( 230,50 );
877 dia.setCaption( i18n("Enter password") ); 879 dia.setCaption( i18n("Enter password") );
878 QPushButton pb ( "OK", &dia); 880 QPushButton pb ( "OK", &dia);
879 lay.addWidget( &pb ); 881 lay.addWidget( &pb );
880 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 882 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
881 dia.show(); 883 dia.show();
882 int res = dia.exec(); 884 int res = dia.exec();
883 if ( res ) 885 if ( res )
884 retfile = lab.text(); 886 retfile = lab.text();
885 dia.hide(); 887 dia.hide();
886 qApp->processEvents(); 888 qApp->processEvents();
887 return retfile; 889 return retfile;
888 890
889} 891}
890 892
891 893
892void KSyncManager::confSync() 894void KSyncManager::confSync()
893{ 895{
894 static KSyncPrefsDialog* sp = 0; 896 static KSyncPrefsDialog* sp = 0;
895 if ( ! sp ) { 897 if ( ! sp ) {
896 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 898 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
897 } 899 }
898 sp->usrReadConfig(); 900 sp->usrReadConfig();
899#ifndef DESKTOP_VERSION 901#ifndef DESKTOP_VERSION
900 sp->showMaximized(); 902 sp->showMaximized();
901#else 903#else
902 sp->show(); 904 sp->show();
903#endif 905#endif
904 sp->exec(); 906 sp->exec();
905 QStringList oldSyncProfileNames = mSyncProfileNames; 907 QStringList oldSyncProfileNames = mSyncProfileNames;
906 mSyncProfileNames = sp->getSyncProfileNames(); 908 mSyncProfileNames = sp->getSyncProfileNames();
907 mLocalMachineName = sp->getLocalMachineName (); 909 mLocalMachineName = sp->getLocalMachineName ();
908 int ii; 910 int ii;
909 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 911 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
910 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 912 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
911 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 913 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
912 } 914 }
913 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 915 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
914} 916}
915void KSyncManager::syncKDE() 917void KSyncManager::syncKDE()