From cb7eddb91455a69cf66fcd717e91a51ca5e2cfef Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 16 Feb 2011 20:17:18 +0000 Subject: Moved kpilot from kdepim to applications, as the core Trinity libraries should not contain hardware-dependent software git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kpilot@1221127 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- conduits/vcalconduit/CMakeLists.txt | 75 +++ conduits/vcalconduit/Makefile.am | 43 ++ conduits/vcalconduit/README | 11 + conduits/vcalconduit/cleanupstate.cc | 132 ++++++ conduits/vcalconduit/cleanupstate.h | 49 ++ conduits/vcalconduit/conduitstate.h | 86 ++++ conduits/vcalconduit/deleteunsyncedhhstate.cc | 115 +++++ conduits/vcalconduit/deleteunsyncedhhstate.h | 53 +++ conduits/vcalconduit/deleteunsyncedpcstate.cc | 135 ++++++ conduits/vcalconduit/deleteunsyncedpcstate.h | 53 +++ conduits/vcalconduit/hhtopcstate.cc | 249 ++++++++++ conduits/vcalconduit/hhtopcstate.h | 55 +++ conduits/vcalconduit/initstate.cc | 109 +++++ conduits/vcalconduit/initstate.h | 52 +++ conduits/vcalconduit/kcalRecord.cc | 143 ++++++ conduits/vcalconduit/kcalRecord.h | 49 ++ conduits/vcalconduit/korganizerConduit.ui | 275 +++++++++++ conduits/vcalconduit/pctohhstate.cc | 159 +++++++ conduits/vcalconduit/pctohhstate.h | 54 +++ conduits/vcalconduit/teststate.cc | 127 +++++ conduits/vcalconduit/teststate.h | 55 +++ conduits/vcalconduit/todo-conduit.cc | 373 +++++++++++++++ conduits/vcalconduit/todo-conduit.desktop | 105 +++++ conduits/vcalconduit/todo-conduit.h | 108 +++++ conduits/vcalconduit/todo-factory.cc | 46 ++ conduits/vcalconduit/todo-factory.h | 40 ++ conduits/vcalconduit/todo-setup.cc | 86 ++++ conduits/vcalconduit/todo-setup.h | 44 ++ conduits/vcalconduit/todoRecord.cc | 141 ++++++ conduits/vcalconduit/todoRecord.h | 49 ++ conduits/vcalconduit/vcal-conduit.cc | 309 ++++++++++++ conduits/vcalconduit/vcal-conduit.desktop | 103 ++++ conduits/vcalconduit/vcal-conduit.h | 101 ++++ conduits/vcalconduit/vcal-conduitbase.cc | 622 +++++++++++++++++++++++++ conduits/vcalconduit/vcal-conduitbase.h | 202 ++++++++ conduits/vcalconduit/vcal-factory.cc | 50 ++ conduits/vcalconduit/vcal-factory.h | 41 ++ conduits/vcalconduit/vcal-factorybase.h | 44 ++ conduits/vcalconduit/vcal-setup.cc | 78 ++++ conduits/vcalconduit/vcal-setup.h | 46 ++ conduits/vcalconduit/vcal-setupbase.cc | 110 +++++ conduits/vcalconduit/vcal-setupbase.h | 51 ++ conduits/vcalconduit/vcalRecord.cc | 548 ++++++++++++++++++++++ conduits/vcalconduit/vcalRecord.h | 51 ++ conduits/vcalconduit/vcalconduitSettings.kcfgc | 7 + conduits/vcalconduit/vcalconduitbase.kcfg | 31 ++ 46 files changed, 5465 insertions(+) create mode 100644 conduits/vcalconduit/CMakeLists.txt create mode 100644 conduits/vcalconduit/Makefile.am create mode 100644 conduits/vcalconduit/README create mode 100644 conduits/vcalconduit/cleanupstate.cc create mode 100644 conduits/vcalconduit/cleanupstate.h create mode 100644 conduits/vcalconduit/conduitstate.h create mode 100644 conduits/vcalconduit/deleteunsyncedhhstate.cc create mode 100644 conduits/vcalconduit/deleteunsyncedhhstate.h create mode 100644 conduits/vcalconduit/deleteunsyncedpcstate.cc create mode 100644 conduits/vcalconduit/deleteunsyncedpcstate.h create mode 100644 conduits/vcalconduit/hhtopcstate.cc create mode 100644 conduits/vcalconduit/hhtopcstate.h create mode 100644 conduits/vcalconduit/initstate.cc create mode 100644 conduits/vcalconduit/initstate.h create mode 100644 conduits/vcalconduit/kcalRecord.cc create mode 100644 conduits/vcalconduit/kcalRecord.h create mode 100644 conduits/vcalconduit/korganizerConduit.ui create mode 100644 conduits/vcalconduit/pctohhstate.cc create mode 100644 conduits/vcalconduit/pctohhstate.h create mode 100644 conduits/vcalconduit/teststate.cc create mode 100644 conduits/vcalconduit/teststate.h create mode 100644 conduits/vcalconduit/todo-conduit.cc create mode 100644 conduits/vcalconduit/todo-conduit.desktop create mode 100644 conduits/vcalconduit/todo-conduit.h create mode 100644 conduits/vcalconduit/todo-factory.cc create mode 100644 conduits/vcalconduit/todo-factory.h create mode 100644 conduits/vcalconduit/todo-setup.cc create mode 100644 conduits/vcalconduit/todo-setup.h create mode 100644 conduits/vcalconduit/todoRecord.cc create mode 100644 conduits/vcalconduit/todoRecord.h create mode 100644 conduits/vcalconduit/vcal-conduit.cc create mode 100644 conduits/vcalconduit/vcal-conduit.desktop create mode 100644 conduits/vcalconduit/vcal-conduit.h create mode 100644 conduits/vcalconduit/vcal-conduitbase.cc create mode 100644 conduits/vcalconduit/vcal-conduitbase.h create mode 100644 conduits/vcalconduit/vcal-factory.cc create mode 100644 conduits/vcalconduit/vcal-factory.h create mode 100644 conduits/vcalconduit/vcal-factorybase.h create mode 100644 conduits/vcalconduit/vcal-setup.cc create mode 100644 conduits/vcalconduit/vcal-setup.h create mode 100644 conduits/vcalconduit/vcal-setupbase.cc create mode 100644 conduits/vcalconduit/vcal-setupbase.h create mode 100644 conduits/vcalconduit/vcalRecord.cc create mode 100644 conduits/vcalconduit/vcalRecord.h create mode 100644 conduits/vcalconduit/vcalconduitSettings.kcfgc create mode 100644 conduits/vcalconduit/vcalconduitbase.kcfg (limited to 'conduits/vcalconduit') diff --git a/conduits/vcalconduit/CMakeLists.txt b/conduits/vcalconduit/CMakeLists.txt new file mode 100644 index 0000000..2148235 --- /dev/null +++ b/conduits/vcalconduit/CMakeLists.txt @@ -0,0 +1,75 @@ +set(conduit_LIBS kcal) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} +) + +set(conduit_SHARED + vcal-setupbase.cc + vcal-conduitbase.cc + teststate.cc + initstate.cc + pctohhstate.cc + hhtopcstate.cc + cleanupstate.cc + deleteunsyncedpcstate.cc + deleteunsyncedhhstate.cc + kcalRecord.cc + vcalRecord.cc + todoRecord.cc +) + +kde3_add_kcfg_files(conduit_SHARED vcalconduitSettings.kcfgc) +kde3_add_ui_files(conduit_SHARED korganizerConduit.ui) + +set(conduit_vcal_SRCS + ${conduit_SHARED} + vcal-conduit.cc + vcal-factory.cc + vcal-setup.cc +) + +kde3_automoc(${conduit_vcal_SRCS}) +add_library(conduit_vcal SHARED ${conduit_vcal_SRCS}) +target_link_libraries(conduit_vcal kcal) + +set(conduit_todo_SRCS + ${conduit_SHARED} + todo-factory.cc + todo-setup.cc + todo-conduit.cc +) + +kde3_automoc(${conduit_todo_SRCS}) +add_library(conduit_todo SHARED ${conduit_todo_SRCS}) +target_link_libraries(conduit_todo kcal) + +set_target_properties( + conduit_vcal PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR} + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib + PREFIX "" +) +set_target_properties( + conduit_todo PROPERTIES LOCATION ${KDE3_PLUGIN_INSTALL_DIR} + INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib + PREFIX "" +) + +kde3_install_libtool_file(conduit_vcal) + +install( + TARGETS conduit_vcal conduit_todo + LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR} + LIBRARY DESTINATION ${KDE3_PLUGIN_INSTALL_DIR} +) + +kde3_install_libtool_file(conduit_todo) + +install( + FILES vcal-conduit.desktop todo-conduit.desktop + DESTINATION ${KDE3_SERVICES_DIR} +) + +install( + FILES vcalconduitbase.kcfg DESTINATION ${KDE3_KCFG_DIR} +) diff --git a/conduits/vcalconduit/Makefile.am b/conduits/vcalconduit/Makefile.am new file mode 100644 index 0000000..546789e --- /dev/null +++ b/conduits/vcalconduit/Makefile.am @@ -0,0 +1,43 @@ +### +### Makefile for vcal and todo conduits. These two conduits share most code, +### so it seems logical to put them in one place. +### + +INCLUDES= -I$(top_srcdir)/kpilot/lib -I$(top_srcdir) \ + $(PISOCK_INCLUDE) $(all_includes) + +METASOURCES = AUTO + +servicedir = $(kde_servicesdir) +service_DATA = vcal-conduit.desktop todo-conduit.desktop + +kde_module_LTLIBRARIES = conduit_vcal.la conduit_todo.la +noinst_LTLIBRARIES = libvcalconduit_shared.la + +libvcalconduit_shared_la_SOURCES = vcalconduitSettings.kcfgc \ + korganizerConduit.ui \ + kcalRecord.cc \ + vcal-setupbase.cc \ + vcal-conduitbase.cc \ + cleanupstate.cc deleteunsyncedhhstate.cc deleteunsyncedpcstate.cc \ + hhtopcstate.cc initstate.cc pctohhstate.cc teststate.cc + +conduit_vcal_la_SOURCES = vcal-conduit.cc vcalRecord.cc \ + vcal-factory.cc vcal-setup.cc +conduit_vcal_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +conduit_vcal_la_LIBADD = ../../lib/libkpilot.la \ + ../../../libkcal/libkcal.la \ + libvcalconduit_shared.la +conduit_vcal_la_COMPILE_FIRST = vcalconduitSettings.h korganizerConduit.h + +conduit_todo_la_SOURCES = todo-conduit.cc todoRecord.cc \ + todo-factory.cc todo-setup.cc +conduit_todo_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +conduit_todo_la_LIBADD = ../../lib/libkpilot.la \ + ../../../libkcal/libkcal.la \ + libvcalconduit_shared.la +conduit_todo_la_COMPILE_FIRST = vcalconduitSettings.h korganizerConduit.h + + +kde_kcfg_DATA = vcalconduitbase.kcfg + diff --git a/conduits/vcalconduit/README b/conduits/vcalconduit/README new file mode 100644 index 0000000..8d4ea49 --- /dev/null +++ b/conduits/vcalconduit/README @@ -0,0 +1,11 @@ +KPilot vCal KOrganizer conduit version 3.0 +(c) 1998 Dan Pilone, Preston Brown, Herwin Jan Steehouwer + +This conduit works with KPilot and KOrganizer. + +Things to remember: +* When deleting from yout PalmPilot set + 'Save Archive Copy On PC' OFF !!! + +Preston Brown and Herwin Jan Steehouwer +pbrown@kde.org, steehouwer@kde.org diff --git a/conduits/vcalconduit/cleanupstate.cc b/conduits/vcalconduit/cleanupstate.cc new file mode 100644 index 0000000..209a0e9 --- /dev/null +++ b/conduits/vcalconduit/cleanupstate.cc @@ -0,0 +1,132 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the CleanUpState. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include +#include + +#include "pilotDatabase.h" + +#include "vcal-conduitbase.h" +#include "vcalconduitSettings.h" +#include "cleanupstate.h" + + +CleanUpState::CleanUpState() +{ + fState = eCleanUp; +} + +CleanUpState::~CleanUpState() +{ +} + +void CleanUpState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting CleanUpState." << endl; + + vccb->addLogMessage( i18n( "Cleaning up ..." ) ); + vccb->postSync(); + + if ( vccb->database() ) + { + vccb->database()->resetSyncFlags(); + vccb->database()->cleanup(); + } + if ( vccb->localDatabase() ) + { + vccb->localDatabase()->resetSyncFlags(); + vccb->localDatabase()->cleanup(); + } + + KCal::Calendar *fCalendar = vccb->calendar(); + TQString fCalendarFile = vccb->calendarFile(); + + if ( fCalendar ) + { + KURL kurl( vccb->config()->calendarFile() ); + switch( vccb->config()->calendarType() ) + { + case VCalConduitSettings::eCalendarLocal: + dynamic_cast(fCalendar)->save( fCalendarFile ); + if(!kurl.isLocalFile()) + { + if( !KIO::NetAccess::upload( fCalendarFile + , vccb->config()->calendarFile(), 0L) ) + { + vccb->addLogError( i18n( "An error occurred while uploading" + " \"%1\". You can try to upload " + "the temporary local file \"%2\" manually.") + .arg(vccb->config()->calendarFile()).arg(fCalendarFile)); + } + else { + KIO::NetAccess::removeTempFile( fCalendarFile ); + } + TQFile backup( fCalendarFile + CSL1( "~" ) ); + backup.remove(); + } + break; + case VCalConduitSettings::eCalendarResource: + fCalendar->save(); + break; + default: + break; + } + fCalendar->close(); + } + + vccb->setHasNextRecord( false ); +} + +void CleanUpState::handleRecord( ConduitAction * ) +{ + FUNCTIONSETUP; +} + +void CleanUpState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Finished CleanUpState." << endl; + vccb->setState( 0L ); +} diff --git a/conduits/vcalconduit/cleanupstate.h b/conduits/vcalconduit/cleanupstate.h new file mode 100644 index 0000000..4d599cd --- /dev/null +++ b/conduits/vcalconduit/cleanupstate.h @@ -0,0 +1,49 @@ +#ifndef _KPILOT_CLEANUPSTATE_H +#define _KPILOT_CLEANUPSTATE_H +/* cleanupstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the cleanupstate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "conduitstate.h" + +class ConduitAction; + +/** + * State to Cleanup after all sync actions are finished. @see vcal-conduitstate.h + */ +class CleanUpState : public ConduitState +{ +public: + CleanUpState(); + virtual ~CleanUpState(); + + virtual void startSync( ConduitAction* ); + virtual void handleRecord( ConduitAction* ); + virtual void finishSync( ConduitAction* ); +}; + +#endif diff --git a/conduits/vcalconduit/conduitstate.h b/conduits/vcalconduit/conduitstate.h new file mode 100644 index 0000000..447ce1c --- /dev/null +++ b/conduits/vcalconduit/conduitstate.h @@ -0,0 +1,86 @@ +#ifndef _KPILOT_CONDUITSTATE_H +#define _KPILOT_CONDUITSTATE_H +/* vcal-conduitstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the vcal-conduitstate. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "plugin.h" + +/** + * This class defines the current state of the vcal-conduitbase. Subclasses of + * this class can do the things that are needed, in methods defined here, for + * the state that they define. + */ +class ConduitState +{ +public: + enum state_t { + eTest, + eInit, + ePCToHH, + eHHToPC, + eDeleteUnsyncedHH, + eDeleteUnsyncedPC, + eCleanUp + }; + +protected: + state_t fState; + bool fStarted; + +public: + ConduitState(){ fState = eInit; fStarted = false; }; + virtual ~ConduitState() {}; + + /** + * Prepare for a sync in the current state. Don't forget to set fState to + * true in this method. Otherwise the state won't handle records. + */ + virtual void startSync( ConduitAction * ) = 0; + + /** + * Sync the next record in row. + */ + virtual void handleRecord( ConduitAction * ) = 0; + + /** + * Clean up after all records are synced and enter next state. + */ + virtual void finishSync( ConduitAction * ) = 0; + + /** + * Returns the state type. + */ + state_t state() { return fState; }; + + /** + * Returns wether or not this state has started. + */ + bool started() { return fStarted; }; +}; + +#endif diff --git a/conduits/vcalconduit/deleteunsyncedhhstate.cc b/conduits/vcalconduit/deleteunsyncedhhstate.cc new file mode 100644 index 0000000..78fb678 --- /dev/null +++ b/conduits/vcalconduit/deleteunsyncedhhstate.cc @@ -0,0 +1,115 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the DeleteUnsyncedHHState. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include +#include + +#include "pilotDatabase.h" +#include "pilotRecord.h" + +#include "vcal-conduitbase.h" +#include "deleteunsyncedhhstate.h" +#include "deleteunsyncedpcstate.h" +#include "cleanupstate.h" + +DeleteUnsyncedHHState::DeleteUnsyncedHHState() +{ + fState = eDeleteUnsyncedHH; +} + +DeleteUnsyncedHHState::~DeleteUnsyncedHHState() +{ +} + +void DeleteUnsyncedHHState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting DeleteUnsyncedHHState." << endl; + + fPilotIndex = 0; + fNextState = new DeleteUnsyncedPCState(); + + vccb->setHasNextRecord( true ); + fStarted = true; +} + +void DeleteUnsyncedHHState::handleRecord( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + PilotRecord *r = vccb->localDatabase()->readRecordByIndex( fPilotIndex++ ); + // if either we don't have a record, or if we're copying everything + // from the handheld to the pc, then we don't have anything to do + // here. the latter is because if we're copying HH->PC, then by + // definition, we will have everything from the HH on the PC and + // therefore can't possibly have anything that needs to be deleted + // from it. + if ( !r + || ( vccb->syncMode().mode() == ConduitAction::SyncMode::eCopyHHToPC ) ) + { + vccb->setHasNextRecord( false ); + return; + } + + KCal::Incidence *e = vccb->privateBase()->findIncidence( r->id() ); + if ( !e ) + { + DEBUGKPILOT << "Didn't find incidence with id = " << r->id() + << ", deleting it" << endl; + vccb->deletePalmRecord( NULL, r ); + } + + KPILOT_DELETE( r ); +} + +void DeleteUnsyncedHHState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Finishing DeleteUnsyncedHHState." << endl; + vccb->setState( fNextState ); +} diff --git a/conduits/vcalconduit/deleteunsyncedhhstate.h b/conduits/vcalconduit/deleteunsyncedhhstate.h new file mode 100644 index 0000000..df9b721 --- /dev/null +++ b/conduits/vcalconduit/deleteunsyncedhhstate.h @@ -0,0 +1,53 @@ +#ifndef _KPILOT_DUSHHSTATE_H +#define _KPILOT_DUSHHSTATE_H +/* deleteunsyncedhhstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the deleteunsyncedpcstate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "conduitstate.h" + +class VCalConduitBase; + +/** + * State to handle delete unsynced pc records. @see vcal-conduitstate.h + */ +class DeleteUnsyncedHHState : public ConduitState +{ +private: + ConduitState *fNextState; + int fPilotIndex; + +public: + DeleteUnsyncedHHState(); + virtual ~DeleteUnsyncedHHState(); + + virtual void startSync( ConduitAction* ); + virtual void handleRecord( ConduitAction* ); + virtual void finishSync( ConduitAction* ); +}; + +#endif diff --git a/conduits/vcalconduit/deleteunsyncedpcstate.cc b/conduits/vcalconduit/deleteunsyncedpcstate.cc new file mode 100644 index 0000000..26a0a08 --- /dev/null +++ b/conduits/vcalconduit/deleteunsyncedpcstate.cc @@ -0,0 +1,135 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the DeleteUnsyncedPCState. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include +#include + +#include "pilotDatabase.h" +#include "pilotRecord.h" + +#include "vcal-conduitbase.h" +#include "deleteunsyncedpcstate.h" +#include "cleanupstate.h" + +DeleteUnsyncedPCState::DeleteUnsyncedPCState() +{ + fState = eDeleteUnsyncedPC; +} + +DeleteUnsyncedPCState::~DeleteUnsyncedPCState() +{ +} + +void DeleteUnsyncedPCState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting DeleteUnsyncedPCState." << endl; + + fPilotIndex = 0; + fNextState = new CleanUpState(); + + vccb->setHasNextRecord( true ); + fStarted = true; +} + +void DeleteUnsyncedPCState::handleRecord( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + KCal::Incidence *e = 0L; + e = vccb->privateBase()->getNextIncidence(); + + // if we don't have a record, then we can't do anything. also, if + // we're copying everything from the PC to our handheld, then we're + // guaranteed not to have anything extra on our PC that's not on + // our handheld that needs to get deleted, so we can return in that + // case too... + + if( !e || ( vccb->syncMode().mode() == ConduitAction::SyncMode::eCopyPCToHH ) ) + { + vccb->setHasNextRecord( false ); + return; + } + + + // try to find the corresponding index on the palm. if we can't + // find it, then we have a pc record that needs to be deleted. + recordid_t id = e->pilotId(); + + PilotRecord *s = 0L; + + if( id > 0 ) + { + s = vccb->database()->readRecordById( id ); + } + + // if we either have a pc record with no palm id or if we can't + // find a palm record that matches, then we need to delete this PC + // record. + if ( id <=0 || !s ) + { +#ifdef DEBUG + DEBUGKPILOT << fname << ": found PC entry with pilotID: [" << id + << "], Description: [" << e->summary() + << "], Time: ["<< e->dtStart().toString() << "] until: [" + << e->dtEnd().toString() << "]. Can't find it on Palm, " + << "so I'm deleting it from the local calendar." << endl; +#endif + vccb->privateBase()->removeIncidence(e); + } + + KPILOT_DELETE( s ); + +} + +void DeleteUnsyncedPCState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Finishing DeleteUnsyncedPCState." << endl; + vccb->setState( fNextState ); +} diff --git a/conduits/vcalconduit/deleteunsyncedpcstate.h b/conduits/vcalconduit/deleteunsyncedpcstate.h new file mode 100644 index 0000000..854b2a6 --- /dev/null +++ b/conduits/vcalconduit/deleteunsyncedpcstate.h @@ -0,0 +1,53 @@ +#ifndef _KPILOT_DUSPCSTATE_H +#define _KPILOT_DUSPCSTATE_H +/* deleteunsyncedpcstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the deleteunsyncedpcstate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "conduitstate.h" + +class VCalConduitBase; + +/** + * State to handle delete unsynced pc records. @see vcal-conduitstate.h + */ +class DeleteUnsyncedPCState : public ConduitState +{ +private: + ConduitState *fNextState; + int fPilotIndex; + +public: + DeleteUnsyncedPCState(); + virtual ~DeleteUnsyncedPCState(); + + virtual void startSync( ConduitAction* ); + virtual void handleRecord( ConduitAction* ); + virtual void finishSync( ConduitAction* ); +}; + +#endif diff --git a/conduits/vcalconduit/hhtopcstate.cc b/conduits/vcalconduit/hhtopcstate.cc new file mode 100644 index 0000000..82024f1 --- /dev/null +++ b/conduits/vcalconduit/hhtopcstate.cc @@ -0,0 +1,249 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the HHtoPCState +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include "pilotDatabase.h" +#include "pilotRecord.h" + +#include "vcalconduitSettings.h" +#include "vcal-conduitbase.h" +#include "hhtopcstate.h" +#include "pctohhstate.h" +#include "cleanupstate.h" + +HHToPCState::HHToPCState() +{ + fState = eHHToPC; + fPilotindex = 0; +} + +HHToPCState::~HHToPCState() +{ +} + +void HHToPCState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting HHToPCState." << endl; + + if ( vccb->syncMode() == ConduitAction::SyncMode::eCopyHHToPC ) + { + fNextState = new CleanUpState(); + } + else + { + fNextState = new PCToHHState(); + } + + fStarted = true; + vccb->setHasNextRecord( true ); +} + +void HHToPCState::handleRecord( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + PilotRecord *r = 0L; + PilotRecord *s = 0L; + + if ( vccb->isFullSync() ) + { + r = vccb->database()->readRecordByIndex( fPilotindex++ ); + } + else + { + r = vccb->database()->readNextModifiedRec(); + } + + if (!r) + { + vccb->privateBase()->updateIncidences(); + vccb->setHasNextRecord( false ); + return; + } + + // let subclasses do something with the record before we try to sync + vccb->preRecord( r ); + + bool archiveRecord = ( r->isArchived() ); + s = vccb->localDatabase()->readRecordById( r->id() ); + + if ( !s || vccb->isFirstSync() ) + { +#ifdef DEBUG + if ( r->id() > 0 && !s ) + { + DEBUGKPILOT << "-------------------------------------------------"; + DEBUGKPILOT << "--------------------------" << endl; + DEBUGKPILOT << fname << ": Could not read palm record with ID "; + DEBUGKPILOT << r->id() << endl; + } +#endif + if ( !r->isDeleted() + || ( vccb->config()->syncArchived() && archiveRecord ) ) + { + KCal::Incidence *e = vccb->addRecord( r ); + if ( vccb->config()->syncArchived() && archiveRecord ) { + e->setSyncStatus( KCal::Incidence::SYNCDEL ); + } + } + } + else + { + if ( r->isDeleted() ) + { + if ( vccb->config()->syncArchived() && archiveRecord ) + { + vccb->changeRecord( r, s ); + } + else + { + vccb->deleteRecord( r, s ); + } + } + else + { + vccb->changeRecord( r, s ); + } + } + + KPILOT_DELETE(r); + KPILOT_DELETE(s); +} + +void HHToPCState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Finished HHToPCState." << endl; + vccb->setState( fNextState ); +} + +/* +void VCalConduitBase::slotPalmRecToPC() +{ + FUNCTIONSETUP; + + PilotRecord *r; + if (isFullSync()) + { + r = fDatabase->readRecordByIndex(pilotindex++); + } + else + { + r = fDatabase->readNextModifiedRec(); + } + PilotRecord *s = 0L; + + if (!r) + { + fP->updateIncidences(); + if ( syncMode()==SyncMode::eCopyHHToPC ) + { + emit logMessage(i18n("Cleaning up ...")); + TQTimer::singleShot(0, this, TQT_SLOT(cleanup())); + return; + } + else + { + emit logMessage(i18n("Copying records to Pilot ...")); + TQTimer::singleShot(0 ,this,TQT_SLOT(slotPCRecToPalm())); + return; + } + } + + // let subclasses do something with the record before we try to sync + preRecord(r); + +// DEBUGKPILOT<dtStart()<<" until "<dtEnd()<dtStart()<<" until "<dtEnd()<isArchived()); + + s = fLocalDatabase->readRecordById(r->id()); + if (!s || isFirstSync()) + { +#ifdef DEBUG + if (r->id()>0 && !s) + { + DEBUGKPILOT<<"---------------------------------------------------------------------------"<id()<isDeleted() || (config()->syncArchived() && archiveRecord)) + { + KCal::Incidence*e=addRecord(r); + if (config()->syncArchived() && archiveRecord) { + e->setSyncStatus(KCal::Incidence::SYNCDEL); + } + } + } + else + { + if (r->isDeleted()) + { + if (config()->syncArchived() && archiveRecord) + { + changeRecord(r,s); + } + else + { + deleteRecord(r,s); + } + } + else + { + changeRecord(r,s); + } + } + + KPILOT_DELETE(r); + KPILOT_DELETE(s); + + TQTimer::singleShot(0,this,TQT_SLOT(slotPalmRecToPC())); +} +*/ diff --git a/conduits/vcalconduit/hhtopcstate.h b/conduits/vcalconduit/hhtopcstate.h new file mode 100644 index 0000000..838828e --- /dev/null +++ b/conduits/vcalconduit/hhtopcstate.h @@ -0,0 +1,55 @@ +#ifndef _KPILOT_HHTOPCSTATE_H +#define _KPILOT_HHTOPCSTATE_H +/* hhtopcstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the teststate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include "conduitstate.h" + +class VCalConduitBase; + +/** + * State to test the vcal-conduit. @see vcal-conduitstate.h + */ +class HHToPCState : public ConduitState +{ +private: + ConduitState *fNextState; + int fPilotindex; + +public: + HHToPCState(); + virtual ~HHToPCState(); + + virtual void startSync( ConduitAction* ); + virtual void handleRecord( ConduitAction* ); + virtual void finishSync( ConduitAction* ); +}; + +#endif diff --git a/conduits/vcalconduit/initstate.cc b/conduits/vcalconduit/initstate.cc new file mode 100644 index 0000000..23257ff --- /dev/null +++ b/conduits/vcalconduit/initstate.cc @@ -0,0 +1,109 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the InitState. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include +#include + +#include "vcal-conduitbase.h" +#include "initstate.h" +#include "teststate.h" +#include "pctohhstate.h" +#include "hhtopcstate.h" + +InitState::InitState() +{ + fState = eInit; +} + +InitState::~InitState() +{ +} + +void InitState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting InitState." << endl; + + vccb->addLogMessage( i18n( "Initializing conduit ..." ) ); + vccb->preSync(); + + if ( vccb->syncMode().isTest() ) + { + fNextState = new TestState(); + } + else + { + switch( vccb->syncMode().mode() ) + { + case ConduitAction::SyncMode::eCopyPCToHH: + // TODO: Clear the palm and backup database??? Or just add the + // new items ignore the Palm->PC side and leave the existing items + // on the palm? + fNextState = new PCToHHState(); + break; + case ConduitAction::SyncMode::eCopyHHToPC: + // TODO: Clear the backup database and the calendar, update fP + // or just add the palm items and leave the PC ones there???? + fNextState = new HHToPCState(); + break; + default: + fNextState = new HHToPCState(); + break; + } + } + + fStarted = true; + vccb->setHasNextRecord( false ); +} + +void InitState::handleRecord( ConduitAction *vccb ) +{ + FUNCTIONSETUP; + Q_UNUSED(vccb); +} + +void InitState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Finished InitState." << endl; + vccb->setState( fNextState ); +} diff --git a/conduits/vcalconduit/initstate.h b/conduits/vcalconduit/initstate.h new file mode 100644 index 0000000..83042ba --- /dev/null +++ b/conduits/vcalconduit/initstate.h @@ -0,0 +1,52 @@ +#ifndef _KPILOT_INITSTATE_H +#define _KPILOT_INITSTATE_H +/* initstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the teststate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "conduitstate.h" + +class VCalConduitBase; + +/** + * State to test the vcal-conduit. @see vcal-conduitstate.h + */ +class InitState : public ConduitState +{ +private: + ConduitState *fNextState; + +public: + InitState(); + virtual ~InitState(); + + virtual void startSync( ConduitAction *vccb ); + virtual void handleRecord( ConduitAction *vccb ); + virtual void finishSync( ConduitAction *vccb ); +}; + +#endif diff --git a/conduits/vcalconduit/kcalRecord.cc b/conduits/vcalconduit/kcalRecord.cc new file mode 100644 index 0000000..e7f8c68 --- /dev/null +++ b/conduits/vcalconduit/kcalRecord.cc @@ -0,0 +1,143 @@ +/* kcalRecord.cc KPilot +** +** Copyright (C) 2006 by Adriaan de Groot +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include +#include +#include + +#include "pilot.h" +#include "pilotRecord.h" +#include "kcalRecord.h" + +void KCalSync::setCategory(PilotRecordBase *de, + const KCal::Incidence *e, + const CategoryAppInfo &info) +{ + FUNCTIONSETUP; + + if (!de || !e) + { + return; + } + + TQString deCategory; + TQStringList eventCategories = e->categories(); + if (eventCategories.size() < 1) + { + // This event has no categories. + de->setCategory(Pilot::Unfiled); + return; + } + + // Quick check: does the record (not unfiled) have an entry + // in the categories list? If so, use that. + if (de->category() != Pilot::Unfiled) + { + deCategory = Pilot::categoryName(&info,de->category()); + if (eventCategories.tqcontains(deCategory)) + { + // Found, so leave the category unchanged. + return; + } + } + + TQStringList availableHandheldCategories = Pilot::categoryNames(&info); + + // Either the record is unfiled, and should be filed, or + // it has a category set which is not in the list of + // categories that the event has. So go looking for + // a category that is available both for the event + // and on the handheld. + for ( TQStringList::ConstIterator it = eventCategories.begin(); + it != eventCategories.end(); ++it ) + { + // Odd, an empty category string. + if ( (*it).isEmpty() ) + { + continue; + } + + if (availableHandheldCategories.tqcontains(*it)) + { + // Since the string is in the list of available categories, + // this *can't* fail. + int c = Pilot::findCategory(&info,*it,false); + Q_ASSERT( Pilot::validCategory(c) ); + de->setCategory(c); + return; + } + } + + de->setCategory(Pilot::Unfiled); +} + +void KCalSync::setCategory(KCal::Incidence *e, + const PilotRecordBase *de, + const CategoryAppInfo &info) +{ + FUNCTIONSETUP; + + if (!e || !de) + { + DEBUGKPILOT << fname << ": error. unable to set kcal category. e: [" + << (void *)e << "], de: [" << (void *)de << "]" << endl; + return; + } + + TQStringList cats=e->categories(); + int cat = de->category(); + TQString newcat = Pilot::categoryName(&info,cat); + + DEBUGKPILOT << fname << ": palm category id: [" << cat << + "], label: [" << newcat << "]" << endl; + + if ( Pilot::validCategory(cat) && (cat != Pilot::Unfiled)) + { + if (!cats.tqcontains(newcat)) + { + // if this event only has one category associated with it, then we can + // safely assume that what we should be doing here is changing it to match + // the palm. if there's already more than one category in the event, however, we + // won't cause data loss--we'll just append what the palm has to the + // event's categories + if (cats.count() <=1) + { + cats.clear(); + } + + cats.append( newcat ); + e->setCategories(cats); + } + } + + DEBUGKPILOT << fname << ": kcal categories now: [" << cats.join(",") << "]" << endl; +} diff --git a/conduits/vcalconduit/kcalRecord.h b/conduits/vcalconduit/kcalRecord.h new file mode 100644 index 0000000..efd916e --- /dev/null +++ b/conduits/vcalconduit/kcalRecord.h @@ -0,0 +1,49 @@ +#ifndef _KPILOT_KCALRECORD_H +#define _KPILOT_KCALRECORD_H +/* +** Copyright (C) 2006 by Adriaan de Groot +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +class PilotRecordBase; + +namespace KCal +{ + class Incidence; +} + +namespace KCalSync +{ + void setCategory(PilotRecordBase *de, + const KCal::Incidence *incidence, + const CategoryAppInfo &info); + void setCategory(KCal::Incidence *e, + const PilotRecordBase *de, + const CategoryAppInfo &info); +} + +#endif + diff --git a/conduits/vcalconduit/korganizerConduit.ui b/conduits/vcalconduit/korganizerConduit.ui new file mode 100644 index 0000000..7c657fe --- /dev/null +++ b/conduits/vcalconduit/korganizerConduit.ui @@ -0,0 +1,275 @@ + +VCalWidget +Adriaan de Groot + + + Form1 + + + + 0 + 0 + 593 + 209 + + + + + 5 + 5 + 0 + 0 + + + + + 570 + 270 + + + + Calendar-Conduit Options + + + + + + + + unnamed + + + 0 + + + 6 + + + + tabWidget + + + + 7 + 7 + 0 + 0 + + + + + + + Widget2 + + + General + + + + unnamed + + + + Spacer4 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + fSyncDestination + + + Sync Destination + + + + unnamed + + + + fSyncStdCalendar + + + &Standard calendar + + + <qt>Select this option to synchronize with the calendar specified by the KDE calendar settings.</qt> + + + + + fSyncFile + + + true + + + Calendar &file: + + + <qt>Select this option to use a specific calendar file, instead of the standard KDE calendar. This file must be in the in the vCalendar or iCalendar format. Enter the location of this file in the edit box or select it clicking the file picker button.</qt> + + + + + fCalendarFile + + + false + + + + 3 + 5 + 0 + 0 + + + + <qt>Enter here the location and filename of the calendar file or select it clicking the file picker button. This file must be in the iCalendar or vCalendar format.</qt> + + + + + + + fArchive + + + Store &archived records in the KDE calendar + + + When this box is checked, archived records will still +be saved in the calendar on the PC. + + + + + + + tab + + + Conflicts + + + + unnamed + + + + fTextLabel + + + + 4 + 5 + 0 + 0 + + + + Conflict &resolution: + + + fConflictResolution + + + + + + Use KPilot's Global Setting + + + + + Ask User + + + + + Do Nothing + + + + + Handheld Overrides + + + + + PC Overrides + + + + + Values From Last Sync (if possible) + + + + + Use Both Entries + + + + fConflictResolution + + + 6 + + + <qt>Select in this list how conflicting entries (entries which were edited both on your handheld and on the PC) are resolved. Possibly values are "Use KPilot's Global Setting" to use the settings defined in KPilot HotSync configuration, "Ask User" to let you decide case by case, "Do Nothing" to allow the entries to be different, "PC overrides", "Handheld overrides", "Use values from last sync" and "Use both entries" to create a new entry on both the PC and handheld. Note that this does <i>not</i> handle double-scheduling conflicts.</qt> + + + + + spacer2 + + + Vertical + + + Expanding + + + + 20 + 31 + + + + + + + + + + + fSyncFile + toggled(bool) + fCalendarFile + setEnabled(bool) + + + + tabWidget + + + + kurlrequester.h + klineedit.h + kpushbutton.h + + diff --git a/conduits/vcalconduit/pctohhstate.cc b/conduits/vcalconduit/pctohhstate.cc new file mode 100644 index 0000000..d2866fd --- /dev/null +++ b/conduits/vcalconduit/pctohhstate.cc @@ -0,0 +1,159 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the PCToHHState. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include "pilotDatabase.h" +#include "pilotRecord.h" + +#include "vcal-conduitbase.h" +#include "pctohhstate.h" +#include "cleanupstate.h" +#include "deleteunsyncedhhstate.h" + +PCToHHState::PCToHHState() +{ + fState = ePCToHH; +} + +PCToHHState::~PCToHHState() +{ +} + +void PCToHHState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting PCToHHState." << endl; + + // if we are asked to copy HH to PC, we shouldn't look for deleted records + // on the Palm, since we've just copied them all. =:) Otherwise, look for + // data on the palm that shouldn't be there and delete it if we find it.... + if ( vccb->syncMode() == ConduitAction::SyncMode::eCopyHHToPC ) + { + fNextState = new CleanUpState(); + } + else + { + fNextState = new DeleteUnsyncedHHState(); + } + + vccb->addLogMessage( i18n( "Copying records to Pilot ..." ) ); + + fStarted = true; + vccb->setHasNextRecord( true ); +} + +void PCToHHState::handleRecord( ConduitAction *ca ) +{ + FUNCTIONSETUP; + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + KCal::Incidence *e = 0L; + + if( vccb->isFullSync() ) + { + e = vccb->privateBase()->getNextIncidence(); + } + else + { + e = vccb->privateBase()->getNextModifiedIncidence(); + } + + // No more incidences to sync + if( !e ) + { + vccb->setHasNextRecord( false ); + return; + } + + // let subclasses do something with the event + vccb->preIncidence( e ); + + // find the corresponding index on the palm and sync. If there is none, + // create it. + recordid_t id = e->pilotId(); + + DEBUGKPILOT << fname << ": found PC entry with pilotID " << id <summary() << endl; + + TQDateTime start_time = e->dtStart(); + TQDateTime end_time = e->dtEnd(); + DEBUGKPILOT << fname << ": Time: "<< start_time.toString() << " until " + << end_time.toString() << endl; + + PilotRecord *s = 0L; + + if( id > 0 && ( s = vccb->database()->readRecordById( id ) ) ) + { + if( e->syncStatus() == KCal::Incidence::SYNCDEL ) + { + vccb->deletePalmRecord( e, s ); + } + else + { + vccb->changePalmRecord( e, s ); + } + + KPILOT_DELETE( s ); + } else { +#ifdef DEBUG + if (id > 0 ) + { + DEBUGKPILOT << "-------------------------------------------------" + << "--------------------------" << endl; + DEBUGKPILOT << fname << ": Could not read palm record with ID " + << id << endl; + } +#endif + vccb->addPalmRecord( e ); + } +} + +void PCToHHState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Finished PCToHHState." << endl; + vccb->setState( fNextState ); +} diff --git a/conduits/vcalconduit/pctohhstate.h b/conduits/vcalconduit/pctohhstate.h new file mode 100644 index 0000000..44f929d --- /dev/null +++ b/conduits/vcalconduit/pctohhstate.h @@ -0,0 +1,54 @@ +#ifndef _KPILOT_PCTOHHSTATE_H +#define _KPILOT_PCTOHHSTATE_H +/* pctohhstate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the pctohhstate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "conduitstate.h" + +class VCalConduitBase; + +/** + * State that handles copying of records from pc to handheld. + * @see vcal-conduitstate.h + */ +class PCToHHState : public ConduitState +{ +private: + ConduitState *fNextState; + int fPilotindex; + +public: + PCToHHState(); + virtual ~PCToHHState(); + + virtual void startSync( ConduitAction* ); + virtual void handleRecord( ConduitAction* ); + virtual void finishSync( ConduitAction* ); +}; + +#endif diff --git a/conduits/vcalconduit/teststate.cc b/conduits/vcalconduit/teststate.cc new file mode 100644 index 0000000..c762d32 --- /dev/null +++ b/conduits/vcalconduit/teststate.cc @@ -0,0 +1,127 @@ +/* KPilot +** +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file is the implementation of the TestState. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include +#include + +#include "pilotSerialDatabase.h" +#include "pilotLocalDatabase.h" +#include "pilotDateEntry.h" + +#include "teststate.h" +#include "vcal-conduitbase.h" + +TestState::TestState() : fCalendar( TQString::null ) +{ + fState = eTest; +} + +TestState::~TestState() +{ + FUNCTIONSETUP; +} + +void TestState::startSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Starting teststate." << endl; + + vccb->setHasNextRecord( true ); + fPilotindex = 0; + fStarted = true; +} + +void TestState::handleRecord( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": Handling record " << fPilotindex << endl; + + PilotRecord *record = vccb->readRecordByIndex( fPilotindex ); + + if( record ) + { + KCal::Incidence *i = vccb->incidenceFromRecord( record ); + fCalendar.addIncidence( i ); + + KPILOT_DELETE(record); + + // Schedule more work. + ++fPilotindex; + } + else + { + vccb->setHasNextRecord( false ); + } +} + +void TestState::finishSync( ConduitAction *ca ) +{ + FUNCTIONSETUP; + + VCalConduitBase *vccb = dynamic_cast(ca); + if( !vccb ) + { + return; + } + + DEBUGKPILOT << fname << ": finishing teststate." << endl; + + // No more records present on the device so lets dump the + // readed records in a file. + TQFile f( CSL1("dump.ics") ); + if( !f.exists() ) + { + f.open( IO_WriteOnly ); + f.close(); + } + + if( !fCalendar.save( CSL1("dump.ics") ) ) + { + DEBUGKPILOT << fname << ": Can't save calendar file." << endl; + } + + fCalendar.close(); + + vccb->setState( 0L ); +} diff --git a/conduits/vcalconduit/teststate.h b/conduits/vcalconduit/teststate.h new file mode 100644 index 0000000..76361e3 --- /dev/null +++ b/conduits/vcalconduit/teststate.h @@ -0,0 +1,55 @@ +#ifndef _KPILOT_TESTSTATE_H +#define _KPILOT_TESTSTATE_H +/* teststate.h KPilot +** +** Copyright (C) 2006 Bertjan Broeksema +** +** This file defines the teststate for vcal-conduitbase. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include "conduitstate.h" + +class VCalConduitBase; + +/** + * State to test the vcal-conduit. @see vcal-conduitstate.h + */ +class TestState : public ConduitState +{ +private: + KCal::CalendarLocal fCalendar; + int fPilotindex; + +public: + TestState(); + virtual ~TestState(); + + virtual void startSync( ConduitAction* ); + virtual void handleRecord( ConduitAction* ); + virtual void finishSync( ConduitAction* ); +}; + +#endif diff --git a/conduits/vcalconduit/todo-conduit.cc b/conduits/vcalconduit/todo-conduit.cc new file mode 100644 index 0000000..9b1007c --- /dev/null +++ b/conduits/vcalconduit/todo-conduit.cc @@ -0,0 +1,373 @@ +/* Todo-Conduit for syncing KPilot and KOrganizer +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 1998-2001 Dan Pilone +** Copyright (C) 1998-2000 Preston Brown +** Copyright (C) 1998 Herwin-Jan Steehouwer +** Copyright (C) 2001 Cornelius Schumacher +** +** This file is part of the todo conduit, a conduit for KPilot that +** synchronises the Pilot's todo application with the outside world, +** which currently means KOrganizer. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include + +#include +#include + +#include + +#include "todo-conduit.moc" +#include "vcalconduitSettings.h" +#include "todo-factory.h" + +#include "kcalRecord.h" +#include "todoRecord.h" + +// define conduit versions, one for the version when categories were synced for the first time, and the current version number +#define CONDUIT_VERSION_CATEGORYSYNC 10 +#define CONDUIT_VERSION 10 + +extern "C" +{ +unsigned long version_conduit_todo = Pilot::PLUGIN_API; +} + + +TodoConduitPrivate::TodoConduitPrivate(KCal::Calendar *b) : + VCalConduitPrivateBase(b) +{ + fAllTodos.setAutoDelete(false); +} + +void TodoConduitPrivate::addIncidence(KCal::Incidence*e) +{ + fAllTodos.append(static_cast(e)); + fCalendar->addTodo(static_cast(e)); +} + +int TodoConduitPrivate::updateIncidences() +{ + fAllTodos = fCalendar->todos(); + fAllTodos.setAutoDelete(false); + return fAllTodos.count(); +} + + +void TodoConduitPrivate::removeIncidence(KCal::Incidence *e) +{ + fAllTodos.remove(static_cast(e)); + if (!fCalendar) return; + fCalendar->deleteTodo(static_cast(e)); + // now just in case we're in the middle of reading through our list + // and we delete something, set reading to false so we start at the + // top again next time and don't have problems with our iterator + reading = false; +} + + + +KCal::Incidence *TodoConduitPrivate::findIncidence(recordid_t id) +{ + KCal::Todo::List::ConstIterator it; + for( it = fAllTodos.begin(); it != fAllTodos.end(); ++it ) { + KCal::Todo *todo = *it; + if ((recordid_t)(todo->pilotId()) == id) return todo; + } + + return 0L; +} + + + +KCal::Incidence *TodoConduitPrivate::findIncidence(PilotRecordBase *tosearch) +{ + PilotTodoEntry*entry=dynamic_cast(tosearch); + if (!entry) return 0L; + + TQString title=entry->getDescription(); + TQDateTime dt=readTm( entry->getDueDate() ); + + KCal::Todo::List::ConstIterator it; + for( it = fAllTodos.begin(); it != fAllTodos.end(); ++it ) { + KCal::Todo *event = *it; + if ( (event->dtDue().date() == dt.date()) && (event->summary() == title) ) return event; + } + return 0L; +} + + + +KCal::Incidence *TodoConduitPrivate::getNextIncidence() +{ + FUNCTIONSETUP; + if (reading) { + ++fAllTodosIterator; + } + else { + reading=true; + fAllTodosIterator = fAllTodos.begin(); + } + + return(fAllTodosIterator == fAllTodos.end()) ? 0L : *fAllTodosIterator; +} + + + +KCal::Incidence *TodoConduitPrivate::getNextModifiedIncidence() +{ + FUNCTIONSETUP; + KCal::Todo*e=0L; + if (!reading) + { + reading=true; + fAllTodosIterator = fAllTodos.begin(); + } + else + { + ++fAllTodosIterator; + } + if ( fAllTodosIterator != fAllTodos.end() ) e=*fAllTodosIterator; + while (fAllTodosIterator != fAllTodos.end() && + e && e->syncStatus()!=KCal::Incidence::SYNCMOD && e->pilotId()) + { + e = (++fAllTodosIterator != fAllTodos.end()) ? *fAllTodosIterator : 0L; + +#ifdef DEBUG + if(e) + DEBUGKPILOT<< e->summary()<<" had SyncStatus="<syncStatus()<writeTo(fDatabase); +} + +void TodoConduit::_getAppInfo() +{ + FUNCTIONSETUP; + // get the address application header information + + KPILOT_DELETE( fTodoAppInfo ); + fTodoAppInfo = new PilotToDoInfo(fDatabase); + fTodoAppInfo->dump(); +} + + + +const TQString TodoConduit::getTitle(PilotRecordBase *de) +{ + PilotTodoEntry*d=dynamic_cast(de); + if (d) + { + return TQString(d->getDescription()); + } + return TQString::null; +} + + + +void TodoConduit::readConfig() +{ + FUNCTIONSETUP; + VCalConduitBase::readConfig(); + // determine if the categories have ever been synce. Needed to prevent loosing + // the categories on the desktop. Also use a full sync for the first time to + // make sure the palm categories are really transferred to the desktop. + // + categoriesSynced = config()->conduitVersion()>=CONDUIT_VERSION_CATEGORYSYNC; + if (!categoriesSynced && !isFullSync() ) + { + changeSync(SyncMode::eFullSync); + } + DEBUGKPILOT<<"categoriesSynced=" << categoriesSynced << endl; +} + +void TodoConduit::preSync() +{ + FUNCTIONSETUP; + VCalConduitBase::preSync(); + _getAppInfo(); +} + +void TodoConduit::postSync() +{ + FUNCTIONSETUP; + VCalConduitBase::postSync(); + // after this successful sync the categories have been synced for sure + config()->setConduitVersion( CONDUIT_VERSION ); + config()->writeConfig(); + _setAppInfo(); +} + + + +PilotRecord *TodoConduit::recordFromIncidence(PilotRecordBase *de, const KCal::Incidence *e) +{ + FUNCTIONSETUP; + + if (!de || !e) + { + DEBUGKPILOT << fname + << ": got NULL entry or NULL incidence." << endl; + return 0L; + } + + PilotTodoEntry *todoEntry = dynamic_cast(de); + if (!todoEntry) + { + // Secretly wasn't a todo entry after all + return 0L; + } + + const KCal::Todo *todo = dynamic_cast(e); + if (!todo) + { + DEBUGKPILOT << fname << ": Incidence is not a todo." << endl; + return 0L; + } + + // don't need to check for null pointers here, the recordFromIncidence(PTE*, KCal::Todo*) will do that. + if (KCalSync::setTodoEntry(todoEntry,todo,*fTodoAppInfo->categoryInfo())) + { + return todoEntry->pack(); + } + else + { + return 0L; + } +} + +KCal::Incidence *TodoConduit::incidenceFromRecord(KCal::Incidence *e, const PilotRecordBase *de) +{ + FUNCTIONSETUP; + + if (!de || !e) + { + DEBUGKPILOT << fname + << ": Got NULL entry or NULL incidence." << endl; + return 0L; + } + + const PilotTodoEntry *todoEntry = dynamic_cast(de); + if (!todoEntry) + { + DEBUGKPILOT << fname << ": HH record not a todo entry." << endl; + return 0L; + } + + KCal::Todo *todo = dynamic_cast(e); + if (!todo) + { + DEBUGKPILOT << fname << ": Incidence is not a todo." << endl; + return 0L; + } + + KCalSync::setTodo(todo, todoEntry,*fTodoAppInfo->categoryInfo()); + return e; +} + + + + + +void TodoConduit::preRecord(PilotRecord*r) +{ + FUNCTIONSETUP; + if (!categoriesSynced && r) + { + const PilotRecordBase *de = newPilotEntry(r); + KCal::Incidence *e = fP->findIncidence(r->id()); + KCalSync::setCategory(dynamic_cast(e), + dynamic_cast(de), + *fTodoAppInfo->categoryInfo()); + } +} + + + + + + +static VCalConduitSettings *config_vcal = 0L; + +VCalConduitSettings *TodoConduit::theConfig() { + if (!config_vcal) + { + config_vcal = new VCalConduitSettings(CSL1("Calendar")); + } + + return config_vcal; +} + +VCalConduitSettings *TodoConduit::config() { + return theConfig(); +} diff --git a/conduits/vcalconduit/todo-conduit.desktop b/conduits/vcalconduit/todo-conduit.desktop new file mode 100644 index 0000000..d1101af --- /dev/null +++ b/conduits/vcalconduit/todo-conduit.desktop @@ -0,0 +1,105 @@ +[Desktop Entry] +Type=Service +Comment=This conduit syncs the ToDo list from your handheld to KOrganizer. +Comment[af]=Hierdie pad sinkroniseer die Te-doen lys vanaf jou draagbare toestel na KOrganizer. +Comment[bg]=Синхронизация на списъка със задачи на мобилно устройство с организатора в KDE +Comment[bs]=Ovaj conduit sinhronizuje listu Zadataka na ručnom računaru sa KOrganizerom. +Comment[ca]=Aquest conducte sincronitza la llista de pendents des de la vostra agenda electrònica a KOrganizer. +Comment[cs]=Toto propojení synchronizuje seznam úkolů s KOrganizérem +Comment[cy]=Mae'r cwndid yma yn cydamseru'r rhestr I-Wneud o'ch llawiadur i KTrefnydd. +Comment[da]=Denne kanal synkroniserer din gøremålsliste fra din håndholdte til KOrganizer. +Comment[de]=Abgleich der Aufgabenlisten von Taschencomputer und KOrganizer +Comment[el]=Αυτός ο σύνδεσμος συγχρονίζει τη λίστα προς υλοποίηση από τον υπολογιστή παλάμης σας στο KOrganizer. +Comment[eo]=Tiu kanalo sinkronigas la farendaĵliston de via poŝkomputilo kun KOrganizilo. +Comment[es]=Este conducto sincroniza la lista de tareas pendientes de su agenda electrónica con KOrganizer. +Comment[et]=See kanal sünkroniseerib pihuarvuti ja KOrganizeri ülesannete nimekirja. +Comment[eu]=Kanal honek zure agenda elektronikoko egitekoen zerrenda KOrganizer-era sinkronizatzen du. +Comment[fa]=این لوله، فهرست کارهایی که باید انجام شود را از دستی شما با KOrganizer همگام‌سازی می‌کند. +Comment[fi]=Tämä yhdyskäytävä synkronoi taskutietokoneen tehtävälistan KOrganizeriin. +Comment[fr]=Ce canal synchronise la liste des tâches de votre Palm sur KOrganizer. +Comment[fy]=Dit conduit syngronisearret de takenlist fan jo handheld mei KOrganizer. +Comment[gl]=Este conducto sincroniza a lista de tarefas pendentes dende o seu aparello portátil a KOrganizer. +Comment[hi]=यह कन्ड्यूइट आपके हैंण्डहेल्ड से टू-डू सूची को के-आर्गेनाइज़र में सिंक करता है +Comment[hu]=Ezzel a csatolóval a Pilot tennivalólistája és a KOrganizer tennivalói között lehet szinkronizálást végezni. +Comment[is]=Þessi rás samstillir verkþáttalista lófatölvunnar þinnar og KOrganizer. +Comment[it]=Questo condotto sincronizza il tuo Pilot con la lista delle cose da fare di KOrganizer. +Comment[ja]=このコンジットはハンドヘルドの To-Do と KOrganizer を同期させます。 +Comment[kk]=Қалта құрылғыдағы жоспар тізімін KOrganizer-мен қадамдастыру арнасы. +Comment[km]=បំពង់​នេះ​ធ្វើ​សមកាលកម្ម​បញ្ជី​ការងារ​ត្រូវ​ធ្វើ​ពី​ឧបករណ៍​យួរ​ដៃ​របស់​អ្នកទៅ KOrganizer ។ +Comment[lt]=Šis kanalas sinchronizuoja Jūsų darbų sąrašą iš delninuko su su KOrganizer sąrašu. +Comment[ms]=Saluran ini mensegerakkan senarai tugasan dari komputer telapak anda ke KOrganizer. +Comment[nb]=Denne kanalen synkroniserer gjørelista fra PDA-en til KOrganizer. +Comment[nds]=Synkroniseert de Opgavenlist vun den Handreekner mit KOrganizer. +Comment[ne]=यो कन्डयुटले केडीई आयोजकमा ह्यान्डहेल्डबाट कार्य गर्ने सूचि सिन्क गर्दछ । +Comment[nl]=Dit conduit synchroniseert de takenlijst van uw handheld met KOrganizer. +Comment[nn]=Denne koplinga synkroniserer oppgåvelista frå den handheldte eininga di til KOrganizer. +Comment[pl]=Ten łącznik synchronizuje listę zadań z palmtopa z KOrganizerem. +Comment[pt]=Esta conduta sincroniza a lista de 'A Fazer' do seu dispositivo com o KOrganizer. +Comment[pt_BR]=Este conduíte sincroniza a lista de tarefas do seu handheld com o KOrganizer. +Comment[ru]=Канал синхронизации списка задач КПК и органайзера KDE. +Comment[sk]=Táto spojka synchronizuje zoznam ToDo s KOrganizer. +Comment[sl]=Ta veznik usklajuje seznam čakajočih opravil z vašega ročnega računalnika s KOrganizerjem. +Comment[sr]=Овај провод синхронизује листу обавеза из вашег ручног рачунара са KOrganizer-ом. +Comment[sr@Latn]=Ovaj provod sinhronizuje listu obaveza iz vašeg ručnog računara sa KOrganizer-om. +Comment[sv]=Den här kanalen synkroniserar uppgiftslistan i handdatorn med Korganizer. +Comment[ta]=இந்த காப்புக்குழாய் உங்கள் கையேட்டில் இருந்து செய்யவேண்டிய பட்டியலை கேஅமைபாளருக்கு ஒத்திசைக்கிறது +Comment[tg]=Канали синхронизатсияи рӯйхати вазифоти Pilot ва органайзери KDE. +Comment[tr]=Bu bileşen el bilgisayarınızdaki Yapılacaklar Listesini KOrganizer ile birleştirir. +Comment[uk]=Цей акведук синхронізує список завдань кишенькового пристрою з тижневиком KOrganizer. +Comment[zh_CN]=此管道会将您的待办列表与 KOrganizer 同步。 +Comment[zh_TW]=此軟體將您的 handheld 與 KOrganizer 的待辦事項清單同步。 +Name=ToDos (KOrganizer) +Name[af]=Te-doen (KOrganizer) +Name[ar]=الواجبات (KOrganizer) +Name[be]=Заданні (K Арганізатар) +Name[bg]=Задачи (KOrganizer) +Name[br]=Traoù d'ober (KOrganizer) +Name[bs]=Zadaci (KOrganizer) +Name[ca]=Pendents (KOrganizer) +Name[cs]=Úkoly (KOrganizer) +Name[da]=Gøremål (KOrganizer) +Name[de]=Aufgaben (KOrganizer) +Name[el]=Προς υλοποίηση εργασίες (KOrganizer) +Name[eo]=Farendaĵoj (KOrganizilo) +Name[es]=Tareas pendientes (KOrganizer) +Name[et]=Ülesanded (KOrganizer) +Name[eu]=Egitekoak (KOrganizer) +Name[fa]=کارهای انجامی (KOrganizer) +Name[fi]=Tehtävät (KOrganizer) +Name[fr]=Tâches (KOrganizer) +Name[fy]=Taken (KOrganizer) +Name[ga]=Tascanna (KOrganizer) +Name[gl]=Pendentes (KOrganizer) +Name[he]=מטלות (ארגונית) +Name[hu]=Feladatok (KOrganizer) +Name[is]=Verkþáttalistar (KOrganizer) +Name[it]=Cose da fare (KOrganizer) +Name[ja]=To-Do (KOrganizer) +Name[kk]=Жоспарлар (KOrganizer) +Name[km]=ការងារ​ត្រូវ​ធ្វើ (KOrganizer) +Name[lt]=Darbai (KOrganizer) +Name[ms]=Tugsan (KOrganizer) +Name[nb]=Gjøreliste (KOrganizer) +Name[nds]=Opgaven (KOrganizer) +Name[ne]=गर्नुपर्ने कार्यहरू (केडीई आयोजक) +Name[nl]=Taken (KOrganizer) +Name[nn]=Oppgåveliste (KOrganizer) +Name[pl]=Do zrobienia (Korganizer) +Name[pt]=Por Fazer (KOrganizer) +Name[pt_BR]=Tarefas (KOrganizer) +Name[ru]=Задачи (KOrganizer) +Name[se]=Barggut (KOrganizer) +Name[sk]=Úlohy (KOrganizer) +Name[sl]=Čakajoča opravila (KOrganizer) +Name[sr]=Обавезе (KOrganizer) +Name[sr@Latn]=Obaveze (KOrganizer) +Name[sv]=Uppgifter (Korganizer) +Name[ta]=செய்ய வேண்டியவை(கேஅமைப்பாளர்) +Name[tg]=Вазифот (KOrganizer) +Name[tr]=Yapılacaklar (KOrganizer) +Name[uk]=Завдання (KOrganizer) +Name[zh_CN]=待办事项 (KOrganizer) +Name[zh_TW]=待辦事項(KOrganizer) +Implemented=file +ServiceTypes=KPilotConduit +X-KDE-Library=conduit_todo diff --git a/conduits/vcalconduit/todo-conduit.h b/conduits/vcalconduit/todo-conduit.h new file mode 100644 index 0000000..8d8780e --- /dev/null +++ b/conduits/vcalconduit/todo-conduit.h @@ -0,0 +1,108 @@ +#ifndef _KPILOT_TODO_CONDUIT_H +#define _KPILOT_TODO_CONDUIT_H +/* todo-conduit.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 1998-2001 Dan Pilone +** Copyright (C) 1998-2000 Preston Brown +** Copyright (C) 1998 Herwin-Jan Steehouwer +** +** This file is part of the todo conduit, a conduit for KPilot that +** synchronises the Pilot's todo application with the outside world, +** which currently means KOrganizer. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include +#include +#include "vcal-conduitbase.h" + +class PilotSerialDatabase; +class PilotLocalDatabase; + +class TodoConduitPrivate : public VCalConduitPrivateBase +{ +public: + TodoConduitPrivate(KCal::Calendar *buddy); + virtual ~TodoConduitPrivate() {}; + + KCal::Todo::List fAllTodos; + KCal::Todo::List::ConstIterator fAllTodosIterator; + + virtual int updateIncidences(); + virtual void addIncidence(KCal::Incidence*); + virtual void removeIncidence(KCal::Incidence *); + virtual KCal::Incidence *findIncidence(recordid_t); + virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch); + virtual KCal::Incidence *getNextIncidence(); + virtual KCal::Incidence *getNextModifiedIncidence(); + virtual int count() {return fAllTodos.count();}; +} ; + + + +class TodoConduit : public VCalConduitBase +{ +Q_OBJECT +public: + TodoConduit(KPilotLink *, + const char *name=0L, + const TQStringList &args = TQStringList()); + virtual ~TodoConduit(); + +protected: + virtual const TQString getTitle(PilotRecordBase *de); + + virtual const TQString dbname() { return CSL1("ToDoDB"); }; + virtual void preSync(); + virtual VCalConduitPrivateBase *createPrivateCalendarData(KCal::Calendar *fCalendar) + { + return new TodoConduitPrivate(fCalendar); + }; + + virtual void readConfig(); + void _getAppInfo(); + void _setAppInfo(); + virtual void postSync(); + + virtual PilotRecordBase *newPilotEntry(PilotRecord*r) + { + return new PilotTodoEntry(r); + }; + virtual KCal::Incidence*newIncidence() { return new KCal::Todo; }; + + virtual void preRecord(PilotRecord*r); + virtual VCalConduitSettings *config(); +public: + static VCalConduitSettings *theConfig(); + +protected: + + virtual PilotRecord *recordFromIncidence(PilotRecordBase *de, const KCal::Incidence *e); + virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *e, const PilotRecordBase *de); + + PilotToDoInfo *fTodoAppInfo; + bool categoriesSynced; +} ; + +#endif diff --git a/conduits/vcalconduit/todo-factory.cc b/conduits/vcalconduit/todo-factory.cc new file mode 100644 index 0000000..fad8841 --- /dev/null +++ b/conduits/vcalconduit/todo-factory.cc @@ -0,0 +1,46 @@ +/* KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the factory for the todo-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include "pluginfactory.h" + +#include "todo-setup.h" +#include "todo-conduit.h" + +extern "C" +{ + +void *init_conduit_todo() +{ + return new ConduitFactory; +} + +} + diff --git a/conduits/vcalconduit/todo-factory.h b/conduits/vcalconduit/todo-factory.h new file mode 100644 index 0000000..52a2d5e --- /dev/null +++ b/conduits/vcalconduit/todo-factory.h @@ -0,0 +1,40 @@ +#ifndef _KPILOT_TODO_FACTORY_H +#define _KPILOT_TODO_FACTORY_H +/* todo-factory.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the factory for the todo-conduit plugin. +** It also defines the class for the behavior of the setup dialog. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +extern "C" +{ + +void *init_libtodoconduit(); + +} + +#endif diff --git a/conduits/vcalconduit/todo-setup.cc b/conduits/vcalconduit/todo-setup.cc new file mode 100644 index 0000000..19a731c --- /dev/null +++ b/conduits/vcalconduit/todo-setup.cc @@ -0,0 +1,86 @@ +/* KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the factory for the todo-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include + +#include "korganizerConduit.h" +#include "todo-conduit.h" +#include "todo-setup.h" + + + +ToDoWidgetSetup::ToDoWidgetSetup(TQWidget *w, const char *n) : + VCalWidgetSetupBase(w,n) +{ + FUNCTIONSETUP; + fConduitName = i18n("To-do"); + KAboutData *fAbout = new KAboutData("todoConduit", + I18N_NOOP("To-do Conduit for KPilot"), + KPILOT_VERSION, + I18N_NOOP("Configures the To-do Conduit for KPilot"), + KAboutData::License_GPL, + "(C) 2001, Adriaan de Groot\n(C) 2002-2003, Reinhold Kainhofer"); + fAbout->addAuthor("Dan Pilone", + I18N_NOOP("Original Author")); + fAbout->addAuthor("Preston Brown", + I18N_NOOP("Original Author")); + fAbout->addAuthor("Herwin-Jan Steehouwer", + I18N_NOOP("Original Author")); + fAbout->addAuthor("Adriaan de Groot", + I18N_NOOP("Maintainer"), + "groot@kde.org", + "http://www.cs.kun.nl/~adridg/kpilot"); + fAbout->addAuthor("Reinhold Kainhofer", + I18N_NOOP("Maintainer"), + "reinhold@kainhofer.com", + "http://reinhold.kainhofer.com/Linux/"); + + ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget,fAbout); + + fConfigWidget->fSyncDestination->setTitle(i18n("To-do Destination")); +} + +ToDoWidgetSetup::~ToDoWidgetSetup() +{ + FUNCTIONSETUP; +} + +/* static */ ConduitConfigBase *ToDoWidgetSetup::create(TQWidget *w, const char *n) +{ + return new ToDoWidgetSetup(w,n); +} + +VCalConduitSettings*ToDoWidgetSetup::config() +{ + return TodoConduit::theConfig(); +} + diff --git a/conduits/vcalconduit/todo-setup.h b/conduits/vcalconduit/todo-setup.h new file mode 100644 index 0000000..b9b919c --- /dev/null +++ b/conduits/vcalconduit/todo-setup.h @@ -0,0 +1,44 @@ +#ifndef _KPILOT_TODO_SETUP_H +#define _KPILOT_TODO_SETUP_H +/* todo-setup.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the class for the behavior of the setup dialog. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "vcal-setup.h" + +class ToDoWidgetSetup : public VCalWidgetSetupBase +{ +public: + ToDoWidgetSetup(TQWidget *,const char *); + virtual ~ToDoWidgetSetup(); + + virtual VCalConduitSettings*config(); + static ConduitConfigBase *create(TQWidget *, const char *); +} ; + +#endif diff --git a/conduits/vcalconduit/todoRecord.cc b/conduits/vcalconduit/todoRecord.cc new file mode 100644 index 0000000..9bc0998 --- /dev/null +++ b/conduits/vcalconduit/todoRecord.cc @@ -0,0 +1,141 @@ +/* vcalRecord.cc KPilot +** +** Copyright (C) 2006 by Adriaan de Groot +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include +#include +#include + +#include "pilot.h" +#include "pilotTodoEntry.h" + +#include "kcalRecord.h" +#include "todoRecord.h" + +bool KCalSync::setTodoEntry(PilotTodoEntry *de, + const KCal::Todo *todo, + const CategoryAppInfo &info) +{ + FUNCTIONSETUP; + if (!de || !todo) { + DEBUGKPILOT << fname << ": NULL todo given... Skipping it" << endl; + return false; + } + + // set secrecy, start/end times, alarms, recurrence, exceptions, summary and description: + if (todo->secrecy()!=KCal::Todo::SecrecyPublic) + { + de->setSecret( true ); + } + + // update it from the iCalendar Todo. + + if (todo->hasDueDate()) { + struct tm t = writeTm(todo->dtDue()); + de->setDueDate(t); + de->setIndefinite(0); + } else { + de->setIndefinite(1); + } + + // TODO: take recurrence (code in VCAlConduit) from ActionNames + + setCategory(de, todo, info); + + // TODO: sync the alarm from ActionNames. Need to extend PilotTodoEntry + de->setPriority(todo->priority()); + + de->setComplete(todo->isCompleted()); + + // what we call summary pilot calls description. + de->setDescription(todo->summary()); + + // what we call description pilot puts as a separate note + de->setNote(todo->description()); + + DEBUGKPILOT << "-------- " << todo->summary() << endl; + return de->pack(); +} + +bool KCalSync::setTodo(KCal::Todo *e, + const PilotTodoEntry *de, + const CategoryAppInfo &info) +{ + FUNCTIONSETUP; + + if (!e) + { + DEBUGKPILOT << fname + << ": null todo entry given. skipping..." << endl; + return false; + } + if (!de) + { + DEBUGKPILOT << fname + << "! NULL todo entry given... Skipping it" << endl; + return false; + } + + + e->setPilotId(de->id()); + DEBUGKPILOT<pilotId() << "] ..."<setSecrecy(de->isSecret() ? KCal::Todo::SecrecyPrivate : KCal::Todo::SecrecyPublic); + + if (de->getIndefinite()) { + e->setHasDueDate(false); + } else { + e->setDtDue(readTm(de->getDueDate())); + e->setHasDueDate(true); + } + + // Categories + setCategory(e, de, info); + + // PRIORITY // + e->setPriority(de->getPriority()); + + // COMPLETED? // + e->setCompleted(de->getComplete()); + if ( de->getComplete() && !e->hasCompletedDate() ) { + e->setCompleted( TQDateTime::tqcurrentDateTime() ); + } + + e->setSummary(de->getDescription()); + e->setDescription(de->getNote()); + + // NOTE: This MUST be done last, since every other set* call + // calls updated(), which will trigger an + // setSyncStatus(SYNCMOD)!!! + e->setSyncStatus(KCal::Incidence::SYNCNONE); + + return true; +} diff --git a/conduits/vcalconduit/todoRecord.h b/conduits/vcalconduit/todoRecord.h new file mode 100644 index 0000000..85ffd6a --- /dev/null +++ b/conduits/vcalconduit/todoRecord.h @@ -0,0 +1,49 @@ +#ifndef _KPILOT_TODORECORD_H +#define _KPILOT_TODORECORD_H +/* +** Copyright (C) 2006 by Adriaan de Groot +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +namespace KCal +{ + class Todo; +} + +class PilotTodoEntry; + +namespace KCalSync +{ + bool setTodo(KCal::Todo *e, + const PilotTodoEntry *de, + const CategoryAppInfo &info); + bool setTodoEntry(PilotTodoEntry *de, + const KCal::Todo *e, + const CategoryAppInfo &info); +} + +#endif + diff --git a/conduits/vcalconduit/vcal-conduit.cc b/conduits/vcalconduit/vcal-conduit.cc new file mode 100644 index 0000000..d882cf8 --- /dev/null +++ b/conduits/vcalconduit/vcal-conduit.cc @@ -0,0 +1,309 @@ +/* KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include +#include +#include + +#include "pilotDateEntry.h" +#include "pilotDatabase.h" + +#include "vcal-conduit.moc" +#include "vcalconduitSettings.h" + +#include "kcalRecord.h" +#include "vcalRecord.h" + + +extern "C" +{ + +unsigned long version_conduit_vcal = Pilot::PLUGIN_API; + +} + + + + +VCalConduitPrivate::VCalConduitPrivate(KCal::Calendar *b) : + VCalConduitPrivateBase(b) +{ + fAllEvents.setAutoDelete(false); +} + +void VCalConduitPrivate::addIncidence(KCal::Incidence*e) +{ + fAllEvents.append(dynamic_cast(e)); + fCalendar->addEvent(dynamic_cast(e)); +} + +int VCalConduitPrivate::updateIncidences() +{ + FUNCTIONSETUP; + if (!fCalendar) return 0; + fAllEvents = fCalendar->events(); + fAllEvents.setAutoDelete(false); + return fAllEvents.count(); +} + + +void VCalConduitPrivate::removeIncidence(KCal::Incidence *e) +{ + // use dynamic_cast which returns a null pointer if the class does not match... + fAllEvents.remove(dynamic_cast(e)); + if (!fCalendar) return; + fCalendar->deleteEvent(dynamic_cast(e)); + // now just in case we're in the middle of reading through our list + // and we delete something, set reading to false so we start at the + // top again next time and don't have problems with our iterator + reading = false; +} + + +KCal::Incidence *VCalConduitPrivate::findIncidence(recordid_t id) +{ + KCal::Event::List::ConstIterator it; + for( it = fAllEvents.begin(); it != fAllEvents.end(); ++it ) { + KCal::Event *event = *it; + if ((recordid_t)event->pilotId() == id) return event; + } + return 0L; +} + +KCal::Incidence *VCalConduitPrivate::findIncidence(PilotRecordBase *tosearch) +{ + PilotDateEntry*entry=dynamic_cast(tosearch); + if (!entry) return 0L; + + TQString title=entry->getDescription(); + TQDateTime dt=readTm( entry->getEventStart() ); + + KCal::Event::List::ConstIterator it; + for( it = fAllEvents.begin(); it != fAllEvents.end(); ++it ) { + KCal::Event *event = *it; + if ( (event->dtStart() == dt) && (event->summary() == title) ) return event; + } + return 0L; +} + + + +KCal::Incidence *VCalConduitPrivate::getNextIncidence() +{ + FUNCTIONSETUP; + + if (reading) { + ++fAllEventsIterator; + } else { + reading=true; + fAllEventsIterator = fAllEvents.begin(); + } + // At end of list, or empty list. + return (fAllEventsIterator == fAllEvents.end()) ? 0L : *fAllEventsIterator; +} + +/** Find the next incidence in the list which ddoes not have the SYNCNONE flag set. The + * current position is always stored in the iteratoor fAllEventsIterator, so we can just + * start from there. Only if reading==false, we haven't yet started goind through the + * incidents, so start at fAllEvents.begin() in that case */ +KCal::Incidence *VCalConduitPrivate::getNextModifiedIncidence() +{ + FUNCTIONSETUP; + KCal::Event*e=0L; + if (!reading) + { + // Start from the top + reading=true; + fAllEventsIterator = fAllEvents.begin(); + } + else + { + // Move on from current position + ++fAllEventsIterator; + } + + // Fetch (new) current if possible. + if ( fAllEventsIterator != fAllEvents.end() ) e = *fAllEventsIterator; + // Then walk the list until we find an unsynced entry + while ( fAllEventsIterator != fAllEvents.end() && + e && e->syncStatus()!=KCal::Incidence::SYNCMOD && e->pilotId() > 0) + { + e = (++fAllEventsIterator != fAllEvents.end()) ? *fAllEventsIterator : 0L; + } + return (fAllEventsIterator == fAllEvents.end()) ? 0L : *fAllEventsIterator; +} + + + +/**************************************************************************** + * VCalConduit class * + ****************************************************************************/ + +VCalConduit::VCalConduit(KPilotLink *d, + const char *n, + const TQStringList &a) : + VCalConduitBase(d,n,a), + fAppointmentAppInfo( 0L ) +{ + FUNCTIONSETUP; + fConduitName=i18n("Calendar"); +} + + +VCalConduit::~VCalConduit() +{ +// FUNCTIONSETUP; +} + +VCalConduitPrivateBase *VCalConduit::createPrivateCalendarData(KCal::Calendar *fCalendar) { + return new VCalConduitPrivate(fCalendar); +} + +void VCalConduit::_getAppInfo() +{ + FUNCTIONSETUP; + // get the address application header information + KPILOT_DELETE(fAppointmentAppInfo); + fAppointmentAppInfo = new PilotDateInfo( fDatabase ); +} + +const TQString VCalConduit::getTitle(PilotRecordBase *de) +{ + PilotDateEntry*d=dynamic_cast(de); + if (d) return TQString(d->getDescription()); + return TQString::null; +} + + + +PilotRecord *VCalConduit::recordFromIncidence(PilotRecordBase *de, const KCal::Incidence*e) +{ + FUNCTIONSETUP; + if (!de || !e) + { + DEBUGKPILOT << fname + << ": got NULL entry or NULL incidence." << endl; + return 0L; + } + + if ( (e->recurrenceType() == KCal::Recurrence::rYearlyDay) || + (e->recurrenceType() == KCal::Recurrence::rYearlyPos) ) + { + // Warn ahead of time + emit logMessage(i18n("Event \"%1\" has a yearly recurrence other than by month, will change this to recurrence by month on handheld.").arg(e->summary())); + } + + PilotDateEntry *dateEntry = dynamic_cast(de); + if (!dateEntry) + { + // Secretly wasn't a date entry after all + return 0L; + } + + const KCal::Event *event = dynamic_cast(e); + if (!event) + { + DEBUGKPILOT << fname << ": Incidence is not an event." << endl; + return 0L; + } + + if (KCalSync::setDateEntry(dateEntry, event,*fAppointmentAppInfo->categoryInfo())) + { + return dateEntry->pack(); + } + else + { + return 0L; + } +} + +KCal::Incidence *VCalConduit::incidenceFromRecord(KCal::Incidence *e, const PilotRecordBase *de) +{ + FUNCTIONSETUP; + + if (!de || !e) + { + DEBUGKPILOT << fname + << ": Got NULL entry or NULL incidence." << endl; + return 0L; + } + + const PilotDateEntry *dateEntry = dynamic_cast(de); + if (!dateEntry) + { + DEBUGKPILOT << fname << ": HH record not a date entry." << endl; + return 0L; + } + + KCal::Event *event = dynamic_cast(e); + if (!event) + { + DEBUGKPILOT << fname << ": Incidence is not an event." << endl; + return 0L; + } + + KCalSync::setEvent(event, dateEntry,*fAppointmentAppInfo->categoryInfo()); + return e; +} + + + +PilotRecordBase * VCalConduit::newPilotEntry(PilotRecord*r) +{ + return new PilotDateEntry(r); +} + +KCal::Incidence* VCalConduit::newIncidence() +{ + return new KCal::Event; +} + +static VCalConduitSettings *config_vcal = 0L; + +VCalConduitSettings *VCalConduit::theConfig() +{ + if (!config_vcal) + { + config_vcal = new VCalConduitSettings(CSL1("Calendar")); + } + + return config_vcal; +} + +VCalConduitSettings *VCalConduit::config() { + return theConfig(); +} + + + +// vim: ts=4:sw=4:noexpandtab: + diff --git a/conduits/vcalconduit/vcal-conduit.desktop b/conduits/vcalconduit/vcal-conduit.desktop new file mode 100644 index 0000000..c123bf1 --- /dev/null +++ b/conduits/vcalconduit/vcal-conduit.desktop @@ -0,0 +1,103 @@ +[Desktop Entry] +Type=Service +Name=Calendar (KOrganizer) +Name[af]=Kalender (KOrganizer) +Name[ar]=التقويم (KOrganizer) +Name[be]=Каляндар (K Арганізатар) +Name[bg]=Календар (KOrganizer) +Name[br]=Deiziadur (KOrganizer) +Name[bs]=Kalendar (KOrganizer) +Name[ca]=Calendari (KOrganizer) +Name[cs]=Kalendář (KOrganizer) +Name[da]=Kalender (KOrganizer) +Name[de]=Kalender (KOrganizer) +Name[el]=Ημερολόγιο (KOrganizer) +Name[eo]=Kalendaro (KOrganizilo) +Name[es]=Calendario (KOrganizer) +Name[et]=Kalender (KOrganizer) +Name[eu]=Egutegia (KOrganizer) +Name[fa]=تقویم (KOrganizer) +Name[fi]=Kalenteri (KOrganizer) +Name[fr]=Agenda (KOrganizer) +Name[fy]=Aginda (KOrganizer) +Name[ga]=Féilire (KOrganizer) +Name[gl]=Calendario (KOrganizer) +Name[he]=לוח שנה (ארגונית) +Name[hu]=Naptár (KOrganizer) +Name[is]=Dagbók (KOrganizer) +Name[it]=Calendario (KOrganizer) +Name[ja]=カレンダー (KOrganizer) +Name[kk]=Күнтізбе (KOrganizer) +Name[km]=ប្រតិទិន (KOrganizer) +Name[lt]=Kalendorius (KOrganizer) +Name[mk]=Календар (КОрганизатор) +Name[ms]=Kalendar (KOrganizer) +Name[nb]=Kalender (KOrganizer) +Name[nds]=Kalenner (KOrganizer) +Name[ne]=क्यालेन्डर (केडीई आयोजक) +Name[nl]=Agenda (KOrganizer) +Name[nn]=Kalender (KOrganizer) +Name[pl]=Kalendarz (Korganizer) +Name[pt]=Calendário (KOrganizer) +Name[pt_BR]=Calendário (KOrganizer) +Name[ru]=Календарь (KOrganizer) +Name[se]=Kaleandar (KOrganizer) +Name[sk]=Kalendár (KOrganizer) +Name[sl]=Koledar (KOrganizer) +Name[sr]=Календар (KOrganizer) +Name[sr@Latn]=Kalendar (KOrganizer) +Name[sv]=Kalender (Korganizer) +Name[ta]=நாள்காட்டி(கேஅமைப்பாளர்) +Name[tg]=Тақвимот (KOrganizer) +Name[tr]=Takvim (KOrganizer) +Name[uk]=Календар (KOrganizer) +Name[zh_CN]=日历 (KOrganizer) +Name[zh_TW]=行事曆(KOrganizer) +Comment=This conduit synchronizes your handheld with the KOrganizer datebook. +Comment[af]=Hierdie pad sinkroniseer jou draagbare toestel met die KOrganizer datum boek. +Comment[bg]=Синхронизация на календара на мобилно устройство с организатора в KDE. +Comment[ca]=Aquest conducte sincronitza la vostra agenda electrònica amb la llibreta de dates de KOrganizer. +Comment[cs]=Toto propojení synchronizuje seznam úkolů s KOrganizérem. +Comment[da]=Denne kanal synkroniserer din håndholdte med KOrganizer-datobogen. +Comment[de]=Abgleich des Taschencomputers mit dem KOrganizer-Terminkalender +Comment[el]=Αυτός ο σύνδεσμος συγχρονίζει τον υπολογιστή παλάμης σας με το βιβλίο ημερομηνιών του KOrganizer. +Comment[en_GB]=This conduit synchronises your handheld with the KOrganizer datebook. +Comment[eo]=Tiu kanalo sinkronigas vian poŝkomputilon kun la datlibro de KOrganizilo. +Comment[es]=Este conducto sincroniza su agenda electrónica con la libreta de fechas de KOrganizer. +Comment[et]=See kanal sünkroniseerib pihuseadme ja KOrganizeri kalendri. +Comment[eu]=Kanal honek zure agenda elektronikoa KOrganizer-en data-liburuarekin sinkronizatzen du. +Comment[fa]=این لوله، دستی شما را با کتاب دادۀ KOrganizer همگام می‌سازد. +Comment[fi]=Tämä yhdyskäytävä synkronoi taskutietokoneen KOrganizerin päiväkirjaan. +Comment[fr]=Ce canal synchronise votre Palm avec l'agenda KOrganizer. +Comment[fy]=Dit conduit syngronisearret jo handheld mei KOrganizer's datumboek. +Comment[gl]=Este conducto sincroniza o seu aparello portátil co libro de datos de KOrganizer. +Comment[hu]=Ezzel a csatolóval szinkronizálhatók a kézi számítógép és a KOrganizer dátumai. +Comment[is]=Þessi rás samstillir lófatölvuna þína við dagbók KOrganizer. +Comment[it]=Questo conduit sincronizza il tuo palmare con il calendario di KOrganizer. +Comment[ja]=このコンジットはハンドヘルドを KOrganizer の手帳と同期させます。 +Comment[kk]=Қалта құрылғыдағы күнтізбені KOrganizer-мен қадамдастыру арнасы. +Comment[km]=បំពង់​នេះ​ធ្វើ​សមកាលកម្ម​ឧបករណ៍​យួរ​ដៃ​របស់​អ្នក​ជាមួយ​នឹង​សៀវភៅ​កាលបរិច្ឆេទ KOrganizer ។ +Comment[lt]=Šis kanalas sinchronizuoja jūsų delninuką su KOrganizer datų knyga. +Comment[mk]=Овој канал ги синхронизира рачниот уред и датумите од KОрганизатор. +Comment[ms]=Saluran ini mensegerakkan komputer telapak dengan buku tarikh KOrganizer. +Comment[nb]=Denne kanalen synkroniserer PDA-en med KOrganizers almanakk. +Comment[nds]=Synkroniseert den Mötenkalenner vun den Handreekner mit KOrganizer. +Comment[ne]=यो कन्ड्युटले केडीई आयोजक मिति पुस्तिकामा ह्यान्डहेल्ड समक्रमण गर्छ । +Comment[nl]=Dit conduit synchroniseert uw handheld met KOrganizer's datumboek. +Comment[pl]=Ten łącznik synchronizuje palmtopa z terminarzem KOrganizera. +Comment[pt]=Esta conduta sincroniza o seu dispositivo móvel com a agenda do KOrganizer. +Comment[pt_BR]=Este Conduíte sincroniza seu handheld com a agenda do KOrganizer. +Comment[ru]=Канал синхронизации календаря КПК и органайзера KDE. +Comment[sk]=Táto spojka synchronizuje prenosné zariadenie s KOrganizer. +Comment[sl]=Ta veznik uskladni vaš ročni računalnik z dnevnikom KOrganizerja. +Comment[sr]=Овај провод синхронизује ваш ручни рачунар са KOrganizer-овом књигом датума. +Comment[sr@Latn]=Ovaj provod sinhronizuje vaš ručni računar sa KOrganizer-ovom knjigom datuma. +Comment[sv]=Den här kanalen synkroniserar din handdator med Korganizers kalender. +Comment[ta]=இந்த குழாய் உங்கள் பைலட்டை கேஅமைப்பாளர் தேதிபுத்தகத்துடன் ஒத்திசைக்கிறது +Comment[tr]=Bu bileşen el bilgisayarınızı KOrganizer'daki randevu defteriyle senkronize eder. +Comment[uk]=Цей акведук синхронізує ваш кишеньковий пристрій з тижневиком KOrganizer. +Comment[zh_CN]=此管道会将您的手持设备与 KOrganizer 的日程安排同步。 +Comment[zh_TW]=此軟體將您的 handheld 日期與 KOrganizer 同步。 +Implemented=file +ServiceTypes=KPilotConduit +X-KDE-Library=conduit_vcal diff --git a/conduits/vcalconduit/vcal-conduit.h b/conduits/vcalconduit/vcal-conduit.h new file mode 100644 index 0000000..ed47d71 --- /dev/null +++ b/conduits/vcalconduit/vcal-conduit.h @@ -0,0 +1,101 @@ +#ifndef _KPILOT_VCAL_CONDUIT_H +#define _KPILOT_VCAL_CONDUIT_H +/* vcal-conduit.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include "pilotDateEntry.h" + +#include "vcal-conduitbase.h" + +class PilotRecord; +class PilotSerialDatabase; +class PilotLocalDatabase; + +class VCalConduitPrivate : public VCalConduitPrivateBase +{ +public: + VCalConduitPrivate(KCal::Calendar *buddy); + virtual ~VCalConduitPrivate() {}; + + KCal::Event::List fAllEvents; + KCal::Event::List::ConstIterator fAllEventsIterator; + + virtual int updateIncidences(); + virtual void addIncidence(KCal::Incidence*); + virtual void removeIncidence(KCal::Incidence *); + virtual KCal::Incidence *findIncidence(recordid_t); + /** + * Find the incidence based on tosearch's description and date information. + * Returns 0L if no incidence could be found. + */ + virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch); + virtual KCal::Incidence *getNextIncidence(); + virtual KCal::Incidence *getNextModifiedIncidence(); + virtual int count() {return fAllEvents.count();}; +} ; + + + +class VCalConduit : public VCalConduitBase +{ +Q_OBJECT +public: + VCalConduit(KPilotLink *, + const char *name=0L, + const TQStringList &args = TQStringList()); + virtual ~VCalConduit(); + +protected: + virtual const TQString dbname() { return CSL1("DatebookDB"); }; + + virtual void preSync() {VCalConduitBase::preSync(); _getAppInfo(); }; + virtual VCalConduitPrivateBase *createPrivateCalendarData(KCal::Calendar *fCalendar); + + void _getAppInfo(); + void _setAppInfo(); + + virtual PilotRecordBase *newPilotEntry(PilotRecord*r); + virtual KCal::Incidence*newIncidence(); + virtual const TQString getTitle(PilotRecordBase *de); + virtual VCalConduitSettings *config(); +public: + static VCalConduitSettings *theConfig(); + +protected: + virtual PilotRecord *recordFromIncidence(PilotRecordBase *de, + const KCal::Incidence *e); + virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *e, + const PilotRecordBase *de); + + PilotDateInfo *fAppointmentAppInfo; +}; + +#endif diff --git a/conduits/vcalconduit/vcal-conduitbase.cc b/conduits/vcalconduit/vcal-conduitbase.cc new file mode 100644 index 0000000..cd288ba --- /dev/null +++ b/conduits/vcalconduit/vcal-conduitbase.cc @@ -0,0 +1,622 @@ +/* KPilot +** +** Copyright (C) 2002-3 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** Contributions: +** Copyright (c) 2001 David Jarvie +** Copyright (C) 2006 by Bertjan Broeksema +** +** This file defines the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include + +#include +#include + +#include +#include + +#include "libkcal/calendar.h" +#include "libkcal/calendarlocal.h" +#include "libkcal/calendarresources.h" +#include + +#include "pilotSerialDatabase.h" +#include "pilotLocalDatabase.h" +#include "pilotDateEntry.h" + +#include "vcal-conduitbase.moc" +#include "vcalconduitSettings.h" + +#ifndef LIBKCAL_IS_VERSION +#warning "Using an old version of libkcal with timezone bug." +#define LIBKCAL_IS_VERSION(a,b,c) (0) +#endif + +#include "conduitstate.h" +#include "initstate.h" + + +/**************************************************************************** + * VCalConduitBase class * + ****************************************************************************/ + +VCalConduitBase::VCalConduitBase(KPilotLink *d, + const char *n, + const TQStringList &a) : + ConduitAction(d,n,a), + fCalendar(0L), + fP(0L) +{ + FUNCTIONSETUP; + + fState = new InitState(); +} + +VCalConduitBase::~VCalConduitBase() +{ + FUNCTIONSETUP; + + KPILOT_DELETE(fP); + KPILOT_DELETE(fState); + KPILOT_DELETE(fCalendar); + KPILOT_DELETE(fDatabase); + KPILOT_DELETE(fLocalDatabase); +} + + +/* + There are several different scenarios for a record on the Palm and its PC + counterpart. N means a new record, M flags a modified record, D a deleted + and - an unmodified record. First is the Palm record, second the + corresponding PC record: + (-,-) unchanged, just sync if first time or full sync + (N,-) no rec matching the Palm ID in the backupDB/calendar yet => add + KCal::Event + (M,-) record is in backupDB, unchanged in calendar => modify in calendar and + in backupDB + (D,-) deleted on Palm, exists in backupDB and calendar => just delete from + calendar and backupDB + (-,N) no or invalid pilotID set for the KCal::Event => just add to palm and + backupDB + (-,M) valid PilotID set => just modify on Palm + (-,D) Record in backupDB, but not in calendar => delete from Palm and + backupDB + (N,N) Can't find out (the two records are not correlated in any way, they + just have the same data!! + (M,M),(M,L),(L,M) (Record exists on Palm and the Event has the ID) CONFLICT, + ask the user what to do or use a config setting + (L,L) already deleted on both, no need to do anything. + + The sync process is as follows (for a fast sync): + 1) HHToPCState goes through all records on Palm (just the modified one + are necessary), find it in the backupDB. The following handles ([NMD],*) + a) if it doesn't exist and was not deleted, add it to the calendar and + the backupDB + b) if it exists, is unchanged in the calendar and was not deleted, + just modify in the calendar + c) if it exists and was deleted, delete it from the calendar if + necessary + 2) PCToHHState goes through all KCale::Events in the calendar (just + modified, this is the modification time is later than the last sync time + ). This handles (-,N),(-,M) + a) if it does not have a pilotID, add it to the palm and backupDB, + store the PalmID + b) if it has a valid pilotID, update the Palm record and the backup + 3) DeletedUnsyncedHHState goes through all palm records (which don't + have the deleted flag) of the palm db and if one does not exist in the + Calendar, it was deleted there, so delete it from the Palm and backup, + too. This handles the case of (-,D) + 4) DeletedUnsyncedPCState goes through all KCal::Events in the calendar and + looks for a corresponding event in the palm database. If it does not + exist, that means that it was deleted on the palm, so we need to also + delete it from the local calendar. This handles the case of (D,-). + + In addition to the fast sync, where the last sync was done with this very + PC and calendar file, there are two special cases: a full and a first sync. + -) a full sync goes through all records, not just the modified ones. The + pilotID setting of the calendar records is used to determine if the + record already exists. if yes, the record is just modified. + -) a first sync completely ignores the pilotID setting of the calendar + events. All records are added, so there might be duplicates. The add + function for the calendar should check if a similar record already + exists, but this is not done yet. + + -) a full sync is done if + a) there is a backupdb and a calendar, but the PC id number changed + b) it was explicitly requested by pressing the full sync button in KPilot + c) the setting "always full sync" was selected in the configuration dlg + -) a first sync is done if + a) either the calendar or the backup DB does not exist. + b) the calendar and the backup DB exists, but the sync is done for a + different User name + c) it was explicitly requested in KPilot +*/ + +/* virtual */ bool VCalConduitBase::exec() +{ + FUNCTIONSETUP; + + readConfig(); + + // don't do a first sync by default in any case, only when explicitly + // requested, or the backup database or the alendar are empty. + setFirstSync( false ); + + // TODO: Check Full sync and First sync + bool retrieved = false; + if ( !openDatabases( dbname(), &retrieved ) ) goto error; + setFirstSync( retrieved ); + + // If we are in testmode we don't need the local calendar. Else a + // calendar *must* be opened, we want to sync something don't we? + if (!syncMode().isTest() && !openCalendar() ) goto error; + + // Start processing the sync + TQTimer::singleShot(0, this, TQT_SLOT(slotProcess())); + return true; + +error: + emit logError( i18n( "Could not open the calendar databases." ) ); + + KPILOT_DELETE(fCalendar); + KPILOT_DELETE(fP); + KPILOT_DELETE(fState); + return false; +} + +void VCalConduitBase::slotProcess() { + FUNCTIONSETUP; + + // start the current state if necessary + if( fState && !fState->started() ) { + fState->startSync( this ); + } + + // Process next record if applicable + if( hasNextRecord ) + { + fState->handleRecord( this ); + TQTimer::singleShot( 0, this, TQT_SLOT( slotProcess() ) ); + } + // Else finish the current state if there is one + else if( fState ) + { + fState->finishSync( this ); + TQTimer::singleShot( 0, this, TQT_SLOT( slotProcess() ) ); + } + // No state so sync is finished + else + { + DEBUGKPILOT << fname << ": Sync finished." << endl; + delayDone(); + } +} + +/* virtual */ void VCalConduitBase::readConfig() +{ + config()->readConfig(); + SyncAction::ConflictResolution res = (SyncAction::ConflictResolution) + (config()->conflictResolution()); + setConflictResolution( res ); +} + +static void listResources( KCal::CalendarResources *p ) +{ + FUNCTIONSETUP; + KCal::CalendarResourceManager *manager = p->resourceManager(); + + DEBUGKPILOT << fname << ": Resources in calendar:" << endl; + KCal::CalendarResourceManager::Iterator it; + for( it = manager->begin(); it != manager->end(); ++it ) + { + DEBUGKPILOT << fname << ": " << (*it)->resourceName() << endl; + } +} + +/* virtual */ bool VCalConduitBase::openCalendar() +{ + FUNCTIONSETUP; + + KConfig korgcfg( locate( "config", CSL1("korganizerrc") ) ); + + // this part taken from adcalendarbase.cpp: + korgcfg.setGroup( "Time & Date" ); + TQString tz(korgcfg.readEntry( "TimeZoneId" ) ); + + DEBUGKPILOT << fname << ": KOrganizer's time zone = " << tz << endl; + + // Need a subclass ptr. for the ResourceCalendar methods + KCal::CalendarResources *rescal = 0L; + + DEBUGKPILOT << fname << ": Got calendar type " << config()->calendarType() + << endl; + + switch(config()->calendarType()) + { + case VCalConduitSettings::eCalendarLocal: + { + DEBUGKPILOT << fname << "Using CalendarLocal, file = " + << config()->calendarFile() << endl; + + if ( config()->calendarFile().isEmpty() ) + { + DEBUGKPILOT << fname << "Empty calendar file name." << endl; + + emit logError( i18n( "You selected to sync with an iCalendar" + " file, but did not give a filename. Please select a" + " valid file name in the conduit's configuration" + " dialog" ) ); + return false; + } + + fCalendar = new KCal::CalendarLocal( tz ); + if ( !fCalendar ) + { + WARNINGKPILOT + << "Cannot initialize calendar object for file " + << config()->calendarFile() << endl; + return false; + } + + DEBUGKPILOT << fname << "Calendar's timezone: " + << fCalendar->timeZoneId() << endl; + DEBUGKPILOT << fname << "Calendar is local time: " + << fCalendar->isLocalTime() << endl; + + emit logMessage( fCalendar->isLocalTime() ? + i18n( "Using local time zone: %1" ).arg( tz ) : + i18n( "Using non-local time zone: %1" ).arg( tz ) ); + + KURL kurl( config()->calendarFile() ); + if( !KIO::NetAccess::download( config()->calendarFile(), + fCalendarFile, 0L ) && !kurl.isLocalFile() ) + { + emit logError(i18n( "You chose to sync with the file \"%1\", which " + "cannot be opened. Please make sure to supply a " + "valid file name in the conduit's configuration dialog. " + "Aborting the conduit." ).arg( config()->calendarFile() ) ); + KIO::NetAccess::removeTempFile( fCalendarFile ); + return false; + } + + // if there is no calendar yet, use a first sync.. + // the calendar is initialized, so nothing more to do... + if (!dynamic_cast(fCalendar)->load(fCalendarFile) ) + { + DEBUGKPILOT << fname << "Calendar file " << fCalendarFile + << " could not be opened. Will create a new one" << endl; + + // Try to create empty file. if it fails, + // no valid file name was given. + TQFile fl(fCalendarFile); + if (!fl.open(IO_WriteOnly | IO_Append)) + { + DEBUGKPILOT << fname << "Invalid calendar file name " + << fCalendarFile << endl; + + emit logError( i18n( "You chose to sync with the file \"%1\", which " + "cannot be opened or created. Please make sure to supply a " + "valid file name in the conduit's configuration dialog. " + "Aborting the conduit." ).arg( config()->calendarFile() ) ); + return false; + } + fl.close(); + setFirstSync( true ); + } + addSyncLogEntry( i18n( "Syncing with file \"%1\"" ) + .arg( config()->calendarFile() ) ); + break; + } + + case VCalConduitSettings::eCalendarResource: + DEBUGKPILOT << "Using CalendarResource!" << endl; + + rescal = new KCal::CalendarResources( tz ); + listResources(rescal); + fCalendar = rescal; + if ( !fCalendar) + { + WARNINGKPILOT << "Cannot initialize calendar " << + "object for ResourceCalendar" << endl; + return false; + } + +#if LIBKCAL_IS_VERSION(1,1,0) + rescal->readConfig(); + rescal->load(); +#else +#warning "Timezone bug is present." +#endif + addSyncLogEntry( i18n( "Syncing with standard calendar resource." ) ); + emit logMessage( fCalendar->isLocalTime() ? + i18n( "Using local time zone: %1" ).arg( tz ) : + i18n( "Using non-local time zone: %1" ).arg( tz ) ); + break; + default: + break; + } + + if ( !fCalendar ) + { + WARNINGKPILOT << "Unable to initialize calendar object." + << " Please check the conduit's setup." << endl; + emit logError( i18n( "Unable to initialize the calendar object. Please" + " check the conduit's setup") ); + return false; + } + fP = createPrivateCalendarData( fCalendar ); + if ( !fP ) + { + return false; + } + int rc = fP->updateIncidences(); + DEBUGKPILOT << fname << ": return from updateIncidences: [" << rc + << "]" << endl; + + if ( fP->count() < 1 ) + { + setFirstSync( true ); + } + + return true; +} + +KCal::Incidence* VCalConduitBase::addRecord( PilotRecord *r ) +{ + FUNCTIONSETUP; + + recordid_t id = fLocalDatabase->writeRecord( r ); + DEBUGKPILOT<summary(); + query += i18n( "\nHandheld entry:\n\t" ); + query += getTitle( de ); + query += i18n( "\n\nWhich entry do you want to keep? It will " + "overwrite the other entry." ); + + return KMessageBox::No == questionYesNo( + query, + i18n( "Conflicting Entries" ), + TQString::null, + 0 /* Never timeout */, + i18n( "Handheld" ), i18n( "PC" )); + } + return getConflictResolution(); +} + +KCal::Incidence*VCalConduitBase::changeRecord(PilotRecord *r,PilotRecord *) +{ + FUNCTIONSETUP; + + PilotRecordBase *de = newPilotEntry( r ); + KCal::Incidence *e = fP->findIncidence( r->id() ); + + DEBUGKPILOT << fname << ": Pilot Record ID: [" << r->id() << "]" << endl; + + if ( e && de ) + { + // TODO: check for conflict, and if there is one, ask for resolution + if ( ( e->syncStatus() != KCal::Incidence::SYNCNONE ) + && r->isModified() ) + { + // TODO: I have not yet found a way to complete ignore an item + if (resolveConflict( e, de ) ) + { + // PC record takes precedence: + KPILOT_DELETE( de ); + return e; + } + } + // no conflict or conflict resolution says, Palm overwrites, so do it: + incidenceFromRecord( e, de ); + + // NOTE: This MUST be done last, since every other set* call + // calls updated(), which will trigger an + // setSyncStatus(SYNCMOD)!!! + e->setSyncStatus(KCal::Incidence::SYNCNONE); + fLocalDatabase->writeRecord( r ); + } + else + { + WARNINGKPILOT + << "While changing record -- not found in iCalendar" << endl; + addRecord( r ); + } + + KPILOT_DELETE( de ); + return e; +} + + +KCal::Incidence*VCalConduitBase::deleteRecord( PilotRecord *r, PilotRecord * ) +{ + FUNCTIONSETUP; + + KCal::Incidence *e = fP->findIncidence(r->id()); + if (e) + { + // RemoveEvent also takes it out of the calendar. + fP->removeIncidence(e); + fCtrPC->deleted(); + } + fLocalDatabase->writeRecord( r ); + return NULL; +} + + +void VCalConduitBase::addPalmRecord( KCal::Incidence *e ) +{ + FUNCTIONSETUP; + + PilotRecordBase *de = newPilotEntry( 0L ); + updateIncidenceOnPalm( e, de ); + fCtrHH->created(); + KPILOT_DELETE( de ); +} + + +void VCalConduitBase::changePalmRecord(KCal::Incidence*e, PilotRecord*s) +{ + PilotRecordBase *de = newPilotEntry( s ); + updateIncidenceOnPalm( e, de ); + fCtrHH->updated(); + KPILOT_DELETE( de ); +} + + +void VCalConduitBase::deletePalmRecord( KCal::Incidence *e, PilotRecord *s ) +{ + FUNCTIONSETUP; + if ( s ) + { + DEBUGKPILOT << fname << ": deleting record " << s->id() << endl; + s->setDeleted(); + fDatabase->writeRecord( s ); + fLocalDatabase->writeRecord( s ); + fCtrHH->deleted(); + } + else + { + DEBUGKPILOT << fname << ": could not find record to delete ("; + DEBUGKPILOT << e->pilotId() << ")" << endl; + } + + Q_UNUSED(e); +} + +/* I have to use a pointer to an existing PilotDateEntry so that I can handle + new records as well (and to prevent some crashes concerning the validity + domain of the PilotRecord*r). In syncEvent this PilotDateEntry is created. */ +void VCalConduitBase::updateIncidenceOnPalm( KCal::Incidence *e, + PilotRecordBase *de ) +{ + FUNCTIONSETUP; + if ( !de || !e ) { + DEBUGKPILOT << fname << ": NULL event given... Skipping it" << endl; + return; + } + + if ( e->syncStatus() == KCal::Incidence::SYNCDEL ) + { + DEBUGKPILOT << fname << ": don't write deleted incidence " + << e->summary() << " to the palm" << endl; + return; + } + + PilotRecord *r = recordFromIncidence( de, e ); + + // TODO: Check for conflict! + if ( r ) + { + recordid_t id=fDatabase->writeRecord(r); + r->setID(id); +// r->setAttrib(r->getAttrib() & ~dlpRecAttrDeleted); + fLocalDatabase->writeRecord( r ); +// fDatabase->writeRecord(r); + e->setPilotId( id ); + + // NOTE: This MUST be done last, since every other set* call + // calls updated(), which will trigger an + // setSyncStatus(SYNCMOD)!!! + e->setSyncStatus(KCal::Incidence::SYNCNONE); + KPILOT_DELETE( r ); + } +} + +const TQString VCalConduitBase::dbname() +{ + return TQString::null; +} + +PilotRecord *VCalConduitBase::readRecordByIndex( int index ) +{ + FUNCTIONSETUP; + return fDatabase->readRecordByIndex( index ); +} + +KCal::Incidence *VCalConduitBase::incidenceFromRecord( PilotRecord *r ) +{ + FUNCTIONSETUP; + PilotRecordBase *pac = newPilotEntry( r ); + KCal::Incidence *i = newIncidence(); + incidenceFromRecord( i, pac ); + + KPILOT_DELETE( pac ); + return i; +} + +void VCalConduitBase::setState( ConduitState *s ) +{ + KPILOT_DELETE( fState ); + fState = s; +} + +/* virtual */ void VCalConduitBase::postSync( ) +{ + FUNCTIONSETUP; + if (fCtrPC && fP) + fCtrPC->setEndCount(fP->count()); +} + +/* virtual */ void VCalConduitBase::preSync( ) +{ + FUNCTIONSETUP; + if (fCtrPC && fP) + fCtrPC->setStartCount(fP->count()); +} diff --git a/conduits/vcalconduit/vcal-conduitbase.h b/conduits/vcalconduit/vcal-conduitbase.h new file mode 100644 index 0000000..4e2f3ae --- /dev/null +++ b/conduits/vcalconduit/vcal-conduitbase.h @@ -0,0 +1,202 @@ +#ifndef _KPILOT_VCAL_CONDUITBASE_H +#define _KPILOT_VCAL_CONDUITBASE_H +/* vcal-conduit.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + + +#include + +#include + +#include +#include + +namespace KCal +{ +class Calendar; +class Incidence; +} + +class PilotSerialDatabase; +class PilotLocalDatabase; +class VCalConduitSettings; + +class ConduitState; + +class VCalConduitPrivateBase +{ +protected: + bool reading; + KCal::Calendar *fCalendar; +public: + VCalConduitPrivateBase(KCal::Calendar *buddy) : fCalendar(buddy) + { + reading = false; + }; + + virtual ~VCalConduitPrivateBase() { } ; + + virtual int updateIncidences() = 0; + virtual void addIncidence(KCal::Incidence*) = 0; + virtual void removeIncidence(KCal::Incidence*) = 0; + virtual KCal::Incidence *findIncidence(recordid_t) = 0; + virtual KCal::Incidence *findIncidence(PilotRecordBase *tosearch) = 0; + virtual KCal::Incidence *getNextIncidence() = 0; + virtual KCal::Incidence *getNextModifiedIncidence() = 0; + virtual int count()=0; +} ; + +class VCalConduitBase : public ConduitAction +{ + Q_OBJECT +public: + VCalConduitBase(KPilotLink *, + const char *name = 0L, + const TQStringList &args = TQStringList()); + virtual ~VCalConduitBase(); + +/********************************************************************* + D A T A M E M B E R S , S E T T I N G S + *********************************************************************/ +protected: + KCal::Calendar *fCalendar; + TQString fCalendarFile; + VCalConduitPrivateBase *fP; + ConduitState *fState; + bool hasNextRecord; + + virtual const TQString dbname() = 0; + virtual const TQString getTitle(PilotRecordBase *de) = 0; + virtual void readConfig(); + + virtual bool exec(); + +protected slots: + /** + * This slot is used to execute the actions applicable to this conduit. What + * happens in this method is defined by the state the conduit has at the + * moment that this method is called. For more information about the actions + * that are executed, look at the classes that are implementing ConduitState. + */ + void slotProcess(); + +public: + /** + * Method used by state classes to indicatie if there are more records to + * deal with. + */ + void setHasNextRecord( bool b ) + { + hasNextRecord = b; + } + + /** + * Change the current state of the conduit. The state that the conduit has + * at the moment of the call will be deleted. The last state *must* set the + * state to 0L when finished. + */ + void setState( ConduitState *s ); + + /** + * Returns the privatebase, that is used to for accessing the local calendar. + */ + VCalConduitPrivateBase *privateBase() const + { + return fP; + } + + /** + * Returns the record at index from the palm or 0L if there is no record at + * index. + */ + PilotRecord *readRecordByIndex( int index ); + + /** + * Returns a KCal::Incidence constructed from PilotRecord r. If r is 0L the + * it will return a KCal::Incidence that is empty. + */ + KCal::Incidence *incidenceFromRecord( PilotRecord *r ); + + virtual void preIncidence( KCal::Incidence* ) {}; + + // Getters + KCal::Calendar *calendar() const { return fCalendar; }; + TQString calendarFile() const { return fCalendarFile; }; + + virtual VCalConduitSettings *config() = 0; + virtual PilotDatabase *database() const { return fDatabase; }; + virtual PilotDatabase *localDatabase() const { return fLocalDatabase; }; + + // add, change or delete records from the palm + virtual void addPalmRecord( KCal::Incidence *e ); + virtual void changePalmRecord( KCal::Incidence *e, PilotRecord *s ); + virtual void deletePalmRecord( KCal::Incidence *e, PilotRecord *s ); + + // add, change or delete events from the calendar + virtual KCal::Incidence* changeRecord( PilotRecord*, PilotRecord* ); + virtual KCal::Incidence* deleteRecord( PilotRecord*, PilotRecord* ); + virtual KCal::Incidence* addRecord( PilotRecord * ); + +/********************************************************************* + P R E - A N D P O S T S Y N C F U N C T I O N S + *********************************************************************/ + virtual void preSync(); + virtual void postSync(); + virtual void preRecord(PilotRecord*) {}; + +protected: + virtual void updateIncidenceOnPalm(KCal::Incidence *e, PilotRecordBase *de); + +/********************************************************************* + S Y N C F U N C T I O N S + for creating events from Palm records or vice versa + *********************************************************************/ + virtual PilotRecord *recordFromIncidence(PilotRecordBase *de, + const KCal::Incidence *e) = 0; + virtual PilotRecordBase *newPilotEntry(PilotRecord *r) = 0; + + virtual KCal::Incidence *newIncidence() = 0; + virtual KCal::Incidence *incidenceFromRecord(KCal::Incidence *e, + const PilotRecordBase *de) = 0; + +/********************************************************************* + M I S C F U N C T I O N S + *********************************************************************/ + /** + * Return how to resolve conflicts. For now + * PalmOverrides=0=false, + * PCOverrides=1=true, + * Ask=2-> ask the user using a messagebox + */ + virtual int resolveConflict(KCal::Incidence *e, PilotRecordBase *de); + virtual bool openCalendar(); + virtual VCalConduitPrivateBase *createPrivateCalendarData(KCal::Calendar *fCalendar) = 0; +} ; + +#endif diff --git a/conduits/vcalconduit/vcal-factory.cc b/conduits/vcalconduit/vcal-factory.cc new file mode 100644 index 0000000..2e15781 --- /dev/null +++ b/conduits/vcalconduit/vcal-factory.cc @@ -0,0 +1,50 @@ +/* KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the factory for the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include + +#include "pluginfactory.h" + +#include "vcal-setup.h" +#include "vcal-conduit.h" + +extern "C" +{ + +void *init_conduit_vcal() +{ + return new ConduitFactory; +} + +} + + + diff --git a/conduits/vcalconduit/vcal-factory.h b/conduits/vcalconduit/vcal-factory.h new file mode 100644 index 0000000..5cd4a61 --- /dev/null +++ b/conduits/vcalconduit/vcal-factory.h @@ -0,0 +1,41 @@ +#ifndef _KPILOT_VCAL_FACTORY_H +#define _KPILOT_VCAL_FACTORY_H +/* vcal-factory.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the factory for the vcal-conduit plugin. +** It also defines the class for the behavior of the setup dialog. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + + +extern "C" +{ + +void *init_libvcalconduit(); + +} + +#endif diff --git a/conduits/vcalconduit/vcal-factorybase.h b/conduits/vcalconduit/vcal-factorybase.h new file mode 100644 index 0000000..5a1d2a5 --- /dev/null +++ b/conduits/vcalconduit/vcal-factorybase.h @@ -0,0 +1,44 @@ +#ifndef _KPILOT_VCAL_FACTORYBASE_H +#define _KPILOT_VCAL_FACTORYBASE_H +/* vcal-factory.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the factory for the vcal-conduit plugin. +** It also defines the class for the behavior of the setup dialog. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + + +#define RES_PALMOVERRIDES 0 +#define RES_PCOVERRIDES 1 +#define RES_ASK 2 + +#define SYNC_FIRST 0 +#define SYNC_FAST 1 +#define SYNC_FULL 2 +#define SYNC_MAX SYNC_FULL + + +#endif diff --git a/conduits/vcalconduit/vcal-setup.cc b/conduits/vcalconduit/vcal-setup.cc new file mode 100644 index 0000000..0361c32 --- /dev/null +++ b/conduits/vcalconduit/vcal-setup.cc @@ -0,0 +1,78 @@ +/* KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the setup dialog for the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include + +#include "korganizerConduit.h" +#include "vcal-conduit.h" +#include "vcal-setup.h" + + +VCalWidgetSetup::VCalWidgetSetup(TQWidget *w, const char *n) : + VCalWidgetSetupBase(w,n) +{ + KAboutData *fAbout = new KAboutData("vcalConduit", + I18N_NOOP("VCal Conduit for KPilot"), + KPILOT_VERSION, + I18N_NOOP("Configures the VCal Conduit for KPilot"), + KAboutData::License_GPL, + "(C) 2001, Adriaan de Groot\n(C) 2002-2003, Reinhold Kainhofer"); + fAbout->addAuthor("Adriaan de Groot", + I18N_NOOP("Maintainer"), + "groot@kde.org", + "http://www.kpilot.org/"); + fAbout->addAuthor("Reinhold Kainhofer", + I18N_NOOP("Maintainer"), + "reinhold@kainhofer.com", + "http://reinhold.kainhofer.com/Linux/"); + fAbout->addAuthor("Dan Pilone", + I18N_NOOP("Original Author")); + fAbout->addAuthor("Preston Brown", + I18N_NOOP("Original Author")); + fAbout->addAuthor("Herwin-Jan Steehouwer", + I18N_NOOP("Original Author")); + fAbout->addCredit("Cornelius Schumacher", + I18N_NOOP("iCalendar port")); + fAbout->addCredit("Philipp Hullmann", + I18N_NOOP("Bugfixer")); + + ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget, fAbout); + fConfigWidget->fSyncDestination->setTitle(i18n("Calendar Destination")); + fConduitName=i18n("Calendar"); + +} + +/* static */ ConduitConfigBase *VCalWidgetSetup::create(TQWidget *w,const char *n) +{ + return new VCalWidgetSetup(w,n); +} +VCalConduitSettings*VCalWidgetSetup::config() { return VCalConduit::theConfig(); } diff --git a/conduits/vcalconduit/vcal-setup.h b/conduits/vcalconduit/vcal-setup.h new file mode 100644 index 0000000..20723ce --- /dev/null +++ b/conduits/vcalconduit/vcal-setup.h @@ -0,0 +1,46 @@ +#ifndef _KPILOT_VCAL_SETUP_H +#define _KPILOT_VCAL_SETUP_H +/* vcal-setup.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** It also defines the class for the behavior of the setup dialog. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "vcal-setupbase.h" + +class VCalWidget; +class VCalConduitSettings; + +class VCalWidgetSetup : public VCalWidgetSetupBase +{ +public: + VCalWidgetSetup(TQWidget *, const char *); + static ConduitConfigBase *create(TQWidget *, const char *); +protected: + virtual VCalConduitSettings*config(); +} ; + +#endif diff --git a/conduits/vcalconduit/vcal-setupbase.cc b/conduits/vcalconduit/vcal-setupbase.cc new file mode 100644 index 0000000..643dee6 --- /dev/null +++ b/conduits/vcalconduit/vcal-setupbase.cc @@ -0,0 +1,110 @@ +/* vcal-setup.cc KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** This file defines the setup dialog for the vcal-conduit plugin. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include +#include + +#include + +#include "korganizerConduit.h" +#include "vcalconduitSettings.h" +#include "vcal-setupbase.h" + +VCalWidgetSetupBase::VCalWidgetSetupBase(TQWidget *w, const char *n) : + ConduitConfigBase(w,n), + fConfigWidget(new VCalWidget(w)) +{ + FUNCTIONSETUP; + fWidget=fConfigWidget; + + fConfigWidget->fCalendarFile->setMode(KFile::File); + fConfigWidget->fCalendarFile->setFilter(CSL1("*.vcs *.ics|ICalendars\n*.*|All Files (*.*)")); + +#define CM(a,b) connect(fConfigWidget->a,b,this,TQT_SLOT(modified())); + CM(fSyncDestination,TQT_SIGNAL(clicked(int))); + CM(fCalendarFile,TQT_SIGNAL(textChanged(const TQString &))); + CM(fArchive,TQT_SIGNAL(toggled(bool))); + CM(fConflictResolution,TQT_SIGNAL(activated(int))); +#undef CM +} + +VCalWidgetSetupBase::~VCalWidgetSetupBase() +{ + FUNCTIONSETUP; +} + +/* virtual */ void VCalWidgetSetupBase::commit() +{ + FUNCTIONSETUP; + config()->readConfig(); + + // General page +#ifdef DEBUG + DEBUGKPILOT << fname << ": Selected type=" + << fConfigWidget->fSyncDestination->selected() + << " with id=" + << fConfigWidget->fSyncDestination->id(fConfigWidget->fSyncDestination->selected()) + << endl; +#endif + config()->setCalendarType( fConfigWidget->fSyncDestination->id( + fConfigWidget->fSyncDestination->selected())); + config()->setCalendarFile( fConfigWidget->fCalendarFile->url()); + + config()->setSyncArchived( fConfigWidget->fArchive->isChecked() ); + + // Conflicts page + config()->setConflictResolution( + fConfigWidget->fConflictResolution->currentItem()+SyncAction::eCROffset); + + config()->writeConfig(); + unmodified(); +} + +/* virtual */ void VCalWidgetSetupBase::load() +{ + FUNCTIONSETUP; + config()->readConfig(); + + // General page + fConfigWidget->fSyncDestination->setButton( config()->calendarType()); + fConfigWidget->fCalendarFile->setURL( config()->calendarFile() ); + + fConfigWidget->fArchive->setChecked( config()->syncArchived() ); + + // Conflicts page + fConfigWidget->fConflictResolution->setCurrentItem( + config()->conflictResolution() - SyncAction::eCROffset); + + config()->writeConfig(); + unmodified(); +} + diff --git a/conduits/vcalconduit/vcal-setupbase.h b/conduits/vcalconduit/vcal-setupbase.h new file mode 100644 index 0000000..a14bf14 --- /dev/null +++ b/conduits/vcalconduit/vcal-setupbase.h @@ -0,0 +1,51 @@ +#ifndef _KPILOT_VCAL_SETUPBASE_H +#define _KPILOT_VCAL_SETUPBASE_H +/* vcal-setup.h KPilot +** +** Copyright (C) 2002-2003 Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +** It also defines the class for the behavior of the setup dialog. +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "plugin.h" + +class VCalWidget; +class VCalConduitSettings; + +class VCalWidgetSetupBase : public ConduitConfigBase +{ +public: + VCalWidgetSetupBase(TQWidget *, const char *); + virtual ~VCalWidgetSetupBase(); + + virtual void load(); + virtual void commit(); + +protected: + virtual VCalConduitSettings*config()=0; + VCalWidget *fConfigWidget; +} ; + +#endif diff --git a/conduits/vcalconduit/vcalRecord.cc b/conduits/vcalconduit/vcalRecord.cc new file mode 100644 index 0000000..898bc79 --- /dev/null +++ b/conduits/vcalconduit/vcalRecord.cc @@ -0,0 +1,548 @@ +/* vcalRecord.cc KPilot +** +** Copyright (C) 2006 by Adriaan de Groot +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +#include "options.h" + +#include +#include +#include +#include + +#include "pilot.h" +#include "pilotDateEntry.h" + +#include "kcalRecord.h" +#include "vcalRecord.h" + + +static void setStartEndTimes(KCal::Event *e, const PilotDateEntry *de) +{ + FUNCTIONSETUP; + DEBUGKPILOT << fname + << "# Start time on Palm: " + << readTm(de->getEventStart()).toString() << endl; + + e->setDtStart(readTm(de->getEventStart())); + e->setFloats(de->isEvent()); + + if (de->isMultiDay()) + { + e->setDtEnd(readTm(de->getRepeatEnd())); + } + else + { + e->setDtEnd(readTm(de->getEventEnd())); + } +} + +static void setAlarms(KCal::Event *e, const PilotDateEntry *de) +{ + FUNCTIONSETUP; + + if (!e) return; + // Delete all the alarms now and add them one by one later on. + e->clearAlarms(); + if (!de->isAlarmEnabled()) return; + +// TQDateTime alarmDT = readTm(de->getEventStart()); + int advanceUnits = de->getAdvanceUnits(); + + switch (advanceUnits) + { + case advMinutes: + advanceUnits = 1; + break; + case advHours: + advanceUnits = 60; + break; + case advDays: + advanceUnits = 60*24; + break; + default: +#ifdef DEBUG + DEBUGKPILOT << fname + << ": Unknown advance units " + << advanceUnits + << endl; +#endif + advanceUnits=1; + } + + KCal::Duration adv(-60*advanceUnits*de->getAdvance()); + KCal::Alarm*alm=e->newAlarm(); + if (!alm) return; + + alm->setStartOffset(adv); + alm->setEnabled(true); +} + +static void setRecurrence(KCal::Event *event,const PilotDateEntry *dateEntry) +{ + FUNCTIONSETUP; + + if ((dateEntry->getRepeatType() == repeatNone) || dateEntry->isMultiDay()) + { +#ifdef DEBUG + DEBUGKPILOT<recurrence(); + int freq = dateEntry->getRepeatFrequency(); + bool repeatsForever = dateEntry->getRepeatForever(); + TQDate endDate, evt; + + if (!repeatsForever) + { + endDate = readTm(dateEntry->getRepeatEnd()).date(); +#ifdef DEBUG + DEBUGKPILOT << fname << "-- end " << endDate.toString() << endl; + } + else + { + DEBUGKPILOT << fname << "-- noend" << endl; +#endif + } + + TQBitArray dayArray(7); + + switch(dateEntry->getRepeatType()) + { + case repeatDaily: + recur->setDaily(freq); + break; + case repeatWeekly: + { + const int *days = dateEntry->getRepeatDays(); + +#ifdef DEBUG + DEBUGKPILOT << fname + << ": Got repeat-weekly entry, by-days=" + << days[0] << " "<< days[1] << " "<< days[2] << " " + << days[3] << " " + << days[4] << " "<< days[5] << " "<< days[6] << " " + << endl; +#endif + + // Rotate the days of the week, since day numbers on the Pilot and + // in vCal / Events are different. + // + if (days[0]) dayArray.setBit(6); + for (int i = 1; i < 7; i++) + { + if (days[i]) dayArray.setBit(i-1); + } + recur->setWeekly( freq, dayArray ); + } + break; + case repeatMonthlyByDay: { + // Palm: Day=0(sun)-6(sat); week=0-4, 4=last week; pos=week*7+day + // libkcal: day=bit0(mon)-bit6(sun); week=-5to-1(from end) and 1-5 (from beginning) + // Palm->PC: w=pos/7 + // week: if w=4 -> week=-1, else week=w+1; + // day: day=(pos-1)%7 (rotate by one day!) + recur->setMonthly( freq ); + + int day=dateEntry->getRepeatDay(); + int week=day/7; + // week=4 means last, otherwise convert to 0-based + if (week==4) week=-1; else week++; + dayArray.setBit((day+6) % 7); + recur->addMonthlyPos(week, dayArray); + break;} + case repeatMonthlyByDate: + recur->setMonthly( freq ); + recur->addMonthlyDate( dateEntry->getEventStart().tm_mday ); + break; + case repeatYearly: + recur->setYearly( freq ); + evt=readTm(dateEntry->getEventStart()).date(); + recur->addYearlyMonth( evt.month() ); +// dayArray.setBit((evt.day()-1) % 7); +// recur->addYearlyMonthPos( ( (evt.day()-1) / 7) + 1, dayArray ); + break; + case repeatNone: + default : +#ifdef DEBUG + DEBUGKPILOT << fname + << ": Can't handle repeat type " + << dateEntry->getRepeatType() + << endl; +#endif + break; + } + if (!repeatsForever) + { + recur->setEndDate(endDate); + } +} + +static void setExceptions(KCal::Event *vevent,const PilotDateEntry *dateEntry) +{ + FUNCTIONSETUP; + + // Start from an empty exception list, and if necessary, add exceptions. + // At the end of the function, apply the (possibly empty) exception list. + KCal::DateList dl; + + if ( !(dateEntry->isMultiDay() ) && dateEntry->getExceptionCount()>0 ) + { + for (int i = 0; i < dateEntry->getExceptionCount(); i++) + { +// vevent->addExDate(readTm(dateEntry->getExceptions()[i]).date()); + dl.append(readTm(dateEntry->getExceptions()[i]).date()); + } + } + else + { +#ifdef DEBUG + if (dateEntry->getExceptionCount()>0) + DEBUGKPILOT << fname + << ": WARNING Exceptions ignored for multi-day event " + << dateEntry->getDescription() + << endl ; +#endif + return; + } + vevent->recurrence()->setExDates(dl); +} + +static void setStartEndTimes(PilotDateEntry*de, const KCal::Event *e) +{ + FUNCTIONSETUP; + struct tm ttm=writeTm(e->dtStart()); + de->setEventStart(ttm); + de->setFloats( e->doesFloat() ); + + if (e->hasEndDate() && e->dtEnd().isValid()) + { + ttm=writeTm(e->dtEnd()); + } + else + { + ttm=writeTm(e->dtStart()); + } + de->setEventEnd(ttm); +} + + + + +static void setAlarms(PilotDateEntry*de, const KCal::Event *e) +{ + FUNCTIONSETUP; + + if (!de || !e ) + { +#ifdef DEBUG + DEBUGKPILOT << fname << ": NULL entry given to setAlarms. "<isAlarmEnabled() ) + { + de->setAlarmEnabled( false ); + return; + } + + // find the first enabled alarm + KCal::Alarm::List alms=e->alarms(); + KCal::Alarm* alm=0; + KCal::Alarm::List::ConstIterator it; + for ( it = alms.begin(); it != alms.end(); ++it ) { + if ((*it)->enabled()) alm=*it; + } + + if (!alm ) + { +#ifdef DEBUG + DEBUGKPILOT << fname << ": no enabled alarm found (should exist!!!)"<setAlarmEnabled( false ); + return; + } + + // palm and PC offsets have a different sign!! + int aoffs=-alm->startOffset().asSeconds()/60; + int offs=(aoffs>0)?aoffs:-aoffs; + + // find the best Advance Unit + if (offs>=100 || offs==60) + { + offs/=60; + if (offs>=48 || offs==24) + { + offs/=24; + de->setAdvanceUnits(advDays); + } + else + { + de->setAdvanceUnits(advHours); + } + } + else + { + de->setAdvanceUnits(advMinutes); + } + de->setAdvance((aoffs>0)?offs:-offs); + de->setAlarmEnabled( true ); +} + + + +static void setRecurrence(PilotDateEntry*dateEntry, const KCal::Event *event) +{ + FUNCTIONSETUP; + bool isMultiDay=false; + + // first we have 'fake type of recurrence' when a multi-day event is passed to the pilot, it is converted to an event + // which recurs daily a number of times. if the event itself recurs, this will be overridden, and + // only the first day will be included in the event!!!! + TQDateTime startDt(readTm(dateEntry->getEventStart())), endDt(readTm(dateEntry->getEventEnd())); + if (startDt.daysTo(endDt)) + { + isMultiDay=true; + dateEntry->setRepeatType(repeatDaily); + dateEntry->setRepeatFrequency(1); + dateEntry->setRepeatEnd(dateEntry->getEventEnd()); +#ifdef DEBUG + DEBUGKPILOT << fname <<": Setting single-day recurrence (" << startDt.toString() << " - " << endDt.toString() << ")" <recurrence(); + if (!r) return; + ushort recType=r->recurrenceType(); + if ( recType==KCal::Recurrence::rNone ) + { + if (!isMultiDay) dateEntry->setRepeatType(repeatNone); + return; + } + + + int freq=r->frequency(); + TQDate endDate=r->endDate(); + + if ( r->duration() < 0 || !endDate.isValid() ) + { + dateEntry->setRepeatForever(); + } + else + { + dateEntry->setRepeatEnd(writeTm(endDate)); + } + dateEntry->setRepeatFrequency(freq); +#ifdef DEBUG + DEBUGKPILOT<<" Event: "<summary()<<" ("<description()<<")"<duration() << ", endDate: "<setRepeatType(repeatDaily); + break; + case KCal::Recurrence::rWeekly: + dateEntry->setRepeatType(repeatWeekly); + dayArray=r->days(); + // rotate the bits by one + for (int i=0; i<7; i++) + { + dayArrayPalm.setBit( (i+1)%7, dayArray[i]); + } + dateEntry->setRepeatDays(dayArrayPalm); + break; + case KCal::Recurrence::rMonthlyPos: + // Palm: Day=0(sun)-6(sat); week=0-4, 4=last week; pos=week*7+day + // libkcal: day=bit0(mon)-bit6(sun); week=-5to-1(from end) and 1-5 (from beginning) + // PC->Palm: pos=week*7+day + // week: if w=-1 -> week=4, else week=w-1 + // day: day=(daybit+1)%7 (rotate because of the different offset) + dateEntry->setRepeatType(repeatMonthlyByDay); + if (r->monthPositions().count()>0) + { + // Only take the first monthly position, as the palm allows only one + TQValueList mps=r->monthPositions(); + KCal::RecurrenceRule::WDayPos mp=mps.first(); + int week = mp.pos(); + int day = (mp.day()+1) % 7; // rotate because of different offset + // turn to 0-based and include starting from end of month + // TODO: We don't handle counting from the end of the month yet! + if (week==-1) week=4; else week--; + dateEntry->setRepeatDay(static_cast(7*week + day)); + } + break; + case KCal::Recurrence::rMonthlyDay: + dateEntry->setRepeatType(repeatMonthlyByDate); +//TODO: is this needed? dateEntry->setRepeatDay(static_cast(startDt.day())); + break; + case KCal::Recurrence::rYearlyDay: + case KCal::Recurrence::rYearlyPos: + DEBUGKPILOT << fname + << "! Unsupported yearly recurrence type." << endl; + case KCal::Recurrence::rYearlyMonth: + dateEntry->setRepeatType(repeatYearly); + break; + case KCal::Recurrence::rNone: + if (!isMultiDay) dateEntry->setRepeatType(repeatNone); + break; + default: +#ifdef DEBUG + DEBUGKPILOT << fname << ": Unknown recurrence type "<< recType << " with frequency " + << freq << " and duration " << r->duration() << endl; +#endif + break; + } +} + + +static void setExceptions(PilotDateEntry *dateEntry, const KCal::Event *vevent ) +{ + FUNCTIONSETUP; + struct tm *ex_List; + + if (!dateEntry || !vevent) + { + WARNINGKPILOT << "NULL dateEntry or NULL vevent given for exceptions. Skipping exceptions" << endl; + return; + } + // first, we need to delete the old exceptions list, if it existed... + // This is no longer needed, as I fixed PilotDateEntry::setExceptions to do this automatically +/* ex_List=const_castgetExceptions(); + if (ex_List) + KPILOT_DELETE(ex_List);*/ + + KCal::DateList exDates = vevent->recurrence()->exDates(); + size_t excount = exDates.size(); + if (excount<1) + { + dateEntry->setExceptionCount(0); + dateEntry->setExceptions(0); + return; + } + + // we have exceptions, so allocate mem and copy them there... + ex_List=new struct tm[excount]; + if (!ex_List) + { + WARNINGKPILOT << "Couldn't allocate memory for the exceptions" << endl; + dateEntry->setExceptionCount(0); + dateEntry->setExceptions(0); + return; + } + + size_t n=0; + + KCal::DateList::ConstIterator dit; + for (dit = exDates.begin(); dit != exDates.end(); ++dit ) { + struct tm ttm=writeTm(*dit); + ex_List[n++]=ttm; + } + dateEntry->setExceptionCount(excount); + dateEntry->setExceptions(ex_List); +} + + +bool KCalSync::setEvent(KCal::Event *e, + const PilotDateEntry *de, + const CategoryAppInfo &info) +{ + FUNCTIONSETUP; + if (!e) + { + DEBUGKPILOT << fname + << "! NULL event given... Skipping it" << endl; + return false; + } + if (!de) + { + DEBUGKPILOT << fname + << "! NULL date entry given... Skipping it" << endl; + return false; + } + + + e->setSecrecy(de->isSecret() ? + KCal::Event::SecrecyPrivate : + KCal::Event::SecrecyPublic); + + e->setPilotId(de->id()); + + setStartEndTimes(e,de); + setAlarms(e,de); + setRecurrence(e,de); + setExceptions(e,de); + + e->setSummary(de->getDescription()); + e->setDescription(de->getNote()); + e->setLocation(de->getLocation()); + + // used by e.g. Agendus and Datebk + setCategory(e, de, info); + + // NOTE: This MUST be done last, since every other set* call + // calls updated(), which will trigger an + // setSyncStatus(SYNCMOD)!!! + e->setSyncStatus(KCal::Incidence::SYNCNONE); + + return true; +} + +bool KCalSync::setDateEntry(PilotDateEntry *de, + const KCal::Event *e, + const CategoryAppInfo &info) +{ + FUNCTIONSETUP; + if (!de || !e) { + DEBUGKPILOT << fname + << ": NULL event given... Skipping it" << endl; + return false; + } + + // set secrecy, start/end times, alarms, recurrence, exceptions, summary and description: + if (e->secrecy()!=KCal::Event::SecrecyPublic) + { + de->setSecret( true ); + } + + setStartEndTimes(de, e); + setAlarms(de, e); + setRecurrence(de, e); + setExceptions(de, e); + de->setDescription(e->summary()); + de->setNote(e->description()); + de->setLocation(e->location()); + setCategory(de, e, info); + return true; +} + diff --git a/conduits/vcalconduit/vcalRecord.h b/conduits/vcalconduit/vcalRecord.h new file mode 100644 index 0000000..4cad14b --- /dev/null +++ b/conduits/vcalconduit/vcalRecord.h @@ -0,0 +1,51 @@ +#ifndef _KPILOT_VCALRECORD_H +#define _KPILOT_VCALRECORD_H +/* vcal-conduit.h KPilot +** +** Copyright (C) 2006 by Adriaan de Groot +** Copyright (C) 2002-2003 by Reinhold Kainhofer +** Copyright (C) 2001 by Dan Pilone +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-pim@kde.org +*/ + +class PilotDateEntry; + +namespace KCal +{ + class Event; +} + +namespace KCalSync +{ + bool setEvent( KCal::Event *e, + const PilotDateEntry *de, + const CategoryAppInfo &info); + bool setDateEntry(PilotDateEntry *de, + const KCal::Event *e, + const CategoryAppInfo &info); +} + +#endif + + diff --git a/conduits/vcalconduit/vcalconduitSettings.kcfgc b/conduits/vcalconduit/vcalconduitSettings.kcfgc new file mode 100644 index 0000000..7855ad2 --- /dev/null +++ b/conduits/vcalconduit/vcalconduitSettings.kcfgc @@ -0,0 +1,7 @@ +File=vcalconduitbase.kcfg +ClassName=VCalConduitSettings +#Singleton=true +ItemAccessors=true +Mutators=true +GlobalEnums=true +SetUserTexts=true diff --git a/conduits/vcalconduit/vcalconduitbase.kcfg b/conduits/vcalconduit/vcalconduitbase.kcfg new file mode 100644 index 0000000..c35e790 --- /dev/null +++ b/conduits/vcalconduit/vcalconduitbase.kcfg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + eCalendarLocal + + + $HOME/.kde/share/apps/korganizer/std.ics + + + true + + + 0 + + + + -- cgit v1.2.1