summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-17 14:32:16 (UTC)
committer zautrix <zautrix>2004-10-17 14:32:16 (UTC)
commit780a12295cbbcf4eff4f9570322c1cac517414ad (patch) (unidiff)
tree4c68b7e6ee854f9d4f0e7e3032f7c70cc45668be
parentf909868a098a22c17906f3d2ab05d5fac0332e85 (diff)
downloadkdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.zip
kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.tar.gz
kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.tar.bz2
many kde sync fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--kde2file/caldump/main.cpp97
-rw-r--r--libkdepim/ksyncmanager.cpp7
3 files changed, 73 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 93437e6..4d562fe 100644
--- a/Makefile
+++ b/Makefile
@@ -2,3 +2,3 @@
2# Makefile for building: kdepim-desktop 2# Makefile for building: kdepim-desktop
3# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 16 22:32:03 2004 3# Generated by qmake (1.07a) (Qt 3.3.3) on: Sun Oct 17 11:53:22 2004
4# Project: kdepim-desktop.pro 4# Project: kdepim-desktop.pro
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp
index 76bfad3..8d81307 100644
--- a/kde2file/caldump/main.cpp
+++ b/kde2file/caldump/main.cpp
@@ -56,2 +56,3 @@
56#include <qfile.h> 56#include <qfile.h>
57#include <qdir.h>
57 58
@@ -107,6 +108,9 @@ int main( int argc, char *argv[] )
107 } 108 }
109 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
108 CalendarResources *calendarResource = 0; 110 CalendarResources *calendarResource = 0;
109 CalendarLocal *localCalendar = 0; 111 CalendarLocal *localCalendar = 0;
110 112 KConfig c( locate( "config", "korganizerrc" ) );
111 calendarResource = new CalendarResources( "" ); 113 c.setGroup( "Time & Date" );
114 QString tz = c.readEntry( "TimeZoneId" );
115 calendarResource = new CalendarResources( tz );
112 calendarResource->readConfig(); 116 calendarResource->readConfig();
@@ -114,3 +118,3 @@ int main( int argc, char *argv[] )
114 qDebug("************************************* "); 118 qDebug("************************************* ");
115 qDebug("************************************* "); 119 qDebug("**************kdecaldump************* ");
116 qDebug("************************************* "); 120 qDebug("************************************* ");
@@ -140,3 +144,3 @@ int main( int argc, char *argv[] )
140 FileStorage* storage = new FileStorage( calendarResource ); 144 FileStorage* storage = new FileStorage( calendarResource );
141 storage->setFileName( "/tmp/kdedumpall.ics" ); 145 storage->setFileName( fileName );
142 storage->setSaveFormat( new ICalFormat() ); 146 storage->setSaveFormat( new ICalFormat() );
@@ -145,5 +149,5 @@ int main( int argc, char *argv[] )
145 qDebug("************************************* "); 149 qDebug("************************************* ");
150 qDebug("************kdecaldump*************** ");
146 qDebug("************************************* "); 151 qDebug("************************************* ");
147 qDebug("************************************* "); 152 qDebug("%d calendar entries dumped to file %s", num, fileName.latin1());
148 qDebug("%d calendar entries dumped to file /tmp/kdedumpall.ics", num);
149 153
@@ -153,33 +157,66 @@ int main( int argc, char *argv[] )
153 FileStorage* storage = new FileStorage( localCalendar ); 157 FileStorage* storage = new FileStorage( localCalendar );
154 storage->setFileName( "/tmp/kdedumpall.ics" ); 158 storage->setFileName( fileName );
155 int num = 0; 159 int num = 0;
156 int del = 0; 160 int del = 0;
161 int add = 0;
157 if ( storage->load() ) { 162 if ( storage->load() ) {
158 KCal::Incidence::List allInc = calendarResource->rawIncidences();
159 KCal::Incidence::List newInc = localCalendar->rawIncidences(); 163 KCal::Incidence::List newInc = localCalendar->rawIncidences();
160 Incidence::List::ConstIterator it; 164 Incidence::List::ConstIterator it;
161 for( it = allInc.begin(); it != allInc.end(); ++it ) { 165 for( it = newInc.begin(); it != newInc.end(); ++it ) {
162 ResourceCalendar * re = calendarResource->resource( (*it) ); 166 Incidence* cl = (*it)->clone();
163 if ( re && !re->readOnly() ) { 167 Incidence *incOld = calendarResource->incidence( cl->uid() );
164 Incidence* cl = localCalendar->incidence( (*it)->uid() ); 168 ResourceCalendar * res = 0;
165 if ( cl ) { 169 if ( incOld )
166 QDateTime lm = cl->lastModified(); 170 res = calendarResource->resource( incOld );
167 cl->setResources( (*it)->resources() ); 171 if ( res ) {
168 cl->setLastModified(lm); 172 ++num;
169 } 173 if ( incOld->type() == "Journal" )
170 ++del; 174 calendarResource->deleteJournal( (Journal *) incOld );
171 cl = (*it); 175 else if ( incOld->type() == "Todo" )
176 calendarResource->deleteTodo( (Todo *) incOld );
177 else if ( incOld->type() == "Event" )
178 calendarResource->deleteEvent( (Event *) incOld );
179
172 if ( cl->type() == "Journal" ) 180 if ( cl->type() == "Journal" )
173 calendarResource->deleteJournal( (Journal *) cl ); 181 calendarResource->addJournal( (Journal *) cl, res );
174 else if ( cl->type() == "Todo" ) 182 else if ( cl->type() == "Todo" )
175 calendarResource->deleteTodo( (Todo *) cl ); 183 calendarResource->addTodo( (Todo *) cl, res );
176 else if ( cl->type() == "Event" ) 184 else if ( cl->type() == "Event" )
177 calendarResource->deleteEvent( (Event *) cl ); 185 calendarResource->addEvent( (Event *) cl, res );
186
187 } else {
188 if ( incOld ) {
189 qDebug("ERROR: no resource found for old incidence ");
190 if ( incOld->type() == "Journal" )
191 calendarResource->deleteJournal( (Journal *) incOld );
192 else if ( incOld->type() == "Todo" )
193 calendarResource->deleteTodo( (Todo *) incOld );
194 else if ( incOld->type() == "Event" )
195 calendarResource->deleteEvent( (Event *) incOld );
196
197 }
198 calendarResource->addIncidence( cl );
199 ++add;
200 }
201 KCal::Incidence::List allInc = calendarResource->rawIncidences();
202
203 for( it = allInc.begin(); it != allInc.end(); ++it ) {
204 ResourceCalendar * re = calendarResource->resource( (*it) );
205 if ( re && !re->readOnly() ) {
206 Incidence* cl = localCalendar->incidence( (*it)->uid() );
207 if ( !cl ) {
208 ++del;
209 cl = (*it);
210 if ( cl->type() == "Journal" )
211 calendarResource->deleteJournal( (Journal *) cl );
212 else if ( cl->type() == "Todo" )
213 calendarResource->deleteTodo( (Todo *) cl );
214 else if ( cl->type() == "Event" )
215 calendarResource->deleteEvent( (Event *) cl );
216 //QDateTime lm = cl->lastModified();
217 //cl->setResources( (*it)->resources() );
218 //cl->setLastModified(lm);
219 }
220 }
178 } 221 }
179 }
180 for( it = newInc.begin(); it != newInc.end(); ++it ) {
181 Incidence* cl = (*it)->clone();
182 ++num;
183 calendarResource->addIncidence( cl );
184 //cl->setLastModified( (*it)->lastModified() );
185 } 222 }
@@ -187,5 +224,5 @@ int main( int argc, char *argv[] )
187 qDebug("************************************* "); 224 qDebug("************************************* ");
225 qDebug("************kdecaldump*************** ");
188 qDebug("************************************* "); 226 qDebug("************************************* ");
189 qDebug("************************************* "); 227 qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1());
190 qDebug("%d calendar entries deleted/ %d added from file /tmp/kdedumpall.ics", del, num);
191 228
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index c6e06f8..8851097 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -783,5 +783,8 @@ void KSyncManager::syncKDE()
783 { 783 {
784 QString command ="./kdecaldump"; 784 QString command = qApp->applicationDirPath () + "/kdecaldump";
785 if ( ! QFile::exists ( command ) )
786 command = "kdecaldump";
787 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
785 system ( command.latin1()); 788 system ( command.latin1());
786 if ( syncWithFile( "/tmp/kdedumpall.ics",true ) ) { 789 if ( syncWithFile( fileName,true ) ) {
787 if ( mWriteBackFile ) { 790 if ( mWriteBackFile ) {