summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-18 17:56:55 (UTC)
committer zautrix <zautrix>2005-03-18 17:56:55 (UTC)
commitd6438efc4c7cff39024b65bfd1d2f810212da544 (patch) (side-by-side diff)
treebadb4c48d83477dd1027af1807cb2b6ed09db52a
parentf9f521c487143641b2cf077d04fe1c475001bce2 (diff)
downloadkdepimpi-d6438efc4c7cff39024b65bfd1d2f810212da544.zip
kdepimpi-d6438efc4c7cff39024b65bfd1d2f810212da544.tar.gz
kdepimpi-d6438efc4c7cff39024b65bfd1d2f810212da544.tar.bz2
kde sync fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kde2file/abdump/main.cpp5
-rw-r--r--libkdepim/ksyncmanager.cpp14
2 files changed, 16 insertions, 3 deletions
diff --git a/kde2file/abdump/main.cpp b/kde2file/abdump/main.cpp
index 9ad78e5..b359cfe 100644
--- a/kde2file/abdump/main.cpp
+++ b/kde2file/abdump/main.cpp
@@ -123,71 +123,74 @@ int main( int argc, char *argv[] )
int added = 0, changedC = 0, deleted = 0;
QFile file( fileName );
if ( file.open( IO_ReadOnly ) ) {
QTextStream t( &file ); // use a text stream
t.setEncoding( QTextStream::UnicodeUTF8 );
QString data;
data = t.read();
file.close();
KABC::VCardConverter converter;
list = converter.parseVCards( data );
qDebug("kdeABdump::file has %d entries", list.count());
KABC::Addressee::List::Iterator it;
for ( it = list.begin();it != list.end();++it) {
(*it).setChanged( true );
bool changed = ((*it).custom( "KADDRESSBOOK", "X-ExternalID" ) == "changed");
(*it).removeCustom( "KADDRESSBOOK", "X-ExternalID" );
//qDebug("ext %s ", (*it).custom( "KADDRESSBOOK", "X-ExternalID" ).latin1());
if ( changed ) {
//qDebug("changed Addressee found! ");
KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() );
if ( ! std.isEmpty() )
(*it).setResource(std.resource());
standardAddressBook->insertAddressee( (*it) );
++changedC;
} else {
//maybe added?
KABC::Addressee std = standardAddressBook->findByUid( (*it).uid() );
if ( std.isEmpty() ) {
standardAddressBook->insertAddressee( (*it) );
++added;
}
}
}
KABC::AddressBook::Iterator itA = standardAddressBook->begin();
KABC::AddressBook::Iterator it2 ;
while ( itA != standardAddressBook->end() ) {
bool found = false;
KABC::Addressee::List::Iterator itL;
for ( itL = list.begin();itL != list.end();++itL) {
if ( (*itL).uid() == (*itA).uid() ) {
found = true;
break;
}
}
if ( !found ) {
it2 = itA;
++itA;
standardAddressBook->removeAddressee( it2 );
++deleted;
} else {
++itA;
}
}
//standardAddressBook->saveAll();
standardAddressBook->setAutomaticSave( true );
qDebug("************************************* ");
qDebug("*************kdeABdump*************** ");
qDebug("************************************* ");
qDebug("Addressbook entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", changedC,deleted, added, fileName.latin1());
} else
qDebug("error open file ");
}
+ standardAddressBook->close();
+ // line not needed by KDE 3.4:
+ // delete standardAddressBook;
+
- delete standardAddressBook;
//KABC::StdAddressBook::close();
//StdAddressBook::mSelf = 0;
qDebug("ente ");
return 0;
}
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d59f4a4..7319285 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -861,149 +861,159 @@ QString KSyncManager::getPassword( )
{
QString retfile = "";
QDialog dia ( mParent, "input-dialog", true );
QLineEdit lab ( &dia );
lab.setEchoMode( QLineEdit::Password );
QVBoxLayout lay( &dia );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
dia.setFixedSize( 230,50 );
dia.setCaption( i18n("Enter password") );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.show();
int res = dia.exec();
if ( res )
retfile = lab.text();
dia.hide();
qApp->processEvents();
return retfile;
}
void KSyncManager::confSync()
{
static KSyncPrefsDialog* sp = 0;
if ( ! sp ) {
sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
}
sp->usrReadConfig();
#ifndef DESKTOP_VERSION
sp->showMaximized();
#else
sp->show();
#endif
sp->exec();
QStringList oldSyncProfileNames = mSyncProfileNames;
mSyncProfileNames = sp->getSyncProfileNames();
mLocalMachineName = sp->getLocalMachineName ();
int ii;
for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
}
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
}
void KSyncManager::syncKDE()
{
mSyncWithDesktop = true;
emit save();
switch(mTargetApp)
{
case (KAPI):
{
#ifdef DESKTOP_VERSION
QString command = qApp->applicationDirPath () + "/kdeabdump";
#else
QString command = "kdeabdump";
#endif
if ( ! QFile::exists ( command ) )
command = "kdeabdump";
QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
- system ( command.latin1());
+ int result = system ( command.latin1());
+ qDebug("AB dump command call result: %d ", result);
+ if ( result != 0 ) {
+ KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n/opt/kdepimpi/kdeabdump\nexists.The standard version of this file\nis for syncing with KDE 3.4.x.\nIf you are running KDE 3.3.x please\ndownload the KDE 3.3.x version of this file\nat http://sourceforge.net/projects/kdepimpi/\nsection: general files for KDE/Pim."));
+ return;
+ }
if ( syncWithFile( fileName,true ) ) {
if ( mWriteBackFile ) {
command += " --read";
system ( command.latin1());
}
}
}
break;
case (KOPI):
{
#ifdef DESKTOP_VERSION
QString command = qApp->applicationDirPath () + "/kdecaldump";
#else
QString command = "kdecaldump";
#endif
if ( ! QFile::exists ( command ) )
command = "kdecaldump";
QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
- system ( command.latin1());
+ int result = system ( command.latin1());
+ qDebug("Cal dump command call result result: %d ", result);
+ if ( result != 0 ) {
+ KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n/opt/kdepimpi/kdecaldump\nexists.The standard version of this file\nis for syncing with KDE 3.4.x.\nIf you are running KDE 3.3.x please\ndownload the KDE 3.3.x version of this file\nat http://sourceforge.net/projects/kdepimpi/\nsection: general files for KDE/Pim."));
+ return;
+ }
if ( syncWithFile( fileName,true ) ) {
if ( mWriteBackFile ) {
command += " --read";
system ( command.latin1());
}
}
}
break;
case (PWMPI):
break;
default:
qDebug("KSM::slotSyncMenu: invalid apptype selected");
break;
}
}
void KSyncManager::syncSharp()
{
if ( ! syncExternalApplication("sharp") )
qDebug("KSM::ERROR sync sharp ");
}
bool KSyncManager::syncExternalApplication(QString resource)
{
emit save();
if ( mAskForPreferences )
if ( !edit_sync_options()) {
mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
return false;
}
qDebug("KSM::Sync extern %s", resource.latin1());
bool syncOK = mImplementation->syncExternal(this, resource);
return syncOK;
}
void KSyncManager::syncPhone()
{
syncExternalApplication("phone");
}
void KSyncManager::showProgressBar(int percentage, QString caption, int total)
{
if (!bar->isVisible())
{
bar->setCaption (caption);
bar->setTotalSteps ( total ) ;
bar->show();
}
bar->raise();
bar->setProgress( percentage );
qApp->processEvents();
}