summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Side-by-side diff
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
@@ -309,28 +309,80 @@ 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 );
+ 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 ));
@@ -1781,12 +1833,18 @@ void KABCore::initActions()
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(),
@@ -1951,12 +2009,14 @@ void KABCore::addActionsManually()
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 );
@@ -2744,12 +2804,13 @@ 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());
@@ -2764,12 +2825,13 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
+ disableBR( false );
return syncOK;
}
void KABCore::message( QString m )
{
topLevelWidget()->setCaption( m );