summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-06 01:40:28 (UTC)
committer ulf69 <ulf69>2004-08-06 01:40:28 (UTC)
commitb82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138 (patch) (unidiff)
tree6e407c4b61128e5d16f657f6ae788ebcaadb7862
parent422cea307a0a85064db6b5b64a847375da9311e1 (diff)
downloadkdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.zip
kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.tar.gz
kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.tar.bz2
enabled beaming and sending of emails
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp134
-rw-r--r--kaddressbook/kabcore.h42
2 files changed, 162 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2a54900..d891b07 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -82,12 +82,13 @@
82 82
83 83
84#ifdef Q_WS_QWS 84#ifdef Q_WS_QWS
85#include <qtopia/services.h> 85#include <qtopia/services.h>
86#include <qtopia/qcopenvelope_qws.h> 86#include <qtopia/qcopenvelope_qws.h>
87#endif 87#endif
88#include <qpe/ir.h>
88 89
89#endif // KAB_EMBEDDED 90#endif // KAB_EMBEDDED
90#include <kcmkabconfig.h> 91#include <kcmkabconfig.h>
91 92
92 93
93#include <kresources/selectdialog.h> 94#include <kresources/selectdialog.h>
@@ -446,12 +447,18 @@ void KABCore::setContactSelected( const QString &uid )
446 447
447 mActionCopy->setEnabled( selected ); 448 mActionCopy->setEnabled( selected );
448 mActionDelete->setEnabled( selected ); 449 mActionDelete->setEnabled( selected );
449 mActionEditAddressee->setEnabled( selected ); 450 mActionEditAddressee->setEnabled( selected );
450 mActionMail->setEnabled( selected ); 451 mActionMail->setEnabled( selected );
451 mActionMailVCard->setEnabled( selected ); 452 mActionMailVCard->setEnabled( selected );
453 if (mActionBeam)
454 mActionBeam->setEnabled( selected );
455
456 if (mActionBeam)
457 mActionBeamVCard->setEnabled( selected );
458
452 mActionWhoAmI->setEnabled( selected ); 459 mActionWhoAmI->setEnabled( selected );
453 mActionCategories->setEnabled( selected ); 460 mActionCategories->setEnabled( selected );
454} 461}
455 462
456void KABCore::sendMail() 463void KABCore::sendMail()
457{ 464{
@@ -482,12 +489,14 @@ void KABCore::sendMail( const QString& email )
482 e << "" << email; 489 e << "" << email;
483#else 490#else
484 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); 491 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
485#endif 492#endif
486} 493}
487 494
495
496
488void KABCore::mailVCard() 497void KABCore::mailVCard()
489{ 498{
490 QStringList uids = mViewManager->selectedUids(); 499 QStringList uids = mViewManager->selectedUids();
491 if ( !uids.isEmpty() ) 500 if ( !uids.isEmpty() )
492 mailVCard( uids ); 501 mailVCard( uids );
493} 502}
@@ -561,12 +570,118 @@ void KABCore::mailVCard( const QStringList& uids )
561 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); 570 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
562#endif 571#endif
563 572
564 573
565} 574}
566 575
576/**
577 Beams the "WhoAmI contact.
578*/
579void KABCore::beamMySelf()
580{
581 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
582 if (!a.isEmpty())
583 {
584 QStringList uids;
585 uids << a.uid();
586
587 beamVCard(uids);
588 }
589}
590
591void KABCore::beamVCard()
592{
593 QStringList uids = mViewManager->selectedUids();
594 if ( !uids.isEmpty() )
595 beamVCard( uids );
596}
597
598
599void KABCore::beamVCard(const QStringList& uids)
600{
601/*US
602 QString beamFilename;
603 Opie::OPimContact c;
604 if ( actionPersonal->isOn() ) {
605 beamFilename = addressbookPersonalVCardName();
606 if ( !QFile::exists( beamFilename ) )
607 return; // can't beam a non-existent file
608 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
609 beamFilename );
610 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
611 Opie::OPimContactAccess::List allList = access->allRecords();
612 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
613 c = *it;
614
615 delete access;
616 } else {
617 unlink( beamfile ); // delete if exists
618 mkdir("/tmp/obex/", 0755);
619 c = m_abView -> currentEntry();
620 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
621 beamfile );
622 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
623 access->add( c );
624 access->save();
625 delete access;
626
627 beamFilename = beamfile;
628 }
629
630 owarn << "Beaming: " << beamFilename << oendl;
631*/
632 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
633
634 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
635
636 QString name = "contact.vcf";
637
638 QString fileName = dirName + "/" + name;
639
640
641 QDir().mkdir( dirName, true );
642
643 QFile outFile(fileName);
644 KABC::VCardConverter converter;
645 QString description;
646
647 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
648
649 QTextStream t( &outFile ); // use a text stream
650 t.setEncoding( QTextStream::UnicodeUTF8 );
651
652 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
653 KABC::Addressee a = mAddressBook->findByUid( *it );
654
655 if ( a.isEmpty() )
656 continue;
657
658 if (description.isEmpty())
659 description = a.formattedName();
660
661 QString vcard;
662 converter.addresseeToVCard( a, vcard );
663 t << vcard;
664
665 }
666 }
667
668 outFile.close();
669
670 Ir *ir = new Ir( this );
671 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
672 ir->send( fileName, description, "text/x-vCard" );
673
674}
675
676void KABCore::beamDone( Ir *ir )
677{
678 delete ir;
679}
680
681
567void KABCore::browse( const QString& url ) 682void KABCore::browse( const QString& url )
568{ 683{
569#ifndef KAB_EMBEDDED 684#ifndef KAB_EMBEDDED
570 kapp->invokeBrowser( url ); 685 kapp->invokeBrowser( url );
571#else //KAB_EMBEDDED 686#else //KAB_EMBEDDED
572 qDebug("KABCore::browse must be fixed"); 687 qDebug("KABCore::browse must be fixed");
@@ -1360,22 +1475,31 @@ void KABCore::initActions()
1360 1475
1361 } else { 1476 } else {
1362 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1477 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1363 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1478 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1364 } 1479 }
1365 1480
1481
1366 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1482 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1367 SLOT( save() ), actionCollection(), "file_sync" ); 1483 SLOT( save() ), actionCollection(), "file_sync" );
1368 1484
1369 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1485 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1370 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1486 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1371 1487
1372 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1488 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1373 this, SLOT( mailVCard() ), 1489 this, SLOT( mailVCard() ),
1374 actionCollection(), "file_mail_vcard"); 1490 actionCollection(), "file_mail_vcard");
1375 1491
1492 mActionBeamVCard = 0;
1493 if ( Ir::supported() ) {
1494 mActionBeamVCard = new KAction( i18n( "Beam v&Card" ), "beam", 0, this,
1495 SLOT( beamVCard() ), actionCollection(),
1496 "kaddressbook_beam_vcard" );
1497 }
1498
1499
1376 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1500 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1377 this, SLOT( editContact2() ), 1501 this, SLOT( editContact2() ),
1378 actionCollection(), "file_properties" ); 1502 actionCollection(), "file_properties" );
1379 1503
1380#ifdef KAB_EMBEDDED 1504#ifdef KAB_EMBEDDED
1381 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1505 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
@@ -1470,12 +1594,20 @@ void KABCore::initActions()
1470 1594
1471 1595
1472 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1596 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1473 SLOT( setWhoAmI() ), actionCollection(), 1597 SLOT( setWhoAmI() ), actionCollection(),
1474 "set_personal" ); 1598 "set_personal" );
1475 1599
1600 mActionBeam = 0;
1601 if ( Ir::supported() ) {
1602 mActionBeam = new KAction( i18n( "&Beam Who Am I" ), "beam", 0, this,
1603 SLOT( beamMySelf() ), actionCollection(),
1604 "kaddressbook_beam_myself" );
1605 }
1606
1607
1476 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1608 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1477 SLOT( setCategories() ), actionCollection(), 1609 SLOT( setCategories() ), actionCollection(),
1478 "edit_set_categories" ); 1610 "edit_set_categories" );
1479 1611
1480 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1612 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1481 SLOT( removeVoice() ), actionCollection(), 1613 SLOT( removeVoice() ), actionCollection(),
@@ -1558,12 +1690,13 @@ void KABCore::addActionsManually()
1558 fileMenu->insertSeparator(); 1690 fileMenu->insertSeparator();
1559 mActionSave->plug( fileMenu ); 1691 mActionSave->plug( fileMenu );
1560 fileMenu->insertItem( "&Import", ImportMenu ); 1692 fileMenu->insertItem( "&Import", ImportMenu );
1561 fileMenu->insertItem( "&Emport", ExportMenu ); 1693 fileMenu->insertItem( "&Emport", ExportMenu );
1562 fileMenu->insertSeparator(); 1694 fileMenu->insertSeparator();
1563 mActionMailVCard->plug( fileMenu ); 1695 mActionMailVCard->plug( fileMenu );
1696 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1564 fileMenu->insertSeparator(); 1697 fileMenu->insertSeparator();
1565 mActionQuit->plug( fileMenu ); 1698 mActionQuit->plug( fileMenu );
1566#ifdef _WIN32_ 1699#ifdef _WIN32_
1567 mActionImportOL->plug( ImportMenu ); 1700 mActionImportOL->plug( ImportMenu );
1568#endif 1701#endif
1569 // edit menu 1702 // edit menu
@@ -1598,12 +1731,13 @@ void KABCore::addActionsManually()
1598 1731
1599 mActionJumpBar->plug( settingsMenu ); 1732 mActionJumpBar->plug( settingsMenu );
1600 mActionDetails->plug( settingsMenu ); 1733 mActionDetails->plug( settingsMenu );
1601 settingsMenu->insertSeparator(); 1734 settingsMenu->insertSeparator();
1602 1735
1603 mActionWhoAmI->plug( settingsMenu ); 1736 mActionWhoAmI->plug( settingsMenu );
1737 if ( Ir::supported() ) mActionBeam->plug( settingsMenu );
1604 mActionCategories->plug( settingsMenu ); 1738 mActionCategories->plug( settingsMenu );
1605 1739
1606 mActionAboutKAddressbook->plug( helpMenu ); 1740 mActionAboutKAddressbook->plug( helpMenu );
1607 1741
1608 1742
1609 if (QApplication::desktop()->width() > 320 ) { 1743 if (QApplication::desktop()->width() > 320 ) {
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 6446974..be39148 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -61,21 +61,22 @@ class KToggleAction;
61class QAction; 61class QAction;
62class QMenuBar; 62class QMenuBar;
63class QSplitter; 63class QSplitter;
64class ViewContainer; 64class ViewContainer;
65class ViewManager; 65class ViewManager;
66class AddresseeEditorDialog; 66class AddresseeEditorDialog;
67class Ir;
67 68
68class KABCore : public QWidget 69class KABCore : public QWidget
69{ 70{
70 Q_OBJECT 71 Q_OBJECT
71 72
72 public: 73 public:
73 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 74 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
74 75
75 76
76 ~KABCore(); 77 ~KABCore();
77 78
78 79
79#ifdef KAB_EMBEDDED 80#ifdef KAB_EMBEDDED
80 //US added functionality 81 //US added functionality
81 QPopupMenu* getViewMenu() {return viewMenu;} 82 QPopupMenu* getViewMenu() {return viewMenu;}
@@ -136,13 +137,13 @@ class KABCore : public QWidget
136#endif //KAB_EMBEDDED 137#endif //KAB_EMBEDDED
137 138
138 public slots: 139 public slots:
139#ifdef KAB_EMBEDDED 140#ifdef KAB_EMBEDDED
140 void createAboutData(); 141 void createAboutData();
141#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
142 143
143 void statusMessage(QString, int time = 0 ); 144 void statusMessage(QString, int time = 0 );
144 /** 145 /**
145 Is called whenever a contact is selected in the view. 146 Is called whenever a contact is selected in the view.
146 */ 147 */
147 void setContactSelected( const QString &uid ); 148 void setContactSelected( const QString &uid );
148 149
@@ -160,12 +161,22 @@ class KABCore : public QWidget
160 161
161 162
162 void mailVCard(); 163 void mailVCard();
163 void mailVCard(const QStringList& uids); 164 void mailVCard(const QStringList& uids);
164 165
165 /** 166 /**
167 Beams the "WhoAmI contact.
168 */
169 void beamMySelf();
170
171 void beamVCard();
172 void beamVCard(const QStringList& uids);
173 void beamDone( Ir *ir );
174
175
176 /**
166 Starts the preferred web browser with the given URL as argument. 177 Starts the preferred web browser with the given URL as argument.
167 */ 178 */
168 void browse( const QString& url ); 179 void browse( const QString& url );
169 180
170 /** 181 /**
171 Select all contacts in the view. 182 Select all contacts in the view.
@@ -283,15 +294,15 @@ class KABCore : public QWidget
283 294
284 /** 295 /**
285 Shows the edit dialog for the given uid. If the uid is QString::null, 296 Shows the edit dialog for the given uid. If the uid is QString::null,
286 the method will try to find a selected addressee in the view. 297 the method will try to find a selected addressee in the view.
287 */ 298 */
288 void editContact( const QString &uid /*US = QString::null*/ ); 299 void editContact( const QString &uid /*US = QString::null*/ );
289//US added a second method without defaultparameter 300//US added a second method without defaultparameter
290 void editContact2(); 301 void editContact2();
291 302
292 /** 303 /**
293 Launches the configuration dialog. 304 Launches the configuration dialog.
294 */ 305 */
295 void openConfigDialog(); 306 void openConfigDialog();
296 307
297 /** 308 /**
@@ -332,18 +343,18 @@ class KABCore : public QWidget
332 void configurationChanged(); 343 void configurationChanged();
333 void addressBookChanged(); 344 void addressBookChanged();
334 345
335 private: 346 private:
336 void initGUI(); 347 void initGUI();
337 void initActions(); 348 void initActions();
338 349
339 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 350 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
340 const char *name = 0 ); 351 const char *name = 0 );
341 352
342 KXMLGUIClient *mGUIClient; 353 KXMLGUIClient *mGUIClient;
343 354
344 KABC::AddressBook *mAddressBook; 355 KABC::AddressBook *mAddressBook;
345 356
346 ViewManager *mViewManager; 357 ViewManager *mViewManager;
347 // QSplitter *mDetailsSplitter; 358 // QSplitter *mDetailsSplitter;
348 KDGanttMinimizeSplitter *mExtensionBarSplitter; 359 KDGanttMinimizeSplitter *mExtensionBarSplitter;
349 ViewContainer *mDetails; 360 ViewContainer *mDetails;
@@ -363,62 +374,65 @@ class KABCore : public QWidget
363 bool mReadWrite; 374 bool mReadWrite;
364 bool mModified; 375 bool mModified;
365 bool mIsPart; 376 bool mIsPart;
366 377
367 //US file menu 378 //US file menu
368 KAction *mActionMail; 379 KAction *mActionMail;
380 KAction *mActionBeam;
369 KAction* mActionPrint; 381 KAction* mActionPrint;
370 KAction* mActionNewContact; 382 KAction* mActionNewContact;
371 KAction *mActionSave; 383 KAction *mActionSave;
372 KAction *mActionEditAddressee; 384 KAction *mActionEditAddressee;
373 KAction *mActionMailVCard; 385 KAction *mActionMailVCard;
386 KAction *mActionBeamVCard;
387
374 KAction *mActionQuit; 388 KAction *mActionQuit;
375 389
376 //US edit menu 390 //US edit menu
377 KAction *mActionCopy; 391 KAction *mActionCopy;
378 KAction *mActionCut; 392 KAction *mActionCut;
379 KAction *mActionPaste; 393 KAction *mActionPaste;
380 KAction *mActionSelectAll; 394 KAction *mActionSelectAll;
381 KAction *mActionUndo; 395 KAction *mActionUndo;
382 KAction *mActionRedo; 396 KAction *mActionRedo;
383 KAction *mActionDelete; 397 KAction *mActionDelete;
384 398
385 //US settings menu 399 //US settings menu
386 KAction *mActionConfigResources; 400 KAction *mActionConfigResources;
387 KAction *mActionConfigKAddressbook; 401 KAction *mActionConfigKAddressbook;
388 KAction *mActionConfigShortcuts; 402 KAction *mActionConfigShortcuts;
389 KAction *mActionConfigureToolbars; 403 KAction *mActionConfigureToolbars;
390 KAction *mActionKeyBindings; 404 KAction *mActionKeyBindings;
391 KToggleAction *mActionJumpBar; 405 KToggleAction *mActionJumpBar;
392 KToggleAction *mActionDetails; 406 KToggleAction *mActionDetails;
393 KAction *mActionWhoAmI; 407 KAction *mActionWhoAmI;
394 KAction *mActionCategories; 408 KAction *mActionCategories;
395 KAction *mActionAboutKAddressbook; 409 KAction *mActionAboutKAddressbook;
396 410
397 KAction *mActionDeleteView; 411 KAction *mActionDeleteView;
398 412
399 QPopupMenu *viewMenu; 413 QPopupMenu *viewMenu;
400 QPopupMenu *filterMenu; 414 QPopupMenu *filterMenu;
401 QPopupMenu *settingsMenu; 415 QPopupMenu *settingsMenu;
402 QPopupMenu *changeMenu; 416 QPopupMenu *changeMenu;
403 417
404//US QAction *mActionSave; 418//US QAction *mActionSave;
405 QPopupMenu *ImportMenu; 419 QPopupMenu *ImportMenu;
406 QPopupMenu *ExportMenu; 420 QPopupMenu *ExportMenu;
407 //LR additional methods 421 //LR additional methods
408 KAction *mActionRemoveVoice; 422 KAction *mActionRemoveVoice;
409 KAction * mActionImportOL; 423 KAction * mActionImportOL;
410 424
411#ifndef KAB_EMBEDDED 425#ifndef KAB_EMBEDDED
412 KAddressBookService *mAddressBookService; 426 KAddressBookService *mAddressBookService;
413#endif //KAB_EMBEDDED 427#endif //KAB_EMBEDDED
414 428
415 class KABCorePrivate; 429 class KABCorePrivate;
416 KABCorePrivate *d; 430 KABCorePrivate *d;
417 431
418#ifdef KAB_EMBEDDED 432#ifdef KAB_EMBEDDED
419 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 433 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
420#endif //KAB_EMBEDDED 434#endif //KAB_EMBEDDED
421 435
422}; 436};
423 437
424#endif 438#endif