summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
authorzautrix <zautrix>2004-10-20 10:24:19 (UTC)
committer zautrix <zautrix>2004-10-20 10:24:19 (UTC)
commitf6f5f5cfcaa38f3e2bf36d8466b2b44ba7b3fb28 (patch) (side-by-side diff)
treec0f67de8a80dc20d80612d7b4b27ebc6ca30f1ca /kaddressbook/kabcore.cpp
parentb3662915cb2c966ed7b5c563b8e840ae5b82d4e6 (diff)
downloadkdepimpi-f6f5f5cfcaa38f3e2bf36d8466b2b44ba7b3fb28.zip
kdepimpi-f6f5f5cfcaa38f3e2bf36d8466b2b44ba7b3fb28.tar.gz
kdepimpi-f6f5f5cfcaa38f3e2bf36d8466b2b44ba7b3fb28.tar.bz2
fixed br for kapi
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp64
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;
}