summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
authorzautrix <zautrix>2004-10-07 17:51:17 (UTC)
committer zautrix <zautrix>2004-10-07 17:51:17 (UTC)
commit1f1538e5707b59bfcff2014901f29a65589229e3 (patch) (side-by-side diff)
tree0d91a303524e6ac9f7c954f01a0e1d09d0e305e7 /libkdepim/ksyncmanager.cpp
parentbb8293c794d82a57bc93af85ccd89b601356d577 (diff)
downloadkdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.zip
kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.gz
kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.bz2
many cleanups
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp72
1 files changed, 45 insertions, 27 deletions
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 ) {
@@ -192,21 +196,21 @@ void KSyncManager::slotSyncMenu( int action )
} else if ( action >= 1003 ) {
if ( temp->getIsLocalFileSync() ) {
switch(mTargetApp)
{
case (KAPI):
if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNameAB();
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
break;
case (KOPI):
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileName();
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
break;
case (PWMPI):
if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
break;
default:
qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
break;
}
@@ -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" ) );
@@ -449,32 +457,47 @@ int KSyncManager::ringSync()
} else {
if ( temp->getIsLocalFileSync() ) {
switch(mTargetApp)
{
case (KAPI):
if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNameAB();
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
break;
case (KOPI):
if ( syncWithFile( temp->getRemoteFileName( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileName();
+ mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
break;
case (PWMPI):
if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
- mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
+ 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 );
}
-