author | zautrix <zautrix> | 2005-06-29 16:14:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-29 16:14:46 (UTC) |
commit | 77aa480c9891a90c9b492618ebfd2b20f2d0727a (patch) (unidiff) | |
tree | 4f2c278d016fe21f280f8ee6abbca34685aada96 /libkdepim/externalapphandler.cpp | |
parent | e0fa858c284dddf0d47146e666c4ece7158487be (diff) | |
download | kdepimpi-77aa480c9891a90c9b492618ebfd2b20f2d0727a.zip kdepimpi-77aa480c9891a90c9b492618ebfd2b20f2d0727a.tar.gz kdepimpi-77aa480c9891a90c9b492618ebfd2b20f2d0727a.tar.bz2 |
many sync fixes
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/externalapphandler.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 0e9c5e5..2ce6926 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,1211 +1,1217 @@ | |||
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 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (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 | ||
59 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 60 | QCopTransferItem::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 | ||
75 | QCopTransferItem::QCopTransferItem() | 76 | QCopTransferItem::QCopTransferItem() |
76 | { | 77 | { |
77 | } | 78 | } |
78 | 79 | ||
79 | /*********************************************************************************/ | 80 | /*********************************************************************************/ |
80 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) | 81 | bool 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 | /*********************************************************************************/ |
115 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | 116 | void 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 | /*********************************************************************************/ |
124 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 125 | bool 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 | ||
190 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 191 | QCopMapTransferItem::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 | /*********************************************************************************/ |
198 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 199 | bool 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 | /*********************************************************************************/ |
227 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 228 | bool 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 | ||
260 | QCopListTransferItem::~QCopListTransferItem() | 261 | QCopListTransferItem::~QCopListTransferItem() |
261 | { | 262 | { |
262 | 263 | ||
263 | } | 264 | } |
264 | 265 | ||
265 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 266 | QCopListTransferItem::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 | /*********************************************************************************/ |
273 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | 274 | bool 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 | /*********************************************************************************/ |
306 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 307 | bool 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 | ||
354 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 355 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
355 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 356 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
356 | 357 | ||
357 | ExternalAppHandler::ExternalAppHandler() | 358 | ExternalAppHandler::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 | ||
381 | ExternalAppHandler::~ExternalAppHandler() | 382 | ExternalAppHandler::~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 | ||
389 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | 390 | void 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 | ||
402 | void ExternalAppHandler::loadConfig() | 403 | void 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 | ||
417 | //if qtopiapath is not set, fallback to qt | 418 | //if qtopiapath is not set, fallback to qt |
418 | if (qtopiapath.isEmpty()) | 419 | if (qtopiapath.isEmpty()) |
419 | qtopiapath = qtpath; | 420 | qtopiapath = qtpath; |
420 | 421 | ||
421 | //if opiepath is not set, fallback to qtopia | 422 | //if opiepath is not set, fallback to qtopia |
422 | if (opiepath.isEmpty()) | 423 | if (opiepath.isEmpty()) |
423 | opiepath = qtopiapath; | 424 | opiepath = qtopiapath; |
424 | 425 | ||
425 | 426 | ||
426 | 427 | ||
427 | //mailclients | 428 | //mailclients |
428 | QString mailmsg1 = "writeMail(QString,QString)"; | 429 | QString mailmsg1 = "writeMail(QString,QString)"; |
429 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 430 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
430 | 431 | ||
431 | QString undefined = ""; | 432 | QString undefined = ""; |
432 | 433 | ||
433 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 434 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
434 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 435 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
435 | 436 | ||
436 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 437 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
437 | ( QFile::exists( opiepath + "/bin/ompi" )) || | 438 | ( QFile::exists( opiepath + "/bin/ompi" )) || |
438 | ( QFile::exists( qtpath + "/bin/ompi" ))) | 439 | ( QFile::exists( qtpath + "/bin/ompi" ))) |
439 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 440 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
440 | 441 | ||
441 | if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || | 442 | if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || |
442 | ( QFile::exists( qtpath + "/bin/qtmail" ))) | 443 | ( QFile::exists( qtpath + "/bin/qtmail" ))) |
443 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 444 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
444 | 445 | ||
445 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 446 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
446 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 447 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
447 | 448 | ||
448 | if ( QFile::exists( opiepath + "/bin/mailit" )) | 449 | if ( QFile::exists( opiepath + "/bin/mailit" )) |
449 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 450 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
450 | 451 | ||
451 | 452 | ||
452 | 453 | ||
453 | //phoneclients | 454 | //phoneclients |
454 | 455 | ||
455 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 456 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
456 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 457 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
457 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 458 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
458 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 459 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
459 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 460 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
460 | 461 | ||
461 | //faxclients | 462 | //faxclients |
462 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 463 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
463 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 464 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
464 | 465 | ||
465 | //smsclients | 466 | //smsclients |
466 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 467 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
467 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 468 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
468 | 469 | ||
469 | //pagerclients | 470 | //pagerclients |
470 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 471 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
471 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 472 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
472 | 473 | ||
473 | //sipclients | 474 | //sipclients |
474 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); | 475 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); |
475 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); | 476 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); |
476 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 477 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
477 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 478 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
478 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 479 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
479 | 480 | ||
480 | } | 481 | } |
481 | 482 | ||
482 | ExternalAppHandler *ExternalAppHandler::instance() | 483 | ExternalAppHandler *ExternalAppHandler::instance() |
483 | { | 484 | { |
484 | if ( !sInstance ) { | 485 | if ( !sInstance ) { |
485 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 486 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
486 | sInstance->loadConfig(); | 487 | sInstance->loadConfig(); |
487 | } | 488 | } |
488 | 489 | ||
489 | return sInstance; | 490 | return sInstance; |
490 | } | 491 | } |
491 | 492 | ||
492 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) | 493 | void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2) |
493 | { | 494 | { |
494 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 495 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
495 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 496 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
496 | mDefaultItems.append(dai); | 497 | mDefaultItems.append(dai); |
497 | } | 498 | } |
498 | 499 | ||
499 | 500 | ||
500 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 501 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
501 | { | 502 | { |
502 | QList<DefaultAppItem> list; | 503 | QList<DefaultAppItem> list; |
503 | 504 | ||
504 | DefaultAppItem* dai; | 505 | DefaultAppItem* dai; |
505 | 506 | ||
506 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 507 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
507 | { | 508 | { |
508 | if (dai->_type == type) | 509 | if (dai->_type == type) |
509 | list.append(dai); | 510 | list.append(dai); |
510 | } | 511 | } |
511 | 512 | ||
512 | return list; | 513 | return list; |
513 | } | 514 | } |
514 | 515 | ||
515 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 516 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
516 | { | 517 | { |
517 | DefaultAppItem* dai; | 518 | DefaultAppItem* dai; |
518 | 519 | ||
519 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 520 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
520 | { | 521 | { |
521 | if (dai->_type == type && dai->_id == clientid) | 522 | if (dai->_type == type && dai->_id == clientid) |
522 | return dai; | 523 | return dai; |
523 | } | 524 | } |
524 | 525 | ||
525 | return 0; | 526 | return 0; |
526 | } | 527 | } |
527 | 528 | ||
528 | bool ExternalAppHandler::isEmailAppAvailable() | 529 | bool ExternalAppHandler::isEmailAppAvailable() |
529 | { | 530 | { |
530 | #ifndef DESKTOP_VERSION | 531 | #ifndef DESKTOP_VERSION |
531 | if (mEmailAppAvailable == UNDEFINED) | 532 | if (mEmailAppAvailable == UNDEFINED) |
532 | { | 533 | { |
533 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 534 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
534 | if (client == KPimGlobalPrefs::NONE_EMC) | 535 | if (client == KPimGlobalPrefs::NONE_EMC) |
535 | mEmailAppAvailable = UNAVAILABLE; | 536 | mEmailAppAvailable = UNAVAILABLE; |
536 | else | 537 | else |
537 | mEmailAppAvailable = AVAILABLE; | 538 | mEmailAppAvailable = AVAILABLE; |
538 | } | 539 | } |
539 | return (mEmailAppAvailable == AVAILABLE); | 540 | return (mEmailAppAvailable == AVAILABLE); |
540 | 541 | ||
541 | #else //DESKTOP_VERSION | 542 | #else //DESKTOP_VERSION |
542 | return false; | 543 | return false; |
543 | #endif //DESKTOP_VERSION | 544 | #endif //DESKTOP_VERSION |
544 | } | 545 | } |
545 | 546 | ||
546 | bool ExternalAppHandler::isSMSAppAvailable() | 547 | bool ExternalAppHandler::isSMSAppAvailable() |
547 | { | 548 | { |
548 | #ifndef DESKTOP_VERSION | 549 | #ifndef DESKTOP_VERSION |
549 | if (mSMSAppAvailable == UNDEFINED) | 550 | if (mSMSAppAvailable == UNDEFINED) |
550 | { | 551 | { |
551 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 552 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
552 | if (client == KPimGlobalPrefs::NONE_SMC) | 553 | if (client == KPimGlobalPrefs::NONE_SMC) |
553 | mSMSAppAvailable = UNAVAILABLE; | 554 | mSMSAppAvailable = UNAVAILABLE; |
554 | else | 555 | else |
555 | mSMSAppAvailable = AVAILABLE; | 556 | mSMSAppAvailable = AVAILABLE; |
556 | } | 557 | } |
557 | 558 | ||
558 | return (mSMSAppAvailable == AVAILABLE); | 559 | return (mSMSAppAvailable == AVAILABLE); |
559 | #else //DESKTOP_VERSION | 560 | #else //DESKTOP_VERSION |
560 | return false; | 561 | return false; |
561 | #endif //DESKTOP_VERSION | 562 | #endif //DESKTOP_VERSION |
562 | } | 563 | } |
563 | 564 | ||
564 | bool ExternalAppHandler::isPhoneAppAvailable() | 565 | bool ExternalAppHandler::isPhoneAppAvailable() |
565 | { | 566 | { |
566 | #ifndef DESKTOP_VERSION | 567 | #ifndef DESKTOP_VERSION |
567 | if (mPhoneAppAvailable == UNDEFINED) | 568 | if (mPhoneAppAvailable == UNDEFINED) |
568 | { | 569 | { |
569 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 570 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
570 | if (client == KPimGlobalPrefs::NONE_PHC) | 571 | if (client == KPimGlobalPrefs::NONE_PHC) |
571 | mPhoneAppAvailable = UNAVAILABLE; | 572 | mPhoneAppAvailable = UNAVAILABLE; |
572 | else | 573 | else |
573 | mPhoneAppAvailable = AVAILABLE; | 574 | mPhoneAppAvailable = AVAILABLE; |
574 | } | 575 | } |
575 | 576 | ||
576 | return (mPhoneAppAvailable == AVAILABLE); | 577 | return (mPhoneAppAvailable == AVAILABLE); |
577 | #else //DESKTOP_VERSION | 578 | #else //DESKTOP_VERSION |
578 | return false; | 579 | return false; |
579 | #endif //DESKTOP_VERSION | 580 | #endif //DESKTOP_VERSION |
580 | } | 581 | } |
581 | 582 | ||
582 | bool ExternalAppHandler::isFaxAppAvailable() | 583 | bool ExternalAppHandler::isFaxAppAvailable() |
583 | { | 584 | { |
584 | #ifndef DESKTOP_VERSION | 585 | #ifndef DESKTOP_VERSION |
585 | if (mFaxAppAvailable == UNDEFINED) | 586 | if (mFaxAppAvailable == UNDEFINED) |
586 | { | 587 | { |
587 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 588 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
588 | if (client == KPimGlobalPrefs::NONE_FAC) | 589 | if (client == KPimGlobalPrefs::NONE_FAC) |
589 | mFaxAppAvailable = UNAVAILABLE; | 590 | mFaxAppAvailable = UNAVAILABLE; |
590 | else | 591 | else |
591 | mFaxAppAvailable = AVAILABLE; | 592 | mFaxAppAvailable = AVAILABLE; |
592 | } | 593 | } |
593 | 594 | ||
594 | return (mFaxAppAvailable == AVAILABLE); | 595 | return (mFaxAppAvailable == AVAILABLE); |
595 | #else //DESKTOP_VERSION | 596 | #else //DESKTOP_VERSION |
596 | return false; | 597 | return false; |
597 | #endif //DESKTOP_VERSION | 598 | #endif //DESKTOP_VERSION |
598 | } | 599 | } |
599 | 600 | ||
600 | bool ExternalAppHandler::isPagerAppAvailable() | 601 | bool ExternalAppHandler::isPagerAppAvailable() |
601 | { | 602 | { |
602 | #ifndef DESKTOP_VERSION | 603 | #ifndef DESKTOP_VERSION |
603 | if (mPagerAppAvailable == UNDEFINED) | 604 | if (mPagerAppAvailable == UNDEFINED) |
604 | { | 605 | { |
605 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 606 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
606 | if (client == KPimGlobalPrefs::NONE_PAC) | 607 | if (client == KPimGlobalPrefs::NONE_PAC) |
607 | mPagerAppAvailable = UNAVAILABLE; | 608 | mPagerAppAvailable = UNAVAILABLE; |
608 | else | 609 | else |
609 | mPagerAppAvailable = AVAILABLE; | 610 | mPagerAppAvailable = AVAILABLE; |
610 | } | 611 | } |
611 | 612 | ||
612 | return (mPagerAppAvailable == AVAILABLE); | 613 | return (mPagerAppAvailable == AVAILABLE); |
613 | #else //DESKTOP_VERSION | 614 | #else //DESKTOP_VERSION |
614 | return false; | 615 | return false; |
615 | #endif //DESKTOP_VERSION | 616 | #endif //DESKTOP_VERSION |
616 | } | 617 | } |
617 | 618 | ||
618 | 619 | ||
619 | bool ExternalAppHandler::isSIPAppAvailable() | 620 | bool ExternalAppHandler::isSIPAppAvailable() |
620 | { | 621 | { |
621 | #ifndef DESKTOP_VERSION | 622 | #ifndef DESKTOP_VERSION |
622 | if (mSIPAppAvailable == UNDEFINED) | 623 | if (mSIPAppAvailable == UNDEFINED) |
623 | { | 624 | { |
624 | int client = KPimGlobalPrefs::instance()->mSipClient; | 625 | int client = KPimGlobalPrefs::instance()->mSipClient; |
625 | if (client == KPimGlobalPrefs::NONE_SIC) | 626 | if (client == KPimGlobalPrefs::NONE_SIC) |
626 | mSIPAppAvailable = UNAVAILABLE; | 627 | mSIPAppAvailable = UNAVAILABLE; |
627 | else | 628 | else |
628 | mSIPAppAvailable = AVAILABLE; | 629 | mSIPAppAvailable = AVAILABLE; |
629 | } | 630 | } |
630 | 631 | ||
631 | return (mSIPAppAvailable == AVAILABLE); | 632 | return (mSIPAppAvailable == AVAILABLE); |
632 | #else //DESKTOP_VERSION | 633 | #else //DESKTOP_VERSION |
633 | return false; | 634 | return false; |
634 | #endif //DESKTOP_VERSION | 635 | #endif //DESKTOP_VERSION |
635 | } | 636 | } |
636 | 637 | ||
637 | /************************************************************************** | 638 | /************************************************************************** |
638 | * | 639 | * |
639 | **************************************************************************/ | 640 | **************************************************************************/ |
640 | 641 | ||
641 | 642 | ||
642 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 643 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
643 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 644 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
644 | { | 645 | { |
645 | 646 | ||
646 | #ifndef DESKTOP_VERSION | 647 | #ifndef DESKTOP_VERSION |
647 | QString channel; | 648 | QString channel; |
648 | QString message2; | 649 | QString message2; |
649 | QString parameters2; | 650 | QString parameters2; |
650 | 651 | ||
651 | 652 | ||
652 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 653 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
653 | if (client == KPimGlobalPrefs::OTHER_EMC) | 654 | if (client == KPimGlobalPrefs::OTHER_EMC) |
654 | { | 655 | { |
655 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 656 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
656 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 657 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
657 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 658 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
658 | } | 659 | } |
659 | else | 660 | else |
660 | { | 661 | { |
661 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 662 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
662 | if (!dai) | 663 | if (!dai) |
663 | { | 664 | { |
664 | qDebug("could not find configured email application."); | 665 | qDebug("could not find configured email application."); |
665 | return false; | 666 | return false; |
666 | } | 667 | } |
667 | channel = dai->_channel; | 668 | channel = dai->_channel; |
668 | message2 = dai->_message2; | 669 | message2 = dai->_message2; |
669 | parameters2 = dai->_parameters2; | 670 | parameters2 = dai->_parameters2; |
670 | } | 671 | } |
671 | 672 | ||
672 | //first check if one of the mailers need the emails right in the message. | 673 | //first check if one of the mailers need the emails right in the message. |
673 | message2 = translateMessage(message2, emails, urls); | 674 | message2 = translateMessage(message2, emails, urls); |
674 | 675 | ||
675 | 676 | ||
676 | #ifdef DEBUG_EXT_APP_HANDLER | 677 | #ifdef DEBUG_EXT_APP_HANDLER |
677 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 678 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
678 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 679 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
679 | #endif | 680 | #endif |
680 | 681 | ||
681 | 682 | ||
682 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 683 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
683 | //US we need no names in the To field. The emailadresses are enough | 684 | //US we need no names in the To field. The emailadresses are enough |
684 | 685 | ||
685 | passParameters(&e, parameters2, emails, urls); | 686 | passParameters(&e, parameters2, emails, urls); |
686 | 687 | ||
687 | 688 | ||
688 | 689 | ||
689 | #else | 690 | #else |
690 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 691 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
691 | #endif | 692 | #endif |
692 | 693 | ||
693 | return true; | 694 | return true; |
694 | } | 695 | } |
695 | 696 | ||
696 | /************************************************************************** | 697 | /************************************************************************** |
697 | * | 698 | * |
698 | **************************************************************************/ | 699 | **************************************************************************/ |
699 | 700 | ||
700 | 701 | ||
701 | //calls the emailapplication and creates a mail with parameter emails as recipients | 702 | //calls the emailapplication and creates a mail with parameter emails as recipients |
702 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 703 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
703 | { | 704 | { |
704 | #ifndef DESKTOP_VERSION | 705 | #ifndef DESKTOP_VERSION |
705 | QString channel; | 706 | QString channel; |
706 | QString message; | 707 | QString message; |
707 | QString parameters; | 708 | QString parameters; |
708 | 709 | ||
709 | 710 | ||
710 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 711 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
711 | if (client == KPimGlobalPrefs::OTHER_EMC) | 712 | if (client == KPimGlobalPrefs::OTHER_EMC) |
712 | { | 713 | { |
713 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 714 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
714 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 715 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
715 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 716 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
716 | } | 717 | } |
717 | else | 718 | else |
718 | { | 719 | { |
719 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 720 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
720 | if (!dai) | 721 | if (!dai) |
721 | { | 722 | { |
722 | qDebug("could not find configured email application."); | 723 | qDebug("could not find configured email application."); |
723 | return false; | 724 | return false; |
724 | } | 725 | } |
725 | channel = dai->_channel; | 726 | channel = dai->_channel; |
726 | message = dai->_message; | 727 | message = dai->_message; |
727 | parameters = dai->_parameters; | 728 | parameters = dai->_parameters; |
728 | } | 729 | } |
729 | 730 | ||
730 | 731 | ||
731 | //first check if one of the mailers need the emails right in the message. | 732 | //first check if one of the mailers need the emails right in the message. |
732 | message = translateMessage(message, name, emailadress); | 733 | message = translateMessage(message, name, emailadress); |
733 | 734 | ||
734 | 735 | ||
735 | #ifdef DEBUG_EXT_APP_HANDLER | 736 | #ifdef DEBUG_EXT_APP_HANDLER |
736 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 737 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
737 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 738 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
738 | #endif | 739 | #endif |
739 | 740 | ||
740 | QCopEnvelope e(channel.latin1(), message.latin1()); | 741 | QCopEnvelope e(channel.latin1(), message.latin1()); |
741 | //US we need no names in the To field. The emailadresses are enough | 742 | //US we need no names in the To field. The emailadresses are enough |
742 | 743 | ||
743 | passParameters(&e, parameters, name, emailadress); | 744 | passParameters(&e, parameters, name, emailadress); |
744 | 745 | ||
745 | 746 | ||
746 | #else | 747 | #else |
747 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 748 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
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 |
761 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 762 | bool 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 |
781 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 782 | bool 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 |
838 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 839 | bool 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 |
895 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 896 | bool 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 |
952 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 953 | bool 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 |
1009 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | 1010 | bool 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 | ||
1067 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1068 | QString& 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 | ||
1077 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1078 | void 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 | ||
1130 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1131 | void 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 | ||
1157 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1163 | bool 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 | ||
1168 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1174 | bool 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 | ||
1176 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1182 | bool 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 | ||
1182 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1188 | bool 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 | ||
1190 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1196 | bool 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 | ||
1196 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1202 | bool 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 | ||
1202 | bool 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) | 1208 | bool 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 | ||