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.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index dae9cd2..087e9e3 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -672,73 +672,70 @@ void KABCore::beamMySelf()
void KABCore::export2phone()
{
KAex2phonePrefs ex2phone;
ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
if ( !ex2phone.exec() ) {
return;
}
KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
KPimGlobalPrefs::instance()->mEx2PhoneConnection,
KPimGlobalPrefs::instance()->mEx2PhoneModel );
QStringList uids = mViewManager->selectedUids();
if ( uids.isEmpty() )
return;
+ QString fileName = getPhoneFile();
+ if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
+ return;
+
+ QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
+
+}
+QString KABCore::getPhoneFile()
+{
#ifdef _WIN32_
- QString fileName = locateLocal("tmp", "phonefile.vcf");
+ return locateLocal("tmp", "phonefile.vcf");
#else
- QString fileName = "/tmp/phonefile.vcf";
+ return "/tmp/phonefile.vcf";
#endif
- if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
- return;
-
- if ( PhoneAccess::writeToPhone( fileName ) )
- qDebug("Export okay ");
- else
- qDebug("Error export contacts ");
-
-
-#if 0
-
- setCaption( i18n("Writing to phone..."));
- if ( PhoneFormat::writeToPhone( cal ) )
- setCaption( i18n("Export to phone successful!"));
+}
+void KABCore::writeToPhone( )
+{
+ if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
+ qDebug("Export okay ");
else
- setCaption( i18n("Error exporting to phone!"));
-#endif
-
-
+ qDebug("Error export contacts ");
}
void KABCore::beamVCard()
{
QStringList uids = mViewManager->selectedUids();
if ( !uids.isEmpty() )
beamVCard( uids );
}
void KABCore::beamVCard(const QStringList& uids)
{
/*US
QString beamFilename;
Opie::OPimContact c;
if ( actionPersonal->isOn() ) {
beamFilename = addressbookPersonalVCardName();
if ( !QFile::exists( beamFilename ) )
return; // can't beam a non-existent file
Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
beamFilename );
Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
Opie::OPimContactAccess::List allList = access->allRecords();
Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
c = *it;
@@ -813,48 +810,49 @@ void KABCore::beamVCard(const QStringList& uids)
if ( outFile.open(IO_WriteOnly) ) {
datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
QTextStream t( &outFile ); // use a text stream
//t.setEncoding( QTextStream::UnicodeUTF8 );
t.setEncoding( QTextStream::Latin1 );
t <<datastream.latin1();
outFile.close();
Ir *ir = new Ir( this );
connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
ir->send( fileName, description, "text/x-vCard" );
} else {
qDebug("Error open temp beam file ");
return;
}
#endif
}
void KABCore::beamDone( Ir *ir )
{
#ifndef DESKTOP_VERSION
delete ir;
#endif
topLevelWidget()->raise();
+ message( i18n("Beaming successful!") );
}
void KABCore::browse( const QString& url )
{
#ifndef KAB_EMBEDDED
kapp->invokeBrowser( url );
#else //KAB_EMBEDDED
qDebug("KABCore::browse must be fixed");
#endif //KAB_EMBEDDED
}
void KABCore::selectAllContacts()
{
mViewManager->setSelected( QString::null, true );
}
void KABCore::deleteContacts()
{
QStringList uidList = mViewManager->selectedUids();
deleteContacts( uidList );
}
void KABCore::deleteContacts( const QStringList &uids )
@@ -2797,54 +2795,49 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( false );
abLocal.saveAB();
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
setModified();
}
if ( syncOK )
mViewManager->refreshView();
return syncOK;
}
void KABCore::message( QString m )
{
topLevelWidget()->setCaption( m );
QTimer::singleShot( 15000, this , SLOT ( setCaptionBack()));
}
bool KABCore::syncPhone()
{
QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
- QString fileName;
-#ifdef _WIN32_
- fileName = locateLocal("tmp", "phonefile.vcf");
-#else
- fileName = "/tmp/phonefile.vcf";
-#endif
+ QString fileName = getPhoneFile();
if ( !PhoneAccess::readFromPhone( fileName) ) {
message(i18n("Phone access failed!"));
return false;
}
AddressBook abLocal( fileName,"syncContact");
bool syncOK = false;
{
abLocal.importFromFile( fileName );
qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
abLocal.preparePhoneSync( mCurrentSyncDevice, true );
abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
if ( syncOK ) {
if ( syncManager->mWriteBackFile ) {
abLocal.removeSyncAddressees( true );
abLocal.saveABphone( fileName );
abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
//abLocal.preparePhoneSync( mCurrentSyncDevice, false );
abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
}
}
setModified();
}