-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 @@ -314,4 +314,9 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const createAddresseeEditorDialog( this ); setModified( false ); + mBRdisabled = 0; +#ifndef DESKTOP_VERSION + infrared = 0; +#endif + toggleBeamReceive( ); } @@ -326,7 +331,54 @@ KABCore::~KABCore() 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 ) { @@ -1785,4 +1837,10 @@ void KABCore::initActions() 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 @@ -1955,4 +2013,6 @@ void KABCore::addActionsManually() mActionDetails->plug( tb ); settingsMenu->insertSeparator(); + mActionBR->plug(settingsMenu ); + settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); @@ -2748,4 +2808,5 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) if ( resource == "phone" ) return syncPhone(); + disableBR( true ); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); @@ -2768,4 +2829,5 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) if ( syncOK ) mViewManager->refreshView(); + disableBR( false ); return syncOK; diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h index c7be343..fcbe1e8 100644 --- a/kaddressbook/kabcore.h +++ b/kaddressbook/kabcore.h @@ -35,4 +35,7 @@ #include <qpopupmenu.h> #include <ksyncmanager.h> +#ifndef DESKTOP_VERSION +#include <qcopchannel_qws.h> +#endif namespace KABC { @@ -353,4 +356,7 @@ class KABCore : public QWidget, public KSyncInterface // void slotSyncMenu( int ); private slots: + void receive( const QCString& cmsg, const QByteArray& data ); + void toggleBeamReceive( ); + void disableBR(bool); void setJumpButtonBarVisible( bool visible ); void setCaptionBack(); @@ -371,4 +377,8 @@ class KABCore : public QWidget, public KSyncInterface private: + bool mBRdisabled; +#ifndef DESKTOP_VERSION + QCopChannel* infrared; +#endif QTimer *mMessageTimer; void initGUI(); @@ -409,4 +419,5 @@ class KABCore : public QWidget, public KSyncInterface KAction *mActionMail; KAction *mActionBeam; + KToggleAction *mActionBR; KAction *mActionExport2phone; KAction* mActionPrint; diff --git a/kaddressbook/kaddressbookmain.cpp b/kaddressbook/kaddressbookmain.cpp index 8c4ca09..f48f214 100644 --- a/kaddressbook/kaddressbookmain.cpp +++ b/kaddressbook/kaddressbookmain.cpp @@ -93,15 +93,5 @@ 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 () { diff --git a/kaddressbook/kaddressbookmain.h b/kaddressbook/kaddressbookmain.h index 40d2bdd..b6d9b4b 100644 --- a/kaddressbook/kaddressbookmain.h +++ b/kaddressbook/kaddressbookmain.h @@ -82,5 +82,4 @@ class KAddressBookMain : public KMainWindow, virtual public KAddressBookIface virtual void save(); virtual void exit(); - void recieve( const QCString& cmsg, const QByteArray& data ); protected: void initActions(); diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp index 6dd97b8..a2ff1e9 100644 --- a/kaddressbook/mainembedded.cpp +++ b/kaddressbook/mainembedded.cpp @@ -80,6 +80,5 @@ int main( int argc, char **argv ) #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 ); @@ -88,7 +87,5 @@ int main( int argc, char **argv ) #endif a.exec(); -#ifndef DESKTOP_VERSION - delete c1; -#endif + } |