author | zautrix <zautrix> | 2004-08-07 16:10:09 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-07 16:10:09 (UTC) |
commit | ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf (patch) (side-by-side diff) | |
tree | 7ff6c37e8ad6b7f1dbd672d28de6fcea916caf8f /korganizer | |
parent | a9a774e19c02f03de948b6064804b913abd4f08b (diff) | |
download | kdepimpi-ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf.zip kdepimpi-ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf.tar.gz kdepimpi-ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf.tar.bz2 |
Fix of the syncprofiles
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/koprefs.h | 3 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
5 files changed, 23 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f859b90..689618d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1112,128 +1112,132 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } } } inL = el.next(); } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); eventLSync->setReadOnly( false ); eventLSync->setDtStart( mLastCalendarSync ); eventRSync->setDtStart( mLastCalendarSync ); eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); if ( mGlobalSyncMode == SYNC_MODE_NORMAL) remote->addEvent( eventRSync ); QString mes; 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 ); if ( KOPrefs::instance()->mShowSyncSummary ) { KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); } qDebug( mes ); mCalendar->checkAlarmForIncidence( 0, true ); return syncOK; } void CalendarView::setSyncDevice( QString s ) { mCurrentSyncDevice= s; } void CalendarView::setSyncName( QString s ) { mCurrentSyncName= s; } bool CalendarView::syncCalendar(QString filename, int mode) { mGlobalSyncMode = SYNC_MODE_NORMAL; CalendarLocal* calendar = new CalendarLocal(); calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); FileStorage* storage = new FileStorage( calendar ); bool syncOK = false; storage->setFileName( filename ); // qDebug("loading ... "); if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, mode ); getEventViewerDialog()->setSyncMode( false ); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); storage->save(); } } setModified( true ); } delete storage; delete calendar; if ( syncOK ) updateView(); return syncOK; } +void CalendarView::syncPhone() +{ + qDebug("CalendarView::syncPhone() "); +} void CalendarView::syncSharp() { #ifndef DESKTOP_VERSION 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); bool syncOK = false; SharpFormat sharpFormat; if ( sharpFormat.load( calendar, mCalendar ) ) { getEventViewerDialog()->setSyncMode( true ); syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); getEventViewerDialog()->setSyncMode( false ); qApp->processEvents(); if ( syncOK ) { if ( KOPrefs::instance()->mWriteBackFile ) { QPtrList<Incidence> iL = mCalendar->rawIncidences(); Incidence* inc = iL.first(); /* obsolete while ( inc ) { inc->setZaurusStat( inc->revision () ); inc = iL.next(); } */ // pending: clean last sync event description sharpFormat.save(calendar); iL = calendar->rawIncidences(); inc = iL.first(); Incidence* loc; while ( inc ) { if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { loc = mCalendar->incidence(inc->uid() ); if ( loc ) { loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); } } inc = iL.next(); } Incidence* lse = getLastSyncEvent(); if ( lse ) { lse->setReadOnly( false ); lse->setDescription( "" ); lse->setReadOnly( true ); } } } setModified( true ); } else { QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), question, i18n("Ok")) ; } delete calendar; updateView(); return ;//syncOK; #endif } diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index d564473..b2838db 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -364,128 +364,129 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser /* iTIP scheduling actions */ void schedule_publish(Incidence *incidence = 0); void schedule_request(Incidence *incidence = 0); void schedule_refresh(Incidence *incidence = 0); void schedule_cancel(Incidence *incidence = 0); void schedule_add(Incidence *incidence = 0); void schedule_reply(Incidence *incidence = 0); void schedule_counter(Incidence *incidence = 0); void schedule_declinecounter(Incidence *incidence = 0); void schedule_publish_freebusy(int daysToPublish = 30); void openAddressbook(); void editFilters(); void toggleFilerEnabled(); QPtrList<CalFilter> filters(); void toggleFilter(); void showFilter(bool visible); void updateFilter(); void filterEdited(); void selectFilter( int ); KOFilterView *filterView(); void showIntro(); /** Move the curdatepient view date to today */ void goToday(); /** Move to the next date(s) in the current view */ void goNext(); /** Move to the previous date(s) in the current view */ void goPrevious(); /** Move to the next date(s) in the current view */ void goNextMonth(); /** Move to the previous date(s) in the current view */ void goPreviousMonth(); void toggleExpand(); void toggleDateNavigatorWidget(); void toggleAllDaySize(); void dialogClosing(Incidence *); /** Look for new messages in the inbox */ void lookForIncomingMessages(); /** Look for new messages in the outbox */ void lookForOutgoingMessages(); void processMainViewSelection( Incidence * ); void processTodoListSelection( Incidence * ); void processIncidenceSelection( Incidence * ); void purgeCompleted(); bool removeCompletedSubTodos( Todo* ); void slotCalendarChanged(); bool importBday(); bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); bool importQtopia( const QString &categoriesFile, const QString &datebookFile, const QString &tasklistFile ); void syncSharp( ); + void syncPhone( ); void slotSelectPickerDate( QDate ) ; void showDatePicker( ) ; void moveIncidence(Incidence *) ; void beamIncidence(Incidence *) ; void beamCalendar() ; void beamFilteredCalendar() ; void beamIncidenceList(QPtrList<Incidence>) ; void manageCategories(); int addCategories(); void removeCategories(); void setSyncDevice( QString ); void setSyncName( QString ); protected slots: void timerAlarm(); void suspendAlarm(); void beamDone( Ir *ir ); /** Select a view or adapt the current view to display the specified dates. */ void showDates( const KCal::DateList & ); void selectWeekNum ( int ); public: // show a standard warning // returns KMsgBox::yesNoCancel() int msgCalModified(); void confSync(); void setLoadedFileVersion(QDateTime); bool checkFileVersion(QString fn); bool checkFileChanged(QString fn); Event* getLastSyncEvent(); /** Adapt navigation units correpsonding to step size of navigation of the * current view. */ void adaptNavigationUnits(); bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); //Attendee* getYourAttendee(Event *event); protected: void schedule(Scheduler::Method, Incidence *incidence = 0); // returns KMsgBox::OKCandel() int msgItemDelete(); void showEventEditor(); void showTodoEditor(); void writeLocale(); Todo *selectedTodo(); private: AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); QDateTime loadedFileVersion; void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); void checkExternalId( Incidence * inc ); int mGlobalSyncMode; QString mCurrentSyncDevice; QString mCurrentSyncName; KOBeamPrefs* beamDialog; diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 424fa98..446fe2e 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -149,128 +149,131 @@ class KOPrefs : public KPimPrefs int mHourSize; int mAllDaySize; bool mShowFullMenu; bool mDailyRecur; bool mWeeklyRecur; bool mMonthDailyRecur; bool mMonthWeeklyRecur; bool mMonthShowIcons; bool mMonthShowShort; bool mEnableToolTips; bool mEnableMonthScroll; bool mFullViewMonth; bool mMonthViewUsesCategoryColor; bool mFullViewTodo; bool mShowCompletedTodo; bool mMarcusBainsEnabled; int mNextXDays; int mWhatsNextDays; int mWhatsNextPrios; bool mEnableQuickTodo; bool mLanguageChanged; bool mCompactDialogs; bool mVerticalScreen; bool mShowIconNewTodo; bool mShowIconNewEvent; bool mShowIconSearch; bool mShowIconList; bool mShowIconDay1; bool mShowIconDay5; bool mShowIconDay7; bool mShowIconMonth; bool mShowIconTodoview; bool mShowIconBackFast; bool mShowIconBack; bool mShowIconToday; bool mShowIconForward; bool mShowIconForwardFast; bool mShowIconWhatsThis; bool mShowIconNextDays; bool mShowIconNext; bool mShowIconJournal; bool mShowIconStretch; bool mToolBarHor; bool mToolBarUp; bool mToolBarMiniIcons; bool mAskForQuit; bool mUsePassWd; bool mWriteBackFile; 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); QString mArchiveFile; QString mHtmlExportFile; bool mHtmlWithSave; QStringList mSelectedPlugins; QString mLastImportFile; QString mLastVcalFile; QString mLastSaveFile; QString mLastLoadFile; QString mLastSyncedLocalFile; QString mDefaultAlarmFile; int mIMIPScheduler; int mIMIPSend; QStringList mAdditionalMails; int mIMIPAutoRefresh; int mIMIPAutoInsertReply; int mIMIPAutoInsertRequest; int mIMIPAutoFreeBusy; int mIMIPAutoFreeBusyReply; QStringList mTodoTemplates; QStringList mEventTemplates; int mDestination; bool mEditOnDoubleClick; bool mViewChangeHoldFullscreen; bool mViewChangeHoldNonFullscreen; bool mCenterOnCurrentTime; bool mSetTimeToDayStartAt; bool mHighlightCurrentDay; bool mUseHighlightLightColor; bool mListViewMonthTimespan; bool mWNViewShowsParents; bool mWNViewShowLocation; bool mTodoViewShowsPercentage; bool mTodoViewUsesCatColors; bool mTodoViewUsesSmallFont; bool mTodoViewUsesForegroundColor; bool mMonthViewUsesForegroundColor; bool mHightlightDateTimeEdit; int mPreferredLanguage; bool mUseQuicksave; int mPreferredTime; int mPreferredDate; bool mWeekStartsOnSunday; bool mShortDateInViewer; QString mUserDateFormatLong; QString mUserDateFormatShort; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index c3c4c26..062c95f 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -836,128 +836,134 @@ void MainWindow::fillSyncMenu() 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 ); } mView->setupExternSyncProfiles(); } int MainWindow::ringSync() { int syncedProfiles = 0; int i; QTime timer; KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 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()->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 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 ) { confSync(); return; } if ( action == 1 ) { @@ -1976,74 +1982,82 @@ void MainWindow::syncSSH() 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." ) ); //mView->setSyncDevice("ssh-scp" ); if ( syncWithFile(localFile , true ) ) { // Event* e = mView->getLastSyncEvent(); // e->setReadOnly( false ); // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); // e->setReadOnly( true ); if ( KOPrefs::instance()->mWriteBackFile ) { command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; setCaption ( i18n( "Writing back file ..." ) ); result = system ( command ); if ( result != 0 ) { int len = maxlen; while ( len < command.length() ) { command.insert( len , "\n" ); len += maxlen +2; } question = i18n("Sorry, the copy back 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; } else { setCaption ( i18n( "Syncronization sucessfully completed" ) ); } } } return; #if 0 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); while ( timer.elapsed() < 5000 ) qApp->processEvents(); qDebug("MainWindow::merging) "); mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); while ( mBlockSaveFlag ) qApp->processEvents(); save(); system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); #endif } 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(); } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index fba8c52..1d87db0 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -14,107 +14,108 @@ class KSyncProfile; #ifdef DESKTOP_VERSION #define QPEToolBar QToolBar #define QPEMenuBar QMenuBar #endif class QPEToolBar; namespace KCal { class CalendarLocal; } using namespace KCal; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); ~MainWindow(); public slots: void configureAgenda( int ); void recieve( const QCString& msg, const QByteArray& data ); static QString defaultFileName(); static QString resourcePath(); protected slots: void setCaptionToDates(); int ringSync(); void multiSync( bool askforPrefs = false ); void about(); void licence(); void faq(); void usertrans(); void features(); void synchowto(); void whatsNew(); void keyBindings(); void aboutAutoSaving();; void aboutKnownBugs(); void processIncidenceSelection( Incidence * ); void importQtopia(); void importBday(); void importOL(); void importIcal(); void importFile( QString, bool ); void quickImportIcal(); void slotModifiedChanged( bool ); void save(); void configureToolBar( int ); void printSel(); void printCal(); void saveCalendar(); void loadCalendar(); void exportVCalendar(); void fillFilterMenu(); void selectFilter( int ); void slotSyncMenu( int ); void syncSSH(); void confSync(); void syncSharp(); + void syncPhone(); void syncLocalFile(); bool syncWithFile( QString, bool ); void quickSyncLocalFile(); protected: void displayText( QString, QString); void displayFile( QString, QString); void enableIncidenceActions( bool ); private: void saveOnClose(); int mCurrentSyncProfile; void syncRemote( KSyncProfile* , bool ask = true); void fillSyncMenu(); bool mFlagKeyPressed; bool mBlockAtStartup; QPEToolBar *iconToolBar; void initActions(); void setDefaultPreferences(); void keyPressEvent ( QKeyEvent * ) ; void keyReleaseEvent ( QKeyEvent * ) ; QPopupMenu *configureToolBarMenu; QPopupMenu *selectFilterMenu; QPopupMenu *configureAgendaMenu, *syncMenu; CalendarLocal *mCalendar; CalendarView *mView; QString getPassword(); QAction *mNewSubTodoAction; QAction *mShowAction; QAction *mEditAction; QAction *mDeleteAction; void closeEvent( QCloseEvent* ce ); SimpleAlarmClient mAlarmClient; QTimer mSaveTimer; bool mBlockSaveFlag; bool mCalendarModifiedFlag; QPixmap loadPixmap( QString ); }; #endif |