-rw-r--r-- | libkdepim/externalapphandler.cpp | 111 |
1 files changed, 97 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 2ce6926..edefda4 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,1217 +1,1300 @@ | |||
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 <qtimer.h> |
34 | #include <qmap.h> | 34 | #include <qmap.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | 36 | ||
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include <qtopia/qcopenvelope_qws.h> | 39 | #include <qtopia/qcopenvelope_qws.h> |
40 | #else | 40 | #else |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #include <qprocess.h> | ||
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | #include <kstaticdeleter.h> | 45 | #include <kstaticdeleter.h> |
45 | #include <kmessagebox.h> | 46 | #include <kmessagebox.h> |
46 | 47 | ||
47 | 48 | ||
48 | #include "externalapphandler.h" | 49 | #include "externalapphandler.h" |
49 | 50 | ||
50 | #include "kpimglobalprefs.h" | 51 | #include "kpimglobalprefs.h" |
51 | 52 | ||
52 | //uncomment line to get debug output | 53 | //uncomment line to get debug output |
53 | //#define DEBUG_EXT_APP_HANDLER | 54 | //#define DEBUG_EXT_APP_HANDLER |
54 | 55 | ||
55 | /********************************************************************************* | 56 | /********************************************************************************* |
56 | * | 57 | * |
57 | ********************************************************************************/ | 58 | ********************************************************************************/ |
58 | 59 | ||
59 | 60 | ||
60 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 61 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
61 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) | 62 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) |
62 | { | 63 | { |
63 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 | 64 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 |
64 | if (_usedSourceParameters == 0) | 65 | if (_usedSourceParameters == 0) |
65 | _sourceMessageParameters = "QString,QString)"; | 66 | _sourceMessageParameters = "QString,QString)"; |
66 | else if (_usedSourceParameters == 1) | 67 | else if (_usedSourceParameters == 1) |
67 | _sourceMessageParameters = "(QString,QString,QString)"; | 68 | _sourceMessageParameters = "(QString,QString,QString)"; |
68 | else if (_usedSourceParameters == 2) | 69 | else if (_usedSourceParameters == 2) |
69 | _sourceMessageParameters = "(QString,QString,QString,QString)"; | 70 | _sourceMessageParameters = "(QString,QString,QString,QString)"; |
70 | else if (_usedSourceParameters == 3) | 71 | else if (_usedSourceParameters == 3) |
71 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; | 72 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; |
72 | } | 73 | } |
73 | 74 | ||
74 | /*********************************************************************************/ | 75 | /*********************************************************************************/ |
75 | 76 | ||
76 | QCopTransferItem::QCopTransferItem() | 77 | QCopTransferItem::QCopTransferItem() |
77 | { | 78 | { |
78 | } | 79 | } |
79 | 80 | ||
80 | /*********************************************************************************/ | 81 | /*********************************************************************************/ |
81 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) | 82 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) |
82 | { | 83 | { |
83 | 84 | ||
84 | #ifndef DESKTOP_VERSION | 85 | #ifndef DESKTOP_VERSION |
85 | //sourceMessage passes two parameters: sourceChannel, uid | 86 | //sourceMessage passes two parameters: sourceChannel, uid |
86 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; | 87 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; |
87 | #ifdef DEBUG_EXT_APP_HANDLER | 88 | #ifdef DEBUG_EXT_APP_HANDLER |
88 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); | 89 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.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()); | 90 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); |
90 | #endif | 91 | #endif |
91 | 92 | ||
92 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); | 93 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); |
93 | 94 | ||
94 | e << _sourceChannel << uid; | 95 | e << _sourceChannel << uid; |
95 | 96 | ||
96 | if (_usedSourceParameters == 1) | 97 | if (_usedSourceParameters == 1) |
97 | e << param1; | 98 | e << param1; |
98 | else if (_usedSourceParameters == 2) | 99 | else if (_usedSourceParameters == 2) |
99 | e << param1 << param2; | 100 | e << param1 << param2; |
100 | else if (_usedSourceParameters == 3) | 101 | else if (_usedSourceParameters == 3) |
101 | e << param1 << param2 << param3; | 102 | e << param1 << param2 << param3; |
102 | 103 | ||
103 | qApp->processEvents(); | 104 | qApp->processEvents(); |
104 | 105 | ||
105 | return true; | 106 | return true; |
106 | 107 | ||
107 | #else | 108 | #else |
108 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 109 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
109 | return false; | 110 | return false; |
110 | #endif | 111 | #endif |
111 | 112 | ||
112 | } | 113 | } |
113 | 114 | ||
114 | 115 | ||
115 | /*********************************************************************************/ | 116 | /*********************************************************************************/ |
116 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | 117 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) |
117 | { | 118 | { |
118 | 119 | ||
119 | if ( !sourceChannel.isEmpty()) | 120 | if ( !sourceChannel.isEmpty()) |
120 | _sourceChannel = sourceChannel; | 121 | _sourceChannel = sourceChannel; |
121 | } | 122 | } |
122 | 123 | ||
123 | 124 | ||
124 | /*********************************************************************************/ | 125 | /*********************************************************************************/ |
125 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 126 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
126 | { | 127 | { |
127 | 128 | ||
128 | // copied from old mail2 | 129 | // copied from old mail2 |
129 | /* | 130 | /* |
130 | static int ii = 0; | 131 | static int ii = 0; |
131 | 132 | ||
132 | // block second call | 133 | // block second call |
133 | if ( ii < 2 ) { | 134 | if ( ii < 2 ) { |
134 | ++ii; | 135 | ++ii; |
135 | if ( ii > 1 ) { | 136 | if ( ii > 1 ) { |
136 | qDebug("qcop call blocked "); | 137 | qDebug("qcop call blocked "); |
137 | return true; | 138 | return true; |
138 | } | 139 | } |
139 | } | 140 | } |
140 | */ | 141 | */ |
141 | 142 | ||
142 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); | 143 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); |
143 | 144 | ||
144 | //we are in the target and get a request from the source | 145 | //we are in the target and get a request from the source |
145 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) | 146 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) |
146 | { | 147 | { |
147 | 148 | ||
148 | QDataStream stream( data, IO_ReadOnly ); | 149 | QDataStream stream( data, IO_ReadOnly ); |
149 | 150 | ||
150 | 151 | ||
151 | QString sourceChannel; | 152 | QString sourceChannel; |
152 | QString uid; | 153 | QString uid; |
153 | QString param1; | 154 | QString param1; |
154 | QString param2; | 155 | QString param2; |
155 | QString param3; | 156 | QString param3; |
156 | 157 | ||
157 | stream >> sourceChannel >> uid; | 158 | stream >> sourceChannel >> uid; |
158 | 159 | ||
159 | if (_usedSourceParameters == 0) | 160 | if (_usedSourceParameters == 0) |
160 | { | 161 | { |
161 | emit receivedMessageFromSource(sourceChannel, uid); | 162 | emit receivedMessageFromSource(sourceChannel, uid); |
162 | } | 163 | } |
163 | else if (_usedSourceParameters == 1) | 164 | else if (_usedSourceParameters == 1) |
164 | { | 165 | { |
165 | stream >> param1; | 166 | stream >> param1; |
166 | emit receivedMessageFromSource(sourceChannel, uid, param1); | 167 | emit receivedMessageFromSource(sourceChannel, uid, param1); |
167 | } | 168 | } |
168 | else if (_usedSourceParameters == 2) | 169 | else if (_usedSourceParameters == 2) |
169 | { | 170 | { |
170 | stream >> param1 >> param2; | 171 | stream >> param1 >> param2; |
171 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); | 172 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); |
172 | } | 173 | } |
173 | else if (_usedSourceParameters == 3) | 174 | else if (_usedSourceParameters == 3) |
174 | { | 175 | { |
175 | stream >> param1 >> param2 >> param3; | 176 | stream >> param1 >> param2 >> param3; |
176 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); | 177 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); |
177 | } | 178 | } |
178 | 179 | ||
179 | return true; | 180 | return true; |
180 | } | 181 | } |
181 | 182 | ||
182 | return false; | 183 | return false; |
183 | } | 184 | } |
184 | 185 | ||
185 | 186 | ||
186 | /********************************************************************************* | 187 | /********************************************************************************* |
187 | * | 188 | * |
188 | ********************************************************************************/ | 189 | ********************************************************************************/ |
189 | 190 | ||
190 | 191 | ||
191 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 192 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
192 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 193 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
193 | { | 194 | { |
194 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | 195 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> |
195 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | 196 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; |
196 | } | 197 | } |
197 | 198 | ||
198 | /*********************************************************************************/ | 199 | /*********************************************************************************/ |
199 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 200 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) |
200 | { | 201 | { |
201 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
202 | //targetMessage passes two parameters: uid, map | 203 | //targetMessage passes two parameters: uid, map |
203 | QString targetMessage = _targetMessage + _targetMessageParameters; | 204 | QString targetMessage = _targetMessage + _targetMessageParameters; |
204 | 205 | ||
205 | #ifdef DEBUG_EXT_APP_HANDLER | 206 | #ifdef DEBUG_EXT_APP_HANDLER |
206 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 207 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
207 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | 208 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); |
208 | #endif | 209 | #endif |
209 | 210 | ||
210 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 211 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
211 | //US we need no names in the To field. The emailadresses are enough | 212 | //US we need no names in the To field. The emailadresses are enough |
212 | 213 | ||
213 | e << uid << nameEmailMap; | 214 | e << uid << nameEmailMap; |
214 | 215 | ||
215 | qApp->processEvents(); | 216 | qApp->processEvents(); |
216 | 217 | ||
217 | return true; | 218 | return true; |
218 | 219 | ||
219 | #else | 220 | #else |
220 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 221 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
221 | return false; | 222 | return false; |
222 | #endif | 223 | #endif |
223 | 224 | ||
224 | } | 225 | } |
225 | 226 | ||
226 | 227 | ||
227 | /*********************************************************************************/ | 228 | /*********************************************************************************/ |
228 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 229 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
229 | { | 230 | { |
230 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 231 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
231 | 232 | ||
232 | if (res == false) | 233 | if (res == false) |
233 | { | 234 | { |
234 | QDataStream stream( data, IO_ReadOnly ); | 235 | QDataStream stream( data, IO_ReadOnly ); |
235 | 236 | ||
236 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | 237 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); |
237 | 238 | ||
238 | //we are in the source and get an answer from the target | 239 | //we are in the source and get an answer from the target |
239 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 240 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
240 | { | 241 | { |
241 | QMap<QString,QString> adrMap; | 242 | QMap<QString,QString> adrMap; |
242 | QString uid; | 243 | QString uid; |
243 | 244 | ||
244 | stream >> uid >> adrMap; | 245 | stream >> uid >> adrMap; |
245 | 246 | ||
246 | emit receivedMessageFromTarget(uid, adrMap); | 247 | emit receivedMessageFromTarget(uid, adrMap); |
247 | 248 | ||
248 | 249 | ||
249 | return true; | 250 | return true; |
250 | } | 251 | } |
251 | } | 252 | } |
252 | 253 | ||
253 | return false; | 254 | return false; |
254 | } | 255 | } |
255 | 256 | ||
256 | 257 | ||
257 | /********************************************************************************* | 258 | /********************************************************************************* |
258 | * | 259 | * |
259 | ********************************************************************************/ | 260 | ********************************************************************************/ |
260 | 261 | ||
261 | QCopListTransferItem::~QCopListTransferItem() | 262 | QCopListTransferItem::~QCopListTransferItem() |
262 | { | 263 | { |
263 | 264 | ||
264 | } | 265 | } |
265 | 266 | ||
266 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 267 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
267 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 268 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
268 | { | 269 | { |
269 | //targetMessage returns later two parameters: uid, and three lists | 270 | //targetMessage returns later two parameters: uid, and three lists |
270 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; | 271 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; |
271 | } | 272 | } |
272 | 273 | ||
273 | /*********************************************************************************/ | 274 | /*********************************************************************************/ |
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) | 275 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
275 | { | 276 | { |
276 | #ifndef DESKTOP_VERSION | 277 | #ifndef DESKTOP_VERSION |
277 | //targetMessage passes two parameters: uid, map | 278 | //targetMessage passes two parameters: uid, map |
278 | QString targetMessage = _targetMessage + _targetMessageParameters; | 279 | QString targetMessage = _targetMessage + _targetMessageParameters; |
279 | 280 | ||
280 | #ifdef DEBUG_EXT_APP_HANDLER | 281 | #ifdef DEBUG_EXT_APP_HANDLER |
281 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 282 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
282 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); | 283 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); |
283 | 284 | ||
284 | 285 | ||
285 | for ( int i = 0; i < list3.count(); i++) | 286 | for ( int i = 0; i < list3.count(); i++) |
286 | qDebug("listentry list3: %s",list3[i].latin1()); | 287 | qDebug("listentry list3: %s",list3[i].latin1()); |
287 | #endif | 288 | #endif |
288 | 289 | ||
289 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 290 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
290 | //US we need no names in the To field. The emailadresses are enough | 291 | //US we need no names in the To field. The emailadresses are enough |
291 | 292 | ||
292 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; | 293 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; |
293 | 294 | ||
294 | qApp->processEvents(); | 295 | qApp->processEvents(); |
295 | 296 | ||
296 | return true; | 297 | return true; |
297 | 298 | ||
298 | #else | 299 | #else |
299 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 300 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
300 | return false; | 301 | return false; |
301 | #endif | 302 | #endif |
302 | 303 | ||
303 | } | 304 | } |
304 | 305 | ||
305 | 306 | ||
306 | /*********************************************************************************/ | 307 | /*********************************************************************************/ |
307 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 308 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
308 | { | 309 | { |
309 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 310 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
310 | #ifdef DEBUG_EXT_APP_HANDLER | 311 | #ifdef DEBUG_EXT_APP_HANDLER |
311 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 312 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
312 | #endif | 313 | #endif |
313 | 314 | ||
314 | if (res == false) | 315 | if (res == false) |
315 | { | 316 | { |
316 | QDataStream stream( data, IO_ReadOnly ); | 317 | QDataStream stream( data, IO_ReadOnly ); |
317 | 318 | ||
318 | #ifdef DEBUG_EXT_APP_HANDLER | 319 | #ifdef DEBUG_EXT_APP_HANDLER |
319 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 320 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
320 | #endif | 321 | #endif |
321 | 322 | ||
322 | //we are in the source and get an answer from the target | 323 | //we are in the source and get an answer from the target |
323 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 324 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
324 | { | 325 | { |
325 | QStringList list1; | 326 | QStringList list1; |
326 | QStringList list2; | 327 | QStringList list2; |
327 | QStringList list3; | 328 | QStringList list3; |
328 | QStringList list4; | 329 | QStringList list4; |
329 | QStringList list5; | 330 | QStringList list5; |
330 | QStringList list6; | 331 | QStringList list6; |
331 | QString uid; | 332 | QString uid; |
332 | 333 | ||
333 | #ifdef DEBUG_EXT_APP_HANDLER | 334 | #ifdef DEBUG_EXT_APP_HANDLER |
334 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 335 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
335 | #endif | 336 | #endif |
336 | 337 | ||
337 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; | 338 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; |
338 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); | 339 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); |
339 | 340 | ||
340 | 341 | ||
341 | return true; | 342 | return true; |
342 | } | 343 | } |
343 | } | 344 | } |
344 | 345 | ||
345 | return false; | 346 | return false; |
346 | } | 347 | } |
347 | 348 | ||
348 | 349 | ||
349 | 350 | ||
350 | /********************************************************************************* | 351 | /********************************************************************************* |
351 | * | 352 | * |
352 | ********************************************************************************/ | 353 | ********************************************************************************/ |
353 | 354 | ||
354 | 355 | ||
355 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 356 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
356 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 357 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
357 | 358 | ||
358 | ExternalAppHandler::ExternalAppHandler() | 359 | ExternalAppHandler::ExternalAppHandler() |
359 | { | 360 | { |
360 | mDefaultItems.setAutoDelete(true); | 361 | mDefaultItems.setAutoDelete(true); |
361 | 362 | ||
362 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 363 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
363 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 364 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
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&))); | 365 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
365 | 366 | ||
366 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 367 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
367 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 368 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
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&))); | 369 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
369 | 370 | ||
370 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 371 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
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&))); | 372 | connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); |
372 | 373 | ||
373 | 374 | ||
374 | 375 | ||
375 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); | 376 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); |
376 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); | 377 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); |
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&))); | 378 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
378 | 379 | ||
379 | 380 | ||
380 | } | 381 | } |
381 | 382 | ||
382 | ExternalAppHandler::~ExternalAppHandler() | 383 | ExternalAppHandler::~ExternalAppHandler() |
383 | { | 384 | { |
384 | delete mNameEmailUidListFromKAPITransfer; | 385 | delete mNameEmailUidListFromKAPITransfer; |
385 | //delete mFindByEmailFromKAPITransfer; | 386 | //delete mFindByEmailFromKAPITransfer; |
386 | delete mDisplayDetails; | 387 | delete mDisplayDetails; |
387 | delete mBirthdayListFromKAPITransfer; | 388 | delete mBirthdayListFromKAPITransfer; |
388 | } | 389 | } |
389 | 390 | ||
390 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | 391 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, |
391 | const QStringList& nameList, | 392 | const QStringList& nameList, |
392 | const QStringList& emailList, | 393 | const QStringList& emailList, |
393 | const QStringList& uidList, | 394 | const QStringList& uidList, |
394 | const QStringList&, | 395 | const QStringList&, |
395 | const QStringList&, | 396 | const QStringList&, |
396 | const QStringList& ) | 397 | const QStringList& ) |
397 | { | 398 | { |
398 | // this method is a conevnient way to reduce the number of parameters I have to pass | 399 | // this method is a conevnient way to reduce the number of parameters I have to pass |
399 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); | 400 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); |
400 | } | 401 | } |
401 | 402 | ||
402 | 403 | ||
403 | void ExternalAppHandler::loadConfig() | 404 | void ExternalAppHandler::loadConfig() |
404 | { | 405 | { |
405 | 406 | ||
406 | mDefaultItems.clear(); | 407 | mDefaultItems.clear(); |
407 | mEmailAppAvailable = UNDEFINED; | 408 | mEmailAppAvailable = UNDEFINED; |
408 | mPhoneAppAvailable = UNDEFINED; | 409 | mPhoneAppAvailable = UNDEFINED; |
409 | mFaxAppAvailable = UNDEFINED; | 410 | mFaxAppAvailable = UNDEFINED; |
410 | mSMSAppAvailable = UNDEFINED; | 411 | mSMSAppAvailable = UNDEFINED; |
411 | mPagerAppAvailable = UNDEFINED; | 412 | mPagerAppAvailable = UNDEFINED; |
412 | mSIPAppAvailable = UNDEFINED; | 413 | mSIPAppAvailable = UNDEFINED; |
413 | 414 | ||
414 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 415 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
415 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 416 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
416 | QString qtpath = QString::fromLatin1( getenv("QTDIR") ); | 417 | QString qtpath = QString::fromLatin1( getenv("QTDIR") ); |
417 | 418 | ||
418 | //if qtopiapath is not set, fallback to qt | 419 | //if qtopiapath is not set, fallback to qt |
419 | if (qtopiapath.isEmpty()) | 420 | if (qtopiapath.isEmpty()) |
420 | qtopiapath = qtpath; | 421 | qtopiapath = qtpath; |
421 | 422 | ||
422 | //if opiepath is not set, fallback to qtopia | 423 | //if opiepath is not set, fallback to qtopia |
423 | if (opiepath.isEmpty()) | 424 | if (opiepath.isEmpty()) |
424 | opiepath = qtopiapath; | 425 | opiepath = qtopiapath; |
425 | 426 | ||
426 | 427 | ||
427 | 428 | ||
428 | //mailclients | 429 | //mailclients |
429 | QString mailmsg1 = "writeMail(QString,QString)"; | 430 | QString mailmsg1 = "writeMail(QString,QString)"; |
430 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 431 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
431 | 432 | ||
432 | QString undefined = ""; | 433 | QString undefined = ""; |
433 | 434 | ||
434 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 435 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
435 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 436 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
436 | 437 | ||
438 | #ifdef DESKTOP_VERSION | ||
439 | QString appPath; | ||
440 | #ifdef _WIN32_ | ||
441 | appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe"; | ||
442 | #else | ||
443 | appPath = "/usr/bin/thunderbird"; | ||
444 | #endif | ||
445 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1"); | ||
446 | |||
447 | #ifdef _WIN32_ | ||
448 | appPath = "C:\\Programme\\Mozilla\\mozilla.exe"; | ||
449 | #else | ||
450 | appPath = "/usr/bin/mozilla"; | ||
451 | #endif | ||
452 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1"); | ||
453 | |||
454 | |||
455 | |||
456 | #else | ||
437 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 457 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
438 | ( QFile::exists( opiepath + "/bin/ompi" )) || | 458 | ( QFile::exists( opiepath + "/bin/ompi" )) || |
439 | ( QFile::exists( qtpath + "/bin/ompi" ))) | 459 | ( QFile::exists( qtpath + "/bin/ompi" ))) |
440 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 460 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
441 | 461 | ||
442 | if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || | 462 | if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || |
443 | ( QFile::exists( qtpath + "/bin/qtmail" ))) | 463 | ( QFile::exists( qtpath + "/bin/qtmail" ))) |
444 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 464 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
445 | 465 | ||
446 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 466 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
447 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 467 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
448 | 468 | ||
449 | if ( QFile::exists( opiepath + "/bin/mailit" )) | 469 | if ( QFile::exists( opiepath + "/bin/mailit" )) |
450 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 470 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
451 | 471 | #endif | |
452 | 472 | ||
453 | 473 | ||
454 | //phoneclients | 474 | //phoneclients |
455 | 475 | ||
456 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 476 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
457 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 477 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
458 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 478 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
459 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 479 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
460 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 480 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
461 | 481 | ||
462 | //faxclients | 482 | //faxclients |
463 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 483 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
464 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 484 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
465 | 485 | ||
466 | //smsclients | 486 | //smsclients |
467 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 487 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
468 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 488 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
469 | 489 | ||
470 | //pagerclients | 490 | //pagerclients |
471 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 491 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
472 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 492 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
473 | 493 | ||
474 | //sipclients | 494 | //sipclients |
475 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); | 495 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); |
476 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); | 496 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); |
477 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 497 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
478 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 498 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
479 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 499 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
480 | 500 | ||
481 | } | 501 | } |
482 | 502 | ||
483 | ExternalAppHandler *ExternalAppHandler::instance() | 503 | ExternalAppHandler *ExternalAppHandler::instance() |
484 | { | 504 | { |
485 | if ( !sInstance ) { | 505 | if ( !sInstance ) { |
486 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 506 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
487 | sInstance->loadConfig(); | 507 | sInstance->loadConfig(); |
488 | } | 508 | } |
489 | 509 | ||
490 | return sInstance; | 510 | return sInstance; |
491 | } | 511 | } |
492 | 512 | ||
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) | 513 | 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) |
494 | { | 514 | { |
495 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 515 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
496 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 516 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
497 | mDefaultItems.append(dai); | 517 | mDefaultItems.append(dai); |
498 | } | 518 | } |
499 | 519 | ||
500 | 520 | ||
501 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 521 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
502 | { | 522 | { |
503 | QList<DefaultAppItem> list; | 523 | QList<DefaultAppItem> list; |
504 | 524 | ||
505 | DefaultAppItem* dai; | 525 | DefaultAppItem* dai; |
506 | 526 | ||
507 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 527 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
508 | { | 528 | { |
509 | if (dai->_type == type) | 529 | if (dai->_type == type) |
510 | list.append(dai); | 530 | list.append(dai); |
511 | } | 531 | } |
512 | 532 | ||
513 | return list; | 533 | return list; |
514 | } | 534 | } |
515 | 535 | ||
516 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 536 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
517 | { | 537 | { |
518 | DefaultAppItem* dai; | 538 | DefaultAppItem* dai; |
519 | 539 | ||
520 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 540 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
521 | { | 541 | { |
522 | if (dai->_type == type && dai->_id == clientid) | 542 | if (dai->_type == type && dai->_id == clientid) |
523 | return dai; | 543 | return dai; |
524 | } | 544 | } |
525 | 545 | ||
526 | return 0; | 546 | return 0; |
527 | } | 547 | } |
528 | 548 | ||
529 | bool ExternalAppHandler::isEmailAppAvailable() | 549 | bool ExternalAppHandler::isEmailAppAvailable() |
530 | { | 550 | { |
531 | #ifndef DESKTOP_VERSION | 551 | |
532 | if (mEmailAppAvailable == UNDEFINED) | 552 | if (mEmailAppAvailable == UNDEFINED) |
533 | { | 553 | { |
534 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 554 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
535 | if (client == KPimGlobalPrefs::NONE_EMC) | 555 | if (client == KPimGlobalPrefs::NONE_EMC) |
536 | mEmailAppAvailable = UNAVAILABLE; | 556 | mEmailAppAvailable = UNAVAILABLE; |
537 | else | 557 | else |
538 | mEmailAppAvailable = AVAILABLE; | 558 | mEmailAppAvailable = AVAILABLE; |
539 | } | 559 | } |
540 | return (mEmailAppAvailable == AVAILABLE); | 560 | return (mEmailAppAvailable == AVAILABLE); |
541 | 561 | ||
542 | #else //DESKTOP_VERSION | ||
543 | return false; | ||
544 | #endif //DESKTOP_VERSION | ||
545 | } | 562 | } |
546 | 563 | ||
547 | bool ExternalAppHandler::isSMSAppAvailable() | 564 | bool ExternalAppHandler::isSMSAppAvailable() |
548 | { | 565 | { |
549 | #ifndef DESKTOP_VERSION | 566 | #ifndef DESKTOP_VERSION |
550 | if (mSMSAppAvailable == UNDEFINED) | 567 | if (mSMSAppAvailable == UNDEFINED) |
551 | { | 568 | { |
552 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 569 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
553 | if (client == KPimGlobalPrefs::NONE_SMC) | 570 | if (client == KPimGlobalPrefs::NONE_SMC) |
554 | mSMSAppAvailable = UNAVAILABLE; | 571 | mSMSAppAvailable = UNAVAILABLE; |
555 | else | 572 | else |
556 | mSMSAppAvailable = AVAILABLE; | 573 | mSMSAppAvailable = AVAILABLE; |
557 | } | 574 | } |
558 | 575 | ||
559 | return (mSMSAppAvailable == AVAILABLE); | 576 | return (mSMSAppAvailable == AVAILABLE); |
560 | #else //DESKTOP_VERSION | 577 | #else //DESKTOP_VERSION |
561 | return false; | 578 | return false; |
562 | #endif //DESKTOP_VERSION | 579 | #endif //DESKTOP_VERSION |
563 | } | 580 | } |
564 | 581 | ||
565 | bool ExternalAppHandler::isPhoneAppAvailable() | 582 | bool ExternalAppHandler::isPhoneAppAvailable() |
566 | { | 583 | { |
567 | #ifndef DESKTOP_VERSION | 584 | #ifndef DESKTOP_VERSION |
568 | if (mPhoneAppAvailable == UNDEFINED) | 585 | if (mPhoneAppAvailable == UNDEFINED) |
569 | { | 586 | { |
570 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 587 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
571 | if (client == KPimGlobalPrefs::NONE_PHC) | 588 | if (client == KPimGlobalPrefs::NONE_PHC) |
572 | mPhoneAppAvailable = UNAVAILABLE; | 589 | mPhoneAppAvailable = UNAVAILABLE; |
573 | else | 590 | else |
574 | mPhoneAppAvailable = AVAILABLE; | 591 | mPhoneAppAvailable = AVAILABLE; |
575 | } | 592 | } |
576 | 593 | ||
577 | return (mPhoneAppAvailable == AVAILABLE); | 594 | return (mPhoneAppAvailable == AVAILABLE); |
578 | #else //DESKTOP_VERSION | 595 | #else //DESKTOP_VERSION |
579 | return false; | 596 | return false; |
580 | #endif //DESKTOP_VERSION | 597 | #endif //DESKTOP_VERSION |
581 | } | 598 | } |
582 | 599 | ||
583 | bool ExternalAppHandler::isFaxAppAvailable() | 600 | bool ExternalAppHandler::isFaxAppAvailable() |
584 | { | 601 | { |
585 | #ifndef DESKTOP_VERSION | 602 | #ifndef DESKTOP_VERSION |
586 | if (mFaxAppAvailable == UNDEFINED) | 603 | if (mFaxAppAvailable == UNDEFINED) |
587 | { | 604 | { |
588 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 605 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
589 | if (client == KPimGlobalPrefs::NONE_FAC) | 606 | if (client == KPimGlobalPrefs::NONE_FAC) |
590 | mFaxAppAvailable = UNAVAILABLE; | 607 | mFaxAppAvailable = UNAVAILABLE; |
591 | else | 608 | else |
592 | mFaxAppAvailable = AVAILABLE; | 609 | mFaxAppAvailable = AVAILABLE; |
593 | } | 610 | } |
594 | 611 | ||
595 | return (mFaxAppAvailable == AVAILABLE); | 612 | return (mFaxAppAvailable == AVAILABLE); |
596 | #else //DESKTOP_VERSION | 613 | #else //DESKTOP_VERSION |
597 | return false; | 614 | return false; |
598 | #endif //DESKTOP_VERSION | 615 | #endif //DESKTOP_VERSION |
599 | } | 616 | } |
600 | 617 | ||
601 | bool ExternalAppHandler::isPagerAppAvailable() | 618 | bool ExternalAppHandler::isPagerAppAvailable() |
602 | { | 619 | { |
603 | #ifndef DESKTOP_VERSION | 620 | #ifndef DESKTOP_VERSION |
604 | if (mPagerAppAvailable == UNDEFINED) | 621 | if (mPagerAppAvailable == UNDEFINED) |
605 | { | 622 | { |
606 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 623 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
607 | if (client == KPimGlobalPrefs::NONE_PAC) | 624 | if (client == KPimGlobalPrefs::NONE_PAC) |
608 | mPagerAppAvailable = UNAVAILABLE; | 625 | mPagerAppAvailable = UNAVAILABLE; |
609 | else | 626 | else |
610 | mPagerAppAvailable = AVAILABLE; | 627 | mPagerAppAvailable = AVAILABLE; |
611 | } | 628 | } |
612 | 629 | ||
613 | return (mPagerAppAvailable == AVAILABLE); | 630 | return (mPagerAppAvailable == AVAILABLE); |
614 | #else //DESKTOP_VERSION | 631 | #else //DESKTOP_VERSION |
615 | return false; | 632 | return false; |
616 | #endif //DESKTOP_VERSION | 633 | #endif //DESKTOP_VERSION |
617 | } | 634 | } |
618 | 635 | ||
619 | 636 | ||
620 | bool ExternalAppHandler::isSIPAppAvailable() | 637 | bool ExternalAppHandler::isSIPAppAvailable() |
621 | { | 638 | { |
622 | #ifndef DESKTOP_VERSION | 639 | #ifndef DESKTOP_VERSION |
623 | if (mSIPAppAvailable == UNDEFINED) | 640 | if (mSIPAppAvailable == UNDEFINED) |
624 | { | 641 | { |
625 | int client = KPimGlobalPrefs::instance()->mSipClient; | 642 | int client = KPimGlobalPrefs::instance()->mSipClient; |
626 | if (client == KPimGlobalPrefs::NONE_SIC) | 643 | if (client == KPimGlobalPrefs::NONE_SIC) |
627 | mSIPAppAvailable = UNAVAILABLE; | 644 | mSIPAppAvailable = UNAVAILABLE; |
628 | else | 645 | else |
629 | mSIPAppAvailable = AVAILABLE; | 646 | mSIPAppAvailable = AVAILABLE; |
630 | } | 647 | } |
631 | 648 | ||
632 | return (mSIPAppAvailable == AVAILABLE); | 649 | return (mSIPAppAvailable == AVAILABLE); |
633 | #else //DESKTOP_VERSION | 650 | #else //DESKTOP_VERSION |
634 | return false; | 651 | return false; |
635 | #endif //DESKTOP_VERSION | 652 | #endif //DESKTOP_VERSION |
636 | } | 653 | } |
637 | 654 | ||
638 | /************************************************************************** | 655 | /************************************************************************** |
639 | * | 656 | * |
640 | **************************************************************************/ | 657 | **************************************************************************/ |
641 | 658 | ||
642 | 659 | ||
643 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 660 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
644 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 661 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
645 | { | 662 | { |
646 | 663 | ||
647 | #ifndef DESKTOP_VERSION | 664 | #ifndef DESKTOP_VERSION |
648 | QString channel; | 665 | QString channel; |
649 | QString message2; | 666 | QString message2; |
650 | QString parameters2; | 667 | QString parameters2; |
651 | 668 | ||
652 | 669 | ||
653 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 670 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
654 | if (client == KPimGlobalPrefs::OTHER_EMC) | 671 | if (client == KPimGlobalPrefs::OTHER_EMC) |
655 | { | 672 | { |
656 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 673 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
657 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 674 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
658 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 675 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
659 | } | 676 | } |
660 | else | 677 | else |
661 | { | 678 | { |
662 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 679 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
663 | if (!dai) | 680 | if (!dai) |
664 | { | 681 | { |
665 | qDebug("could not find configured email application."); | 682 | qDebug("could not find configured email application."); |
666 | return false; | 683 | return false; |
667 | } | 684 | } |
668 | channel = dai->_channel; | 685 | channel = dai->_channel; |
669 | message2 = dai->_message2; | 686 | message2 = dai->_message2; |
670 | parameters2 = dai->_parameters2; | 687 | parameters2 = dai->_parameters2; |
671 | } | 688 | } |
672 | 689 | ||
673 | //first check if one of the mailers need the emails right in the message. | 690 | //first check if one of the mailers need the emails right in the message. |
674 | message2 = translateMessage(message2, emails, urls); | 691 | message2 = translateMessage(message2, emails, urls); |
675 | 692 | ||
676 | 693 | ||
677 | #ifdef DEBUG_EXT_APP_HANDLER | 694 | #ifdef DEBUG_EXT_APP_HANDLER |
678 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 695 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
679 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 696 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
680 | #endif | 697 | #endif |
681 | 698 | ||
682 | 699 | ||
683 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 700 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
684 | //US we need no names in the To field. The emailadresses are enough | 701 | //US we need no names in the To field. The emailadresses are enough |
685 | 702 | ||
686 | passParameters(&e, parameters2, emails, urls); | 703 | passParameters(&e, parameters2, emails, urls); |
687 | 704 | ||
688 | 705 | ||
689 | 706 | ||
690 | #else | 707 | #else |
691 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 708 | //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1()); |
709 | |||
710 | QString channel; | ||
711 | QString message2; | ||
712 | QString parameters2; | ||
713 | QString message; | ||
714 | QString parameters; | ||
715 | |||
716 | |||
717 | int client = KPimGlobalPrefs::instance()->mEmailClient; | ||
718 | if (client == KPimGlobalPrefs::OTHER_EMC) | ||
719 | { | ||
720 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | ||
721 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | ||
722 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | ||
723 | } | ||
724 | else | ||
725 | { | ||
726 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | ||
727 | if (!dai) | ||
728 | { | ||
729 | qDebug("could not find configured email application."); | ||
730 | return false; | ||
731 | } | ||
732 | channel = dai->_channel; | ||
733 | message2 = dai->_message2; | ||
734 | parameters2 = dai->_parameters2; | ||
735 | message = dai->_message; | ||
736 | parameters = dai->_parameters; | ||
737 | } | ||
738 | |||
739 | //first check if one of the mailers need the emails right in the message. | ||
740 | message2 = translateMessage(message2, emails, urls); | ||
741 | #ifdef DEBUG_EXT_APP_HANDLER | ||
742 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | ||
743 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | ||
744 | #endif | ||
745 | qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() ); | ||
746 | //KMessageBox::sorry( 0, message2 ); | ||
747 | QProcess * proc = new QProcess( this ); | ||
748 | QStringList list = QStringList::split( " ", message ); | ||
749 | int i = 0; | ||
750 | proc->addArgument( channel ); | ||
751 | while ( i < list.count ( ) ) { | ||
752 | //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() ); | ||
753 | proc->addArgument( list[i].stripWhiteSpace() ); | ||
754 | ++i; | ||
755 | } | ||
756 | parameters2 = translateMessage(parameters2, urls, "" ); | ||
757 | QString arg = "to='%1'"; | ||
758 | arg = arg.arg( emails ) + ","+parameters2;; | ||
759 | |||
760 | //qDebug("2add%sdd ",arg.latin1() ); | ||
761 | proc->addArgument( arg); | ||
762 | proc->launch(""); | ||
692 | #endif | 763 | #endif |
693 | 764 | ||
694 | return true; | 765 | return true; |
695 | } | 766 | } |
696 | 767 | ||
697 | /************************************************************************** | 768 | /************************************************************************** |
698 | * | 769 | * |
699 | **************************************************************************/ | 770 | **************************************************************************/ |
700 | 771 | ||
701 | 772 | ||
702 | //calls the emailapplication and creates a mail with parameter emails as recipients | 773 | //calls the emailapplication and creates a mail with parameter emails as recipients |
703 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 774 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
704 | { | 775 | { |
705 | #ifndef DESKTOP_VERSION | 776 | |
706 | QString channel; | 777 | QString channel; |
707 | QString message; | 778 | QString message; |
708 | QString parameters; | 779 | QString parameters; |
709 | 780 | ||
710 | 781 | ||
711 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 782 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
712 | if (client == KPimGlobalPrefs::OTHER_EMC) | 783 | if (client == KPimGlobalPrefs::OTHER_EMC) |
713 | { | 784 | { |
714 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 785 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
715 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 786 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
716 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 787 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
717 | } | 788 | } |
718 | else | 789 | else |
719 | { | 790 | { |
720 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 791 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
721 | if (!dai) | 792 | if (!dai) |
722 | { | 793 | { |
723 | qDebug("could not find configured email application."); | 794 | qDebug("could not find configured email application."); |
724 | return false; | 795 | return false; |
725 | } | 796 | } |
726 | channel = dai->_channel; | 797 | channel = dai->_channel; |
727 | message = dai->_message; | 798 | message = dai->_message; |
728 | parameters = dai->_parameters; | 799 | parameters = dai->_parameters; |
729 | } | 800 | } |
730 | 801 | ||
731 | 802 | #ifdef DESKTOP_VERSION | |
803 | //message = channel + " " +message + " \""+ parameters + "\""; | ||
804 | #endif | ||
732 | //first check if one of the mailers need the emails right in the message. | 805 | //first check if one of the mailers need the emails right in the message. |
733 | message = translateMessage(message, name, emailadress); | 806 | message = translateMessage(message, name, emailadress); |
734 | 807 | ||
735 | |||
736 | #ifdef DEBUG_EXT_APP_HANDLER | 808 | #ifdef DEBUG_EXT_APP_HANDLER |
737 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 809 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
738 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 810 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
739 | #endif | 811 | #endif |
740 | 812 | ||
813 | #ifndef DESKTOP_VERSION | ||
741 | QCopEnvelope e(channel.latin1(), message.latin1()); | 814 | QCopEnvelope e(channel.latin1(), message.latin1()); |
742 | //US we need no names in the To field. The emailadresses are enough | 815 | //US we need no names in the To field. The emailadresses are enough |
743 | 816 | ||
744 | passParameters(&e, parameters, name, emailadress); | 817 | passParameters(&e, parameters, name, emailadress); |
745 | 818 | #else // DESKTOP_VERSION | |
746 | 819 | ||
747 | #else | 820 | //KMessageBox::sorry( 0, message ); |
748 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 821 | QProcess * proc = new QProcess( this ); |
822 | QStringList list = QStringList::split( " ", message ); | ||
823 | int i = 0; | ||
824 | proc->addArgument( channel ); | ||
825 | while ( i < list.count ( ) ) { | ||
826 | //qDebug("add%sdd ",list[i].latin1() ); | ||
827 | proc->addArgument( list[i] ); | ||
828 | ++i; | ||
829 | } | ||
830 | parameters = translateMessage(parameters, name, emailadress); | ||
831 | proc->addArgument( parameters ); | ||
832 | proc->launch(""); | ||
749 | #endif | 833 | #endif |
750 | 834 | ||
751 | |||
752 | return true; | 835 | return true; |
753 | } | 836 | } |
754 | 837 | ||
755 | /************************************************************************** | 838 | /************************************************************************** |
756 | * | 839 | * |
757 | **************************************************************************/ | 840 | **************************************************************************/ |
758 | 841 | ||
759 | //calls the emailapplication and creates a mail with parameter as recipients | 842 | //calls the emailapplication and creates a mail with parameter as recipients |
760 | // parameters format is | 843 | // parameters format is |
761 | // NAME <EMAIL>:SUBJECT | 844 | // NAME <EMAIL>:SUBJECT |
762 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 845 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
763 | { | 846 | { |
764 | QString line = adressline; | 847 | QString line = adressline; |
765 | 848 | ||
766 | int first = line.find( "<"); | 849 | int first = line.find( "<"); |
767 | int last = line.find( ">"); | 850 | int last = line.find( ">"); |
768 | QString name = line.left(first); | 851 | QString name = line.left(first); |
769 | QString emailadress = line.mid(first+1, last-first-1); | 852 | QString emailadress = line.mid(first+1, last-first-1); |
770 | 853 | ||
771 | //Subject can not be handled right now. | 854 | //Subject can not be handled right now. |
772 | return mailToOneContact( name, emailadress ); | 855 | return mailToOneContact( name, emailadress ); |
773 | 856 | ||
774 | } | 857 | } |
775 | 858 | ||
776 | 859 | ||
777 | /************************************************************************** | 860 | /************************************************************************** |
778 | * | 861 | * |
779 | **************************************************************************/ | 862 | **************************************************************************/ |
780 | 863 | ||
781 | //calls the phoneapplication with the number | 864 | //calls the phoneapplication with the number |
782 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 865 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
783 | { | 866 | { |
784 | #ifndef DESKTOP_VERSION | 867 | #ifndef DESKTOP_VERSION |
785 | QString channel; | 868 | QString channel; |
786 | QString message; | 869 | QString message; |
787 | QString parameters; | 870 | QString parameters; |
788 | 871 | ||
789 | 872 | ||
790 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 873 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
791 | if (client == KPimGlobalPrefs::OTHER_PHC) | 874 | if (client == KPimGlobalPrefs::OTHER_PHC) |
792 | { | 875 | { |
793 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 876 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
794 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 877 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
795 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 878 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
796 | } | 879 | } |
797 | else | 880 | else |
798 | { | 881 | { |
799 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 882 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
800 | if (!dai) | 883 | if (!dai) |
801 | { | 884 | { |
802 | qDebug("could not find configured phone application."); | 885 | qDebug("could not find configured phone application."); |
803 | return false; | 886 | return false; |
804 | } | 887 | } |
805 | channel = dai->_channel; | 888 | channel = dai->_channel; |
806 | message = dai->_message; | 889 | message = dai->_message; |
807 | parameters = dai->_parameters; | 890 | parameters = dai->_parameters; |
808 | } | 891 | } |
809 | 892 | ||
810 | 893 | ||
811 | //first check if one of the mailers need the emails right in the message. | 894 | //first check if one of the mailers need the emails right in the message. |
812 | message = translateMessage(message, phonenumber, ""); | 895 | message = translateMessage(message, phonenumber, ""); |
813 | 896 | ||
814 | 897 | ||
815 | #ifdef DEBUG_EXT_APP_HANDLER | 898 | #ifdef DEBUG_EXT_APP_HANDLER |
816 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 899 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
817 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 900 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
818 | #endif | 901 | #endif |
819 | 902 | ||
820 | QCopEnvelope e(channel.latin1(), message.latin1()); | 903 | QCopEnvelope e(channel.latin1(), message.latin1()); |
821 | //US we need no names in the To field. The emailadresses are enough | 904 | //US we need no names in the To field. The emailadresses are enough |
822 | 905 | ||
823 | passParameters(&e, parameters, phonenumber, ""); | 906 | passParameters(&e, parameters, phonenumber, ""); |
824 | 907 | ||
825 | 908 | ||
826 | #else | 909 | #else |
827 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 910 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
828 | #endif | 911 | #endif |
829 | 912 | ||
830 | 913 | ||
831 | return true; | 914 | return true; |
832 | } | 915 | } |
833 | 916 | ||
834 | /************************************************************************** | 917 | /************************************************************************** |
835 | * | 918 | * |
836 | **************************************************************************/ | 919 | **************************************************************************/ |
837 | 920 | ||
838 | //calls the smsapplication with the number | 921 | //calls the smsapplication with the number |
839 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 922 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
840 | { | 923 | { |
841 | #ifndef DESKTOP_VERSION | 924 | #ifndef DESKTOP_VERSION |
842 | QString channel; | 925 | QString channel; |
843 | QString message; | 926 | QString message; |
844 | QString parameters; | 927 | QString parameters; |
845 | 928 | ||
846 | 929 | ||
847 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 930 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
848 | if (client == KPimGlobalPrefs::OTHER_SMC) | 931 | if (client == KPimGlobalPrefs::OTHER_SMC) |
849 | { | 932 | { |
850 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 933 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
851 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 934 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
852 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 935 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
853 | } | 936 | } |
854 | else | 937 | else |
855 | { | 938 | { |
856 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 939 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
857 | if (!dai) | 940 | if (!dai) |
858 | { | 941 | { |
859 | qDebug("could not find configured sms application."); | 942 | qDebug("could not find configured sms application."); |
860 | return false; | 943 | return false; |
861 | } | 944 | } |
862 | channel = dai->_channel; | 945 | channel = dai->_channel; |
863 | message = dai->_message; | 946 | message = dai->_message; |
864 | parameters = dai->_parameters; | 947 | parameters = dai->_parameters; |
865 | } | 948 | } |
866 | 949 | ||
867 | 950 | ||
868 | //first check if one of the mailers need the emails right in the message. | 951 | //first check if one of the mailers need the emails right in the message. |
869 | message = translateMessage(message, phonenumber, ""); | 952 | message = translateMessage(message, phonenumber, ""); |
870 | 953 | ||
871 | 954 | ||
872 | #ifdef DEBUG_EXT_APP_HANDLER | 955 | #ifdef DEBUG_EXT_APP_HANDLER |
873 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 956 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
874 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 957 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
875 | #endif | 958 | #endif |
876 | 959 | ||
877 | QCopEnvelope e(channel.latin1(), message.latin1()); | 960 | QCopEnvelope e(channel.latin1(), message.latin1()); |
878 | //US we need no names in the To field. The emailadresses are enough | 961 | //US we need no names in the To field. The emailadresses are enough |
879 | 962 | ||
880 | passParameters(&e, parameters, phonenumber, ""); | 963 | passParameters(&e, parameters, phonenumber, ""); |
881 | 964 | ||
882 | 965 | ||
883 | #else | 966 | #else |
884 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 967 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
885 | #endif | 968 | #endif |
886 | 969 | ||
887 | 970 | ||
888 | return true; | 971 | return true; |
889 | } | 972 | } |
890 | 973 | ||
891 | /************************************************************************** | 974 | /************************************************************************** |
892 | * | 975 | * |
893 | **************************************************************************/ | 976 | **************************************************************************/ |
894 | 977 | ||
895 | //calls the pagerapplication with the number | 978 | //calls the pagerapplication with the number |
896 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 979 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
897 | { | 980 | { |
898 | #ifndef DESKTOP_VERSION | 981 | #ifndef DESKTOP_VERSION |
899 | QString channel; | 982 | QString channel; |
900 | QString message; | 983 | QString message; |
901 | QString parameters; | 984 | QString parameters; |
902 | 985 | ||
903 | 986 | ||
904 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 987 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
905 | if (client == KPimGlobalPrefs::OTHER_PAC) | 988 | if (client == KPimGlobalPrefs::OTHER_PAC) |
906 | { | 989 | { |
907 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 990 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
908 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 991 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
909 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 992 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
910 | } | 993 | } |
911 | else | 994 | else |
912 | { | 995 | { |
913 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 996 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
914 | if (!dai) | 997 | if (!dai) |
915 | { | 998 | { |
916 | qDebug("could not find configured pager application."); | 999 | qDebug("could not find configured pager application."); |
917 | return false; | 1000 | return false; |
918 | } | 1001 | } |
919 | channel = dai->_channel; | 1002 | channel = dai->_channel; |
920 | message = dai->_message; | 1003 | message = dai->_message; |
921 | parameters = dai->_parameters; | 1004 | parameters = dai->_parameters; |
922 | } | 1005 | } |
923 | 1006 | ||
924 | 1007 | ||
925 | //first check if one of the mailers need the emails right in the message. | 1008 | //first check if one of the mailers need the emails right in the message. |
926 | message = translateMessage(message, pagernumber, ""); | 1009 | message = translateMessage(message, pagernumber, ""); |
927 | 1010 | ||
928 | 1011 | ||
929 | #ifdef DEBUG_EXT_APP_HANDLER | 1012 | #ifdef DEBUG_EXT_APP_HANDLER |
930 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1013 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
931 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 1014 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
932 | #endif | 1015 | #endif |
933 | 1016 | ||
934 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1017 | QCopEnvelope e(channel.latin1(), message.latin1()); |
935 | //US we need no names in the To field. The emailadresses are enough | 1018 | //US we need no names in the To field. The emailadresses are enough |
936 | 1019 | ||
937 | passParameters(&e, parameters, pagernumber, ""); | 1020 | passParameters(&e, parameters, pagernumber, ""); |
938 | 1021 | ||
939 | 1022 | ||
940 | #else | 1023 | #else |
941 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 1024 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
942 | #endif | 1025 | #endif |
943 | 1026 | ||
944 | 1027 | ||
945 | return true; | 1028 | return true; |
946 | } | 1029 | } |
947 | 1030 | ||
948 | /************************************************************************** | 1031 | /************************************************************************** |
949 | * | 1032 | * |
950 | **************************************************************************/ | 1033 | **************************************************************************/ |
951 | 1034 | ||
952 | //calls the faxapplication with the number | 1035 | //calls the faxapplication with the number |
953 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 1036 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
954 | { | 1037 | { |
955 | #ifndef DESKTOP_VERSION | 1038 | #ifndef DESKTOP_VERSION |
956 | QString channel; | 1039 | QString channel; |
957 | QString message; | 1040 | QString message; |
958 | QString parameters; | 1041 | QString parameters; |
959 | 1042 | ||
960 | 1043 | ||
961 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 1044 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
962 | if (client == KPimGlobalPrefs::OTHER_FAC) | 1045 | if (client == KPimGlobalPrefs::OTHER_FAC) |
963 | { | 1046 | { |
964 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 1047 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
965 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 1048 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
966 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 1049 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
967 | } | 1050 | } |
968 | else | 1051 | else |
969 | { | 1052 | { |
970 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 1053 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
971 | if (!dai) | 1054 | if (!dai) |
972 | { | 1055 | { |
973 | qDebug("could not find configured fax application."); | 1056 | qDebug("could not find configured fax application."); |
974 | return false; | 1057 | return false; |
975 | } | 1058 | } |
976 | channel = dai->_channel; | 1059 | channel = dai->_channel; |
977 | message = dai->_message; | 1060 | message = dai->_message; |
978 | parameters = dai->_parameters; | 1061 | parameters = dai->_parameters; |
979 | } | 1062 | } |
980 | 1063 | ||
981 | 1064 | ||
982 | //first check if one of the mailers need the emails right in the message. | 1065 | //first check if one of the mailers need the emails right in the message. |
983 | message = translateMessage(message, faxnumber, ""); | 1066 | message = translateMessage(message, faxnumber, ""); |
984 | 1067 | ||
985 | 1068 | ||
986 | #ifdef DEBUG_EXT_APP_HANDLER | 1069 | #ifdef DEBUG_EXT_APP_HANDLER |
987 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1070 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
988 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 1071 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
989 | #endif | 1072 | #endif |
990 | 1073 | ||
991 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1074 | QCopEnvelope e(channel.latin1(), message.latin1()); |
992 | //US we need no names in the To field. The emailadresses are enough | 1075 | //US we need no names in the To field. The emailadresses are enough |
993 | 1076 | ||
994 | passParameters(&e, parameters, faxnumber, ""); | 1077 | passParameters(&e, parameters, faxnumber, ""); |
995 | 1078 | ||
996 | 1079 | ||
997 | #else | 1080 | #else |
998 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 1081 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
999 | #endif | 1082 | #endif |
1000 | 1083 | ||
1001 | 1084 | ||
1002 | return true; | 1085 | return true; |
1003 | } | 1086 | } |
1004 | 1087 | ||
1005 | /************************************************************************** | 1088 | /************************************************************************** |
1006 | * | 1089 | * |
1007 | **************************************************************************/ | 1090 | **************************************************************************/ |
1008 | 1091 | ||
1009 | //calls the sipapplication with the number | 1092 | //calls the sipapplication with the number |
1010 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | 1093 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) |
1011 | { | 1094 | { |
1012 | #ifndef DESKTOP_VERSION | 1095 | #ifndef DESKTOP_VERSION |
1013 | QString channel; | 1096 | QString channel; |
1014 | QString message; | 1097 | QString message; |
1015 | QString parameters; | 1098 | QString parameters; |
1016 | 1099 | ||
1017 | 1100 | ||
1018 | int client = KPimGlobalPrefs::instance()->mSipClient; | 1101 | int client = KPimGlobalPrefs::instance()->mSipClient; |
1019 | if (client == KPimGlobalPrefs::OTHER_SIC) | 1102 | if (client == KPimGlobalPrefs::OTHER_SIC) |
1020 | { | 1103 | { |
1021 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; | 1104 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; |
1022 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; | 1105 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; |
1023 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; | 1106 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; |
1024 | } | 1107 | } |
1025 | else | 1108 | else |
1026 | { | 1109 | { |
1027 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); | 1110 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); |
1028 | if (!dai) | 1111 | if (!dai) |
1029 | { | 1112 | { |
1030 | qDebug("could not find configured sip application."); | 1113 | qDebug("could not find configured sip application."); |
1031 | return false; | 1114 | return false; |
1032 | } | 1115 | } |
1033 | channel = dai->_channel; | 1116 | channel = dai->_channel; |
1034 | message = dai->_message; | 1117 | message = dai->_message; |
1035 | parameters = dai->_parameters; | 1118 | parameters = dai->_parameters; |
1036 | } | 1119 | } |
1037 | 1120 | ||
1038 | 1121 | ||
1039 | //first check if one of the sip apps need the emails right in the message. | 1122 | //first check if one of the sip apps need the emails right in the message. |
1040 | message = translateMessage(message, sipnumber, ""); | 1123 | message = translateMessage(message, sipnumber, ""); |
1041 | 1124 | ||
1042 | 1125 | ||
1043 | #ifdef DEBUG_EXT_APP_HANDLER | 1126 | #ifdef DEBUG_EXT_APP_HANDLER |
1044 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1127 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
1045 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | 1128 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); |
1046 | #endif | 1129 | #endif |
1047 | 1130 | ||
1048 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1131 | QCopEnvelope e(channel.latin1(), message.latin1()); |
1049 | //US we need no names in the To field. The emailadresses are enough | 1132 | //US we need no names in the To field. The emailadresses are enough |
1050 | 1133 | ||
1051 | passParameters(&e, parameters, sipnumber, ""); | 1134 | passParameters(&e, parameters, sipnumber, ""); |
1052 | 1135 | ||
1053 | 1136 | ||
1054 | #else | 1137 | #else |
1055 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | 1138 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); |
1056 | #endif | 1139 | #endif |
1057 | 1140 | ||
1058 | 1141 | ||
1059 | return true; | 1142 | return true; |
1060 | } | 1143 | } |
1061 | 1144 | ||
1062 | 1145 | ||
1063 | /************************************************************************** | 1146 | /************************************************************************** |
1064 | * | 1147 | * |
1065 | **************************************************************************/ | 1148 | **************************************************************************/ |
1066 | 1149 | ||
1067 | 1150 | ||
1068 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1151 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
1069 | { | 1152 | { |
1070 | message = message.replace( QRegExp("%1"), param1 ); | 1153 | message = message.replace( QRegExp("%1"), param1 ); |
1071 | return message.replace( QRegExp("%2"), param2 ); | 1154 | return message.replace( QRegExp("%2"), param2 ); |
1072 | } | 1155 | } |
1073 | 1156 | ||
1074 | /************************************************************************** | 1157 | /************************************************************************** |
1075 | * | 1158 | * |
1076 | **************************************************************************/ | 1159 | **************************************************************************/ |
1077 | 1160 | ||
1078 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1161 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
1079 | { | 1162 | { |
1080 | #ifndef DESKTOP_VERSION | 1163 | #ifndef DESKTOP_VERSION |
1081 | QMap<QString, QString> valmap; | 1164 | QMap<QString, QString> valmap; |
1082 | bool useValMap = false; | 1165 | bool useValMap = false; |
1083 | 1166 | ||
1084 | // first extract all parts of the parameters. | 1167 | // first extract all parts of the parameters. |
1085 | QStringList paramlist = QStringList::split(";", parameters); | 1168 | QStringList paramlist = QStringList::split(";", parameters); |
1086 | 1169 | ||
1087 | //Now check how many parts we have. | 1170 | //Now check how many parts we have. |
1088 | //=0 :no params to pass | 1171 | //=0 :no params to pass |
1089 | //>0 :parameters to pass | 1172 | //>0 :parameters to pass |
1090 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1173 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
1091 | { | 1174 | { |
1092 | QString param = (*it); | 1175 | QString param = (*it); |
1093 | QStringList keyvallist = QStringList::split("=", param); | 1176 | QStringList keyvallist = QStringList::split("=", param); |
1094 | 1177 | ||
1095 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1178 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
1096 | QStringList::Iterator it2 = keyvallist.begin(); | 1179 | QStringList::Iterator it2 = keyvallist.begin(); |
1097 | QString key = (*it2); | 1180 | QString key = (*it2); |
1098 | key = key.replace( QRegExp("%1"), param1 ); | 1181 | key = key.replace( QRegExp("%1"), param1 ); |
1099 | key = key.replace( QRegExp("%2"), param2 ); | 1182 | key = key.replace( QRegExp("%2"), param2 ); |
1100 | ++it2; | 1183 | ++it2; |
1101 | 1184 | ||
1102 | if(it2 != keyvallist.end()) | 1185 | if(it2 != keyvallist.end()) |
1103 | { | 1186 | { |
1104 | QString value = (*it2); | 1187 | QString value = (*it2); |
1105 | value = value.replace( QRegExp("%1"), param1 ); | 1188 | value = value.replace( QRegExp("%1"), param1 ); |
1106 | value = value.replace( QRegExp("%2"), param2 ); | 1189 | value = value.replace( QRegExp("%2"), param2 ); |
1107 | 1190 | ||
1108 | valmap.insert(key, value); | 1191 | valmap.insert(key, value); |
1109 | useValMap = true; | 1192 | useValMap = true; |
1110 | } | 1193 | } |
1111 | else | 1194 | else |
1112 | { | 1195 | { |
1113 | // qDebug("pass parameter << %s", key.latin1()); | 1196 | // qDebug("pass parameter << %s", key.latin1()); |
1114 | (*e) << key; | 1197 | (*e) << key; |
1115 | } | 1198 | } |
1116 | } | 1199 | } |
1117 | 1200 | ||
1118 | if (useValMap == true) | 1201 | if (useValMap == true) |
1119 | (*e) << valmap; | 1202 | (*e) << valmap; |
1120 | 1203 | ||
1121 | #endif | 1204 | #endif |
1122 | 1205 | ||
1123 | } | 1206 | } |
1124 | 1207 | ||
1125 | 1208 | ||
1126 | 1209 | ||
1127 | /************************************************************************** | 1210 | /************************************************************************** |
1128 | * | 1211 | * |
1129 | **************************************************************************/ | 1212 | **************************************************************************/ |
1130 | 1213 | ||
1131 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1214 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
1132 | { | 1215 | { |
1133 | qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); | 1216 | qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this); |
1134 | if ( cmsg == "nextView()" ) { | 1217 | if ( cmsg == "nextView()" ) { |
1135 | qDebug("nextView()"); | 1218 | qDebug("nextView()"); |
1136 | QTimer::singleShot( 0, this, SIGNAL ( nextView() )); | 1219 | QTimer::singleShot( 0, this, SIGNAL ( nextView() )); |
1137 | return; | 1220 | return; |
1138 | } | 1221 | } |
1139 | if ( cmsg == "callContactdialog()" ) { | 1222 | if ( cmsg == "callContactdialog()" ) { |
1140 | qDebug("callContactdialog()"); | 1223 | qDebug("callContactdialog()"); |
1141 | QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); | 1224 | QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() )); |
1142 | return; | 1225 | return; |
1143 | } | 1226 | } |
1144 | if ( cmsg == "doRingSync" ) { | 1227 | if ( cmsg == "doRingSync" ) { |
1145 | qDebug("doRingSync"); | 1228 | qDebug("doRingSync"); |
1146 | QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); | 1229 | QTimer::singleShot( 0, this, SIGNAL ( doRingSync() )); |
1147 | return; | 1230 | return; |
1148 | } | 1231 | } |
1149 | 1232 | ||
1150 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1233 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1151 | if (!res) | 1234 | if (!res) |
1152 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); | 1235 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); |
1153 | 1236 | ||
1154 | if (!res) | 1237 | if (!res) |
1155 | res = mDisplayDetails->appMessage( cmsg, data ); | 1238 | res = mDisplayDetails->appMessage( cmsg, data ); |
1156 | 1239 | ||
1157 | // if (!res) | 1240 | // if (!res) |
1158 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1241 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1159 | } | 1242 | } |
1160 | 1243 | ||
1161 | 1244 | ||
1162 | 1245 | ||
1163 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1246 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1164 | { | 1247 | { |
1165 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1248 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1166 | // maybe we are sending to KA/Pi fom a different worldd... | 1249 | // maybe we are sending to KA/Pi fom a different worldd... |
1167 | // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application | 1250 | // it may be that the QAplication::desktop()->width() values in KA/Pi are not the same as in our application |
1168 | // for that reason we send the current QApplication::desktop()->width() to KA/Pi | 1251 | // for that reason we send the current QApplication::desktop()->width() to KA/Pi |
1169 | //qDebug("UID %s ", sessionuid.latin1()); | 1252 | //qDebug("UID %s ", sessionuid.latin1()); |
1170 | //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); | 1253 | //return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(QString::number ( QApplication::desktop()->width() )); |
1171 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1254 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1172 | } | 1255 | } |
1173 | 1256 | ||
1174 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1257 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1175 | { | 1258 | { |
1176 | QStringList list4, list5, list6; | 1259 | QStringList list4, list5, list6; |
1177 | 1260 | ||
1178 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1261 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1179 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1262 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1180 | } | 1263 | } |
1181 | 1264 | ||
1182 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1265 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
1183 | { | 1266 | { |
1184 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1267 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1185 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 1268 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
1186 | } | 1269 | } |
1187 | 1270 | ||
1188 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1271 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1189 | { | 1272 | { |
1190 | QStringList list4, list5, list6; | 1273 | QStringList list4, list5, list6; |
1191 | 1274 | ||
1192 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1275 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1193 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1276 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1194 | } | 1277 | } |
1195 | 1278 | ||
1196 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1279 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1197 | { | 1280 | { |
1198 | mDisplayDetails->setSourceChannel(""); | 1281 | mDisplayDetails->setSourceChannel(""); |
1199 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1282 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1200 | } | 1283 | } |
1201 | 1284 | ||
1202 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1285 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1203 | { | 1286 | { |
1204 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1287 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1205 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1288 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1206 | } | 1289 | } |
1207 | 1290 | ||
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) | 1291 | 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) |
1209 | { | 1292 | { |
1210 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | 1293 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); |
1211 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | 1294 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1212 | } | 1295 | } |
1213 | 1296 | ||
1214 | 1297 | ||
1215 | 1298 | ||
1216 | 1299 | ||
1217 | 1300 | ||