author | ulf69 <ulf69> | 2004-10-07 01:04:18 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-07 01:04:18 (UTC) |
commit | 0406c1ac252f2fa631f7a486e73b0a97d09874f9 (patch) (unidiff) | |
tree | 72de99490603b5913a39a101ef571ba74acd6798 | |
parent | 0afcfa29ace7bc5e42a11fae44301e1e8230a376 (diff) | |
download | kdepimpi-0406c1ac252f2fa631f7a486e73b0a97d09874f9.zip kdepimpi-0406c1ac252f2fa631f7a486e73b0a97d09874f9.tar.gz kdepimpi-0406c1ac252f2fa631f7a486e73b0a97d09874f9.tar.bz2 |
added functionality for Birthdaylookup from kopi via qCop
-rw-r--r-- | libkdepim/externalapphandler.cpp | 68 | ||||
-rw-r--r-- | libkdepim/externalapphandler.h | 32 |
2 files changed, 86 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 99aee86..07bdff2 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp | |||
@@ -163,283 +163,313 @@ bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data | |||
163 | else if (_usedSourceParameters == 2) | 163 | else if (_usedSourceParameters == 2) |
164 | { | 164 | { |
165 | stream >> param1 >> param2; | 165 | stream >> param1 >> param2; |
166 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); | 166 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2); |
167 | } | 167 | } |
168 | else if (_usedSourceParameters == 3) | 168 | else if (_usedSourceParameters == 3) |
169 | { | 169 | { |
170 | stream >> param1 >> param2 >> param3; | 170 | stream >> param1 >> param2 >> param3; |
171 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); | 171 | emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3); |
172 | } | 172 | } |
173 | 173 | ||
174 | return true; | 174 | return true; |
175 | } | 175 | } |
176 | 176 | ||
177 | return false; | 177 | return false; |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | /********************************************************************************* | 181 | /********************************************************************************* |
182 | * | 182 | * |
183 | ********************************************************************************/ | 183 | ********************************************************************************/ |
184 | 184 | ||
185 | 185 | ||
186 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 186 | QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
187 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 187 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
188 | { | 188 | { |
189 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> | 189 | //targetMessage returns later two parameters: uid, and map<qstring,qstring> |
190 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; | 190 | _targetMessageParameters = "(QString,QMAP<QString,QString>)"; |
191 | } | 191 | } |
192 | 192 | ||
193 | /*********************************************************************************/ | 193 | /*********************************************************************************/ |
194 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) | 194 | bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap) |
195 | { | 195 | { |
196 | #ifndef DESKTOP_VERSION | 196 | #ifndef DESKTOP_VERSION |
197 | //targetMessage passes two parameters: uid, map | 197 | //targetMessage passes two parameters: uid, map |
198 | QString targetMessage = _targetMessage + _targetMessageParameters; | 198 | QString targetMessage = _targetMessage + _targetMessageParameters; |
199 | 199 | ||
200 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 200 | qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
201 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); | 201 | qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1()); |
202 | 202 | ||
203 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 203 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
204 | //US we need no names in the To field. The emailadresses are enough | 204 | //US we need no names in the To field. The emailadresses are enough |
205 | 205 | ||
206 | e << uid << nameEmailMap; | 206 | e << uid << nameEmailMap; |
207 | 207 | ||
208 | qApp->processEvents(); | 208 | qApp->processEvents(); |
209 | 209 | ||
210 | return true; | 210 | return true; |
211 | 211 | ||
212 | #else | 212 | #else |
213 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 213 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
214 | return false; | 214 | return false; |
215 | #endif | 215 | #endif |
216 | 216 | ||
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | /*********************************************************************************/ | 220 | /*********************************************************************************/ |
221 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 221 | bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
222 | { | 222 | { |
223 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 223 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
224 | 224 | ||
225 | if (res == false) | 225 | if (res == false) |
226 | { | 226 | { |
227 | QDataStream stream( data, IO_ReadOnly ); | 227 | QDataStream stream( data, IO_ReadOnly ); |
228 | 228 | ||
229 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); | 229 | // qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() ); |
230 | 230 | ||
231 | //we are in the source and get an answer from the target | 231 | //we are in the source and get an answer from the target |
232 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 232 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
233 | { | 233 | { |
234 | QMap<QString,QString> adrMap; | 234 | QMap<QString,QString> adrMap; |
235 | QString uid; | 235 | QString uid; |
236 | 236 | ||
237 | stream >> uid >> adrMap; | 237 | stream >> uid >> adrMap; |
238 | 238 | ||
239 | emit receivedMessageFromTarget(uid, adrMap); | 239 | emit receivedMessageFromTarget(uid, adrMap); |
240 | 240 | ||
241 | 241 | ||
242 | return true; | 242 | return true; |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | return false; | 246 | return false; |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | /********************************************************************************* | 250 | /********************************************************************************* |
251 | * | 251 | * |
252 | ********************************************************************************/ | 252 | ********************************************************************************/ |
253 | 253 | ||
254 | 254 | ||
255 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) | 255 | QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) |
256 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) | 256 | : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) |
257 | { | 257 | { |
258 | //targetMessage returns later two parameters: uid, and three lists | 258 | //targetMessage returns later two parameters: uid, and three lists |
259 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; | 259 | _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; |
260 | } | 260 | } |
261 | 261 | ||
262 | /*********************************************************************************/ | 262 | /*********************************************************************************/ |
263 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 263 | bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) |
264 | { | 264 | { |
265 | #ifndef DESKTOP_VERSION | 265 | #ifndef DESKTOP_VERSION |
266 | //targetMessage passes two parameters: uid, map | 266 | //targetMessage passes two parameters: uid, map |
267 | QString targetMessage = _targetMessage + _targetMessageParameters; | 267 | QString targetMessage = _targetMessage + _targetMessageParameters; |
268 | 268 | ||
269 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); | 269 | qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); |
270 | qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); | 270 | qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); |
271 | |||
272 | |||
273 | for ( int i = 0; i < list3.count(); i++) | ||
274 | qDebug("listentry list3: %s",list3[i].latin1()); | ||
271 | 275 | ||
272 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); | 276 | QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1()); |
273 | //US we need no names in the To field. The emailadresses are enough | 277 | //US we need no names in the To field. The emailadresses are enough |
274 | 278 | ||
275 | e << uid << list1 << list2 << list3; | 279 | e << uid << list1 << list2 << list3 << list4 << list5 << list6; |
276 | 280 | ||
277 | qApp->processEvents(); | 281 | qApp->processEvents(); |
278 | 282 | ||
279 | return true; | 283 | return true; |
280 | 284 | ||
281 | #else | 285 | #else |
282 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); | 286 | KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) ); |
283 | return false; | 287 | return false; |
284 | #endif | 288 | #endif |
285 | 289 | ||
286 | } | 290 | } |
287 | 291 | ||
288 | 292 | ||
289 | /*********************************************************************************/ | 293 | /*********************************************************************************/ |
290 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) | 294 | bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data ) |
291 | { | 295 | { |
292 | bool res = QCopTransferItem::appMessage( cmsg, data ); | 296 | bool res = QCopTransferItem::appMessage( cmsg, data ); |
293 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 297 | qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
294 | 298 | ||
295 | if (res == false) | 299 | if (res == false) |
296 | { | 300 | { |
297 | QDataStream stream( data, IO_ReadOnly ); | 301 | QDataStream stream( data, IO_ReadOnly ); |
298 | 302 | ||
299 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); | 303 | qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
300 | 304 | ||
301 | //we are in the source and get an answer from the target | 305 | //we are in the source and get an answer from the target |
302 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) | 306 | if ((_targetMessage + _targetMessageParameters) == cmsg.data()) |
303 | { | 307 | { |
304 | QStringList list1; | 308 | QStringList list1; |
305 | QStringList list2; | 309 | QStringList list2; |
306 | QStringList list3; | 310 | QStringList list3; |
311 | QStringList list4; | ||
312 | QStringList list5; | ||
313 | QStringList list6; | ||
307 | QString uid; | 314 | QString uid; |
308 | 315 | ||
309 | stream >> uid >> list1 >> list2 >> list3; | 316 | qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); |
310 | emit receivedMessageFromTarget(uid, list1, list2, list3); | 317 | |
318 | stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; | ||
319 | emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); | ||
311 | 320 | ||
312 | 321 | ||
313 | return true; | 322 | return true; |
314 | } | 323 | } |
315 | } | 324 | } |
316 | 325 | ||
317 | return false; | 326 | return false; |
318 | } | 327 | } |
319 | 328 | ||
320 | 329 | ||
321 | 330 | ||
322 | /********************************************************************************* | 331 | /********************************************************************************* |
323 | * | 332 | * |
324 | ********************************************************************************/ | 333 | ********************************************************************************/ |
325 | 334 | ||
326 | 335 | ||
327 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; | 336 | ExternalAppHandler *ExternalAppHandler::sInstance = 0; |
328 | static KStaticDeleter<ExternalAppHandler> staticDeleter; | 337 | static KStaticDeleter<ExternalAppHandler> staticDeleter; |
329 | 338 | ||
330 | ExternalAppHandler::ExternalAppHandler() | 339 | ExternalAppHandler::ExternalAppHandler() |
331 | { | 340 | { |
332 | mDefaultItems.setAutoDelete(true); | 341 | mDefaultItems.setAutoDelete(true); |
333 | 342 | ||
334 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); | 343 | mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList"); |
335 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); | 344 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&))); |
336 | connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 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&))); |
337 | 346 | ||
338 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); | 347 | //US mFindByEmailFromKAPITransfer = new QCopListTransferItem(1, "requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList"); |
339 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); | 348 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&))); |
340 | //US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 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&))); |
341 | 350 | ||
342 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); | 351 | mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", ""); |
343 | connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); | 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&))); |
353 | |||
354 | |||
355 | |||
356 | 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&))); | ||
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&))); | ||
359 | |||
360 | |||
344 | } | 361 | } |
345 | 362 | ||
346 | ExternalAppHandler::~ExternalAppHandler() | 363 | ExternalAppHandler::~ExternalAppHandler() |
347 | { | 364 | { |
348 | } | 365 | } |
349 | 366 | ||
367 | void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, | ||
368 | const QStringList& nameList, | ||
369 | const QStringList& emailList, | ||
370 | const QStringList& uidList, | ||
371 | const QStringList&, | ||
372 | const QStringList&, | ||
373 | const QStringList& ) | ||
374 | { | ||
375 | // this method is a conevnient way to reduce the number of parameters I have to pass | ||
376 | emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); | ||
377 | } | ||
378 | |||
379 | |||
350 | void ExternalAppHandler::loadConfig() | 380 | void ExternalAppHandler::loadConfig() |
351 | { | 381 | { |
352 | 382 | ||
353 | mDefaultItems.clear(); | 383 | mDefaultItems.clear(); |
354 | mEmailAppAvailable = UNDEFINED; | 384 | mEmailAppAvailable = UNDEFINED; |
355 | mPhoneAppAvailable = UNDEFINED; | 385 | mPhoneAppAvailable = UNDEFINED; |
356 | mFaxAppAvailable = UNDEFINED; | 386 | mFaxAppAvailable = UNDEFINED; |
357 | mSMSAppAvailable = UNDEFINED; | 387 | mSMSAppAvailable = UNDEFINED; |
358 | mPagerAppAvailable = UNDEFINED; | 388 | mPagerAppAvailable = UNDEFINED; |
359 | mSIPAppAvailable = UNDEFINED; | 389 | mSIPAppAvailable = UNDEFINED; |
360 | 390 | ||
361 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); | 391 | QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); |
362 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); | 392 | QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); |
363 | 393 | ||
364 | if (opiepath.isEmpty()) | 394 | if (opiepath.isEmpty()) |
365 | opiepath = qtopiapath; | 395 | opiepath = qtopiapath; |
366 | 396 | ||
367 | //mailclients | 397 | //mailclients |
368 | QString mailmsg1 = "writeMail(QString,QString)"; | 398 | QString mailmsg1 = "writeMail(QString,QString)"; |
369 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; | 399 | QString mailmsg2 = "writeMail(QMap(QString,QString))"; |
370 | 400 | ||
371 | QString undefined = ""; | 401 | QString undefined = ""; |
372 | 402 | ||
373 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); | 403 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); |
374 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); | 404 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); |
375 | 405 | ||
376 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || | 406 | if (( QFile::exists( qtopiapath + "/bin/ompi" )) || |
377 | ( QFile::exists( opiepath + "/bin/ompi" ))) | 407 | ( QFile::exists( opiepath + "/bin/ompi" ))) |
378 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 408 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
379 | 409 | ||
380 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) | 410 | if ( QFile::exists( qtopiapath + "/bin/qtmail" )) |
381 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 411 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
382 | 412 | ||
383 | if ( QFile::exists( opiepath + "/bin/opiemail" )) | 413 | if ( QFile::exists( opiepath + "/bin/opiemail" )) |
384 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); | 414 | addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); |
385 | 415 | ||
386 | 416 | ||
387 | 417 | ||
388 | //phoneclients | 418 | //phoneclients |
389 | 419 | ||
390 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); | 420 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); |
391 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); | 421 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); |
392 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || | 422 | if (( QFile::exists( qtopiapath + "/bin/kppi" )) || |
393 | ( QFile::exists( opiepath + "/bin/kppi" ))) | 423 | ( QFile::exists( opiepath + "/bin/kppi" ))) |
394 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); | 424 | addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); |
395 | 425 | ||
396 | //faxclients | 426 | //faxclients |
397 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); | 427 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); |
398 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); | 428 | addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); |
399 | 429 | ||
400 | //smsclients | 430 | //smsclients |
401 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); | 431 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); |
402 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); | 432 | addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); |
403 | 433 | ||
404 | //pagerclients | 434 | //pagerclients |
405 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); | 435 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); |
406 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); | 436 | addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); |
407 | 437 | ||
408 | //sipclients | 438 | //sipclients |
409 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined); | 439 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined); |
410 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined); | 440 | addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined); |
411 | 441 | ||
412 | } | 442 | } |
413 | 443 | ||
414 | ExternalAppHandler *ExternalAppHandler::instance() | 444 | ExternalAppHandler *ExternalAppHandler::instance() |
415 | { | 445 | { |
416 | if ( !sInstance ) { | 446 | if ( !sInstance ) { |
417 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); | 447 | sInstance = staticDeleter.setObject( new ExternalAppHandler() ); |
418 | sInstance->loadConfig(); | 448 | sInstance->loadConfig(); |
419 | } | 449 | } |
420 | 450 | ||
421 | return sInstance; | 451 | return sInstance; |
422 | } | 452 | } |
423 | 453 | ||
424 | 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) | 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) |
425 | { | 455 | { |
426 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); | 456 | DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2); |
427 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); | 457 | // qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() ); |
428 | mDefaultItems.append(dai); | 458 | mDefaultItems.append(dai); |
429 | } | 459 | } |
430 | 460 | ||
431 | 461 | ||
432 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) | 462 | QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type) |
433 | { | 463 | { |
434 | QList<DefaultAppItem> list; | 464 | QList<DefaultAppItem> list; |
435 | 465 | ||
436 | DefaultAppItem* dai; | 466 | DefaultAppItem* dai; |
437 | 467 | ||
438 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) | 468 | for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) |
439 | { | 469 | { |
440 | if (dai->_type == type) | 470 | if (dai->_type == type) |
441 | list.append(dai); | 471 | list.append(dai); |
442 | } | 472 | } |
443 | 473 | ||
444 | return list; | 474 | return list; |
445 | } | 475 | } |
@@ -956,139 +986,157 @@ bool ExternalAppHandler::callBySIP( const QString& sipnumber ) | |||
956 | 986 | ||
957 | 987 | ||
958 | //first check if one of the sip apps need the emails right in the message. | 988 | //first check if one of the sip apps need the emails right in the message. |
959 | message = translateMessage(message, sipnumber, ""); | 989 | message = translateMessage(message, sipnumber, ""); |
960 | 990 | ||
961 | 991 | ||
962 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); | 992 | qDebug("10Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); |
963 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); | 993 | qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1()); |
964 | 994 | ||
965 | QCopEnvelope e(channel.latin1(), message.latin1()); | 995 | QCopEnvelope e(channel.latin1(), message.latin1()); |
966 | //US we need no names in the To field. The emailadresses are enough | 996 | //US we need no names in the To field. The emailadresses are enough |
967 | 997 | ||
968 | passParameters(&e, parameters, sipnumber, ""); | 998 | passParameters(&e, parameters, sipnumber, ""); |
969 | 999 | ||
970 | 1000 | ||
971 | #else | 1001 | #else |
972 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); | 1002 | KMessageBox::sorry( 0, i18n( "This version does not support sip." ) ); |
973 | #endif | 1003 | #endif |
974 | 1004 | ||
975 | 1005 | ||
976 | return true; | 1006 | return true; |
977 | } | 1007 | } |
978 | 1008 | ||
979 | 1009 | ||
980 | /************************************************************************** | 1010 | /************************************************************************** |
981 | * | 1011 | * |
982 | **************************************************************************/ | 1012 | **************************************************************************/ |
983 | 1013 | ||
984 | 1014 | ||
985 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const | 1015 | QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const |
986 | { | 1016 | { |
987 | message = message.replace( QRegExp("%1"), param1 ); | 1017 | message = message.replace( QRegExp("%1"), param1 ); |
988 | return message.replace( QRegExp("%2"), param2 ); | 1018 | return message.replace( QRegExp("%2"), param2 ); |
989 | } | 1019 | } |
990 | 1020 | ||
991 | /************************************************************************** | 1021 | /************************************************************************** |
992 | * | 1022 | * |
993 | **************************************************************************/ | 1023 | **************************************************************************/ |
994 | 1024 | ||
995 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const | 1025 | void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const |
996 | { | 1026 | { |
997 | #ifndef DESKTOP_VERSION | 1027 | #ifndef DESKTOP_VERSION |
998 | QMap<QString, QString> valmap; | 1028 | QMap<QString, QString> valmap; |
999 | bool useValMap = false; | 1029 | bool useValMap = false; |
1000 | 1030 | ||
1001 | // first extract all parts of the parameters. | 1031 | // first extract all parts of the parameters. |
1002 | QStringList paramlist = QStringList::split(";", parameters); | 1032 | QStringList paramlist = QStringList::split(";", parameters); |
1003 | 1033 | ||
1004 | //Now check how many parts we have. | 1034 | //Now check how many parts we have. |
1005 | //=0 :no params to pass | 1035 | //=0 :no params to pass |
1006 | //>0 :parameters to pass | 1036 | //>0 :parameters to pass |
1007 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) | 1037 | for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it ) |
1008 | { | 1038 | { |
1009 | QString param = (*it); | 1039 | QString param = (*it); |
1010 | QStringList keyvallist = QStringList::split("=", param); | 1040 | QStringList keyvallist = QStringList::split("=", param); |
1011 | 1041 | ||
1012 | //if we have keyvalue pairs, we assume that we pass a map to the envelope | 1042 | //if we have keyvalue pairs, we assume that we pass a map to the envelope |
1013 | QStringList::Iterator it2 = keyvallist.begin(); | 1043 | QStringList::Iterator it2 = keyvallist.begin(); |
1014 | QString key = (*it2); | 1044 | QString key = (*it2); |
1015 | key = key.replace( QRegExp("%1"), param1 ); | 1045 | key = key.replace( QRegExp("%1"), param1 ); |
1016 | key = key.replace( QRegExp("%2"), param2 ); | 1046 | key = key.replace( QRegExp("%2"), param2 ); |
1017 | ++it2; | 1047 | ++it2; |
1018 | 1048 | ||
1019 | if(it2 != keyvallist.end()) | 1049 | if(it2 != keyvallist.end()) |
1020 | { | 1050 | { |
1021 | QString value = (*it2); | 1051 | QString value = (*it2); |
1022 | value = value.replace( QRegExp("%1"), param1 ); | 1052 | value = value.replace( QRegExp("%1"), param1 ); |
1023 | value = value.replace( QRegExp("%2"), param2 ); | 1053 | value = value.replace( QRegExp("%2"), param2 ); |
1024 | 1054 | ||
1025 | valmap.insert(key, value); | 1055 | valmap.insert(key, value); |
1026 | useValMap = true; | 1056 | useValMap = true; |
1027 | } | 1057 | } |
1028 | else | 1058 | else |
1029 | { | 1059 | { |
1030 | // qDebug("pass parameter << %s", key.latin1()); | 1060 | // qDebug("pass parameter << %s", key.latin1()); |
1031 | (*e) << key; | 1061 | (*e) << key; |
1032 | } | 1062 | } |
1033 | } | 1063 | } |
1034 | 1064 | ||
1035 | if (useValMap == true) | 1065 | if (useValMap == true) |
1036 | (*e) << valmap; | 1066 | (*e) << valmap; |
1037 | 1067 | ||
1038 | #endif | 1068 | #endif |
1039 | 1069 | ||
1040 | } | 1070 | } |
1041 | 1071 | ||
1042 | 1072 | ||
1043 | 1073 | ||
1044 | /************************************************************************** | 1074 | /************************************************************************** |
1045 | * | 1075 | * |
1046 | **************************************************************************/ | 1076 | **************************************************************************/ |
1047 | 1077 | ||
1048 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) | 1078 | void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) |
1049 | { | 1079 | { |
1050 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1080 | bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1051 | if (!res) | 1081 | if (!res) |
1082 | res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data ); | ||
1083 | |||
1084 | if (!res) | ||
1052 | res = mDisplayDetails->appMessage( cmsg, data ); | 1085 | res = mDisplayDetails->appMessage( cmsg, data ); |
1053 | 1086 | ||
1054 | // if (!res) | 1087 | // if (!res) |
1055 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); | 1088 | // res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); |
1056 | } | 1089 | } |
1057 | 1090 | ||
1058 | 1091 | ||
1059 | 1092 | ||
1060 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | 1093 | bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid) |
1061 | { | 1094 | { |
1062 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1095 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1063 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); | 1096 | return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); |
1064 | } | 1097 | } |
1065 | 1098 | ||
1066 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1099 | bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1067 | { | 1100 | { |
1068 | 1101 | QStringList list4, list5, list6; | |
1102 | |||
1069 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); | 1103 | mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); |
1070 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); | 1104 | return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1071 | } | 1105 | } |
1072 | 1106 | ||
1073 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) | 1107 | bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) |
1074 | { | 1108 | { |
1075 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1109 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1076 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); | 1110 | return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); |
1077 | } | 1111 | } |
1078 | 1112 | ||
1079 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) | 1113 | bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) |
1080 | { | 1114 | { |
1115 | QStringList list4, list5, list6; | ||
1116 | |||
1081 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); | 1117 | mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); |
1082 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); | 1118 | return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); |
1083 | } | 1119 | } |
1084 | 1120 | ||
1085 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) | 1121 | bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) |
1086 | { | 1122 | { |
1087 | mDisplayDetails->setSourceChannel(""); | 1123 | mDisplayDetails->setSourceChannel(""); |
1088 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); | 1124 | return mDisplayDetails->sendMessageToTarget("", name, email, uid); |
1089 | } | 1125 | } |
1090 | 1126 | ||
1127 | bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) | ||
1128 | { | ||
1129 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | ||
1130 | return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); | ||
1131 | } | ||
1132 | |||
1133 | bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) | ||
1134 | { | ||
1135 | mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); | ||
1136 | return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); | ||
1137 | } | ||
1138 | |||
1091 | 1139 | ||
1092 | 1140 | ||
1093 | 1141 | ||
1094 | 1142 | ||
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index cfe577b..4c6f1ea 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h | |||
@@ -1,267 +1,291 @@ | |||
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 EXTERNALAPPHANDLER_H | 31 | #ifndef EXTERNALAPPHANDLER_H |
32 | #define EXTERNALAPPHANDLER_H | 32 | #define EXTERNALAPPHANDLER_H |
33 | 33 | ||
34 | #include <qobject.h> | 34 | #include <qobject.h> |
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QCopEnvelope; | 38 | class QCopEnvelope; |
39 | 39 | ||
40 | 40 | ||
41 | class ExternalAppHandler; | 41 | class ExternalAppHandler; |
42 | class QCopTransferItem : public QObject | 42 | class QCopTransferItem : public QObject |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 46 | QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
47 | QCopTransferItem(); | 47 | QCopTransferItem(); |
48 | 48 | ||
49 | bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); | 49 | bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null); |
50 | 50 | ||
51 | void setSourceChannel(const QString& sourceChannel); | 51 | void setSourceChannel(const QString& sourceChannel); |
52 | 52 | ||
53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 53 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
54 | 54 | ||
55 | 55 | ||
56 | signals: | 56 | signals: |
57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); | 57 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid); |
58 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); | 58 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); |
59 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); | 59 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2); |
60 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); | 60 | void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3); |
61 | 61 | ||
62 | |||
63 | public: | 62 | public: |
64 | int _usedSourceParameters; | 63 | int _usedSourceParameters; |
65 | QString _sourceChannel; | 64 | QString _sourceChannel; |
66 | QString _sourceMessage; | 65 | QString _sourceMessage; |
67 | QString _sourceMessageParameters; | 66 | QString _sourceMessageParameters; |
68 | QString _targetChannel; | 67 | QString _targetChannel; |
69 | QString _targetMessage; | 68 | QString _targetMessage; |
70 | QString _targetMessageParameters; | 69 | QString _targetMessageParameters; |
71 | 70 | ||
72 | }; | 71 | }; |
73 | 72 | ||
74 | /********************************************************************************* | 73 | /********************************************************************************* |
75 | * | 74 | * |
76 | ********************************************************************************/ | 75 | ********************************************************************************/ |
77 | 76 | ||
78 | class QCopMapTransferItem : public QCopTransferItem | 77 | class QCopMapTransferItem : public QCopTransferItem |
79 | { | 78 | { |
80 | Q_OBJECT | 79 | Q_OBJECT |
81 | public: | 80 | public: |
82 | QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 81 | QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
83 | 82 | ||
84 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); | 83 | bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap); |
85 | 84 | ||
86 | 85 | ||
87 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 86 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
88 | 87 | ||
89 | 88 | ||
90 | signals: | 89 | signals: |
91 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); | 90 | void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); |
92 | 91 | ||
93 | }; | 92 | }; |
94 | 93 | ||
95 | /********************************************************************************* | 94 | /********************************************************************************* |
96 | * | 95 | * |
97 | ********************************************************************************/ | 96 | ********************************************************************************/ |
98 | 97 | ||
99 | class QCopListTransferItem : public QCopTransferItem | 98 | class QCopListTransferItem : public QCopTransferItem |
100 | { | 99 | { |
101 | Q_OBJECT | 100 | Q_OBJECT |
102 | public: | 101 | public: |
103 | QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); | 102 | QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); |
104 | 103 | ||
105 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); | 104 | bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); |
106 | 105 | ||
107 | 106 | ||
108 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); | 107 | virtual bool appMessage( const QCString& msg, const QByteArray& data ); |
109 | 108 | ||
110 | 109 | ||
111 | signals: | 110 | signals: |
112 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); | 111 | void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); |
113 | 112 | ||
114 | }; | 113 | }; |
115 | 114 | ||
116 | /********************************************************************************* | 115 | /********************************************************************************* |
117 | * | 116 | * |
118 | ********************************************************************************/ | 117 | ********************************************************************************/ |
119 | 118 | ||
120 | 119 | ||
121 | class DefaultAppItem | 120 | class DefaultAppItem |
122 | { | 121 | { |
123 | public: | 122 | public: |
124 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) | 123 | DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) |
125 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) | 124 | : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) |
126 | {} | 125 | {} |
127 | 126 | ||
128 | DefaultAppItem() | 127 | DefaultAppItem() |
129 | { } | 128 | { } |
130 | 129 | ||
131 | public: | 130 | public: |
132 | int _type; | 131 | int _type; |
133 | int _id; | 132 | int _id; |
134 | QString _label; | 133 | QString _label; |
135 | QString _channel; | 134 | QString _channel; |
136 | QString _message; | 135 | QString _message; |
137 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; | 136 | QString _parameters;// a list of parameters in stringrepresentation. Delimiter is ; |
138 | QString _message2; | 137 | QString _message2; |
139 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; | 138 | QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; |
140 | 139 | ||
141 | }; | 140 | }; |
142 | 141 | ||
143 | /********************************************************************************* | 142 | /********************************************************************************* |
144 | * | 143 | * |
145 | ********************************************************************************/ | 144 | ********************************************************************************/ |
146 | 145 | ||
147 | class ExternalAppHandler : public QObject | 146 | class ExternalAppHandler : public QObject |
148 | { | 147 | { |
149 | Q_OBJECT | 148 | Q_OBJECT |
150 | public: | 149 | public: |
151 | virtual ~ExternalAppHandler(); | 150 | virtual ~ExternalAppHandler(); |
152 | 151 | ||
153 | static ExternalAppHandler *instance(); | 152 | static ExternalAppHandler *instance(); |
154 | 153 | ||
155 | enum Types { | 154 | enum Types { |
156 | EMAIL = 0, | 155 | EMAIL = 0, |
157 | PHONE = 1, | 156 | PHONE = 1, |
158 | SMS = 2, | 157 | SMS = 2, |
159 | FAX = 3, | 158 | FAX = 3, |
160 | PAGER = 4, | 159 | PAGER = 4, |
161 | SIP = 5 | 160 | SIP = 5 |
162 | }; | 161 | }; |
163 | 162 | ||
164 | enum Availability { | 163 | enum Availability { |
165 | UNDEFINED = -1, | 164 | UNDEFINED = -1, |
166 | UNAVAILABLE = 0, | 165 | UNAVAILABLE = 0, |
167 | AVAILABLE = 1 | 166 | AVAILABLE = 1 |
168 | }; | 167 | }; |
169 | 168 | ||
170 | //calls the emailapplication with a number of attachments that need to be send. | 169 | //calls the emailapplication with a number of attachments that need to be send. |
171 | //either parameter can be left empty. | 170 | //either parameter can be left empty. |
172 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); | 171 | bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls ); |
173 | 172 | ||
174 | //calls the emailapplication and creates a mail with parameter emailadress as recipients | 173 | //calls the emailapplication and creates a mail with parameter emailadress as recipients |
175 | bool mailToOneContact( const QString& name, const QString& emailadress ); | 174 | bool mailToOneContact( const QString& name, const QString& emailadress ); |
176 | 175 | ||
177 | //calls the emailapplication and creates a mail with parameter as recipients | 176 | //calls the emailapplication and creates a mail with parameter as recipients |
178 | // parameters format is | 177 | // parameters format is |
179 | // NAME <EMAIL>:SUBJECT | 178 | // NAME <EMAIL>:SUBJECT |
180 | bool mailToOneContact( const QString& adressline ); | 179 | bool mailToOneContact( const QString& adressline ); |
181 | 180 | ||
182 | //calls the phoneapplication with the number | 181 | //calls the phoneapplication with the number |
183 | bool callByPhone( const QString& phonenumber ); | 182 | bool callByPhone( const QString& phonenumber ); |
184 | 183 | ||
185 | //calls the smsapplication with the number | 184 | //calls the smsapplication with the number |
186 | bool callBySMS( const QString& phonenumber ); | 185 | bool callBySMS( const QString& phonenumber ); |
187 | 186 | ||
188 | //calls the pagerapplication with the number | 187 | //calls the pagerapplication with the number |
189 | bool callByPager( const QString& pagernumber ); | 188 | bool callByPager( const QString& pagernumber ); |
190 | 189 | ||
191 | //calls the faxapplication with the number | 190 | //calls the faxapplication with the number |
192 | bool callByFax( const QString& faxnumber ); | 191 | bool callByFax( const QString& faxnumber ); |
193 | 192 | ||
194 | //calls the sipapplication with the number | 193 | //calls the sipapplication with the number |
195 | bool callBySIP( const QString& sipnumber ); | 194 | bool callBySIP( const QString& sipnumber ); |
196 | 195 | ||
197 | bool isEmailAppAvailable(); | 196 | bool isEmailAppAvailable(); |
198 | bool isSMSAppAvailable(); | 197 | bool isSMSAppAvailable(); |
199 | bool isPhoneAppAvailable(); | 198 | bool isPhoneAppAvailable(); |
200 | bool isFaxAppAvailable(); | 199 | bool isFaxAppAvailable(); |
201 | bool isPagerAppAvailable(); | 200 | bool isPagerAppAvailable(); |
202 | bool isSIPAppAvailable(); | 201 | bool isSIPAppAvailable(); |
203 | 202 | ||
204 | 203 | ||
205 | //Call this method on the source when you want to select names from the addressbook by using QCop | 204 | //Call this method on the source when you want to select names from the addressbook by using QCop |
206 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); | 205 | bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid); |
207 | //Call this method on the target when you want to return the name/email map to the source (client). | 206 | //Call this method on the target when you want to return the name/email map to the source (client). |
208 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); | 207 | bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); |
209 | 208 | ||
209 | |||
210 | |||
210 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); | 211 | bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); |
211 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); | 212 | bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); |
212 | 213 | ||
213 | bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); | 214 | bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); |
214 | 215 | ||
215 | 216 | ||
217 | |||
218 | bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); | ||
219 | bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, | ||
220 | const QStringList& birthdayList, const QStringList& anniversaryList, | ||
221 | const QStringList& realNameList, const QStringList& emailList, | ||
222 | const QStringList& assembledNameList, const QStringList& uidList); | ||
223 | |||
224 | |||
216 | //loadConfig clears the cache and checks again if the applications are available or not | 225 | //loadConfig clears the cache and checks again if the applications are available or not |
217 | void loadConfig(); | 226 | void loadConfig(); |
218 | 227 | ||
219 | QList<DefaultAppItem> getAvailableDefaultItems(Types); | 228 | QList<DefaultAppItem> getAvailableDefaultItems(Types); |
220 | DefaultAppItem* getDefaultItem(Types, int); | 229 | DefaultAppItem* getDefaultItem(Types, int); |
221 | 230 | ||
222 | public slots: | 231 | public slots: |
223 | void appMessage( const QCString& msg, const QByteArray& data ); | 232 | void appMessage( const QCString& msg, const QByteArray& data ); |
224 | 233 | ||
225 | 234 | ||
226 | signals: | 235 | signals: |
227 | // Emmitted when the target app receives a request from the source app | 236 | // Emmitted when the target app receives a request from the source app |
228 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); | 237 | void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid); |
229 | 238 | ||
230 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | 239 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi |
231 | // The first parameter is a uniqueid. It can be used to identify the event | 240 | // The first parameter is a uniqueid. It can be used to identify the event |
232 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | 241 | void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); |
233 | 242 | ||
234 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); | 243 | void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email); |
235 | void receivedFindBbyEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); | 244 | void receivedFindByEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList); |
236 | 245 | ||
237 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); | 246 | void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); |
238 | 247 | ||
239 | 248 | ||
249 | // Emmitted when the target app receives a request from the source app | ||
250 | void requestForBirthdayList(const QString& sourceChannel, const QString& uid); | ||
251 | |||
252 | // Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi | ||
253 | // The first parameter is a uniqueid. It can be used to identify the event | ||
254 | void receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, | ||
255 | const QStringList& anniversaryList, const QStringList& realNameList, | ||
256 | const QStringList& emailList, const QStringList& assembledNameList, | ||
257 | const QStringList& uidList); | ||
258 | |||
259 | |||
240 | private: | 260 | private: |
241 | ExternalAppHandler(); | 261 | ExternalAppHandler(); |
242 | QList<DefaultAppItem> mDefaultItems; | 262 | QList<DefaultAppItem> mDefaultItems; |
243 | 263 | ||
244 | Availability mEmailAppAvailable; | 264 | Availability mEmailAppAvailable; |
245 | Availability mPhoneAppAvailable; | 265 | Availability mPhoneAppAvailable; |
246 | Availability mFaxAppAvailable; | 266 | Availability mFaxAppAvailable; |
247 | Availability mSMSAppAvailable; | 267 | Availability mSMSAppAvailable; |
248 | Availability mPagerAppAvailable; | 268 | Availability mPagerAppAvailable; |
249 | Availability mSIPAppAvailable; | 269 | Availability mSIPAppAvailable; |
250 | 270 | ||
251 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; | 271 | QCopListTransferItem* mNameEmailUidListFromKAPITransfer; |
252 | QCopListTransferItem* mFindByEmailFromKAPITransfer; | 272 | QCopListTransferItem* mFindByEmailFromKAPITransfer; |
253 | QCopTransferItem* mDisplayDetails; | 273 | QCopTransferItem* mDisplayDetails; |
274 | QCopListTransferItem* mBirthdayListFromKAPITransfer; | ||
254 | 275 | ||
255 | 276 | ||
256 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); | 277 | void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2); |
257 | 278 | ||
258 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; | 279 | QString& translateMessage(QString& message, const QString& param1, const QString& param2) const; |
259 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; | 280 | void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const; |
260 | 281 | ||
261 | 282 | ||
262 | static ExternalAppHandler *sInstance; | 283 | static ExternalAppHandler *sInstance; |
263 | 284 | ||
285 | private slots: | ||
286 | void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); | ||
287 | |||
264 | }; | 288 | }; |
265 | 289 | ||
266 | 290 | ||
267 | #endif | 291 | #endif |