author | ulf69 <ulf69> | 2004-08-10 22:46:12 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-10 22:46:12 (UTC) |
commit | 02d51ae409a353d3a79e976c26ccc1f652e55de8 (patch) (unidiff) | |
tree | 54d7a9f1eecd2ef9c3332f2bc22ff6ac6d9af335 /kaddressbook | |
parent | dc81e96e29f619c6eb32c3ed18ff45b789c8504e (diff) | |
download | kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.zip kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.tar.gz kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.tar.bz2 |
final changes on how to send emails to selected contacts
-rw-r--r-- | kaddressbook/kabcore.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index d6f0cee..6610288 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp | |||
@@ -212,577 +212,571 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const | |||
212 | #ifndef KAB_EMBEDDED | 212 | #ifndef KAB_EMBEDDED |
213 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), | 213 | connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), |
214 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); | 214 | mXXPortManager, SLOT( importVCard( const KURL& ) ) ); |
215 | 215 | ||
216 | connect( mDetails, SIGNAL( browse( const QString& ) ), | 216 | connect( mDetails, SIGNAL( browse( const QString& ) ), |
217 | SLOT( browse( const QString& ) ) ); | 217 | SLOT( browse( const QString& ) ) ); |
218 | 218 | ||
219 | mAddressBookService = new KAddressBookService( this ); | 219 | mAddressBookService = new KAddressBookService( this ); |
220 | 220 | ||
221 | #endif //KAB_EMBEDDED | 221 | #endif //KAB_EMBEDDED |
222 | mEditorDialog = 0; | 222 | mEditorDialog = 0; |
223 | createAddresseeEditorDialog( this ); | 223 | createAddresseeEditorDialog( this ); |
224 | setModified( false ); | 224 | setModified( false ); |
225 | } | 225 | } |
226 | 226 | ||
227 | KABCore::~KABCore() | 227 | KABCore::~KABCore() |
228 | { | 228 | { |
229 | // save(); | 229 | // save(); |
230 | //saveSettings(); | 230 | //saveSettings(); |
231 | //KABPrefs::instance()->writeConfig(); | 231 | //KABPrefs::instance()->writeConfig(); |
232 | delete AddresseeConfig::instance(); | 232 | delete AddresseeConfig::instance(); |
233 | mAddressBook = 0; | 233 | mAddressBook = 0; |
234 | KABC::StdAddressBook::close(); | 234 | KABC::StdAddressBook::close(); |
235 | } | 235 | } |
236 | 236 | ||
237 | void KABCore::restoreSettings() | 237 | void KABCore::restoreSettings() |
238 | { | 238 | { |
239 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; | 239 | bool state = KABPrefs::instance()->mJumpButtonBarVisible; |
240 | 240 | ||
241 | mActionJumpBar->setChecked( state ); | 241 | mActionJumpBar->setChecked( state ); |
242 | setJumpButtonBarVisible( state ); | 242 | setJumpButtonBarVisible( state ); |
243 | 243 | ||
244 | state = KABPrefs::instance()->mDetailsPageVisible; | 244 | state = KABPrefs::instance()->mDetailsPageVisible; |
245 | 245 | ||
246 | mActionDetails->setChecked( state ); | 246 | mActionDetails->setChecked( state ); |
247 | setDetailsVisible( state ); | 247 | setDetailsVisible( state ); |
248 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; | 248 | QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; |
249 | if ( splitterSize.count() == 0 ) { | 249 | if ( splitterSize.count() == 0 ) { |
250 | splitterSize.append( width() / 2 ); | 250 | splitterSize.append( width() / 2 ); |
251 | splitterSize.append( width() / 2 ); | 251 | splitterSize.append( width() / 2 ); |
252 | } | 252 | } |
253 | mMiniSplitter->setSizes( splitterSize ); | 253 | mMiniSplitter->setSizes( splitterSize ); |
254 | if ( mExtensionBarSplitter ) { | 254 | if ( mExtensionBarSplitter ) { |
255 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 255 | splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
256 | if ( splitterSize.count() == 0 ) { | 256 | if ( splitterSize.count() == 0 ) { |
257 | splitterSize.append( width() / 2 ); | 257 | splitterSize.append( width() / 2 ); |
258 | splitterSize.append( width() / 2 ); | 258 | splitterSize.append( width() / 2 ); |
259 | } | 259 | } |
260 | mExtensionBarSplitter->setSizes( splitterSize ); | 260 | mExtensionBarSplitter->setSizes( splitterSize ); |
261 | 261 | ||
262 | } | 262 | } |
263 | #ifndef KAB_EMBEDDED | 263 | #ifndef KAB_EMBEDDED |
264 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; | 264 | QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; |
265 | if ( splitterSize.count() == 0 ) { | 265 | if ( splitterSize.count() == 0 ) { |
266 | splitterSize.append( width() / 2 ); | 266 | splitterSize.append( width() / 2 ); |
267 | splitterSize.append( width() / 2 ); | 267 | splitterSize.append( width() / 2 ); |
268 | } | 268 | } |
269 | mExtensionBarSplitter->setSizes( splitterSize ); | 269 | mExtensionBarSplitter->setSizes( splitterSize ); |
270 | 270 | ||
271 | splitterSize = KABPrefs::instance()->mDetailsSplitter; | 271 | splitterSize = KABPrefs::instance()->mDetailsSplitter; |
272 | if ( splitterSize.count() == 0 ) { | 272 | if ( splitterSize.count() == 0 ) { |
273 | splitterSize.append( height() / 2 ); | 273 | splitterSize.append( height() / 2 ); |
274 | splitterSize.append( height() / 2 ); | 274 | splitterSize.append( height() / 2 ); |
275 | } | 275 | } |
276 | mDetailsSplitter->setSizes( splitterSize ); | 276 | mDetailsSplitter->setSizes( splitterSize ); |
277 | 277 | ||
278 | mExtensionManager->restoreSettings(); | 278 | mExtensionManager->restoreSettings(); |
279 | 279 | ||
280 | #endif //KAB_EMBEDDED | 280 | #endif //KAB_EMBEDDED |
281 | 281 | ||
282 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); | 282 | mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); |
283 | 283 | ||
284 | mViewManager->restoreSettings(); | 284 | mViewManager->restoreSettings(); |
285 | mExtensionManager->restoreSettings(); | 285 | mExtensionManager->restoreSettings(); |
286 | } | 286 | } |
287 | 287 | ||
288 | void KABCore::saveSettings() | 288 | void KABCore::saveSettings() |
289 | { | 289 | { |
290 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); | 290 | KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); |
291 | if ( mExtensionBarSplitter ) | 291 | if ( mExtensionBarSplitter ) |
292 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 292 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
293 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); | 293 | KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); |
294 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); | 294 | KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); |
295 | #ifndef KAB_EMBEDDED | 295 | #ifndef KAB_EMBEDDED |
296 | 296 | ||
297 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); | 297 | KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); |
298 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); | 298 | KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); |
299 | #endif //KAB_EMBEDDED | 299 | #endif //KAB_EMBEDDED |
300 | mExtensionManager->saveSettings(); | 300 | mExtensionManager->saveSettings(); |
301 | mViewManager->saveSettings(); | 301 | mViewManager->saveSettings(); |
302 | 302 | ||
303 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); | 303 | KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); |
304 | 304 | ||
305 | } | 305 | } |
306 | 306 | ||
307 | KABC::AddressBook *KABCore::addressBook() const | 307 | KABC::AddressBook *KABCore::addressBook() const |
308 | { | 308 | { |
309 | return mAddressBook; | 309 | return mAddressBook; |
310 | } | 310 | } |
311 | 311 | ||
312 | KConfig *KABCore::config() | 312 | KConfig *KABCore::config() |
313 | { | 313 | { |
314 | #ifndef KAB_EMBEDDED | 314 | #ifndef KAB_EMBEDDED |
315 | return KABPrefs::instance()->config(); | 315 | return KABPrefs::instance()->config(); |
316 | #else //KAB_EMBEDDED | 316 | #else //KAB_EMBEDDED |
317 | return KABPrefs::instance()->getConfig(); | 317 | return KABPrefs::instance()->getConfig(); |
318 | #endif //KAB_EMBEDDED | 318 | #endif //KAB_EMBEDDED |
319 | } | 319 | } |
320 | 320 | ||
321 | KActionCollection *KABCore::actionCollection() const | 321 | KActionCollection *KABCore::actionCollection() const |
322 | { | 322 | { |
323 | return mGUIClient->actionCollection(); | 323 | return mGUIClient->actionCollection(); |
324 | } | 324 | } |
325 | 325 | ||
326 | KABC::Field *KABCore::currentSearchField() const | 326 | KABC::Field *KABCore::currentSearchField() const |
327 | { | 327 | { |
328 | if (mIncSearchWidget) | 328 | if (mIncSearchWidget) |
329 | return mIncSearchWidget->currentField(); | 329 | return mIncSearchWidget->currentField(); |
330 | else | 330 | else |
331 | return 0; | 331 | return 0; |
332 | } | 332 | } |
333 | 333 | ||
334 | QStringList KABCore::selectedUIDs() const | 334 | QStringList KABCore::selectedUIDs() const |
335 | { | 335 | { |
336 | return mViewManager->selectedUids(); | 336 | return mViewManager->selectedUids(); |
337 | } | 337 | } |
338 | 338 | ||
339 | KABC::Resource *KABCore::requestResource( QWidget *parent ) | 339 | KABC::Resource *KABCore::requestResource( QWidget *parent ) |
340 | { | 340 | { |
341 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); | 341 | QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); |
342 | 342 | ||
343 | QPtrList<KRES::Resource> kresResources; | 343 | QPtrList<KRES::Resource> kresResources; |
344 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); | 344 | QPtrListIterator<KABC::Resource> resIt( kabcResources ); |
345 | KABC::Resource *resource; | 345 | KABC::Resource *resource; |
346 | while ( ( resource = resIt.current() ) != 0 ) { | 346 | while ( ( resource = resIt.current() ) != 0 ) { |
347 | ++resIt; | 347 | ++resIt; |
348 | if ( !resource->readOnly() ) { | 348 | if ( !resource->readOnly() ) { |
349 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); | 349 | KRES::Resource *res = static_cast<KRES::Resource*>( resource ); |
350 | if ( res ) | 350 | if ( res ) |
351 | kresResources.append( res ); | 351 | kresResources.append( res ); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | 354 | ||
355 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); | 355 | KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); |
356 | return static_cast<KABC::Resource*>( res ); | 356 | return static_cast<KABC::Resource*>( res ); |
357 | } | 357 | } |
358 | 358 | ||
359 | #ifndef KAB_EMBEDDED | 359 | #ifndef KAB_EMBEDDED |
360 | KAboutData *KABCore::createAboutData() | 360 | KAboutData *KABCore::createAboutData() |
361 | #else //KAB_EMBEDDED | 361 | #else //KAB_EMBEDDED |
362 | void KABCore::createAboutData() | 362 | void KABCore::createAboutData() |
363 | #endif //KAB_EMBEDDED | 363 | #endif //KAB_EMBEDDED |
364 | { | 364 | { |
365 | #ifndef KAB_EMBEDDED | 365 | #ifndef KAB_EMBEDDED |
366 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), | 366 | KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), |
367 | "3.1", I18N_NOOP( "The KDE Address Book" ), | 367 | "3.1", I18N_NOOP( "The KDE Address Book" ), |
368 | KAboutData::License_GPL_V2, | 368 | KAboutData::License_GPL_V2, |
369 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); | 369 | I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); |
370 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); | 370 | about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); |
371 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); | 371 | about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); |
372 | about->addAuthor( "Cornelius Schumacher", | 372 | about->addAuthor( "Cornelius Schumacher", |
373 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), | 373 | I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), |
374 | "schumacher@kde.org" ); | 374 | "schumacher@kde.org" ); |
375 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), | 375 | about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), |
376 | "mpilone@slac.com" ); | 376 | "mpilone@slac.com" ); |
377 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); | 377 | about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); |
378 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); | 378 | about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); |
379 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), | 379 | about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), |
380 | "michel@klaralvdalens-datakonsult.se" ); | 380 | "michel@klaralvdalens-datakonsult.se" ); |
381 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), | 381 | about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), |
382 | "hansen@kde.org" ); | 382 | "hansen@kde.org" ); |
383 | 383 | ||
384 | return about; | 384 | return about; |
385 | #endif //KAB_EMBEDDED | 385 | #endif //KAB_EMBEDDED |
386 | 386 | ||
387 | QString version; | 387 | QString version; |
388 | #include <../version> | 388 | #include <../version> |
389 | QMessageBox::about( this, "About KAddressbook/Pi", | 389 | QMessageBox::about( this, "About KAddressbook/Pi", |
390 | "KAddressbook/Platform-independent\n" | 390 | "KAddressbook/Platform-independent\n" |
391 | "(KA/Pi) " +version + " - " + | 391 | "(KA/Pi) " +version + " - " + |
392 | #ifdef DESKTOP_VERSION | 392 | #ifdef DESKTOP_VERSION |
393 | "Desktop Edition\n" | 393 | "Desktop Edition\n" |
394 | #else | 394 | #else |
395 | "PDA-Edition\n" | 395 | "PDA-Edition\n" |
396 | "for: Zaurus 5500 / 7x0 / 8x0\n" | 396 | "for: Zaurus 5500 / 7x0 / 8x0\n" |
397 | #endif | 397 | #endif |
398 | 398 | ||
399 | "(c) 2004 Ulf Schenk\n" | 399 | "(c) 2004 Ulf Schenk\n" |
400 | "(c) 1997-2003, The KDE PIM Team\n" | 400 | "(c) 1997-2003, The KDE PIM Team\n" |
401 | "Tobias Koenig Current maintainer tokoe@kde.org\n" | 401 | "Tobias Koenig Current maintainer tokoe@kde.org\n" |
402 | "Don Sanders Original author\n" | 402 | "Don Sanders Original author\n" |
403 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" | 403 | "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" |
404 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" | 404 | "Mike Pilone GUI and framework redesign mpilone@slac.com\n" |
405 | "Greg Stern DCOP interface\n" | 405 | "Greg Stern DCOP interface\n" |
406 | "Mark Westcot Contact pinning\n" | 406 | "Mark Westcot Contact pinning\n" |
407 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" | 407 | "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" |
408 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" | 408 | "Steffen Hansen LDAP Lookup hansen@kde.org\n" |
409 | #ifdef _WIN32_ | 409 | #ifdef _WIN32_ |
410 | "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" | 410 | "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" |
411 | #endif | 411 | #endif |
412 | ); | 412 | ); |
413 | } | 413 | } |
414 | 414 | ||
415 | void KABCore::setContactSelected( const QString &uid ) | 415 | void KABCore::setContactSelected( const QString &uid ) |
416 | { | 416 | { |
417 | KABC::Addressee addr = mAddressBook->findByUid( uid ); | 417 | KABC::Addressee addr = mAddressBook->findByUid( uid ); |
418 | if ( !mDetails->isHidden() ) | 418 | if ( !mDetails->isHidden() ) |
419 | mDetails->setAddressee( addr ); | 419 | mDetails->setAddressee( addr ); |
420 | 420 | ||
421 | if ( !addr.isEmpty() ) { | 421 | if ( !addr.isEmpty() ) { |
422 | emit contactSelected( addr.formattedName() ); | 422 | emit contactSelected( addr.formattedName() ); |
423 | KABC::Picture pic = addr.photo(); | 423 | KABC::Picture pic = addr.photo(); |
424 | if ( pic.isIntern() ) { | 424 | if ( pic.isIntern() ) { |
425 | //US emit contactSelected( pic.data() ); | 425 | //US emit contactSelected( pic.data() ); |
426 | //US instead use: | 426 | //US instead use: |
427 | QPixmap px; | 427 | QPixmap px; |
428 | if (pic.data().isNull() != true) | 428 | if (pic.data().isNull() != true) |
429 | { | 429 | { |
430 | px.convertFromImage(pic.data()); | 430 | px.convertFromImage(pic.data()); |
431 | } | 431 | } |
432 | 432 | ||
433 | emit contactSelected( px ); | 433 | emit contactSelected( px ); |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
438 | mExtensionManager->setSelectionChanged(); | 438 | mExtensionManager->setSelectionChanged(); |
439 | 439 | ||
440 | // update the actions | 440 | // update the actions |
441 | bool selected = !uid.isEmpty(); | 441 | bool selected = !uid.isEmpty(); |
442 | 442 | ||
443 | if ( mReadWrite ) { | 443 | if ( mReadWrite ) { |
444 | mActionCut->setEnabled( selected ); | 444 | mActionCut->setEnabled( selected ); |
445 | mActionPaste->setEnabled( selected ); | 445 | mActionPaste->setEnabled( selected ); |
446 | } | 446 | } |
447 | 447 | ||
448 | mActionCopy->setEnabled( selected ); | 448 | mActionCopy->setEnabled( selected ); |
449 | mActionDelete->setEnabled( selected ); | 449 | mActionDelete->setEnabled( selected ); |
450 | mActionEditAddressee->setEnabled( selected ); | 450 | mActionEditAddressee->setEnabled( selected ); |
451 | mActionMail->setEnabled( selected ); | 451 | mActionMail->setEnabled( selected ); |
452 | mActionMailVCard->setEnabled( selected ); | 452 | mActionMailVCard->setEnabled( selected ); |
453 | //if (mActionBeam) | 453 | //if (mActionBeam) |
454 | //mActionBeam->setEnabled( selected ); | 454 | //mActionBeam->setEnabled( selected ); |
455 | 455 | ||
456 | if (mActionBeamVCard) | 456 | if (mActionBeamVCard) |
457 | mActionBeamVCard->setEnabled( selected ); | 457 | mActionBeamVCard->setEnabled( selected ); |
458 | 458 | ||
459 | mActionWhoAmI->setEnabled( selected ); | 459 | mActionWhoAmI->setEnabled( selected ); |
460 | mActionCategories->setEnabled( selected ); | 460 | mActionCategories->setEnabled( selected ); |
461 | } | 461 | } |
462 | 462 | ||
463 | void KABCore::sendMail() | 463 | void KABCore::sendMail() |
464 | { | 464 | { |
465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); | 465 | sendMail( mViewManager->selectedEmails().join( ", " ) ); |
466 | } | 466 | } |
467 | 467 | ||
468 | void KABCore::sendMail( const QString& email ) | 468 | void KABCore::sendMail( const QString& emaillist ) |
469 | { | 469 | { |
470 | bool result = ExternalAppHandler::instance()->mailToContacts(email); | 470 | // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " |
471 | if (emaillist.contains(",") > 0) | ||
472 | ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); | ||
473 | else | ||
474 | ExternalAppHandler::instance()->mailToOneContact( emaillist ); | ||
471 | } | 475 | } |
472 | 476 | ||
473 | 477 | ||
474 | 478 | ||
475 | void KABCore::mailVCard() | 479 | void KABCore::mailVCard() |
476 | { | 480 | { |
477 | QStringList uids = mViewManager->selectedUids(); | 481 | QStringList uids = mViewManager->selectedUids(); |
478 | if ( !uids.isEmpty() ) | 482 | if ( !uids.isEmpty() ) |
479 | mailVCard( uids ); | 483 | mailVCard( uids ); |
480 | } | 484 | } |
481 | 485 | ||
482 | void KABCore::mailVCard( const QStringList& uids ) | 486 | void KABCore::mailVCard( const QStringList& uids ) |
483 | { | 487 | { |
484 | QStringList urls; | 488 | QStringList urls; |
485 | 489 | ||
486 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 490 | // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
487 | 491 | ||
488 | /*US | 492 | QString dirName = "/tmp/" + KApplication::randomString( 8 ); |
489 | // Create a temp dir, so that we can put the files in it with proper names | ||
490 | KTempFile tempDir; | ||
491 | if ( tempDir.status() != 0 ) { | ||
492 | kdWarning() << strerror( tempDir.status() ) << endl; | ||
493 | return; | ||
494 | } | ||
495 | |||
496 | QString dirName = tempDir.name(); | ||
497 | tempDir.unlink(); | ||
498 | */ | ||
499 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | ||
500 | 493 | ||
501 | 494 | ||
502 | 495 | ||
503 | QDir().mkdir( dirName, true ); | 496 | QDir().mkdir( dirName, true ); |
504 | 497 | ||
505 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 498 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
506 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 499 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
507 | 500 | ||
508 | if ( a.isEmpty() ) | 501 | if ( a.isEmpty() ) |
509 | continue; | 502 | continue; |
510 | 503 | ||
511 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; | 504 | QString name = a.givenName() + "_" + a.familyName() + ".vcf"; |
512 | 505 | ||
513 | QString fileName = dirName + "/" + name; | 506 | QString fileName = dirName + "/" + name; |
514 | 507 | ||
515 | QFile outFile(fileName); | 508 | QFile outFile(fileName); |
509 | |||
516 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 510 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
517 | KABC::VCardConverter converter; | 511 | KABC::VCardConverter converter; |
518 | QString vcard; | 512 | QString vcard; |
519 | 513 | ||
520 | converter.addresseeToVCard( a, vcard ); | 514 | converter.addresseeToVCard( a, vcard ); |
521 | 515 | ||
522 | QTextStream t( &outFile ); // use a text stream | 516 | QTextStream t( &outFile ); // use a text stream |
523 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 517 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
524 | t << vcard; | 518 | t << vcard; |
525 | 519 | ||
526 | outFile.close(); | 520 | outFile.close(); |
527 | 521 | ||
528 | urls.append( fileName ); | 522 | urls.append( fileName ); |
529 | } | 523 | } |
530 | } | 524 | } |
531 | 525 | ||
532 | bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", ")); | 526 | bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); |
533 | 527 | ||
534 | 528 | ||
535 | /*US | 529 | /*US |
536 | kapp->invokeMailer( QString::null, QString::null, QString::null, | 530 | kapp->invokeMailer( QString::null, QString::null, QString::null, |
537 | QString::null, // subject | 531 | QString::null, // subject |
538 | QString::null, // body | 532 | QString::null, // body |
539 | QString::null, | 533 | QString::null, |
540 | urls ); // attachments | 534 | urls ); // attachments |
541 | */ | 535 | */ |
542 | 536 | ||
543 | } | 537 | } |
544 | 538 | ||
545 | /** | 539 | /** |
546 | Beams the "WhoAmI contact. | 540 | Beams the "WhoAmI contact. |
547 | */ | 541 | */ |
548 | void KABCore::beamMySelf() | 542 | void KABCore::beamMySelf() |
549 | { | 543 | { |
550 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); | 544 | KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); |
551 | if (!a.isEmpty()) | 545 | if (!a.isEmpty()) |
552 | { | 546 | { |
553 | QStringList uids; | 547 | QStringList uids; |
554 | uids << a.uid(); | 548 | uids << a.uid(); |
555 | 549 | ||
556 | beamVCard(uids); | 550 | beamVCard(uids); |
557 | } else { | 551 | } else { |
558 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); | 552 | KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); |
559 | 553 | ||
560 | 554 | ||
561 | } | 555 | } |
562 | } | 556 | } |
563 | 557 | ||
564 | void KABCore::beamVCard() | 558 | void KABCore::beamVCard() |
565 | { | 559 | { |
566 | QStringList uids = mViewManager->selectedUids(); | 560 | QStringList uids = mViewManager->selectedUids(); |
567 | if ( !uids.isEmpty() ) | 561 | if ( !uids.isEmpty() ) |
568 | beamVCard( uids ); | 562 | beamVCard( uids ); |
569 | } | 563 | } |
570 | 564 | ||
571 | 565 | ||
572 | void KABCore::beamVCard(const QStringList& uids) | 566 | void KABCore::beamVCard(const QStringList& uids) |
573 | { | 567 | { |
574 | /*US | 568 | /*US |
575 | QString beamFilename; | 569 | QString beamFilename; |
576 | Opie::OPimContact c; | 570 | Opie::OPimContact c; |
577 | if ( actionPersonal->isOn() ) { | 571 | if ( actionPersonal->isOn() ) { |
578 | beamFilename = addressbookPersonalVCardName(); | 572 | beamFilename = addressbookPersonalVCardName(); |
579 | if ( !QFile::exists( beamFilename ) ) | 573 | if ( !QFile::exists( beamFilename ) ) |
580 | return; // can't beam a non-existent file | 574 | return; // can't beam a non-existent file |
581 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 575 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
582 | beamFilename ); | 576 | beamFilename ); |
583 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 577 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
584 | Opie::OPimContactAccess::List allList = access->allRecords(); | 578 | Opie::OPimContactAccess::List allList = access->allRecords(); |
585 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first | 579 | Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first |
586 | c = *it; | 580 | c = *it; |
587 | 581 | ||
588 | delete access; | 582 | delete access; |
589 | } else { | 583 | } else { |
590 | unlink( beamfile ); // delete if exists | 584 | unlink( beamfile ); // delete if exists |
591 | mkdir("/tmp/obex/", 0755); | 585 | mkdir("/tmp/obex/", 0755); |
592 | c = m_abView -> currentEntry(); | 586 | c = m_abView -> currentEntry(); |
593 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, | 587 | Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, |
594 | beamfile ); | 588 | beamfile ); |
595 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 589 | Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
596 | access->add( c ); | 590 | access->add( c ); |
597 | access->save(); | 591 | access->save(); |
598 | delete access; | 592 | delete access; |
599 | 593 | ||
600 | beamFilename = beamfile; | 594 | beamFilename = beamfile; |
601 | } | 595 | } |
602 | 596 | ||
603 | owarn << "Beaming: " << beamFilename << oendl; | 597 | owarn << "Beaming: " << beamFilename << oendl; |
604 | */ | 598 | */ |
605 | 599 | ||
606 | #if 0 | 600 | #if 0 |
607 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); | 601 | QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); |
608 | 602 | ||
609 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); | 603 | QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); |
610 | 604 | ||
611 | QString name = "contact.vcf"; | 605 | QString name = "contact.vcf"; |
612 | 606 | ||
613 | QString fileName = dirName + "/" + name; | 607 | QString fileName = dirName + "/" + name; |
614 | #endif | 608 | #endif |
615 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory | 609 | // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory |
616 | // | 610 | // |
617 | QString fileName = "/tmp/kdepimbeamfile"; | 611 | QString fileName = "/tmp/kdepimbeamfile"; |
618 | 612 | ||
619 | 613 | ||
620 | //QDir().mkdir( dirName, true ); | 614 | //QDir().mkdir( dirName, true ); |
621 | 615 | ||
622 | QFile outFile(fileName); | 616 | QFile outFile(fileName); |
623 | KABC::VCardConverter converter; | 617 | KABC::VCardConverter converter; |
624 | QString description; | 618 | QString description; |
625 | 619 | ||
626 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully | 620 | if ( outFile.open(IO_WriteOnly) ) { // file opened successfully |
627 | 621 | ||
628 | QTextStream t( &outFile ); // use a text stream | 622 | QTextStream t( &outFile ); // use a text stream |
629 | t.setEncoding( QTextStream::UnicodeUTF8 ); | 623 | t.setEncoding( QTextStream::UnicodeUTF8 ); |
630 | 624 | ||
631 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { | 625 | for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { |
632 | KABC::Addressee a = mAddressBook->findByUid( *it ); | 626 | KABC::Addressee a = mAddressBook->findByUid( *it ); |
633 | 627 | ||
634 | if ( a.isEmpty() ) | 628 | if ( a.isEmpty() ) |
635 | continue; | 629 | continue; |
636 | 630 | ||
637 | if (description.isEmpty()) | 631 | if (description.isEmpty()) |
638 | description = a.formattedName(); | 632 | description = a.formattedName(); |
639 | 633 | ||
640 | QString vcard; | 634 | QString vcard; |
641 | converter.addresseeToVCard( a, vcard ); | 635 | converter.addresseeToVCard( a, vcard ); |
642 | t << vcard; | 636 | t << vcard; |
643 | 637 | ||
644 | } | 638 | } |
645 | } else { | 639 | } else { |
646 | qDebug("Error open temp beam file "); | 640 | qDebug("Error open temp beam file "); |
647 | return; | 641 | return; |
648 | } | 642 | } |
649 | 643 | ||
650 | outFile.close(); | 644 | outFile.close(); |
651 | 645 | ||
652 | #ifndef DESKTOP_VERSION | 646 | #ifndef DESKTOP_VERSION |
653 | Ir *ir = new Ir( this ); | 647 | Ir *ir = new Ir( this ); |
654 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); | 648 | connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); |
655 | ir->send( fileName, description, "text/x-vCard" ); | 649 | ir->send( fileName, description, "text/x-vCard" ); |
656 | #endif | 650 | #endif |
657 | 651 | ||
658 | } | 652 | } |
659 | 653 | ||
660 | void KABCore::beamDone( Ir *ir ) | 654 | void KABCore::beamDone( Ir *ir ) |
661 | { | 655 | { |
662 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
663 | delete ir; | 657 | delete ir; |
664 | #endif | 658 | #endif |
665 | } | 659 | } |
666 | 660 | ||
667 | 661 | ||
668 | void KABCore::browse( const QString& url ) | 662 | void KABCore::browse( const QString& url ) |
669 | { | 663 | { |
670 | #ifndef KAB_EMBEDDED | 664 | #ifndef KAB_EMBEDDED |
671 | kapp->invokeBrowser( url ); | 665 | kapp->invokeBrowser( url ); |
672 | #else //KAB_EMBEDDED | 666 | #else //KAB_EMBEDDED |
673 | qDebug("KABCore::browse must be fixed"); | 667 | qDebug("KABCore::browse must be fixed"); |
674 | #endif //KAB_EMBEDDED | 668 | #endif //KAB_EMBEDDED |
675 | } | 669 | } |
676 | 670 | ||
677 | void KABCore::selectAllContacts() | 671 | void KABCore::selectAllContacts() |
678 | { | 672 | { |
679 | mViewManager->setSelected( QString::null, true ); | 673 | mViewManager->setSelected( QString::null, true ); |
680 | } | 674 | } |
681 | 675 | ||
682 | void KABCore::deleteContacts() | 676 | void KABCore::deleteContacts() |
683 | { | 677 | { |
684 | QStringList uidList = mViewManager->selectedUids(); | 678 | QStringList uidList = mViewManager->selectedUids(); |
685 | deleteContacts( uidList ); | 679 | deleteContacts( uidList ); |
686 | } | 680 | } |
687 | 681 | ||
688 | void KABCore::deleteContacts( const QStringList &uids ) | 682 | void KABCore::deleteContacts( const QStringList &uids ) |
689 | { | 683 | { |
690 | if ( uids.count() > 0 ) { | 684 | if ( uids.count() > 0 ) { |
691 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); | 685 | PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); |
692 | UndoStack::instance()->push( command ); | 686 | UndoStack::instance()->push( command ); |
693 | RedoStack::instance()->clear(); | 687 | RedoStack::instance()->clear(); |
694 | 688 | ||
695 | // now if we deleted anything, refresh | 689 | // now if we deleted anything, refresh |
696 | setContactSelected( QString::null ); | 690 | setContactSelected( QString::null ); |
697 | setModified( true ); | 691 | setModified( true ); |
698 | } | 692 | } |
699 | } | 693 | } |
700 | 694 | ||
701 | void KABCore::copyContacts() | 695 | void KABCore::copyContacts() |
702 | { | 696 | { |
703 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 697 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
704 | 698 | ||
705 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); | 699 | QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); |
706 | 700 | ||
707 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; | 701 | kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; |
708 | 702 | ||
709 | QClipboard *cb = QApplication::clipboard(); | 703 | QClipboard *cb = QApplication::clipboard(); |
710 | cb->setText( clipText ); | 704 | cb->setText( clipText ); |
711 | } | 705 | } |
712 | 706 | ||
713 | void KABCore::cutContacts() | 707 | void KABCore::cutContacts() |
714 | { | 708 | { |
715 | QStringList uidList = mViewManager->selectedUids(); | 709 | QStringList uidList = mViewManager->selectedUids(); |
716 | 710 | ||
717 | //US if ( uidList.size() > 0 ) { | 711 | //US if ( uidList.size() > 0 ) { |
718 | if ( uidList.count() > 0 ) { | 712 | if ( uidList.count() > 0 ) { |
719 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); | 713 | PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); |
720 | UndoStack::instance()->push( command ); | 714 | UndoStack::instance()->push( command ); |
721 | RedoStack::instance()->clear(); | 715 | RedoStack::instance()->clear(); |
722 | 716 | ||
723 | setModified( true ); | 717 | setModified( true ); |
724 | } | 718 | } |
725 | } | 719 | } |
726 | 720 | ||
727 | void KABCore::pasteContacts() | 721 | void KABCore::pasteContacts() |
728 | { | 722 | { |
729 | QClipboard *cb = QApplication::clipboard(); | 723 | QClipboard *cb = QApplication::clipboard(); |
730 | 724 | ||
731 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); | 725 | KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); |
732 | 726 | ||
733 | pasteContacts( list ); | 727 | pasteContacts( list ); |
734 | } | 728 | } |
735 | 729 | ||
736 | void KABCore::pasteContacts( KABC::Addressee::List &list ) | 730 | void KABCore::pasteContacts( KABC::Addressee::List &list ) |
737 | { | 731 | { |
738 | KABC::Resource *resource = requestResource( this ); | 732 | KABC::Resource *resource = requestResource( this ); |
739 | KABC::Addressee::List::Iterator it; | 733 | KABC::Addressee::List::Iterator it; |
740 | for ( it = list.begin(); it != list.end(); ++it ) | 734 | for ( it = list.begin(); it != list.end(); ++it ) |
741 | (*it).setResource( resource ); | 735 | (*it).setResource( resource ); |
742 | 736 | ||
743 | PwPasteCommand *command = new PwPasteCommand( this, list ); | 737 | PwPasteCommand *command = new PwPasteCommand( this, list ); |
744 | UndoStack::instance()->push( command ); | 738 | UndoStack::instance()->push( command ); |
745 | RedoStack::instance()->clear(); | 739 | RedoStack::instance()->clear(); |
746 | 740 | ||
747 | setModified( true ); | 741 | setModified( true ); |
748 | } | 742 | } |
749 | 743 | ||
750 | void KABCore::setWhoAmI() | 744 | void KABCore::setWhoAmI() |
751 | { | 745 | { |
752 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); | 746 | KABC::Addressee::List addrList = mViewManager->selectedAddressees(); |
753 | 747 | ||
754 | if ( addrList.count() > 1 ) { | 748 | if ( addrList.count() > 1 ) { |
755 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); | 749 | KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); |
756 | return; | 750 | return; |
757 | } | 751 | } |
758 | 752 | ||
759 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); | 753 | QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); |
760 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) | 754 | if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) |
761 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); | 755 | static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); |
762 | } | 756 | } |
763 | 757 | ||
764 | void KABCore::setCategories() | 758 | void KABCore::setCategories() |
765 | { | 759 | { |
766 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); | 760 | KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); |
767 | if ( !dlg.exec() ) | 761 | if ( !dlg.exec() ) |
768 | return; | 762 | return; |
769 | 763 | ||
770 | bool merge = false; | 764 | bool merge = false; |
771 | QString msg = i18n( "Merge with existing categories?" ); | 765 | QString msg = i18n( "Merge with existing categories?" ); |
772 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) | 766 | if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) |
773 | merge = true; | 767 | merge = true; |
774 | 768 | ||
775 | QStringList categories = dlg.selectedCategories(); | 769 | QStringList categories = dlg.selectedCategories(); |
776 | 770 | ||
777 | QStringList uids = mViewManager->selectedUids(); | 771 | QStringList uids = mViewManager->selectedUids(); |
778 | QStringList::Iterator it; | 772 | QStringList::Iterator it; |
779 | for ( it = uids.begin(); it != uids.end(); ++it ) { | 773 | for ( it = uids.begin(); it != uids.end(); ++it ) { |
780 | KABC::Addressee addr = mAddressBook->findByUid( *it ); | 774 | KABC::Addressee addr = mAddressBook->findByUid( *it ); |
781 | if ( !addr.isEmpty() ) { | 775 | if ( !addr.isEmpty() ) { |
782 | if ( !merge ) | 776 | if ( !merge ) |
783 | addr.setCategories( categories ); | 777 | addr.setCategories( categories ); |
784 | else { | 778 | else { |
785 | QStringList addrCategories = addr.categories(); | 779 | QStringList addrCategories = addr.categories(); |
786 | QStringList::Iterator catIt; | 780 | QStringList::Iterator catIt; |
787 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 781 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
788 | if ( !addrCategories.contains( *catIt ) ) | 782 | if ( !addrCategories.contains( *catIt ) ) |