-rw-r--r-- | kaddressbook/kabcore.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 11eeabc..980e436 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -312,7 +312,12 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); mEditorDialog = 0; createAddresseeEditorDialog( this ); - setModified( false ); + setModified( false ); + mBRdisabled = 0; +#ifndef DESKTOP_VERSION + infrared = 0; +#endif + toggleBeamReceive( ); } KABCore::~KABCore() @@ -325,9 +330,56 @@ KABCore::~KABCore() 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 "); @@ -1784,6 +1836,12 @@ void KABCore::initActions() 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 @@ -1954,6 +2012,8 @@ void KABCore::addActionsManually() if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); + mActionBR->plug(settingsMenu ); + settingsMenu->insertSeparator(); mActionWhoAmI->plug( settingsMenu ); mActionCategories->plug( settingsMenu ); @@ -2747,6 +2807,7 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) { if ( resource == "phone" ) return syncPhone(); + disableBR( true ); QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); AddressBook abLocal( resource,"syncContact"); @@ -2767,6 +2828,7 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource) } if ( syncOK ) mViewManager->refreshView(); + disableBR( false ); return syncOK; } |