summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp53
1 files changed, 13 insertions, 40 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 4303cab..fe4841a 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -68,48 +68,50 @@
68#include "kaddressbookmain.h" 68#include "kaddressbookmain.h"
69#include "kactioncollection.h" 69#include "kactioncollection.h"
70#include <qapp.h> 70#include <qapp.h>
71#include <qmenubar.h> 71#include <qmenubar.h>
72//#include <qtoolbar.h> 72//#include <qtoolbar.h>
73#include <qmessagebox.h> 73#include <qmessagebox.h>
74#include <kdebug.h> 74#include <kdebug.h>
75#include <kiconloader.h> // needed for SmallIcon 75#include <kiconloader.h> // needed for SmallIcon
76#include <kresources/kcmkresources.h> 76#include <kresources/kcmkresources.h>
77#include <ktoolbar.h> 77#include <ktoolbar.h>
78 78
79 79
80//#include <qlabel.h> 80//#include <qlabel.h>
81 81
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <qtopia/services.h> 84#include <qtopia/services.h>
85#include <qtopia/qcopenvelope_qws.h> 85#include <qtopia/qcopenvelope_qws.h>
86#include <qpe/ir.h> 86#include <qpe/ir.h>
87#endif 87#endif
88 88
89#endif // KAB_EMBEDDED 89#endif // KAB_EMBEDDED
90#include "kcmconfigs/kcmkabconfig.h" 90#include "kcmconfigs/kcmkabconfig.h"
91#include "kcmconfigs/kcmkdepimconfig.h" 91#include "kcmconfigs/kcmkdepimconfig.h"
92#include "kpimglobalprefs.h"
93#include "externalapphandler.h"
92 94
93 95
94#include <kresources/selectdialog.h> 96#include <kresources/selectdialog.h>
95#include <kmessagebox.h> 97#include <kmessagebox.h>
96 98
97#include <picture.h> 99#include <picture.h>
98#include <resource.h> 100#include <resource.h>
99 101
100//US#include <qsplitter.h> 102//US#include <qsplitter.h>
101#include <qmap.h> 103#include <qmap.h>
102#include <qdir.h> 104#include <qdir.h>
103#include <qfile.h> 105#include <qfile.h>
104#include <qvbox.h> 106#include <qvbox.h>
105#include <qlayout.h> 107#include <qlayout.h>
106#include <qclipboard.h> 108#include <qclipboard.h>
107#include <qtextstream.h> 109#include <qtextstream.h>
108 110
109#include <libkdepim/categoryselectdialog.h> 111#include <libkdepim/categoryselectdialog.h>
110#include <kabc/vcardconverter.h> 112#include <kabc/vcardconverter.h>
111 113
112 114
113#include "addresseeutil.h" 115#include "addresseeutil.h"
114#include "undocmds.h" 116#include "undocmds.h"
115#include "addresseeeditordialog.h" 117#include "addresseeeditordialog.h"
@@ -446,71 +448,49 @@ void KABCore::setContactSelected( const QString &uid )
446 } 448 }
447 449
448 mActionCopy->setEnabled( selected ); 450 mActionCopy->setEnabled( selected );
449 mActionDelete->setEnabled( selected ); 451 mActionDelete->setEnabled( selected );
450 mActionEditAddressee->setEnabled( selected ); 452 mActionEditAddressee->setEnabled( selected );
451 mActionMail->setEnabled( selected ); 453 mActionMail->setEnabled( selected );
452 mActionMailVCard->setEnabled( selected ); 454 mActionMailVCard->setEnabled( selected );
453 //if (mActionBeam) 455 //if (mActionBeam)
454 //mActionBeam->setEnabled( selected ); 456 //mActionBeam->setEnabled( selected );
455 457
456 if (mActionBeamVCard) 458 if (mActionBeamVCard)
457 mActionBeamVCard->setEnabled( selected ); 459 mActionBeamVCard->setEnabled( selected );
458 460
459 mActionWhoAmI->setEnabled( selected ); 461 mActionWhoAmI->setEnabled( selected );
460 mActionCategories->setEnabled( selected ); 462 mActionCategories->setEnabled( selected );
461} 463}
462 464
463void KABCore::sendMail() 465void KABCore::sendMail()
464{ 466{
465 sendMail( mViewManager->selectedEmails().join( ", " ) ); 467 sendMail( mViewManager->selectedEmails().join( ", " ) );
466} 468}
467 469
468void KABCore::sendMail( const QString& email ) 470void KABCore::sendMail( const QString& email )
469{ 471{
470//US original kde implementation : kapp->invokeMailer( email, "" ); 472 bool result = ExternalAppHandler::instance()->mailToContacts(email);
471
472/*US original qtopia implementation
473 PimContact c = abList->currentEntry();
474 QString name = c.fileAs();
475 QString email = c.defaultEmail();
476#ifndef QT_NO_COP
477 QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)");
478 e << name << email;
479#else
480*/
481
482
483#ifndef QT_NO_COP
484 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
485 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
486
487 QCopEnvelope e(channel, "writeMail(QString,QString)");
488 //US we need no names in the To field. The emailadresses are enough
489 e << "" << email;
490#else
491 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
492#endif
493} 473}
494 474
495 475
496 476
497void KABCore::mailVCard() 477void KABCore::mailVCard()
498{ 478{
499 QStringList uids = mViewManager->selectedUids(); 479 QStringList uids = mViewManager->selectedUids();
500 if ( !uids.isEmpty() ) 480 if ( !uids.isEmpty() )
501 mailVCard( uids ); 481 mailVCard( uids );
502} 482}
503 483
504void KABCore::mailVCard( const QStringList& uids ) 484void KABCore::mailVCard( const QStringList& uids )
505{ 485{
506 QStringList urls; 486 QStringList urls;
507 487
508 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 488 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
509 489
510/*US 490/*US
511 // Create a temp dir, so that we can put the files in it with proper names 491 // Create a temp dir, so that we can put the files in it with proper names
512 KTempFile tempDir; 492 KTempFile tempDir;
513 if ( tempDir.status() != 0 ) { 493 if ( tempDir.status() != 0 ) {
514 kdWarning() << strerror( tempDir.status() ) << endl; 494 kdWarning() << strerror( tempDir.status() ) << endl;
515 return; 495 return;
516 } 496 }
@@ -529,68 +509,59 @@ void KABCore::mailVCard( const QStringList& uids )
529 509
530 if ( a.isEmpty() ) 510 if ( a.isEmpty() )
531 continue; 511 continue;
532 512
533 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 513 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
534 514
535 QString fileName = dirName + "/" + name; 515 QString fileName = dirName + "/" + name;
536 516
537 QFile outFile(fileName); 517 QFile outFile(fileName);
538 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 518 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
539 KABC::VCardConverter converter; 519 KABC::VCardConverter converter;
540 QString vcard; 520 QString vcard;
541 521
542 converter.addresseeToVCard( a, vcard ); 522 converter.addresseeToVCard( a, vcard );
543 523
544 QTextStream t( &outFile ); // use a text stream 524 QTextStream t( &outFile ); // use a text stream
545 t.setEncoding( QTextStream::UnicodeUTF8 ); 525 t.setEncoding( QTextStream::UnicodeUTF8 );
546 t << vcard; 526 t << vcard;
547 527
548 outFile.close(); 528 outFile.close();
549 529
550 urls.append( fileName ); 530 urls.append( fileName );
551 } 531 }
552 } 532 }
533
534 bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", "));
535
536
553/*US 537/*US
554 kapp->invokeMailer( QString::null, QString::null, QString::null, 538 kapp->invokeMailer( QString::null, QString::null, QString::null,
555 QString::null, // subject 539 QString::null, // subject
556 QString::null, // body 540 QString::null, // body
557 QString::null, 541 QString::null,
558 urls ); // attachments 542 urls ); // attachments
559*/ 543*/
560#ifndef QT_NO_COP
561 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
562 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
563
564 QMap<QString, QString> parameterMap;
565 parameterMap.insert("ATTACHMENT<n>", urls.join(", "));
566
567 QCopEnvelope e(channel, "writeMail(QMap(QString,QString))");
568 e << parameterMap;
569#else
570 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
571#endif
572
573 544
574} 545}
575 546
576/** 547/**
577 Beams the "WhoAmI contact. 548 Beams the "WhoAmI contact.
578*/ 549*/
579void KABCore::beamMySelf() 550void KABCore::beamMySelf()
580{ 551{
581 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 552 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
582 if (!a.isEmpty()) 553 if (!a.isEmpty())
583 { 554 {
584 QStringList uids; 555 QStringList uids;
585 uids << a.uid(); 556 uids << a.uid();
586 557
587 beamVCard(uids); 558 beamVCard(uids);
588 } else { 559 } else {
589 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 560 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
590 561
591 562
592 } 563 }
593} 564}
594 565
595void KABCore::beamVCard() 566void KABCore::beamVCard()
596{ 567{
@@ -1176,53 +1147,55 @@ QString KABCore::getNameByPhone( const QString &phone )
1176 KABC::PhoneNumber::List::Iterator phoneIter; 1147 KABC::PhoneNumber::List::Iterator phoneIter;
1177 KABC::PhoneNumber::List phoneList; 1148 KABC::PhoneNumber::List phoneList;
1178 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1149 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1179 phoneList = (*iter).phoneNumbers(); 1150 phoneList = (*iter).phoneNumbers();
1180 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1151 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1181 ++phoneIter) { 1152 ++phoneIter) {
1182 // Get rid of separator chars so just the numbers are compared. 1153 // Get rid of separator chars so just the numbers are compared.
1183 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1154 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1184 ownerName = (*iter).formattedName(); 1155 ownerName = (*iter).formattedName();
1185 found = true; 1156 found = true;
1186 } 1157 }
1187 } 1158 }
1188 } 1159 }
1189 1160
1190 return ownerName; 1161 return ownerName;
1191#else //KAB_EMBEDDED 1162#else //KAB_EMBEDDED
1192 qDebug("KABCore::getNameByPhone finsih method"); 1163 qDebug("KABCore::getNameByPhone finsih method");
1193 return ""; 1164 return "";
1194#endif //KAB_EMBEDDED 1165#endif //KAB_EMBEDDED
1195 1166
1196} 1167}
1197 1168
1198void KABCore::openConfigDialog() 1169void KABCore::openConfigDialog()
1199{ 1170{
1200 KABPrefs* prefs = KABPrefs::instance(); 1171 KABPrefs* kab_prefs = KABPrefs::instance();
1201 KCMultiDialog* ConfigureDialog = new KCMultiDialog( prefs, "PIM", this ,"kabconfigdialog", true ); 1172 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1202 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1173
1174 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1175 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1203 ConfigureDialog->addModule(kabcfg ); 1176 ConfigureDialog->addModule(kabcfg );
1204 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Pim")) , "KCMKdeLibConfig" ); 1177 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1205 ConfigureDialog->addModule(kdelibcfg ); 1178 ConfigureDialog->addModule(kdelibcfg );
1206 1179
1207 1180
1208 1181
1209 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1182 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1210 this, SLOT( configurationChanged() ) ); 1183 this, SLOT( configurationChanged() ) );
1211 connect( ConfigureDialog, SIGNAL( okClicked() ), 1184 connect( ConfigureDialog, SIGNAL( okClicked() ),
1212 this, SLOT( configurationChanged() ) ); 1185 this, SLOT( configurationChanged() ) );
1213 saveSettings(); 1186 saveSettings();
1214 ConfigureDialog->showMaximized(); 1187 ConfigureDialog->showMaximized();
1215 if ( ConfigureDialog->exec() ) 1188 if ( ConfigureDialog->exec() )
1216 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); 1189 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") );
1217 delete ConfigureDialog; 1190 delete ConfigureDialog;
1218} 1191}
1219 1192
1220void KABCore::openLDAPDialog() 1193void KABCore::openLDAPDialog()
1221{ 1194{
1222#ifndef KAB_EMBEDDED 1195#ifndef KAB_EMBEDDED
1223 if ( !mLdapSearchDialog ) { 1196 if ( !mLdapSearchDialog ) {
1224 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1197 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1225 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1198 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1226 SLOT( refreshView() ) ); 1199 SLOT( refreshView() ) );
1227 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1200 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1228 SLOT( setModified() ) ); 1201 SLOT( setModified() ) );