author | zautrix <zautrix> | 2004-10-22 10:45:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-22 10:45:11 (UTC) |
commit | 54405df7e8d5e931741145d6242d1d06b72c37d6 (patch) (unidiff) | |
tree | d872a99a200202270eeaad38c2d38b3dd0d20e83 /libkdepim | |
parent | 0af0436b73d0e55d4254aad66fb41efc06d329d1 (diff) | |
download | kdepimpi-54405df7e8d5e931741145d6242d1d06b72c37d6.zip kdepimpi-54405df7e8d5e931741145d6242d1d06b72c37d6.tar.gz kdepimpi-54405df7e8d5e931741145d6242d1d06b72c37d6.tar.bz2 |
added kphone to SIP ext app
-rw-r--r-- | libkdepim/externalapphandler.cpp | 37 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 2 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.h | 3 |
3 files changed, 37 insertions, 5 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 07bdff2..779b20e 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -1,536 +1,553 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qmap.h> | 33 | #include <qmap.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | 35 | ||
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
39 | #else | 39 | #else |
40 | #include <qapplication.h> | 40 | #include <qapplication.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | 46 | ||
47 | #include "externalapphandler.h" | 47 | #include "externalapphandler.h" |
48 | 48 | ||
49 | #include "kpimglobalprefs.h" | 49 | #include "kpimglobalprefs.h" |
50 | 50 | ||
51 | //uncomment line to get debug output | ||
52 | //#define DEBUG_EXT_APP_HANDLER | ||
53 | |||
51 | /********************************************************************************* | 54 | /********************************************************************************* |
52 | * | 55 | * |
53 | ********************************************************************************/ | 56 | ********************************************************************************/ |
54 | 57 | ||
55 | 58 | ||
56 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 59 | QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
57 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) | 60 | : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) |
58 | { | 61 | { |
59 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 | 62 | //sourceMessage passes later three parameters: sourceChannel, uid, param1 |
60 | if (_usedSourceParameters == 0) | 63 | if (_usedSourceParameters == 0) |
61 | _sourceMessageParameters = "(QString,QString)"; | 64 | _sourceMessageParameters = "(QString,QString)"; |
62 | else if (_usedSourceParameters == 1) | 65 | else if (_usedSourceParameters == 1) |
63 | _sourceMessageParameters = "(QString,QString,QString)"; | 66 | _sourceMessageParameters = "(QString,QString,QString)"; |
64 | else if (_usedSourceParameters == 2) | 67 | else if (_usedSourceParameters == 2) |
65 | _sourceMessageParameters = "(QString,QString,QString,QString)"; | 68 | _sourceMessageParameters = "(QString,QString,QString,QString)"; |
66 | else if (_usedSourceParameters == 3) | 69 | else if (_usedSourceParameters == 3) |
67 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; | 70 | _sourceMessageParameters = "(QString,QString,QString,QString,QString)"; |
68 | } | 71 | } |
69 | 72 | ||
70 | /*********************************************************************************/ | 73 | /*********************************************************************************/ |
71 | 74 | ||
72 | QCopTransferItem::QCopTransferItem() | 75 | QCopTransferItem::QCopTransferItem() |
73 | { | 76 | { |
74 | } | 77 | } |
75 | 78 | ||
76 | /*********************************************************************************/ | 79 | /*********************************************************************************/ |
77 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) | 80 | bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3) |
78 | { | 81 | { |
79 | 82 | ||
80 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
81 | //sourceMessage passes two parameters: sourceChannel, uid | 84 | //sourceMessage passes two parameters: sourceChannel, uid |
82 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; | 85 | QString sourceMessage = _sourceMessage + _sourceMessageParameters; |
83 | 86 | #ifdef DEBUG_EXT_APP_HANDLER | |
84 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); | 87 | qDebug("1Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1()); |
85 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); | 88 | qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1()); |
89 | #endif | ||
86 | 90 | ||
87 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); | 91 | QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1()); |
88 | 92 | ||
89 | e << _sourceChannel << uid; | 93 | e << _sourceChannel << uid; |
90 | 94 | ||
91 | if (_usedSourceParameters == 1) | 95 | if (_usedSourceParameters == 1) |
92 | e << param1; | 96 | e << param1; |
93 | else if (_usedSourceParameters == 2) | 97 | else if (_usedSourceParameters == 2) |
94 | e << param1 << param2; | 98 | e << param1 << param2; |
95 | else if (_usedSourceParameters == 3) | 99 | else if (_usedSourceParameters == 3) |
96 | e << param1 << param2 << param3; | 100 | e << param1 << param2 << param3; |
97 | 101 | ||
98 | qApp->processEvents(); | 102 | qApp->processEvents(); |
99 | 103 | ||
100 | return true; | 104 | return true; |
101 | 105 | ||
102 | #else | 106 | #else |
103 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 107 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
104 | return false; | 108 | return false; |
105 | #endif | 109 | #endif |
106 | 110 | ||
107 | } | 111 | } |
108 | 112 | ||
109 | 113 | ||
110 | /*********************************************************************************/ | 114 | /*********************************************************************************/ |
111 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) | 115 | void QCopTransferItem::setSourceChannel(const QString& sourceChannel) |
112 | { | 116 | { |
113 | 117 | ||
114 | if ( !sourceChannel.isEmpty()) | 118 | if ( !sourceChannel.isEmpty()) |
115 | _sourceChannel = sourceChannel; | 119 | _sourceChannel = sourceChannel; |
116 | } | 120 | } |
117 | 121 | ||
118 | 122 | ||
119 | /*********************************************************************************/ | 123 | /*********************************************************************************/ |
120 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 124 | bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
121 | { | 125 | { |
122 | 126 | ||
123 | // copied from old mail2 | 127 | // copied from old mail2 |
124 | /* | 128 | /* |
125 | static int ii = 0; | 129 | static int ii = 0; |
126 | 130 | ||
127 | // block second call | 131 | // block second call |
128 | if ( ii < 2 ) { | 132 | if ( ii < 2 ) { |
129 | ++ii; | 133 | ++ii; |
130 | if ( ii > 1 ) { | 134 | if ( ii > 1 ) { |
131 | qDebug("qcop call blocked "); | 135 | qDebug("qcop call blocked "); |
132 | return true; | 136 | return true; |
133 | } | 137 | } |
134 | } | 138 | } |
135 | */ | 139 | */ |
136 | 140 | ||
137 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); | 141 | // qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() ); |
138 | 142 | ||
139 | //we are in the target and get a request from the source | 143 | //we are in the target and get a request from the source |
140 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) | 144 | if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data()) |
141 | { | 145 | { |
142 | 146 | ||
143 | QDataStream stream( data, IO_ReadOnly ); | 147 | QDataStream stream( data, IO_ReadOnly ); |
144 | 148 | ||
145 | 149 | ||
146 | QString sourceChannel; | 150 | QString sourceChannel; |
147 | QString uid; | 151 | QString uid; |
148 | QString param1; | 152 | QString param1; |
149 | QString param2; | 153 | QString param2; |
150 | QString param3; | 154 | QString param3; |
151 | 155 | ||
152 | stream >> sourceChannel >> uid; | 156 | stream >> sourceChannel >> uid; |
153 | 157 | ||
154 | if (_usedSourceParameters == 0) | 158 | if (_usedSourceParameters == 0) |
155 | { | 159 | { |
156 | emit receivedMessageFromSource(sourceChannel, uid); | 160 | emit receivedMessageFromSource(sourceChannel, uid); |
157 | } | 161 | } |
158 | else if (_usedSourceParameters == 1) | 162 | else if (_usedSourceParameters == 1) |
159 | { | 163 | { |
160 | stream >> param1; | 164 | stream >> param1; |
161 | emit receivedMessageFromSource(sourceChannel, uid, param1); | 165 | emit receivedMessageFromSource(sourceChannel, uid, param1); |
162 | } | 166 | } |
163 | else if (_usedSourceParameters == 2) | 167 | else if (_usedSourceParameters == 2) |
164 | { | 168 | { |
165 | stream >> param1 >> param2; | 169 | stream >> param1 >> param2; |
166 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); | 170 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); |
167 | } | 171 | } |
168 | else if (_usedSourceParameters == 3) | 172 | else if (_usedSourceParameters == 3) |
169 | { | 173 | { |
170 | stream >> param1 >> param2 >> param3; | 174 | stream >> param1 >> param2 >> param3; |
171 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); | 175 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); |
172 | } | 176 | } |
173 | 177 | ||
174 | return true; | 178 | return true; |
175 | } | 179 | } |
176 | 180 | ||
177 | return false; | 181 | return false; |
178 | } | 182 | } |
179 | 183 | ||
180 | 184 | ||
181 | /********************************************************************************* | 185 | /********************************************************************************* |
182 | * | 186 | * |
183 | ********************************************************************************/ | 187 | ********************************************************************************/ |
184 | 188 | ||
185 | 189 | ||
186 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 190 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
187 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 191 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
188 | { | 192 | { |
189 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | 193 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> |
190 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | 194 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; |
191 | } | 195 | } |
192 | 196 | ||
193 | /*********************************************************************************/ | 197 | /*********************************************************************************/ |
194 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 198 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) |
195 | { | 199 | { |
196 | #ifndef DESKTOP_VERSION | 200 | #ifndef DESKTOP_VERSION |
197 | //targetMessage passes two parameters: uid, map | 201 | //targetMessage passes two parameters: uid, map |
198 | QString targetMessage = _targetMessage + _targetMessageParameters; | 202 | QString targetMessage = _targetMessage + _targetMessageParameters; |
199 | 203 | ||
204 | #ifdef DEBUG_EXT_APP_HANDLER | ||
200 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 205 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
201 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | 206 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); |
207 | #endif | ||
202 | 208 | ||
203 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 209 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
204 | //US we need no names in the To field. The emailadresses are enough | 210 | //US we need no names in the To field. The emailadresses are enough |
205 | 211 | ||
206 | e << uid << nameEmailMap; | 212 | e << uid << nameEmailMap; |
207 | 213 | ||
208 | qApp->processEvents(); | 214 | qApp->processEvents(); |
209 | 215 | ||
210 | return true; | 216 | return true; |
211 | 217 | ||
212 | #else | 218 | #else |
213 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 219 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
214 | return false; | 220 | return false; |
215 | #endif | 221 | #endif |
216 | 222 | ||
217 | } | 223 | } |
218 | 224 | ||
219 | 225 | ||
220 | /*********************************************************************************/ | 226 | /*********************************************************************************/ |
221 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 227 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
222 | { | 228 | { |
223 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 229 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
224 | 230 | ||
225 | if (res == false) | 231 | if (res == false) |
226 | { | 232 | { |
227 | QDataStream stream( data, IO_ReadOnly ); | 233 | QDataStream stream( data, IO_ReadOnly ); |
228 | 234 | ||
229 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | 235 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); |
230 | 236 | ||
231 | //we are in the source and get an answer from the target | 237 | //we are in the source and get an answer from the target |
232 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 238 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
233 | { | 239 | { |
234 | QMap<QString,QString> adrMap; | 240 | QMap<QString,QString> adrMap; |
235 | QString uid; | 241 | QString uid; |
236 | 242 | ||
237 | stream >> uid >> adrMap; | 243 | stream >> uid >> adrMap; |
238 | 244 | ||
239 | emit receivedMessageFromTarget(uid, adrMap); | 245 | emit receivedMessageFromTarget(uid, adrMap); |
240 | 246 | ||
241 | 247 | ||
242 | return true; | 248 | return true; |
243 | } | 249 | } |
244 | } | 250 | } |
245 | 251 | ||
246 | return false; | 252 | return false; |
247 | } | 253 | } |
248 | 254 | ||
249 | 255 | ||
250 | /********************************************************************************* | 256 | /********************************************************************************* |
251 | * | 257 | * |
252 | ********************************************************************************/ | 258 | ********************************************************************************/ |
253 | 259 | ||
254 | 260 | ||
255 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 261 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
256 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 262 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
257 | { | 263 | { |
258 | //targetMessage returns later two parameters: uid, and three lists | 264 | //targetMessage returns later two parameters: uid, and three lists |
259 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; | 265 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; |
260 | } | 266 | } |
261 | 267 | ||
262 | /*********************************************************************************/ | 268 | /*********************************************************************************/ |
263 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | 269 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
264 | { | 270 | { |
265 | #ifndef DESKTOP_VERSION | 271 | #ifndef DESKTOP_VERSION |
266 | //targetMessage passes two parameters: uid, map | 272 | //targetMessage passes two parameters: uid, map |
267 | QString targetMessage = _targetMessage + _targetMessageParameters; | 273 | QString targetMessage = _targetMessage + _targetMessageParameters; |
268 | 274 | ||
275 | #ifdef DEBUG_EXT_APP_HANDLER | ||
269 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 276 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
270 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); | 277 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); |
271 | 278 | ||
272 | 279 | ||
273 | for ( int i = 0; i < list3.count(); i++) | 280 | for ( int i = 0; i < list3.count(); i++) |
274 | qDebug("listentry list3: %s",list3[i].latin1()); | 281 | qDebug("listentry list3: %s",list3[i].latin1()); |
282 | #endif | ||
275 | 283 | ||
276 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 284 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
277 | //US we need no names in the To field. The emailadresses are enough | 285 | //US we need no names in the To field. The emailadresses are enough |
278 | 286 | ||
279 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; | 287 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; |
280 | 288 | ||
281 | qApp->processEvents(); | 289 | qApp->processEvents(); |
282 | 290 | ||
283 | return true; | 291 | return true; |
284 | 292 | ||
285 | #else | 293 | #else |
286 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 294 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
287 | return false; | 295 | return false; |
288 | #endif | 296 | #endif |
289 | 297 | ||
290 | } | 298 | } |
291 | 299 | ||
292 | 300 | ||
293 | /*********************************************************************************/ | 301 | /*********************************************************************************/ |
294 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 302 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
295 | { | 303 | { |
296 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 304 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
305 | #ifdef DEBUG_EXT_APP_HANDLER | ||
297 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 306 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
307 | #endif | ||
298 | 308 | ||
299 | if (res == false) | 309 | if (res == false) |
300 | { | 310 | { |
301 | QDataStream stream( data, IO_ReadOnly ); | 311 | QDataStream stream( data, IO_ReadOnly ); |
302 | 312 | ||
313 | #ifdef DEBUG_EXT_APP_HANDLER | ||
303 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 314 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
315 | #endif | ||
304 | 316 | ||
305 | //we are in the source and get an answer from the target | 317 | //we are in the source and get an answer from the target |
306 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 318 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
307 | { | 319 | { |
308 | QStringList list1; | 320 | QStringList list1; |
309 | QStringList list2; | 321 | QStringList list2; |
310 | QStringList list3; | 322 | QStringList list3; |
311 | QStringList list4; | 323 | QStringList list4; |
312 | QStringList list5; | 324 | QStringList list5; |
313 | QStringList list6; | 325 | QStringList list6; |
314 | QString uid; | 326 | QString uid; |
315 | 327 | ||
328 | #ifdef DEBUG_EXT_APP_HANDLER | ||
316 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 329 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
330 | #endif | ||
317 | 331 | ||
318 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; | 332 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; |
319 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); | 333 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); |
320 | 334 | ||
321 | 335 | ||
322 | return true; | 336 | return true; |
323 | } | 337 | } |
324 | } | 338 | } |
325 | 339 | ||
326 | return false; | 340 | return false; |
327 | } | 341 | } |
328 | 342 | ||
329 | 343 | ||
330 | 344 | ||
331 | /********************************************************************************* | 345 | /********************************************************************************* |
332 | * | 346 | * |
333 | ********************************************************************************/ | 347 | ********************************************************************************/ |
334 | 348 | ||
335 | 349 | ||
336 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 350 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
337 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 351 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
338 | 352 | ||
339 | ExternalAppHandler::ExternalAppHandler() | 353 | ExternalAppHandler::ExternalAppHandler() |
340 | { | 354 | { |
341 | mDefaultItems.setAutoDelete(true); | 355 | mDefaultItems.setAutoDelete(true); |
342 | 356 | ||
343 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 357 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
344 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 358 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
345 | 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&))); | 359 | 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&))); |
346 | 360 | ||
347 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 361 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
348 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 362 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
349 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 363 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
350 | 364 | ||
351 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 365 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
352 | 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&))); | 366 | 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&))); |
353 | 367 | ||
354 | 368 | ||
355 | 369 | ||
356 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); | 370 | mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); |
357 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); | 371 | connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); |
358 | 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&))); | 372 | 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&))); |
359 | 373 | ||
360 | 374 | ||
361 | } | 375 | } |
362 | 376 | ||
363 | ExternalAppHandler::~ExternalAppHandler() | 377 | ExternalAppHandler::~ExternalAppHandler() |
364 | { | 378 | { |
365 | } | 379 | } |
366 | 380 | ||
367 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | 381 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, |
368 | const QStringList& nameList, | 382 | const QStringList& nameList, |
369 | const QStringList& emailList, | 383 | const QStringList& emailList, |
370 | const QStringList& uidList, | 384 | const QStringList& uidList, |
371 | const QStringList&, | 385 | const QStringList&, |
372 | const QStringList&, | 386 | const QStringList&, |
373 | const QStringList& ) | 387 | const QStringList& ) |
374 | { | 388 | { |
375 | // this method is a conevnient way to reduce the number of parameters I have to pass | 389 | // this method is a conevnient way to reduce the number of parameters I have to pass |
376 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); | 390 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); |
377 | } | 391 | } |
378 | 392 | ||
379 | 393 | ||
380 | void ExternalAppHandler::loadConfig() | 394 | void ExternalAppHandler::loadConfig() |
381 | { | 395 | { |
382 | 396 | ||
383 | mDefaultItems.clear(); | 397 | mDefaultItems.clear(); |
384 | mEmailAppAvailable = UNDEFINED; | 398 | mEmailAppAvailable = UNDEFINED; |
385 | mPhoneAppAvailable = UNDEFINED; | 399 | mPhoneAppAvailable = UNDEFINED; |
386 | mFaxAppAvailable = UNDEFINED; | 400 | mFaxAppAvailable = UNDEFINED; |
387 | mSMSAppAvailable = UNDEFINED; | 401 | mSMSAppAvailable = UNDEFINED; |
388 | mPagerAppAvailable = UNDEFINED; | 402 | mPagerAppAvailable = UNDEFINED; |
389 | mSIPAppAvailable = UNDEFINED; | 403 | mSIPAppAvailable = UNDEFINED; |
390 | 404 | ||
391 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 405 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
392 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 406 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
393 | 407 | ||
394 | if (opiepath.isEmpty()) | 408 | if (opiepath.isEmpty()) |
395 | opiepath = qtopiapath; | 409 | opiepath = qtopiapath; |
396 | 410 | ||
397 | //mailclients | 411 | //mailclients |
398 | QString mailmsg1 = "writeMail(QString,QString)"; | 412 | QString mailmsg1 = "writeMail(QString,QString)"; |
399 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 413 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
400 | 414 | ||
401 | QString undefined = ""; | 415 | QString undefined = ""; |
402 | 416 | ||
403 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 417 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
404 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 418 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
405 | 419 | ||
406 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 420 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
407 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 421 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
408 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 422 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
409 | 423 | ||
410 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 424 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
411 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 425 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
412 | 426 | ||
413 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 427 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
414 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 428 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
415 | 429 | ||
416 | 430 | ||
417 | 431 | ||
418 | //phoneclients | 432 | //phoneclients |
419 | 433 | ||
420 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 434 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
421 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 435 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
422 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 436 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
423 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 437 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
424 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 438 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
425 | 439 | ||
426 | //faxclients | 440 | //faxclients |
427 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 441 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
428 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 442 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
429 | 443 | ||
430 | //smsclients | 444 | //smsclients |
431 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 445 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
432 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 446 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
433 | 447 | ||
434 | //pagerclients | 448 | //pagerclients |
435 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 449 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
436 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 450 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
437 | 451 | ||
438 | //sipclients | 452 | //sipclients |
439 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined); | 453 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); |
440 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined); | 454 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other SIP client", undefined, undefined, undefined, undefined, undefined); |
455 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | ||
456 | ( QFile::exists( opiepath + "/bin/kppi" ))) | ||
457 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | ||
441 | 458 | ||
442 | } | 459 | } |
443 | 460 | ||
444 | ExternalAppHandler *ExternalAppHandler::instance() | 461 | ExternalAppHandler *ExternalAppHandler::instance() |
445 | { | 462 | { |
446 | if ( !sInstance ) { | 463 | if ( !sInstance ) { |
447 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 464 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
448 | sInstance->loadConfig(); | 465 | sInstance->loadConfig(); |
449 | } | 466 | } |
450 | 467 | ||
451 | return sInstance; | 468 | return sInstance; |
452 | } | 469 | } |
453 | 470 | ||
454 | 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) | 471 | 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) |
455 | { | 472 | { |
456 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 473 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
457 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 474 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
458 | mDefaultItems.append(dai); | 475 | mDefaultItems.append(dai); |
459 | } | 476 | } |
460 | 477 | ||
461 | 478 | ||
462 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 479 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
463 | { | 480 | { |
464 | QList<DefaultAppItem> list; | 481 | QList<DefaultAppItem> list; |
465 | 482 | ||
466 | DefaultAppItem* dai; | 483 | DefaultAppItem* dai; |
467 | 484 | ||
468 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 485 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
469 | { | 486 | { |
470 | if (dai->_type == type) | 487 | if (dai->_type == type) |
471 | list.append(dai); | 488 | list.append(dai); |
472 | } | 489 | } |
473 | 490 | ||
474 | return list; | 491 | return list; |
475 | } | 492 | } |
476 | 493 | ||
477 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 494 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
478 | { | 495 | { |
479 | DefaultAppItem* dai; | 496 | DefaultAppItem* dai; |
480 | 497 | ||
481 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 498 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
482 | { | 499 | { |
483 | if (dai->_type == type && dai->_id == clientid) | 500 | if (dai->_type == type && dai->_id == clientid) |
484 | return dai; | 501 | return dai; |
485 | } | 502 | } |
486 | 503 | ||
487 | return 0; | 504 | return 0; |
488 | } | 505 | } |
489 | 506 | ||
490 | bool ExternalAppHandler::isEmailAppAvailable() | 507 | bool ExternalAppHandler::isEmailAppAvailable() |
491 | { | 508 | { |
492 | #ifndef DESKTOP_VERSION | 509 | #ifndef DESKTOP_VERSION |
493 | if (mEmailAppAvailable == UNDEFINED) | 510 | if (mEmailAppAvailable == UNDEFINED) |
494 | { | 511 | { |
495 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 512 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
496 | if (client == KPimGlobalPrefs::NONE_EMC) | 513 | if (client == KPimGlobalPrefs::NONE_EMC) |
497 | mEmailAppAvailable = UNAVAILABLE; | 514 | mEmailAppAvailable = UNAVAILABLE; |
498 | else | 515 | else |
499 | mEmailAppAvailable = AVAILABLE; | 516 | mEmailAppAvailable = AVAILABLE; |
500 | } | 517 | } |
501 | return (mEmailAppAvailable == AVAILABLE); | 518 | return (mEmailAppAvailable == AVAILABLE); |
502 | 519 | ||
503 | #else //DESKTOP_VERSION | 520 | #else //DESKTOP_VERSION |
504 | return false; | 521 | return false; |
505 | #endif //DESKTOP_VERSION | 522 | #endif //DESKTOP_VERSION |
506 | } | 523 | } |
507 | 524 | ||
508 | bool ExternalAppHandler::isSMSAppAvailable() | 525 | bool ExternalAppHandler::isSMSAppAvailable() |
509 | { | 526 | { |
510 | #ifndef DESKTOP_VERSION | 527 | #ifndef DESKTOP_VERSION |
511 | if (mSMSAppAvailable == UNDEFINED) | 528 | if (mSMSAppAvailable == UNDEFINED) |
512 | { | 529 | { |
513 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 530 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
514 | if (client == KPimGlobalPrefs::NONE_SMC) | 531 | if (client == KPimGlobalPrefs::NONE_SMC) |
515 | mSMSAppAvailable = UNAVAILABLE; | 532 | mSMSAppAvailable = UNAVAILABLE; |
516 | else | 533 | else |
517 | mSMSAppAvailable = AVAILABLE; | 534 | mSMSAppAvailable = AVAILABLE; |
518 | } | 535 | } |
519 | 536 | ||
520 | return (mSMSAppAvailable == AVAILABLE); | 537 | return (mSMSAppAvailable == AVAILABLE); |
521 | #else //DESKTOP_VERSION | 538 | #else //DESKTOP_VERSION |
522 | return false; | 539 | return false; |
523 | #endif //DESKTOP_VERSION | 540 | #endif //DESKTOP_VERSION |
524 | } | 541 | } |
525 | 542 | ||
526 | bool ExternalAppHandler::isPhoneAppAvailable() | 543 | bool ExternalAppHandler::isPhoneAppAvailable() |
527 | { | 544 | { |
528 | #ifndef DESKTOP_VERSION | 545 | #ifndef DESKTOP_VERSION |
529 | if (mPhoneAppAvailable == UNDEFINED) | 546 | if (mPhoneAppAvailable == UNDEFINED) |
530 | { | 547 | { |
531 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 548 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
532 | if (client == KPimGlobalPrefs::NONE_PHC) | 549 | if (client == KPimGlobalPrefs::NONE_PHC) |
533 | mPhoneAppAvailable = UNAVAILABLE; | 550 | mPhoneAppAvailable = UNAVAILABLE; |
534 | else | 551 | else |
535 | mPhoneAppAvailable = AVAILABLE; | 552 | mPhoneAppAvailable = AVAILABLE; |
536 | } | 553 | } |
@@ -542,548 +559,562 @@ bool ExternalAppHandler::isPhoneAppAvailable() | |||
542 | } | 559 | } |
543 | 560 | ||
544 | bool ExternalAppHandler::isFaxAppAvailable() | 561 | bool ExternalAppHandler::isFaxAppAvailable() |
545 | { | 562 | { |
546 | #ifndef DESKTOP_VERSION | 563 | #ifndef DESKTOP_VERSION |
547 | if (mFaxAppAvailable == UNDEFINED) | 564 | if (mFaxAppAvailable == UNDEFINED) |
548 | { | 565 | { |
549 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 566 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
550 | if (client == KPimGlobalPrefs::NONE_FAC) | 567 | if (client == KPimGlobalPrefs::NONE_FAC) |
551 | mFaxAppAvailable = UNAVAILABLE; | 568 | mFaxAppAvailable = UNAVAILABLE; |
552 | else | 569 | else |
553 | mFaxAppAvailable = AVAILABLE; | 570 | mFaxAppAvailable = AVAILABLE; |
554 | } | 571 | } |
555 | 572 | ||
556 | return (mFaxAppAvailable == AVAILABLE); | 573 | return (mFaxAppAvailable == AVAILABLE); |
557 | #else //DESKTOP_VERSION | 574 | #else //DESKTOP_VERSION |
558 | return false; | 575 | return false; |
559 | #endif //DESKTOP_VERSION | 576 | #endif //DESKTOP_VERSION |
560 | } | 577 | } |
561 | 578 | ||
562 | bool ExternalAppHandler::isPagerAppAvailable() | 579 | bool ExternalAppHandler::isPagerAppAvailable() |
563 | { | 580 | { |
564 | #ifndef DESKTOP_VERSION | 581 | #ifndef DESKTOP_VERSION |
565 | if (mPagerAppAvailable == UNDEFINED) | 582 | if (mPagerAppAvailable == UNDEFINED) |
566 | { | 583 | { |
567 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 584 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
568 | if (client == KPimGlobalPrefs::NONE_PAC) | 585 | if (client == KPimGlobalPrefs::NONE_PAC) |
569 | mPagerAppAvailable = UNAVAILABLE; | 586 | mPagerAppAvailable = UNAVAILABLE; |
570 | else | 587 | else |
571 | mPagerAppAvailable = AVAILABLE; | 588 | mPagerAppAvailable = AVAILABLE; |
572 | } | 589 | } |
573 | 590 | ||
574 | return (mPagerAppAvailable == AVAILABLE); | 591 | return (mPagerAppAvailable == AVAILABLE); |
575 | #else //DESKTOP_VERSION | 592 | #else //DESKTOP_VERSION |
576 | return false; | 593 | return false; |
577 | #endif //DESKTOP_VERSION | 594 | #endif //DESKTOP_VERSION |
578 | } | 595 | } |
579 | 596 | ||
580 | 597 | ||
581 | bool ExternalAppHandler::isSIPAppAvailable() | 598 | bool ExternalAppHandler::isSIPAppAvailable() |
582 | { | 599 | { |
583 | #ifndef DESKTOP_VERSION | 600 | #ifndef DESKTOP_VERSION |
584 | if (mSIPAppAvailable == UNDEFINED) | 601 | if (mSIPAppAvailable == UNDEFINED) |
585 | { | 602 | { |
586 | int client = KPimGlobalPrefs::instance()->mSipClient; | 603 | int client = KPimGlobalPrefs::instance()->mSipClient; |
587 | if (client == KPimGlobalPrefs::NONE_SIC) | 604 | if (client == KPimGlobalPrefs::NONE_SIC) |
588 | mSIPAppAvailable = UNAVAILABLE; | 605 | mSIPAppAvailable = UNAVAILABLE; |
589 | else | 606 | else |
590 | mSIPAppAvailable = AVAILABLE; | 607 | mSIPAppAvailable = AVAILABLE; |
591 | } | 608 | } |
592 | 609 | ||
593 | return (mSIPAppAvailable == AVAILABLE); | 610 | return (mSIPAppAvailable == AVAILABLE); |
594 | #else //DESKTOP_VERSION | 611 | #else //DESKTOP_VERSION |
595 | return false; | 612 | return false; |
596 | #endif //DESKTOP_VERSION | 613 | #endif //DESKTOP_VERSION |
597 | } | 614 | } |
598 | 615 | ||
599 | /************************************************************************** | 616 | /************************************************************************** |
600 | * | 617 | * |
601 | **************************************************************************/ | 618 | **************************************************************************/ |
602 | 619 | ||
603 | 620 | ||
604 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 621 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
605 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 622 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
606 | { | 623 | { |
607 | 624 | ||
608 | #ifndef DESKTOP_VERSION | 625 | #ifndef DESKTOP_VERSION |
609 | QString channel; | 626 | QString channel; |
610 | QString message2; | 627 | QString message2; |
611 | QString parameters2; | 628 | QString parameters2; |
612 | 629 | ||
613 | 630 | ||
614 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 631 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
615 | if (client == KPimGlobalPrefs::OTHER_EMC) | 632 | if (client == KPimGlobalPrefs::OTHER_EMC) |
616 | { | 633 | { |
617 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 634 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
618 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 635 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
619 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 636 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
620 | } | 637 | } |
621 | else | 638 | else |
622 | { | 639 | { |
623 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 640 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
624 | if (!dai) | 641 | if (!dai) |
625 | { | 642 | { |
626 | qDebug("could not find configured email application."); | 643 | qDebug("could not find configured email application."); |
627 | return false; | 644 | return false; |
628 | } | 645 | } |
629 | channel = dai->_channel; | 646 | channel = dai->_channel; |
630 | message2 = dai->_message2; | 647 | message2 = dai->_message2; |
631 | parameters2 = dai->_parameters2; | 648 | parameters2 = dai->_parameters2; |
632 | } | 649 | } |
633 | 650 | ||
634 | //first check if one of the mailers need the emails right in the message. | 651 | //first check if one of the mailers need the emails right in the message. |
635 | message2 = translateMessage(message2, emails, urls); | 652 | message2 = translateMessage(message2, emails, urls); |
636 | 653 | ||
637 | 654 | ||
655 | #ifdef DEBUG_EXT_APP_HANDLER | ||
638 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 656 | qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
639 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 657 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
658 | #endif | ||
640 | 659 | ||
641 | 660 | ||
642 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 661 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
643 | //US we need no names in the To field. The emailadresses are enough | 662 | //US we need no names in the To field. The emailadresses are enough |
644 | 663 | ||
645 | passParameters(&e, parameters2, emails, urls); | 664 | passParameters(&e, parameters2, emails, urls); |
646 | 665 | ||
647 | 666 | ||
648 | 667 | ||
649 | #else | 668 | #else |
650 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 669 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
651 | #endif | 670 | #endif |
652 | 671 | ||
653 | return true; | 672 | return true; |
654 | } | 673 | } |
655 | 674 | ||
656 | /************************************************************************** | 675 | /************************************************************************** |
657 | * | 676 | * |
658 | **************************************************************************/ | 677 | **************************************************************************/ |
659 | 678 | ||
660 | 679 | ||
661 | //calls the emailapplication and creates a mail with parameter emails as recipients | 680 | //calls the emailapplication and creates a mail with parameter emails as recipients |
662 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 681 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
663 | { | 682 | { |
664 | #ifndef DESKTOP_VERSION | 683 | #ifndef DESKTOP_VERSION |
665 | QString channel; | 684 | QString channel; |
666 | QString message; | 685 | QString message; |
667 | QString parameters; | 686 | QString parameters; |
668 | 687 | ||
669 | 688 | ||
670 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 689 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
671 | if (client == KPimGlobalPrefs::OTHER_EMC) | 690 | if (client == KPimGlobalPrefs::OTHER_EMC) |
672 | { | 691 | { |
673 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 692 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
674 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 693 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
675 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 694 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
676 | } | 695 | } |
677 | else | 696 | else |
678 | { | 697 | { |
679 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 698 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
680 | if (!dai) | 699 | if (!dai) |
681 | { | 700 | { |
682 | qDebug("could not find configured email application."); | 701 | qDebug("could not find configured email application."); |
683 | return false; | 702 | return false; |
684 | } | 703 | } |
685 | channel = dai->_channel; | 704 | channel = dai->_channel; |
686 | message = dai->_message; | 705 | message = dai->_message; |
687 | parameters = dai->_parameters; | 706 | parameters = dai->_parameters; |
688 | } | 707 | } |
689 | 708 | ||
690 | 709 | ||
691 | //first check if one of the mailers need the emails right in the message. | 710 | //first check if one of the mailers need the emails right in the message. |
692 | message = translateMessage(message, name, emailadress); | 711 | message = translateMessage(message, name, emailadress); |
693 | 712 | ||
694 | 713 | ||
714 | #ifdef DEBUG_EXT_APP_HANDLER | ||
695 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 715 | qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
696 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 716 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
717 | #endif | ||
697 | 718 | ||
698 | QCopEnvelope e(channel.latin1(), message.latin1()); | 719 | QCopEnvelope e(channel.latin1(), message.latin1()); |
699 | //US we need no names in the To field. The emailadresses are enough | 720 | //US we need no names in the To field. The emailadresses are enough |
700 | 721 | ||
701 | passParameters(&e, parameters, name, emailadress); | 722 | passParameters(&e, parameters, name, emailadress); |
702 | 723 | ||
703 | 724 | ||
704 | #else | 725 | #else |
705 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 726 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
706 | #endif | 727 | #endif |
707 | 728 | ||
708 | 729 | ||
709 | return true; | 730 | return true; |
710 | } | 731 | } |
711 | 732 | ||
712 | /************************************************************************** | 733 | /************************************************************************** |
713 | * | 734 | * |
714 | **************************************************************************/ | 735 | **************************************************************************/ |
715 | 736 | ||
716 | //calls the emailapplication and creates a mail with parameter as recipients | 737 | //calls the emailapplication and creates a mail with parameter as recipients |
717 | // parameters format is | 738 | // parameters format is |
718 | // NAME <EMAIL>:SUBJECT | 739 | // NAME <EMAIL>:SUBJECT |
719 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 740 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
720 | { | 741 | { |
721 | QString line = adressline; | 742 | QString line = adressline; |
722 | 743 | ||
723 | int first = line.find( "<"); | 744 | int first = line.find( "<"); |
724 | int last = line.find( ">"); | 745 | int last = line.find( ">"); |
725 | QString name = line.left(first); | 746 | QString name = line.left(first); |
726 | QString emailadress = line.mid(first+1, last-first-1); | 747 | QString emailadress = line.mid(first+1, last-first-1); |
727 | 748 | ||
728 | //Subject can not be handled right now. | 749 | //Subject can not be handled right now. |
729 | return mailToOneContact( name, emailadress ); | 750 | return mailToOneContact( name, emailadress ); |
730 | 751 | ||
731 | } | 752 | } |
732 | 753 | ||
733 | 754 | ||
734 | /************************************************************************** | 755 | /************************************************************************** |
735 | * | 756 | * |
736 | **************************************************************************/ | 757 | **************************************************************************/ |
737 | 758 | ||
738 | //calls the phoneapplication with the number | 759 | //calls the phoneapplication with the number |
739 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 760 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
740 | { | 761 | { |
741 | #ifndef DESKTOP_VERSION | 762 | #ifndef DESKTOP_VERSION |
742 | QString channel; | 763 | QString channel; |
743 | QString message; | 764 | QString message; |
744 | QString parameters; | 765 | QString parameters; |
745 | 766 | ||
746 | 767 | ||
747 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 768 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
748 | if (client == KPimGlobalPrefs::OTHER_PHC) | 769 | if (client == KPimGlobalPrefs::OTHER_PHC) |
749 | { | 770 | { |
750 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 771 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
751 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 772 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
752 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 773 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
753 | } | 774 | } |
754 | else | 775 | else |
755 | { | 776 | { |
756 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 777 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
757 | if (!dai) | 778 | if (!dai) |
758 | { | 779 | { |
759 | qDebug("could not find configured phone application."); | 780 | qDebug("could not find configured phone application."); |
760 | return false; | 781 | return false; |
761 | } | 782 | } |
762 | channel = dai->_channel; | 783 | channel = dai->_channel; |
763 | message = dai->_message; | 784 | message = dai->_message; |
764 | parameters = dai->_parameters; | 785 | parameters = dai->_parameters; |
765 | } | 786 | } |
766 | 787 | ||
767 | 788 | ||
768 | //first check if one of the mailers need the emails right in the message. | 789 | //first check if one of the mailers need the emails right in the message. |
769 | message = translateMessage(message, phonenumber, ""); | 790 | message = translateMessage(message, phonenumber, ""); |
770 | 791 | ||
771 | 792 | ||
793 | #ifdef DEBUG_EXT_APP_HANDLER | ||
772 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 794 | qDebug("6Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
773 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 795 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
796 | #endif | ||
774 | 797 | ||
775 | QCopEnvelope e(channel.latin1(), message.latin1()); | 798 | QCopEnvelope e(channel.latin1(), message.latin1()); |
776 | //US we need no names in the To field. The emailadresses are enough | 799 | //US we need no names in the To field. The emailadresses are enough |
777 | 800 | ||
778 | passParameters(&e, parameters, phonenumber, ""); | 801 | passParameters(&e, parameters, phonenumber, ""); |
779 | 802 | ||
780 | 803 | ||
781 | #else | 804 | #else |
782 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 805 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
783 | #endif | 806 | #endif |
784 | 807 | ||
785 | 808 | ||
786 | return true; | 809 | return true; |
787 | } | 810 | } |
788 | 811 | ||
789 | /************************************************************************** | 812 | /************************************************************************** |
790 | * | 813 | * |
791 | **************************************************************************/ | 814 | **************************************************************************/ |
792 | 815 | ||
793 | //calls the smsapplication with the number | 816 | //calls the smsapplication with the number |
794 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 817 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
795 | { | 818 | { |
796 | #ifndef DESKTOP_VERSION | 819 | #ifndef DESKTOP_VERSION |
797 | QString channel; | 820 | QString channel; |
798 | QString message; | 821 | QString message; |
799 | QString parameters; | 822 | QString parameters; |
800 | 823 | ||
801 | 824 | ||
802 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 825 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
803 | if (client == KPimGlobalPrefs::OTHER_SMC) | 826 | if (client == KPimGlobalPrefs::OTHER_SMC) |
804 | { | 827 | { |
805 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 828 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
806 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 829 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
807 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 830 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
808 | } | 831 | } |
809 | else | 832 | else |
810 | { | 833 | { |
811 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 834 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
812 | if (!dai) | 835 | if (!dai) |
813 | { | 836 | { |
814 | qDebug("could not find configured sms application."); | 837 | qDebug("could not find configured sms application."); |
815 | return false; | 838 | return false; |
816 | } | 839 | } |
817 | channel = dai->_channel; | 840 | channel = dai->_channel; |
818 | message = dai->_message; | 841 | message = dai->_message; |
819 | parameters = dai->_parameters; | 842 | parameters = dai->_parameters; |
820 | } | 843 | } |
821 | 844 | ||
822 | 845 | ||
823 | //first check if one of the mailers need the emails right in the message. | 846 | //first check if one of the mailers need the emails right in the message. |
824 | message = translateMessage(message, phonenumber, ""); | 847 | message = translateMessage(message, phonenumber, ""); |
825 | 848 | ||
826 | 849 | ||
850 | #ifdef DEBUG_EXT_APP_HANDLER | ||
827 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 851 | qDebug("7Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
828 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 852 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
853 | #endif | ||
829 | 854 | ||
830 | QCopEnvelope e(channel.latin1(), message.latin1()); | 855 | QCopEnvelope e(channel.latin1(), message.latin1()); |
831 | //US we need no names in the To field. The emailadresses are enough | 856 | //US we need no names in the To field. The emailadresses are enough |
832 | 857 | ||
833 | passParameters(&e, parameters, phonenumber, ""); | 858 | passParameters(&e, parameters, phonenumber, ""); |
834 | 859 | ||
835 | 860 | ||
836 | #else | 861 | #else |
837 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 862 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
838 | #endif | 863 | #endif |
839 | 864 | ||
840 | 865 | ||
841 | return true; | 866 | return true; |
842 | } | 867 | } |
843 | 868 | ||
844 | /************************************************************************** | 869 | /************************************************************************** |
845 | * | 870 | * |
846 | **************************************************************************/ | 871 | **************************************************************************/ |
847 | 872 | ||
848 | //calls the pagerapplication with the number | 873 | //calls the pagerapplication with the number |
849 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 874 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
850 | { | 875 | { |
851 | #ifndef DESKTOP_VERSION | 876 | #ifndef DESKTOP_VERSION |
852 | QString channel; | 877 | QString channel; |
853 | QString message; | 878 | QString message; |
854 | QString parameters; | 879 | QString parameters; |
855 | 880 | ||
856 | 881 | ||
857 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 882 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
858 | if (client == KPimGlobalPrefs::OTHER_PAC) | 883 | if (client == KPimGlobalPrefs::OTHER_PAC) |
859 | { | 884 | { |
860 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 885 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
861 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 886 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
862 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 887 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
863 | } | 888 | } |
864 | else | 889 | else |
865 | { | 890 | { |
866 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 891 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
867 | if (!dai) | 892 | if (!dai) |
868 | { | 893 | { |
869 | qDebug("could not find configured pager application."); | 894 | qDebug("could not find configured pager application."); |
870 | return false; | 895 | return false; |
871 | } | 896 | } |
872 | channel = dai->_channel; | 897 | channel = dai->_channel; |
873 | message = dai->_message; | 898 | message = dai->_message; |
874 | parameters = dai->_parameters; | 899 | parameters = dai->_parameters; |
875 | } | 900 | } |
876 | 901 | ||
877 | 902 | ||
878 | //first check if one of the mailers need the emails right in the message. | 903 | //first check if one of the mailers need the emails right in the message. |
879 | message = translateMessage(message, pagernumber, ""); | 904 | message = translateMessage(message, pagernumber, ""); |
880 | 905 | ||
881 | 906 | ||
907 | #ifdef DEBUG_EXT_APP_HANDLER | ||
882 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 908 | qDebug("8Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
883 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 909 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
910 | #endif | ||
884 | 911 | ||
885 | QCopEnvelope e(channel.latin1(), message.latin1()); | 912 | QCopEnvelope e(channel.latin1(), message.latin1()); |
886 | //US we need no names in the To field. The emailadresses are enough | 913 | //US we need no names in the To field. The emailadresses are enough |
887 | 914 | ||
888 | passParameters(&e, parameters, pagernumber, ""); | 915 | passParameters(&e, parameters, pagernumber, ""); |
889 | 916 | ||
890 | 917 | ||
891 | #else | 918 | #else |
892 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 919 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
893 | #endif | 920 | #endif |
894 | 921 | ||
895 | 922 | ||
896 | return true; | 923 | return true; |
897 | } | 924 | } |
898 | 925 | ||
899 | /************************************************************************** | 926 | /************************************************************************** |
900 | * | 927 | * |
901 | **************************************************************************/ | 928 | **************************************************************************/ |
902 | 929 | ||
903 | //calls the faxapplication with the number | 930 | //calls the faxapplication with the number |
904 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 931 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
905 | { | 932 | { |
906 | #ifndef DESKTOP_VERSION | 933 | #ifndef DESKTOP_VERSION |
907 | QString channel; | 934 | QString channel; |
908 | QString message; | 935 | QString message; |
909 | QString parameters; | 936 | QString parameters; |
910 | 937 | ||
911 | 938 | ||
912 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 939 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
913 | if (client == KPimGlobalPrefs::OTHER_FAC) | 940 | if (client == KPimGlobalPrefs::OTHER_FAC) |
914 | { | 941 | { |
915 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 942 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
916 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 943 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
917 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 944 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
918 | } | 945 | } |
919 | else | 946 | else |
920 | { | 947 | { |
921 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 948 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
922 | if (!dai) | 949 | if (!dai) |
923 | { | 950 | { |
924 | qDebug("could not find configured fax application."); | 951 | qDebug("could not find configured fax application."); |
925 | return false; | 952 | return false; |
926 | } | 953 | } |
927 | channel = dai->_channel; | 954 | channel = dai->_channel; |
928 | message = dai->_message; | 955 | message = dai->_message; |
929 | parameters = dai->_parameters; | 956 | parameters = dai->_parameters; |
930 | } | 957 | } |
931 | 958 | ||
932 | 959 | ||
933 | //first check if one of the mailers need the emails right in the message. | 960 | //first check if one of the mailers need the emails right in the message. |
934 | message = translateMessage(message, faxnumber, ""); | 961 | message = translateMessage(message, faxnumber, ""); |
935 | 962 | ||
936 | 963 | ||
964 | #ifdef DEBUG_EXT_APP_HANDLER | ||
937 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 965 | qDebug("9Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
938 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 966 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
967 | #endif | ||
939 | 968 | ||
940 | QCopEnvelope e(channel.latin1(), message.latin1()); | 969 | QCopEnvelope e(channel.latin1(), message.latin1()); |
941 | //US we need no names in the To field. The emailadresses are enough | 970 | //US we need no names in the To field. The emailadresses are enough |
942 | 971 | ||
943 | passParameters(&e, parameters, faxnumber, ""); | 972 | passParameters(&e, parameters, faxnumber, ""); |
944 | 973 | ||
945 | 974 | ||
946 | #else | 975 | #else |
947 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 976 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
948 | #endif | 977 | #endif |
949 | 978 | ||
950 | 979 | ||
951 | return true; | 980 | return true; |
952 | } | 981 | } |
953 | 982 | ||
954 | /************************************************************************** | 983 | /************************************************************************** |
955 | * | 984 | * |
956 | **************************************************************************/ | 985 | **************************************************************************/ |
957 | 986 | ||
958 | //calls the sipapplication with the number | 987 | //calls the sipapplication with the number |
959 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | 988 | bool ExternalAppHandler::callBySIP( const QString& sipnumber ) |
960 | { | 989 | { |
961 | #ifndef DESKTOP_VERSION | 990 | #ifndef DESKTOP_VERSION |
962 | QString channel; | 991 | QString channel; |
963 | QString message; | 992 | QString message; |
964 | QString parameters; | 993 | QString parameters; |
965 | 994 | ||
966 | 995 | ||
967 | int client = KPimGlobalPrefs::instance()->mSipClient; | 996 | int client = KPimGlobalPrefs::instance()->mSipClient; |
968 | if (client == KPimGlobalPrefs::OTHER_SIC) | 997 | if (client == KPimGlobalPrefs::OTHER_SIC) |
969 | { | 998 | { |
970 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; | 999 | channel = KPimGlobalPrefs::instance()->mSipOtherChannel; |
971 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; | 1000 | message = KPimGlobalPrefs::instance()->mSipOtherMessage; |
972 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; | 1001 | parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters; |
973 | } | 1002 | } |
974 | else | 1003 | else |
975 | { | 1004 | { |
976 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); | 1005 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client); |
977 | if (!dai) | 1006 | if (!dai) |
978 | { | 1007 | { |
979 | qDebug("could not find configured sip application."); | 1008 | qDebug("could not find configured sip application."); |
980 | return false; | 1009 | return false; |
981 | } | 1010 | } |
982 | channel = dai->_channel; | 1011 | channel = dai->_channel; |
983 | message = dai->_message; | 1012 | message = dai->_message; |
984 | parameters = dai->_parameters; | 1013 | parameters = dai->_parameters; |
985 | } | 1014 | } |
986 | 1015 | ||
987 | 1016 | ||
988 | //first check if one of the sip apps need the emails right in the message. | 1017 | //first check if one of the sip apps need the emails right in the message. |
989 | message = translateMessage(message, sipnumber, ""); | 1018 | message = translateMessage(message, sipnumber, ""); |
990 | 1019 | ||
991 | 1020 | ||
1021 | #ifdef DEBUG_EXT_APP_HANDLER | ||
992 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 1022 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
993 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | 1023 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); |
1024 | #endif | ||
994 | 1025 | ||
995 | QCopEnvelope e(channel.latin1(), message.latin1()); | 1026 | QCopEnvelope e(channel.latin1(), message.latin1()); |
996 | //US we need no names in the To field. The emailadresses are enough | 1027 | //US we need no names in the To field. The emailadresses are enough |
997 | 1028 | ||
998 | passParameters(&e, parameters, sipnumber, ""); | 1029 | passParameters(&e, parameters, sipnumber, ""); |
999 | 1030 | ||
1000 | 1031 | ||
1001 | #else | 1032 | #else |
1002 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | 1033 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); |
1003 | #endif | 1034 | #endif |
1004 | 1035 | ||
1005 | 1036 | ||
1006 | return true; | 1037 | return true; |
1007 | } | 1038 | } |
1008 | 1039 | ||
1009 | 1040 | ||
1010 | /************************************************************************** | 1041 | /************************************************************************** |
1011 | * | 1042 | * |
1012 | **************************************************************************/ | 1043 | **************************************************************************/ |
1013 | 1044 | ||
1014 | 1045 | ||
1015 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1046 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
1016 | { | 1047 | { |
1017 | message = message.replace( QRegExp("%1"), param1 ); | 1048 | message = message.replace( QRegExp("%1"), param1 ); |
1018 | return message.replace( QRegExp("%2"), param2 ); | 1049 | return message.replace( QRegExp("%2"), param2 ); |
1019 | } | 1050 | } |
1020 | 1051 | ||
1021 | /************************************************************************** | 1052 | /************************************************************************** |
1022 | * | 1053 | * |
1023 | **************************************************************************/ | 1054 | **************************************************************************/ |
1024 | 1055 | ||
1025 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1056 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
1026 | { | 1057 | { |
1027 | #ifndef DESKTOP_VERSION | 1058 | #ifndef DESKTOP_VERSION |
1028 | QMap<QString, QString> valmap; | 1059 | QMap<QString, QString> valmap; |
1029 | bool useValMap = false; | 1060 | bool useValMap = false; |
1030 | 1061 | ||
1031 | // first extract all parts of the parameters. | 1062 | // first extract all parts of the parameters. |
1032 | QStringList paramlist = QStringList::split(";", parameters); | 1063 | QStringList paramlist = QStringList::split(";", parameters); |
1033 | 1064 | ||
1034 | //Now check how many parts we have. | 1065 | //Now check how many parts we have. |
1035 | //=0 :no params to pass | 1066 | //=0 :no params to pass |
1036 | //>0 :parameters to pass | 1067 | //>0 :parameters to pass |
1037 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1068 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
1038 | { | 1069 | { |
1039 | QString param = (*it); | 1070 | QString param = (*it); |
1040 | QStringList keyvallist = QStringList::split("=", param); | 1071 | QStringList keyvallist = QStringList::split("=", param); |
1041 | 1072 | ||
1042 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1073 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
1043 | QStringList::Iterator it2 = keyvallist.begin(); | 1074 | QStringList::Iterator it2 = keyvallist.begin(); |
1044 | QString key = (*it2); | 1075 | QString key = (*it2); |
1045 | key = key.replace( QRegExp("%1"), param1 ); | 1076 | key = key.replace( QRegExp("%1"), param1 ); |
1046 | key = key.replace( QRegExp("%2"), param2 ); | 1077 | key = key.replace( QRegExp("%2"), param2 ); |
1047 | ++it2; | 1078 | ++it2; |
1048 | 1079 | ||
1049 | if(it2 != keyvallist.end()) | 1080 | if(it2 != keyvallist.end()) |
1050 | { | 1081 | { |
1051 | QString value = (*it2); | 1082 | QString value = (*it2); |
1052 | value = value.replace( QRegExp("%1"), param1 ); | 1083 | value = value.replace( QRegExp("%1"), param1 ); |
1053 | value = value.replace( QRegExp("%2"), param2 ); | 1084 | value = value.replace( QRegExp("%2"), param2 ); |
1054 | 1085 | ||
1055 | valmap.insert(key, value); | 1086 | valmap.insert(key, value); |
1056 | useValMap = true; | 1087 | useValMap = true; |
1057 | } | 1088 | } |
1058 | else | 1089 | else |
1059 | { | 1090 | { |
1060 | // qDebug("pass parameter << %s", key.latin1()); | 1091 | // qDebug("pass parameter << %s", key.latin1()); |
1061 | (*e) << key; | 1092 | (*e) << key; |
1062 | } | 1093 | } |
1063 | } | 1094 | } |
1064 | 1095 | ||
1065 | if (useValMap == true) | 1096 | if (useValMap == true) |
1066 | (*e) << valmap; | 1097 | (*e) << valmap; |
1067 | 1098 | ||
1068 | #endif | 1099 | #endif |
1069 | 1100 | ||
1070 | } | 1101 | } |
1071 | 1102 | ||
1072 | 1103 | ||
1073 | 1104 | ||
1074 | /************************************************************************** | 1105 | /************************************************************************** |
1075 | * | 1106 | * |
1076 | **************************************************************************/ | 1107 | **************************************************************************/ |
1077 | 1108 | ||
1078 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1109 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
1079 | { | 1110 | { |
1080 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1111 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1081 | if (!res) | 1112 | if (!res) |
1082 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); | 1113 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); |
1083 | 1114 | ||
1084 | if (!res) | 1115 | if (!res) |
1085 | res = mDisplayDetails->appMessage( cmsg, data ); | 1116 | res = mDisplayDetails->appMessage( cmsg, data ); |
1086 | 1117 | ||
1087 | // if (!res) | 1118 | // if (!res) |
1088 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1119 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1089 | } | 1120 | } |
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 04e2072..7cd6038 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -1,139 +1,139 @@ | |||
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 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kstaticdeleter.h> | 35 | #include <kstaticdeleter.h> |
36 | 36 | ||
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | #include "kpimglobalprefs.h" | 38 | #include "kpimglobalprefs.h" |
39 | 39 | ||
40 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; | 40 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; |
41 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; | 41 | static KStaticDeleter<KPimGlobalPrefs> staticDeleter; |
42 | 42 | ||
43 | 43 | ||
44 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | 44 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) |
45 | : KPrefs("microkdeglobalrc") | 45 | : KPrefs("microkdeglobalrc") |
46 | { | 46 | { |
47 | 47 | ||
48 | KPrefs::setCurrentGroup("Locale"); | 48 | KPrefs::setCurrentGroup("Locale"); |
49 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 49 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
50 | addItemInt("PreferredTime",&mPreferredTime,0); | 50 | addItemInt("PreferredTime",&mPreferredTime,0); |
51 | addItemInt("PreferredDate",&mPreferredDate,0); | 51 | addItemInt("PreferredDate",&mPreferredDate,0); |
52 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 52 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
53 | //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); | 53 | //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); |
54 | // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 54 | // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
55 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 55 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
56 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 56 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
57 | 57 | ||
58 | KPrefs::setCurrentGroup("Time & Date"); | 58 | KPrefs::setCurrentGroup("Time & Date"); |
59 | 59 | ||
60 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 60 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
61 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 61 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
62 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); | 62 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); |
63 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 63 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
64 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 64 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
65 | 65 | ||
66 | KPrefs::setCurrentGroup( "ExternalApplications" ); | 66 | KPrefs::setCurrentGroup( "ExternalApplications" ); |
67 | 67 | ||
68 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); | 68 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); |
69 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | 69 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); |
70 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | 70 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); |
71 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | 71 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); |
72 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | 72 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); |
73 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | 73 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); |
74 | 74 | ||
75 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); | 75 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); |
76 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | 76 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); |
77 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | 77 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); |
78 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | 78 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); |
79 | 79 | ||
80 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | 80 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); |
81 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | 81 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); |
82 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | 82 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); |
83 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | 83 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); |
84 | 84 | ||
85 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | 85 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); |
86 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | 86 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); |
87 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | 87 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); |
88 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | 88 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); |
89 | 89 | ||
90 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | 90 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); |
91 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | 91 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); |
92 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | 92 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); |
93 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | 93 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); |
94 | 94 | ||
95 | addItemInt( "SIPChannelType", &mSipClient, NONE_SIC ); | 95 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); |
96 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); | 96 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); |
97 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); | 97 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); |
98 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); | 98 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); |
99 | 99 | ||
100 | KPrefs::setCurrentGroup( "PhoneAccess" ); | 100 | KPrefs::setCurrentGroup( "PhoneAccess" ); |
101 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | 101 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); |
102 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | 102 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); |
103 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | 103 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | void KPimGlobalPrefs::setGlobalConfig() | 108 | void KPimGlobalPrefs::setGlobalConfig() |
109 | { | 109 | { |
110 | 110 | ||
111 | KGlobal::locale()->setHore24Format( !mPreferredTime ); | 111 | KGlobal::locale()->setHore24Format( !mPreferredTime ); |
112 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); | 112 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); |
113 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); | 113 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); |
114 | KGlobal::locale()->setLanguage( mPreferredLanguage ); | 114 | KGlobal::locale()->setLanguage( mPreferredLanguage ); |
115 | QString dummy = mUserDateFormatLong; | 115 | QString dummy = mUserDateFormatLong; |
116 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 116 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
117 | dummy = mUserDateFormatShort; | 117 | dummy = mUserDateFormatShort; |
118 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 118 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
119 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, | 119 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, |
120 | mDaylightsavingStart, | 120 | mDaylightsavingStart, |
121 | mDaylightsavingEnd ); | 121 | mDaylightsavingEnd ); |
122 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); | 122 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); |
123 | 123 | ||
124 | } | 124 | } |
125 | KPimGlobalPrefs::~KPimGlobalPrefs() | 125 | KPimGlobalPrefs::~KPimGlobalPrefs() |
126 | { | 126 | { |
127 | //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); | 127 | //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); |
128 | writeConfig(); | 128 | writeConfig(); |
129 | } | 129 | } |
130 | 130 | ||
131 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | 131 | KPimGlobalPrefs *KPimGlobalPrefs::instance() |
132 | { | 132 | { |
133 | if ( !sInstance ) { | 133 | if ( !sInstance ) { |
134 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); | 134 | sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); |
135 | sInstance->readConfig(); | 135 | sInstance->readConfig(); |
136 | } | 136 | } |
137 | 137 | ||
138 | return sInstance; | 138 | return sInstance; |
139 | } | 139 | } |
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h index 7c55099..d09c3da 100644 --- a/libkdepim/kpimglobalprefs.h +++ b/libkdepim/kpimglobalprefs.h | |||
@@ -1,139 +1,140 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkdepim. | 2 | This file is part of libkdepim. |
3 | Copyright (c) 2004 Ulf Schenk | 3 | Copyright (c) 2004 Ulf Schenk |
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 | 30 | ||
31 | #ifndef KPIMGLOBALPREFS_H | 31 | #ifndef KPIMGLOBALPREFS_H |
32 | #define KPIMGLOBALPREFS_H | 32 | #define KPIMGLOBALPREFS_H |
33 | 33 | ||
34 | #include "kprefs.h" | 34 | #include "kprefs.h" |
35 | 35 | ||
36 | class KPimGlobalPrefs : public KPrefs | 36 | class KPimGlobalPrefs : public KPrefs |
37 | { | 37 | { |
38 | public: | 38 | public: |
39 | 39 | ||
40 | void setGlobalConfig(); | 40 | void setGlobalConfig(); |
41 | static KPimGlobalPrefs *instance(); | 41 | static KPimGlobalPrefs *instance(); |
42 | 42 | ||
43 | 43 | ||
44 | virtual ~KPimGlobalPrefs(); | 44 | virtual ~KPimGlobalPrefs(); |
45 | 45 | ||
46 | 46 | ||
47 | enum EMailClients { | 47 | enum EMailClients { |
48 | NONE_EMC = 0, | 48 | NONE_EMC = 0, |
49 | OTHER_EMC = 1, | 49 | OTHER_EMC = 1, |
50 | OMPI_EMC = 2, | 50 | OMPI_EMC = 2, |
51 | QTOPIA_EMC = 3, | 51 | QTOPIA_EMC = 3, |
52 | OPIE_EMC = 4 | 52 | OPIE_EMC = 4 |
53 | }; | 53 | }; |
54 | 54 | ||
55 | enum PhoneClients { | 55 | enum PhoneClients { |
56 | NONE_PHC = 0, | 56 | NONE_PHC = 0, |
57 | OTHER_PHC = 1, | 57 | OTHER_PHC = 1, |
58 | KPPI_PHC = 2 | 58 | KPPI_PHC = 2 |
59 | }; | 59 | }; |
60 | 60 | ||
61 | enum FaxClients { | 61 | enum FaxClients { |
62 | NONE_FAC = 0, | 62 | NONE_FAC = 0, |
63 | OTHER_FAC = 1 | 63 | OTHER_FAC = 1 |
64 | }; | 64 | }; |
65 | 65 | ||
66 | enum SMSClients { | 66 | enum SMSClients { |
67 | NONE_SMC = 0, | 67 | NONE_SMC = 0, |
68 | OTHER_SMC = 1 | 68 | OTHER_SMC = 1 |
69 | }; | 69 | }; |
70 | 70 | ||
71 | enum PagerClients { | 71 | enum PagerClients { |
72 | NONE_PAC = 0, | 72 | NONE_PAC = 0, |
73 | OTHER_PAC = 1 | 73 | OTHER_PAC = 1 |
74 | }; | 74 | }; |
75 | 75 | ||
76 | enum SIPClients { | 76 | enum SIPClients { |
77 | NONE_SIC = 0, | 77 | NONE_SIC = 0, |
78 | OTHER_SIC = 1 | 78 | OTHER_SIC = 1, |
79 | KPPI_SIC = 2 | ||
79 | }; | 80 | }; |
80 | 81 | ||
81 | private: | 82 | private: |
82 | KPimGlobalPrefs( const QString &name = QString::null ); | 83 | KPimGlobalPrefs( const QString &name = QString::null ); |
83 | 84 | ||
84 | static KPimGlobalPrefs *sInstance; | 85 | static KPimGlobalPrefs *sInstance; |
85 | 86 | ||
86 | 87 | ||
87 | public: | 88 | public: |
88 | //US I copied the following "locale" settings from KOPrefs | 89 | //US I copied the following "locale" settings from KOPrefs |
89 | int mPreferredDate; | 90 | int mPreferredDate; |
90 | QString mUserDateFormatLong; | 91 | QString mUserDateFormatLong; |
91 | QString mUserDateFormatShort; | 92 | QString mUserDateFormatShort; |
92 | int mPreferredLanguage; | 93 | int mPreferredLanguage; |
93 | int mPreferredTime; | 94 | int mPreferredTime; |
94 | bool mWeekStartsOnSunday; | 95 | bool mWeekStartsOnSunday; |
95 | QString mTimeZoneId; | 96 | QString mTimeZoneId; |
96 | bool mUseDaylightsaving; | 97 | bool mUseDaylightsaving; |
97 | int mDaylightsavingStart; | 98 | int mDaylightsavingStart; |
98 | int mDaylightsavingEnd; | 99 | int mDaylightsavingEnd; |
99 | bool mTimeZoneAdd30min; | 100 | bool mTimeZoneAdd30min; |
100 | 101 | ||
101 | int mEmailClient; | 102 | int mEmailClient; |
102 | QString mEmailOtherChannel; | 103 | QString mEmailOtherChannel; |
103 | QString mEmailOtherMessage; | 104 | QString mEmailOtherMessage; |
104 | QString mEmailOtherMessageParameters; | 105 | QString mEmailOtherMessageParameters; |
105 | QString mEmailOtherMessage2; | 106 | QString mEmailOtherMessage2; |
106 | QString mEmailOtherMessageParameters2; | 107 | QString mEmailOtherMessageParameters2; |
107 | 108 | ||
108 | int mPhoneClient; | 109 | int mPhoneClient; |
109 | QString mPhoneOtherChannel; | 110 | QString mPhoneOtherChannel; |
110 | QString mPhoneOtherMessage; | 111 | QString mPhoneOtherMessage; |
111 | QString mPhoneOtherMessageParameters; | 112 | QString mPhoneOtherMessageParameters; |
112 | 113 | ||
113 | int mFaxClient; | 114 | int mFaxClient; |
114 | QString mFaxOtherChannel; | 115 | QString mFaxOtherChannel; |
115 | QString mFaxOtherMessage; | 116 | QString mFaxOtherMessage; |
116 | QString mFaxOtherMessageParameters; | 117 | QString mFaxOtherMessageParameters; |
117 | 118 | ||
118 | int mSMSClient; | 119 | int mSMSClient; |
119 | QString mSMSOtherChannel; | 120 | QString mSMSOtherChannel; |
120 | QString mSMSOtherMessage; | 121 | QString mSMSOtherMessage; |
121 | QString mSMSOtherMessageParameters; | 122 | QString mSMSOtherMessageParameters; |
122 | 123 | ||
123 | int mPagerClient; | 124 | int mPagerClient; |
124 | QString mPagerOtherChannel; | 125 | QString mPagerOtherChannel; |
125 | QString mPagerOtherMessage; | 126 | QString mPagerOtherMessage; |
126 | QString mPagerOtherMessageParameters; | 127 | QString mPagerOtherMessageParameters; |
127 | 128 | ||
128 | int mSipClient; | 129 | int mSipClient; |
129 | QString mSipOtherChannel; | 130 | QString mSipOtherChannel; |
130 | QString mSipOtherMessage; | 131 | QString mSipOtherMessage; |
131 | QString mSipOtherMessageParameters; | 132 | QString mSipOtherMessageParameters; |
132 | 133 | ||
133 | QString mEx2PhoneDevice; | 134 | QString mEx2PhoneDevice; |
134 | QString mEx2PhoneConnection; | 135 | QString mEx2PhoneConnection; |
135 | QString mEx2PhoneModel; | 136 | QString mEx2PhoneModel; |
136 | 137 | ||
137 | }; | 138 | }; |
138 | 139 | ||
139 | #endif | 140 | #endif |