summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 11eeabc..980e436 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -313,6 +313,11 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
313 mEditorDialog = 0; 313 mEditorDialog = 0;
314 createAddresseeEditorDialog( this ); 314 createAddresseeEditorDialog( this );
315 setModified( false ); 315 setModified( false );
316 mBRdisabled = 0;
317#ifndef DESKTOP_VERSION
318 infrared = 0;
319#endif
320 toggleBeamReceive( );
316} 321}
317 322
318KABCore::~KABCore() 323KABCore::~KABCore()
@@ -325,9 +330,56 @@ KABCore::~KABCore()
325 KABC::StdAddressBook::close(); 330 KABC::StdAddressBook::close();
326 331
327 delete syncManager; 332 delete syncManager;
333 if ( infrared )
334 delete infrared;
335}
336void KABCore::receive( const QCString& cmsg, const QByteArray& data )
337{
338 qDebug("KA: QCOP message received: %s ", cmsg.data() );
339 if ( cmsg == "setDocument(QString)" ) {
340 QDataStream stream( data, IO_ReadOnly );
341 QString fileName;
342 stream >> fileName;
343 recieve( fileName );
344 return;
345 }
346}
347void KABCore::toggleBeamReceive( )
348{
349 if ( mBRdisabled )
350 return;
351#ifndef DESKTOP_VERSION
352 if ( infrared ) {
353 qDebug("AB disable BeamReceive ");
354 delete infrared;
355 infrared = 0;
356 mActionBR->setChecked(false);
357 return;
358 }
359 qDebug("AB enable BeamReceive ");
360 mActionBR->setChecked(true);
328 361
362 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
363 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
364#endif
329} 365}
330 366
367
368void KABCore::disableBR(bool b)
369{
370 if ( b ) {
371 if ( infrared ) {
372 toggleBeamReceive( );
373 mBRdisabled = true;
374 }
375 } else {
376 if ( mBRdisabled ) {
377 mBRdisabled = false;
378 toggleBeamReceive( );
379 }
380 }
381
382}
331void KABCore::recieve( QString fn ) 383void KABCore::recieve( QString fn )
332{ 384{
333 //qDebug("KABCore::recieve "); 385 //qDebug("KABCore::recieve ");
@@ -1784,6 +1836,12 @@ void KABCore::initActions()
1784 actionCollection(), "options_show_details" ); 1836 actionCollection(), "options_show_details" );
1785 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1837 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1786 1838
1839
1840 mActionBR = new KToggleAction( i18n( "Beam receice enabled" ), "beam", 0, this,
1841 SLOT( toggleBeamReceive() ), actionCollection(),
1842 "kaddressbook_beam_rec" );
1843
1844
1787 // misc 1845 // misc
1788 // only enable LDAP lookup if we can handle the protocol 1846 // only enable LDAP lookup if we can handle the protocol
1789#ifndef KAB_EMBEDDED 1847#ifndef KAB_EMBEDDED
@@ -1954,6 +2012,8 @@ void KABCore::addActionsManually()
1954 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2012 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1955 mActionDetails->plug( tb ); 2013 mActionDetails->plug( tb );
1956 settingsMenu->insertSeparator(); 2014 settingsMenu->insertSeparator();
2015 mActionBR->plug(settingsMenu );
2016 settingsMenu->insertSeparator();
1957 2017
1958 mActionWhoAmI->plug( settingsMenu ); 2018 mActionWhoAmI->plug( settingsMenu );
1959 mActionCategories->plug( settingsMenu ); 2019 mActionCategories->plug( settingsMenu );
@@ -2747,6 +2807,7 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2747{ 2807{
2748 if ( resource == "phone" ) 2808 if ( resource == "phone" )
2749 return syncPhone(); 2809 return syncPhone();
2810 disableBR( true );
2750 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 2811 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
2751 2812
2752 AddressBook abLocal( resource,"syncContact"); 2813 AddressBook abLocal( resource,"syncContact");
@@ -2767,6 +2828,7 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2767 } 2828 }
2768 if ( syncOK ) 2829 if ( syncOK )
2769 mViewManager->refreshView(); 2830 mViewManager->refreshView();
2831 disableBR( false );
2770 return syncOK; 2832 return syncOK;
2771 2833
2772} 2834}