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) (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
@@ -1,171 +1,171 @@
#############################################################################
# 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 =
SUBTARGETS = \
sub-gammu-emb-common \
sub-gammu-emb-gammu \
sub-libical \
sub-libkcal \
sub-microkde \
sub-libkdepim \
sub-kabc \
sub-korganizer \
sub-kaddressbook \
sub-kabc-plugins-file \
sub-kabc-plugins-dir
first: all
all: Makefile $(SUBTARGETS)
gammu/emb/common/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "gammu/emb/common" || $(MKDIR) "gammu/emb/common"
cd gammu/emb/common && $(QMAKE) common.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-gammu-emb-common: gammu/emb/common/$(MAKEFILE) FORCE
cd gammu/emb/common && $(MAKE) -f $(MAKEFILE)
gammu/emb/gammu/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "gammu/emb/gammu" || $(MKDIR) "gammu/emb/gammu"
cd gammu/emb/gammu && $(QMAKE) gammu.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-gammu-emb-gammu: gammu/emb/gammu/$(MAKEFILE) FORCE
cd gammu/emb/gammu && $(MAKE) -f $(MAKEFILE)
libical/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "libical" || $(MKDIR) "libical"
cd libical && $(QMAKE) libical.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-libical: libical/$(MAKEFILE) FORCE
cd libical && $(MAKE) -f $(MAKEFILE)
libkcal/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "libkcal" || $(MKDIR) "libkcal"
cd libkcal && $(QMAKE) libkcal.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-libkcal: libkcal/$(MAKEFILE) FORCE
cd libkcal && $(MAKE) -f $(MAKEFILE)
microkde/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "microkde" || $(MKDIR) "microkde"
cd microkde && $(QMAKE) microkde.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-microkde: microkde/$(MAKEFILE) FORCE
cd microkde && $(MAKE) -f $(MAKEFILE)
libkdepim/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "libkdepim" || $(MKDIR) "libkdepim"
cd libkdepim && $(QMAKE) libkdepim.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-libkdepim: libkdepim/$(MAKEFILE) FORCE
cd libkdepim && $(MAKE) -f $(MAKEFILE)
kabc/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "kabc" || $(MKDIR) "kabc"
cd kabc && $(QMAKE) kabc.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-kabc: kabc/$(MAKEFILE) FORCE
cd kabc && $(MAKE) -f $(MAKEFILE)
korganizer/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "korganizer" || $(MKDIR) "korganizer"
cd korganizer && $(QMAKE) korganizer.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-korganizer: korganizer/$(MAKEFILE) FORCE
cd korganizer && $(MAKE) -f $(MAKEFILE)
kaddressbook/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "kaddressbook" || $(MKDIR) "kaddressbook"
cd kaddressbook && $(QMAKE) kaddressbook.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-kaddressbook: kaddressbook/$(MAKEFILE) FORCE
cd kaddressbook && $(MAKE) -f $(MAKEFILE)
kabc/plugins/file/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "kabc/plugins/file" || $(MKDIR) "kabc/plugins/file"
cd kabc/plugins/file && $(QMAKE) file.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-kabc-plugins-file: kabc/plugins/file/$(MAKEFILE) FORCE
cd kabc/plugins/file && $(MAKE) -f $(MAKEFILE)
kabc/plugins/dir/$(MAKEFILE):
@$(CHK_DIR_EXISTS) "kabc/plugins/dir" || $(MKDIR) "kabc/plugins/dir"
cd kabc/plugins/dir && $(QMAKE) dir.pro "CONFIG+=thread" "CONFIG+=debug" -o $(MAKEFILE)
sub-kabc-plugins-dir: kabc/plugins/dir/$(MAKEFILE) FORCE
cd kabc/plugins/dir && $(MAKE) -f $(MAKEFILE)
Makefile: kdepim-desktop.pro /usr/local/qtgcc/mkspecs/default/qmake.conf
$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kdepim-desktop.pro
qmake: qmake_all
@$(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kdepim-desktop.pro
all: $(SUBTARGETS)
qmake_all: gammu/emb/common/$(MAKEFILE) gammu/emb/gammu/$(MAKEFILE) libical/$(MAKEFILE) libkcal/$(MAKEFILE) microkde/$(MAKEFILE) libkdepim/$(MAKEFILE) kabc/$(MAKEFILE) korganizer/$(MAKEFILE) kaddressbook/$(MAKEFILE) kabc/plugins/file/$(MAKEFILE) kabc/plugins/dir/$(MAKEFILE)
( [ -d gammu/emb/common ] && cd gammu/emb/common ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d libical ] && cd libical ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d libkcal ] && cd libkcal ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d microkde ] && cd microkde ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d libkdepim ] && cd libkdepim ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d kabc ] && cd kabc ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d korganizer ] && cd korganizer ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d kaddressbook ] && cd kaddressbook ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; grep "^qmake_all:" $(MAKEFILE) && $(MAKE) -f $(MAKEFILE) qmake_all; ) || true
clean uicables mocables uiclean mocclean lexclean yaccclean : qmake_all FORCE
( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; ) || true
( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; ) || true
uninstall_subdirs: qmake_all FORCE
( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) uninstall; ) || true
install_subdirs: qmake_all FORCE
( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) install; ) || true
( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) install; ) || true
distclean: qmake_all FORCE
( [ -d gammu/emb/common ] && cd gammu/emb/common ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d gammu/emb/gammu ] && cd gammu/emb/gammu ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d libical ] && cd libical ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d libkcal ] && cd libkcal ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d microkde ] && cd microkde ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d libkdepim ] && cd libkdepim ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d kabc ] && cd kabc ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d korganizer ] && cd korganizer ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d kaddressbook ] && cd kaddressbook ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d kabc/plugins/file ] && cd kabc/plugins/file ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
( [ -d kabc/plugins/dir ] && cd kabc/plugins/dir ; $(MAKE) -f $(MAKEFILE) $@; $(DEL_FILE) $(MAKEFILE); ) || true
install: install_subdirs
uninstall: uninstall_subdirs
FORCE:
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
@@ -1,208 +1,245 @@
/*******************************************************************************
* main.cpp *
* *
*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* As a special exception, permission is given to link this program *
* with any edition of Qt, and distribute the resulting executable, *
* without including the source code for Qt in the source distribution. *
* *
******************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <klocale.h>
#include <kglobal.h>
#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";
static KCmdLineOptions options[] =
{
{ "dump",
I18N_NOOP( "Dumps calendar" ), 0 },
{ "read",
I18N_NOOP( "Reads calendar" ), 0 },
KCmdLineLastOption
};
int main( int argc, char *argv[] )
{
KAboutData aboutData(
progName, // internal program name
I18N_NOOP( progDisplay ), // displayable program name.
progVersion, // version string
I18N_NOOP( progDesc ), // short porgram description
KAboutData::License_GPL, // license type
"(c) 2004, Lutz Rogowski", // copyright statement
0, // any free form text
"", // program home page address
"bugs.kde.org" // bug report email address
);
// KCmdLineArgs::init() final 'true' argument indicates no commandline options
// for QApplication/KApplication (no KDE or Qt options)
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() ) {
++num;
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 = 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);
- }
- ++del;
- cl = (*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->deleteJournal( (Journal *) cl );
+ calendarResource->addJournal( (Journal *) cl, res );
else if ( cl->type() == "Todo" )
- calendarResource->deleteTodo( (Todo *) cl );
+ calendarResource->addTodo( (Todo *) cl, res );
else if ( cl->type() == "Event" )
- calendarResource->deleteEvent( (Event *) cl );
+ 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 ) {
+ ++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();
delete calendarResource;
}
qDebug("ente ");
return 0;
}
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index c6e06f8..8851097 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -528,515 +528,518 @@ int KSyncManager::ringSync()
}
timer.start();
while ( timer.elapsed () < 2000 ) {
qApp->processEvents();
}
} else
syncRemote( temp, false );
}
}
timer.start();
mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
while ( timer.elapsed () < 2000 ) {
qApp->processEvents();
#ifndef _WIN32_
sleep (1);
#endif
}
}
}
delete temp;
return syncedProfiles;
}
void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
{
QString question;
if ( ask ) {
question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
if ( QMessageBox::information( mParent, i18n("Sync"),
question,
i18n("Yes"), i18n("No"),
0, 0 ) != 0 )
return;
}
QString preCommand;
QString localTempFile;
QString postCommand;
switch(mTargetApp)
{
case (KAPI):
preCommand = prof->getPreSyncCommandAB();
postCommand = prof->getPostSyncCommandAB();
localTempFile = prof->getLocalTempFileAB();
break;
case (KOPI):
preCommand = prof->getPreSyncCommand();
postCommand = prof->getPostSyncCommand();
localTempFile = prof->getLocalTempFile();
break;
case (PWMPI):
preCommand = prof->getPreSyncCommandPWM();
postCommand = prof->getPostSyncCommandPWM();
localTempFile = prof->getLocalTempFilePWM();
break;
default:
qDebug("KSyncManager::syncRemote: invalid apptype selected");
break;
}
int fi;
if ( (fi = preCommand.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
}
int maxlen = 30;
if ( QApplication::desktop()->width() > 320 )
maxlen += 25;
mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
int fileSize = 0;
int result = system ( preCommand );
// 0 : okay
// 256: no such file or dir
//
qDebug("Sync: Remote copy result(0 = okay): %d ",result );
if ( result != 0 ) {
unsigned int len = maxlen;
while ( len < preCommand.length() ) {
preCommand.insert( len , "\n" );
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 (preCommand) ;
QMessageBox::information( mParent, i18n("Sync - ERROR"),
question,
i18n("Okay!")) ;
mParent->topLevelWidget()->setCaption ("KDE-Pim");
return;
}
mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
//qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
if ( syncWithFile( localTempFile, true ) ) {
if ( mWriteBackFile ) {
int fi;
if ( (fi = postCommand.find("$PWD$")) > 0 ) {
QString pwd = getPassword();
postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
}
mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
result = system ( postCommand );
qDebug("Sync:Writing back file result: %d ", result);
if ( result != 0 ) {
mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
return;
} else {
mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
}
}
}
return;
}
void KSyncManager::edit_pisync_options()
{
QDialog dia( mParent, "dia", true );
dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
QVBoxLayout lay ( &dia );
lay.setSpacing( 5 );
lay.setMargin( 3 );
QLabel lab1 ( i18n("Password for remote access:"), &dia);
lay.addWidget( &lab1 );
QLineEdit le1 (&dia );
lay.addWidget( &le1 );
QLabel lab2 ( i18n("Remote IP address:"), &dia);
lay.addWidget( &lab2 );
QLineEdit le2 (&dia );
lay.addWidget( &le2 );
QLabel lab3 ( i18n("Remote port number:"), &dia);
lay.addWidget( &lab3 );
QLineEdit le3 (&dia );
lay.addWidget( &le3 );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
le1.setText( mPassWordPiSync );
le2.setText( mActiveSyncIP );
le3.setText( mActiveSyncPort );
if ( dia.exec() ) {
mPassWordPiSync = le1.text();
mActiveSyncPort = le3.text();
mActiveSyncIP = le2.text();
}
}
void KSyncManager::edit_sync_options()
{
QDialog dia( mParent, "dia", true );
dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
QVBoxLayout lay ( &dia );
lay.setSpacing( 2 );
lay.setMargin( 3 );
lay.addWidget(&gr);
QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
//QRadioButton both( i18n("Take both on conflict"), &gr );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
switch ( mSyncAlgoPrefs ) {
case 0:
loc.setChecked( true);
break;
case 1:
rem.setChecked( true );
break;
case 2:
newest.setChecked( true);
break;
case 3:
ask.setChecked( true);
break;
case 4:
f_loc.setChecked( true);
break;
case 5:
f_rem.setChecked( true);
break;
case 6:
// both.setChecked( true);
break;
default:
break;
}
if ( dia.exec() ) {
mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
}
}
QString KSyncManager::getPassword( )
{
QString retfile = "";
QDialog dia ( mParent, "input-dialog", true );
QLineEdit lab ( &dia );
lab.setEchoMode( QLineEdit::Password );
QVBoxLayout lay( &dia );
lay.setMargin(7);
lay.setSpacing(7);
lay.addWidget( &lab);
dia.setFixedSize( 230,50 );
dia.setCaption( i18n("Enter password") );
QPushButton pb ( "OK", &dia);
lay.addWidget( &pb );
connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
dia.show();
int res = dia.exec();
if ( res )
retfile = lab.text();
dia.hide();
qApp->processEvents();
return retfile;
}
void KSyncManager::confSync()
{
static KSyncPrefsDialog* sp = 0;
if ( ! sp ) {
sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
}
sp->usrReadConfig();
#ifndef DESKTOP_VERSION
sp->showMaximized();
#else
sp->show();
#endif
sp->exec();
mSyncProfileNames = sp->getSyncProfileNames();
mLocalMachineName = sp->getLocalMachineName ();
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:
qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
break;
}
}
void KSyncManager::syncSharp()
{
if ( ! syncExternalApplication("sharp") )
qDebug("ERROR sync sharp ");
}
bool KSyncManager::syncExternalApplication(QString resource)
{
emit save();
if ( mAskForPreferences )
edit_sync_options();
qDebug("Sync extern %s", resource.latin1());
bool syncOK = mImplementation->syncExternal(this, resource);
return syncOK;
}
void KSyncManager::syncPhone()
{
syncExternalApplication("phone");
}
void KSyncManager::showProgressBar(int percentage, QString caption, int total)
{
if (!bar->isVisible())
{
bar->setCaption (caption);
bar->setTotalSteps ( total ) ;
bar->show();
}
bar->setProgress( percentage );
}
void KSyncManager::hideProgressBar()
{
bar->hide();
}
bool KSyncManager::isProgressBarCanceled()
{
return !bar->isVisible();
}
QString KSyncManager::syncFileName()
{
QString fn = "tempfile";
switch(mTargetApp)
{
case (KAPI):
fn = "tempsyncab.vcf";
break;
case (KOPI):
fn = "tempsynccal.ics";
break;
case (PWMPI):
fn = "tempsyncpw.pwm";
break;
default:
break;
}
#ifdef _WIN32_
return locateLocal( "tmp", fn );
#else
return (QString( "/tmp/" )+ fn );
#endif
}
void KSyncManager::syncPi()
{
mPisyncFinished = false;
qApp->processEvents();
if ( mAskForPreferences )
edit_pisync_options();
bool ok;
Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
if ( ! ok ) {
mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
return;
}
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
commandSocket->readFile( syncFileName() );
}
void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
{
//enum { success, errorW, errorR, quiet };
if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
delete s;
if ( state == KCommandSocket::errorR ) {
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
commandSocket->sendStop();
}
mPisyncFinished = true;
return;
} else if ( state == KCommandSocket::errorW ) {
mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
mPisyncFinished = true;
} else if ( state == KCommandSocket::successR ) {
QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
} else if ( state == KCommandSocket::successW ) {
mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
mPisyncFinished = true;
}
delete s;
}
void KSyncManager::readFileFromSocket()
{
QString fileName = syncFileName();
mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
if ( ! syncWithFile( fileName , true ) ) {
mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
mPisyncFinished = true;
return;
}
KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
if ( mWriteBackFile )
commandSocket->writeFile( fileName );
else {
commandSocket->sendStop();
mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
mPisyncFinished = true;
}
}
KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
{
mPassWord = pw;
mSocket = 0;
mSyncActionDialog = 0;
blockRC = false;
};
void KServerSocket::newConnection ( int socket )
{
// qDebug("KServerSocket:New connection %d ", socket);
if ( mSocket ) {
qDebug("KServerSocket::newConnection Socket deleted! ");
delete mSocket;
mSocket = 0;
}
mSocket = new QSocket( this );
connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
mSocket->setSocket( socket );
}
void KServerSocket::discardClient()
{
//qDebug(" KServerSocket::discardClient()");
if ( mSocket ) {
delete mSocket;
mSocket = 0;
}
//emit endConnect();
}
void KServerSocket::readClient()
{
if ( blockRC )
return;
if ( mSocket == 0 ) {
qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
return;
}
//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 );
send_file();
else {
KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
//qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
}
}
if ( tokens[0] == "PUT" ) {
if ( tokens[1] == mPassWord ) {
//emit getFile( mSocket );
blockRC = true;
get_file();
}
else {
KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
//qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
}
}
if ( tokens[0] == "STOP" ) {
//emit endConnect();
end_connect();
}
}
}
void KServerSocket::end_connect()
{
delete mSyncActionDialog;
mSyncActionDialog = 0;
}
void KServerSocket::send_file()
{
//qDebug("MainWindow::sendFile(QSocket* s) ");
if ( mSyncActionDialog )
delete mSyncActionDialog;
mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
mSyncActionDialog->setCaption(i18n("Received sync request"));
QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
lay->addWidget( label);
lay->setMargin(7);
lay->setSpacing(7);
mSyncActionDialog->setFixedSize( 230, 120);
mSyncActionDialog->show();
mSyncActionDialog->raise();
emit request_file();
qApp->processEvents();
QString fileName = mFileName;