-rw-r--r-- | libkdepim/externalapphandler.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index bd83626..6100097 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,1016 +1,1014 @@ | |||
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 <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
39 | #else | 39 | #else |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | 46 | ||
47 | #include "externalapphandler.h" | 47 | #include "externalapphandler.h" |
48 | 48 | ||
49 | #include "kpimglobalprefs.h" | 49 | #include "kpimglobalprefs.h" |
50 | 50 | ||
51 | /********************************************************************************* | 51 | /********************************************************************************* |
52 | * | 52 | * |
53 | ********************************************************************************/ | 53 | ********************************************************************************/ |
54 | 54 | ||
55 | 55 | ||
56 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 56 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
57 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) | 57 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) |
58 | { | 58 | { |
59 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 | 59 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 |
60 | if (_usedSourceParameters == 0) | 60 | if (_usedSourceParameters == 0) |
61 | _sourceMessageParameters = "(QString,QString)"; | 61 | _sourceMessageParameters = "(QString,QString)"; |
62 | else if (_usedSourceParameters == 1) | 62 | else if (_usedSourceParameters == 1) |
63 | _sourceMessageParameters = "(QString,QString,QString)"; | 63 | _sourceMessageParameters = "(QString,QString,QString)"; |
64 | else if (_usedSourceParameters == 2) | 64 | else if (_usedSourceParameters == 2) |
65 | _sourceMessageParameters = "(QString,QString,QString,QString)"; | 65 | _sourceMessageParameters = "(QString,QString,QString,QString)"; |
66 | else if (_usedSourceParameters == 3) | 66 | else if (_usedSourceParameters == 3) |
67 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; | 67 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; |
68 | } | 68 | } |
69 | 69 | ||
70 | /*********************************************************************************/ | 70 | /*********************************************************************************/ |
71 | 71 | ||
72 | QCopTransferItem::QCopTransferItem() | 72 | QCopTransferItem::QCopTransferItem() |
73 | { | 73 | { |
74 | } | 74 | } |
75 | 75 | ||
76 | /*********************************************************************************/ | 76 | /*********************************************************************************/ |
77 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) | 77 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) |
78 | { | 78 | { |
79 | 79 | ||
80 | #ifndef DESKTOP_VERSION | 80 | #ifndef DESKTOP_VERSION |
81 | //sourceMessage passes two parameters: sourceChannel, uid | 81 | //sourceMessage passes two parameters: sourceChannel, uid |
82 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; | 82 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; |
83 | 83 | ||
84 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); | 84 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); |
85 | 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()); | 85 | 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()); |
86 | 86 | ||
87 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); | 87 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); |
88 | 88 | ||
89 | e << _sourceChannel << uid; | 89 | e << _sourceChannel << uid; |
90 | 90 | ||
91 | if (_usedSourceParameters == 1) | 91 | if (_usedSourceParameters == 1) |
92 | e << param1; | 92 | e << param1; |
93 | else if (_usedSourceParameters == 2) | 93 | else if (_usedSourceParameters == 2) |
94 | e << param1 << param2; | 94 | e << param1 << param2; |
95 | else if (_usedSourceParameters == 3) | 95 | else if (_usedSourceParameters == 3) |
96 | e << param1 << param2 << param3; | 96 | e << param1 << param2 << param3; |
97 | 97 | ||
98 | qApp->processEvents(); | 98 | qApp->processEvents(); |
99 | 99 | ||
100 | return true; | 100 | return true; |
101 | 101 | ||
102 | #else | 102 | #else |
103 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 103 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
104 | return false; | 104 | return false; |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | 109 | ||
110 | /*********************************************************************************/ | 110 | /*********************************************************************************/ |
111 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | 111 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) |
112 | { | 112 | { |
113 | 113 | ||
114 | if (_sourceChannel.isEmpty()) | 114 | if (_sourceChannel.isEmpty()) |
115 | _sourceChannel = sourceChannel; | 115 | _sourceChannel = sourceChannel; |
116 | } | 116 | } |
117 | 117 | ||
118 | 118 | ||
119 | /*********************************************************************************/ | 119 | /*********************************************************************************/ |
120 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 120 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
121 | { | 121 | { |
122 | 122 | ||
123 | // copied from old mail2 | 123 | // copied from old mail2 |
124 | /* | 124 | /* |
125 | static int ii = 0; | 125 | static int ii = 0; |
126 | 126 | ||
127 | // block second call | 127 | // block second call |
128 | if ( ii < 2 ) { | 128 | if ( ii < 2 ) { |
129 | ++ii; | 129 | ++ii; |
130 | if ( ii > 1 ) { | 130 | if ( ii > 1 ) { |
131 | qDebug("qcop call blocked "); | 131 | qDebug("qcop call blocked "); |
132 | return true; | 132 | return true; |
133 | } | 133 | } |
134 | } | 134 | } |
135 | */ | 135 | */ |
136 | 136 | ||
137 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); | 137 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); |
138 | 138 | ||
139 | //we are in the target and get a request from the source | 139 | //we are in the target and get a request from the source |
140 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) | 140 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) |
141 | { | 141 | { |
142 | 142 | ||
143 | QDataStream stream( data, IO_ReadOnly ); | 143 | QDataStream stream( data, IO_ReadOnly ); |
144 | 144 | ||
145 | 145 | ||
146 | QString sourceChannel; | 146 | QString sourceChannel; |
147 | QString uid; | 147 | QString uid; |
148 | QString param1; | 148 | QString param1; |
149 | QString param2; | 149 | QString param2; |
150 | QString param3; | 150 | QString param3; |
151 | 151 | ||
152 | stream >> sourceChannel >> uid; | 152 | stream >> sourceChannel >> uid; |
153 | 153 | ||
154 | if (_usedSourceParameters == 0) | 154 | if (_usedSourceParameters == 0) |
155 | { | 155 | { |
156 | emit receivedMessageFromSource(sourceChannel, uid); | 156 | emit receivedMessageFromSource(sourceChannel, uid); |
157 | } | 157 | } |
158 | else if (_usedSourceParameters == 1) | 158 | else if (_usedSourceParameters == 1) |
159 | { | 159 | { |
160 | stream >> param1; | 160 | stream >> param1; |
161 | emit receivedMessageFromSource(sourceChannel, uid, param1); | 161 | emit receivedMessageFromSource(sourceChannel, uid, param1); |
162 | } | 162 | } |
163 | else if (_usedSourceParameters == 2) | 163 | else if (_usedSourceParameters == 2) |
164 | { | 164 | { |
165 | stream >> param1 >> param2; | 165 | stream >> param1 >> param2; |
166 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); | 166 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); |
167 | } | 167 | } |
168 | else if (_usedSourceParameters == 3) | 168 | else if (_usedSourceParameters == 3) |
169 | { | 169 | { |
170 | stream >> param1 >> param2 >> param3; | 170 | stream >> param1 >> param2 >> param3; |
171 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); | 171 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); |
172 | } | 172 | } |
173 | 173 | ||
174 | return true; | 174 | return true; |
175 | } | 175 | } |
176 | 176 | ||
177 | return false; | 177 | return false; |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | /********************************************************************************* | 181 | /********************************************************************************* |
182 | * | 182 | * |
183 | ********************************************************************************/ | 183 | ********************************************************************************/ |
184 | 184 | ||
185 | 185 | ||
186 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 186 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
187 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 187 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
188 | { | 188 | { |
189 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | 189 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> |
190 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | 190 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; |
191 | } | 191 | } |
192 | 192 | ||
193 | /*********************************************************************************/ | 193 | /*********************************************************************************/ |
194 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 194 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) |
195 | { | 195 | { |
196 | #ifndef DESKTOP_VERSION | 196 | #ifndef DESKTOP_VERSION |
197 | //targetMessage passes two parameters: uid, map | 197 | //targetMessage passes two parameters: uid, map |
198 | QString targetMessage = _targetMessage + _targetMessageParameters; | 198 | QString targetMessage = _targetMessage + _targetMessageParameters; |
199 | 199 | ||
200 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 200 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
201 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | 201 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); |
202 | 202 | ||
203 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 203 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
204 | //US we need no names in the To field. The emailadresses are enough | 204 | //US we need no names in the To field. The emailadresses are enough |
205 | 205 | ||
206 | e << uid << nameEmailMap; | 206 | e << uid << nameEmailMap; |
207 | 207 | ||
208 | qApp->processEvents(); | 208 | qApp->processEvents(); |
209 | 209 | ||
210 | return true; | 210 | return true; |
211 | 211 | ||
212 | #else | 212 | #else |
213 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 213 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
214 | return false; | 214 | return false; |
215 | #endif | 215 | #endif |
216 | 216 | ||
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | /*********************************************************************************/ | 220 | /*********************************************************************************/ |
221 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 221 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
222 | { | 222 | { |
223 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 223 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
224 | 224 | ||
225 | if (res == false) | 225 | if (res == false) |
226 | { | 226 | { |
227 | QDataStream stream( data, IO_ReadOnly ); | 227 | QDataStream stream( data, IO_ReadOnly ); |
228 | 228 | ||
229 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | 229 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); |
230 | 230 | ||
231 | //we are in the source and get an answer from the target | 231 | //we are in the source and get an answer from the target |
232 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 232 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
233 | { | 233 | { |
234 | QMap<QString,QString> adrMap; | 234 | QMap<QString,QString> adrMap; |
235 | QString uid; | 235 | QString uid; |
236 | 236 | ||
237 | stream >> uid >> adrMap; | 237 | stream >> uid >> adrMap; |
238 | 238 | ||
239 | emit receivedMessageFromTarget(uid, adrMap); | 239 | emit receivedMessageFromTarget(uid, adrMap); |
240 | 240 | ||
241 | 241 | ||
242 | return true; | 242 | return true; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | return false; | 246 | return false; |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | /********************************************************************************* | 250 | /********************************************************************************* |
251 | * | 251 | * |
252 | ********************************************************************************/ | 252 | ********************************************************************************/ |
253 | 253 | ||
254 | 254 | ||
255 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 255 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
256 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 256 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
257 | { | 257 | { |
258 | //targetMessage returns later two parameters: uid, and three lists | 258 | //targetMessage returns later two parameters: uid, and three lists |
259 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; | 259 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; |
260 | } | 260 | } |
261 | 261 | ||
262 | /*********************************************************************************/ | 262 | /*********************************************************************************/ |
263 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 263 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
264 | { | 264 | { |
265 | #ifndef DESKTOP_VERSION | 265 | #ifndef DESKTOP_VERSION |
266 | //targetMessage passes two parameters: uid, map | 266 | //targetMessage passes two parameters: uid, map |
267 | QString targetMessage = _targetMessage + _targetMessageParameters; | 267 | QString targetMessage = _targetMessage + _targetMessageParameters; |
268 | 268 | ||
269 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 269 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
270 | qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); | 270 | qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); |
271 | 271 | ||
272 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 272 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
273 | //US we need no names in the To field. The emailadresses are enough | 273 | //US we need no names in the To field. The emailadresses are enough |
274 | 274 | ||
275 | e << uid << list1 << list2 << list3; | 275 | e << uid << list1 << list2 << list3; |
276 | 276 | ||
277 | qApp->processEvents(); | 277 | qApp->processEvents(); |
278 | 278 | ||
279 | return true; | 279 | return true; |
280 | 280 | ||
281 | #else | 281 | #else |
282 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 282 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
283 | return false; | 283 | return false; |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | /*********************************************************************************/ | 289 | /*********************************************************************************/ |
290 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 290 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
291 | { | 291 | { |
292 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 292 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
293 | 293 | ||
294 | if (res == false) | 294 | if (res == false) |
295 | { | 295 | { |
296 | QDataStream stream( data, IO_ReadOnly ); | 296 | QDataStream stream( data, IO_ReadOnly ); |
297 | 297 | ||
298 | // qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 298 | // qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
299 | 299 | ||
300 | //we are in the source and get an answer from the target | 300 | //we are in the source and get an answer from the target |
301 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 301 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
302 | { | 302 | { |
303 | QStringList list1; | 303 | QStringList list1; |
304 | QStringList list2; | 304 | QStringList list2; |
305 | QStringList list3; | 305 | QStringList list3; |
306 | QString uid; | 306 | QString uid; |
307 | 307 | ||
308 | stream >> uid >> list1 >> list2 >> list3; | 308 | stream >> uid >> list1 >> list2 >> list3; |
309 | |||
310 | emit receivedMessageFromTarget(uid, list1, list2, list3); | 309 | emit receivedMessageFromTarget(uid, list1, list2, list3); |
311 | 310 | ||
312 | 311 | ||
313 | return true; | 312 | return true; |
314 | } | 313 | } |
315 | } | 314 | } |
316 | 315 | ||
317 | return false; | 316 | return false; |
318 | } | 317 | } |
319 | 318 | ||
320 | 319 | ||
321 | 320 | ||
322 | /********************************************************************************* | 321 | /********************************************************************************* |
323 | * | 322 | * |
324 | ********************************************************************************/ | 323 | ********************************************************************************/ |
325 | 324 | ||
326 | 325 | ||
327 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 326 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
328 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 327 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
329 | 328 | ||
330 | ExternalAppHandler::ExternalAppHandler() | 329 | ExternalAppHandler::ExternalAppHandler() |
331 | { | 330 | { |
332 | mDefaultItems.setAutoDelete(true); | 331 | mDefaultItems.setAutoDelete(true); |
333 | 332 | ||
334 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 333 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
335 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 334 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
336 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 335 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
337 | 336 | ||
338 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 337 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
339 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 338 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
340 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 339 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
341 | 340 | ||
342 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 341 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
343 | 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&))); | 342 | 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&))); |
344 | } | 343 | } |
345 | 344 | ||
346 | ExternalAppHandler::~ExternalAppHandler() | 345 | ExternalAppHandler::~ExternalAppHandler() |
347 | { | 346 | { |
348 | } | 347 | } |
349 | 348 | ||
350 | void ExternalAppHandler::loadConfig() | 349 | void ExternalAppHandler::loadConfig() |
351 | { | 350 | { |
352 | 351 | ||
353 | mDefaultItems.clear(); | 352 | mDefaultItems.clear(); |
354 | 353 | ||
355 | mEmailAppAvailable = UNDEFINED; | 354 | mEmailAppAvailable = UNDEFINED; |
356 | mPhoneAppAvailable = UNDEFINED; | 355 | mPhoneAppAvailable = UNDEFINED; |
357 | mFaxAppAvailable = UNDEFINED; | 356 | mFaxAppAvailable = UNDEFINED; |
358 | mSMSAppAvailable = UNDEFINED; | 357 | mSMSAppAvailable = UNDEFINED; |
359 | mPagerAppAvailable = UNDEFINED; | 358 | mPagerAppAvailable = UNDEFINED; |
360 | 359 | ||
361 | 360 | ||
362 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 361 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
363 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 362 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
364 | 363 | ||
365 | if (opiepath.isEmpty()) | 364 | if (opiepath.isEmpty()) |
366 | opiepath = qtopiapath; | 365 | opiepath = qtopiapath; |
367 | 366 | ||
368 | //mailclients | 367 | //mailclients |
369 | QString mailmsg1 = "writeMail(QString,QString)"; | 368 | QString mailmsg1 = "writeMail(QString,QString)"; |
370 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 369 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
371 | 370 | ||
372 | QString undefined = ""; | 371 | QString undefined = ""; |
373 | 372 | ||
374 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 373 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
375 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 374 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
376 | 375 | ||
377 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 376 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
378 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 377 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
379 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 378 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
380 | 379 | ||
381 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 380 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
382 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 381 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
383 | 382 | ||
384 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 383 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
385 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 384 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
386 | 385 | ||
387 | 386 | ||
388 | 387 | ||
389 | //phoneclients | 388 | //phoneclients |
390 | 389 | ||
391 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 390 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
392 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 391 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
393 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 392 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
394 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 393 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
395 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 394 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
396 | 395 | ||
397 | //faxclients | 396 | //faxclients |
398 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 397 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
399 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 398 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
400 | 399 | ||
401 | //smsclients | 400 | //smsclients |
402 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 401 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
403 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 402 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
404 | 403 | ||
405 | //pagerclients | 404 | //pagerclients |
406 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 405 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
407 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 406 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
408 | 407 | ||
409 | } | 408 | } |
410 | 409 | ||
411 | ExternalAppHandler *ExternalAppHandler::instance() | 410 | ExternalAppHandler *ExternalAppHandler::instance() |
412 | { | 411 | { |
413 | if ( !sInstance ) { | 412 | if ( !sInstance ) { |
414 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 413 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
415 | sInstance->loadConfig(); | 414 | sInstance->loadConfig(); |
416 | } | 415 | } |
417 | 416 | ||
418 | return sInstance; | 417 | return sInstance; |
419 | } | 418 | } |
420 | 419 | ||
421 | 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) | 420 | 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) |
422 | { | 421 | { |
423 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 422 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
424 | 423 | ||
425 | mDefaultItems.append(dai); | 424 | mDefaultItems.append(dai); |
426 | } | 425 | } |
427 | 426 | ||
428 | 427 | ||
429 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 428 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
430 | { | 429 | { |
431 | QList<DefaultAppItem> list; | 430 | QList<DefaultAppItem> list; |
432 | 431 | ||
433 | DefaultAppItem* dai; | 432 | DefaultAppItem* dai; |
434 | 433 | ||
435 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 434 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
436 | { | 435 | { |
437 | if (dai->_type == type) | 436 | if (dai->_type == type) |
438 | list.append(dai); | 437 | list.append(dai); |
439 | } | 438 | } |
440 | 439 | ||
441 | return list; | 440 | return list; |
442 | } | 441 | } |
443 | 442 | ||
444 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 443 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
445 | { | 444 | { |
446 | DefaultAppItem* dai; | 445 | DefaultAppItem* dai; |
447 | 446 | ||
448 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 447 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
449 | { | 448 | { |
450 | if (dai->_type == type && dai->_id == clientid) | 449 | if (dai->_type == type && dai->_id == clientid) |
451 | return dai; | 450 | return dai; |
452 | } | 451 | } |
453 | 452 | ||
454 | return 0; | 453 | return 0; |
455 | } | 454 | } |
456 | 455 | ||
457 | bool ExternalAppHandler::isEmailAppAvailable() | 456 | bool ExternalAppHandler::isEmailAppAvailable() |
458 | { | 457 | { |
459 | #ifndef DESKTOP_VERSION | 458 | #ifndef DESKTOP_VERSION |
460 | if (mEmailAppAvailable == UNDEFINED) | 459 | if (mEmailAppAvailable == UNDEFINED) |
461 | { | 460 | { |
462 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 461 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
463 | if (client == KPimGlobalPrefs::NONE_EMC) | 462 | if (client == KPimGlobalPrefs::NONE_EMC) |
464 | mEmailAppAvailable = UNAVAILABLE; | 463 | mEmailAppAvailable = UNAVAILABLE; |
465 | else | 464 | else |
466 | mEmailAppAvailable = AVAILABLE; | 465 | mEmailAppAvailable = AVAILABLE; |
467 | } | 466 | } |
468 | return (mEmailAppAvailable == AVAILABLE); | 467 | return (mEmailAppAvailable == AVAILABLE); |
469 | 468 | ||
470 | #else //DESKTOP_VERSION | 469 | #else //DESKTOP_VERSION |
471 | return false; | 470 | return false; |
472 | #endif //DESKTOP_VERSION | 471 | #endif //DESKTOP_VERSION |
473 | } | 472 | } |
474 | 473 | ||
475 | bool ExternalAppHandler::isSMSAppAvailable() | 474 | bool ExternalAppHandler::isSMSAppAvailable() |
476 | { | 475 | { |
477 | #ifndef DESKTOP_VERSION | 476 | #ifndef DESKTOP_VERSION |
478 | if (mSMSAppAvailable == UNDEFINED) | 477 | if (mSMSAppAvailable == UNDEFINED) |
479 | { | 478 | { |
480 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 479 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
481 | if (client == KPimGlobalPrefs::NONE_SMC) | 480 | if (client == KPimGlobalPrefs::NONE_SMC) |
482 | mSMSAppAvailable = UNAVAILABLE; | 481 | mSMSAppAvailable = UNAVAILABLE; |
483 | else | 482 | else |
484 | mSMSAppAvailable = AVAILABLE; | 483 | mSMSAppAvailable = AVAILABLE; |
485 | } | 484 | } |
486 | 485 | ||
487 | return (mSMSAppAvailable == AVAILABLE); | 486 | return (mSMSAppAvailable == AVAILABLE); |
488 | #else //DESKTOP_VERSION | 487 | #else //DESKTOP_VERSION |
489 | return false; | 488 | return false; |
490 | #endif //DESKTOP_VERSION | 489 | #endif //DESKTOP_VERSION |
491 | } | 490 | } |
492 | 491 | ||
493 | bool ExternalAppHandler::isPhoneAppAvailable() | 492 | bool ExternalAppHandler::isPhoneAppAvailable() |
494 | { | 493 | { |
495 | #ifndef DESKTOP_VERSION | 494 | #ifndef DESKTOP_VERSION |
496 | if (mPhoneAppAvailable == UNDEFINED) | 495 | if (mPhoneAppAvailable == UNDEFINED) |
497 | { | 496 | { |
498 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 497 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
499 | if (client == KPimGlobalPrefs::NONE_PHC) | 498 | if (client == KPimGlobalPrefs::NONE_PHC) |
500 | mPhoneAppAvailable = UNAVAILABLE; | 499 | mPhoneAppAvailable = UNAVAILABLE; |
501 | else | 500 | else |
502 | mPhoneAppAvailable = AVAILABLE; | 501 | mPhoneAppAvailable = AVAILABLE; |
503 | } | 502 | } |
504 | 503 | ||
505 | return (mPhoneAppAvailable == AVAILABLE); | 504 | return (mPhoneAppAvailable == AVAILABLE); |
506 | #else //DESKTOP_VERSION | 505 | #else //DESKTOP_VERSION |
507 | return false; | 506 | return false; |
508 | #endif //DESKTOP_VERSION | 507 | #endif //DESKTOP_VERSION |
509 | } | 508 | } |
510 | 509 | ||
511 | bool ExternalAppHandler::isFaxAppAvailable() | 510 | bool ExternalAppHandler::isFaxAppAvailable() |
512 | { | 511 | { |
513 | #ifndef DESKTOP_VERSION | 512 | #ifndef DESKTOP_VERSION |
514 | if (mFaxAppAvailable == UNDEFINED) | 513 | if (mFaxAppAvailable == UNDEFINED) |
515 | { | 514 | { |
516 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 515 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
517 | if (client == KPimGlobalPrefs::NONE_FAC) | 516 | if (client == KPimGlobalPrefs::NONE_FAC) |
518 | mFaxAppAvailable = UNAVAILABLE; | 517 | mFaxAppAvailable = UNAVAILABLE; |
519 | else | 518 | else |
520 | mFaxAppAvailable = AVAILABLE; | 519 | mFaxAppAvailable = AVAILABLE; |
521 | } | 520 | } |
522 | 521 | ||
523 | return (mFaxAppAvailable == AVAILABLE); | 522 | return (mFaxAppAvailable == AVAILABLE); |
524 | #else //DESKTOP_VERSION | 523 | #else //DESKTOP_VERSION |
525 | return false; | 524 | return false; |
526 | #endif //DESKTOP_VERSION | 525 | #endif //DESKTOP_VERSION |
527 | } | 526 | } |
528 | 527 | ||
529 | bool ExternalAppHandler::isPagerAppAvailable() | 528 | bool ExternalAppHandler::isPagerAppAvailable() |
530 | { | 529 | { |
531 | #ifndef DESKTOP_VERSION | 530 | #ifndef DESKTOP_VERSION |
532 | if (mPagerAppAvailable == UNDEFINED) | 531 | if (mPagerAppAvailable == UNDEFINED) |
533 | { | 532 | { |
534 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 533 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
535 | if (client == KPimGlobalPrefs::NONE_PAC) | 534 | if (client == KPimGlobalPrefs::NONE_PAC) |
536 | mPagerAppAvailable = UNAVAILABLE; | 535 | mPagerAppAvailable = UNAVAILABLE; |
537 | else | 536 | else |
538 | mPagerAppAvailable = AVAILABLE; | 537 | mPagerAppAvailable = AVAILABLE; |
539 | } | 538 | } |
540 | 539 | ||
541 | return (mPagerAppAvailable == AVAILABLE); | 540 | return (mPagerAppAvailable == AVAILABLE); |
542 | #else //DESKTOP_VERSION | 541 | #else //DESKTOP_VERSION |
543 | return false; | 542 | return false; |
544 | #endif //DESKTOP_VERSION | 543 | #endif //DESKTOP_VERSION |
545 | } | 544 | } |
546 | 545 | ||
547 | /************************************************************************** | 546 | /************************************************************************** |
548 | * | 547 | * |
549 | **************************************************************************/ | 548 | **************************************************************************/ |
550 | 549 | ||
551 | 550 | ||
552 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 551 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
553 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 552 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
554 | { | 553 | { |
555 | 554 | ||
556 | #ifndef DESKTOP_VERSION | 555 | #ifndef DESKTOP_VERSION |
557 | QString channel; | 556 | QString channel; |
558 | QString message2; | 557 | QString message2; |
559 | QString parameters2; | 558 | QString parameters2; |
560 | 559 | ||
561 | 560 | ||
562 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 561 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
563 | if (client == KPimGlobalPrefs::OTHER_EMC) | 562 | if (client == KPimGlobalPrefs::OTHER_EMC) |
564 | { | 563 | { |
565 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 564 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
566 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 565 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
567 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 566 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
568 | } | 567 | } |
569 | else | 568 | else |
570 | { | 569 | { |
571 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 570 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
572 | if (!dai) | 571 | if (!dai) |
573 | { | 572 | { |
574 | qDebug("could not find configured email application."); | 573 | qDebug("could not find configured email application."); |
575 | return false; | 574 | return false; |
576 | } | 575 | } |
577 | channel = dai->_channel; | 576 | channel = dai->_channel; |
578 | message2 = dai->_message2; | 577 | message2 = dai->_message2; |
579 | parameters2 = dai->_parameters2; | 578 | parameters2 = dai->_parameters2; |
580 | } | 579 | } |
581 | 580 | ||
582 | //first check if one of the mailers need the emails right in the message. | 581 | //first check if one of the mailers need the emails right in the message. |
583 | message2 = translateMessage(message2, emails, urls); | 582 | message2 = translateMessage(message2, emails, urls); |
584 | 583 | ||
585 | 584 | ||
586 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 585 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
587 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 586 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
588 | 587 | ||
589 | 588 | ||
590 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 589 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
591 | //US we need no names in the To field. The emailadresses are enough | 590 | //US we need no names in the To field. The emailadresses are enough |
592 | 591 | ||
593 | passParameters(&e, parameters2, emails, urls); | 592 | passParameters(&e, parameters2, emails, urls); |
594 | 593 | ||
595 | 594 | ||
596 | 595 | ||
597 | #else | 596 | #else |
598 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 597 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
599 | #endif | 598 | #endif |
600 | 599 | ||
601 | return true; | 600 | return true; |
602 | } | 601 | } |
603 | 602 | ||
604 | /************************************************************************** | 603 | /************************************************************************** |
605 | * | 604 | * |
606 | **************************************************************************/ | 605 | **************************************************************************/ |
607 | 606 | ||
608 | 607 | ||
609 | //calls the emailapplication and creates a mail with parameter emails as recipients | 608 | //calls the emailapplication and creates a mail with parameter emails as recipients |
610 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 609 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
611 | { | 610 | { |
612 | #ifndef DESKTOP_VERSION | 611 | #ifndef DESKTOP_VERSION |
613 | QString channel; | 612 | QString channel; |
614 | QString message; | 613 | QString message; |
615 | QString parameters; | 614 | QString parameters; |
616 | 615 | ||
617 | 616 | ||
618 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 617 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
619 | if (client == KPimGlobalPrefs::OTHER_EMC) | 618 | if (client == KPimGlobalPrefs::OTHER_EMC) |
620 | { | 619 | { |
621 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 620 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
622 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 621 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
623 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 622 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
624 | } | 623 | } |
625 | else | 624 | else |
626 | { | 625 | { |
627 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 626 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
628 | if (!dai) | 627 | if (!dai) |
629 | { | 628 | { |
630 | qDebug("could not find configured email application."); | 629 | qDebug("could not find configured email application."); |
631 | return false; | 630 | return false; |
632 | } | 631 | } |
633 | channel = dai->_channel; | 632 | channel = dai->_channel; |
634 | message = dai->_message; | 633 | message = dai->_message; |
635 | parameters = dai->_parameters; | 634 | parameters = dai->_parameters; |
636 | } | 635 | } |
637 | 636 | ||
638 | 637 | ||
639 | //first check if one of the mailers need the emails right in the message. | 638 | //first check if one of the mailers need the emails right in the message. |
640 | message = translateMessage(message, name, emailadress); | 639 | message = translateMessage(message, name, emailadress); |
641 | 640 | ||
642 | 641 | ||
643 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 642 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
644 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 643 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
645 | 644 | ||
646 | QCopEnvelope e(channel.latin1(), message.latin1()); | 645 | QCopEnvelope e(channel.latin1(), message.latin1()); |
647 | //US we need no names in the To field. The emailadresses are enough | 646 | //US we need no names in the To field. The emailadresses are enough |
648 | 647 | ||
649 | passParameters(&e, parameters, name, emailadress); | 648 | passParameters(&e, parameters, name, emailadress); |
650 | 649 | ||
651 | 650 | ||
652 | #else | 651 | #else |
653 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 652 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
654 | #endif | 653 | #endif |
655 | 654 | ||
656 | 655 | ||
657 | return true; | 656 | return true; |
658 | } | 657 | } |
659 | 658 | ||
660 | /************************************************************************** | 659 | /************************************************************************** |
661 | * | 660 | * |
662 | **************************************************************************/ | 661 | **************************************************************************/ |
663 | 662 | ||
664 | //calls the emailapplication and creates a mail with parameter as recipients | 663 | //calls the emailapplication and creates a mail with parameter as recipients |
665 | // parameters format is | 664 | // parameters format is |
666 | // NAME <EMAIL>:SUBJECT | 665 | // NAME <EMAIL>:SUBJECT |
667 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 666 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
668 | { | 667 | { |
669 | QString line = adressline; | 668 | QString line = adressline; |
670 | 669 | ||
671 | int first = line.find( "<"); | 670 | int first = line.find( "<"); |
672 | int last = line.find( ">"); | 671 | int last = line.find( ">"); |
673 | QString name = line.left(first); | 672 | QString name = line.left(first); |
674 | QString emailadress = line.mid(first+1, last-first-1); | 673 | QString emailadress = line.mid(first+1, last-first-1); |
675 | 674 | ||
676 | //Subject can not be handled right now. | 675 | //Subject can not be handled right now. |
677 | return mailToOneContact( name, emailadress ); | 676 | return mailToOneContact( name, emailadress ); |
678 | 677 | ||
679 | } | 678 | } |
680 | 679 | ||
681 | 680 | ||
682 | /************************************************************************** | 681 | /************************************************************************** |
683 | * | 682 | * |
684 | **************************************************************************/ | 683 | **************************************************************************/ |
685 | 684 | ||
686 | //calls the phoneapplication with the number | 685 | //calls the phoneapplication with the number |
687 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 686 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
688 | { | 687 | { |
689 | #ifndef DESKTOP_VERSION | 688 | #ifndef DESKTOP_VERSION |
690 | QString channel; | 689 | QString channel; |
691 | QString message; | 690 | QString message; |
692 | QString parameters; | 691 | QString parameters; |
693 | 692 | ||
694 | 693 | ||
695 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 694 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
696 | if (client == KPimGlobalPrefs::OTHER_PHC) | 695 | if (client == KPimGlobalPrefs::OTHER_PHC) |
697 | { | 696 | { |
698 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 697 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
699 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 698 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
700 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 699 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
701 | } | 700 | } |
702 | else | 701 | else |
703 | { | 702 | { |
704 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 703 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
705 | if (!dai) | 704 | if (!dai) |
706 | { | 705 | { |
707 | qDebug("could not find configured phone application."); | 706 | qDebug("could not find configured phone application."); |
708 | return false; | 707 | return false; |
709 | } | 708 | } |
710 | channel = dai->_channel; | 709 | channel = dai->_channel; |
711 | message = dai->_message; | 710 | message = dai->_message; |
712 | parameters = dai->_parameters; | 711 | parameters = dai->_parameters; |
713 | } | 712 | } |
714 | 713 | ||
715 | 714 | ||
716 | //first check if one of the mailers need the emails right in the message. | 715 | //first check if one of the mailers need the emails right in the message. |
717 | message = translateMessage(message, phonenumber, ""); | 716 | message = translateMessage(message, phonenumber, ""); |
718 | 717 | ||
719 | 718 | ||
720 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 719 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
721 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 720 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
722 | 721 | ||
723 | QCopEnvelope e(channel.latin1(), message.latin1()); | 722 | QCopEnvelope e(channel.latin1(), message.latin1()); |
724 | //US we need no names in the To field. The emailadresses are enough | 723 | //US we need no names in the To field. The emailadresses are enough |
725 | 724 | ||
726 | passParameters(&e, parameters, phonenumber, ""); | 725 | passParameters(&e, parameters, phonenumber, ""); |
727 | 726 | ||
728 | 727 | ||
729 | #else | 728 | #else |
730 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 729 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
731 | #endif | 730 | #endif |
732 | 731 | ||
733 | 732 | ||
734 | return true; | 733 | return true; |
735 | } | 734 | } |
736 | 735 | ||
737 | /************************************************************************** | 736 | /************************************************************************** |
738 | * | 737 | * |
739 | **************************************************************************/ | 738 | **************************************************************************/ |
740 | 739 | ||
741 | //calls the smsapplication with the number | 740 | //calls the smsapplication with the number |
742 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 741 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
743 | { | 742 | { |
744 | #ifndef DESKTOP_VERSION | 743 | #ifndef DESKTOP_VERSION |
745 | QString channel; | 744 | QString channel; |
746 | QString message; | 745 | QString message; |
747 | QString parameters; | 746 | QString parameters; |
748 | 747 | ||
749 | 748 | ||
750 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 749 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
751 | if (client == KPimGlobalPrefs::OTHER_SMC) | 750 | if (client == KPimGlobalPrefs::OTHER_SMC) |
752 | { | 751 | { |
753 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 752 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
754 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 753 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
755 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 754 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
756 | } | 755 | } |
757 | else | 756 | else |
758 | { | 757 | { |
759 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 758 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
760 | if (!dai) | 759 | if (!dai) |
761 | { | 760 | { |
762 | qDebug("could not find configured sms application."); | 761 | qDebug("could not find configured sms application."); |
763 | return false; | 762 | return false; |
764 | } | 763 | } |
765 | channel = dai->_channel; | 764 | channel = dai->_channel; |
766 | message = dai->_message; | 765 | message = dai->_message; |
767 | parameters = dai->_parameters; | 766 | parameters = dai->_parameters; |
768 | } | 767 | } |
769 | 768 | ||
770 | 769 | ||
771 | //first check if one of the mailers need the emails right in the message. | 770 | //first check if one of the mailers need the emails right in the message. |
772 | message = translateMessage(message, phonenumber, ""); | 771 | message = translateMessage(message, phonenumber, ""); |
773 | 772 | ||
774 | 773 | ||
775 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 774 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
776 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 775 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
777 | 776 | ||
778 | QCopEnvelope e(channel.latin1(), message.latin1()); | 777 | QCopEnvelope e(channel.latin1(), message.latin1()); |
779 | //US we need no names in the To field. The emailadresses are enough | 778 | //US we need no names in the To field. The emailadresses are enough |
780 | 779 | ||
781 | passParameters(&e, parameters, phonenumber, ""); | 780 | passParameters(&e, parameters, phonenumber, ""); |
782 | 781 | ||
783 | 782 | ||
784 | #else | 783 | #else |
785 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 784 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
786 | #endif | 785 | #endif |
787 | 786 | ||
788 | 787 | ||
789 | return true; | 788 | return true; |
790 | } | 789 | } |
791 | 790 | ||
792 | /************************************************************************** | 791 | /************************************************************************** |
793 | * | 792 | * |
794 | **************************************************************************/ | 793 | **************************************************************************/ |
795 | 794 | ||
796 | //calls the pagerapplication with the number | 795 | //calls the pagerapplication with the number |
797 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 796 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
798 | { | 797 | { |
799 | #ifndef DESKTOP_VERSION | 798 | #ifndef DESKTOP_VERSION |
800 | QString channel; | 799 | QString channel; |
801 | QString message; | 800 | QString message; |
802 | QString parameters; | 801 | QString parameters; |
803 | 802 | ||
804 | 803 | ||
805 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 804 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
806 | if (client == KPimGlobalPrefs::OTHER_PAC) | 805 | if (client == KPimGlobalPrefs::OTHER_PAC) |
807 | { | 806 | { |
808 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 807 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
809 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 808 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
810 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 809 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
811 | } | 810 | } |
812 | else | 811 | else |
813 | { | 812 | { |
814 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 813 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
815 | if (!dai) | 814 | if (!dai) |
816 | { | 815 | { |
817 | qDebug("could not find configured pager application."); | 816 | qDebug("could not find configured pager application."); |
818 | return false; | 817 | return false; |
819 | } | 818 | } |
820 | channel = dai->_channel; | 819 | channel = dai->_channel; |
821 | message = dai->_message; | 820 | message = dai->_message; |
822 | parameters = dai->_parameters; | 821 | parameters = dai->_parameters; |
823 | } | 822 | } |
824 | 823 | ||
825 | 824 | ||
826 | //first check if one of the mailers need the emails right in the message. | 825 | //first check if one of the mailers need the emails right in the message. |
827 | message = translateMessage(message, pagernumber, ""); | 826 | message = translateMessage(message, pagernumber, ""); |
828 | 827 | ||
829 | 828 | ||
830 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 829 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
831 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 830 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
832 | 831 | ||
833 | QCopEnvelope e(channel.latin1(), message.latin1()); | 832 | QCopEnvelope e(channel.latin1(), message.latin1()); |
834 | //US we need no names in the To field. The emailadresses are enough | 833 | //US we need no names in the To field. The emailadresses are enough |
835 | 834 | ||
836 | passParameters(&e, parameters, pagernumber, ""); | 835 | passParameters(&e, parameters, pagernumber, ""); |
837 | 836 | ||
838 | 837 | ||
839 | #else | 838 | #else |
840 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 839 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
841 | #endif | 840 | #endif |
842 | 841 | ||
843 | 842 | ||
844 | return true; | 843 | return true; |
845 | } | 844 | } |
846 | 845 | ||
847 | /************************************************************************** | 846 | /************************************************************************** |
848 | * | 847 | * |
849 | **************************************************************************/ | 848 | **************************************************************************/ |
850 | 849 | ||
851 | //calls the faxapplication with the number | 850 | //calls the faxapplication with the number |
852 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 851 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
853 | { | 852 | { |
854 | #ifndef DESKTOP_VERSION | 853 | #ifndef DESKTOP_VERSION |
855 | QString channel; | 854 | QString channel; |
856 | QString message; | 855 | QString message; |
857 | QString parameters; | 856 | QString parameters; |
858 | 857 | ||
859 | 858 | ||
860 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 859 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
861 | if (client == KPimGlobalPrefs::OTHER_FAC) | 860 | if (client == KPimGlobalPrefs::OTHER_FAC) |
862 | { | 861 | { |
863 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 862 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
864 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 863 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
865 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 864 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
866 | } | 865 | } |
867 | else | 866 | else |
868 | { | 867 | { |
869 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 868 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
870 | if (!dai) | 869 | if (!dai) |
871 | { | 870 | { |
872 | qDebug("could not find configured fax application."); | 871 | qDebug("could not find configured fax application."); |
873 | return false; | 872 | return false; |
874 | } | 873 | } |
875 | channel = dai->_channel; | 874 | channel = dai->_channel; |
876 | message = dai->_message; | 875 | message = dai->_message; |
877 | parameters = dai->_parameters; | 876 | parameters = dai->_parameters; |
878 | } | 877 | } |
879 | 878 | ||
880 | 879 | ||
881 | //first check if one of the mailers need the emails right in the message. | 880 | //first check if one of the mailers need the emails right in the message. |
882 | message = translateMessage(message, faxnumber, ""); | 881 | message = translateMessage(message, faxnumber, ""); |
883 | 882 | ||
884 | 883 | ||
885 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 884 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
886 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 885 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
887 | 886 | ||
888 | QCopEnvelope e(channel.latin1(), message.latin1()); | 887 | QCopEnvelope e(channel.latin1(), message.latin1()); |
889 | //US we need no names in the To field. The emailadresses are enough | 888 | //US we need no names in the To field. The emailadresses are enough |
890 | 889 | ||
891 | passParameters(&e, parameters, faxnumber, ""); | 890 | passParameters(&e, parameters, faxnumber, ""); |
892 | 891 | ||
893 | 892 | ||
894 | #else | 893 | #else |
895 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 894 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
896 | #endif | 895 | #endif |
897 | 896 | ||
898 | 897 | ||
899 | return true; | 898 | return true; |
900 | } | 899 | } |
901 | 900 | ||
902 | /************************************************************************** | 901 | /************************************************************************** |
903 | * | 902 | * |
904 | **************************************************************************/ | 903 | **************************************************************************/ |
905 | 904 | ||
906 | 905 | ||
907 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 906 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
908 | { | 907 | { |
909 | message = message.replace( QRegExp("%1"), param1 ); | 908 | message = message.replace( QRegExp("%1"), param1 ); |
910 | return message.replace( QRegExp("%2"), param2 ); | 909 | return message.replace( QRegExp("%2"), param2 ); |
911 | } | 910 | } |
912 | 911 | ||
913 | /************************************************************************** | 912 | /************************************************************************** |
914 | * | 913 | * |
915 | **************************************************************************/ | 914 | **************************************************************************/ |
916 | 915 | ||
917 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 916 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
918 | { | 917 | { |
919 | #ifndef DESKTOP_VERSION | 918 | #ifndef DESKTOP_VERSION |
920 | QMap<QString, QString> valmap; | 919 | QMap<QString, QString> valmap; |
921 | bool useValMap = false; | 920 | bool useValMap = false; |
922 | 921 | ||
923 | // first extract all parts of the parameters. | 922 | // first extract all parts of the parameters. |
924 | QStringList paramlist = QStringList::split(";", parameters); | 923 | QStringList paramlist = QStringList::split(";", parameters); |
925 | 924 | ||
926 | //Now check how many parts we have. | 925 | //Now check how many parts we have. |
927 | //=0 :no params to pass | 926 | //=0 :no params to pass |
928 | //>0 :parameters to pass | 927 | //>0 :parameters to pass |
929 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 928 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
930 | { | 929 | { |
931 | QString param = (*it); | 930 | QString param = (*it); |
932 | QStringList keyvallist = QStringList::split("=", param); | 931 | QStringList keyvallist = QStringList::split("=", param); |
933 | 932 | ||
934 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 933 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
935 | QStringList::Iterator it2 = keyvallist.begin(); | 934 | QStringList::Iterator it2 = keyvallist.begin(); |
936 | QString key = (*it2); | 935 | QString key = (*it2); |
937 | key = key.replace( QRegExp("%1"), param1 ); | 936 | key = key.replace( QRegExp("%1"), param1 ); |
938 | key = key.replace( QRegExp("%2"), param2 ); | 937 | key = key.replace( QRegExp("%2"), param2 ); |
939 | ++it2; | 938 | ++it2; |
940 | 939 | ||
941 | if(it2 != keyvallist.end()) | 940 | if(it2 != keyvallist.end()) |
942 | { | 941 | { |
943 | QString value = (*it2); | 942 | QString value = (*it2); |
944 | value = value.replace( QRegExp("%1"), param1 ); | 943 | value = value.replace( QRegExp("%1"), param1 ); |
945 | value = value.replace( QRegExp("%2"), param2 ); | 944 | value = value.replace( QRegExp("%2"), param2 ); |
946 | 945 | ||
947 | valmap.insert(key, value); | 946 | valmap.insert(key, value); |
948 | useValMap = true; | 947 | useValMap = true; |
949 | } | 948 | } |
950 | else | 949 | else |
951 | { | 950 | { |
952 | // qDebug("pass parameter << %s", key.latin1()); | 951 | // qDebug("pass parameter << %s", key.latin1()); |
953 | (*e) << key; | 952 | (*e) << key; |
954 | } | 953 | } |
955 | } | 954 | } |
956 | 955 | ||
957 | if (useValMap == true) | 956 | if (useValMap == true) |
958 | (*e) << valmap; | 957 | (*e) << valmap; |
959 | 958 | ||
960 | #endif | 959 | #endif |
961 | 960 | ||
962 | } | 961 | } |
963 | 962 | ||
964 | 963 | ||
965 | 964 | ||
966 | /************************************************************************** | 965 | /************************************************************************** |
967 | * | 966 | * |
968 | **************************************************************************/ | 967 | **************************************************************************/ |
969 | 968 | ||
970 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 969 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
971 | { | 970 | { |
972 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 971 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
973 | |||
974 | if (!res) | 972 | if (!res) |
975 | res = mDisplayDetails->appMessage( cmsg, data ); | 973 | res = mDisplayDetails->appMessage( cmsg, data ); |
976 | 974 | ||
977 | // if (!res) | 975 | // if (!res) |
978 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 976 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
979 | } | 977 | } |
980 | 978 | ||
981 | 979 | ||
982 | 980 | ||
983 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 981 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
984 | { | 982 | { |
985 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 983 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
986 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 984 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
987 | } | 985 | } |
988 | 986 | ||
989 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 987 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
990 | { | 988 | { |
991 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 989 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
992 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); | 990 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); |
993 | } | 991 | } |
994 | 992 | ||
995 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 993 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
996 | { | 994 | { |
997 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 995 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
998 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 996 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
999 | } | 997 | } |
1000 | 998 | ||
1001 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 999 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1002 | { | 1000 | { |
1003 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1001 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1004 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); | 1002 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); |
1005 | } | 1003 | } |
1006 | 1004 | ||
1007 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1005 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1008 | { | 1006 | { |
1009 | mDisplayDetails->setSourceChannel(""); | 1007 | mDisplayDetails->setSourceChannel(""); |
1010 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1008 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1011 | } | 1009 | } |
1012 | 1010 | ||
1013 | 1011 | ||
1014 | 1012 | ||
1015 | 1013 | ||
1016 | 1014 | ||