summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorzautrix <zautrix>2005-06-29 16:14:46 (UTC)
committer zautrix <zautrix>2005-06-29 16:14:46 (UTC)
commit77aa480c9891a90c9b492618ebfd2b20f2d0727a (patch) (unidiff)
tree4f2c278d016fe21f280f8ee6abbca34685aada96 /libkdepim
parente0fa858c284dddf0d47146e666c4ece7158487be (diff)
downloadkdepimpi-77aa480c9891a90c9b492618ebfd2b20f2d0727a.zip
kdepimpi-77aa480c9891a90c9b492618ebfd2b20f2d0727a.tar.gz
kdepimpi-77aa480c9891a90c9b492618ebfd2b20f2d0727a.tar.bz2
many sync fixes
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,224 +1,225 @@
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
@@ -940,272 +941,277 @@ bool ExternalAppHandler::callByPager( const QString& pagernumber )
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
@@ -46,248 +46,249 @@ class QCopTransferItem : public QObject
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
@@ -332,392 +332,394 @@ void KSyncManager::slotSyncMenu( int action )
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;