-rw-r--r-- | libkdepim/externalapphandler.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 1093abf..35638b1 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -112,569 +112,570 @@ void ExternalAppHandler::loadConfig() | |||
112 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 112 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
113 | 113 | ||
114 | //faxclients | 114 | //faxclients |
115 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 115 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
116 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 116 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
117 | 117 | ||
118 | //smsclients | 118 | //smsclients |
119 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 119 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
120 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 120 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
121 | 121 | ||
122 | //pagerclients | 122 | //pagerclients |
123 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 123 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
124 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 124 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
125 | 125 | ||
126 | } | 126 | } |
127 | 127 | ||
128 | ExternalAppHandler *ExternalAppHandler::instance() | 128 | ExternalAppHandler *ExternalAppHandler::instance() |
129 | { | 129 | { |
130 | if ( !sInstance ) { | 130 | if ( !sInstance ) { |
131 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 131 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
132 | sInstance->loadConfig(); | 132 | sInstance->loadConfig(); |
133 | } | 133 | } |
134 | 134 | ||
135 | return sInstance; | 135 | return sInstance; |
136 | } | 136 | } |
137 | 137 | ||
138 | 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) | 138 | 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) |
139 | { | 139 | { |
140 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 140 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
141 | 141 | ||
142 | mDefaultItems.append(dai); | 142 | mDefaultItems.append(dai); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 146 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
147 | { | 147 | { |
148 | QList<DefaultAppItem> list; | 148 | QList<DefaultAppItem> list; |
149 | 149 | ||
150 | DefaultAppItem* dai; | 150 | DefaultAppItem* dai; |
151 | 151 | ||
152 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 152 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
153 | { | 153 | { |
154 | if (dai->_type == type) | 154 | if (dai->_type == type) |
155 | list.append(dai); | 155 | list.append(dai); |
156 | } | 156 | } |
157 | 157 | ||
158 | return list; | 158 | return list; |
159 | } | 159 | } |
160 | 160 | ||
161 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) | 161 | DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) |
162 | { | 162 | { |
163 | DefaultAppItem* dai; | 163 | DefaultAppItem* dai; |
164 | 164 | ||
165 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 165 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
166 | { | 166 | { |
167 | if (dai->_type == type && dai->_id == clientid) | 167 | if (dai->_type == type && dai->_id == clientid) |
168 | return dai; | 168 | return dai; |
169 | } | 169 | } |
170 | 170 | ||
171 | return 0; | 171 | return 0; |
172 | } | 172 | } |
173 | 173 | ||
174 | bool ExternalAppHandler::isEmailAppAvailable() | 174 | bool ExternalAppHandler::isEmailAppAvailable() |
175 | { | 175 | { |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | if (mEmailAppAvailable == UNDEFINED) | 177 | if (mEmailAppAvailable == UNDEFINED) |
178 | { | 178 | { |
179 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 179 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
180 | if (client == KPimGlobalPrefs::NONE_EMC) | 180 | if (client == KPimGlobalPrefs::NONE_EMC) |
181 | mEmailAppAvailable = UNAVAILABLE; | 181 | mEmailAppAvailable = UNAVAILABLE; |
182 | else | 182 | else |
183 | mEmailAppAvailable = AVAILABLE; | 183 | mEmailAppAvailable = AVAILABLE; |
184 | } | 184 | } |
185 | return (mEmailAppAvailable == AVAILABLE); | 185 | return (mEmailAppAvailable == AVAILABLE); |
186 | 186 | ||
187 | #else //DESKTOP_VERSION | 187 | #else //DESKTOP_VERSION |
188 | return false; | 188 | return false; |
189 | #endif //DESKTOP_VERSION | 189 | #endif //DESKTOP_VERSION |
190 | } | 190 | } |
191 | 191 | ||
192 | bool ExternalAppHandler::isSMSAppAvailable() | 192 | bool ExternalAppHandler::isSMSAppAvailable() |
193 | { | 193 | { |
194 | #ifndef DESKTOP_VERSION | 194 | #ifndef DESKTOP_VERSION |
195 | if (mSMSAppAvailable == UNDEFINED) | 195 | if (mSMSAppAvailable == UNDEFINED) |
196 | { | 196 | { |
197 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 197 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
198 | if (client == KPimGlobalPrefs::NONE_SMC) | 198 | if (client == KPimGlobalPrefs::NONE_SMC) |
199 | mSMSAppAvailable = UNAVAILABLE; | 199 | mSMSAppAvailable = UNAVAILABLE; |
200 | else | 200 | else |
201 | mSMSAppAvailable = AVAILABLE; | 201 | mSMSAppAvailable = AVAILABLE; |
202 | } | 202 | } |
203 | 203 | ||
204 | return (mSMSAppAvailable == AVAILABLE); | 204 | return (mSMSAppAvailable == AVAILABLE); |
205 | #else //DESKTOP_VERSION | 205 | #else //DESKTOP_VERSION |
206 | return false; | 206 | return false; |
207 | #endif //DESKTOP_VERSION | 207 | #endif //DESKTOP_VERSION |
208 | } | 208 | } |
209 | 209 | ||
210 | bool ExternalAppHandler::isPhoneAppAvailable() | 210 | bool ExternalAppHandler::isPhoneAppAvailable() |
211 | { | 211 | { |
212 | #ifndef DESKTOP_VERSION | 212 | #ifndef DESKTOP_VERSION |
213 | if (mPhoneAppAvailable == UNDEFINED) | 213 | if (mPhoneAppAvailable == UNDEFINED) |
214 | { | 214 | { |
215 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 215 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
216 | if (client == KPimGlobalPrefs::NONE_PHC) | 216 | if (client == KPimGlobalPrefs::NONE_PHC) |
217 | mPhoneAppAvailable = UNAVAILABLE; | 217 | mPhoneAppAvailable = UNAVAILABLE; |
218 | else | 218 | else |
219 | mPhoneAppAvailable = AVAILABLE; | 219 | mPhoneAppAvailable = AVAILABLE; |
220 | } | 220 | } |
221 | 221 | ||
222 | return (mPhoneAppAvailable == AVAILABLE); | 222 | return (mPhoneAppAvailable == AVAILABLE); |
223 | #else //DESKTOP_VERSION | 223 | #else //DESKTOP_VERSION |
224 | return false; | 224 | return false; |
225 | #endif //DESKTOP_VERSION | 225 | #endif //DESKTOP_VERSION |
226 | } | 226 | } |
227 | 227 | ||
228 | bool ExternalAppHandler::isFaxAppAvailable() | 228 | bool ExternalAppHandler::isFaxAppAvailable() |
229 | { | 229 | { |
230 | #ifndef DESKTOP_VERSION | 230 | #ifndef DESKTOP_VERSION |
231 | if (mFaxAppAvailable == UNDEFINED) | 231 | if (mFaxAppAvailable == UNDEFINED) |
232 | { | 232 | { |
233 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 233 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
234 | if (client == KPimGlobalPrefs::NONE_FAC) | 234 | if (client == KPimGlobalPrefs::NONE_FAC) |
235 | mFaxAppAvailable = UNAVAILABLE; | 235 | mFaxAppAvailable = UNAVAILABLE; |
236 | else | 236 | else |
237 | mFaxAppAvailable = AVAILABLE; | 237 | mFaxAppAvailable = AVAILABLE; |
238 | } | 238 | } |
239 | 239 | ||
240 | return (mFaxAppAvailable == AVAILABLE); | 240 | return (mFaxAppAvailable == AVAILABLE); |
241 | #else //DESKTOP_VERSION | 241 | #else //DESKTOP_VERSION |
242 | return false; | 242 | return false; |
243 | #endif //DESKTOP_VERSION | 243 | #endif //DESKTOP_VERSION |
244 | } | 244 | } |
245 | 245 | ||
246 | bool ExternalAppHandler::isPagerAppAvailable() | 246 | bool ExternalAppHandler::isPagerAppAvailable() |
247 | { | 247 | { |
248 | #ifndef DESKTOP_VERSION | 248 | #ifndef DESKTOP_VERSION |
249 | if (mPagerAppAvailable == UNDEFINED) | 249 | if (mPagerAppAvailable == UNDEFINED) |
250 | { | 250 | { |
251 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 251 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
252 | if (client == KPimGlobalPrefs::NONE_PAC) | 252 | if (client == KPimGlobalPrefs::NONE_PAC) |
253 | mPagerAppAvailable = UNAVAILABLE; | 253 | mPagerAppAvailable = UNAVAILABLE; |
254 | else | 254 | else |
255 | mPagerAppAvailable = AVAILABLE; | 255 | mPagerAppAvailable = AVAILABLE; |
256 | } | 256 | } |
257 | 257 | ||
258 | return (mPagerAppAvailable == AVAILABLE); | 258 | return (mPagerAppAvailable == AVAILABLE); |
259 | #else //DESKTOP_VERSION | 259 | #else //DESKTOP_VERSION |
260 | return false; | 260 | return false; |
261 | #endif //DESKTOP_VERSION | 261 | #endif //DESKTOP_VERSION |
262 | } | 262 | } |
263 | 263 | ||
264 | /************************************************************************** | 264 | /************************************************************************** |
265 | * | 265 | * |
266 | **************************************************************************/ | 266 | **************************************************************************/ |
267 | 267 | ||
268 | 268 | ||
269 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) | 269 | //calls the emailapplication with a number of attachments that need to be send (Seperated by Comma) |
270 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) | 270 | bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls ) |
271 | { | 271 | { |
272 | 272 | ||
273 | #ifndef DESKTOP_VERSION | 273 | #ifndef DESKTOP_VERSION |
274 | QString channel; | 274 | QString channel; |
275 | QString message2; | 275 | QString message2; |
276 | QString parameters2; | 276 | QString parameters2; |
277 | 277 | ||
278 | 278 | ||
279 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 279 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
280 | if (client == KPimGlobalPrefs::OTHER_EMC) | 280 | if (client == KPimGlobalPrefs::OTHER_EMC) |
281 | { | 281 | { |
282 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 282 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
283 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 283 | message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
284 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 284 | parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
285 | } | 285 | } |
286 | else | 286 | else |
287 | { | 287 | { |
288 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); | 288 | DefaultAppItem* dai = getDefaultItem(EMAIL, client); |
289 | if (!dai) | 289 | if (!dai) |
290 | { | 290 | { |
291 | qDebug("could not find configured email application."); | 291 | qDebug("could not find configured email application."); |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | channel = dai->_channel; | 294 | channel = dai->_channel; |
295 | message2 = dai->_message2; | 295 | message2 = dai->_message2; |
296 | parameters2 = dai->_parameters2; | 296 | parameters2 = dai->_parameters2; |
297 | } | 297 | } |
298 | 298 | ||
299 | //first check if one of the mailers need the emails right in the message. | 299 | //first check if one of the mailers need the emails right in the message. |
300 | message2 = translateMessage(message2, emails, urls); | 300 | message2 = translateMessage(message2, emails, urls); |
301 | 301 | ||
302 | 302 | ||
303 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); | 303 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); |
304 | qDebug("passing emailadresses:(%s), attachmenturls:(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); | 304 | qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); |
305 | 305 | ||
306 | 306 | ||
307 | QCopEnvelope e(channel.latin1(), message2.latin1()); | 307 | QCopEnvelope e(channel.latin1(), message2.latin1()); |
308 | //US we need no names in the To field. The emailadresses are enough | 308 | //US we need no names in the To field. The emailadresses are enough |
309 | 309 | ||
310 | passParameters(&e, parameters2, emails, urls); | 310 | passParameters(&e, parameters2, emails, urls); |
311 | 311 | ||
312 | 312 | ||
313 | 313 | ||
314 | #else | 314 | #else |
315 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 315 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
316 | #endif | 316 | #endif |
317 | 317 | ||
318 | return true; | 318 | return true; |
319 | } | 319 | } |
320 | 320 | ||
321 | /************************************************************************** | 321 | /************************************************************************** |
322 | * | 322 | * |
323 | **************************************************************************/ | 323 | **************************************************************************/ |
324 | 324 | ||
325 | 325 | ||
326 | //calls the emailapplication and creates a mail with parameter emails as recipients | 326 | //calls the emailapplication and creates a mail with parameter emails as recipients |
327 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) | 327 | bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) |
328 | { | 328 | { |
329 | #ifndef DESKTOP_VERSION | 329 | #ifndef DESKTOP_VERSION |
330 | QString channel; | 330 | QString channel; |
331 | QString message; | 331 | QString message; |
332 | QString parameters; | 332 | QString parameters; |
333 | 333 | ||
334 | 334 | ||
335 | int client = KPimGlobalPrefs::instance()->mEmailClient; | 335 | int client = KPimGlobalPrefs::instance()->mEmailClient; |
336 | if (client == KPimGlobalPrefs::OTHER_EMC) | 336 | if (client == KPimGlobalPrefs::OTHER_EMC) |
337 | { | 337 | { |
338 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; | 338 | channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; |
339 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; | 339 | message = KPimGlobalPrefs::instance()->mEmailOtherMessage; |
340 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; | 340 | parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; |
341 | } | 341 | } |
342 | else | 342 | else |
343 | { | 343 | { |
344 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); | 344 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); |
345 | if (!dai) | 345 | if (!dai) |
346 | { | 346 | { |
347 | qDebug("could not find configured email application."); | 347 | qDebug("could not find configured email application."); |
348 | return false; | 348 | return false; |
349 | } | 349 | } |
350 | channel = dai->_channel; | 350 | channel = dai->_channel; |
351 | message = dai->_message; | 351 | message = dai->_message; |
352 | parameters = dai->_parameters; | 352 | parameters = dai->_parameters; |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | //first check if one of the mailers need the emails right in the message. | 356 | //first check if one of the mailers need the emails right in the message. |
357 | message = translateMessage(message, name, emailadress); | 357 | message = translateMessage(message, name, emailadress); |
358 | 358 | ||
359 | 359 | ||
360 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 360 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
361 | qDebug("passing name:(%s), emailadresses:(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); | 361 | qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); |
362 | 362 | ||
363 | QCopEnvelope e(channel.latin1(), message.latin1()); | 363 | QCopEnvelope e(channel.latin1(), message.latin1()); |
364 | //US we need no names in the To field. The emailadresses are enough | 364 | //US we need no names in the To field. The emailadresses are enough |
365 | 365 | ||
366 | passParameters(&e, parameters, name, emailadress); | 366 | passParameters(&e, parameters, name, emailadress); |
367 | 367 | ||
368 | 368 | ||
369 | #else | 369 | #else |
370 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); | 370 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); |
371 | #endif | 371 | #endif |
372 | 372 | ||
373 | 373 | ||
374 | return true; | 374 | return true; |
375 | } | 375 | } |
376 | 376 | ||
377 | /************************************************************************** | 377 | /************************************************************************** |
378 | * | 378 | * |
379 | **************************************************************************/ | 379 | **************************************************************************/ |
380 | 380 | ||
381 | //calls the emailapplication and creates a mail with parameter as recipients | 381 | //calls the emailapplication and creates a mail with parameter as recipients |
382 | // parameters format is | 382 | // parameters format is |
383 | // NAME <EMAIL>:SUBJECT | 383 | // NAME <EMAIL>:SUBJECT |
384 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) | 384 | bool ExternalAppHandler::mailToOneContact( const QString& adressline ) |
385 | { | 385 | { |
386 | QString line = adressline; | 386 | QString line = adressline; |
387 | 387 | ||
388 | int first = line.find( "<"); | 388 | int first = line.find( "<"); |
389 | int last = line.find( ">"); | 389 | int last = line.find( ">"); |
390 | QString name = line.left(first); | 390 | QString name = line.left(first); |
391 | QString emailadress = line.mid(first+1, last-first-1); | 391 | QString emailadress = line.mid(first+1, last-first-1); |
392 | 392 | ||
393 | //Subject can not be handled right now. | 393 | //Subject can not be handled right now. |
394 | mailToOneContact( name, emailadress ); | 394 | mailToOneContact( name, emailadress ); |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | /************************************************************************** | 398 | /************************************************************************** |
399 | * | 399 | * |
400 | **************************************************************************/ | 400 | **************************************************************************/ |
401 | 401 | ||
402 | //calls the phoneapplication with the number | 402 | //calls the phoneapplication with the number |
403 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) | 403 | bool ExternalAppHandler::callByPhone( const QString& phonenumber ) |
404 | { | 404 | { |
405 | #ifndef DESKTOP_VERSION | 405 | #ifndef DESKTOP_VERSION |
406 | QString channel; | 406 | QString channel; |
407 | QString message; | 407 | QString message; |
408 | QString parameters; | 408 | QString parameters; |
409 | 409 | ||
410 | 410 | ||
411 | int client = KPimGlobalPrefs::instance()->mPhoneClient; | 411 | int client = KPimGlobalPrefs::instance()->mPhoneClient; |
412 | if (client == KPimGlobalPrefs::OTHER_PHC) | 412 | if (client == KPimGlobalPrefs::OTHER_PHC) |
413 | { | 413 | { |
414 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; | 414 | channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel; |
415 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; | 415 | message = KPimGlobalPrefs::instance()->mPhoneOtherMessage; |
416 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; | 416 | parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters; |
417 | } | 417 | } |
418 | else | 418 | else |
419 | { | 419 | { |
420 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); | 420 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client); |
421 | if (!dai) | 421 | if (!dai) |
422 | { | 422 | { |
423 | qDebug("could not find configured phone application."); | 423 | qDebug("could not find configured phone application."); |
424 | return false; | 424 | return false; |
425 | } | 425 | } |
426 | channel = dai->_channel; | 426 | channel = dai->_channel; |
427 | message = dai->_message; | 427 | message = dai->_message; |
428 | parameters = dai->_parameters; | 428 | parameters = dai->_parameters; |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | //first check if one of the mailers need the emails right in the message. | 432 | //first check if one of the mailers need the emails right in the message. |
433 | message = translateMessage(message, phonenumber, ""); | 433 | message = translateMessage(message, phonenumber, ""); |
434 | 434 | ||
435 | 435 | ||
436 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 436 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
437 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 437 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
438 | 438 | ||
439 | QCopEnvelope e(channel.latin1(), message.latin1()); | 439 | QCopEnvelope e(channel.latin1(), message.latin1()); |
440 | //US we need no names in the To field. The emailadresses are enough | 440 | //US we need no names in the To field. The emailadresses are enough |
441 | 441 | ||
442 | passParameters(&e, parameters, phonenumber, ""); | 442 | passParameters(&e, parameters, phonenumber, ""); |
443 | 443 | ||
444 | 444 | ||
445 | #else | 445 | #else |
446 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); | 446 | KMessageBox::sorry( 0, i18n( "This version does not support phonecalls." ) ); |
447 | #endif | 447 | #endif |
448 | 448 | ||
449 | 449 | ||
450 | return true; | 450 | return true; |
451 | } | 451 | } |
452 | 452 | ||
453 | /************************************************************************** | 453 | /************************************************************************** |
454 | * | 454 | * |
455 | **************************************************************************/ | 455 | **************************************************************************/ |
456 | 456 | ||
457 | //calls the smsapplication with the number | 457 | //calls the smsapplication with the number |
458 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) | 458 | bool ExternalAppHandler::callBySMS( const QString& phonenumber ) |
459 | { | 459 | { |
460 | #ifndef DESKTOP_VERSION | 460 | #ifndef DESKTOP_VERSION |
461 | QString channel; | 461 | QString channel; |
462 | QString message; | 462 | QString message; |
463 | QString parameters; | 463 | QString parameters; |
464 | 464 | ||
465 | 465 | ||
466 | int client = KPimGlobalPrefs::instance()->mSMSClient; | 466 | int client = KPimGlobalPrefs::instance()->mSMSClient; |
467 | if (client == KPimGlobalPrefs::OTHER_SMC) | 467 | if (client == KPimGlobalPrefs::OTHER_SMC) |
468 | { | 468 | { |
469 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; | 469 | channel = KPimGlobalPrefs::instance()->mSMSOtherChannel; |
470 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; | 470 | message = KPimGlobalPrefs::instance()->mSMSOtherMessage; |
471 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; | 471 | parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters; |
472 | } | 472 | } |
473 | else | 473 | else |
474 | { | 474 | { |
475 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); | 475 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client); |
476 | if (!dai) | 476 | if (!dai) |
477 | { | 477 | { |
478 | qDebug("could not find configured sms application."); | 478 | qDebug("could not find configured sms application."); |
479 | return false; | 479 | return false; |
480 | } | 480 | } |
481 | channel = dai->_channel; | 481 | channel = dai->_channel; |
482 | message = dai->_message; | 482 | message = dai->_message; |
483 | parameters = dai->_parameters; | 483 | parameters = dai->_parameters; |
484 | } | 484 | } |
485 | 485 | ||
486 | 486 | ||
487 | //first check if one of the mailers need the emails right in the message. | 487 | //first check if one of the mailers need the emails right in the message. |
488 | message = translateMessage(message, phonenumber, ""); | 488 | message = translateMessage(message, phonenumber, ""); |
489 | 489 | ||
490 | 490 | ||
491 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 491 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
492 | qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); | 492 | qDebug("passing phonenumber(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1()); |
493 | 493 | ||
494 | QCopEnvelope e(channel.latin1(), message.latin1()); | 494 | QCopEnvelope e(channel.latin1(), message.latin1()); |
495 | //US we need no names in the To field. The emailadresses are enough | 495 | //US we need no names in the To field. The emailadresses are enough |
496 | 496 | ||
497 | passParameters(&e, parameters, phonenumber, ""); | 497 | passParameters(&e, parameters, phonenumber, ""); |
498 | 498 | ||
499 | 499 | ||
500 | #else | 500 | #else |
501 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); | 501 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of sms." ) ); |
502 | #endif | 502 | #endif |
503 | 503 | ||
504 | 504 | ||
505 | return true; | 505 | return true; |
506 | } | 506 | } |
507 | 507 | ||
508 | /************************************************************************** | 508 | /************************************************************************** |
509 | * | 509 | * |
510 | **************************************************************************/ | 510 | **************************************************************************/ |
511 | 511 | ||
512 | //calls the pagerapplication with the number | 512 | //calls the pagerapplication with the number |
513 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) | 513 | bool ExternalAppHandler::callByPager( const QString& pagernumber ) |
514 | { | 514 | { |
515 | #ifndef DESKTOP_VERSION | 515 | #ifndef DESKTOP_VERSION |
516 | QString channel; | 516 | QString channel; |
517 | QString message; | 517 | QString message; |
518 | QString parameters; | 518 | QString parameters; |
519 | 519 | ||
520 | 520 | ||
521 | int client = KPimGlobalPrefs::instance()->mPagerClient; | 521 | int client = KPimGlobalPrefs::instance()->mPagerClient; |
522 | if (client == KPimGlobalPrefs::OTHER_PAC) | 522 | if (client == KPimGlobalPrefs::OTHER_PAC) |
523 | { | 523 | { |
524 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; | 524 | channel = KPimGlobalPrefs::instance()->mPagerOtherChannel; |
525 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; | 525 | message = KPimGlobalPrefs::instance()->mPagerOtherMessage; |
526 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; | 526 | parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters; |
527 | } | 527 | } |
528 | else | 528 | else |
529 | { | 529 | { |
530 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); | 530 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client); |
531 | if (!dai) | 531 | if (!dai) |
532 | { | 532 | { |
533 | qDebug("could not find configured pager application."); | 533 | qDebug("could not find configured pager application."); |
534 | return false; | 534 | return false; |
535 | } | 535 | } |
536 | channel = dai->_channel; | 536 | channel = dai->_channel; |
537 | message = dai->_message; | 537 | message = dai->_message; |
538 | parameters = dai->_parameters; | 538 | parameters = dai->_parameters; |
539 | } | 539 | } |
540 | 540 | ||
541 | 541 | ||
542 | //first check if one of the mailers need the emails right in the message. | 542 | //first check if one of the mailers need the emails right in the message. |
543 | message = translateMessage(message, pagernumber, ""); | 543 | message = translateMessage(message, pagernumber, ""); |
544 | 544 | ||
545 | 545 | ||
546 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 546 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
547 | qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); | 547 | qDebug("passing pagernumber(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1()); |
548 | 548 | ||
549 | QCopEnvelope e(channel.latin1(), message.latin1()); | 549 | QCopEnvelope e(channel.latin1(), message.latin1()); |
550 | //US we need no names in the To field. The emailadresses are enough | 550 | //US we need no names in the To field. The emailadresses are enough |
551 | 551 | ||
552 | passParameters(&e, parameters, pagernumber, ""); | 552 | passParameters(&e, parameters, pagernumber, ""); |
553 | 553 | ||
554 | 554 | ||
555 | #else | 555 | #else |
556 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); | 556 | KMessageBox::sorry( 0, i18n( "This version does not support paging." ) ); |
557 | #endif | 557 | #endif |
558 | 558 | ||
559 | 559 | ||
560 | return true; | 560 | return true; |
561 | } | 561 | } |
562 | 562 | ||
563 | /************************************************************************** | 563 | /************************************************************************** |
564 | * | 564 | * |
565 | **************************************************************************/ | 565 | **************************************************************************/ |
566 | 566 | ||
567 | //calls the faxapplication with the number | 567 | //calls the faxapplication with the number |
568 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) | 568 | bool ExternalAppHandler::callByFax( const QString& faxnumber ) |
569 | { | 569 | { |
570 | #ifndef DESKTOP_VERSION | 570 | #ifndef DESKTOP_VERSION |
571 | QString channel; | 571 | QString channel; |
572 | QString message; | 572 | QString message; |
573 | QString parameters; | 573 | QString parameters; |
574 | 574 | ||
575 | 575 | ||
576 | int client = KPimGlobalPrefs::instance()->mFaxClient; | 576 | int client = KPimGlobalPrefs::instance()->mFaxClient; |
577 | if (client == KPimGlobalPrefs::OTHER_FAC) | 577 | if (client == KPimGlobalPrefs::OTHER_FAC) |
578 | { | 578 | { |
579 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; | 579 | channel = KPimGlobalPrefs::instance()->mFaxOtherChannel; |
580 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; | 580 | message = KPimGlobalPrefs::instance()->mFaxOtherMessage; |
581 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; | 581 | parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters; |
582 | } | 582 | } |
583 | else | 583 | else |
584 | { | 584 | { |
585 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); | 585 | DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client); |
586 | if (!dai) | 586 | if (!dai) |
587 | { | 587 | { |
588 | qDebug("could not find configured fax application."); | 588 | qDebug("could not find configured fax application."); |
589 | return false; | 589 | return false; |
590 | } | 590 | } |
591 | channel = dai->_channel; | 591 | channel = dai->_channel; |
592 | message = dai->_message; | 592 | message = dai->_message; |
593 | parameters = dai->_parameters; | 593 | parameters = dai->_parameters; |
594 | } | 594 | } |
595 | 595 | ||
596 | 596 | ||
597 | //first check if one of the mailers need the emails right in the message. | 597 | //first check if one of the mailers need the emails right in the message. |
598 | message = translateMessage(message, faxnumber, ""); | 598 | message = translateMessage(message, faxnumber, ""); |
599 | 599 | ||
600 | 600 | ||
601 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 601 | qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
602 | qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); | 602 | qDebug("passing faxnumber(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1()); |
603 | 603 | ||
604 | QCopEnvelope e(channel.latin1(), message.latin1()); | 604 | QCopEnvelope e(channel.latin1(), message.latin1()); |
605 | //US we need no names in the To field. The emailadresses are enough | 605 | //US we need no names in the To field. The emailadresses are enough |
606 | 606 | ||
607 | passParameters(&e, parameters, faxnumber, ""); | 607 | passParameters(&e, parameters, faxnumber, ""); |
608 | 608 | ||
609 | 609 | ||
610 | #else | 610 | #else |
611 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); | 611 | KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) ); |
612 | #endif | 612 | #endif |
613 | 613 | ||
614 | 614 | ||
615 | return true; | 615 | return true; |
616 | } | 616 | } |
617 | 617 | ||
618 | /************************************************************************** | 618 | /************************************************************************** |
619 | * | 619 | * |
620 | **************************************************************************/ | 620 | **************************************************************************/ |
621 | 621 | ||
622 | 622 | ||
623 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 623 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
624 | { | 624 | { |
625 | message = message.replace( QRegExp("%1"), param1 ); | 625 | message = message.replace( QRegExp("%1"), param1 ); |
626 | return message.replace( QRegExp("%2"), param2 ); | 626 | return message.replace( QRegExp("%2"), param2 ); |
627 | } | 627 | } |
628 | 628 | ||
629 | /************************************************************************** | 629 | /************************************************************************** |
630 | * | 630 | * |
631 | **************************************************************************/ | 631 | **************************************************************************/ |
632 | 632 | ||
633 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 633 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
634 | { | 634 | { |
635 | #ifndef DESKTOP_VERSION | 635 | #ifndef DESKTOP_VERSION |
636 | QMap<QString, QString> valmap; | 636 | QMap<QString, QString> valmap; |
637 | bool useValMap = false; | 637 | bool useValMap = false; |
638 | 638 | ||
639 | // first extract all parts of the parameters. | 639 | // first extract all parts of the parameters. |
640 | QStringList paramlist = QStringList::split(";", parameters); | 640 | QStringList paramlist = QStringList::split(";", parameters); |
641 | 641 | ||
642 | //Now check how many parts we have. | 642 | //Now check how many parts we have. |
643 | //=0 :no params to pass | 643 | //=0 :no params to pass |
644 | //>0 :parameters to pass | 644 | //>0 :parameters to pass |
645 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 645 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
646 | { | 646 | { |
647 | QString param = (*it); | 647 | QString param = (*it); |
648 | QStringList keyvallist = QStringList::split("=", param); | 648 | QStringList keyvallist = QStringList::split("=", param); |
649 | 649 | ||
650 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 650 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
651 | QStringList::Iterator it2 = keyvallist.begin(); | 651 | QStringList::Iterator it2 = keyvallist.begin(); |
652 | QString key = (*it2); | 652 | QString key = (*it2); |
653 | key = key.replace( QRegExp("%1"), param1 ); | 653 | key = key.replace( QRegExp("%1"), param1 ); |
654 | key = key.replace( QRegExp("%2"), param2 ); | 654 | key = key.replace( QRegExp("%2"), param2 ); |
655 | ++it2; | 655 | ++it2; |
656 | 656 | ||
657 | if(it2 != keyvallist.end()) | 657 | if(it2 != keyvallist.end()) |
658 | { | 658 | { |
659 | QString value = (*it2); | 659 | QString value = (*it2); |
660 | value = value.replace( QRegExp("%1"), param1 ); | 660 | value = value.replace( QRegExp("%1"), param1 ); |
661 | value = value.replace( QRegExp("%2"), param2 ); | 661 | value = value.replace( QRegExp("%2"), param2 ); |
662 | 662 | ||
663 | valmap.insert(key, value); | 663 | valmap.insert(key, value); |
664 | useValMap = true; | 664 | useValMap = true; |
665 | } | 665 | } |
666 | else | 666 | else |
667 | { | 667 | { |
668 | (*e) << key.latin1(); | 668 | // qDebug("pass parameter << %s", key.latin1()); |
669 | (*e) << key; | ||
669 | } | 670 | } |
670 | } | 671 | } |
671 | 672 | ||
672 | if (useValMap == true) | 673 | if (useValMap == true) |
673 | (*e) << valmap; | 674 | (*e) << valmap; |
674 | 675 | ||
675 | #endif | 676 | #endif |
676 | 677 | ||
677 | } | 678 | } |
678 | 679 | ||
679 | 680 | ||
680 | 681 | ||