summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -72,32 +72,33 @@
//#include <qtoolbar.h>
#include <qmessagebox.h>
#include <kdebug.h>
#include <kiconloader.h> // needed for SmallIcon
#include <kresources/kcmkresources.h>
#include <ktoolbar.h>
#include <kcmkabconfig.h>
//#include <qlabel.h>
#ifdef Q_WS_QWS
#include <qtopia/services.h>
#include <qtopia/qcopenvelope_qws.h>
#endif
+#include <qpe/ir.h>
#endif // KAB_EMBEDDED
#include <kcmkabconfig.h>
#include <kresources/selectdialog.h>
#include <kmessagebox.h>
#include <picture.h>
#include <resource.h>
//US#include <qsplitter.h>
#include <qmap.h>
#include <qdir.h>
#include <qfile.h>
#include <qvbox.h>
@@ -436,32 +437,38 @@ void KABCore::setContactSelected( const QString &uid )
mExtensionManager->setSelectionChanged();
// update the actions
bool selected = !uid.isEmpty();
if ( mReadWrite ) {
mActionCut->setEnabled( selected );
mActionPaste->setEnabled( selected );
}
mActionCopy->setEnabled( selected );
mActionDelete->setEnabled( selected );
mActionEditAddressee->setEnabled( selected );
mActionMail->setEnabled( selected );
mActionMailVCard->setEnabled( selected );
+ if (mActionBeam)
+ mActionBeam->setEnabled( selected );
+
+ if (mActionBeam)
+ mActionBeamVCard->setEnabled( selected );
+
mActionWhoAmI->setEnabled( selected );
mActionCategories->setEnabled( selected );
}
void KABCore::sendMail()
{
sendMail( mViewManager->selectedEmails().join( ", " ) );
}
void KABCore::sendMail( const QString& email )
{
//US original kde implementation : kapp->invokeMailer( email, "" );
/*US original qtopia implementation
PimContact c = abList->currentEntry();
QString name = c.fileAs();
@@ -472,32 +479,34 @@ void KABCore::sendMail( const QString& email )
#else
*/
#ifndef QT_NO_COP
QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
QCopEnvelope e(channel, "writeMail(QString,QString)");
//US we need no names in the To field. The emailadresses are enough
e << "" << email;
#else
KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
#endif
}
+
+
void KABCore::mailVCard()
{
QStringList uids = mViewManager->selectedUids();
if ( !uids.isEmpty() )
mailVCard( uids );
}
void KABCore::mailVCard( const QStringList& uids )
{
QStringList urls;
QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
/*US
// Create a temp dir, so that we can put the files in it with proper names
KTempFile tempDir;
@@ -551,32 +560,138 @@ void KABCore::mailVCard( const QStringList& uids )
#ifndef QT_NO_COP
QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
QMap<QString, QString> parameterMap;
parameterMap.insert("ATTACHMENT<n>", urls.join(", "));
QCopEnvelope e(channel, "writeMail(QMap(QString,QString))");
e << parameterMap;
#else
KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
#endif
}
+/**
+ 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 )
{
#ifndef KAB_EMBEDDED
kapp->invokeBrowser( url );
#else //KAB_EMBEDDED
qDebug("KABCore::browse must be fixed");
#endif //KAB_EMBEDDED
}
void KABCore::selectAllContacts()
{
mViewManager->setSelected( QString::null, true );
}
void KABCore::deleteContacts()
{
@@ -1350,42 +1465,51 @@ void KABCore::initActions()
SLOT( clipboardDataChanged() ) );
#endif //KAB_EMBEDDED
// file menu
if ( mIsPart ) {
mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
SLOT( sendMail() ), actionCollection(),
"kaddressbook_mail" );
mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
SLOT( print() ), actionCollection(), "kaddressbook_print" );
} else {
mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
}
+
mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
SLOT( save() ), actionCollection(), "file_sync" );
mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
SLOT( newContact() ), actionCollection(), "file_new_contact" );
mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
this, SLOT( mailVCard() ),
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() ),
actionCollection(), "file_properties" );
#ifdef KAB_EMBEDDED
// mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
mMainWindow, SLOT( exit() ),
actionCollection(), "quit" );
#endif //KAB_EMBEDDED
// edit menu
if ( mIsPart ) {
mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
SLOT( copyContacts() ), actionCollection(),
"kaddressbook_copy" );
@@ -1460,32 +1584,40 @@ void KABCore::initActions()
// only enable LDAP lookup if we can handle the protocol
#ifndef KAB_EMBEDDED
if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
this, SLOT( openLDAPDialog() ), actionCollection(),
"ldap_lookup" );
}
#else //KAB_EMBEDDED
//qDebug("KABCore::initActions() LDAP has to be implemented");
#endif //KAB_EMBEDDED
mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
SLOT( setWhoAmI() ), actionCollection(),
"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(),
"edit_set_categories" );
mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
SLOT( removeVoice() ), actionCollection(),
"remove_voice" );
mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
SLOT( importFromOL() ), actionCollection(),
"import_OL" );
#ifdef KAB_EMBEDDED
mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
this, SLOT( createAboutData() ), actionCollection(),
"kaddressbook_about_data" );
#endif //KAB_EMBEDDED
@@ -1548,32 +1680,33 @@ void KABCore::addActionsManually()
//US Now connect the actions with the menue entries.
mActionPrint->plug( fileMenu );
mActionMail->plug( fileMenu );
fileMenu->insertSeparator();
mActionNewContact->plug( fileMenu );
mActionNewContact->plug( tb );
mActionEditAddressee->plug( fileMenu );
fileMenu->insertSeparator();
mActionSave->plug( fileMenu );
fileMenu->insertItem( "&Import", ImportMenu );
fileMenu->insertItem( "&Emport", ExportMenu );
fileMenu->insertSeparator();
mActionMailVCard->plug( fileMenu );
+ if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
fileMenu->insertSeparator();
mActionQuit->plug( fileMenu );
#ifdef _WIN32_
mActionImportOL->plug( ImportMenu );
#endif
// edit menu
mActionUndo->plug( editMenu );
mActionRedo->plug( editMenu );
editMenu->insertSeparator();
mActionCut->plug( editMenu );
mActionCopy->plug( editMenu );
mActionPaste->plug( editMenu );
mActionDelete->plug( editMenu );
editMenu->insertSeparator();
mActionSelectAll->plug( editMenu );
@@ -1588,32 +1721,33 @@ void KABCore::addActionsManually()
if ( mIsPart ) {
mActionConfigShortcuts->plug( settingsMenu );
mActionConfigureToolbars->plug( settingsMenu );
} else {
mActionKeyBindings->plug( settingsMenu );
}
settingsMenu->insertSeparator();
mActionJumpBar->plug( settingsMenu );
mActionDetails->plug( settingsMenu );
settingsMenu->insertSeparator();
mActionWhoAmI->plug( settingsMenu );
+ if ( Ir::supported() ) mActionBeam->plug( settingsMenu );
mActionCategories->plug( settingsMenu );
mActionAboutKAddressbook->plug( helpMenu );
if (QApplication::desktop()->width() > 320 ) {
mActionEditAddressee->plug( tb );
mActionSave->plug( tb );
mViewManager->getFilterAction()->plug ( tb);
if (QApplication::desktop()->width() > 480 ) {
mActionUndo->plug( tb );
mActionDelete->plug( tb );
mActionRedo->plug( tb );
}
}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 6446974..be39148 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -51,32 +51,33 @@ class KCMultiDialog;
class KXMLGUIClient;
class ExtensionManager;
class XXPortManager;
class JumpButtonBar;
class IncSearchWidget;
class KDGanttMinimizeSplitter;
class KAction;
class KActionCollection;
class KToggleAction;
class QAction;
class QMenuBar;
class QSplitter;
class ViewContainer;
class ViewManager;
class AddresseeEditorDialog;
+class Ir;
class KABCore : public QWidget
{
Q_OBJECT
public:
KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
~KABCore();
#ifdef KAB_EMBEDDED
//US added functionality
QPopupMenu* getViewMenu() {return viewMenu;}
QPopupMenu* getFilterMenu() {return filterMenu;}
@@ -150,32 +151,42 @@ class KABCore : public QWidget
Opens the preferred mail composer with all selected contacts as
arguments.
*/
void sendMail();
/**
Opens the preferred mail composer with the given contacts as
arguments.
*/
void sendMail( const QString& email );
void mailVCard();
void mailVCard(const QStringList& uids);
/**
+ 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.
*/
void browse( const QString& url );
/**
Select all contacts in the view.
*/
void selectAllContacts();
/**
Deletes all selected contacts from the address book.
*/
void deleteContacts();
/**
Deletes given contacts from the address book.
@@ -353,37 +364,40 @@ class KABCore : public QWidget
IncSearchWidget *mIncSearchWidget;
ExtensionManager *mExtensionManager;
KCMultiDialog *mConfigureDialog;
#ifndef KAB_EMBEDDED
LDAPSearchDialog *mLdapSearchDialog;
#endif //KAB_EMBEDDED
// QDict<AddresseeEditorDialog> mEditorDict;
AddresseeEditorDialog *mEditorDialog;
bool mReadWrite;
bool mModified;
bool mIsPart;
//US file menu
KAction *mActionMail;
+ KAction *mActionBeam;
KAction* mActionPrint;
KAction* mActionNewContact;
KAction *mActionSave;
KAction *mActionEditAddressee;
KAction *mActionMailVCard;
+ KAction *mActionBeamVCard;
+
KAction *mActionQuit;
//US edit menu
KAction *mActionCopy;
KAction *mActionCut;
KAction *mActionPaste;
KAction *mActionSelectAll;
KAction *mActionUndo;
KAction *mActionRedo;
KAction *mActionDelete;
//US settings menu
KAction *mActionConfigResources;
KAction *mActionConfigKAddressbook;
KAction *mActionConfigShortcuts;
KAction *mActionConfigureToolbars;