summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-17 14:32:16 (UTC)
committer zautrix <zautrix>2004-10-17 14:32:16 (UTC)
commit780a12295cbbcf4eff4f9570322c1cac517414ad (patch) (side-by-side diff)
tree4c68b7e6ee854f9d4f0e7e3032f7c70cc45668be
parentf909868a098a22c17906f3d2ab05d5fac0332e85 (diff)
downloadkdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.zip
kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.tar.gz
kdepimpi-780a12295cbbcf4eff4f9570322c1cac517414ad.tar.bz2
many kde sync fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--kde2file/caldump/main.cpp77
-rw-r--r--libkdepim/ksyncmanager.cpp7
3 files changed, 63 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 93437e6..4d562fe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,15 @@
#############################################################################
# Makefile for building: kdepim-desktop
-# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 16 22:32:03 2004
+# Generated by qmake (1.07a) (Qt 3.3.3) on: Sun Oct 17 11:53:22 2004
# Project: kdepim-desktop.pro
# Template: subdirs
# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kdepim-desktop.pro
#############################################################################
MAKEFILE = Makefile
QMAKE = qmake
DEL_FILE = rm -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
INSTALL_FILE=
INSTALL_DIR =
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
@@ -45,24 +45,25 @@
#include <kconfig.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <libkcal/calformat.h>
#include <libkcal/calendarresources.h>
#include <libkcal/resourcelocal.h>
#include <libkcal/filestorage.h>
#include <libkcal/icalformat.h>
#include <qdatetime.h>
#include <qfile.h>
+#include <qdir.h>
#include <stdlib.h>
#include <iostream>
using namespace KCal;
using namespace std;
static const char progName[] = "kdecalendar";
static const char progDisplay[] = "KDE_Calendar";
static const char progVersion[] = "33.1/3";
static const char progDesc[] = "A command line interface to KDE calendars";
@@ -96,32 +97,35 @@ int main( int argc, char *argv[] )
KCmdLineArgs::init( argc, argv, &aboutData, true );
KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
KInstance ins ( progName );
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
bool read = false;
if ( args->isSet( "read" ) ) {
read = true;
qDebug("read ");
}
+ QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
CalendarResources *calendarResource = 0;
CalendarLocal *localCalendar = 0;
-
- calendarResource = new CalendarResources( "" );
+ KConfig c( locate( "config", "korganizerrc" ) );
+ c.setGroup( "Time & Date" );
+ QString tz = c.readEntry( "TimeZoneId" );
+ calendarResource = new CalendarResources( tz );
calendarResource->readConfig();
calendarResource->load();
qDebug("************************************* ");
- qDebug("************************************* ");
+ qDebug("**************kdecaldump************* ");
qDebug("************************************* ");
qDebug("Using timezone id: %s", calendarResource->timeZoneId().latin1());
if ( !read ) {
localCalendar = new CalendarLocal();
localCalendar->setTimeZoneId( calendarResource->timeZoneId());
KCal::Incidence::List allInc = calendarResource->rawIncidences();
Incidence::List::ConstIterator it;
int num = 0;
for( it = allInc.begin(); it != allInc.end(); ++it ) {
ResourceCalendar * re = calendarResource->resource( (*it) );
if ( re && !re->readOnly() ) {
@@ -129,74 +133,107 @@ int main( int argc, char *argv[] )
Incidence* cl = (*it)->clone();
cl->setLastModified( (*it)->lastModified() );
if ( cl->type() == "Journal" )
localCalendar->addJournal( (Journal *) cl );
else if ( cl->type() == "Todo" )
localCalendar->addTodo( (Todo *) cl );
else if ( cl->type() == "Event" )
localCalendar->addEvent( (Event *) cl );
}
}
FileStorage* storage = new FileStorage( calendarResource );
- storage->setFileName( "/tmp/kdedumpall.ics" );
+ storage->setFileName( fileName );
storage->setSaveFormat( new ICalFormat() );
storage->save();
delete storage;
qDebug("************************************* ");
+ qDebug("************kdecaldump*************** ");
qDebug("************************************* ");
- qDebug("************************************* ");
- qDebug("%d calendar entries dumped to file /tmp/kdedumpall.ics", num);
+ qDebug("%d calendar entries dumped to file %s", num, fileName.latin1());
} else {
localCalendar = new CalendarLocal();
localCalendar->setTimeZoneId( calendarResource->timeZoneId());
FileStorage* storage = new FileStorage( localCalendar );
- storage->setFileName( "/tmp/kdedumpall.ics" );
+ storage->setFileName( fileName );
int num = 0;
int del = 0;
+ int add = 0;
if ( storage->load() ) {
- KCal::Incidence::List allInc = calendarResource->rawIncidences();
KCal::Incidence::List newInc = localCalendar->rawIncidences();
Incidence::List::ConstIterator it;
+ for( it = newInc.begin(); it != newInc.end(); ++it ) {
+ Incidence* cl = (*it)->clone();
+ Incidence *incOld = calendarResource->incidence( cl->uid() );
+ ResourceCalendar * res = 0;
+ if ( incOld )
+ res = calendarResource->resource( incOld );
+ if ( res ) {
+ ++num;
+ if ( incOld->type() == "Journal" )
+ calendarResource->deleteJournal( (Journal *) incOld );
+ else if ( incOld->type() == "Todo" )
+ calendarResource->deleteTodo( (Todo *) incOld );
+ else if ( incOld->type() == "Event" )
+ calendarResource->deleteEvent( (Event *) incOld );
+
+ if ( cl->type() == "Journal" )
+ calendarResource->addJournal( (Journal *) cl, res );
+ else if ( cl->type() == "Todo" )
+ calendarResource->addTodo( (Todo *) cl, res );
+ else if ( cl->type() == "Event" )
+ calendarResource->addEvent( (Event *) cl, res );
+
+ } else {
+ if ( incOld ) {
+ qDebug("ERROR: no resource found for old incidence ");
+ if ( incOld->type() == "Journal" )
+ calendarResource->deleteJournal( (Journal *) incOld );
+ else if ( incOld->type() == "Todo" )
+ calendarResource->deleteTodo( (Todo *) incOld );
+ else if ( incOld->type() == "Event" )
+ calendarResource->deleteEvent( (Event *) incOld );
+
+ }
+ calendarResource->addIncidence( cl );
+ ++add;
+ }
+ KCal::Incidence::List allInc = calendarResource->rawIncidences();
+
for( it = allInc.begin(); it != allInc.end(); ++it ) {
ResourceCalendar * re = calendarResource->resource( (*it) );
if ( re && !re->readOnly() ) {
Incidence* cl = localCalendar->incidence( (*it)->uid() );
- if ( cl ) {
- QDateTime lm = cl->lastModified();
- cl->setResources( (*it)->resources() );
- cl->setLastModified(lm);
- }
+ if ( !cl ) {
++del;
cl = (*it);
if ( cl->type() == "Journal" )
calendarResource->deleteJournal( (Journal *) cl );
else if ( cl->type() == "Todo" )
calendarResource->deleteTodo( (Todo *) cl );
else if ( cl->type() == "Event" )
calendarResource->deleteEvent( (Event *) cl );
+ //QDateTime lm = cl->lastModified();
+ //cl->setResources( (*it)->resources() );
+ //cl->setLastModified(lm);
+ }
}
}
- for( it = newInc.begin(); it != newInc.end(); ++it ) {
- Incidence* cl = (*it)->clone();
- ++num;
- calendarResource->addIncidence( cl );
- //cl->setLastModified( (*it)->lastModified() );
}
calendarResource->save();
qDebug("************************************* ");
+ qDebug("************kdecaldump*************** ");
qDebug("************************************* ");
- qDebug("************************************* ");
- qDebug("%d calendar entries deleted/ %d added from file /tmp/kdedumpall.ics", del, num);
+ qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1());
} else
qDebug("error loading file /tmp/kdedumpall.ics");
}
if ( localCalendar ) {
localCalendar->close();
delete localCalendar;
}
if ( calendarResource ) {
calendarResource->close();
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index c6e06f8..8851097 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -772,27 +772,30 @@ void KSyncManager::confSync()
QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
}
void KSyncManager::syncKDE()
{
emit save();
switch(mTargetApp)
{
case (KAPI):
break;
case (KOPI):
{
- QString command ="./kdecaldump";
+ QString command = qApp->applicationDirPath () + "/kdecaldump";
+ if ( ! QFile::exists ( command ) )
+ command = "kdecaldump";
+ QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
system ( command.latin1());
- if ( syncWithFile( "/tmp/kdedumpall.ics",true ) ) {
+ if ( syncWithFile( fileName,true ) ) {
if ( mWriteBackFile ) {
command += " --read";
system ( command.latin1());
}
}
}
break;
case (PWMPI):
break;
default: