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