summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp3
-rw-r--r--libkdepim/ksyncmanager.cpp2
2 files changed, 3 insertions, 2 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 2a57724..c33581c 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -114,193 +114,194 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
114 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 114 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
115 if ( it->uid() == uid ) { 115 if ( it->uid() == uid ) {
116 if ( doNotCheckDuplicates ) return it; 116 if ( doNotCheckDuplicates ) return it;
117 if ( retVal ) { 117 if ( retVal ) {
118 if ( retVal->calID() > it->calID() ) { 118 if ( retVal->calID() > it->calID() ) {
119 retVal = it; 119 retVal = it;
120 } 120 }
121 } else { 121 } else {
122 retVal = it; 122 retVal = it;
123 } 123 }
124 } 124 }
125 return retVal; 125 return retVal;
126} 126}
127 127
128bool CalendarLocal::mergeCalendar( Calendar* remote ) 128bool CalendarLocal::mergeCalendar( Calendar* remote )
129{ 129{
130 // 1 look for raw inc in local 130 // 1 look for raw inc in local
131 // if inc not in remote, delete in local 131 // if inc not in remote, delete in local
132 // 2 look for raw inc in remote 132 // 2 look for raw inc in remote
133 // if inc in local, replace it 133 // if inc in local, replace it
134 // if not in local, add it to default calendar 134 // if not in local, add it to default calendar
135 QPtrList<Incidence> localInc = rawIncidences(); 135 QPtrList<Incidence> localInc = rawIncidences();
136 Incidence* inL = localInc.first(); 136 Incidence* inL = localInc.first();
137 while ( inL ) { 137 while ( inL ) {
138 if ( ! inL->isReadOnly () ) 138 if ( ! inL->isReadOnly () )
139 if ( !remote->incidenceForUid( inL->uid(), true )) 139 if ( !remote->incidenceForUid( inL->uid(), true ))
140 deleteIncidence( inL ); 140 deleteIncidence( inL );
141 inL = localInc.next(); 141 inL = localInc.next();
142 } 142 }
143 QPtrList<Incidence> er = remote->rawIncidences(); 143 QPtrList<Incidence> er = remote->rawIncidences();
144 Incidence* inR = er.first(); 144 Incidence* inR = er.first();
145 while ( inR ) { 145 while ( inR ) {
146 inL = incidenceForUid( inR->uid(),false ); 146 inL = incidenceForUid( inR->uid(),false );
147 if ( inL ) { 147 if ( inL ) {
148 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { 148 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) {
149 int calID = inL->calID(); 149 int calID = inL->calID();
150 deleteIncidence( inL ); 150 deleteIncidence( inL );
151 inL = inR->clone(); 151 inL = inR->clone();
152 inL->setCalID( calID ); 152 inL->setCalID( calID );
153 addIncidence( inL ); 153 addIncidence( inL );
154 } 154 }
155 } else { 155 } else {
156 inL = inR->clone(); 156 inL = inR->clone();
157 inL->setCalID( 0 );// add to default cal 157 inL->setCalID( 0 );// add to default cal
158 addIncidence( inL ); 158 addIncidence( inL );
159 } 159 }
160 inR = er.next(); 160 inR = er.next();
161 } 161 }
162 return true; 162 return true;
163} 163}
164 164
165 165
166bool CalendarLocal::addCalendarFile( QString name, int id ) 166bool CalendarLocal::addCalendarFile( QString name, int id )
167{ 167{
168 CalendarLocal calendar( timeZoneId() ); 168 CalendarLocal calendar( timeZoneId() );
169 calendar.setDefaultCalendar( id ); 169 calendar.setDefaultCalendar( id );
170 if ( calendar.load( name ) ) { 170 if ( calendar.load( name ) ) {
171 addCalendar( &calendar ); 171 addCalendar( &calendar );
172 return true; 172 return true;
173 } 173 }
174 return false; 174 return false;
175} 175}
176void CalendarLocal::setSyncEventsEnabled() 176void CalendarLocal::setSyncEventsEnabled()
177{ 177{
178 Event * ev; 178 Event * ev;
179 ev = mEventList.first(); 179 ev = mEventList.first();
180 while ( ev ) { 180 while ( ev ) {
181 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 181 if ( ev->uid().left(15) == QString("last-syncEvent-") )
182 ev->setCalEnabled( true ); 182 ev->setCalEnabled( true );
183 ev = mEventList.next(); 183 ev = mEventList.next();
184 } 184 }
185} 185}
186void CalendarLocal::setSyncEventsReadOnly() 186void CalendarLocal::setSyncEventsReadOnly()
187{ 187{
188 Event * ev; 188 Event * ev;
189 ev = mEventList.first(); 189 ev = mEventList.first();
190 while ( ev ) { 190 while ( ev ) {
191 if ( ev->uid().left(15) == QString("last-syncEvent-") ) { 191 if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
192 ev->setReadOnly( true ); 192 ev->setReadOnly( true );
193 } 193 }
194 ev = mEventList.next(); 194 ev = mEventList.next();
195 } 195 }
196} 196}
197 197
198void CalendarLocal::addCalendar( Calendar* cal ) 198void CalendarLocal::addCalendar( Calendar* cal )
199{ 199{
200 cal->setDontDeleteIncidencesOnClose(); 200 cal->setDontDeleteIncidencesOnClose();
201 setSyncEventsEnabled(); 201 setSyncEventsEnabled();
202 { 202 {
203 QPtrList<Event> EventList = cal->rawEvents(); 203 QPtrList<Event> EventList = cal->rawEvents();
204 QPtrList<Event> el; 204 QPtrList<Event> el;
205 Event * ev = EventList.first(); 205 Event * ev = EventList.first();
206 while ( ev ) { 206 while ( ev ) {
207 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { 207 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
208 Event * se = event( ev->uid() ); 208 Event * se = event( ev->uid() );
209 if ( se ) 209 if ( se )
210 el.append( se ); 210 el.append( se );
211 ev->setCalID( 1 );
211 } 212 }
212 ev->unRegisterObserver( cal ); 213 ev->unRegisterObserver( cal );
213 ev->registerObserver( this ); 214 ev->registerObserver( this );
214 mEventList.append( ev ); 215 mEventList.append( ev );
215 ev = EventList.next(); 216 ev = EventList.next();
216 } 217 }
217 for ( ev = el.first(); ev; ev = el.next() ) { 218 for ( ev = el.first(); ev; ev = el.next() ) {
218 deleteIncidence ( ev ); 219 deleteIncidence ( ev );
219 } 220 }
220 } 221 }
221 { 222 {
222 223
223 QPtrList<Todo> TodoList = cal->rawTodos(); 224 QPtrList<Todo> TodoList = cal->rawTodos();
224 Todo * ev = TodoList.first(); 225 Todo * ev = TodoList.first();
225 while ( ev ) { 226 while ( ev ) {
226 QString rel = ev->relatedToUid(); 227 QString rel = ev->relatedToUid();
227 if ( !rel.isEmpty() ){ 228 if ( !rel.isEmpty() ){
228 ev->setRelatedTo ( 0 ); 229 ev->setRelatedTo ( 0 );
229 ev->setRelatedToUid( rel ); 230 ev->setRelatedToUid( rel );
230 } 231 }
231 ev = TodoList.next(); 232 ev = TodoList.next();
232 } 233 }
233 //TodoList = cal->rawTodos(); 234 //TodoList = cal->rawTodos();
234 ev = TodoList.first(); 235 ev = TodoList.first();
235 while ( ev ) { 236 while ( ev ) {
236 ev->unRegisterObserver( cal ); 237 ev->unRegisterObserver( cal );
237 ev->registerObserver( this ); 238 ev->registerObserver( this );
238 mTodoList.append( ev ); 239 mTodoList.append( ev );
239 setupRelations( ev ); 240 setupRelations( ev );
240 ev = TodoList.next(); 241 ev = TodoList.next();
241 } 242 }
242 } 243 }
243 { 244 {
244 QPtrList<Journal> JournalList = cal->journals(); 245 QPtrList<Journal> JournalList = cal->journals();
245 Journal * ev = JournalList.first(); 246 Journal * ev = JournalList.first();
246 while ( ev ) { 247 while ( ev ) {
247 ev->unRegisterObserver( cal ); 248 ev->unRegisterObserver( cal );
248 ev->registerObserver( this ); 249 ev->registerObserver( this );
249 mJournalList.append( ev ); 250 mJournalList.append( ev );
250 ev = JournalList.next(); 251 ev = JournalList.next();
251 } 252 }
252 } 253 }
253 setModified( true ); 254 setModified( true );
254} 255}
255bool CalendarLocal::load( const QString &fileName ) 256bool CalendarLocal::load( const QString &fileName )
256{ 257{
257 FileStorage storage( this, fileName ); 258 FileStorage storage( this, fileName );
258 return storage.load(); 259 return storage.load();
259} 260}
260 261
261bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 262bool CalendarLocal::save( const QString &fileName, CalFormat *format )
262{ 263{
263 FileStorage storage( this, fileName, format ); 264 FileStorage storage( this, fileName, format );
264 return storage.save(); 265 return storage.save();
265} 266}
266 267
267void CalendarLocal::stopAllTodos() 268void CalendarLocal::stopAllTodos()
268{ 269{
269 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 270 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
270 it->setRunning( false ); 271 it->setRunning( false );
271 272
272} 273}
273void CalendarLocal::close() 274void CalendarLocal::close()
274{ 275{
275 276
276 Todo * i; 277 Todo * i;
277 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 278 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
278 279
279 mEventList.setAutoDelete( true ); 280 mEventList.setAutoDelete( true );
280 mTodoList.setAutoDelete( true ); 281 mTodoList.setAutoDelete( true );
281 mJournalList.setAutoDelete( true ); 282 mJournalList.setAutoDelete( true );
282 283
283 mEventList.clear(); 284 mEventList.clear();
284 mTodoList.clear(); 285 mTodoList.clear();
285 mJournalList.clear(); 286 mJournalList.clear();
286 287
287 mEventList.setAutoDelete( false ); 288 mEventList.setAutoDelete( false );
288 mTodoList.setAutoDelete( false ); 289 mTodoList.setAutoDelete( false );
289 mJournalList.setAutoDelete( false ); 290 mJournalList.setAutoDelete( false );
290 291
291 setModified( false ); 292 setModified( false );
292} 293}
293 294
294bool CalendarLocal::addAnniversaryNoDup( Event *event ) 295bool CalendarLocal::addAnniversaryNoDup( Event *event )
295{ 296{
296 QString cat; 297 QString cat;
297 bool isBirthday = true; 298 bool isBirthday = true;
298 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 299 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
299 isBirthday = false; 300 isBirthday = false;
300 cat = i18n( "Anniversary" ); 301 cat = i18n( "Anniversary" );
301 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 302 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
302 isBirthday = true; 303 isBirthday = true;
303 cat = i18n( "Birthday" ); 304 cat = i18n( "Birthday" );
304 } else { 305 } else {
305 qDebug("addAnniversaryNoDup called without fitting category! "); 306 qDebug("addAnniversaryNoDup called without fitting category! ");
306 return false; 307 return false;
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d2cb71b..e1b15d2 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1680,99 +1680,99 @@ void KCommandSocket::readFileFromSocket()
1680 while ( mSocket->canReadLine () ) { 1680 while ( mSocket->canReadLine () ) {
1681 mTime.restart(); 1681 mTime.restart();
1682 QString line = mSocket->readLine (); 1682 QString line = mSocket->readLine ();
1683 if ( mFirstLine ) { 1683 if ( mFirstLine ) {
1684 mFirstLine = false; 1684 mFirstLine = false;
1685 if ( line.left( 6 ) == "ERROR_" ) { 1685 if ( line.left( 6 ) == "ERROR_" ) {
1686 mTimerSocket->stop(); 1686 mTimerSocket->stop();
1687 mConnectCount = -1; 1687 mConnectCount = -1;
1688 if ( line.left( 8 ) == "ERROR_PW" ) { 1688 if ( line.left( 8 ) == "ERROR_PW" ) {
1689 mRetVal = errorPW; 1689 mRetVal = errorPW;
1690 deleteSocket(); 1690 deleteSocket();
1691 return ; 1691 return ;
1692 } 1692 }
1693 if ( line.left( 8 ) == "ERROR_CA" ) { 1693 if ( line.left( 8 ) == "ERROR_CA" ) {
1694 mRetVal = errorCA; 1694 mRetVal = errorCA;
1695 deleteSocket(); 1695 deleteSocket();
1696 return ; 1696 return ;
1697 } 1697 }
1698 if ( line.left( 8 ) == "ERROR_FI" ) { 1698 if ( line.left( 8 ) == "ERROR_FI" ) {
1699 mRetVal = errorFI; 1699 mRetVal = errorFI;
1700 deleteSocket(); 1700 deleteSocket();
1701 return ; 1701 return ;
1702 } 1702 }
1703 if ( line.left( 8 ) == "ERROR_ED" ) { 1703 if ( line.left( 8 ) == "ERROR_ED" ) {
1704 mRetVal = errorED; 1704 mRetVal = errorED;
1705 deleteSocket(); 1705 deleteSocket();
1706 return ; 1706 return ;
1707 } 1707 }
1708 mRetVal = errorUN; 1708 mRetVal = errorUN;
1709 deleteSocket(); 1709 deleteSocket();
1710 return ; 1710 return ;
1711 } 1711 }
1712 } 1712 }
1713 mFileString += line; 1713 mFileString += line;
1714 //qDebug("readline: %s ", line.latin1()); 1714 //qDebug("readline: %s ", line.latin1());
1715 } 1715 }
1716 if ( mTime.elapsed () < 3000 ) { 1716 if ( mTime.elapsed () < 3000 ) {
1717 // wait for more 1717 // wait for more
1718 //qDebug("waitformore "); 1718 //qDebug("waitformore ");
1719 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1719 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1720 return; 1720 return;
1721 } 1721 }
1722 mTimerSocket->stop(); 1722 mTimerSocket->stop();
1723 mConnectCount = -1; 1723 mConnectCount = -1;
1724 mConnectProgress.hide(); 1724 mConnectProgress.hide();
1725 QString fileName = mFileName; 1725 QString fileName = mFileName;
1726 QFile file ( fileName ); 1726 QFile file ( fileName );
1727 if (!file.open( IO_WriteOnly ) ) { 1727 if (!file.open( IO_WriteOnly ) ) {
1728 mFileString = ""; 1728 mFileString = "";
1729 mRetVal = errorR; 1729 mRetVal = errorR;
1730 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1730 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1731 deleteSocket(); 1731 deleteSocket();
1732 return ; 1732 return ;
1733 1733
1734 } 1734 }
1735 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1735 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1736 QTextStream ts ( &file ); 1736 QTextStream ts ( &file );
1737 ts.setEncoding( QTextStream::Latin1 ); 1737 ts.setEncoding( QTextStream::Latin1 );
1738 ts << mFileString; 1738 ts << mFileString;
1739 file.close(); 1739 file.close();
1740 mFileString = ""; 1740 mFileString = "";
1741 mRetVal = successR; 1741 mRetVal = successR;
1742 mSocket->close(); 1742 mSocket->close();
1743 // if state is not idle, deleteSocket(); is called via 1743 // if state is not idle, deleteSocket(); is called via
1744 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1744 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1745 if ( mSocket->state() == QSocket::Idle ) 1745 if ( mSocket->state() == QSocket::Idle )
1746 deleteSocket(); 1746 deleteSocket();
1747} 1747}
1748 1748
1749void KCommandSocket::deleteSocket() 1749void KCommandSocket::deleteSocket()
1750{ 1750{
1751 //qDebug("KCommandSocket::deleteSocket() "); 1751 //qDebug("KCommandSocket::deleteSocket() ");
1752 mConnectProgress.hide(); 1752 mConnectProgress.hide();
1753 1753
1754 if ( mConnectCount >= 0 ) { 1754 if ( mConnectCount >= 0 ) {
1755 mTimerSocket->stop(); 1755 mTimerSocket->stop();
1756 mRetVal = errorTO; 1756 mRetVal = errorTO;
1757 qDebug("KCS::Connection to remote host timed out"); 1757 qDebug("KCS::Connection to remote host timed out");
1758 if ( mSocket ) { 1758 if ( mSocket ) {
1759 mSocket->close(); 1759 mSocket->close();
1760 //if ( mSocket->state() == QSocket::Idle ) 1760 //if ( mSocket->state() == QSocket::Idle )
1761 // deleteSocket(); 1761 // deleteSocket();
1762 delete mSocket; 1762 delete mSocket;
1763 mSocket = 0; 1763 mSocket = 0;
1764 } 1764 }
1765 if ( mConnectCount == 0 ) 1765 if ( mConnectCount == 0 )
1766 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1766 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1767 else if ( tlw ) 1767 else if ( tlw )
1768 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1768 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1769 emit commandFinished( this, mRetVal ); 1769 emit commandFinished( this, mRetVal );
1770 return; 1770 return;
1771 } 1771 }
1772 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1772 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1773 if ( mSocket) 1773 if ( mSocket)
1774 delete mSocket; 1774 delete mSocket;
1775 mSocket = 0; 1775 mSocket = 0;
1776 qDebug("commandFinished "); 1776 //qDebug("commandFinished ");
1777 emit commandFinished( this, mRetVal ); 1777 emit commandFinished( this, mRetVal );
1778} 1778}