summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp1
-rw-r--r--korganizer/calendarview.cpp136
-rw-r--r--korganizer/calendarview.h11
-rw-r--r--korganizer/koprefs.cpp3
-rw-r--r--korganizer/koprefs.h20
-rw-r--r--korganizer/mainwindow.cpp556
-rw-r--r--korganizer/mainwindow.h24
-rw-r--r--libkdepim/kpimprefs.cpp9
-rw-r--r--libkdepim/kpimprefs.h3
-rw-r--r--libkdepim/ksyncmanager.cpp166
-rw-r--r--libkdepim/ksyncmanager.h3
11 files changed, 186 insertions, 746 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 12502b0..c5406bf 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -2884,4 +2884,3 @@ void KABCore::setCaptionBack()
{
topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
}
-
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index ea9607d..b56f1f9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -700,19 +700,7 @@ void CalendarView::createPrinter()
void CalendarView::confSync()
{
- static KSyncPrefsDialog* sp = 0;
- if ( ! sp ) {
- sp = new KSyncPrefsDialog( this, "syncprefs", true );
- }
- sp->usrReadConfig();
-#ifndef DESKTOP_VERSION
- sp->showMaximized();
-#else
- sp->show();
-#endif
- sp->exec();
- KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
- KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
+ //DELETE
}
@@ -877,7 +865,7 @@ Event* CalendarView::getLastSyncEvent()
lse = new Event();
lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
QString sum = "";
- if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
+ if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
sum = "E: ";
lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
lse->setDtStart( mLastCalendarSync );
@@ -1119,7 +1107,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
local->deleteIncidence( inL );
++deletedEventL;
} else {
- if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
+ if ( ! mSyncManager->mWriteBackExistingOnly ) {
inL->removeID(mCurrentSyncDevice );
++addedEventR;
//qDebug("remote added Incidence %s ", inL->summary().latin1());
@@ -1135,7 +1123,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
local->deleteIncidence( inL );
++deletedEventL;
} else {
- if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
+ if ( ! mSyncManager->mWriteBackExistingOnly ) {
++addedEventR;
inL->setLastModified( modifiedCalendar );
remote->addIncidence( inL->clone() );
@@ -1147,12 +1135,12 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
inL = el.next();
}
int delFut = 0;
- if ( KOPrefs::instance()->mWriteBackInFuture ) {
+ if ( mSyncManager->mWriteBackInFuture ) {
er = remote->rawIncidences();
inR = er.first();
QDateTime dt;
QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
- QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 );
+ QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
while ( inR ) {
if ( inR->type() == "Todo" ) {
Todo * t = (Todo*)inR;
@@ -1192,10 +1180,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
QString delmess;
if ( delFut ) {
- delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
+ delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture );
mes += delmess;
}
- if ( KOPrefs::instance()->mShowSyncSummary ) {
+ if ( mSyncManager->mShowSyncSummary ) {
KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
}
qDebug( mes );
@@ -1225,7 +1213,7 @@ bool CalendarView::syncCalendar(QString filename, int mode)
syncOK = synchronizeCalendar( mCalendar, calendar, mode );
getEventViewerDialog()->setSyncMode( false );
if ( syncOK ) {
- if ( KOPrefs::instance()->mWriteBackFile )
+ if ( mSyncManager->mWriteBackFile )
{
storage->setSaveFormat( new ICalFormat() );
storage->save();
@@ -1241,14 +1229,12 @@ bool CalendarView::syncCalendar(QString filename, int mode)
}
void CalendarView::syncPhone()
{
- syncExternal( 1 );
+ //DELETE
}
void CalendarView::syncExternal( int mode )
{
mGlobalSyncMode = SYNC_MODE_EXTERNAL;
- //mCurrentSyncDevice = "sharp-DTM";
- if ( KOPrefs::instance()->mAskForPreferences )
- edit_sync_options();
+
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
@@ -1265,20 +1251,20 @@ void CalendarView::syncExternal( int mode )
#endif
if ( mode == 1 ) { // phone
phoneFormat = new PhoneFormat (mCurrentSyncDevice,
- KOPrefs::instance()->mPhoneDevice,
- KOPrefs::instance()->mPhoneConnection,
- KOPrefs::instance()->mPhoneModel);
+ mSyncManager->mPhoneDevice,
+ mSyncManager->mPhoneConnection,
+ mSyncManager->mPhoneModel);
loadSuccess = phoneFormat->load( calendar,mCalendar);
} else
return;
if ( loadSuccess ) {
getEventViewerDialog()->setSyncMode( true );
- syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
+ syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
qApp->processEvents();
if ( syncOK ) {
- if ( KOPrefs::instance()->mWriteBackFile )
+ if ( mSyncManager->mWriteBackFile )
{
QPtrList<Incidence> iL = mCalendar->rawIncidences();
Incidence* inc = iL.first();
@@ -1329,7 +1315,7 @@ void CalendarView::syncExternal( int mode )
}
void CalendarView::syncSharp()
{
- syncExternal( 0 );
+ //DELETE
}
@@ -1517,7 +1503,7 @@ bool CalendarView::importQtopia( const QString &categories,
#if 0
mGlobalSyncMode = SYNC_MODE_QTOPIA;
mCurrentSyncDevice = "qtopia-XML";
- if ( KOPrefs::instance()->mAskForPreferences )
+ if ( mSyncManager->mAskForPreferences )
edit_sync_options();
qApp->processEvents();
CalendarLocal* calendar = new CalendarLocal();
@@ -1535,11 +1521,11 @@ bool CalendarView::importQtopia( const QString &categories,
if ( loadOk ) {
getEventViewerDialog()->setSyncMode( true );
- syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
+ syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
getEventViewerDialog()->setSyncMode( false );
qApp->processEvents();
if ( syncOK ) {
- if ( KOPrefs::instance()->mWriteBackFile )
+ if ( mSyncManager->mWriteBackFile )
{
// write back XML file
@@ -1683,11 +1669,11 @@ bool CalendarView::checkFileVersion(QString fn)
return true;
setSyncDevice("deleteaftersync" );
- KOPrefs::instance()->mAskForPreferences = true;
- KOPrefs::instance()->mSyncAlgoPrefs = 3;
- KOPrefs::instance()->mWriteBackFile = false;
- KOPrefs::instance()->mWriteBackExistingOnly = false;
- KOPrefs::instance()->mShowSyncSummary = false;
+ mSyncManager->mAskForPreferences = true;
+ mSyncManager->mSyncAlgoPrefs = 3;
+ mSyncManager->mWriteBackFile = false;
+ mSyncManager->mWriteBackExistingOnly = false;
+ mSyncManager->mShowSyncSummary = false;
syncCalendar( fn, 3 );
Event * e = getLastSyncEvent();
mCalendar->deleteEvent ( e );
@@ -2198,53 +2184,7 @@ void CalendarView::edit_options()
}
void CalendarView::edit_sync_options()
{
- //mDialogManager->showSyncOptions();
- //KOPrefs::instance()->mSyncAlgoPrefs
- QDialog dia( this, "dia", true );
- dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
- QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
- QVBoxLayout lay ( &dia );
- lay.setSpacing( 2 );
- lay.setMargin( 3 );
- lay.addWidget(&gr);
- QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
- QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
- QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
- QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
- QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
- QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
- //QRadioButton both( i18n("Take both on conflict"), &gr );
- QPushButton pb ( "OK", &dia);
- lay.addWidget( &pb );
- connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
- switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
- case 0:
- loc.setChecked( true);
- break;
- case 1:
- rem.setChecked( true );
- break;
- case 2:
- newest.setChecked( true);
- break;
- case 3:
- ask.setChecked( true);
- break;
- case 4:
- f_loc.setChecked( true);
- break;
- case 5:
- f_rem.setChecked( true);
- break;
- case 6:
- // both.setChecked( true);
- break;
- default:
- break;
- }
- if ( dia.exec() ) {
- KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
- }
+ // DELETE
}
@@ -3768,6 +3708,26 @@ void CalendarView::keyPressEvent ( QKeyEvent *e)
e->ignore();
}
-//#include "calendarview.moc"
-//#include "calendarviewbase.moc"
+bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
+{
+ // mSyncManager = manager;
+ mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
+ mCurrentSyncName = mSyncManager->getCurrentSyncName();
+ return syncCalendar( filename, mode );
+}
+bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
+{
+ //mSyncManager = manager;
+ mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
+ mCurrentSyncName = mSyncManager->getCurrentSyncName();
+ if ( resource == "sharp" )
+ syncExternal( 0 );
+ if ( resource == "phone" )
+ syncExternal( 1 );
+ // pending setmodified
+}
+void CalendarView::setSyncManager(KSyncManager* manager)
+{
+ mSyncManager = manager;
+}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 8d329a9..751b8d9 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -42,6 +42,8 @@
#include <korganizer/calendarviewbase.h>
+#include <ksyncmanager.h>
+
class QWidgetStack;
class QSplitter;
@@ -77,7 +79,7 @@ using namespace KCal;
@short main calendar view widget
@author Cornelius Schumacher
*/
-class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
+class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
{
Q_OBJECT
public:
@@ -460,8 +462,12 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
public:
// show a standard warning
// returns KMsgBox::yesNoCancel()
- int msgCalModified();
+ int msgCalModified();
+ virtual bool sync(KSyncManager* manager, QString filename, int mode);
+
+ virtual bool syncExternal(KSyncManager* manager, QString resource);
void confSync();
+ void setSyncManager(KSyncManager* manager);
void setLoadedFileVersion(QDateTime);
bool checkFileVersion(QString fn);
bool checkFileChanged(QString fn);
@@ -484,6 +490,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
Todo *selectedTodo();
private:
+ KSyncManager* mSyncManager;
AlarmDialog * mAlarmDialog;
QString mAlarmNotification;
QString mSuspendAlarmNotification;
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 1210094..13035e0 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -196,8 +196,6 @@ KOPrefs::KOPrefs() :
addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
addItemInt("LastSyncTime",&mLastSyncTime,0);
- addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
- addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
#ifdef _WIN32_
QString hdp= locateLocal("data","korganizer")+"\\\\";
@@ -217,7 +215,6 @@ KOPrefs::KOPrefs() :
addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
- addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
KPrefs::setCurrentGroup("Locale");
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index ff09e19..03df59b 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -194,29 +194,10 @@ class KOPrefs : public KPimPrefs
bool mAskForQuit;
bool mUsePassWd;
- bool mWriteBackFile;
- int mWriteBackInFuture;
- bool mAskForPreferences;
- bool mShowSyncSummary;
bool mShowSyncEvents;
bool mShowTodoInAgenda;
- bool mWriteBackExistingOnly;
-
- QString mRemoteIP;
- QString mRemoteUser;
- QString mRemotePassWd;
- QString mRemoteFile;
- QString mLocalTempFile;
- QString mPhoneDevice;
- QString mPhoneConnection;
- QString mPhoneModel;
int mLastSyncTime;
- int mSyncAlgoPrefs;
- int mRingSyncAlgoPrefs;
- QStringList mSyncProfileNames;
- QStringList mExternSyncProfiles;
- QString mLocalMachineName;
void setCategoryColor(QString cat,const QColor & color);
QColor *categoryColor(QString cat);
@@ -230,7 +211,6 @@ class KOPrefs : public KPimPrefs
QString mLastVcalFile;
QString mLastSaveFile;
QString mLastLoadFile;
- QString mLastSyncedLocalFile;
QString mDefaultAlarmFile;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index e3324ee..f7766f8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -126,7 +126,7 @@ int globalFlagBlockStartup;
MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QMainWindow( parent, name )
{
- mPassWordPiSync = "abc";
+
#ifdef DESKTOP_VERSION
setFont( QFont("Arial"), 14 );
#endif
@@ -142,10 +142,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
setCaption("KOrganizer/Pi");
KOPrefs *p = KOPrefs::instance();
KPimGlobalPrefs::instance()->setGlobalConfig();
- // if ( QApplication::desktop()->height() > 480 ) {
-// if ( p->mHourSize == 4 )
-// p->mHourSize = 6;
-// }
if ( p->mHourSize > 18 )
p->mHourSize = 18;
QMainWindow::ToolBarDock tbd;
@@ -166,7 +162,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
globalFlagBlockStartup = 1;
iconToolBar = new QPEToolBar( this );
addToolBar (iconToolBar , tbd );
- mBlockSaveFlag = false;
mCalendarModifiedFlag = false;
QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
@@ -181,7 +176,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
mView = new CalendarView( mCalendar, this,"mCalendar " );
mView->hide();
//mView->resize(splash->size() );
- initActions();
+ initActions();
+ mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
+ mSyncManager->setBlockSave(false);
+ mView->setSyncManager(mSyncManager);
#ifndef DESKTOP_VERSION
iconToolBar->show();
qApp->processEvents();
@@ -252,7 +250,17 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
mView->updateConfig();
// qApp->processEvents();
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
- fillSyncMenu();
+ //fillSyncMenu();
+
+
+ connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
+ connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
+ connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
+ mSyncManager->setDefaultFileName( defaultFileName());
+ mSyncManager->fillSyncMenu();
+
+
+
mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
if ( showWarning ) {
KMessageBox::information( this,
@@ -395,7 +403,7 @@ void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
mView->viewManager()->showWorkWeekView();
}
else if ( msg == "-ringSync" ) {
- multiSync( false );
+ mSyncManager->multiSync( false );
}
else if ( msg == "-showWeek" ) {
mView->viewManager()->showWeekView();
@@ -940,234 +948,7 @@ void MainWindow::initActions()
configureAgenda( p->mHourSize );
connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
}
-void MainWindow::fillSyncMenu()
-{
- if ( syncMenu->count() )
- syncMenu->clear();
- syncMenu->insertItem( i18n("Configure..."), 0 );
- syncMenu->insertSeparator();
- if ( mServerSocket == 0 ) {
- syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
- } else {
- syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
- }
- syncMenu->insertSeparator();
- syncMenu->insertItem( i18n("Multiple sync"), 1 );
- syncMenu->insertSeparator();
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- config.setGroup("General");
- QStringList prof = config.readListEntry("SyncProfileNames");
- KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
- if ( prof.count() < 3 ) {
- 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;
- }
- KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
- KOPrefs::instance()->mSyncProfileNames = prof;
- int i;
- for ( i = 0; i < prof.count(); ++i ) {
-
- syncMenu->insertItem( prof[i], 1000+i );
- if ( i == 2 )
- syncMenu->insertSeparator();
- }
- QDir app_dir;
- if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
- syncMenu->setItemEnabled( false , 1000 );
- }
-}
-
-int MainWindow::ringSync()
-{
- int syncedProfiles = 0;
- int i;
- QTime timer;
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
- KSyncProfile* temp = new KSyncProfile ();
- KOPrefs::instance()->mAskForPreferences = false;
- for ( i = 0; i < syncProfileNames.count(); ++i ) {
- mCurrentSyncProfile = i;
- temp->setName(syncProfileNames[mCurrentSyncProfile]);
- temp->readConfig(&config);
- if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
- setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
- ++syncedProfiles;
- // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KOPrefs::instance()->mWriteBackInFuture = 0;
- if ( temp->getWriteBackFuture() )
- KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KOPrefs::instance()->mShowSyncSummary = false;
- mView->setSyncDevice(syncProfileNames[i] );
- mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
- if ( i == 0 ) {
- syncSharp();
- } else {
- if ( temp->getIsLocalFileSync() ) {
- if ( syncWithFile( temp->getRemoteFileName( ), true ) )
- KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
- } else {
- if ( temp->getIsPhoneSync() ) {
- KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
- KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
- KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
- syncPhone();
- } else if ( temp->getIsPiSync() ) {
- mPassWordPiSync = temp->getRemotePw();
- KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
- KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
- syncPi();
- } else
- syncRemote( temp, false );
-
- }
- }
- timer.start();
- setCaption(i18n("Multiple sync in progress ... please wait!") );
- while ( timer.elapsed () < 2000 ) {
- qApp->processEvents();
-#ifndef _WIN32_
- sleep (1);
-#endif
- }
-
- }
-
- }
- delete temp;
- return syncedProfiles;
-}
-
-void MainWindow::multiSync( bool askforPrefs )
-{
- if (mBlockSaveFlag)
- return;
- mBlockSaveFlag = 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( this, i18n("KO/Pi Sync"),
- question,
- i18n("Yes"), i18n("No"),
- 0, 0 ) != 0 ) {
- mBlockSaveFlag = false;
- setCaption(i18n("Aborted! Nothing synced!"));
- return;
- }
- mView->setSyncDevice(i18n("Multiple profiles") );
- KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
- if ( askforPrefs ) {
- mView->edit_sync_options();
- KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
- }
- setCaption(i18n("Multiple sync started.") );
- qApp->processEvents();
- int num = ringSync() ;
- if ( num > 1 )
- ringSync();
- mBlockSaveFlag = false;
- if ( num )
- save();
- if ( num )
- setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
- else
- setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
- return;
-}
-void MainWindow::slotSyncMenu( int action )
-{
- qDebug("syncaction %d ", action);
- if ( action == 0 ) {
-
- // seems to be a Qt2 event handling bug
- // syncmenu.clear causes a segfault at first time
- // when we call it after the main event loop, it is ok
- // same behaviour when calling OM/Pi via QCOP for the first time
- QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
- //confSync();
- return;
- }
- if ( action == 1 ) {
- multiSync( true );
- return;
- }
- if ( action == 2 ) {
- enableQuick();
- QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
- return;
- }
- if ( action == 3 ) {
- delete mServerSocket;
- mServerSocket = 0;
- QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
- return;
- }
-
- if (mBlockSaveFlag)
- return;
- mBlockSaveFlag = true;
- mCurrentSyncProfile = action - 1000 ;
- mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
- mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
- KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
- KSyncProfile* temp = new KSyncProfile ();
- temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
- temp->readConfig(&config);
- KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
- KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
- KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
- KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
- KOPrefs::instance()->mWriteBackInFuture = 0;
- if ( temp->getWriteBackFuture() )
- KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
- KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
- if ( action == 1000 ) {
- syncSharp();
-
- } else if ( action == 1001 ) {
- syncLocalFile();
-
- } else if ( action == 1002 ) {
- quickSyncLocalFile();
-
- } else if ( action >= 1003 ) {
- if ( temp->getIsLocalFileSync() ) {
- if ( syncWithFile( temp->getRemoteFileName( ), false ) )
- KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
- } else {
- if ( temp->getIsPhoneSync() ) {
- KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
- KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
- KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
- syncPhone();
- } else if ( temp->getIsPiSync() ) {
- mPassWordPiSync = temp->getRemotePw();
- KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
- KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
- syncPi();
- } else
- syncRemote( temp );
-
- }
- }
- delete temp;
- mBlockSaveFlag = false;
-}
void MainWindow::exportToPhone( int mode )
{
@@ -1584,7 +1365,7 @@ void MainWindow::slotModifiedChanged( bool changed )
int msec;
// we store the changes after 1 minute,
// and for safety reasons after 10 minutes again
- if ( !mBlockSaveFlag )
+ if ( !mSyncManager->blockSave() )
msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
else
msec = 1000 * 600;
@@ -1594,10 +1375,9 @@ void MainWindow::slotModifiedChanged( bool changed )
}
void MainWindow::save()
{
- if ( mBlockSaveFlag )
+ if ( mSyncManager->blockSave() )
return;
- bool store = mBlockSaveFlag;
- mBlockSaveFlag = true;
+ mSyncManager->setBlockSave(true);
if ( mView->checkFileVersion( defaultFileName()) ) {
QTime neededSaveTime = QDateTime::currentDateTime().time();
@@ -1615,7 +1395,7 @@ void MainWindow::save()
} else
setCaption(i18n("Saving cancelled!"));
mCalendarModifiedFlag = false;
- mBlockSaveFlag = store;
+ mSyncManager->setBlockSave( false );
}
void MainWindow::keyReleaseEvent ( QKeyEvent * e)
@@ -2029,80 +1809,11 @@ void MainWindow::exportVCalendar()
}
}
-QString MainWindow::getPassword( )
-{
- QString retfile = "";
- QDialog dia ( this, "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 MainWindow::enableQuick()
+void MainWindow::syncFileRequest()
{
- QDialog dia ( this, "input-dialog", true );
- QLineEdit lab ( &dia );
- QVBoxLayout lay( &dia );
- lab.setText( KOPrefs::instance()->mPassiveSyncPort );
- lay.setMargin(7);
- lay.setSpacing(7);
- QLabel label ( i18n("Port number (Default: 9197)"), &dia );
- lay.addWidget( &label);
- lay.addWidget( &lab);
-
- QLineEdit lepw ( &dia );
- lepw.setText( KOPrefs::instance()->mPassiveSyncPw );
- QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
- lay.addWidget( &label2);
- lay.addWidget( &lepw);
- dia.setFixedSize( 230,80 );
- dia.setCaption( i18n("Enter port for Pi-Sync") );
- QPushButton pb ( "OK", &dia);
- lay.addWidget( &pb );
- connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
- dia.show();
- if ( ! dia.exec() )
- return;
- dia.hide();
- qApp->processEvents();
- KOPrefs::instance()->mPassiveSyncPw = lepw.text();
- KOPrefs::instance()->mPassiveSyncPort = lab.text();
- bool ok;
- Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok);
- if ( ! ok ) {
- KMessageBox::information( this, i18n("No valid port"));
- return;
- }
- //qDebug("port %d ", port);
- mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 );
- mServerSocket->setFileName( defaultFileName() );
- //qDebug("connected ");
- if ( !mServerSocket->ok() ) {
- KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!"));
- delete mServerSocket;
- mServerSocket = 0;
- return;
- }
- connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
- connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
+ save();
}
-
void MainWindow::getFile( bool success )
{
if ( ! success ) {
@@ -2115,227 +1826,6 @@ void MainWindow::getFile( bool success )
}
-
-void MainWindow::syncPi()
-{
- qApp->processEvents();
- bool ok;
- Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
- if ( ! ok ) {
- setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
- return;
- }
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
- setCaption( i18n("Sending request for remote file ...") );
- commandSocket->readFile( syncFileName() );
-}
-
-void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
-{
- qDebug("MainWindow::deleteCommandSocket %d", state);
-
- //enum { success, errorW, errorR, quiet };
- if ( state == KCommandSocket::errorR ) {
- setCaption( i18n("ERROR: Receiving remote file failed.") );
- delete s;
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
- commandSocket->sendStop();
- return;
-
- } else if ( state == KCommandSocket::errorW ) {
- setCaption( i18n("ERROR:Writing back file failed.") );
-
- } else if ( state == KCommandSocket::successR ) {
- QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
-
- } else if ( state == KCommandSocket::successW ) {
- setCaption( i18n("Pi-Sync succesful!") );
- }
-
- delete s;
-}
-
-void MainWindow::readFileFromSocket()
-{
- QString fileName = syncFileName();
- setCaption( i18n("Remote file saved to temp file.") );
- if ( ! syncWithFile( fileName , true ) ) {
- setCaption( i18n("Syncing failed.") );
- qDebug("Syncing failed ");
- return;
- }
- KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
- connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
- if ( KOPrefs::instance()->mWriteBackFile )
- commandSocket->writeFile( fileName );
- else {
- commandSocket->sendStop();
- setCaption( i18n("Pi-Sync succesful!") );
- }
-}
-
-void MainWindow::syncLocalFile()
-{
-
- QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
-
- fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
- if ( fn == "" )
- return;
- //mView->setSyncDevice("local-file" );
- if ( syncWithFile( fn, false ) ) {
- // Event* e = mView->getLastSyncEvent();
-// e->setReadOnly( false );
-// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
-// e->setReadOnly( true );
- }
-
-}
-
-bool MainWindow::syncWithFile( QString fn , bool quick )
-{
- bool ret = false;
- QFileInfo info;
- info.setFile( fn );
- QString mess;
- bool loadbup = true;
- if ( !info. exists() ) {
- mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
- int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
- mess );
- return ret;
- }
- int result = 0;
- if ( !quick ) {
- mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
- result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
- mess,
- i18n("Sync"), i18n("Cancel"), 0,
- 0, 1 );
- if ( result )
- return false;
- }
- if ( KOPrefs::instance()->mAskForPreferences )
- mView->edit_sync_options();
- if ( result == 0 ) {
- //qDebug("Now sycing ... ");
- if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
- setCaption( i18n("Synchronization successful") );
- else
- setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
- if ( ! quick )
- KOPrefs::instance()->mLastSyncedLocalFile = fn;
- slotModifiedChanged( true );
- }
- return ret;
-}
-void MainWindow::quickSyncLocalFile()
-{
- //mView->setSyncDevice("local-file" );
- //qDebug("quickSyncLocalFile() ");
- if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
- // Event* e = mView->getLastSyncEvent();
-// e->setReadOnly( false );
-// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
-// e->setReadOnly( true );
-
- }
-}
-
-void MainWindow::confSync()
-{
- mView->confSync();
- fillSyncMenu();
-}
-void MainWindow::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( this, i18n("KO/Pi Sync"),
- question,
- i18n("Yes"), i18n("No"),
- 0, 0 ) != 0 )
- return;
- }
- QString command = prof->getPreSyncCommand();
- int fi;
- if ( (fi = command.find("$PWD$")) > 0 ) {
- QString pwd = getPassword();
- command = command.left( fi )+ pwd + command.mid( fi+5 );
-
- }
- int maxlen = 30;
- if ( QApplication::desktop()->width() > 320 )
- maxlen += 25;
- setCaption ( i18n( "Copy remote file to local machine..." ) );
- int fileSize = 0;
- int result = system ( command );
- // 0 : okay
- // 256: no such file or dir
- //
- qDebug("KO: Remote copy result(0 = okay): %d ",result );
- if ( result != 0 ) {
- int len = maxlen;
- while ( len < command.length() ) {
- command.insert( len , "\n" );
- 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 (command) ;
- QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
- question,
- i18n("Okay!")) ;
- setCaption ("KO/Pi");
- return;
- }
- setCaption ( i18n( "Copying succeed." ) );
- //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
- if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
-// Event* e = mView->getLastSyncEvent();
-// e->setReadOnly( false );
-// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
-// e->setReadOnly( true );
- if ( KOPrefs::instance()->mWriteBackFile ) {
- command = prof->getPostSyncCommand();
- int fi;
- if ( (fi = command.find("$PWD$")) > 0 ) {
- QString pwd = getPassword();
- command = command.left( fi )+ pwd + command.mid( fi+5 );
-
- }
- setCaption ( i18n( "Writing back file ..." ) );
- result = system ( command );
- qDebug("KO: Writing back file result: %d ", result);
- if ( result != 0 ) {
- setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
- return;
- } else {
- setCaption ( i18n( "Syncronization sucessfully completed" ) );
- }
- }
- }
- return;
-}
-
-void MainWindow::syncSharp()
-{
- if ( mCalendarModifiedFlag )
- save();
- mView->syncSharp();
- slotModifiedChanged( true );
-
-}
-void MainWindow::syncPhone()
-{
- if ( mCalendarModifiedFlag )
- save();
- mView->syncPhone();
- slotModifiedChanged( true );
-
-}
-
void MainWindow::printSel( )
{
mView->viewManager()->agendaView()->agenda()->printSelection();
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 0da0be0..ee7bd87 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -44,8 +44,6 @@ class MainWindow : public QMainWindow
static QString resourcePath();
protected slots:
void setCaptionToDates();
- int ringSync();
- void multiSync( bool askforPrefs = false );
void about();
void licence();
void faq();
@@ -79,15 +77,6 @@ class MainWindow : public QMainWindow
void selectFilter( int );
void exportToPhone( int );
- void slotSyncMenu( int );
- void confSync();
- void syncSharp();
- void syncPhone();
- void syncPi();
- void syncLocalFile();
- bool syncWithFile( QString, bool );
- void quickSyncLocalFile();
-
protected:
void displayText( QString, QString);
@@ -99,19 +88,14 @@ class MainWindow : public QMainWindow
QSocket* piSocket;
QString piFileString;
QTime piTime;
- void deleteCommandSocket(KCommandSocket* s, int state );
- void fillSyncMenu();
void getFile( bool );
- void readFileFromSocket();
+ void syncFileRequest();
private:
+ KSyncManager* mSyncManager;
//QTimer* mTimerCommandSocket;
- QString mPassWordPiSync;
KServerSocket * mServerSocket;
bool mClosed;
void saveOnClose();
- int mCurrentSyncProfile;
- void enableQuick();
- void syncRemote( KSyncProfile* , bool ask = true);
bool mFlagKeyPressed;
bool mBlockAtStartup;
QPEToolBar *iconToolBar;
@@ -124,7 +108,6 @@ class MainWindow : public QMainWindow
QPopupMenu *configureAgendaMenu, *syncMenu;
CalendarLocal *mCalendar;
CalendarView *mView;
- QString getPassword();
QAction *mNewSubTodoAction;
QAction *mShowAction;
@@ -135,11 +118,10 @@ class MainWindow : public QMainWindow
QAction *mBeamAction;
QAction *mCancelAction;
-
void closeEvent( QCloseEvent* ce );
SimpleAlarmClient mAlarmClient;
QTimer mSaveTimer;
- bool mBlockSaveFlag;
+ //bool mBlockSaveFlag;
bool mCalendarModifiedFlag;
QPixmap loadPixmap( QString );
};
diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp
index 0a2f5f1..c21ebaa 100644
--- a/libkdepim/kpimprefs.cpp
+++ b/libkdepim/kpimprefs.cpp
@@ -38,9 +38,16 @@ $Id$
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
@@ -57,7 +57,8 @@ class KPimPrefs : public KPrefs
QStringList mCustomCategories;
QString mPassiveSyncPort;
QString mPassiveSyncPw;
-
+ int mRingSyncAlgoPrefs;
+ QString mLastSyncedLocalFile;
protected:
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index fad9a76..568c2a9 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -76,7 +76,7 @@ KSyncManager::~KSyncManager()
delete bar;
}
-//LR ok
+
void KSyncManager::fillSyncMenu()
{
if ( mSyncMenu->count() )
@@ -101,11 +101,14 @@ void KSyncManager::fillSyncMenu()
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");
@@ -126,8 +129,9 @@ void KSyncManager::fillSyncMenu()
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 )
@@ -191,25 +195,25 @@ void KSyncManager::slotSyncMenu( int action )
} 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( ) ;
@@ -239,6 +243,7 @@ void KSyncManager::slotSyncMenu( int action )
delete temp;
setBlockSave(false);
}
+
void KSyncManager::enableQuick()
{
QDialog dia ( 0, "input-dialog", true );
@@ -285,7 +290,6 @@ void KSyncManager::enableQuick()
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 ) ) );
}
@@ -293,7 +297,7 @@ void KSyncManager::enableQuick()
void KSyncManager::syncLocalFile()
{
- QString fn =mLastSyncedLocalFile;
+ QString fn =mPrefs->mLastSyncedLocalFile;
QString ext;
switch(mTargetApp)
@@ -321,6 +325,7 @@ void KSyncManager::syncLocalFile()
}
}
+
bool KSyncManager::syncWithFile( QString fn , bool quick )
{
bool ret = false;
@@ -353,25 +358,27 @@ bool KSyncManager::syncWithFile( QString fn , bool quick )
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 ) {
@@ -380,7 +387,7 @@ void KSyncManager::multiSync( bool askforPrefs )
return;
}
mCurrentSyncDevice = i18n("Multiple profiles") ;
- mSyncAlgoPrefs = mRingSyncAlgoPrefs;
+ mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
if ( askforPrefs ) {
edit_sync_options();
mRingSyncAlgoPrefs = mSyncAlgoPrefs;
@@ -394,11 +401,12 @@ void KSyncManager::multiSync( bool askforPrefs )
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;
@@ -413,26 +421,26 @@ int KSyncManager::ringSync()
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();
@@ -448,30 +456,45 @@ int KSyncManager::ringSync()
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 );
@@ -558,19 +581,14 @@ void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
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 ) {
@@ -644,6 +662,7 @@ void KSyncManager::edit_sync_options()
}
+
QString KSyncManager::getPassword( )
{
QString retfile = "";
@@ -685,11 +704,12 @@ void KSyncManager::confSync()
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 ");;
}
@@ -712,10 +732,8 @@ bool KSyncManager::syncExternalApplication(QString resource)
void KSyncManager::syncPhone()
{
- emit save();
- qDebug("pending syncPhone(); ");
- //mView->syncPhone();
+ syncExternalApplication("phone");
}
@@ -767,6 +785,7 @@ QString KSyncManager::syncFileName()
#endif
}
+
void KSyncManager::syncPi()
{
qApp->processEvents();
@@ -1153,4 +1172,3 @@ void KCommandSocket::deleteSocket()
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
@@ -117,6 +117,7 @@ class KSyncManager : public QObject
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 ;}
@@ -147,7 +148,6 @@ class KSyncManager : public QObject
QString mPhoneDevice;
QString mPhoneConnection;
QString mPhoneModel;
- QString mLastSyncedLocalFile; // save!
QString mPassWordPiSync;
QString mActiveSyncPort;
QString mActiveSyncIP ;
@@ -178,7 +178,6 @@ class KSyncManager : public QObject
void syncPhone();
void syncSharp();
bool syncExternalApplication(QString);
- void multiSync( bool askforPrefs );
int mCurrentSyncProfile ;
void syncRemote( KSyncProfile* prof, bool ask = true);
void edit_sync_options();