summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-06 01:40:28 (UTC)
committer ulf69 <ulf69>2004-08-06 01:40:28 (UTC)
commitb82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138 (patch) (side-by-side diff)
tree6e407c4b61128e5d16f657f6ae788ebcaadb7862
parent422cea307a0a85064db6b5b64a847375da9311e1 (diff)
downloadkdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.zip
kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.tar.gz
kdepimpi-b82b4b1efe9edddfb7b7d5eaa9fe8da4a9698138.tar.bz2
enabled beaming and sending of emails
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp134
-rw-r--r--kaddressbook/kabcore.h14
2 files changed, 148 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 2a54900..d891b07 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -86,4 +86,5 @@
#include <qtopia/qcopenvelope_qws.h>
#endif
+#include <qpe/ir.h>
#endif // KAB_EMBEDDED
@@ -450,4 +451,10 @@ void KABCore::setContactSelected( const QString &uid )
mActionMail->setEnabled( selected );
mActionMailVCard->setEnabled( selected );
+ if (mActionBeam)
+ mActionBeam->setEnabled( selected );
+
+ if (mActionBeam)
+ mActionBeamVCard->setEnabled( selected );
+
mActionWhoAmI->setEnabled( selected );
mActionCategories->setEnabled( selected );
@@ -486,4 +493,6 @@ void KABCore::sendMail( const QString& email )
}
+
+
void KABCore::mailVCard()
{
@@ -565,4 +574,110 @@ 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 )
{
@@ -1364,4 +1479,5 @@ void KABCore::initActions()
}
+
mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
SLOT( save() ), actionCollection(), "file_sync" );
@@ -1374,4 +1490,12 @@ void KABCore::initActions()
actionCollection(), "file_mail_vcard");
+ 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,
this, SLOT( editContact2() ),
@@ -1474,4 +1598,12 @@ void KABCore::initActions()
"set_personal" );
+ 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,
SLOT( setCategories() ), actionCollection(),
@@ -1562,4 +1694,5 @@ void KABCore::addActionsManually()
fileMenu->insertSeparator();
mActionMailVCard->plug( fileMenu );
+ if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
fileMenu->insertSeparator();
mActionQuit->plug( fileMenu );
@@ -1602,4 +1735,5 @@ 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
@@ -65,4 +65,5 @@ class ViewContainer;
class ViewManager;
class AddresseeEditorDialog;
+class Ir;
class KABCore : public QWidget
@@ -164,4 +165,14 @@ 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.
*/
@@ -367,4 +378,5 @@ class KABCore : public QWidget
//US file menu
KAction *mActionMail;
+ KAction *mActionBeam;
KAction* mActionPrint;
KAction* mActionNewContact;
@@ -372,4 +384,6 @@ class KABCore : public QWidget
KAction *mActionEditAddressee;
KAction *mActionMailVCard;
+ KAction *mActionBeamVCard;
+
KAction *mActionQuit;