summaryrefslogtreecommitdiffabout
path: root/libkdepim/ksyncmanager.cpp
Side-by-side diff
Diffstat (limited to 'libkdepim/ksyncmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/ksyncmanager.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 568c2a9..01309d5 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,30 +1,30 @@
/*
- This file is part of KDE-Pim/Pi.
- Copyright (c) 2004 Ulf Schenk
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ This file is part of KDE-Pim/Pi.
+ Copyright (c) 2004 Ulf Schenk
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
*/
// $Id$
#include "ksyncmanager.h"
#include <stdlib.h>
#ifndef _WIN32_
#include <unistd.h>
#endif
@@ -64,25 +64,25 @@ KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, Targ
int w = 300;
if ( QApplication::desktop()->width() < 320 )
w = 220;
int h = bar->sizeHint().height() ;
int dw = QApplication::desktop()->width();
int dh = QApplication::desktop()->height();
bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
}
KSyncManager::~KSyncManager()
{
- delete bar;
+ delete bar;
}
void KSyncManager::fillSyncMenu()
{
if ( mSyncMenu->count() )
mSyncMenu->clear();
mSyncMenu->insertItem( i18n("Configure..."), 0 );
mSyncMenu->insertSeparator();
if ( mServerSocket == 0 ) {
mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
@@ -156,25 +156,25 @@ void KSyncManager::slotSyncMenu( int action )
enableQuick();
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
if ( action == 3 ) {
delete mServerSocket;
mServerSocket = 0;
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
return;
}
if (blockSave())
- return;
+ return;
setBlockSave(true);
mCurrentSyncProfile = action - 1000 ;
mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
mCurrentSyncName = mLocalMachineName ;
KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
KSyncProfile* temp = new KSyncProfile ();
temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
temp->readConfig(&config);
mAskForPreferences = temp->getAskForPreferences();
mSyncAlgoPrefs = temp->getSyncPrefs();
@@ -291,40 +291,40 @@ void KSyncManager::enableQuick()
return;
}
connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
}
void KSyncManager::syncLocalFile()
{
QString fn =mPrefs->mLastSyncedLocalFile;
QString ext;
- switch(mTargetApp)
- {
+ switch(mTargetApp)
+ {
case (KAPI):
- ext = "(*.vcf)";
- break;
+ ext = "(*.vcf)";
+ break;
case (KOPI):
- ext = "(*.ics/*.vcs)";
- break;
+ ext = "(*.ics/*.vcs)";
+ break;
case (PWMPI):
- ext = "(*.pwm)";
- break;
+ ext = "(*.pwm)";
+ break;
default:
- qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
- break;
+ qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
+ break;
- }
+ }
fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
if ( fn == "" )
return;
if ( syncWithFile( fn, false ) ) {
qDebug("syncLocalFile() successful ");
}
}
bool KSyncManager::syncWithFile( QString fn , bool quick )
{
@@ -381,25 +381,25 @@ void KSyncManager::multiSync( bool askforPrefs )
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 = mPrefs->mRingSyncAlgoPrefs;
if ( askforPrefs ) {
edit_sync_options();
- mRingSyncAlgoPrefs = mSyncAlgoPrefs;
+ mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
}
mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
qApp->processEvents();
int num = ringSync() ;
if ( num > 1 )
ringSync();
setBlockSave(false);
if ( num )
emit save();
if ( num )
mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
else
@@ -511,30 +511,30 @@ int KSyncManager::ringSync()
}
}
delete temp;
return syncedProfiles;
}
void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
{
QString question;
if ( ask ) {
- question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
- if ( QMessageBox::information( mParent, i18n("Sync"),
- question,
- i18n("Yes"), i18n("No"),
- 0, 0 ) != 0 )
- return;
+ question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
+ if ( QMessageBox::information( mParent, i18n("Sync"),
+ question,
+ i18n("Yes"), i18n("No"),
+ 0, 0 ) != 0 )
+ return;
}
QString preCommand;
QString localTempFile;
QString postCommand;
switch(mTargetApp)
{
case (KAPI):
preCommand = prof->getPreSyncCommandAB();
postCommand = prof->getPostSyncCommandAB();
localTempFile = prof->getLocalTempFileAB();
@@ -730,43 +730,43 @@ bool KSyncManager::syncExternalApplication(QString resource)
}
void KSyncManager::syncPhone()
{
syncExternalApplication("phone");
}
void KSyncManager::showProgressBar(int percentage, QString caption, int total)
{
- if (!bar->isVisible())
- {
- bar->setCaption (caption);
- bar->setTotalSteps ( total ) ;
+ if (!bar->isVisible())
+ {
+ bar->setCaption (caption);
+ bar->setTotalSteps ( total ) ;
- bar->show();
- }
+ bar->show();
+ }
- bar->setProgress( percentage );
+ bar->setProgress( percentage );
}
void KSyncManager::hideProgressBar()
{
- bar->hide();
+ bar->hide();
}
bool KSyncManager::isProgressBarCanceled()
{
- return !bar->isVisible();
+ return !bar->isVisible();
}
QString KSyncManager::syncFileName()
{
QString fn = "tempfile";
switch(mTargetApp)
{
case (KAPI):
fn = "tempsyncab.vcf";
break;
case (KOPI):
@@ -798,41 +798,41 @@ void KSyncManager::syncPi()
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
commandSocket->readFile( syncFileName() );
}
void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
{
qDebug("MainWindow::deleteCommandSocket %d", state);
//enum { success, errorW, errorR, quiet };
if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
- mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
+ mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
delete s;
- if ( state == KCommandSocket::errorR ) {
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
- commandSocket->sendStop();
- }
+ if ( state == KCommandSocket::errorR ) {
+ KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
+ connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
+ commandSocket->sendStop();
+ }
return;
} else if ( state == KCommandSocket::errorW ) {
- mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
+ mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
} else if ( state == KCommandSocket::successR ) {
QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
} else if ( state == KCommandSocket::successW ) {
- mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
+ mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
}
delete s;
}
void KSyncManager::readFileFromSocket()
{
QString fileName = syncFileName();
mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
if ( ! syncWithFile( fileName , true ) ) {
mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
qDebug("Syncing failed ");
@@ -1147,28 +1147,28 @@ void KCommandSocket::readFileFromSocket()
mFileString = "";
mRetVal = successR;
mSocket->close();
// if state is not idle, deleteSocket(); is called via
// connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
if ( mSocket->state() == QSocket::Idle )
deleteSocket();
}
void KCommandSocket::deleteSocket()
{
if ( mTimerSocket->isActive () ) {
- mTimerSocket->stop();
- KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
- mRetVal = errorTO;
- if ( mSocket ) {
- mSocket->close();
- if ( mSocket->state() == QSocket::Idle )
- deleteSocket();
- return;
- }
+ mTimerSocket->stop();
+ KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
+ mRetVal = errorTO;
+ if ( mSocket ) {
+ mSocket->close();
+ if ( mSocket->state() == QSocket::Idle )
+ deleteSocket();
+ return;
+ }
}
//qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
if ( mSocket)
delete mSocket;
mSocket = 0;
emit commandFinished( this, mRetVal );
}