-rw-r--r-- | kaddressbook/kabcore.cpp | 62 | ||||
-rw-r--r-- | kaddressbook/kabcore.h | 11 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.cpp | 12 | ||||
-rw-r--r-- | kaddressbook/kaddressbookmain.h | 1 | ||||
-rw-r--r-- | kaddressbook/mainembedded.cpp | 7 |
5 files changed, 76 insertions, 17 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 11eeabc..980e436 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -308,31 +308,83 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const #endif //KAB_EMBEDDED mMessageTimer = new QTimer( this ); connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); + mBRdisabled = 0; +#ifndef DESKTOP_VERSION + infrared = 0; +#endif + toggleBeamReceive( ); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); delete syncManager; + if ( infrared ) + delete infrared; +} +void KABCore::receive( const QCString& cmsg, const QByteArray& data ) +{ + qDebug("KA: QCOP message received: %s ", cmsg.data() ); + if ( cmsg == "setDocument(QString)" ) { + QDataStream stream( data, IO_ReadOnly ); + QString fileName; + stream >> fileName; + recieve( fileName ); + return; + } +} +void KABCore::toggleBeamReceive( ) +{ + if ( mBRdisabled ) + return; +#ifndef DESKTOP_VERSION + if ( infrared ) { + qDebug("AB disable BeamReceive "); + delete infrared; + infrared = 0; + mActionBR->setChecked(false); + return; + } + qDebug("AB enable BeamReceive "); + mActionBR->setChecked(true); + infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; + QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); +#endif } + +void KABCore::disableBR(bool b) +{ + if ( b ) { + if ( infrared ) { + toggleBeamReceive( ); + mBRdisabled = true; + } + } else { + if ( mBRdisabled ) { + mBRdisabled = false; + toggleBeamReceive( ); + } + } + +} void KABCore::recieve( QString fn ) { //qDebug("KABCore::recieve "); int count = mAddressBook->importFromFile( fn, true ); mViewManager->refreshView(); message(i18n("%1 contact(s) received!").arg( count )); topLevelWidget()->showMaximized(); topLevelWidget()->raise(); @@ -1779,16 +1831,22 @@ void KABCore::initActions() mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, actionCollection(), "options_show_jump_bar" ); connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, actionCollection(), "options_show_details" ); connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); + + mActionBR = new KToggleAction( i18n( "Beam receice enabled" ), "beam", 0, this, + SLOT( toggleBeamReceive() ), actionCollection(), + "kaddressbook_beam_rec" ); + + // misc // 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" ); } @@ -1949,16 +2007,18 @@ void KABCore::addActionsManually() settingsMenu->insertSeparator(); mActionJumpBar->plug( settingsMenu ); mActionDetails->plug( settingsMenu ); if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); + mActionBR->plug(settingsMenu ); + settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); mActionCategories->plug( settingsMenu ); mActionWN->plug( helpMenu ); mActionSyncHowto->plug( helpMenu ); mActionLicence->plug( helpMenu ); @@ -2742,16 +2802,17 @@ bool KABCore::sync(KSyncManager* manager, QString filename, int mode) } //this is a overwritten callbackmethods from the syncinterface bool KABCore::syncExternal(KSyncManager* manager, QString resource) { if ( resource == "phone" ) return syncPhone(); + disableBR( true ); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal( resource,"syncContact"); bool syncOK = false; if ( abLocal.load() ) { qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); mGlobalSyncMode = SYNC_MODE_EXTERNAL; abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); @@ -2762,16 +2823,17 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) abLocal.saveAB(); abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); } } setModified(); } if ( syncOK ) mViewManager->refreshView(); + disableBR( false ); return syncOK; } void KABCore::message( QString m ) { topLevelWidget()->setCaption( m ); mMessageTimer->start( 15000, true ); } diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c7be343..fcbe1e8 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -29,16 +29,19 @@ #ifndef KAB_EMBEDDED #endif //KAB_EMBEDDED #include <qdict.h> #include <qtimer.h> #include <qwidget.h> #include <qpopupmenu.h> #include <ksyncmanager.h> +#ifndef DESKTOP_VERSION +#include <qcopchannel_qws.h> +#endif namespace KABC { class AddressBook; } #ifndef KAB_EMBEDDED class KAboutData; class KConfig; @@ -347,16 +350,19 @@ class KABCore : public QWidget, public KSyncInterface public slots: void recieve(QString cmsg ); void getFile( bool success ); void syncFileRequest(); void setDetailsVisible( bool visible ); void setDetailsToState(); // void slotSyncMenu( int ); private slots: + void receive( const QCString& cmsg, const QByteArray& data ); + void toggleBeamReceive( ); + void disableBR(bool); void setJumpButtonBarVisible( bool visible ); void setCaptionBack(); void importFromOL(); void extensionModified( const KABC::Addressee::List &list ); void extensionChanged( int id ); void clipboardDataChanged(); void updateActionMenu(); void configureKeyBindings(); @@ -365,16 +371,20 @@ class KABCore : public QWidget, public KSyncInterface void configureResources(); #endif //KAB_EMBEDDED void slotEditorDestroyed( const QString &uid ); void configurationChanged(); void addressBookChanged(); private: + bool mBRdisabled; +#ifndef DESKTOP_VERSION + QCopChannel* infrared; +#endif QTimer *mMessageTimer; void initGUI(); void initActions(); QString getPhoneFile(); AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, const char *name = 0 ); @@ -403,16 +413,17 @@ class KABCore : public QWidget, public KSyncInterface bool mModified; bool mIsPart; bool mMultipleViewsAtOnce; //US file menu KAction *mActionMail; KAction *mActionBeam; + KToggleAction *mActionBR; KAction *mActionExport2phone; KAction* mActionPrint; KAction* mActionNewContact; KAction *mActionSave; KAction *mActionEditAddressee; KAction *mActionMailVCard; KAction *mActionBeamVCard; diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 8c4ca09..f48f214 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -87,27 +87,17 @@ KAddressBookMain::KAddressBookMain() : DCOPObject( "KAddressBookIface" ), KMainW qApp->processEvents(); mCore->restoreSettings(); } KAddressBookMain::~KAddressBookMain() { // mCore->saveSettings(); } -void KAddressBookMain::recieve( const QCString& cmsg, const QByteArray& data ) -{ - qDebug("KA: QCOP message received: %s ", cmsg.data() ); - if ( cmsg == "setDocument(QString)" ) { - QDataStream stream( data, IO_ReadOnly ); - QString fileName; - stream >> fileName; - mCore->recieve( fileName ); - return; - } -} + void KAddressBookMain::showMinimized () { QWidget::showMinimized () ; } void KAddressBookMain::addEmail( QString addr ) { mCore->addEmail( addr ); } diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h index 40d2bdd..b6d9b4b 100644 --- a/kaddressbook/kaddressbookmain.h +++ b/kaddressbook/kaddressbookmain.h @@ -76,17 +76,16 @@ class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface //MOC_SKIP_BEGIN virtual ASYNC showContactEditor( QString uid ); //MOC_SKIP_END #endif //KAB_EMBEDDED virtual void newContact(); virtual QString getNameByPhone( QString phone ); virtual void save(); virtual void exit(); - void recieve( const QCString& cmsg, const QByteArray& data ); protected: void initActions(); #ifdef KAB_EMBEDDED //US new method to setup menues and toolbars on embedded systems void createGUI(); #endif //KAB_EMBEDDED /** diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 6dd97b8..a2ff1e9 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -74,27 +74,24 @@ int main( int argc, char **argv ) //US MainWindow m; QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); { KPimGlobalPrefs::instance()->setGlobalConfig(); } #ifndef DESKTOP_VERSION a.showMainWidget( &m ); - QCopChannel* c1 = new QCopChannel("QPE/Application/addressbook",&m, "channelAB" ) ; - QObject::connect( c1, SIGNAL (received ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); + #else a.setMainWidget( &m ); m.resize (640, 480 ); m.show(); #endif a.exec(); -#ifndef DESKTOP_VERSION - delete c1; -#endif + } qDebug("KA: Bye! "); } /* #include <stdlib.h> |