-rw-r--r-- | korganizer/calendarview.cpp | 73 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 16 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.cpp | 24 | ||||
-rw-r--r-- | libkdepim/ksyncmanager.h | 6 |
9 files changed, 118 insertions, 25 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8965d3b..307027a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -361,16 +361,17 @@ CalendarView::CalendarView( Calendar *calendar, mEventEditor = 0; mTodoEditor = 0; init(); } void CalendarView::init() { + mMultiResourceSync = false; flag_blockConflict = false; flag_blockScrollBar = false; flag_checkFileFirsttime = true; flag_clearallviewsEventDisplay = false; flag_clearallviewsupdateView = false; mNextAlarmDateTime = QDateTime::currentDateTime(); setFocusPolicy (NoFocus ); mViewerCallerIsSearchDialog = false; @@ -1547,16 +1548,17 @@ Event* CalendarView::getLastSyncEvent() QString sum = ""; if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) sum = "E: "; lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); + lse->setCalID( 1 ); mCalendar->addEvent( lse ); } return lse; } // we check, if the to delete event has a id for a profile @@ -1897,26 +1899,31 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int remote->deleteIncidence( inR ); ++delFut; } inR = er.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 ( mMultiResourceSync ) { + remote->removeSyncInfo( "" ); //all + + } else { + 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 ); + } qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); - if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... + if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... remote->addEvent( eventRSync ); else delete eventRSync; qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); QString delmess; if ( delFut ) { @@ -2430,16 +2437,42 @@ void CalendarView::mergeFile( QString fn ) { clearAllViews(); mCalendar->mergeCalendarFile( fn ); mCalendar->reInitAlarmSettings(); setSyncEventsReadOnly(); updateUnmanagedViews(); updateView(); } +void CalendarView::mergeFileResource( QString fn ,QString resource ) +{ + + if ( resource == "ALL" ) { + mergeFile( fn ); + return; + } + + int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); + if ( !exclusiveResource ) { + qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); + return; + } + clearAllViews(); + mCalendar->setCalendarRemove( exclusiveResource ); + int def = mCalendar->defaultCalendar(); + mCalendar->setDefaultCalendar(exclusiveResource); + if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { + qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); + } + mCalendar->setDefaultCalendar( def ); + mCalendar->reInitAlarmSettings(); + setSyncEventsReadOnly(); + updateUnmanagedViews(); + updateView(); +} void CalendarView::showOpenError() { KMessageBox::error(this,i18n("Couldn't load calendar\n.")); } void CalendarView::setLoadedFileVersion(QDateTime dt) { loadedFileVersion = dt; } @@ -2517,16 +2550,17 @@ bool CalendarView::checkFileVersion(QString fn) return true; setSyncDevice("deleteaftersync" ); mSyncManager->mAskForPreferences = true; mSyncManager->mSyncAlgoPrefs = 3; mSyncManager->mWriteBackFile = false; mSyncManager->mWriteBackExistingOnly = false; mSyncManager->mShowSyncSummary = false; + mMultiResourceSync = false; syncCalendar( fn, 3 ); Event * e = getLastSyncEvent(); if ( e ) mCalendar->deleteEvent( e ); return true; } bool CalendarView::saveCalendars() { @@ -2553,16 +2587,33 @@ bool CalendarView::saveCalendars() //saveError = "test error"; if ( !saveError.isEmpty() ) { saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; KMessageBox::error(this, saveError, i18n("Error saving data")); return false; } return true; } +bool CalendarView::saveCalendarResource(QString filename, QString resource) +{ + if ( resource == "ALL" ) + return saveCalendar( filename ); + int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); + if ( !exclusiveResource ) { + qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); + return false; + } + mCalendar->setDefaultCalendar( exclusiveResource ); + mCalendar->setDefaultCalendarEnabledOnly(); + mCalendar->setSyncEventsEnabled(); + bool res = saveCalendar( filename ); + restoreCalendarSettings(); + return res; + +} bool CalendarView::saveCalendar( QString filename ) { // Store back all unsaved data into calendar object // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); if ( mViewManager->currentView() ) mViewManager->currentView()->flushView(); @@ -5027,17 +5078,21 @@ void CalendarView::slotCalendarChanged() } void CalendarView::keyPressEvent ( QKeyEvent *e) { //qDebug("CalendarView::keyPressEvent "); e->ignore(); } +void CalendarView::multiResourceSyncStart( bool start ) +{ + mMultiResourceSync = start; +} bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) { if ( manager != mSyncManager) qDebug("KO: Internal error-1. SyncManager mismatch "); if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { qDebug("KO: SyncKDE request detected!"); } diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index f85b6a3..60b1276 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -134,16 +134,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser KDateNavigator *dateNavigatorWidget(); void addView(KOrg::BaseView *); void showView(KOrg::BaseView *); KOEventViewerDialog* getEventViewerDialog(); Incidence *currentSelection(); void checkSuspendAlarm(); void mergeFile( QString fn ); + void mergeFileResource( QString fn ,QString res); signals: void save (); void saveStopTimer (); void tempDisableBR(bool); /** This todo has been modified */ void todoModified(Todo *, int); @@ -196,16 +197,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void statusMessage(const QString &); void calendarViewExpanded( bool ); void updateSearchDialog(); void filtersUpdated(); public slots: + void multiResourceSyncStart( bool ); void displayCalendarInfo( int id ); void nextConflict( bool all, bool allday ); void conflictAll(); void conflictAllday(); void conflictNotAll(); void setCalReadOnly( int id, bool readO ); void checkAlarms(); void checkFiles(); @@ -241,16 +243,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void addCalendarId( int id ); bool syncCalendar(QString filename,int mode = 0 ); /** Save calendar data to file. Return true if calendar could be successfully saved. */ bool saveCalendar(QString filename); + bool saveCalendarResource(QString filename, QString resource); /** Close calendar. Clear calendar data and reset views to display an empty calendar. */ void closeCalendar(); /** Archive old events of calendar */ @@ -534,16 +537,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser 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); void setBlockShowDates( bool b ) { mBlockShowDates = b ;} void setScrollBarStep(int val ); protected: + bool mMultiResourceSync; Event *mConflictingEvent; void schedule(Scheduler::Method, Incidence *incidence = 0); // returns KMsgBox::OKCandel() int msgItemDelete(const QString name); void showEventEditor(); void showTodoEditor(); Todo *selectedTodo(); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 66bb19b..69ccde1 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -369,18 +369,20 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : mView->updateConfig(); // qApp->processEvents(); //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); //fillSyncMenu(); connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); - connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); - connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); + connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); + connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) ); + connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) ); + mSyncManager->setDefaultFileName( sentSyncFile()); connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); mSyncManager->fillSyncMenu(); mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); if ( showWarning ) { @@ -2699,40 +2701,40 @@ QString MainWindow::sentSyncFile() { #ifdef DESKTOP_VERSION return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); #else return QString( "/tmp/copysynccal.ics" ); #endif } -void MainWindow::syncFileRequest() +void MainWindow::syncFileRequest(const QString& resource) { while ( mSyncManager->blockSave() ) { qApp->processEvents(); } mSyncManager->setBlockSave(true); if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { mSyncManager->slotSyncMenu( 999 ); } setCaption(i18n("Saving Data to temp file ..." )); - mView->saveCalendar( sentSyncFile() ); + mView->saveCalendarResource( sentSyncFile(), resource ); setCaption(i18n("Data saved to temp file!" )); mSyncManager->setBlockSave( false ); } -void MainWindow::getFile( bool success ) +void MainWindow::getFile( bool success ,const QString& resource) { if ( ! success ) { setCaption( i18n("Error receiving file. Nothing changed!") ); return; } - mView->mergeFile( sentSyncFile() ); + mView->mergeFileResource( sentSyncFile(), resource); if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { mSyncManager->slotSyncMenu( 999 ); } setCaption( i18n("Pi-Sync successful!") ); } void MainWindow::printListView() { diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index d8018b6..a533d8b 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -105,18 +105,18 @@ class MainWindow : public QMainWindow void toggleBeamReceive(); void disableBR(bool); signals: void selectWeek ( int ); private slots: void slotResetFocus(); void slotResetFocusLoop(); void showConfigureAgenda(); - void getFile( bool ); - void syncFileRequest(); + void getFile( bool ,const QString &); + void syncFileRequest(const QString &); protected: int mFocusLoop; void hideEvent ( QHideEvent * ); QString sentSyncFile(); void displayText( QString, QString); void enableIncidenceActions( bool ); bool askForQuitOnSaveError(); diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 4b8b3ff..0a94914 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -74,16 +74,17 @@ public: Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; virtual void addCalendar( Calendar* ) = 0; virtual bool addCalendarFile( QString name, int id ) = 0; virtual bool mergeCalendarFile( QString name ) = 0; virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; virtual void setSyncEventsReadOnly() = 0; + virtual void setSyncEventsEnabled() = 0; virtual void stopAllTodos() = 0; virtual void clearUndo( Incidence * newUndo ); /** Sync changes in memory to persistant storage. */ virtual void save() = 0; virtual QPtrList<Event> getExternLastSyncEvents() = 0; diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 0ddfeca..45e3128 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -168,23 +168,35 @@ bool CalendarLocal::addCalendarFile( QString name, int id ) CalendarLocal calendar( timeZoneId() ); calendar.setDefaultCalendar( id ); if ( calendar.load( name ) ) { addCalendar( &calendar ); return true; } return false; } -void CalendarLocal::setSyncEventsReadOnly() +void CalendarLocal::setSyncEventsEnabled() { Event * ev; ev = mEventList.first(); while ( ev ) { if ( ev->uid().left(15) == QString("last-syncEvent-") ) - ev->setReadOnly( true ); + ev->setCalEnabled( true ); + ev = mEventList.next(); + } +} +void CalendarLocal::setSyncEventsReadOnly() +{ + Event * ev; + ev = mEventList.first(); + while ( ev ) { + if ( ev->uid().left(15) == QString("last-syncEvent-") ) { + ev->setReadOnly( true ); + ev->setCalID( 1 ); + } ev = mEventList.next(); } } void CalendarLocal::addCalendar( Calendar* cal ) { cal->setDontDeleteIncidencesOnClose(); { QPtrList<Event> EventList = cal->rawEvents(); diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index ca0bd98..eb7bf34 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -44,16 +44,17 @@ class CalendarLocal : public Calendar CalendarLocal( const QString &timeZoneId ); ~CalendarLocal(); void addCalendar( Calendar* ); bool addCalendarFile( QString name, int id ); bool mergeCalendarFile( QString name ); bool mergeCalendar( Calendar* cal ); Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); void setSyncEventsReadOnly(); + void setSyncEventsEnabled(); void stopAllTodos(); /** Loads a calendar on disk in vCalendar or iCalendar format into the current calendar. Any information already present is lost. @return true, if successfull, false on error. @param fileName the name of the calendar on disk. */ bool load( const QString &fileName ); diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp index a64eb34..719d80b 100644 --- a/libkdepim/ksyncmanager.cpp +++ b/libkdepim/ksyncmanager.cpp @@ -191,17 +191,18 @@ void KSyncManager::slotClearMenu( int action ) 0, 1 ); if ( result ) return; mImplementation->removeSyncInfo( syncDevice ); } void KSyncManager::slotSyncMenu( int action ) { qDebug("KSM::syncaction %d ", action); - mCurrentResourceLocal = ""; + mCurrentResourceLocal = ""; + emit multiResourceSyncStart( false ); if ( action == 5000 ) return; mSyncWithDesktop = false; 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 @@ -436,16 +437,18 @@ void KSyncManager::enableQuick( bool ask ) return; } mPrefs->mPassiveSyncAutoStart = autoStart; if ( changed ) { mPrefs->writeConfig(); } connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); + connect( mServerSocket, SIGNAL ( request_file(const QString &) ),this, SIGNAL ( request_file(const QString &) ) ); + connect( mServerSocket, SIGNAL ( file_received( bool ,const QString &) ), this, SIGNAL ( getFile( bool,const QString & ) ) ); } void KSyncManager::displayErrorPort() { KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); } void KSyncManager::syncLocalFile() { @@ -564,17 +567,17 @@ void KSyncManager::multiSync( bool askforPrefs ) 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() { - + emit multiResourceSyncStart( false ); int syncedProfiles = 0; unsigned int i; QTime timer; KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); QStringList syncProfileNames = mSyncProfileNames; KSyncProfile* temp = new KSyncProfile (); mAskForPreferences = false; mCurrentResourceLocal = ""; @@ -1135,17 +1138,20 @@ void KSyncManager::syncPi() mPisyncFinished = true; return; } mCurrentResourceLocal = ""; mCurrentResourceRemote = ""; if ( mSpecificResources.count() ) { int startLocal = 0; int startRemote = mSpecificResources.count()/2; + emit multiResourceSyncStart( true ); while ( startLocal < mSpecificResources.count()/2 ) { + if ( startLocal+1 >= mSpecificResources.count()/2 ) + emit multiResourceSyncStart( false ); mPisyncFinished = false; mCurrentResourceLocal = mSpecificResources[ startLocal ]; mCurrentResourceRemote = mSpecificResources[ startRemote ]; KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); commandSocket->readFile( syncFileName() ); while ( !mPisyncFinished ) { //qDebug("waiting "); @@ -1214,17 +1220,17 @@ void KSyncManager::readFileFromSocket() { QString fileName = syncFileName(); bool syncOK = true; mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); if ( ! syncWithFile( fileName , true ) ) { mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); syncOK = false; } - KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); + KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote,mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); if ( mWriteBackFile && syncOK ) { mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); commandSocket->writeFile( fileName ); } else { commandSocket->sendStop(); if ( syncOK ) @@ -1278,43 +1284,46 @@ void KServerSocket::readClient() qDebug("ERROR::KSS::readClient(): mSocket == 0 "); return; } if ( mErrorMessage ) { mErrorMessage = 999; error_connect("ERROR_ED\r\n\r\n"); return; } + mResource = ""; mErrorMessage = 0; //qDebug("KServerSocket::readClient()"); if ( mSocket->canReadLine() ) { QString line = mSocket->readLine(); //qDebug("KServerSocket readline: %s ", line.latin1()); QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) { //emit sendFile( mSocket ); bool ok = false; QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); if ( ok ) { KSyncManager::mRequestedSyncEvent = dt; } else KSyncManager::mRequestedSyncEvent = QDateTime(); + mResource =tokens[3]; send_file(); } else { mErrorMessage = 1; error_connect("ERROR_PW\r\n\r\n"); } } if ( tokens[0] == "PUT" ) { if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); blockRC = true; + mResource =tokens[2]; get_file(); } else { mErrorMessage = 2; error_connect("ERROR_PW\r\n\r\n"); end_connect(); } } @@ -1401,16 +1410,17 @@ void KServerSocket::send_file() } } else { mSyncActionDialog->setFixedSize( 230, 120); } } else mSyncActionDialog->setFixedSize( 230, 120); mSyncActionDialog->show(); mSyncActionDialog->raise(); + emit request_file(mResource); emit request_file(); qApp->processEvents(); QString fileName = mFileName; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { mErrorMessage = 0; end_connect(); error_connect("ERROR_FI\r\n\r\n"); @@ -1462,33 +1472,35 @@ void KServerSocket::readBackFileFromSocket() } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("KSS:Error open read back file "); piFileString = ""; - emit file_received( false ); + emit file_received( false, mResource); + emit file_received( false); blockRC = false; return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setEncoding( QTextStream::Latin1 ); mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); ts << piFileString; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); piFileString = ""; - emit file_received( true ); + emit file_received( true, mResource ); + emit file_received( true); delete mSyncActionDialog; mSyncActionDialog = 0; blockRC = false; } KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) { @@ -1591,17 +1603,17 @@ void KCommandSocket::writeFileToSocket() int count = 0; mConnectProgress.setLabelText( i18n("Sending back synced file...") ); mConnectProgress.setProgress( count ); mConnectProgress.blockSignals( true ); QTextStream ts2( &file2 ); ts2.setEncoding( QTextStream::Latin1 ); QTextStream os2( mSocket ); os2.setEncoding( QTextStream::Latin1 ); - os2 << "PUT " << mPassWord << "\r\n\r\n";; + os2 << "PUT " << mPassWord << mRemoteResource << "\r\n\r\n";; int byteCount = 0; int byteMax = file2.size()/53; while ( ! ts2.atEnd() ) { qApp->processEvents(); if ( byteCount > byteMax ) { byteCount = 0; mConnectProgress.setProgress( count ); } diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h index f4654ce..53c611d 100644 --- a/libkdepim/ksyncmanager.h +++ b/libkdepim/ksyncmanager.h @@ -48,25 +48,28 @@ class KServerSocket : public QServerSocket public: KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); void newConnection ( int socket ) ; void setFileName( QString fn ) {mFileName = fn;}; signals: void file_received( bool ); void request_file(); + void file_received( bool, const QString &); + void request_file(const QString &); void saveFile(); void endConnect(); private slots: void discardClient(); void deleteSocket(); void readClient(); void displayErrorMessage(); void readBackFileFromSocket(); private : + QString mResource; int mErrorMessage; bool blockRC; void send_file(); void get_file(); void end_connect(); void error_connect( QString ); QDialog* mSyncActionDialog; QSocket* mSocket; @@ -169,16 +172,19 @@ class KSyncManager : public QObject QString mFilterInAB; QString mFilterOutAB; static QDateTime mRequestedSyncEvent; signals: void save(); void request_file(); void getFile( bool ); + void getFile( bool, const QString &); + void request_file(const QString &); + void multiResourceSyncStart( bool ); public slots: void slotSyncMenu( int ); void slotClearMenu( int action ); void deleteCommandSocket(KCommandSocket*s, int state); void readFileFromSocket(); void fillSyncMenu(); |