summaryrefslogtreecommitdiffabout
path: root/libkdepim
Side-by-side diff
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kpimprefs.cpp9
-rw-r--r--libkdepim/kpimprefs.h3
-rw-r--r--libkdepim/ksyncmanager.cpp166
-rw-r--r--libkdepim/ksyncmanager.h3
4 files changed, 103 insertions, 78 deletions
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index 0a2f5f1..c21ebaa 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -35,15 +35,22 @@ $Id$
#include "kpimprefs.h"
KPimPrefs::KPimPrefs( const QString &name ) :
KPrefs( name )
{
- config()->setGroup("General");
+#ifdef _WIN32_
+ QString hdp= locateLocal("data","korganizer")+"\\\\";
+#else
+ QString hdp= locateLocal("data","korganizer")+"/";
+#endif
+ config()->setGroup("SyncOptions");
addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" );
addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" );
+ addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
+ addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
}
KPimPrefs::~KPimPrefs()
{
}
diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h
index fde8093..9346f7d 100644
--- a/libkdepim/kpimprefs.h
+++ b/libkdepim/kpimprefs.h
@@ -54,13 +54,14 @@ class KPimPrefs : public KPrefs
public:
QStringList mCustomCategories;
QString mPassiveSyncPort;
QString mPassiveSyncPw;
-
+ int mRingSyncAlgoPrefs;
+ QString mLastSyncedLocalFile;
protected:
virtual void setCategoryDefaults();
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index fad9a76..568c2a9 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -73,13 +73,13 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ
KSyncManager::~KSyncManager()
{
delete bar;
}
-//LR ok
+
void KSyncManager::fillSyncMenu()
{
if ( mSyncMenu->count() )
mSyncMenu->clear();
mSyncMenu->insertItem( i18n("Configure..."), 0 );
@@ -98,17 +98,20 @@ void KSyncManager::fillSyncMenu()
QStringList prof = config.readListEntry("SyncProfileNames");
mLocalMachineName = config.readEntry("LocalMachineName","undefined");
if ( prof.count() < 2 ) {
prof.clear();
prof << i18n("Sharp_DTM");
prof << i18n("Local_file");
+ prof << i18n("Last_file");
KSyncProfile* temp = new KSyncProfile ();
temp->setName( prof[0] );
temp->writeConfig(&config);
temp->setName( prof[1] );
temp->writeConfig(&config);
+ temp->setName( prof[2] );
+ temp->writeConfig(&config);
config.setGroup("General");
config.writeEntry("SyncProfileNames",prof);
config.writeEntry("ExternSyncProfiles","Sharp_DTM");
config.sync();
delete temp;
}
@@ -123,14 +126,15 @@ void KSyncManager::fillSyncMenu()
QDir app_dir;
//US do not display SharpDTM if app is pwmpi, or no sharpfiles available
if ( mTargetApp == PWMPI) {
mSyncMenu->removeItem( 1000 );
}
else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
- mSyncMenu->setItemEnabled( 1000, false );
+ mSyncMenu->removeItem( 1000 );
}
+ mSyncMenu->removeItem( 1002 );
}
void KSyncManager::slotSyncMenu( int action )
{
//qDebug("syncaction %d ", action);
if ( action == 0 ) {
@@ -188,31 +192,31 @@ void KSyncManager::slotSyncMenu( int action )
} else if ( action == 1002 ) {
quickSyncLocalFile();
} else if ( action >= 1003 ) {
if ( temp->getIsLocalFileSync() ) {
- switch(mTargetApp)
- {
- case (KAPI):
- if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNameAB();
- break;
- case (KOPI):
- if ( syncWithFile( temp->getRemoteFileName( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileName();
- break;
- case (PWMPI):
- if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
- break;
- default:
- qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
- break;
+ switch(mTargetApp)
+ {
+ case (KAPI):
+ if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
+ break;
+ case (KOPI):
+ if ( syncWithFile( temp->getRemoteFileName( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
+ break;
+ case (PWMPI):
+ if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
+ break;
+ default:
+ qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
+ break;
- }
+ }
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
@@ -236,12 +240,13 @@ void KSyncManager::slotSyncMenu( int action )
}
}
delete temp;
setBlockSave(false);
}
+
void KSyncManager::enableQuick()
{
QDialog dia ( 0, "input-dialog", true );
QLineEdit lab ( &dia );
QVBoxLayout lay( &dia );
lab.setText( mPrefs->mPassiveSyncPort );
@@ -282,21 +287,20 @@ void KSyncManager::enableQuick()
if ( !mServerSocket->ok() ) {
KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
delete mServerSocket;
mServerSocket = 0;
return;
}
- //connect( mServerSocket, SIGNAL ( saveFile() ),this, SIGNAL ( save() ) );
connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
}
void KSyncManager::syncLocalFile()
{
- QString fn =mLastSyncedLocalFile;
+ QString fn =mPrefs->mLastSyncedLocalFile;
QString ext;
switch(mTargetApp)
{
case (KAPI):
ext = "(*.vcf)";
@@ -318,12 +322,13 @@ void KSyncManager::syncLocalFile()
return;
if ( syncWithFile( fn, false ) ) {
qDebug("syncLocalFile() successful ");
}
}
+
bool KSyncManager::syncWithFile( QString fn , bool quick )
{
bool ret = false;
QFileInfo info;
info.setFile( fn );
QString mess;
@@ -350,40 +355,42 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
//qDebug("Now sycing ... ");
if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
else
mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
if ( ! quick )
- mLastSyncedLocalFile = fn;
+ mPrefs->mLastSyncedLocalFile = fn;
}
return ret;
}
+
void KSyncManager::quickSyncLocalFile()
{
- if ( syncWithFile( mLastSyncedLocalFile, false ) ) {
+ if ( syncWithFile( mPrefs->mLastSyncedLocalFile, false ) ) {
qDebug("quick syncLocalFile() successful ");
}
}
+
void KSyncManager::multiSync( bool askforPrefs )
{
if (blockSave())
return;
setBlockSave(true);
QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
- if ( QMessageBox::information( mParent, i18n("Sync"),
+ if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
question,
i18n("Yes"), i18n("No"),
0, 0 ) != 0 ) {
setBlockSave(false);
mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
return;
}
mCurrentSyncDevice = i18n("Multiple profiles") ;
- mSyncAlgoPrefs = mRingSyncAlgoPrefs;
+ mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
if ( askforPrefs ) {
edit_sync_options();
mRingSyncAlgoPrefs = mSyncAlgoPrefs;
}
mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
qApp->processEvents();
@@ -391,17 +398,18 @@ void KSyncManager::multiSync( bool askforPrefs )
if ( num > 1 )
ringSync();
setBlockSave(false);
if ( num )
emit save();
if ( num )
- mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
+ mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
else
mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
return;
}
+
int KSyncManager::ringSync()
{
int syncedProfiles = 0;
unsigned int i;
QTime timer;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
@@ -410,32 +418,32 @@ int KSyncManager::ringSync()
mAskForPreferences = false;
for ( i = 0; i < syncProfileNames.count(); ++i ) {
mCurrentSyncProfile = i;
temp->setName(syncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
- QString includeInRingSync;
- switch(mTargetApp)
- {
- case (KAPI):
- includeInRingSync = temp->getIncludeInRingSyncAB();
- break;
- case (KOPI):
- includeInRingSync = temp->getIncludeInRingSync();
- break;
- case (PWMPI):
- includeInRingSync = temp->getIncludeInRingSyncPWM();
- break;
- default:
- qDebug("KSyncManager::ringSync: invalid apptype selected");
- break;
+ QString includeInRingSync;
+ switch(mTargetApp)
+ {
+ case (KAPI):
+ includeInRingSync = temp->getIncludeInRingSyncAB();
+ break;
+ case (KOPI):
+ includeInRingSync = temp->getIncludeInRingSync();
+ break;
+ case (PWMPI):
+ includeInRingSync = temp->getIncludeInRingSyncPWM();
+ break;
+ default:
+ qDebug("KSyncManager::ringSync: invalid apptype selected");
+ break;
- }
+ }
- if ( includeInRingSync && ( i < 1 || i > 2 )) {
+ if ( includeInRingSync && ( i < 1 || i > 2 )) {
mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
++syncedProfiles;
// mAskForPreferences = temp->getAskForPreferences();
mWriteBackFile = temp->getWriteBackFile();
mWriteBackExistingOnly = temp->getWriteBackExisting();
mWriteBackInFuture = 0;
@@ -445,36 +453,51 @@ int KSyncManager::ringSync()
mCurrentSyncDevice = syncProfileNames[i] ;
mCurrentSyncName = mLocalMachineName;
if ( i == 0 ) {
syncSharp();
} else {
if ( temp->getIsLocalFileSync() ) {
- switch(mTargetApp)
- {
- case (KAPI):
- if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNameAB();
- break;
- case (KOPI):
- if ( syncWithFile( temp->getRemoteFileName( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileName();
- break;
- case (PWMPI):
- if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
- break;
- default:
- qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
- break;
- }
+ switch(mTargetApp)
+ {
+ case (KAPI):
+ if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
+ break;
+ case (KOPI):
+ if ( syncWithFile( temp->getRemoteFileName( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
+ break;
+ case (PWMPI):
+ if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
+ break;
+ default:
+ qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
+ break;
+ }
} else {
if ( temp->getIsPhoneSync() ) {
mPhoneDevice = temp->getPhoneDevice( ) ;
mPhoneConnection = temp->getPhoneConnection( );
mPhoneModel = temp->getPhoneModel( );
syncPhone();
+ } else if ( temp->getIsPiSync() ) {
+ if ( mTargetApp == KAPI ) {
+ mPassWordPiSync = temp->getRemotePwAB();
+ mActiveSyncPort = temp->getRemotePortAB();
+ mActiveSyncIP = temp->getRemoteIPAB();
+ } else if ( mTargetApp == KOPI ) {
+ mPassWordPiSync = temp->getRemotePw();
+ mActiveSyncPort = temp->getRemotePort();
+ mActiveSyncIP = temp->getRemoteIP();
+ } else {
+ mPassWordPiSync = temp->getRemotePwPWM();
+ mActiveSyncPort = temp->getRemotePortPWM();
+ mActiveSyncIP = temp->getRemoteIPPWM();
+ }
+ syncPi();
} else
syncRemote( temp, false );
}
}
timer.start();
@@ -555,25 +578,20 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
len += maxlen +2;
}
question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (preCommand) ;
QMessageBox::information( mParent, i18n("Sync - ERROR"),
question,
i18n("Okay!")) ;
- mParent->topLevelWidget()->setCaption ("");
+ mParent->topLevelWidget()->setCaption ("KDE-Pim");
return;
}
mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
//qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
-
-
if ( syncWithFile( localTempFile, true ) ) {
-// Event* e = mView->getLastSyncEvent();
-// e->setReadOnly( false );
-// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
-// e->setReadOnly( true );
+
if ( mWriteBackFile ) {
int fi;
if ( (fi = postCommand.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
@@ -641,12 +659,13 @@ void KSyncManager::edit_sync_options()
if ( dia.exec() ) {
mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
}
}
+
QString KSyncManager::getPassword( )
{
QString retfile = "";
QDialog dia ( mParent, "input-dialog", true );
QLineEdit lab ( &dia );
lab.setEchoMode( QLineEdit::Password );
@@ -682,17 +701,18 @@ void KSyncManager::confSync()
#else
sp->show();
#endif
sp->exec();
mSyncProfileNames = sp->getSyncProfileNames();
mLocalMachineName = sp->getLocalMachineName ();
- fillSyncMenu();
+ QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
}
void KSyncManager::syncSharp()
{
+
if ( ! syncExternalApplication("sharp") )
qDebug("ERROR sync sharp ");;
}
bool KSyncManager::syncExternalApplication(QString resource)
{
@@ -709,16 +729,14 @@ bool KSyncManager::syncExternalApplication(QString resource)
return syncOK;
}
void KSyncManager::syncPhone()
{
- emit save();
- qDebug("pending syncPhone(); ");
- //mView->syncPhone();
+ syncExternalApplication("phone");
}
void KSyncManager::showProgressBar(int percentage, QString caption, int total)
{
if (!bar->isVisible())
@@ -764,12 +782,13 @@ QString KSyncManager::syncFileName()
return locateLocal( "tmp", fn );
#else
return (QString( "/tmp/" )+ fn );
#endif
}
+
void KSyncManager::syncPi()
{
qApp->processEvents();
bool ok;
Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
if ( ! ok ) {
@@ -1150,7 +1169,6 @@ void KCommandSocket::deleteSocket()
//qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
if ( mSocket)
delete mSocket;
mSocket = 0;
emit commandFinished( this, mRetVal );
}
-
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 25892d8..7027894 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -114,12 +114,13 @@ class KSyncManager : public QObject
PWMPI = 2 };
KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
~KSyncManager() ;
+ void multiSync( bool askforPrefs );
bool blockSave() { return mBlockSaveFlag; }
void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
void setDefaultFileName( QString s) { mDefFileName = s ;}
QString defaultFileName() { return mDefFileName ;}
QString syncFileName();
void fillSyncMenu();
@@ -144,13 +145,12 @@ class KSyncManager : public QObject
int mRingSyncAlgoPrefs;
bool mWriteBackFile;
int mWriteBackInFuture;
QString mPhoneDevice;
QString mPhoneConnection;
QString mPhoneModel;
- QString mLastSyncedLocalFile; // save!
QString mPassWordPiSync;
QString mActiveSyncPort;
QString mActiveSyncIP ;
signals:
void save();
@@ -175,13 +175,12 @@ class KSyncManager : public QObject
void quickSyncLocalFile();
bool syncWithFile( QString fn , bool quick );
void syncLocalFile();
void syncPhone();
void syncSharp();
bool syncExternalApplication(QString);
- void multiSync( bool askforPrefs );
int mCurrentSyncProfile ;
void syncRemote( KSyncProfile* prof, bool ask = true);
void edit_sync_options();
int ringSync();
QString getPassword( );