author | ulf69 <ulf69> | 2004-08-06 01:40:28 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-06 01:40:28 (UTC) |
commit | b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138 (patch) (side-by-side diff) | |
tree | 6e407c4b61128e5d16f657f6ae788ebcaadb7862 | |
parent | 422cea307a0a85064db6b5b64a847375da9311e1 (diff) | |
download | kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.zip kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.tar.gz kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.tar.bz2 |
enabled beaming and sending of emails
-rw-r--r-- | kaddressbook/kabcore.cpp | 134 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 42 |
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 @@ -87,2 +87,3 @@ #endif +#include <qpe/ir.h> @@ -451,2 +452,8 @@ void KABCore::setContactSelected( const QString &uid ) mActionMailVCard->setEnabled( selected ); + if (mActionBeam) + mActionBeam->setEnabled( selected ); + + if (mActionBeam) + mActionBeamVCard->setEnabled( selected ); + mActionWhoAmI->setEnabled( selected ); @@ -487,2 +494,4 @@ void KABCore::sendMail( const QString& email ) + + void KABCore::mailVCard() @@ -566,2 +575,108 @@ void KABCore::mailVCard( const QStringList& uids ) +/** + Beams the "WhoAmI contact. +*/ +void KABCore::beamMySelf() +{ + KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); + if (!a.isEmpty()) + { + QStringList uids; + uids << a.uid(); + + beamVCard(uids); + } +} + +void KABCore::beamVCard() +{ + QStringList uids = mViewManager->selectedUids(); + if ( !uids.isEmpty() ) + beamVCard( uids ); +} + + +void KABCore::beamVCard(const QStringList& uids) +{ +/*US + QString beamFilename; + Opie::OPimContact c; + if ( actionPersonal->isOn() ) { + beamFilename = addressbookPersonalVCardName(); + if ( !QFile::exists( beamFilename ) ) + return; // can't beam a non-existent file + Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, + beamFilename ); + Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); + Opie::OPimContactAccess::List allList = access->allRecords(); + Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first + c = *it; + + delete access; + } else { + unlink( beamfile ); // delete if exists + mkdir("/tmp/obex/", 0755); + c = m_abView -> currentEntry(); + Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, + beamfile ); + Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); + access->add( c ); + access->save(); + delete access; + + beamFilename = beamfile; + } + + owarn << "Beaming: " << beamFilename << oendl; +*/ + QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); + + QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); + + QString name = "contact.vcf"; + + QString fileName = dirName + "/" + name; + + + QDir().mkdir( dirName, true ); + + QFile outFile(fileName); + KABC::VCardConverter converter; + QString description; + + if ( outFile.open(IO_WriteOnly) ) { // file opened successfully + + QTextStream t( &outFile ); // use a text stream + t.setEncoding( QTextStream::UnicodeUTF8 ); + + for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { + KABC::Addressee a = mAddressBook->findByUid( *it ); + + if ( a.isEmpty() ) + continue; + + if (description.isEmpty()) + description = a.formattedName(); + + QString vcard; + converter.addresseeToVCard( a, vcard ); + t << vcard; + + } + } + + outFile.close(); + + Ir *ir = new Ir( this ); + connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); + ir->send( fileName, description, "text/x-vCard" ); + +} + +void KABCore::beamDone( Ir *ir ) +{ + delete ir; +} + + void KABCore::browse( const QString& url ) @@ -1365,2 +1480,3 @@ void KABCore::initActions() + mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, @@ -1375,2 +1491,10 @@ void KABCore::initActions() + mActionBeamVCard = 0; + if ( Ir::supported() ) { + mActionBeamVCard = new KAction( i18n( "Beam v&Card" ), "beam", 0, this, + SLOT( beamVCard() ), actionCollection(), + "kaddressbook_beam_vcard" ); + } + + mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, @@ -1475,2 +1599,10 @@ void KABCore::initActions() + mActionBeam = 0; + if ( Ir::supported() ) { + mActionBeam = new KAction( i18n( "&Beam Who Am I" ), "beam", 0, this, + SLOT( beamMySelf() ), actionCollection(), + "kaddressbook_beam_myself" ); + } + + mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, @@ -1563,2 +1695,3 @@ void KABCore::addActionsManually() mActionMailVCard->plug( fileMenu ); + if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); fileMenu->insertSeparator(); @@ -1603,2 +1736,3 @@ void KABCore::addActionsManually() mActionWhoAmI->plug( settingsMenu ); + if ( Ir::supported() ) mActionBeam->plug( settingsMenu ); mActionCategories->plug( settingsMenu ); diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index 6446974..be39148 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -66,2 +66,3 @@ class ViewManager; class AddresseeEditorDialog; +class Ir; @@ -73,4 +74,4 @@ class KABCore : public QWidget KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); - - + + ~KABCore(); @@ -141,3 +142,3 @@ class KABCore : public QWidget #endif //KAB_EMBEDDED - + void statusMessage(QString, int time = 0 ); @@ -165,2 +166,12 @@ class KABCore : public QWidget /** + Beams the "WhoAmI contact. + */ + void beamMySelf(); + + void beamVCard(); + void beamVCard(const QStringList& uids); + void beamDone( Ir *ir ); + + + /** Starts the preferred web browser with the given URL as argument. @@ -288,5 +299,5 @@ class KABCore : public QWidget void editContact( const QString &uid /*US = QString::null*/ ); -//US added a second method without defaultparameter +//US added a second method without defaultparameter void editContact2(); - + /** @@ -337,3 +348,3 @@ class KABCore : public QWidget void initActions(); - + AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, @@ -342,3 +353,3 @@ class KABCore : public QWidget KXMLGUIClient *mGUIClient; - + KABC::AddressBook *mAddressBook; @@ -368,2 +379,3 @@ class KABCore : public QWidget KAction *mActionMail; + KAction *mActionBeam; KAction* mActionPrint; @@ -373,4 +385,6 @@ class KABCore : public QWidget KAction *mActionMailVCard; + KAction *mActionBeamVCard; + KAction *mActionQuit; - + //US edit menu @@ -383,3 +397,3 @@ class KABCore : public QWidget KAction *mActionDelete; - + //US settings menu @@ -395,5 +409,5 @@ class KABCore : public QWidget KAction *mActionAboutKAddressbook; - + KAction *mActionDeleteView; - + QPopupMenu *viewMenu; @@ -402,3 +416,3 @@ class KABCore : public QWidget QPopupMenu *changeMenu; - + //US QAction *mActionSave; @@ -409,3 +423,3 @@ class KABCore : public QWidget KAction * mActionImportOL; - + #ifndef KAB_EMBEDDED @@ -420,3 +434,3 @@ class KABCore : public QWidget #endif //KAB_EMBEDDED - + }; |