author | ulf69 <ulf69> | 2004-09-16 17:25:06 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-16 17:25:06 (UTC) |
commit | b6bfa63deb15a2600d46a8c68c231f068da1444a (patch) (unidiff) | |
tree | 271c22bdf98d05d1c0acbd56e5c570f56baa9b5d /libkdepim/externalapphandler.cpp | |
parent | c32d7e58ca69196426eee3217140227aca634f52 (diff) | |
download | kdepimpi-b6bfa63deb15a2600d46a8c68c231f068da1444a.zip kdepimpi-b6bfa63deb15a2600d46a8c68c231f068da1444a.tar.gz kdepimpi-b6bfa63deb15a2600d46a8c68c231f068da1444a.tar.bz2 |
added sip support to external applications and display sip numbers as hyperlink
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/externalapphandler.cpp | 81 |
1 files changed, 80 insertions, 1 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 5ba32b6..fa56ee9 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,1013 +1,1092 @@ | |||
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 | emit receivedMessageFromTarget(uid, list1, list2, list3); | 309 | emit receivedMessageFromTarget(uid, list1, list2, list3); |
310 | 310 | ||
311 | 311 | ||
312 | return true; | 312 | return true; |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | return false; | 316 | return false; |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | 320 | ||
321 | /********************************************************************************* | 321 | /********************************************************************************* |
322 | * | 322 | * |
323 | ********************************************************************************/ | 323 | ********************************************************************************/ |
324 | 324 | ||
325 | 325 | ||
326 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 326 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
327 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 327 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
328 | 328 | ||
329 | ExternalAppHandler::ExternalAppHandler() | 329 | ExternalAppHandler::ExternalAppHandler() |
330 | { | 330 | { |
331 | mDefaultItems.setAutoDelete(true); | 331 | mDefaultItems.setAutoDelete(true); |
332 | 332 | ||
333 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 333 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
334 | 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&))); |
335 | 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&))); |
336 | 336 | ||
337 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 337 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
338 | //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&))); |
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&))); | 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&))); |
340 | 340 | ||
341 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 341 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
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&))); | 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&))); |
343 | } | 343 | } |
344 | 344 | ||
345 | ExternalAppHandler::~ExternalAppHandler() | 345 | ExternalAppHandler::~ExternalAppHandler() |
346 | { | 346 | { |
347 | } | 347 | } |
348 | 348 | ||
349 | void ExternalAppHandler::loadConfig() | 349 | void ExternalAppHandler::loadConfig() |
350 | { | 350 | { |
351 | 351 | ||
352 | mDefaultItems.clear(); | 352 | mDefaultItems.clear(); |
353 | mEmailAppAvailable = UNDEFINED; | 353 | mEmailAppAvailable = UNDEFINED; |
354 | mPhoneAppAvailable = UNDEFINED; | 354 | mPhoneAppAvailable = UNDEFINED; |
355 | mFaxAppAvailable = UNDEFINED; | 355 | mFaxAppAvailable = UNDEFINED; |
356 | mSMSAppAvailable = UNDEFINED; | 356 | mSMSAppAvailable = UNDEFINED; |
357 | mPagerAppAvailable = UNDEFINED; | 357 | mPagerAppAvailable = UNDEFINED; |
358 | 358 | mSIPAppAvailable = UNDEFINED; | |
359 | 359 | ||
360 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 360 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
361 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 361 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
362 | 362 | ||
363 | if (opiepath.isEmpty()) | 363 | if (opiepath.isEmpty()) |
364 | opiepath = qtopiapath; | 364 | opiepath = qtopiapath; |
365 | 365 | ||
366 | //mailclients | 366 | //mailclients |
367 | QString mailmsg1 = "writeMail(QString,QString)"; | 367 | QString mailmsg1 = "writeMail(QString,QString)"; |
368 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 368 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
369 | 369 | ||
370 | QString undefined = ""; | 370 | QString undefined = ""; |
371 | 371 | ||
372 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 372 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
373 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 373 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
374 | 374 | ||
375 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 375 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
376 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 376 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
377 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 377 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
378 | 378 | ||
379 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 379 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
380 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 380 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
381 | 381 | ||
382 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 382 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
383 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 383 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
384 | 384 | ||
385 | 385 | ||
386 | 386 | ||
387 | //phoneclients | 387 | //phoneclients |
388 | 388 | ||
389 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 389 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
390 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 390 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
391 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 391 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
392 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 392 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
393 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 393 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
394 | 394 | ||
395 | //faxclients | 395 | //faxclients |
396 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 396 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
397 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 397 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
398 | 398 | ||
399 | //smsclients | 399 | //smsclients |
400 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 400 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
401 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 401 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
402 | 402 | ||
403 | //pagerclients | 403 | //pagerclients |
404 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 404 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
405 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 405 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
406 | 406 | ||
407 | //sipclients | ||
408 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined); | ||
409 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined); | ||
410 | |||
407 | } | 411 | } |
408 | 412 | ||
409 | ExternalAppHandler *ExternalAppHandler::instance() | 413 | ExternalAppHandler *ExternalAppHandler::instance() |
410 | { | 414 | { |
411 | if ( !sInstance ) { | 415 | if ( !sInstance ) { |
412 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 416 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
413 | sInstance->loadConfig(); | 417 | sInstance->loadConfig(); |
414 | } | 418 | } |
415 | 419 | ||
416 | return sInstance; | 420 | return sInstance; |
417 | } | 421 | } |
418 | 422 | ||
419 | 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) | 423 | 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 | { | 424 | { |
421 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 425 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
422 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 426 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
423 | mDefaultItems.append(dai); | 427 | mDefaultItems.append(dai); |
424 | } | 428 | } |
425 | 429 | ||
426 | 430 | ||
427 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 431 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
428 | { | 432 | { |
429 | QList<DefaultAppItem> list; | 433 | QList<DefaultAppItem> list; |
430 | 434 | ||
431 | DefaultAppItem* dai; | 435 | DefaultAppItem* dai; |
432 | 436 | ||
433 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 437 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
434 | { | 438 | { |
435 | if (dai->_type == type) | 439 | if (dai->_type == type) |
436 | list.append(dai); | 440 | list.append(dai); |
437 | } | 441 | } |
438 | 442 | ||
439 | return list; | 443 | return list; |
440 | } | 444 | } |
441 | 445 | ||
442 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 446 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
443 | { | 447 | { |
444 | DefaultAppItem* dai; | 448 | DefaultAppItem* dai; |
445 | 449 | ||
446 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 450 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
447 | { | 451 | { |
448 | if (dai->_type == type && dai->_id == clientid) | 452 | if (dai->_type == type && dai->_id == clientid) |
449 | return dai; | 453 | return dai; |
450 | } | 454 | } |
451 | 455 | ||
452 | return 0; | 456 | return 0; |
453 | } | 457 | } |
454 | 458 | ||
455 | bool ExternalAppHandler::isEmailAppAvailable() | 459 | bool ExternalAppHandler::isEmailAppAvailable() |
456 | { | 460 | { |
457 | #ifndef DESKTOP_VERSION | 461 | #ifndef DESKTOP_VERSION |
458 | if (mEmailAppAvailable == UNDEFINED) | 462 | if (mEmailAppAvailable == UNDEFINED) |
459 | { | 463 | { |
460 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 464 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
461 | if (client == KPimGlobalPrefs::NONE_EMC) | 465 | if (client == KPimGlobalPrefs::NONE_EMC) |
462 | mEmailAppAvailable = UNAVAILABLE; | 466 | mEmailAppAvailable = UNAVAILABLE; |
463 | else | 467 | else |
464 | mEmailAppAvailable = AVAILABLE; | 468 | mEmailAppAvailable = AVAILABLE; |
465 | } | 469 | } |
466 | return (mEmailAppAvailable == AVAILABLE); | 470 | return (mEmailAppAvailable == AVAILABLE); |
467 | 471 | ||
468 | #else //DESKTOP_VERSION | 472 | #else //DESKTOP_VERSION |
469 | return false; | 473 | return false; |
470 | #endif //DESKTOP_VERSION | 474 | #endif //DESKTOP_VERSION |
471 | } | 475 | } |
472 | 476 | ||
473 | bool ExternalAppHandler::isSMSAppAvailable() | 477 | bool ExternalAppHandler::isSMSAppAvailable() |
474 | { | 478 | { |
475 | #ifndef DESKTOP_VERSION | 479 | #ifndef DESKTOP_VERSION |
476 | if (mSMSAppAvailable == UNDEFINED) | 480 | if (mSMSAppAvailable == UNDEFINED) |
477 | { | 481 | { |
478 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 482 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
479 | if (client == KPimGlobalPrefs::NONE_SMC) | 483 | if (client == KPimGlobalPrefs::NONE_SMC) |
480 | mSMSAppAvailable = UNAVAILABLE; | 484 | mSMSAppAvailable = UNAVAILABLE; |
481 | else | 485 | else |
482 | mSMSAppAvailable = AVAILABLE; | 486 | mSMSAppAvailable = AVAILABLE; |
483 | } | 487 | } |
484 | 488 | ||
485 | return (mSMSAppAvailable == AVAILABLE); | 489 | return (mSMSAppAvailable == AVAILABLE); |
486 | #else //DESKTOP_VERSION | 490 | #else //DESKTOP_VERSION |
487 | return false; | 491 | return false; |
488 | #endif //DESKTOP_VERSION | 492 | #endif //DESKTOP_VERSION |
489 | } | 493 | } |
490 | 494 | ||
491 | bool ExternalAppHandler::isPhoneAppAvailable() | 495 | bool ExternalAppHandler::isPhoneAppAvailable() |
492 | { | 496 | { |
493 | #ifndef DESKTOP_VERSION | 497 | #ifndef DESKTOP_VERSION |
494 | if (mPhoneAppAvailable == UNDEFINED) | 498 | if (mPhoneAppAvailable == UNDEFINED) |
495 | { | 499 | { |
496 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 500 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
497 | if (client == KPimGlobalPrefs::NONE_PHC) | 501 | if (client == KPimGlobalPrefs::NONE_PHC) |
498 | mPhoneAppAvailable = UNAVAILABLE; | 502 | mPhoneAppAvailable = UNAVAILABLE; |
499 | else | 503 | else |
500 | mPhoneAppAvailable = AVAILABLE; | 504 | mPhoneAppAvailable = AVAILABLE; |
501 | } | 505 | } |
502 | 506 | ||
503 | return (mPhoneAppAvailable == AVAILABLE); | 507 | return (mPhoneAppAvailable == AVAILABLE); |
504 | #else //DESKTOP_VERSION | 508 | #else //DESKTOP_VERSION |
505 | return false; | 509 | return false; |
506 | #endif //DESKTOP_VERSION | 510 | #endif //DESKTOP_VERSION |
507 | } | 511 | } |
508 | 512 | ||
509 | bool ExternalAppHandler::isFaxAppAvailable() | 513 | bool ExternalAppHandler::isFaxAppAvailable() |
510 | { | 514 | { |
511 | #ifndef DESKTOP_VERSION | 515 | #ifndef DESKTOP_VERSION |
512 | if (mFaxAppAvailable == UNDEFINED) | 516 | if (mFaxAppAvailable == UNDEFINED) |
513 | { | 517 | { |
514 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 518 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
515 | if (client == KPimGlobalPrefs::NONE_FAC) | 519 | if (client == KPimGlobalPrefs::NONE_FAC) |
516 | mFaxAppAvailable = UNAVAILABLE; | 520 | mFaxAppAvailable = UNAVAILABLE; |
517 | else | 521 | else |
518 | mFaxAppAvailable = AVAILABLE; | 522 | mFaxAppAvailable = AVAILABLE; |
519 | } | 523 | } |
520 | 524 | ||
521 | return (mFaxAppAvailable == AVAILABLE); | 525 | return (mFaxAppAvailable == AVAILABLE); |
522 | #else //DESKTOP_VERSION | 526 | #else //DESKTOP_VERSION |
523 | return false; | 527 | return false; |
524 | #endif //DESKTOP_VERSION | 528 | #endif //DESKTOP_VERSION |
525 | } | 529 | } |
526 | 530 | ||
527 | bool ExternalAppHandler::isPagerAppAvailable() | 531 | bool ExternalAppHandler::isPagerAppAvailable() |
528 | { | 532 | { |
529 | #ifndef DESKTOP_VERSION | 533 | #ifndef DESKTOP_VERSION |
530 | if (mPagerAppAvailable == UNDEFINED) | 534 | if (mPagerAppAvailable == UNDEFINED) |
531 | { | 535 | { |
532 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 536 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
533 | if (client == KPimGlobalPrefs::NONE_PAC) | 537 | if (client == KPimGlobalPrefs::NONE_PAC) |
534 | mPagerAppAvailable = UNAVAILABLE; | 538 | mPagerAppAvailable = UNAVAILABLE; |
535 | else | 539 | else |
536 | mPagerAppAvailable = AVAILABLE; | 540 | mPagerAppAvailable = AVAILABLE; |
537 | } | 541 | } |
538 | 542 | ||
539 | return (mPagerAppAvailable == AVAILABLE); | 543 | return (mPagerAppAvailable == AVAILABLE); |
540 | #else //DESKTOP_VERSION | 544 | #else //DESKTOP_VERSION |
541 | return false; | 545 | return false; |
542 | #endif //DESKTOP_VERSION | 546 | #endif //DESKTOP_VERSION |
543 | } | 547 | } |
544 | 548 | ||
549 | |||
550 | bool ExternalAppHandler::isSIPAppAvailable() | ||
551 | { | ||
552 | #ifndef DESKTOP_VERSION | ||
553 | if (mSIPAppAvailable == UNDEFINED) | ||
554 | { | ||
555 | int client = KPimGlobalPrefs::instance()->mSipClient; | ||
556 | if (client == KPimGlobalPrefs::NONE_SIC) | ||
557 | mSIPAppAvailable = UNAVAILABLE; | ||
558 | else | ||
559 | mSIPAppAvailable = AVAILABLE; | ||
560 | } | ||
561 | |||
562 | return (mSIPAppAvailable == AVAILABLE); | ||
563 | #else //DESKTOP_VERSION | ||
564 | return false; | ||
565 | #endif //DESKTOP_VERSION | ||
566 | } | ||
567 | |||
545 | /************************************************************************** | 568 | /************************************************************************** |
546 | * | 569 | * |
547 | **************************************************************************/ | 570 | **************************************************************************/ |
548 | 571 | ||
549 | 572 | ||
550 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 573 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
551 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 574 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
552 | { | 575 | { |
553 | 576 | ||
554 | #ifndef DESKTOP_VERSION | 577 | #ifndef DESKTOP_VERSION |
555 | QString channel; | 578 | QString channel; |
556 | QString message2; | 579 | QString message2; |
557 | QString parameters2; | 580 | QString parameters2; |
558 | 581 | ||
559 | 582 | ||
560 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 583 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
561 | if (client == KPimGlobalPrefs::OTHER_EMC) | 584 | if (client == KPimGlobalPrefs::OTHER_EMC) |
562 | { | 585 | { |
563 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 586 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
564 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 587 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
565 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 588 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
566 | } | 589 | } |
567 | else | 590 | else |
568 | { | 591 | { |
569 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 592 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
570 | if (!dai) | 593 | if (!dai) |
571 | { | 594 | { |
572 | qDebug("could not find configured email application."); | 595 | qDebug("could not find configured email application."); |
573 | return false; | 596 | return false; |
574 | } | 597 | } |
575 | channel = dai->_channel; | 598 | channel = dai->_channel; |
576 | message2 = dai->_message2; | 599 | message2 = dai->_message2; |
577 | parameters2 = dai->_parameters2; | 600 | parameters2 = dai->_parameters2; |
578 | } | 601 | } |
579 | 602 | ||
580 | //first check if one of the mailers need the emails right in the message. | 603 | //first check if one of the mailers need the emails right in the message. |
581 | message2 = translateMessage(message2, emails, urls); | 604 | message2 = translateMessage(message2, emails, urls); |
582 | 605 | ||
583 | 606 | ||
584 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 607 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
585 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 608 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
586 | 609 | ||
587 | 610 | ||
588 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 611 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
589 | //US we need no names in the To field. The emailadresses are enough | 612 | //US we need no names in the To field. The emailadresses are enough |
590 | 613 | ||
591 | passParameters(&e, parameters2, emails, urls); | 614 | passParameters(&e, parameters2, emails, urls); |
592 | 615 | ||
593 | 616 | ||
594 | 617 | ||
595 | #else | 618 | #else |
596 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 619 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
597 | #endif | 620 | #endif |
598 | 621 | ||
599 | return true; | 622 | return true; |
600 | } | 623 | } |
601 | 624 | ||
602 | /************************************************************************** | 625 | /************************************************************************** |
603 | * | 626 | * |
604 | **************************************************************************/ | 627 | **************************************************************************/ |
605 | 628 | ||
606 | 629 | ||
607 | //calls the emailapplication and creates a mail with parameter emails as recipients | 630 | //calls the emailapplication and creates a mail with parameter emails as recipients |
608 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 631 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
609 | { | 632 | { |
610 | #ifndef DESKTOP_VERSION | 633 | #ifndef DESKTOP_VERSION |
611 | QString channel; | 634 | QString channel; |
612 | QString message; | 635 | QString message; |
613 | QString parameters; | 636 | QString parameters; |
614 | 637 | ||
615 | 638 | ||
616 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 639 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
617 | if (client == KPimGlobalPrefs::OTHER_EMC) | 640 | if (client == KPimGlobalPrefs::OTHER_EMC) |
618 | { | 641 | { |
619 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 642 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
620 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 643 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
621 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 644 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
622 | } | 645 | } |
623 | else | 646 | else |
624 | { | 647 | { |
625 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 648 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
626 | if (!dai) | 649 | if (!dai) |
627 | { | 650 | { |
628 | qDebug("could not find configured email application."); | 651 | qDebug("could not find configured email application."); |
629 | return false; | 652 | return false; |
630 | } | 653 | } |
631 | channel = dai->_channel; | 654 | channel = dai->_channel; |
632 | message = dai->_message; | 655 | message = dai->_message; |
633 | parameters = dai->_parameters; | 656 | parameters = dai->_parameters; |
634 | } | 657 | } |
635 | 658 | ||
636 | 659 | ||
637 | //first check if one of the mailers need the emails right in the message. | 660 | //first check if one of the mailers need the emails right in the message. |
638 | message = translateMessage(message, name, emailadress); | 661 | message = translateMessage(message, name, emailadress); |
639 | 662 | ||
640 | 663 | ||
641 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 664 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
642 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 665 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
643 | 666 | ||
644 | QCopEnvelope e(channel.latin1(), message.latin1()); | 667 | QCopEnvelope e(channel.latin1(), message.latin1()); |
645 | //US we need no names in the To field. The emailadresses are enough | 668 | //US we need no names in the To field. The emailadresses are enough |
646 | 669 | ||
647 | passParameters(&e, parameters, name, emailadress); | 670 | passParameters(&e, parameters, name, emailadress); |
648 | 671 | ||
649 | 672 | ||
650 | #else | 673 | #else |
651 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 674 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
652 | #endif | 675 | #endif |
653 | 676 | ||
654 | 677 | ||
655 | return true; | 678 | return true; |
656 | } | 679 | } |
657 | 680 | ||
658 | /************************************************************************** | 681 | /************************************************************************** |
659 | * | 682 | * |
660 | **************************************************************************/ | 683 | **************************************************************************/ |
661 | 684 | ||
662 | //calls the emailapplication and creates a mail with parameter as recipients | 685 | //calls the emailapplication and creates a mail with parameter as recipients |
663 | // parameters format is | 686 | // parameters format is |
664 | // NAME <EMAIL>:SUBJECT | 687 | // NAME <EMAIL>:SUBJECT |
665 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 688 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
666 | { | 689 | { |
667 | QString line = adressline; | 690 | QString line = adressline; |
668 | 691 | ||
669 | int first = line.find( "<"); | 692 | int first = line.find( "<"); |
670 | int last = line.find( ">"); | 693 | int last = line.find( ">"); |
671 | QString name = line.left(first); | 694 | QString name = line.left(first); |
672 | QString emailadress = line.mid(first+1, last-first-1); | 695 | QString emailadress = line.mid(first+1, last-first-1); |
673 | 696 | ||
674 | //Subject can not be handled right now. | 697 | //Subject can not be handled right now. |
675 | return mailToOneContact( name, emailadress ); | 698 | return mailToOneContact( name, emailadress ); |
676 | 699 | ||
677 | } | 700 | } |
678 | 701 | ||
679 | 702 | ||
680 | /************************************************************************** | 703 | /************************************************************************** |
681 | * | 704 | * |
682 | **************************************************************************/ | 705 | **************************************************************************/ |
683 | 706 | ||
684 | //calls the phoneapplication with the number | 707 | //calls the phoneapplication with the number |
685 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 708 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
686 | { | 709 | { |
687 | #ifndef DESKTOP_VERSION | 710 | #ifndef DESKTOP_VERSION |
688 | QString channel; | 711 | QString channel; |
689 | QString message; | 712 | QString message; |
690 | QString parameters; | 713 | QString parameters; |
691 | 714 | ||
692 | 715 | ||
693 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 716 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
694 | if (client == KPimGlobalPrefs::OTHER_PHC) | 717 | if (client == KPimGlobalPrefs::OTHER_PHC) |
695 | { | 718 | { |
696 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 719 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
697 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 720 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
698 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 721 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
699 | } | 722 | } |
700 | else | 723 | else |
701 | { | 724 | { |
702 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 725 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
703 | if (!dai) | 726 | if (!dai) |
704 | { | 727 | { |
705 | qDebug("could not find configured phone application."); | 728 | qDebug("could not find configured phone application."); |
706 | return false; | 729 | return false; |
707 | } | 730 | } |
708 | channel = dai->_channel; | 731 | channel = dai->_channel; |
709 | message = dai->_message; | 732 | message = dai->_message; |
710 | parameters = dai->_parameters; | 733 | parameters = dai->_parameters; |
711 | } | 734 | } |
712 | 735 | ||
713 | 736 | ||
714 | //first check if one of the mailers need the emails right in the message. | 737 | //first check if one of the mailers need the emails right in the message. |
715 | message = translateMessage(message, phonenumber, ""); | 738 | message = translateMessage(message, phonenumber, ""); |
716 | 739 | ||
717 | 740 | ||
718 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 741 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
719 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 742 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
720 | 743 | ||
721 | QCopEnvelope e(channel.latin1(), message.latin1()); | 744 | QCopEnvelope e(channel.latin1(), message.latin1()); |
722 | //US we need no names in the To field. The emailadresses are enough | 745 | //US we need no names in the To field. The emailadresses are enough |
723 | 746 | ||
724 | passParameters(&e, parameters, phonenumber, ""); | 747 | passParameters(&e, parameters, phonenumber, ""); |
725 | 748 | ||
726 | 749 | ||
727 | #else | 750 | #else |
728 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 751 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
729 | #endif | 752 | #endif |
730 | 753 | ||
731 | 754 | ||
732 | return true; | 755 | return true; |
733 | } | 756 | } |
734 | 757 | ||
735 | /************************************************************************** | 758 | /************************************************************************** |
736 | * | 759 | * |
737 | **************************************************************************/ | 760 | **************************************************************************/ |
738 | 761 | ||
739 | //calls the smsapplication with the number | 762 | //calls the smsapplication with the number |
740 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 763 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
741 | { | 764 | { |
742 | #ifndef DESKTOP_VERSION | 765 | #ifndef DESKTOP_VERSION |
743 | QString channel; | 766 | QString channel; |
744 | QString message; | 767 | QString message; |
745 | QString parameters; | 768 | QString parameters; |
746 | 769 | ||
747 | 770 | ||
748 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 771 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
749 | if (client == KPimGlobalPrefs::OTHER_SMC) | 772 | if (client == KPimGlobalPrefs::OTHER_SMC) |
750 | { | 773 | { |
751 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 774 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
752 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 775 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
753 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 776 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
754 | } | 777 | } |
755 | else | 778 | else |
756 | { | 779 | { |
757 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 780 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
758 | if (!dai) | 781 | if (!dai) |
759 | { | 782 | { |
760 | qDebug("could not find configured sms application."); | 783 | qDebug("could not find configured sms application."); |
761 | return false; | 784 | return false; |
762 | } | 785 | } |
763 | channel = dai->_channel; | 786 | channel = dai->_channel; |
764 | message = dai->_message; | 787 | message = dai->_message; |
765 | parameters = dai->_parameters; | 788 | parameters = dai->_parameters; |
766 | } | 789 | } |
767 | 790 | ||
768 | 791 | ||
769 | //first check if one of the mailers need the emails right in the message. | 792 | //first check if one of the mailers need the emails right in the message. |
770 | message = translateMessage(message, phonenumber, ""); | 793 | message = translateMessage(message, phonenumber, ""); |
771 | 794 | ||
772 | 795 | ||
773 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 796 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
774 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 797 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
775 | 798 | ||
776 | QCopEnvelope e(channel.latin1(), message.latin1()); | 799 | QCopEnvelope e(channel.latin1(), message.latin1()); |
777 | //US we need no names in the To field. The emailadresses are enough | 800 | //US we need no names in the To field. The emailadresses are enough |
778 | 801 | ||
779 | passParameters(&e, parameters, phonenumber, ""); | 802 | passParameters(&e, parameters, phonenumber, ""); |
780 | 803 | ||
781 | 804 | ||
782 | #else | 805 | #else |
783 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 806 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
784 | #endif | 807 | #endif |
785 | 808 | ||
786 | 809 | ||
787 | return true; | 810 | return true; |
788 | } | 811 | } |
789 | 812 | ||
790 | /************************************************************************** | 813 | /************************************************************************** |
791 | * | 814 | * |
792 | **************************************************************************/ | 815 | **************************************************************************/ |
793 | 816 | ||
794 | //calls the pagerapplication with the number | 817 | //calls the pagerapplication with the number |
795 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 818 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
796 | { | 819 | { |
797 | #ifndef DESKTOP_VERSION | 820 | #ifndef DESKTOP_VERSION |
798 | QString channel; | 821 | QString channel; |
799 | QString message; | 822 | QString message; |
800 | QString parameters; | 823 | QString parameters; |
801 | 824 | ||
802 | 825 | ||
803 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 826 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
804 | if (client == KPimGlobalPrefs::OTHER_PAC) | 827 | if (client == KPimGlobalPrefs::OTHER_PAC) |
805 | { | 828 | { |
806 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 829 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
807 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 830 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
808 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 831 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
809 | } | 832 | } |
810 | else | 833 | else |
811 | { | 834 | { |
812 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 835 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
813 | if (!dai) | 836 | if (!dai) |
814 | { | 837 | { |
815 | qDebug("could not find configured pager application."); | 838 | qDebug("could not find configured pager application."); |
816 | return false; | 839 | return false; |
817 | } | 840 | } |
818 | channel = dai->_channel; | 841 | channel = dai->_channel; |
819 | message = dai->_message; | 842 | message = dai->_message; |
820 | parameters = dai->_parameters; | 843 | parameters = dai->_parameters; |
821 | } | 844 | } |
822 | 845 | ||
823 | 846 | ||
824 | //first check if one of the mailers need the emails right in the message. | 847 | //first check if one of the mailers need the emails right in the message. |
825 | message = translateMessage(message, pagernumber, ""); | 848 | message = translateMessage(message, pagernumber, ""); |
826 | 849 | ||
827 | 850 | ||
828 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 851 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
829 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 852 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
830 | 853 | ||
831 | QCopEnvelope e(channel.latin1(), message.latin1()); | 854 | QCopEnvelope e(channel.latin1(), message.latin1()); |
832 | //US we need no names in the To field. The emailadresses are enough | 855 | //US we need no names in the To field. The emailadresses are enough |
833 | 856 | ||
834 | passParameters(&e, parameters, pagernumber, ""); | 857 | passParameters(&e, parameters, pagernumber, ""); |
835 | 858 | ||
836 | 859 | ||
837 | #else | 860 | #else |
838 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 861 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
839 | #endif | 862 | #endif |
840 | 863 | ||
841 | 864 | ||
842 | return true; | 865 | return true; |
843 | } | 866 | } |
844 | 867 | ||
845 | /************************************************************************** | 868 | /************************************************************************** |
846 | * | 869 | * |
847 | **************************************************************************/ | 870 | **************************************************************************/ |
848 | 871 | ||
849 | //calls the faxapplication with the number | 872 | //calls the faxapplication with the number |
850 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 873 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
851 | { | 874 | { |
852 | #ifndef DESKTOP_VERSION | 875 | #ifndef DESKTOP_VERSION |
853 | QString channel; | 876 | QString channel; |
854 | QString message; | 877 | QString message; |
855 | QString parameters; | 878 | QString parameters; |
856 | 879 | ||
857 | 880 | ||
858 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 881 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
859 | if (client == KPimGlobalPrefs::OTHER_FAC) | 882 | if (client == KPimGlobalPrefs::OTHER_FAC) |
860 | { | 883 | { |
861 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 884 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
862 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 885 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
863 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 886 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
864 | } | 887 | } |
865 | else | 888 | else |
866 | { | 889 | { |
867 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 890 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
868 | if (!dai) | 891 | if (!dai) |
869 | { | 892 | { |
870 | qDebug("could not find configured fax application."); | 893 | qDebug("could not find configured fax application."); |
871 | return false; | 894 | return false; |
872 | } | 895 | } |
873 | channel = dai->_channel; | 896 | channel = dai->_channel; |
874 | message = dai->_message; | 897 | message = dai->_message; |
875 | parameters = dai->_parameters; | 898 | parameters = dai->_parameters; |
876 | } | 899 | } |
877 | 900 | ||
878 | 901 | ||
879 | //first check if one of the mailers need the emails right in the message. | 902 | //first check if one of the mailers need the emails right in the message. |
880 | message = translateMessage(message, faxnumber, ""); | 903 | message = translateMessage(message, faxnumber, ""); |
881 | 904 | ||
882 | 905 | ||
883 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 906 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
884 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 907 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
885 | 908 | ||
886 | QCopEnvelope e(channel.latin1(), message.latin1()); | 909 | QCopEnvelope e(channel.latin1(), message.latin1()); |
887 | //US we need no names in the To field. The emailadresses are enough | 910 | //US we need no names in the To field. The emailadresses are enough |
888 | 911 | ||
889 | passParameters(&e, parameters, faxnumber, ""); | 912 | passParameters(&e, parameters, faxnumber, ""); |
890 | 913 | ||
891 | 914 | ||
892 | #else | 915 | #else |
893 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 916 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
894 | #endif | 917 | #endif |
895 | 918 | ||
896 | 919 | ||
897 | return true; | 920 | return true; |
898 | } | 921 | } |
899 | 922 | ||
900 | /************************************************************************** | 923 | /************************************************************************** |
901 | * | 924 | * |
902 | **************************************************************************/ | 925 | **************************************************************************/ |
903 | 926 | ||
927 | //calls the sipapplication with the number | ||
928 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | ||
929 | { | ||
930 | #ifndef DESKTOP_VERSION | ||
931 | QString channel; | ||
932 | QString message; | ||
933 | QString parameters; | ||
934 | |||
935 | |||
936 | int client = KPimGlobalPrefs::instance()->mSipClient; | ||
937 | if (client == KPimGlobalPrefs::OTHER_SIC) | ||
938 | { | ||
939 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; | ||
940 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; | ||
941 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; | ||
942 | } | ||
943 | else | ||
944 | { | ||
945 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); | ||
946 | if (!dai) | ||
947 | { | ||
948 | qDebug("could not find configured sip application."); | ||
949 | return false; | ||
950 | } | ||
951 | channel = dai->_channel; | ||
952 | message = dai->_message; | ||
953 | parameters = dai->_parameters; | ||
954 | } | ||
955 | |||
956 | |||
957 | //first check if one of the sip apps need the emails right in the message. | ||
958 | message = translateMessage(message, sipnumber, ""); | ||
959 | |||
960 | |||
961 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | ||
962 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | ||
963 | |||
964 | QCopEnvelope e(channel.latin1(), message.latin1()); | ||
965 | //US we need no names in the To field. The emailadresses are enough | ||
966 | |||
967 | passParameters(&e, parameters, sipnumber, ""); | ||
968 | |||
969 | |||
970 | #else | ||
971 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | ||
972 | #endif | ||
973 | |||
974 | |||
975 | return true; | ||
976 | } | ||
977 | |||
978 | |||
979 | /************************************************************************** | ||
980 | * | ||
981 | **************************************************************************/ | ||
982 | |||
904 | 983 | ||
905 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 984 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
906 | { | 985 | { |
907 | message = message.replace( QRegExp("%1"), param1 ); | 986 | message = message.replace( QRegExp("%1"), param1 ); |
908 | return message.replace( QRegExp("%2"), param2 ); | 987 | return message.replace( QRegExp("%2"), param2 ); |
909 | } | 988 | } |
910 | 989 | ||
911 | /************************************************************************** | 990 | /************************************************************************** |
912 | * | 991 | * |
913 | **************************************************************************/ | 992 | **************************************************************************/ |
914 | 993 | ||
915 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 994 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
916 | { | 995 | { |
917 | #ifndef DESKTOP_VERSION | 996 | #ifndef DESKTOP_VERSION |
918 | QMap<QString, QString> valmap; | 997 | QMap<QString, QString> valmap; |
919 | bool useValMap = false; | 998 | bool useValMap = false; |
920 | 999 | ||
921 | // first extract all parts of the parameters. | 1000 | // first extract all parts of the parameters. |
922 | QStringList paramlist = QStringList::split(";", parameters); | 1001 | QStringList paramlist = QStringList::split(";", parameters); |
923 | 1002 | ||
924 | //Now check how many parts we have. | 1003 | //Now check how many parts we have. |
925 | //=0 :no params to pass | 1004 | //=0 :no params to pass |
926 | //>0 :parameters to pass | 1005 | //>0 :parameters to pass |
927 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1006 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
928 | { | 1007 | { |
929 | QString param = (*it); | 1008 | QString param = (*it); |
930 | QStringList keyvallist = QStringList::split("=", param); | 1009 | QStringList keyvallist = QStringList::split("=", param); |
931 | 1010 | ||
932 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1011 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
933 | QStringList::Iterator it2 = keyvallist.begin(); | 1012 | QStringList::Iterator it2 = keyvallist.begin(); |
934 | QString key = (*it2); | 1013 | QString key = (*it2); |
935 | key = key.replace( QRegExp("%1"), param1 ); | 1014 | key = key.replace( QRegExp("%1"), param1 ); |
936 | key = key.replace( QRegExp("%2"), param2 ); | 1015 | key = key.replace( QRegExp("%2"), param2 ); |
937 | ++it2; | 1016 | ++it2; |
938 | 1017 | ||
939 | if(it2 != keyvallist.end()) | 1018 | if(it2 != keyvallist.end()) |
940 | { | 1019 | { |
941 | QString value = (*it2); | 1020 | QString value = (*it2); |
942 | value = value.replace( QRegExp("%1"), param1 ); | 1021 | value = value.replace( QRegExp("%1"), param1 ); |
943 | value = value.replace( QRegExp("%2"), param2 ); | 1022 | value = value.replace( QRegExp("%2"), param2 ); |
944 | 1023 | ||
945 | valmap.insert(key, value); | 1024 | valmap.insert(key, value); |
946 | useValMap = true; | 1025 | useValMap = true; |
947 | } | 1026 | } |
948 | else | 1027 | else |
949 | { | 1028 | { |
950 | // qDebug("pass parameter << %s", key.latin1()); | 1029 | // qDebug("pass parameter << %s", key.latin1()); |
951 | (*e) << key; | 1030 | (*e) << key; |
952 | } | 1031 | } |
953 | } | 1032 | } |
954 | 1033 | ||
955 | if (useValMap == true) | 1034 | if (useValMap == true) |
956 | (*e) << valmap; | 1035 | (*e) << valmap; |
957 | 1036 | ||
958 | #endif | 1037 | #endif |
959 | 1038 | ||
960 | } | 1039 | } |
961 | 1040 | ||
962 | 1041 | ||
963 | 1042 | ||
964 | /************************************************************************** | 1043 | /************************************************************************** |
965 | * | 1044 | * |
966 | **************************************************************************/ | 1045 | **************************************************************************/ |
967 | 1046 | ||
968 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1047 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
969 | { | 1048 | { |
970 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1049 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
971 | if (!res) | 1050 | if (!res) |
972 | res = mDisplayDetails->appMessage( cmsg, data ); | 1051 | res = mDisplayDetails->appMessage( cmsg, data ); |
973 | 1052 | ||
974 | // if (!res) | 1053 | // if (!res) |
975 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1054 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
976 | } | 1055 | } |
977 | 1056 | ||
978 | 1057 | ||
979 | 1058 | ||
980 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1059 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
981 | { | 1060 | { |
982 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1061 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
983 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1062 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
984 | } | 1063 | } |
985 | 1064 | ||
986 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1065 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
987 | { | 1066 | { |
988 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1067 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
989 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); | 1068 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); |
990 | } | 1069 | } |
991 | 1070 | ||
992 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1071 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
993 | { | 1072 | { |
994 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1073 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
995 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 1074 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
996 | } | 1075 | } |
997 | 1076 | ||
998 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1077 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
999 | { | 1078 | { |
1000 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1079 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1001 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); | 1080 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); |
1002 | } | 1081 | } |
1003 | 1082 | ||
1004 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1083 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1005 | { | 1084 | { |
1006 | mDisplayDetails->setSourceChannel(""); | 1085 | mDisplayDetails->setSourceChannel(""); |
1007 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1086 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1008 | } | 1087 | } |
1009 | 1088 | ||
1010 | 1089 | ||
1011 | 1090 | ||
1012 | 1091 | ||
1013 | 1092 | ||