author | zautrix <zautrix> | 2004-10-07 17:51:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-07 17:51:17 (UTC) |
commit | 1f1538e5707b59bfcff2014901f29a65589229e3 (patch) (unidiff) | |
tree | 0d91a303524e6ac9f7c954f01a0e1d09d0e305e7 /korganizer | |
parent | bb8293c794d82a57bc93af85ccd89b601356d577 (diff) | |
download | kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.zip kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.gz kdepimpi-1f1538e5707b59bfcff2014901f29a65589229e3.tar.bz2 |
many cleanups
-rw-r--r-- | korganizer/calendarview.cpp | 136 | ||||
-rw-r--r-- | korganizer/calendarview.h | 11 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 3 | ||||
-rw-r--r-- | korganizer/koprefs.h | 20 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 556 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 24 |
6 files changed, 83 insertions, 667 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ea9607d..b56f1f9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -702,15 +702,3 @@ void CalendarView::confSync() | |||
702 | { | 702 | { |
703 | static KSyncPrefsDialog* sp = 0; | 703 | //DELETE |
704 | if ( ! sp ) { | ||
705 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | ||
706 | } | ||
707 | sp->usrReadConfig(); | ||
708 | #ifndef DESKTOP_VERSION | ||
709 | sp->showMaximized(); | ||
710 | #else | ||
711 | sp->show(); | ||
712 | #endif | ||
713 | sp->exec(); | ||
714 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | ||
715 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | ||
716 | } | 704 | } |
@@ -879,3 +867,3 @@ Event* CalendarView::getLastSyncEvent() | |||
879 | QString sum = ""; | 867 | QString sum = ""; |
880 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 868 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
881 | sum = "E: "; | 869 | sum = "E: "; |
@@ -1121,3 +1109,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1121 | } else { | 1109 | } else { |
1122 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1110 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1123 | inL->removeID(mCurrentSyncDevice ); | 1111 | inL->removeID(mCurrentSyncDevice ); |
@@ -1137,3 +1125,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1137 | } else { | 1125 | } else { |
1138 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1126 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1139 | ++addedEventR; | 1127 | ++addedEventR; |
@@ -1149,3 +1137,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1149 | int delFut = 0; | 1137 | int delFut = 0; |
1150 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1138 | if ( mSyncManager->mWriteBackInFuture ) { |
1151 | er = remote->rawIncidences(); | 1139 | er = remote->rawIncidences(); |
@@ -1154,3 +1142,3 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1154 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1142 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1155 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); | 1143 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1156 | while ( inR ) { | 1144 | while ( inR ) { |
@@ -1194,6 +1182,6 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1194 | if ( delFut ) { | 1182 | if ( delFut ) { |
1195 | 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 ); | 1183 | 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 ); |
1196 | mes += delmess; | 1184 | mes += delmess; |
1197 | } | 1185 | } |
1198 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1186 | if ( mSyncManager->mShowSyncSummary ) { |
1199 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1187 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
@@ -1227,3 +1215,3 @@ bool CalendarView::syncCalendar(QString filename, int mode) | |||
1227 | if ( syncOK ) { | 1215 | if ( syncOK ) { |
1228 | if ( KOPrefs::instance()->mWriteBackFile ) | 1216 | if ( mSyncManager->mWriteBackFile ) |
1229 | { | 1217 | { |
@@ -1243,3 +1231,3 @@ void CalendarView::syncPhone() | |||
1243 | { | 1231 | { |
1244 | syncExternal( 1 ); | 1232 | //DELETE |
1245 | } | 1233 | } |
@@ -1248,5 +1236,3 @@ void CalendarView::syncExternal( int mode ) | |||
1248 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1236 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1249 | //mCurrentSyncDevice = "sharp-DTM"; | 1237 | |
1250 | if ( KOPrefs::instance()->mAskForPreferences ) | ||
1251 | edit_sync_options(); | ||
1252 | qApp->processEvents(); | 1238 | qApp->processEvents(); |
@@ -1267,5 +1253,5 @@ void CalendarView::syncExternal( int mode ) | |||
1267 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1253 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1268 | KOPrefs::instance()->mPhoneDevice, | 1254 | mSyncManager->mPhoneDevice, |
1269 | KOPrefs::instance()->mPhoneConnection, | 1255 | mSyncManager->mPhoneConnection, |
1270 | KOPrefs::instance()->mPhoneModel); | 1256 | mSyncManager->mPhoneModel); |
1271 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1257 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
@@ -1276,3 +1262,3 @@ void CalendarView::syncExternal( int mode ) | |||
1276 | getEventViewerDialog()->setSyncMode( true ); | 1262 | getEventViewerDialog()->setSyncMode( true ); |
1277 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1263 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1278 | getEventViewerDialog()->setSyncMode( false ); | 1264 | getEventViewerDialog()->setSyncMode( false ); |
@@ -1280,3 +1266,3 @@ void CalendarView::syncExternal( int mode ) | |||
1280 | if ( syncOK ) { | 1266 | if ( syncOK ) { |
1281 | if ( KOPrefs::instance()->mWriteBackFile ) | 1267 | if ( mSyncManager->mWriteBackFile ) |
1282 | { | 1268 | { |
@@ -1331,3 +1317,3 @@ void CalendarView::syncSharp() | |||
1331 | { | 1317 | { |
1332 | syncExternal( 0 ); | 1318 | //DELETE |
1333 | 1319 | ||
@@ -1519,3 +1505,3 @@ bool CalendarView::importQtopia( const QString &categories, | |||
1519 | mCurrentSyncDevice = "qtopia-XML"; | 1505 | mCurrentSyncDevice = "qtopia-XML"; |
1520 | if ( KOPrefs::instance()->mAskForPreferences ) | 1506 | if ( mSyncManager->mAskForPreferences ) |
1521 | edit_sync_options(); | 1507 | edit_sync_options(); |
@@ -1537,3 +1523,3 @@ bool CalendarView::importQtopia( const QString &categories, | |||
1537 | getEventViewerDialog()->setSyncMode( true ); | 1523 | getEventViewerDialog()->setSyncMode( true ); |
1538 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1539 | getEventViewerDialog()->setSyncMode( false ); | 1525 | getEventViewerDialog()->setSyncMode( false ); |
@@ -1541,3 +1527,3 @@ bool CalendarView::importQtopia( const QString &categories, | |||
1541 | if ( syncOK ) { | 1527 | if ( syncOK ) { |
1542 | if ( KOPrefs::instance()->mWriteBackFile ) | 1528 | if ( mSyncManager->mWriteBackFile ) |
1543 | { | 1529 | { |
@@ -1685,7 +1671,7 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1685 | setSyncDevice("deleteaftersync" ); | 1671 | setSyncDevice("deleteaftersync" ); |
1686 | KOPrefs::instance()->mAskForPreferences = true; | 1672 | mSyncManager->mAskForPreferences = true; |
1687 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1673 | mSyncManager->mSyncAlgoPrefs = 3; |
1688 | KOPrefs::instance()->mWriteBackFile = false; | 1674 | mSyncManager->mWriteBackFile = false; |
1689 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1675 | mSyncManager->mWriteBackExistingOnly = false; |
1690 | KOPrefs::instance()->mShowSyncSummary = false; | 1676 | mSyncManager->mShowSyncSummary = false; |
1691 | syncCalendar( fn, 3 ); | 1677 | syncCalendar( fn, 3 ); |
@@ -2200,49 +2186,3 @@ void CalendarView::edit_sync_options() | |||
2200 | { | 2186 | { |
2201 | //mDialogManager->showSyncOptions(); | 2187 | // DELETE |
2202 | //KOPrefs::instance()->mSyncAlgoPrefs | ||
2203 | QDialog dia( this, "dia", true ); | ||
2204 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | ||
2205 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | ||
2206 | QVBoxLayout lay ( &dia ); | ||
2207 | lay.setSpacing( 2 ); | ||
2208 | lay.setMargin( 3 ); | ||
2209 | lay.addWidget(&gr); | ||
2210 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | ||
2211 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | ||
2212 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | ||
2213 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | ||
2214 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | ||
2215 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | ||
2216 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | ||
2217 | QPushButton pb ( "OK", &dia); | ||
2218 | lay.addWidget( &pb ); | ||
2219 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2220 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | ||
2221 | case 0: | ||
2222 | loc.setChecked( true); | ||
2223 | break; | ||
2224 | case 1: | ||
2225 | rem.setChecked( true ); | ||
2226 | break; | ||
2227 | case 2: | ||
2228 | newest.setChecked( true); | ||
2229 | break; | ||
2230 | case 3: | ||
2231 | ask.setChecked( true); | ||
2232 | break; | ||
2233 | case 4: | ||
2234 | f_loc.setChecked( true); | ||
2235 | break; | ||
2236 | case 5: | ||
2237 | f_rem.setChecked( true); | ||
2238 | break; | ||
2239 | case 6: | ||
2240 | // both.setChecked( true); | ||
2241 | break; | ||
2242 | default: | ||
2243 | break; | ||
2244 | } | ||
2245 | if ( dia.exec() ) { | ||
2246 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | ||
2247 | } | ||
2248 | 2188 | ||
@@ -3770,4 +3710,24 @@ void CalendarView::keyPressEvent ( QKeyEvent *e) | |||
3770 | 3710 | ||
3771 | //#include "calendarview.moc" | ||
3772 | 3711 | ||
3773 | //#include "calendarviewbase.moc" | 3712 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3713 | { | ||
3714 | // mSyncManager = manager; | ||
3715 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | ||
3716 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | ||
3717 | return syncCalendar( filename, mode ); | ||
3718 | } | ||
3719 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | ||
3720 | { | ||
3721 | //mSyncManager = manager; | ||
3722 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | ||
3723 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | ||
3724 | if ( resource == "sharp" ) | ||
3725 | syncExternal( 0 ); | ||
3726 | if ( resource == "phone" ) | ||
3727 | syncExternal( 1 ); | ||
3728 | // pending setmodified | ||
3729 | } | ||
3730 | void CalendarView::setSyncManager(KSyncManager* manager) | ||
3731 | { | ||
3732 | mSyncManager = manager; | ||
3733 | } | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 8d329a9..751b8d9 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -44,2 +44,4 @@ | |||
44 | 44 | ||
45 | #include <ksyncmanager.h> | ||
46 | |||
45 | class QWidgetStack; | 47 | class QWidgetStack; |
@@ -79,3 +81,3 @@ using namespace KCal; | |||
79 | */ | 81 | */ |
80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer | 82 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
81 | { | 83 | { |
@@ -462,4 +464,8 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
462 | // returns KMsgBox::yesNoCancel() | 464 | // returns KMsgBox::yesNoCancel() |
463 | int msgCalModified(); | 465 | int msgCalModified(); |
466 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | ||
467 | |||
468 | virtual bool syncExternal(KSyncManager* manager, QString resource); | ||
464 | void confSync(); | 469 | void confSync(); |
470 | void setSyncManager(KSyncManager* manager); | ||
465 | void setLoadedFileVersion(QDateTime); | 471 | void setLoadedFileVersion(QDateTime); |
@@ -486,2 +492,3 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
486 | private: | 492 | private: |
493 | KSyncManager* mSyncManager; | ||
487 | AlarmDialog * mAlarmDialog; | 494 | AlarmDialog * mAlarmDialog; |
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 1210094..13035e0 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -198,4 +198,2 @@ KOPrefs::KOPrefs() : | |||
198 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 198 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
199 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); | ||
200 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | ||
201 | 199 | ||
@@ -219,3 +217,2 @@ KOPrefs::KOPrefs() : | |||
219 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 217 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
220 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | ||
221 | 218 | ||
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index ff09e19..03df59b 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h | |||
@@ -196,25 +196,6 @@ class KOPrefs : public KPimPrefs | |||
196 | bool mUsePassWd; | 196 | bool mUsePassWd; |
197 | bool mWriteBackFile; | ||
198 | int mWriteBackInFuture; | ||
199 | bool mAskForPreferences; | ||
200 | bool mShowSyncSummary; | ||
201 | bool mShowSyncEvents; | 197 | bool mShowSyncEvents; |
202 | bool mShowTodoInAgenda; | 198 | bool mShowTodoInAgenda; |
203 | bool mWriteBackExistingOnly; | ||
204 | |||
205 | QString mRemoteIP; | ||
206 | QString mRemoteUser; | ||
207 | QString mRemotePassWd; | ||
208 | QString mRemoteFile; | ||
209 | QString mLocalTempFile; | ||
210 | QString mPhoneDevice; | ||
211 | QString mPhoneConnection; | ||
212 | QString mPhoneModel; | ||
213 | 199 | ||
214 | int mLastSyncTime; | 200 | int mLastSyncTime; |
215 | int mSyncAlgoPrefs; | ||
216 | int mRingSyncAlgoPrefs; | ||
217 | QStringList mSyncProfileNames; | ||
218 | QStringList mExternSyncProfiles; | ||
219 | QString mLocalMachineName; | ||
220 | void setCategoryColor(QString cat,const QColor & color); | 201 | void setCategoryColor(QString cat,const QColor & color); |
@@ -232,3 +213,2 @@ class KOPrefs : public KPimPrefs | |||
232 | QString mLastLoadFile; | 213 | QString mLastLoadFile; |
233 | QString mLastSyncedLocalFile; | ||
234 | 214 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index e3324ee..f7766f8 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -128,3 +128,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
128 | { | 128 | { |
129 | mPassWordPiSync = "abc"; | 129 | |
130 | #ifdef DESKTOP_VERSION | 130 | #ifdef DESKTOP_VERSION |
@@ -144,6 +144,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
144 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 144 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
145 | // if ( QApplication::desktop()->height() > 480 ) { | ||
146 | // if ( p->mHourSize == 4 ) | ||
147 | // p->mHourSize = 6; | ||
148 | // } | ||
149 | if ( p->mHourSize > 18 ) | 145 | if ( p->mHourSize > 18 ) |
@@ -168,3 +164,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
168 | addToolBar (iconToolBar , tbd ); | 164 | addToolBar (iconToolBar , tbd ); |
169 | mBlockSaveFlag = false; | ||
170 | mCalendarModifiedFlag = false; | 165 | mCalendarModifiedFlag = false; |
@@ -183,3 +178,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
183 | //mView->resize(splash->size() ); | 178 | //mView->resize(splash->size() ); |
184 | initActions(); | 179 | initActions(); |
180 | mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); | ||
181 | mSyncManager->setBlockSave(false); | ||
182 | mView->setSyncManager(mSyncManager); | ||
185 | #ifndef DESKTOP_VERSION | 183 | #ifndef DESKTOP_VERSION |
@@ -254,3 +252,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | |||
254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 252 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
255 | fillSyncMenu(); | 253 | //fillSyncMenu(); |
254 | |||
255 | |||
256 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | ||
257 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | ||
258 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | ||
259 | mSyncManager->setDefaultFileName( defaultFileName()); | ||
260 | mSyncManager->fillSyncMenu(); | ||
261 | |||
262 | |||
263 | |||
256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 264 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
@@ -397,3 +405,3 @@ void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | |||
397 | else if ( msg == "-ringSync" ) { | 405 | else if ( msg == "-ringSync" ) { |
398 | multiSync( false ); | 406 | mSyncManager->multiSync( false ); |
399 | } | 407 | } |
@@ -942,230 +950,3 @@ void MainWindow::initActions() | |||
942 | } | 950 | } |
943 | void MainWindow::fillSyncMenu() | ||
944 | { | ||
945 | if ( syncMenu->count() ) | ||
946 | syncMenu->clear(); | ||
947 | syncMenu->insertItem( i18n("Configure..."), 0 ); | ||
948 | syncMenu->insertSeparator(); | ||
949 | if ( mServerSocket == 0 ) { | ||
950 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | ||
951 | } else { | ||
952 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | ||
953 | } | ||
954 | syncMenu->insertSeparator(); | ||
955 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | ||
956 | syncMenu->insertSeparator(); | ||
957 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
958 | config.setGroup("General"); | ||
959 | QStringList prof = config.readListEntry("SyncProfileNames"); | ||
960 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | ||
961 | if ( prof.count() < 3 ) { | ||
962 | prof.clear(); | ||
963 | prof << i18n("Sharp_DTM"); | ||
964 | prof << i18n("Local_file"); | ||
965 | prof << i18n("Last_file"); | ||
966 | KSyncProfile* temp = new KSyncProfile (); | ||
967 | temp->setName( prof[0] ); | ||
968 | temp->writeConfig(&config); | ||
969 | temp->setName( prof[1] ); | ||
970 | temp->writeConfig(&config); | ||
971 | temp->setName( prof[2] ); | ||
972 | temp->writeConfig(&config); | ||
973 | config.setGroup("General"); | ||
974 | config.writeEntry("SyncProfileNames",prof); | ||
975 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | ||
976 | config.sync(); | ||
977 | delete temp; | ||
978 | } | ||
979 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | ||
980 | KOPrefs::instance()->mSyncProfileNames = prof; | ||
981 | int i; | ||
982 | for ( i = 0; i < prof.count(); ++i ) { | ||
983 | |||
984 | syncMenu->insertItem( prof[i], 1000+i ); | ||
985 | if ( i == 2 ) | ||
986 | syncMenu->insertSeparator(); | ||
987 | } | ||
988 | QDir app_dir; | ||
989 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | ||
990 | syncMenu->setItemEnabled( false , 1000 ); | ||
991 | } | ||
992 | } | ||
993 | |||
994 | int MainWindow::ringSync() | ||
995 | { | ||
996 | int syncedProfiles = 0; | ||
997 | int i; | ||
998 | QTime timer; | ||
999 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
1000 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | ||
1001 | KSyncProfile* temp = new KSyncProfile (); | ||
1002 | KOPrefs::instance()->mAskForPreferences = false; | ||
1003 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | ||
1004 | mCurrentSyncProfile = i; | ||
1005 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | ||
1006 | temp->readConfig(&config); | ||
1007 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | ||
1008 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | ||
1009 | ++syncedProfiles; | ||
1010 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
1011 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
1012 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
1013 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1014 | if ( temp->getWriteBackFuture() ) | ||
1015 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1016 | KOPrefs::instance()->mShowSyncSummary = false; | ||
1017 | mView->setSyncDevice(syncProfileNames[i] ); | ||
1018 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
1019 | if ( i == 0 ) { | ||
1020 | syncSharp(); | ||
1021 | } else { | ||
1022 | if ( temp->getIsLocalFileSync() ) { | ||
1023 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | ||
1024 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
1025 | } else { | ||
1026 | if ( temp->getIsPhoneSync() ) { | ||
1027 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
1028 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
1029 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
1030 | syncPhone(); | ||
1031 | } else if ( temp->getIsPiSync() ) { | ||
1032 | mPassWordPiSync = temp->getRemotePw(); | ||
1033 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | ||
1034 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | ||
1035 | syncPi(); | ||
1036 | } else | ||
1037 | syncRemote( temp, false ); | ||
1038 | |||
1039 | } | ||
1040 | } | ||
1041 | timer.start(); | ||
1042 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | ||
1043 | while ( timer.elapsed () < 2000 ) { | ||
1044 | qApp->processEvents(); | ||
1045 | #ifndef _WIN32_ | ||
1046 | sleep (1); | ||
1047 | #endif | ||
1048 | } | ||
1049 | |||
1050 | } | ||
1051 | |||
1052 | } | ||
1053 | delete temp; | ||
1054 | return syncedProfiles; | ||
1055 | } | ||
1056 | |||
1057 | void MainWindow::multiSync( bool askforPrefs ) | ||
1058 | { | ||
1059 | if (mBlockSaveFlag) | ||
1060 | return; | ||
1061 | mBlockSaveFlag = true; | ||
1062 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | ||
1063 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
1064 | question, | ||
1065 | i18n("Yes"), i18n("No"), | ||
1066 | 0, 0 ) != 0 ) { | ||
1067 | mBlockSaveFlag = false; | ||
1068 | setCaption(i18n("Aborted! Nothing synced!")); | ||
1069 | return; | ||
1070 | } | ||
1071 | mView->setSyncDevice(i18n("Multiple profiles") ); | ||
1072 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | ||
1073 | if ( askforPrefs ) { | ||
1074 | mView->edit_sync_options(); | ||
1075 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | ||
1076 | } | ||
1077 | setCaption(i18n("Multiple sync started.") ); | ||
1078 | qApp->processEvents(); | ||
1079 | int num = ringSync() ; | ||
1080 | if ( num > 1 ) | ||
1081 | ringSync(); | ||
1082 | mBlockSaveFlag = false; | ||
1083 | if ( num ) | ||
1084 | save(); | ||
1085 | if ( num ) | ||
1086 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | ||
1087 | else | ||
1088 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | ||
1089 | return; | ||
1090 | } | ||
1091 | void MainWindow::slotSyncMenu( int action ) | ||
1092 | { | ||
1093 | qDebug("syncaction %d ", action); | ||
1094 | if ( action == 0 ) { | ||
1095 | |||
1096 | // seems to be a Qt2 event handling bug | ||
1097 | // syncmenu.clear causes a segfault at first time | ||
1098 | // when we call it after the main event loop, it is ok | ||
1099 | // same behaviour when calling OM/Pi via QCOP for the first time | ||
1100 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | ||
1101 | //confSync(); | ||
1102 | 951 | ||
1103 | return; | ||
1104 | } | ||
1105 | if ( action == 1 ) { | ||
1106 | multiSync( true ); | ||
1107 | return; | ||
1108 | } | ||
1109 | if ( action == 2 ) { | ||
1110 | enableQuick(); | ||
1111 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | ||
1112 | return; | ||
1113 | } | ||
1114 | if ( action == 3 ) { | ||
1115 | delete mServerSocket; | ||
1116 | mServerSocket = 0; | ||
1117 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | ||
1118 | return; | ||
1119 | } | ||
1120 | |||
1121 | if (mBlockSaveFlag) | ||
1122 | return; | ||
1123 | mBlockSaveFlag = true; | ||
1124 | mCurrentSyncProfile = action - 1000 ; | ||
1125 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | ||
1126 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | ||
1127 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | ||
1128 | KSyncProfile* temp = new KSyncProfile (); | ||
1129 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
1130 | temp->readConfig(&config); | ||
1131 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | ||
1132 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | ||
1133 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | ||
1134 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | ||
1135 | KOPrefs::instance()->mWriteBackInFuture = 0; | ||
1136 | if ( temp->getWriteBackFuture() ) | ||
1137 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | ||
1138 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | ||
1139 | if ( action == 1000 ) { | ||
1140 | syncSharp(); | ||
1141 | |||
1142 | } else if ( action == 1001 ) { | ||
1143 | syncLocalFile(); | ||
1144 | |||
1145 | } else if ( action == 1002 ) { | ||
1146 | quickSyncLocalFile(); | ||
1147 | |||
1148 | } else if ( action >= 1003 ) { | ||
1149 | if ( temp->getIsLocalFileSync() ) { | ||
1150 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | ||
1151 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | ||
1152 | } else { | ||
1153 | if ( temp->getIsPhoneSync() ) { | ||
1154 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
1155 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
1156 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
1157 | syncPhone(); | ||
1158 | } else if ( temp->getIsPiSync() ) { | ||
1159 | mPassWordPiSync = temp->getRemotePw(); | ||
1160 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | ||
1161 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | ||
1162 | syncPi(); | ||
1163 | } else | ||
1164 | syncRemote( temp ); | ||
1165 | |||
1166 | } | ||
1167 | } | ||
1168 | delete temp; | ||
1169 | mBlockSaveFlag = false; | ||
1170 | } | ||
1171 | void MainWindow::exportToPhone( int mode ) | 952 | void MainWindow::exportToPhone( int mode ) |
@@ -1586,3 +1367,3 @@ void MainWindow::slotModifiedChanged( bool changed ) | |||
1586 | // and for safety reasons after 10 minutes again | 1367 | // and for safety reasons after 10 minutes again |
1587 | if ( !mBlockSaveFlag ) | 1368 | if ( !mSyncManager->blockSave() ) |
1588 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1369 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
@@ -1596,6 +1377,5 @@ void MainWindow::save() | |||
1596 | { | 1377 | { |
1597 | if ( mBlockSaveFlag ) | 1378 | if ( mSyncManager->blockSave() ) |
1598 | return; | 1379 | return; |
1599 | bool store = mBlockSaveFlag; | 1380 | mSyncManager->setBlockSave(true); |
1600 | mBlockSaveFlag = true; | ||
1601 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1381 | if ( mView->checkFileVersion( defaultFileName()) ) { |
@@ -1617,3 +1397,3 @@ void MainWindow::save() | |||
1617 | mCalendarModifiedFlag = false; | 1397 | mCalendarModifiedFlag = false; |
1618 | mBlockSaveFlag = store; | 1398 | mSyncManager->setBlockSave( false ); |
1619 | } | 1399 | } |
@@ -2031,76 +1811,7 @@ void MainWindow::exportVCalendar() | |||
2031 | } | 1811 | } |
2032 | QString MainWindow::getPassword( ) | ||
2033 | { | ||
2034 | QString retfile = ""; | ||
2035 | QDialog dia ( this, "input-dialog", true ); | ||
2036 | QLineEdit lab ( &dia ); | ||
2037 | lab.setEchoMode( QLineEdit::Password ); | ||
2038 | QVBoxLayout lay( &dia ); | ||
2039 | lay.setMargin(7); | ||
2040 | lay.setSpacing(7); | ||
2041 | lay.addWidget( &lab); | ||
2042 | dia.setFixedSize( 230,50 ); | ||
2043 | dia.setCaption( i18n("Enter password") ); | ||
2044 | QPushButton pb ( "OK", &dia); | ||
2045 | lay.addWidget( &pb ); | ||
2046 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2047 | dia.show(); | ||
2048 | int res = dia.exec(); | ||
2049 | if ( res ) | ||
2050 | retfile = lab.text(); | ||
2051 | dia.hide(); | ||
2052 | qApp->processEvents(); | ||
2053 | return retfile; | ||
2054 | |||
2055 | } | ||
2056 | 1812 | ||
2057 | void MainWindow::enableQuick() | 1813 | void MainWindow::syncFileRequest() |
2058 | { | 1814 | { |
2059 | QDialog dia ( this, "input-dialog", true ); | 1815 | save(); |
2060 | QLineEdit lab ( &dia ); | ||
2061 | QVBoxLayout lay( &dia ); | ||
2062 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | ||
2063 | lay.setMargin(7); | ||
2064 | lay.setSpacing(7); | ||
2065 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | ||
2066 | lay.addWidget( &label); | ||
2067 | lay.addWidget( &lab); | ||
2068 | |||
2069 | QLineEdit lepw ( &dia ); | ||
2070 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); | ||
2071 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | ||
2072 | lay.addWidget( &label2); | ||
2073 | lay.addWidget( &lepw); | ||
2074 | dia.setFixedSize( 230,80 ); | ||
2075 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | ||
2076 | QPushButton pb ( "OK", &dia); | ||
2077 | lay.addWidget( &pb ); | ||
2078 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | ||
2079 | dia.show(); | ||
2080 | if ( ! dia.exec() ) | ||
2081 | return; | ||
2082 | dia.hide(); | ||
2083 | qApp->processEvents(); | ||
2084 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); | ||
2085 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); | ||
2086 | bool ok; | ||
2087 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); | ||
2088 | if ( ! ok ) { | ||
2089 | KMessageBox::information( this, i18n("No valid port")); | ||
2090 | return; | ||
2091 | } | ||
2092 | //qDebug("port %d ", port); | ||
2093 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); | ||
2094 | mServerSocket->setFileName( defaultFileName() ); | ||
2095 | //qDebug("connected "); | ||
2096 | if ( !mServerSocket->ok() ) { | ||
2097 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); | ||
2098 | delete mServerSocket; | ||
2099 | mServerSocket = 0; | ||
2100 | return; | ||
2101 | } | ||
2102 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | ||
2103 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | ||
2104 | } | 1816 | } |
2105 | |||
2106 | void MainWindow::getFile( bool success ) | 1817 | void MainWindow::getFile( bool success ) |
@@ -2117,223 +1828,2 @@ void MainWindow::getFile( bool success ) | |||
2117 | 1828 | ||
2118 | |||
2119 | void MainWindow::syncPi() | ||
2120 | { | ||
2121 | qApp->processEvents(); | ||
2122 | bool ok; | ||
2123 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | ||
2124 | if ( ! ok ) { | ||
2125 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | ||
2126 | return; | ||
2127 | } | ||
2128 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | ||
2129 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | ||
2130 | setCaption( i18n("Sending request for remote file ...") ); | ||
2131 | commandSocket->readFile( syncFileName() ); | ||
2132 | } | ||
2133 | |||
2134 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) | ||
2135 | { | ||
2136 | qDebug("MainWindow::deleteCommandSocket %d", state); | ||
2137 | |||
2138 | //enum { success, errorW, errorR, quiet }; | ||
2139 | if ( state == KCommandSocket::errorR ) { | ||
2140 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | ||
2141 | delete s; | ||
2142 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | ||
2143 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
2144 | commandSocket->sendStop(); | ||
2145 | return; | ||
2146 | |||
2147 | } else if ( state == KCommandSocket::errorW ) { | ||
2148 | setCaption( i18n("ERROR:Writing back file failed.") ); | ||
2149 | |||
2150 | } else if ( state == KCommandSocket::successR ) { | ||
2151 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | ||
2152 | |||
2153 | } else if ( state == KCommandSocket::successW ) { | ||
2154 | setCaption( i18n("Pi-Sync succesful!") ); | ||
2155 | } | ||
2156 | |||
2157 | delete s; | ||
2158 | } | ||
2159 | |||
2160 | void MainWindow::readFileFromSocket() | ||
2161 | { | ||
2162 | QString fileName = syncFileName(); | ||
2163 | setCaption( i18n("Remote file saved to temp file.") ); | ||
2164 | if ( ! syncWithFile( fileName , true ) ) { | ||
2165 | setCaption( i18n("Syncing failed.") ); | ||
2166 | qDebug("Syncing failed "); | ||
2167 | return; | ||
2168 | } | ||
2169 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | ||
2170 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | ||
2171 | if ( KOPrefs::instance()->mWriteBackFile ) | ||
2172 | commandSocket->writeFile( fileName ); | ||
2173 | else { | ||
2174 | commandSocket->sendStop(); | ||
2175 | setCaption( i18n("Pi-Sync succesful!") ); | ||
2176 | } | ||
2177 | } | ||
2178 | |||
2179 | void MainWindow::syncLocalFile() | ||
2180 | { | ||
2181 | |||
2182 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | ||
2183 | |||
2184 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
2185 | if ( fn == "" ) | ||
2186 | return; | ||
2187 | //mView->setSyncDevice("local-file" ); | ||
2188 | if ( syncWithFile( fn, false ) ) { | ||
2189 | // Event* e = mView->getLastSyncEvent(); | ||
2190 | // e->setReadOnly( false ); | ||
2191 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | ||
2192 | // e->setReadOnly( true ); | ||
2193 | } | ||
2194 | |||
2195 | } | ||
2196 | |||
2197 | bool MainWindow::syncWithFile( QString fn , bool quick ) | ||
2198 | { | ||
2199 | bool ret = false; | ||
2200 | QFileInfo info; | ||
2201 | info.setFile( fn ); | ||
2202 | QString mess; | ||
2203 | bool loadbup = true; | ||
2204 | if ( !info. exists() ) { | ||
2205 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | ||
2206 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2207 | mess ); | ||
2208 | return ret; | ||
2209 | } | ||
2210 | int result = 0; | ||
2211 | if ( !quick ) { | ||
2212 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | ||
2213 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | ||
2214 | mess, | ||
2215 | i18n("Sync"), i18n("Cancel"), 0, | ||
2216 | 0, 1 ); | ||
2217 | if ( result ) | ||
2218 | return false; | ||
2219 | } | ||
2220 | if ( KOPrefs::instance()->mAskForPreferences ) | ||
2221 | mView->edit_sync_options(); | ||
2222 | if ( result == 0 ) { | ||
2223 | //qDebug("Now sycing ... "); | ||
2224 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | ||
2225 | setCaption( i18n("Synchronization successful") ); | ||
2226 | else | ||
2227 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | ||
2228 | if ( ! quick ) | ||
2229 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | ||
2230 | slotModifiedChanged( true ); | ||
2231 | } | ||
2232 | return ret; | ||
2233 | } | ||
2234 | void MainWindow::quickSyncLocalFile() | ||
2235 | { | ||
2236 | //mView->setSyncDevice("local-file" ); | ||
2237 | //qDebug("quickSyncLocalFile() "); | ||
2238 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | ||
2239 | // Event* e = mView->getLastSyncEvent(); | ||
2240 | // e->setReadOnly( false ); | ||
2241 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | ||
2242 | // e->setReadOnly( true ); | ||
2243 | |||
2244 | } | ||
2245 | } | ||
2246 | |||
2247 | void MainWindow::confSync() | ||
2248 | { | ||
2249 | mView->confSync(); | ||
2250 | fillSyncMenu(); | ||
2251 | } | ||
2252 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | ||
2253 | { | ||
2254 | QString question; | ||
2255 | if ( ask ) { | ||
2256 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | ||
2257 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | ||
2258 | question, | ||
2259 | i18n("Yes"), i18n("No"), | ||
2260 | 0, 0 ) != 0 ) | ||
2261 | return; | ||
2262 | } | ||
2263 | QString command = prof->getPreSyncCommand(); | ||
2264 | int fi; | ||
2265 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2266 | QString pwd = getPassword(); | ||
2267 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2268 | |||
2269 | } | ||
2270 | int maxlen = 30; | ||
2271 | if ( QApplication::desktop()->width() > 320 ) | ||
2272 | maxlen += 25; | ||
2273 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | ||
2274 | int fileSize = 0; | ||
2275 | int result = system ( command ); | ||
2276 | // 0 : okay | ||
2277 | // 256: no such file or dir | ||
2278 | // | ||
2279 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | ||
2280 | if ( result != 0 ) { | ||
2281 | int len = maxlen; | ||
2282 | while ( len < command.length() ) { | ||
2283 | command.insert( len , "\n" ); | ||
2284 | len += maxlen +2; | ||
2285 | } | ||
2286 | 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) ; | ||
2287 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | ||
2288 | question, | ||
2289 | i18n("Okay!")) ; | ||
2290 | setCaption ("KO/Pi"); | ||
2291 | return; | ||
2292 | } | ||
2293 | setCaption ( i18n( "Copying succeed." ) ); | ||
2294 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | ||
2295 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | ||
2296 | // Event* e = mView->getLastSyncEvent(); | ||
2297 | // e->setReadOnly( false ); | ||
2298 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | ||
2299 | // e->setReadOnly( true ); | ||
2300 | if ( KOPrefs::instance()->mWriteBackFile ) { | ||
2301 | command = prof->getPostSyncCommand(); | ||
2302 | int fi; | ||
2303 | if ( (fi = command.find("$PWD$")) > 0 ) { | ||
2304 | QString pwd = getPassword(); | ||
2305 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | ||
2306 | |||
2307 | } | ||
2308 | setCaption ( i18n( "Writing back file ..." ) ); | ||
2309 | result = system ( command ); | ||
2310 | qDebug("KO: Writing back file result: %d ", result); | ||
2311 | if ( result != 0 ) { | ||
2312 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | ||
2313 | return; | ||
2314 | } else { | ||
2315 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | ||
2316 | } | ||
2317 | } | ||
2318 | } | ||
2319 | return; | ||
2320 | } | ||
2321 | |||
2322 | void MainWindow::syncSharp() | ||
2323 | { | ||
2324 | if ( mCalendarModifiedFlag ) | ||
2325 | save(); | ||
2326 | mView->syncSharp(); | ||
2327 | slotModifiedChanged( true ); | ||
2328 | |||
2329 | } | ||
2330 | void MainWindow::syncPhone() | ||
2331 | { | ||
2332 | if ( mCalendarModifiedFlag ) | ||
2333 | save(); | ||
2334 | mView->syncPhone(); | ||
2335 | slotModifiedChanged( true ); | ||
2336 | |||
2337 | } | ||
2338 | |||
2339 | void MainWindow::printSel( ) | 1829 | void MainWindow::printSel( ) |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 0da0be0..ee7bd87 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -46,4 +46,2 @@ class MainWindow : public QMainWindow | |||
46 | void setCaptionToDates(); | 46 | void setCaptionToDates(); |
47 | int ringSync(); | ||
48 | void multiSync( bool askforPrefs = false ); | ||
49 | void about(); | 47 | void about(); |
@@ -81,11 +79,2 @@ class MainWindow : public QMainWindow | |||
81 | 79 | ||
82 | void slotSyncMenu( int ); | ||
83 | void confSync(); | ||
84 | void syncSharp(); | ||
85 | void syncPhone(); | ||
86 | void syncPi(); | ||
87 | void syncLocalFile(); | ||
88 | bool syncWithFile( QString, bool ); | ||
89 | void quickSyncLocalFile(); | ||
90 | |||
91 | 80 | ||
@@ -101,9 +90,7 @@ class MainWindow : public QMainWindow | |||
101 | QTime piTime; | 90 | QTime piTime; |
102 | void deleteCommandSocket(KCommandSocket* s, int state ); | ||
103 | void fillSyncMenu(); | ||
104 | void getFile( bool ); | 91 | void getFile( bool ); |
105 | void readFileFromSocket(); | 92 | void syncFileRequest(); |
106 | private: | 93 | private: |
94 | KSyncManager* mSyncManager; | ||
107 | //QTimer* mTimerCommandSocket; | 95 | //QTimer* mTimerCommandSocket; |
108 | QString mPassWordPiSync; | ||
109 | KServerSocket * mServerSocket; | 96 | KServerSocket * mServerSocket; |
@@ -111,5 +98,2 @@ class MainWindow : public QMainWindow | |||
111 | void saveOnClose(); | 98 | void saveOnClose(); |
112 | int mCurrentSyncProfile; | ||
113 | void enableQuick(); | ||
114 | void syncRemote( KSyncProfile* , bool ask = true); | ||
115 | bool mFlagKeyPressed; | 99 | bool mFlagKeyPressed; |
@@ -126,3 +110,2 @@ class MainWindow : public QMainWindow | |||
126 | CalendarView *mView; | 110 | CalendarView *mView; |
127 | QString getPassword(); | ||
128 | QAction *mNewSubTodoAction; | 111 | QAction *mNewSubTodoAction; |
@@ -137,3 +120,2 @@ class MainWindow : public QMainWindow | |||
137 | 120 | ||
138 | |||
139 | void closeEvent( QCloseEvent* ce ); | 121 | void closeEvent( QCloseEvent* ce ); |
@@ -141,3 +123,3 @@ class MainWindow : public QMainWindow | |||
141 | QTimer mSaveTimer; | 123 | QTimer mSaveTimer; |
142 | bool mBlockSaveFlag; | 124 | //bool mBlockSaveFlag; |
143 | bool mCalendarModifiedFlag; | 125 | bool mCalendarModifiedFlag; |