[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: PATCH: iCalendar port of KPilot todo and datebook conduits
From: Cornelius Schumacher <schumacher () kde ! org>
Date: 2001-06-17 22:21:48
[Download RAW message or body]
This patch fixes the todo and datebook conduits of Kpilot. They now use
libkcal to access the KOrganizer files.
Please test the patch.
It's a massive change to the conduits and it probably still has some
bugs. On the other hand are the KOrganizer conduits non-functional
without this patch. I would like to get this into the beta, then we can
fix the remaining problems before the final release.
What do you think?
--
Cornelius Schumacher <schumacher@kde.org>
["conduit.patch" (text/plain)]
Index: conduits/vcalconduit/Makefile.am
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/Makefile.am,v
retrieving revision 1.18
diff -u -3 -d -p -r1.18 Makefile.am
--- conduits/vcalconduit/Makefile.am 2001/05/15 15:37:02 1.18
+++ conduits/vcalconduit/Makefile.am 2001/06/17 22:03:17
@@ -3,13 +3,9 @@
### so it seems logical to put them in one place.
###
-###
-### Build the VCC library first.
-###
-SUBDIRS = versit
+INCLUDES= -I$(top_srcdir)/kpilot/kpilot -I$(top_srcdir)/libkcal \
+ -I$(LIBPISOCK_PATH) $(all_includes)
-INCLUDES= @all_includes@ -I$(LIBPISOCK_PATH) \
- -I$(top_srcdir)/kpilot -I$(top_srcdir)/kpilot/kpilot -I$(srcdir)/versit
METASOURCES = AUTO
servicedir = $(kde_servicesdir)
@@ -20,27 +16,25 @@ service_DATA = todo-conduit.desktop vcal
bin_PROGRAMS = todoconduit vcalconduit
# Which sources should be compiled for todoconduit
-todoconduit_SOURCES= todo-conduit.cc todo-setup.cc vcalBase.cc
+todoconduit_SOURCES = todo-conduit.cc todo-setup.cc vcalBase.cc
vcalconduit_SOURCES = vcal-conduit.cc vcal-setup.cc vcalBase.cc
-
# the library search path
-todoconduit_LDFLAGS = $(all_libraries) -Lversit \
- -L../../kpilot
-vcalconduit_LDFLAGS = $(all_libraries) -Lversit \
- -L../../kpilot
+todoconduit_LDFLAGS = -L$(top_builddir)/kpilot/kpilot \
+ -L$(top_builddir)/libkcal $(all_libraries)
+vcalconduit_LDFLAGS = -L$(top_builddir)/kpilot/kpilot \
+ -L$(top_builddir)/libkcal $(all_libraries)
# the libraries to link against. Be aware of the order. First the libraries,
# that depend on the following ones.
todoconduit_LDADD = \
- -lconduit -lpilotdb \
+ -lconduit -lpilotdb -lkcal \
$(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) \
- @LIBSOCKET@ -lversit $(LIBPISOCK)
+ @LIBSOCKET@ $(LIBPISOCK)
vcalconduit_LDADD = \
- -lconduit -lpilotdb \
+ -lconduit -lpilotdb -lkcal \
$(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) \
- @LIBSOCKET@ -lversit $(LIBPISOCK)
+ @LIBSOCKET@ $(LIBPISOCK)
# this option you can leave out. Just, if you use "make dist", you need it
noinst_HEADERS = todo-conduit.h todo-setup.h vcal-conduit.h vcal-setup.h
-
Index: conduits/vcalconduit/todo-conduit.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/todo-conduit.cc,v
retrieving revision 1.5
diff -u -3 -d -p -r1.5 todo-conduit.cc
--- conduits/vcalconduit/todo-conduit.cc 2001/06/05 22:58:40 1.5
+++ conduits/vcalconduit/todo-conduit.cc 2001/06/17 22:03:19
@@ -1,8 +1,9 @@
-/* todo-conduit.cc KPilot
+/* todo-conduit.cc Todo-Conduit for syncing KPilot and KOrganizer
**
** 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,
@@ -26,15 +27,7 @@
** MA 02139, USA.
*/
-/*
-** Bug reports and questions can be sent to adridg@cs.kun.nl
-*/
-// I have noticed that this is full of memory leaks, but since it is
-// short lived, it shouldn't matter so much. -- PGB
-
-#ifndef _KPILOT_OPTIONS_H
#include "options.h"
-#endif
#include <sys/types.h>
#include <signal.h>
@@ -42,104 +35,54 @@
#include <stdlib.h>
#include <time.h>
-#ifndef QBITARRAY_H
#include <qbitarray.h>
-#endif
-
-#ifndef QDIR_H
#include <qdir.h>
-#endif
-
-#ifndef QDATETM_H
#include <qdatetm.h>
-#endif
-
-#ifndef QSTRING_H
#include <qstring.h>
-#endif
-
-#ifndef QMSGBOX_H
#include <qmsgbox.h>
-#endif
-
-#ifndef _KAPP_H
#include <kapp.h>
-#endif
-
-#ifndef _KMESSAGEBOX_H
#include <kmessagebox.h>
-#endif
-
-#ifndef _KCONFIG_H
#include <kconfig.h>
-#endif
-
-#ifndef _KDEBUG_H
#include <kdebug.h>
-#endif
-
-#ifndef _KPILOT_KPILOTCONFIG_H
#include "kpilotConfig.h"
-#endif
-
-#ifndef _KPILOT_PILOTDATABASE_H
#include "pilotDatabase.h"
-#endif
-
-#ifndef _KPILOT_PILOTRECORD_H
-#include "pilotRecord.h"
-#endif
-
-#ifndef _KPILOT_PILOTTODOENTRY_H
#include "pilotTodoEntry.h"
-#endif
-
-
-#ifndef __VCC_H__
-#include "vcc.h"
-#endif
-
-#ifndef _KPILOT_TODO_CONDUIT_H
#include "todo-conduit.h"
-#endif
-
-#ifndef _KPILOT_TODO_SETUP_H
#include "todo-setup.h"
-#endif
-
-#ifndef _KPILOT_CONDUITAPP_H
#include "conduitApp.h"
-#endif
+
+#include <todo.h>
+
+using namespace KCal;
static const char *todo_conduit_id = "$Id: todo-conduit.cc,v 1.5 2001/06/05 22:58:40 adridg Exp $";
int main(int argc, char* argv[])
{
- ConduitApp a(argc, argv, "todo_conduit",
- "ToDo-list conduit",
- KPILOT_VERSION);
+ ConduitApp a(argc,argv,"todo_conduit","ToDo-list conduit",KPILOT_VERSION);
a.addAuthor("Preston Brown",I18N_NOOP("Organizer author"));
- a.addAuthor("Adriaan de Groot",
- I18N_NOOP("Maintainer"),
- "adridg@cs.kun.nl");
- a.addAuthor("Philipp Hullmann",
- I18N_NOOP("Bugfixer"));
- TodoConduit conduit(a.getMode());
+ a.addAuthor("Adriaan de Groot",I18N_NOOP("Maintainer"),"adridg@cs.kun.nl");
+ a.addAuthor("Philipp Hullmann",I18N_NOOP("Bugfixer"));
+ a.addAuthor("Cornelius Schumacher",I18N_NOOP("iCalendar port"));
+
+ TodoConduit conduit(a.getMode(),a.getDBSource());
a.setConduit(&conduit);
return a.exec();
- /* NOTREACHED */
- (void) todo_conduit_id;
+ /* NOTREACHED */
+ (void) todo_conduit_id;
}
-TodoConduit::TodoConduit(eConduitMode mode)
- : VCalBaseConduit(mode)
+TodoConduit::TodoConduit(eConduitMode mode,DatabaseSource source)
+ : VCalBaseConduit(mode,source)
{
- FUNCTIONSETUP;
+ FUNCTIONSETUP;
+
+ kdDebug() << "TodoConduit()" << endl;
}
@@ -148,219 +91,164 @@ TodoConduit::~TodoConduit()
}
-/* static */ const char *TodoConduit::version()
+const char *TodoConduit::version()
{
- return "ToDo Conduit " KPILOT_VERSION;
+ return "ToDo Conduit " KPILOT_VERSION;
}
void TodoConduit::doBackup()
{
- PilotRecord* rec;
- int index = 0;
+ kdDebug() << "TodoConduit::doBackup()" << endl;
if (!getCalendar(TodoSetup::TodoGroup)) {
noCalendarError(i18n("ToDo Conduit"));
exit(ConduitMisconfigured);
}
- rec = readRecordByIndex(index++);
+ int index = 0;
+ PilotRecord *rec = readRecordByIndex(index++);
- // Get ALL entries from Pilot
+ // Get ALL entries from Pilot
while(rec) {
- if(rec->getAttrib() & dlpRecAttrDeleted) { // tagged for deletion
- deleteVObject(rec, VCTodoProp);
+ if(rec->isDeleted()) { // tagged for deletion
+ deleteRecord(rec);
+// deleteVObject(rec, VCTodoProp);
} else {
- updateVObject(rec);
- }
+ updateTodo(rec);
+// updateVObject(rec);
+ }
delete rec;
rec = readRecordByIndex(index++);
}
+
// save the todoendar
saveVCal();
// clear the "first time" flag
- KConfig& config = KPilotConfig::getConfig(TodoSetup::TodoGroup);
- setFirstTime(config, false);
+ KConfig& config = KPilotConfig::getConfig(TodoSetup::TodoGroup);
+ setFirstTime(config, false);
}
void TodoConduit::doSync()
{
- FUNCTIONSETUP;
- PilotRecord* rec;
+ FUNCTIONSETUP;
+ PilotRecord* rec;
- if (!getCalendar(TodoSetup::TodoGroup)) {
- noCalendarError(i18n("ToDo Conduit"));
- exit(ConduitMisconfigured);
- }
+ if (!getCalendar(TodoSetup::TodoGroup)) {
+ noCalendarError(i18n("ToDo Conduit"));
+ exit(ConduitMisconfigured);
+ }
- DEBUGCONDUIT << fname << ": Pilot -> Desktop" << endl;
+ DEBUGCONDUIT << fname << ": Pilot -> Desktop" << endl;
- rec = readNextModifiedRecord();
+ rec = readNextModifiedRecord();
- // get only MODIFIED entries from Pilot, compared with the above (doBackup),
- // which gets ALL entries
- while (rec) {
- if(rec->getAttrib() & dlpRecAttrDeleted)
- // recordDeleted(rec);
- deleteVObject(rec, VCTodoProp);
- else {
- bool pilotRecModified = (rec->getAttrib() & dlpRecAttrDirty);
- if (pilotRecModified)
- {
- updateVObject(rec);
- }
- else {
- DEBUGCONDUIT << fname
- << ": Asked for a modified record and got "
- "an unmodified one."
- << endl;
- }
- }
-
- delete rec;
- rec = readNextModifiedRecord();
- }
+ // get only MODIFIED entries from Pilot, compared with the above (doBackup),
+ // which gets ALL entries
+ while (rec) {
+ if(rec->isDeleted()) deleteRecord(rec);
+ else {
+ bool pilotRecModified = (rec->getAttrib() & dlpRecAttrDirty);
+ if (pilotRecModified) {
+ updateTodo(rec);
+ } else {
+ DEBUGCONDUIT << fname
+ << ": Asked for a modified record and got "
+ "an unmodified one."
+ << endl;
+ }
+ }
- // now, all the stuff that was modified/new on the pilot should be
- // added to the todoendar. We now need to add stuff to the pilot
- // that is modified/new in the todoendar (the opposite).
- DEBUGCONDUIT << fname << ": Desktop -> Pilot" << endl;
- doLocalSync();
+ delete rec;
+ rec = readNextModifiedRecord();
+ }
- // now we save the todoendar.
- saveVCal();
+ // now, all the stuff that was modified/new on the pilot should be
+ // added to the todoendar. We now need to add stuff to the pilot
+ // that is modified/new in the todoendar (the opposite).
+ DEBUGCONDUIT << fname << ": Desktop -> Pilot" << endl;
+ doLocalSync();
- // clear the "first time" flag
+ // now we save the todoendar.
+ saveVCal();
+
+ // clear the "first time" flag
KConfig& config = KPilotConfig::getConfig(TodoSetup::TodoGroup);
setFirstTime(config, false);
}
-/*****************************************************************************/
-
/*
* Given a pilot record, check to see what needs to be done to the
* analogous vobject to bring things into sync.
*/
-void TodoConduit::updateVObject(PilotRecord *rec)
+void TodoConduit::updateTodo(PilotRecord *rec)
{
- FUNCTIONSETUP;
-
- VObject *vtodo;
- VObject *vo;
- QDateTime todaysDate = QDateTime::currentDateTime();
- QString tmpStr;
PilotTodoEntry todoEntry(rec);
- vtodo=findEntryInCalendar(rec->getID(), VCTodoProp);
+ Todo *vtodo=findTodo(rec->getID());
if (!vtodo) {
// no event was found, so we need to add one with some initial info
- QString numStr;
- vtodo = addProp(calendar(), VCTodoProp);
- addDateProperty(vtodo, VCDCreatedProp, todaysDate);
- numStr.sprintf("KPilot - %ld",rec->getID());
- addPropValue(vtodo, VCUniqueStringProp, numStr.latin1());
- addPropValue(vtodo, VCSequenceProp, "1");
- addDateProperty(vtodo, VCLastModifiedProp, todaysDate);
- addPropValue(vtodo, VCPriorityProp, "0");
- addPropValue(vtodo, KPilotIdProp,
- numStr.setNum(todoEntry.getID()).latin1());
- addPropValue(vtodo, KPilotStatusProp, "0");
- }
+ vtodo = new Todo;
+ calendar()->addTodo(vtodo);
- if (getStatus(vtodo)) {
- // we don't want to modify the vobject with pilot info, because it has
- // already been modified on the desktop. The VObject's modified state
- // overrides the PilotRec's modified state.
- return;
+ vtodo->setPilotId(todoEntry.getID());
+ vtodo->setSyncStatus(Incidence::SYNCNONE);
}
+ // we don't want to modify the vobject with pilot info, because it has
+ // already been modified on the desktop. The VObject's modified state
+ // overrides the PilotRec's modified state.
+
+ if (vtodo->syncStatus() != Incidence::SYNCNONE) return;
+
// otherwise, the vObject hasn't been touched. Updated it with the
// info from the PilotRec.
-
- // DUE DATE //
- vo = isAPropertyOf(vtodo, VCDueProp);
- if (todoEntry.getIndefinite())
- {
- // there is no due date, remove it if already present.
- //
- //
- if (vo)
- {
- addProp(vo, KPilotSkipProp);
- }
-
- DEBUGCONDUIT << fname
- << ": Todo-item with no end date."
- << endl;
- }
- else
- {
- if (vo)
- {
- setDateProperty(vo, todoEntry.getDueDate_p());
- }
- else
- {
- addDateProperty(vtodo, VCDueProp,
- todoEntry.getDueDate_p());
- }
- }
-
+
+ if (todoEntry.getIndefinite()) {
+ vtodo->setHasDueDate(false);
+ } else {
+ vtodo->setDtDue(readTm(todoEntry.getDueDate()));
+ }
+
// PRIORITY //
- vo = isAPropertyOf(vtodo, VCPriorityProp);
- int priority = todoEntry.getPriority();
- tmpStr.setNum(priority);
- if (vo)
- setVObjectUStringZValue_(vo, fakeUnicode(tmpStr.latin1(), 0));
- else
- addPropValue(vtodo, VCPriorityProp, tmpStr.latin1());
+ vtodo->setPriority(todoEntry.getPriority());
// COMPLETED? //
- vo = isAPropertyOf(vtodo, VCStatusProp);
- tmpStr = (todoEntry.getComplete() ? "COMPLETED" : "X-ACTION");
- if (vo)
- setVObjectUStringZValue_(vo, fakeUnicode(tmpStr.latin1(), 0));
- else
- addPropValue(vtodo, VCStatusProp, tmpStr.latin1());
+ vtodo->setCompleted(todoEntry.getComplete());
setSummary(vtodo, todoEntry.getDescription());
setNote(vtodo, todoEntry.getNote());
- setStatus(vtodo, 0);
+
+ vtodo->setSyncStatus(Incidence::SYNCNONE);
}
-/*****************************************************************************/
-
void TodoConduit::doLocalSync()
{
- FUNCTIONSETUP;
+ FUNCTIONSETUP;
- VObjectIterator i;
-
- initPropIterator(&i, calendar());
+ QList<Todo> todos = calendar()->getTodoList();
/* go through the whole todo list. If the event has the dirty
(modified) flag set, make a new pilot record and add it. */
- while (moreIteration(&i)) {
+ for(Todo *todo = todos.first();todo;todo = todos.next()) {
recordid_t id;
PilotTodoEntry *todoEntry;
PilotRecord *pRec;
- VObject *vtodo = nextVObject(&i);
- if (strcmp(vObjectName(vtodo), VCTodoProp) == 0 &&
- getStatus(vtodo)) {
- /* the event has been modified, need to write it to the pilot
- After using the writeRecord method, be sure and put the returned id
- back into the todo entry! */
+ if (todo->syncStatus() != Incidence::SYNCNONE) {
+ // The event has been modified, need to write it to the pilot.
+ // After using the writeRecord method, be sure and put the returned id
+ // back into the todo entry!
// we read the pilotID.
- id = getRecordID(vtodo);
+ id = todo->pilotId();
- // if id != 0, this is a modified event, otherwise it is new.
- if (id != 0) {
+ // if id != 0, this is a modified event, otherwise it is new.
+ if (id != 0) {
pRec = readRecordById(id);
/* If this fails, somehow the record got deleted from the
pilot but we were never informed! bad pilot. naughty
@@ -373,93 +261,60 @@ void TodoConduit::doLocalSync()
todoEntry = new PilotTodoEntry();
id = 0;
}
- } else {
- todoEntry = new PilotTodoEntry();
- }
-
- // update it from the vObject.
-
- // END TIME (DUE DATE) //
- VObject *vo;
- if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0L) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- struct tm due = ISOToTm(QString(s));
- DEBUGCONDUIT << fname << ": Due Date: " << s << endl;
- deleteStr(s);
- todoEntry->setDueDate(due);
- todoEntry->setIndefinite(0);
- } else {
- // indefinite event
- DEBUGCONDUIT << fname << ": Indefinite event.\n";
- todoEntry->setIndefinite(1);
- }
+ } else {
+ todoEntry = new PilotTodoEntry();
+ }
- // PRIORITY //
- if ((vo = isAPropertyOf(vtodo, VCPriorityProp)) != 0L) {
- int priority = atoi(fakeCString(vObjectUStringZValue(vo)));
- if (priority == 0)
- priority = 1; // no 'undefined' priorities on the pilot
- todoEntry->setPriority(priority);
- } else {
- todoEntry->setPriority(1); // todo needs a priority.
- }
+ // update it from the iCalendar Todo.
- // COMPLETE? //
- if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0L) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- if (strcmp(s, "COMPLETED") == 0)
- todoEntry->setComplete(1);
- else
- todoEntry->setComplete(0);
- deleteStr(s);
- } else {
- // needs complete status even if none given
- todoEntry->setComplete(0);
- }
+ if (todo->hasDueDate()) {
+ struct tm t = writeTm(todo->dtDue());
+ todoEntry->setDueDate(t);
+ todoEntry->setIndefinite(0);
+ } else {
+ todoEntry->setIndefinite(1);
+ }
- // SUMMARY //
- // what we call summary pilot calls description.
- todoEntry->setDescription(getSummary(vtodo));
+ todoEntry->setPriority(todo->priority());
+
+ todoEntry->setComplete(todo->isCompleted());
+
+ // what we call summary pilot calls description.
+ todoEntry->setDescription(todo->summary());
- // DESCRIPTION //
- // what we call description pilot puts as a separate note
- todoEntry->setNote(getDescription(vtodo));
+ // what we call description pilot puts as a separate note
+ todoEntry->setNote(todo->description());
- // put the pilotRec in the database...
- pRec=todoEntry->pack();
- pRec->setAttrib(todoEntry->getAttrib() & ~dlpRecAttrDirty);
- id = writeRecord(pRec);
- delete(todoEntry);
- delete(pRec);
+ // put the pilotRec in the database...
+ pRec=todoEntry->pack();
+ pRec->setAttrib(todoEntry->getAttrib() & ~dlpRecAttrDirty);
+ id = writeRecord(pRec);
+ delete(todoEntry);
+ delete(pRec);
- // write the id we got from writeRecord back to the vObject
- if (id > 0) {
- setNumProperty(vtodo, KPilotIdProp, id);
- setNumProperty(vtodo, KPilotStatusProp, 0);
- } else {
- kdDebug() << fname
- << "error! writeRecord returned a pilotID <= 0!"
- << endl;
- }
+ // write the id we got from writeRecord back to the vObject
+ if (id > 0) {
+ todo->setPilotId(id);
+ todo->setSyncStatus(Incidence::SYNCNONE);
+ } else {
+ kdDebug() << fname
+ << "error! writeRecord returned a pilotID <= 0!"
+ << endl;
}
- }
+ }
+ }
KConfig& config = KPilotConfig::getConfig(TodoSetup::TodoGroup);
- bool DeleteOnPilot = config.readBoolEntry("DeleteOnPilot", true);
+ bool deleteOnPilot = config.readBoolEntry("DeleteOnPilot", true);
- if (firstTime())
- firstSyncCopy(DeleteOnPilot);
+ if (firstTime()) firstSyncCopy(deleteOnPilot);
- if (DeleteOnPilot)
- deleteFromPilot(VCTodoProp);
+ if (deleteOnPilot) deleteFromPilot(VCalBaseConduit::TypeTodo);
}
-
-//////////////////////////////////////////////////////////////////////////
-
-void TodoConduit::firstSyncCopy(bool DeleteOnPilot) {
- FUNCTIONSETUP;
+void TodoConduit::firstSyncCopy(bool DeleteOnPilot)
+{
bool insertall = false, skipall = false;
// Get all entries from Pilot
@@ -474,10 +329,9 @@ void TodoConduit::firstSyncCopy(bool Del
<< endl;
continue;
}
-
- VObject *vevent = findEntryInCalendar(rec->getID(),
- VCTodoProp);
- if (vevent == 0L) {
+
+ Todo *todo = findTodo(rec->getID());
+ if (!todo) {
DEBUGCONDUIT << __FUNCTION__
<< ": Entry found on pilot but not in vcalendar."
<< endl;
@@ -497,7 +351,7 @@ void TodoConduit::firstSyncCopy(bool Del
text += i18n("Item: %1.\n\n"
"What must be done with this item?")
.arg(todoEntry->getDescription());
-
+
int response =
QMessageBox::information(0,
i18n("KPilot To-Do Conduit"),
@@ -514,30 +368,28 @@ void TodoConduit::firstSyncCopy(bool Del
<< endl;
switch (response) {
- case 0:
- default:
- /* Default is to insert this single entry and ask again
- later. */
- updateVObject(rec);
- break;
- case 1:
- // Just skip this, it will be deleted by deleteFromPilot().
- break;
- case 2:
- insertall = true;
- skipall = false;
- updateVObject(rec);
- break;
- } // switch (response)
+ case 0:
+ default:
+ // Default is to insert this single entry and ask again later
+ updateTodo(rec);
+ break;
+ case 1:
+ // Just skip this, it will be deleted by deleteFromPilot().
+ break;
+ case 2:
+ insertall = true;
+ skipall = false;
+ updateTodo(rec);
+ break;
+ }
} else if (insertall) {
- // all records are to be inserted.
- updateVObject(rec);
+ // all records are to be inserted.
+ updateTodo(rec);
}
- } // if (!vevent)
+ }
delete rec;
- } // while ((rec = readRecordByIndex(index++)) != 0)
-} // void TodoConduit::firstSyncCopy()
-
+ }
+}
/* put up the about / setup dialog. */
QWidget* TodoConduit::aboutAndSetup()
Index: conduits/vcalconduit/todo-conduit.h
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/todo-conduit.h,v
retrieving revision 1.2
diff -u -3 -d -p -r1.2 todo-conduit.h
--- conduits/vcalconduit/todo-conduit.h 2001/06/05 22:58:40 1.2
+++ conduits/vcalconduit/todo-conduit.h 2001/06/17 22:03:19
@@ -41,34 +41,36 @@
#include <time.h>
#endif
-#ifndef _VCAL_VCALBASE_H
+#include <todo.h>
+
#include "vcalBase.h"
-#endif
class QWidget;
class PilotRecord;
+using namespace KCal;
class TodoConduit : public VCalBaseConduit
{
-public:
- TodoConduit(eConduitMode mode);
- virtual ~TodoConduit();
-
- virtual void doSync();
- virtual void doBackup();
- virtual QWidget* aboutAndSetup();
+ public:
+ TodoConduit(eConduitMode mode,DatabaseSource source=ConduitSocket);
+ virtual ~TodoConduit();
- virtual const char* dbInfo() { return "TodoDB"; }
+ virtual void doSync();
+ virtual void doBackup();
+ virtual QWidget* aboutAndSetup();
+
+ virtual const char* dbInfo() { return "ToDoDB"; }
- static const char *version();
+ static const char *version();
-protected:
- virtual void doLocalSync();
- virtual void updateVObject(PilotRecord *rec);
+ protected:
+ virtual void doLocalSync();
+ virtual void updateTodo(PilotRecord *rec);
+// virtual void updateVObject(PilotRecord *rec);
- private:
- void firstSyncCopy(bool DeleteOnPilot);
+ private:
+ void firstSyncCopy(bool DeleteOnPilot);
};
#endif
Index: conduits/vcalconduit/todo-setup.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/todo-setup.cc,v
retrieving revision 1.2
diff -u -3 -d -p -r1.2 todo-setup.cc
--- conduits/vcalconduit/todo-setup.cc 2001/06/05 22:58:40 1.2
+++ conduits/vcalconduit/todo-setup.cc 2001/06/17 22:03:19
@@ -25,110 +25,64 @@
** MA 02139, USA.
*/
-/*
-** Bug reports and questions can be sent to adridg@cs.kun.nl
-*/
static const char *todo_setup_id="$Id: todo-setup.cc,v 1.2 2001/06/05 22:58:40 adridg Exp $";
-
#include "options.h"
-#ifndef QDIR_H
#include <qdir.h>
-#endif
-
-#ifndef QLABEL_H
#include <qlabel.h>
-#endif
-
-#ifndef QPUSHBT_H
-#include <qpushbt.h>
-#endif
-
-#ifndef QCHKBOX_H
-#include <qchkbox.h>
-#endif
-
-#ifndef QLINED_H
-#include <qlined.h>
-#endif
-
-#ifndef QLAYOUT_H
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qlineedit.h>
#include <qlayout.h>
-#endif
-#ifndef _KAPP_H
#include <kapp.h>
-#endif
-
-#ifndef _KLOCALE_H
#include <klocale.h>
-#endif
-
-#ifndef _KDEBUG_H
#include <kdebug.h>
-#endif
-
-#ifndef _KFILEDIALOG_H
#include <kfiledialog.h>
-#endif
-#ifndef _KDEBUG_H
-#include <kdebug.h>
-#endif
-
-#ifndef _KPILOT_TODO_CONDUIT_H
-#include "todo-conduit.h"
-#endif
-
-#ifndef _KPILOT_KPILOTCONFIG_H
#include "kpilotConfig.h"
-#endif
-
+#include "todo-conduit.h"
+#include "todo-setup.h"
#include "todo-setup.moc"
-/* static */ const QString TodoSetup::TodoGroup("todoOptions");
+const QString TodoSetup::TodoGroup("todoOptions");
TodoSetup::TodoSetup(QWidget *parent)
: setupDialog(parent,TodoGroup,TodoConduit::version())
{
- FUNCTIONSETUP;
- KConfig& config=KPilotConfig::getConfig(TodoGroup);
- addPage(new TodoSetupPage(this,config));
- addPage(new setupInfoPage(this));
- setupDialog::setupWidget();
- (void) todo_setup_id;
+ KConfig& config=KPilotConfig::getConfig(TodoGroup);
+ addPage(new TodoSetupPage(this,config));
+ addPage(new setupInfoPage(this));
+ setupDialog::setupWidget();
+ (void) todo_setup_id;
}
int TodoSetupPage::commitChanges(KConfig& config)
{
- config.writeEntry("CalFile", fCalendarFile->text());
- config.writeEntry("FirstTime",
- fPromptFirstTime->isChecked() ? "true" : "false");
- config.writeEntry("DeleteOnPilot",
- fDeleteOnPilot->isChecked() ? "true" : "false");
+ config.writeEntry("CalFile", fCalendarFile->text());
+ config.writeEntry("FirstTime",
+ fPromptFirstTime->isChecked() ? "true" : "false");
+ config.writeEntry("DeleteOnPilot",
+ fDeleteOnPilot->isChecked() ? "true" : "false");
- return 0;
+ return 0;
}
void TodoSetupPage::slotBrowse()
{
- FUNCTIONSETUP;
-
- QString fileName = KFileDialog::getOpenFileName(0L, "*.vcs");
+ QString fileName = KFileDialog::getOpenFileName(0, "*.vcs *ics");
if(fileName.isNull()) return;
fCalendarFile->setText(fileName);
}
TodoSetupPage::TodoSetupPage(setupDialog *parent,KConfig& config) :
- setupDialogPage(i18n("ToDo File"),parent)
+ setupDialogPage(i18n("ToDo File"),parent)
{
- FUNCTIONSETUP;
-
grid = new QGridLayout(this, 2, 3, SPACING);
fCalFileLabel = new QLabel(i18n("Calendar File:"),
@@ -160,7 +114,8 @@ TodoSetupPage::TodoSetupPage(setupDialog
grid->addWidget(fDeleteOnPilot, 2, 1);
}
-TodoSetupPage::~TodoSetupPage() {
+TodoSetupPage::~TodoSetupPage()
+{
delete fCalendarFile;
delete fPromptFirstTime;
delete fDeleteOnPilot;
Index: conduits/vcalconduit/vcal-conduit.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/vcal-conduit.cc,v
retrieving revision 1.42
diff -u -3 -d -p -r1.42 vcal-conduit.cc
--- conduits/vcalconduit/vcal-conduit.cc 2001/06/13 21:30:24 1.42
+++ conduits/vcalconduit/vcal-conduit.cc 2001/06/17 22:03:20
@@ -2,12 +2,12 @@
**
** Copyright (C) 1998-2000 by Dan Pilone, Preston Brown, and
** Herwin Jan Steehouwer
+** Copyright (C) 2001 by Cornelius Schumacher
**
** A program to synchronize KOrganizer's date book with the Palm
** Pilot / KPilot. This program is part of KPilot.
*/
-
/*
** 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
@@ -25,15 +25,6 @@
** MA 02139, USA.
*/
-/*
-** Bug reports and questions can be sent to adridg@cs.kun.nl
-*/
-
-
-// I have noticed that this is full of memory leaks, but since it is
-// short lived, it shouldn't matter so much. -- PGB
-
-
#ifndef _KPILOT_OPTIONS_H
#include "options.h"
#endif
@@ -44,196 +35,116 @@
#include <stdlib.h>
#include <time.h>
-#ifndef QBITARRAY_H
#include <qbitarray.h>
-#endif
-
-#ifndef QDIR_H
#include <qdir.h>
-#endif
-
-#ifndef QDATETM_H
#include <qdatetm.h>
-#endif
-
-#ifndef QSTRING_H
#include <qstring.h>
-#endif
-
-#ifndef QMSGBOX_H
#include <qmsgbox.h>
-#endif
-
-#ifndef _KCONFIG_H
#include <kconfig.h>
-#endif
-
-#ifndef _KDEBUG_H
#include <kdebug.h>
-#endif
-
-#ifndef _KPILOT_KPILOTCONFIG_H
#include "kpilotConfig.h"
-#endif
-
-#ifndef _KPILOT_PILOTDATABASE_H
#include "pilotDatabase.h"
-#endif
-
-#ifndef _KPILOT_PILOTRECORD_H
-#include "pilotRecord.h"
-#endif
-
-#ifndef _KPILOT_PILOTDATEENTRY_H
#include "pilotDateEntry.h"
-#endif
-
-#ifndef _KPILOT_VCAL_CONDUIT_H
#include "vcal-conduit.h"
-#endif
-
-#ifndef _KPILOT_VCAL_SETUP_H
#include "vcal-setup.h"
-#endif
-
-#ifndef _KPILOT_CONDUITAPP_H
#include "conduitApp.h"
-#endif
-#ifndef __VCC_H__
-#include "vcc.h"
-#endif
-
static const char *id=
"$Id: vcal-conduit.cc,v 1.42 2001/06/13 21:30:24 adridg Exp $";
int main(int argc, char* argv[])
{
- ConduitApp a(argc, argv, "vcal_conduit",
- "Calendar / Organizer conduit",
- KPILOT_VERSION);
+ ConduitApp a(argc,argv,"vcal_conduit","Calendar / Organizer conduit",
+ KPILOT_VERSION);
a.addAuthor("Preston Brown",I18N_NOOP("Organizer author"));
- a.addAuthor("Adriaan de Groot",
- I18N_NOOP("Maintainer"),
- "adridg@cs.kun.nl");
- a.addAuthor("Philipp Hullmann",
- I18N_NOOP("Bugfixer"));
- VCalConduit conduit(a.getMode());
+ a.addAuthor("Adriaan de Groot",I18N_NOOP("Maintainer"),"adridg@cs.kun.nl");
+ a.addAuthor("Philipp Hullmann",I18N_NOOP("Bugfixer"));
+ a.addAuthor("Cornelius Schumacher",I18N_NOOP("iCalendar port"));
+
+ VCalConduit conduit(a.getMode(),a.getDBSource());
a.setConduit(&conduit);
return a.exec(false,true);
- /* NOTREACHED */
- (void) id;
+ /* NOTREACHED */
+ (void) id;
}
-
-/*****************************************************************************/
-VCalConduit::VCalConduit(BaseConduit::eConduitMode mode) :
- VCalBaseConduit(mode)
+VCalConduit::VCalConduit(eConduitMode mode,DatabaseSource source) :
+ VCalBaseConduit(mode,source)
{
- FUNCTIONSETUP;
}
-
VCalConduit::~VCalConduit()
{
}
-
-//////////////////////////////////////////////////////////////////////////
-
-
void VCalConduit::doBackup()
{
FUNCTIONSETUP;
- PilotRecord* rec;
- int index = 0;
- if (!getCalendar(VCalSetup::VCalGroup))
- {
- noCalendarError(i18n("VCal Conduit"));
- exit(ConduitMisconfigured);
- }
+ if (!getCalendar(VCalSetup::VCalGroup))
+ {
+ noCalendarError(i18n("VCal Conduit"));
+ exit(ConduitMisconfigured);
+ }
- DEBUGCONDUIT << __FUNCTION__
- << ": Performing full backup"
- << endl;
-
- // Get ALL entries from Pilot
- //
- //
- while ((rec=readRecordByIndex(index++)))
- {
- if (rec->isDeleted())
- {
- deleteVObject(rec, VCEventProp);
- }
- else
- {
- updateVObject(rec);
- }
- delete rec;
- }
-
- saveVCal();
-} // void VCalConduit::doBackup()
+ DEBUGCONDUIT << __FUNCTION__
+ << ": Performing full backup"
+ << endl;
+ // Get ALL entries from Pilot
+ int index = 0;
+ PilotRecord* rec;
+ while ((rec=readRecordByIndex(index++))) {
+ if (rec->isDeleted()) deleteRecord(rec);
+ else updateEvent(rec);
+ }
-//////////////////////////////////////////////////////////////////////////
+ saveVCal();
+}
void VCalConduit::doSync()
{
- FUNCTIONSETUP;
+ FUNCTIONSETUP;
- PilotRecord* rec;
- int recordcount=0;
+ PilotRecord* rec;
+ int recordcount=0;
- if (!getCalendar(VCalSetup::VCalGroup)) {
- noCalendarError(i18n("VCal Conduit"));
- exit(ConduitMisconfigured);
- }
+ if (!getCalendar(VCalSetup::VCalGroup)) {
+ noCalendarError(i18n("VCal Conduit"));
+ exit(ConduitMisconfigured);
+ }
- // get only MODIFIED entries from Pilot, compared with
- // the above (doBackup), which gets ALL entries
- //
- //
- while ((rec=readNextModifiedRecord()))
- {
- recordcount++;
- if (rec->isDeleted())
- {
- deleteVObject(rec, VCEventProp);
- }
- else
- {
- bool pilotRecModified =
- (rec->getAttrib() & dlpRecAttrDirty);
- if (pilotRecModified)
- {
- updateVObject(rec);
- }
- else
- {
- kdWarning(CONDUIT_AREA) << __FUNCTION__
- << "weird! we asked for a modified "
- "record and got one that wasn't"
- << endl;
- }
- }
- delete rec;
- }
+ // get only MODIFIED entries from Pilot, compared with
+ // the above (doBackup), which gets ALL entries
+ while ((rec=readNextModifiedRecord())) {
+ recordcount++;
+ if (rec->isDeleted()) deleteRecord(rec);
+ else {
+ bool pilotRecModified = rec->getAttrib() & dlpRecAttrDirty;
+ if (pilotRecModified) {
+ updateEvent(rec);
+ } else {
+ kdWarning(CONDUIT_AREA) << __FUNCTION__
+ << "weird! we asked for a modified "
+ "record and got one that wasn't"
+ << endl;
+ }
+ }
+ delete rec;
+ }
- DEBUGCONDUIT << __FUNCTION__
- << ": Read a total of "
- << recordcount
- << " modified records from the pilot."
- << endl;
+ DEBUGCONDUIT << __FUNCTION__
+ << ": Read a total of "
+ << recordcount
+ << " modified records from the pilot."
+ << endl;
// now, all the stuff that was modified/new on the pilot should be
// added to the vCalendar. We now need to add stuff to the pilot
@@ -242,140 +153,41 @@ void VCalConduit::doSync()
// now we save the vCalendar.
saveVCal();
-} // void VCalConduit::doSync()
-
-
-//////////////////////////////////////////////////////////////////////////
-
-
-void VCalConduit::repeatForever(
- PilotDateEntry *dateEntry,
- int rFreq,
- VObject *vevent)
-{
- FUNCTIONSETUP;
-
- const char *s = "<no description>";
-
- if (vevent)
- {
- VObject *vo = isAPropertyOf(vevent, VCSummaryProp);
- if (vo != 0L)
- {
- s=fakeCString(vObjectUStringZValue(vo));
- }
- }
-
-
- dateEntry->setRepeatFrequency(rFreq);
- dateEntry->setRepeatForever();
- kdWarning(CONDUIT_AREA) << __FUNCTION__
- << ": repeat duration is forever for "
- << s
- << endl;
-}
-// void VCalConduit::repeatForever(PilotDateEntry *dateEntry, int
-// rFreq, VObject *vevent)
-
-
-
-//////////////////////////////////////////////////////////////////////////
-
-
-void VCalConduit::repeatUntil(
- PilotDateEntry *dateEntry,
- const struct tm *start,
- int rFreq,
- int rDuration,
- PeriodConstants period)
-{
- FUNCTIONSETUP;
- struct tm rStart = *start;
- time_t end_time = mktime(&rStart);
- struct tm rEnd = *start;
-
- switch(period)
- {
- case DailyPeriod:
- case WeeklyPeriod:
- // Calculate the end time by adding the right number of
- // repeat periods.
- //
- //
- end_time += rFreq * (rDuration-1) * (int) period;
-
- dateEntry->setRepeatFrequency(rFreq);
- dateEntry->setRepeatEnd(*localtime(&end_time));
- break;
- case MonthlyByDayPeriod:
- case MonthlyByPosPeriod:
- dateEntry->setRepeatFrequency(rFreq);
- rEnd.tm_mon += rFreq * (rDuration - 1);
- rEnd.tm_year += rEnd.tm_mon / 12;
- rEnd.tm_mon %= 12;
- dateEntry->setRepeatEnd(rEnd);
- break;
- case YearlyByDayPeriod:
- dateEntry->setRepeatFrequency(rFreq);
- rEnd.tm_year += rFreq * (rDuration - 1);
- dateEntry->setRepeatEnd(rEnd);
- break;
- default:
- kdWarning(CONDUIT_AREA) << __FUNCTION__
- << ": Unknown repeat period "
- << (int) period
- << endl;
- }
}
-// void VCalConduit::repeatUntil(PilotDateEntry *dateEntry, struct tm
-// start, int rFreq, int rDuration, PeriodConstants period)
-
-/*****************************************************************************/
/*
* Given a pilot record, check to see what needs to be done to the
* analogous vobject to bring things into sync.
*/
-void VCalConduit::updateVObject(PilotRecord *rec) {
+void VCalConduit::updateEvent(PilotRecord *rec)
+{
FUNCTIONSETUP;
- QDateTime todaysDate = QDateTime::currentDateTime();
- //QString tmpStr;
- //QString numStr;
PilotDateEntry dateEntry(rec);
+
+ kdDebug() << "VCalConduit::updateEvent() " << dateEntry.getDescription()
+ << endl;
- VObject *vevent = findEntryInCalendar(rec->getID(), VCEventProp);
+ Event *vevent = findEvent(rec->getID());
if (!vevent) {
// no event was found, so we need to add one with some initial info
DEBUGCONDUIT << __FUNCTION__ << ": creating new vCalendar event"
<< endl;
- vevent = addProp(calendar(), VCEventProp);
+ vevent = new Event;
+ vevent->setOrganizer(calendar()->getEmail());
- addDateProperty(vevent, VCDCreatedProp, todaysDate);
+ calendar()->addEvent(vevent);
- QString numStr;
- numStr.sprintf("KPilot - %ld", rec->getID());
- addPropValue(vevent, VCUniqueStringProp, numStr.latin1());
- addPropValue(vevent, VCSequenceProp, "1");
- addDateProperty(vevent,VCLastModifiedProp,todaysDate);
-
- addPropValue(vevent, VCPriorityProp, "0");
- addPropValue(vevent, VCTranspProp, "0");
- addPropValue(vevent, VCRelatedToProp, "0");
- addPropValue(vevent, KPilotIdProp,
- numStr.setNum(dateEntry.getID()).latin1());
- addPropValue(vevent, KPilotStatusProp, "0");
+ vevent->setPilotId(dateEntry.getID());
+ vevent->setSyncStatus(Incidence::SYNCNONE);
}
-
- // determine whether the vobject has been modified since the last sync
- bool vcalRecModified = (getStatus(vevent) != 0);
- if (vcalRecModified) {
- // we don't want to modify the vobject with pilot info, because it has
- // already been modified on the desktop. The VObject's modified state
- // overrides the PilotRec's modified state.
- return;
- }
+ // we don't want to modify the vobject with pilot info, because it has
+ // already been modified on the desktop. The VObject's modified state
+ // overrides the PilotRec's modified state.
+
+ if (vevent->syncStatus() != Incidence::SYNCNONE) return;
+
// otherwise, the vObject hasn't been touched. Updated it with the
// info from the PilotRec.
@@ -387,154 +199,102 @@ void VCalConduit::updateVObject(PilotRec
setSummary(vevent, dateEntry.getDescription());
setNote(vevent, dateEntry.getNote());
setSecret(vevent, (rec->getAttrib() & dlpRecAttrSecret));
- setStatus(vevent, 0);
-} // void VCalConduit::updateVObject(PilotRecord *rec)
-
-
-//////////////////////////////////////////////////////////////////////////
+ vevent->setSyncStatus(Incidence::SYNCNONE);
+ kdDebug() << "VCalConduit::updateEvent() done" << endl;
+}
-void VCalConduit::setVcalStartEndTimes(VObject *vevent,
- const PilotDateEntry &dateEntry) {
- FUNCTIONSETUP;
+void VCalConduit::setVcalStartEndTimes(Event *vevent,
+ const PilotDateEntry &dateEntry)
+{
// START TIME //
- VObject *vo = isAPropertyOf(vevent, VCDTstartProp);
+ vevent->setDtStart(readTm(dateEntry.getEventStart()));
// check whether the event is an event or an appointment. See dateEntry
// structure for more info.
- if (!dateEntry.getEvent()) {
- // the event doesn't "float"
- if (vo)
- setDateProperty(vo,dateEntry.getEventStart_p());
- else
- addDateProperty(vevent, VCDTstartProp,
- dateEntry.getEventStart_p());
+ if (dateEntry.getEvent()) {
+ vevent->setFloats(true);
} else {
- // the event floats
- if (vo)
- setDateProperty(vo,dateEntry.getEventStart_p(),true);
- else
- addDateProperty(vevent, VCDTstartProp,
- dateEntry.getEventStart_p(),true);
- }
-
- // END TIME //
- vo = isAPropertyOf(vevent, VCDTendProp);
-
- // Patch by Heiko
- bool multiDay = ( (dateEntry.getRepeatType() == repeatDaily) &&
- dateEntry.getEvent() );
-
- if (multiDay) {
- // I honestly don't know what was supposed to go here
+ vevent->setFloats(false);
}
- QDateTime endDT;
+ // END TIME //
// handle the case of a "repeating event on a daily basis" which is the
// pilot's way of indicating a multi-day event.
- if (!multiDay) {
- endDT.setDate(QDate(1900+dateEntry.getEventEnd().tm_year,
- dateEntry.getEventEnd().tm_mon + 1,
- dateEntry.getEventEnd().tm_mday));
- endDT.setTime(QTime(dateEntry.getEventEnd().tm_hour,
- dateEntry.getEventEnd().tm_min,
- dateEntry.getEventEnd().tm_sec));
+ if (dateEntry.isMultiDay()) {
+ vevent->setDtEnd(readTm(dateEntry.getRepeatEnd()));
} else {
- endDT.setDate(QDate(1900+dateEntry.getRepeatEnd().tm_year,
- dateEntry.getRepeatEnd().tm_mon + 1,
- dateEntry.getRepeatEnd().tm_mday));
- endDT.setTime(QTime(dateEntry.getRepeatEnd().tm_hour,
- dateEntry.getRepeatEnd().tm_min,
- dateEntry.getRepeatEnd().tm_sec));
+ vevent->setDtEnd(readTm(dateEntry.getEventEnd()));
}
-
-
- if (vo)
- setDateProperty(vo, endDT, dateEntry.getEvent());
- else
- /* We don't want to add it if it isn't there already, or if the
- event isn't multiday/floating. It is deprecated to have both
- DTSTART and DTEND set to 000000 for their times. */
- if (!dateEntry.getEvent() || multiDay)
- addDateProperty(vevent, VCDTendProp, endDT, dateEntry.getEvent());
-}
-// void VCalConduit::setVcalStartEndTimes(VObject *vevent,
-// PilotDateEntry *dateEntry)
-
-
-//////////////////////////////////////////////////////////////////////////
+}
-void VCalConduit::setVcalAlarms(VObject *vevent,
- const PilotDateEntry &dateEntry) {
+void VCalConduit::setVcalAlarms(Incidence *vevent,
+ const PilotDateEntry &dateEntry)
+{
FUNCTIONSETUP;
- VObject *vo = isAPropertyOf(vevent, VCDAlarmProp);
-
- if (dateEntry.getAlarm()) {
- QDateTime alarmDT;
- alarmDT.setDate(QDate(1900+dateEntry.getEventStart().tm_year,
- dateEntry.getEventStart().tm_mon + 1,
- dateEntry.getEventStart().tm_mday));
- alarmDT.setTime(QTime(dateEntry.getEventStart().tm_hour,
- dateEntry.getEventStart().tm_min,
- dateEntry.getEventStart().tm_sec));
-
- int advanceUnits = dateEntry.getAdvanceUnits();
- switch(advanceUnits) {
- case advMinutes: advanceUnits = 1; break;
- case advHours: advanceUnits = 60; break;
- case advDays: advanceUnits = 60*24; break;
+ if (!dateEntry.getAlarm()) return;
+
+ QDateTime alarmDT = readTm(dateEntry.getEventStart());
+
+ int advanceUnits = dateEntry.getAdvanceUnits();
+ switch (advanceUnits) {
+ case advMinutes:
+ advanceUnits = 1;
+ break;
+ case advHours:
+ advanceUnits = 60;
+ break;
+ case advDays:
+ advanceUnits = 60*24;
+ break;
default:
DEBUGCONDUIT << __FUNCTION__
- << ": Unknown advance units "
- << advanceUnits
- << endl;
+ << ": Unknown advance units "
+ << advanceUnits
+ << endl;
advanceUnits=1;
- }
+ }
- alarmDT = alarmDT.addSecs(60*advanceUnits*-(dateEntry.getAdvance()));
+ alarmDT = alarmDT.addSecs(60*advanceUnits*-(dateEntry.getAdvance()));
- if (vo) {
- vo = isAPropertyOf(vo, VCRunTimeProp);
- setDateProperty(vo, alarmDT);
- } else {
- vo = addProp(vevent, VCDAlarmProp);
- addDateProperty(vo, VCRunTimeProp, alarmDT);
- addPropValue(vo, VCRepeatCountProp, "1");
- addPropValue(vo, VCDisplayStringProp, "beep!");
- }
- } else if (vo)
- addProp(vo, KPilotSkipProp);
+ vevent->alarm()->setTime(alarmDT);
+ vevent->alarm()->setRepeatCount(1); // Enable alarm
}
-// void VCalConduit::setVcalAlarms(VObject *vevent, PilotDateEntry
-// *dateEntry)
-
-//////////////////////////////////////////////////////////////////////////
-
-/* Pilot entries that repeat daily are not what we consider daily
- repeating events in vCalendar/KOrganizer. It is actually a multi-day
- appointment and handled by setVcalStartEndTimes(). */
-void VCalConduit::setVcalRecurrence(VObject *vevent,
- const PilotDateEntry &dateEntry) {
+void VCalConduit::setVcalRecurrence(Incidence *vevent,
+ const PilotDateEntry &dateEntry)
+{
FUNCTIONSETUP;
- const char *dayname[] = {"SU ", "MO ", "TU ", "WE ", "TH ", "FR ",
- "SA "};
+ // Pilot entries that repeat daily are not what we consider daily
+ // repeating events in vCalendar/KOrganizer. It is actually a multi-day
+ // appointment and handled by setVcalStartEndTimes().
+ if ((dateEntry.getRepeatType() == repeatNone) ||
+ ((dateEntry.getRepeatType() == repeatDaily) && dateEntry.getEvent())) {
+ return;
+ }
- VObject *vo = isAPropertyOf(vevent, VCRRuleProp);
+ KORecurrence *recur = vevent->recurrence();
+ int freq = dateEntry.getRepeatFrequency();
+ bool repeatsForever = dateEntry.getRepeatForever();
+ QDate endDate;
+ if (!repeatsForever) {
+ endDate = readTm(dateEntry.getRepeatEnd()).date();
+ kdDebug() << "-- end " << endDate.toString() << endl;
+ } else {
+ kdDebug() << "-- noend" << endl;
+ }
+ QBitArray dayArray(7);
- if (dateEntry.getRepeatType() != repeatNone &&
- !((dateEntry.getRepeatType() == repeatDaily) &&
- dateEntry.getEvent())) {
- QString tmpStr("");
- switch(dateEntry.getRepeatType()) {
+ switch(dateEntry.getRepeatType()) {
case repeatDaily:
- tmpStr.sprintf("D%i ", dateEntry.getRepeatFrequency());
+ if (repeatsForever) recur->setDaily(freq,0);
+ else recur->setDaily(freq,endDate);
break;
case repeatWeekly:
{
@@ -550,21 +310,40 @@ void VCalConduit::setVcalRecurrence(VObj
<< days[6] << " "
<< endl;
- tmpStr.sprintf("W%i ", dateEntry.getRepeatFrequency());
- for (int i = 0; i < 7; i++)
- if (days[i]) tmpStr.append(dayname[i]);
+ if (days[0]) dayArray.setBit(6);
+ for (int i = 1; i < 7; i++) {
+ if (days[i]) dayArray.setBit(i-1);
+ }
+
+ if (repeatsForever) recur->setWeekly(freq,dayArray,0);
+ else recur->setWeekly(freq,dayArray,endDate);
}
break;
- case repeatMonthlyByDay:
+ case repeatMonthlyByDay:
+ if (repeatsForever) recur->setMonthly(KORecurrence::rMonthlyPos,freq,0);
+ else recur->setMonthly(KORecurrence::rMonthlyPos,freq,endDate);
+
+ dayArray.setBit(dateEntry.getRepeatDay() % 7);
+ recur->addMonthlyPos((dateEntry.getRepeatDay() / 7) + 1,dayArray);
+#if 0
tmpStr.sprintf("MP%i %d+ ", dateEntry.getRepeatFrequency(),
(dateEntry.getRepeatDay() / 7) + 1);
tmpStr.append(dayname[dateEntry.getRepeatDay() % 7]);
+#endif
break;
case repeatMonthlyByDate:
+ if (repeatsForever) recur->setMonthly(KORecurrence::rMonthlyDay,freq,0);
+ else recur->setMonthly(KORecurrence::rMonthlyDay,freq,endDate);
+#if 0
tmpStr.sprintf("MD%i ", dateEntry.getRepeatFrequency());
+#endif
break;
case repeatYearly:
+ if (repeatsForever) recur->setYearly(KORecurrence::rYearlyDay,freq,0);
+ else recur->setYearly(KORecurrence::rYearlyDay,freq,endDate);
+#if 0
tmpStr.sprintf("YD%i ", dateEntry.getRepeatFrequency());
+#endif
break;
case repeatNone:
DEBUGCONDUIT << __FUNCTION__
@@ -573,59 +352,30 @@ void VCalConduit::setVcalRecurrence(VObj
break;
default:
break;
- }
-
- if (dateEntry.getRepeatForever())
- tmpStr += "#0";
- else
- tmpStr += TmToISO(dateEntry.getRepeatEnd());
-
- vo = isAPropertyOf(vevent, VCRRuleProp);
- if (vo)
- setVObjectUStringZValue_(vo, fakeUnicode(tmpStr.latin1(), 0));
- else
- addPropValue(vevent, VCRRuleProp,tmpStr.latin1());
- } else if (vo)
- addProp(vo, KPilotSkipProp);
+ }
}
-// void VCalConduit::setVcalRecurrence(VObject *vevent, PilotDateEntry
-// *dateEntry)
-
-
-//////////////////////////////////////////////////////////////////////////
-void VCalConduit::setVcalExceptions(VObject *vevent,
- const PilotDateEntry &dateEntry) {
+void VCalConduit::setVcalExceptions(Incidence *vevent,
+ const PilotDateEntry &dateEntry)
+{
FUNCTIONSETUP;
if (((dateEntry.getRepeatType() == repeatDaily) &&
- dateEntry.getEvent()) && dateEntry.getExceptionCount())
+ dateEntry.getEvent()) && dateEntry.getExceptionCount()) {
DEBUGCONDUIT << __FUNCTION__
<< ": WARNING Exceptions ignored for multi-day event "
<< dateEntry.getDescription()
<< endl ;
+ return;
+ }
- VObject *vo = isAPropertyOf(vevent, VCExDateProp);
- QString tmpStr("");
- if (dateEntry.getExceptionCount()) {
- for (int i = 0; i < dateEntry.getExceptionCount(); i++) {
- tmpStr += TmToISO(dateEntry.getExceptions()[i]);
- tmpStr += ";";
- }
- tmpStr.truncate(tmpStr.length() - 1);
- if (vo)
- setVObjectUStringZValue_(vo, fakeUnicode(tmpStr.latin1(), 0));
- else
- addPropValue(vevent, VCExDateProp, tmpStr.latin1());
- } else if (vo)
- addProp(vo, KPilotSkipProp);
+ for (int i = 0; i < dateEntry.getExceptionCount(); i++) {
+ vevent->addExDate(readTm(dateEntry.getExceptions()[i]).date());
+ }
}
-//////////////////////////////////////////////////////////////////////////
-
-
void VCalConduit::doLocalSync()
{
FUNCTIONSETUP;
@@ -634,189 +384,151 @@ void VCalConduit::doLocalSync()
<< ": Performing local sync."
<< endl;
- VObjectIterator i;
- initPropIterator(&i, calendar());
-
int recordcount = 0;
+ QList<Event> events = calendar()->getAllEvents();
+
// go through the whole vCalendar. If the event has the dirty
// (modified) flag set, make a new pilot record and add it. we only
// take events that have KPilotStatusProp as a property. If this
// property isn't present, ignore the event.
- /* Since the calendar is a singly linked list, we need a pointer to
- the previous item. */
- VObject *previousEvent = 0;
-
- while (moreIteration(&i)) {
+ for(Event *event = events.first();event;event = events.next()) {
recordcount++;
- VObject *vevent = nextVObject(&i);
- if (getStatus(vevent) != 2 &&
- (strcmp(vObjectName(vevent), VCEventProp) == 0)) {
- // the calendar entry is an event and has a KPilotStatus field
+ if (event->syncStatus() == Incidence::SYNCMOD) {
+ // the event has been modified, need to write it to the pilot
- recordid_t id;
- if (getStatus(vevent) == 1) {
- // the event has been modified, need to write it to the pilot
- // we read the pilotID.
+ // we read the pilotID.
- id = getRecordID(vevent);
+ int id = event->pilotId();
- // if id != 0, this is a modified event, otherwise it is new.
+ // if id != 0, this is a modified event, otherwise it is new.
- PilotDateEntry *dateEntry = 0L;
+ PilotDateEntry *dateEntry = 0;
- if (id != 0) {
- PilotRecord *pRec = readRecordById(id);
- // if this fails, somehow the record got deleted from the pilot
- // but we were never informed! bad pilot. naughty pilot.
+ if (id != 0) {
+ PilotRecord *pRec = readRecordById(id);
+ // if this fails, somehow the record got deleted from the pilot
+ // but we were never informed! bad pilot. naughty pilot.
- if (pRec)
- // If the record was deleted on the pilot, recreate it.
- dateEntry = new PilotDateEntry(pRec);
- else {
- dateEntry = new PilotDateEntry();
- id = 0;
- }
- } else
- dateEntry = new PilotDateEntry();
+ if (pRec) {
+ // If the record was deleted on the pilot, recreate it.
+ dateEntry = new PilotDateEntry(pRec);
+ } else {
+ dateEntry = new PilotDateEntry();
+ id = 0;
+ }
+ } else
+ dateEntry = new PilotDateEntry();
- setStartEndTimes(dateEntry, vevent);
- setAlarms(dateEntry, vevent);
+ setStartEndTimes(dateEntry,event);
+ setAlarms(dateEntry,event);
- // RECURRENCE(S) //
- {
- // first we have a 'fake type of recurrence' when a multi-day
- // even it passed to the pilot, it is converted to an event
- // which recurs daily a number of times.
+ // RECURRENCE(S) //
- struct tm start = getStartTime(vevent);
- QDateTime tmpDtStart = tmToQDateTime(start);
- struct tm end = getEndTime(vevent);
- QDateTime tmpDtEnd = tmToQDateTime(end);
+ // first we have a 'fake type of recurrence' when a multi-day
+ // even it passed to the pilot, it is converted to an event
+ // which recurs daily a number of times.
+ if (event->isMultiDay() && event->doesFloat()) {
+ // multi day event
+ DEBUGCONDUIT << __FUNCTION__
+ << ": multi-day event from "
+ << (event->dtStart().toString()) << " to "
+ << (event->dtEnd().toString()) << endl;
+ dateEntry->setRepeatType(repeatDaily);
+ dateEntry->setRepeatFrequency(1);
+ struct tm end = writeTm(event->dtEnd());
+ dateEntry->setRepeatEnd(end);
- if (tmpDtEnd.isValid())
- if (tmpDtStart.daysTo(tmpDtEnd) > 0 &&
- start.tm_hour == 0 && start.tm_min == 0 &&
- start.tm_sec == 0) {
- // multi day event
- DEBUGCONDUIT << __FUNCTION__
- << ": multi-day event from "
- << tmpDtStart.toString() << " to "
- << tmpDtEnd.toString() << endl;
- dateEntry->setRepeatType(repeatDaily);
- dateEntry->setRepeatFrequency(1);
- dateEntry->setRepeatEnd(end);
- if (isAPropertyOf(vevent, VCExDateProp) != 0L)
- DEBUGCONDUIT << __FUNCTION__
- << ": WARNING: exceptions ignored "
- << "for multi-day event "
- << getSummary(vevent)
- << endl ;
- }
- }
+ if (event->exDates().count() > 0) {
+ DEBUGCONDUIT << __FUNCTION__
+ << ": WARNING: exceptions ignored "
+ << "for multi-day event "
+ << event->summary()
+ << endl ;
+ }
+ }
- // and now the real recurring events
- setRepetition(dateEntry, getRepetition(vevent));
+ // and now the real recurring events
+ setRepetition(dateEntry,event);
- // EXCEPTION(S) //
- {
- int count;
- struct tm *exceptionList = getExceptionDates(vevent, &count);
- if (exceptionList) {
- dateEntry->setExceptionCount(count);
- dateEntry->setExceptions(exceptionList);
- } else
- dateEntry->setExceptionCount(0);
- }
+ // EXCEPTION(S) //
+ int count;
+ struct tm *exceptionList = getExceptionDates(event,&count);
+ if (exceptionList) {
+ dateEntry->setExceptionCount(count);
+ dateEntry->setExceptions(exceptionList);
+ } else {
+ dateEntry->setExceptionCount(0);
+ }
- // SUMMARY //
- dateEntry->setDescription(getSummary(vevent).latin1());
+ // SUMMARY //
+ dateEntry->setDescription(event->summary());
- // DESCRIPTION //
- dateEntry->setNote(getDescription(vevent).latin1());
+ // DESCRIPTION //
+ dateEntry->setNote(event->description());
- // put the pilotRec in the database...
- {
- PilotRecord *pRec = dateEntry->pack();
- pRec->setAttrib(dateEntry->getAttrib() & ~dlpRecAttrDirty);
- id = writeRecord(pRec);
- ::free(pRec);
- }
+ // put the pilotRec in the database...
+ PilotRecord *pRec = dateEntry->pack();
+ pRec->setAttrib(dateEntry->getAttrib() & ~dlpRecAttrDirty);
+ id = writeRecord(pRec);
+ ::free(pRec);
- delete dateEntry;
+ delete dateEntry;
- if (id > 0) {
- // Writing succeeded. Write the id we got from writeRecord
- // back to the vObject.
- setNumProperty(vevent, KPilotIdProp, id);
- }
+ if (id > 0) {
+ // Writing succeeded. Write the id we got from writeRecord
+ // back to the vObject.
+ event->setPilotId(id);
}
// Clear the 'modified' flag.
- setNumProperty(vevent, KPilotStatusProp, 0);
+ event->setSyncStatus(Incidence::SYNCNONE);
}
- previousEvent = vevent;
}
DEBUGCONDUIT << __FUNCTION__ << ": Read " << recordcount
- << " records total." << endl;
+ << " records total." << endl;
KConfig& config = KPilotConfig::getConfig(VCalSetup::VCalGroup);
- bool DeleteOnPilot = config.readBoolEntry("DeleteOnPilot", true);
-
- if (firstTime())
- firstSyncCopy(DeleteOnPilot);
-
- if (DeleteOnPilot)
- deleteFromPilot(VCEventProp);
+ bool deleteOnPilot = config.readBoolEntry("DeleteOnPilot", true);
- setFirstTime(config, false);
-} // void VCalConduit::doLocalSync()
+ if (firstTime()) firstSyncCopy(deleteOnPilot);
+ if (deleteOnPilot) deleteFromPilot(VCalBaseConduit::TypeEvent);
-//////////////////////////////////////////////////////////////////////////
+ setFirstTime(config,false);
+}
-struct tm *VCalConduit::getExceptionDates(VObject *vevent, int *n) {
+struct tm *VCalConduit::getExceptionDates(Event *vevent, int *n)
+{
FUNCTIONSETUP;
+
struct tm *tmList = 0;
int count = 0;
- VObject *vo = isAPropertyOf(vevent, VCExDateProp);
- if (vo) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- QString tmpStr(s);
- deleteStr(s);
- int index = 0, index2 = 0;
- struct tm extm;
- while ((index2 = tmpStr.find(',', index)) != -1) {
- ++count;
- tmList = (struct tm *) realloc(tmList, sizeof(struct
- tm)*count);
- if (tmList == 0L)
- kdFatal(CONDUIT_AREA) << __FUNCTION__
- << ": realloc() failed!"
- << endl;
- extm = ISOToTm(tmpStr.mid(index, (index2-index)));
- tmList[count-1] = extm;
- index = index2 + 1;
- }
+
+ QDateList dates = vevent->exDates();
+ QDate *date = dates.first();
+ while(date) {
+ struct tm extm = writeTm(*date);
++count;
tmList = (struct tm *) realloc(tmList, sizeof(struct tm)*count);
- if (tmList == 0L)
+ if (!tmList)
kdFatal(CONDUIT_AREA) << __FUNCTION__
<< ": realloc() failed!" << endl;
- extm = ISOToTm(tmpStr.mid(index, (tmpStr.length()-index)));
tmList[count-1] = extm;
+
+ date = dates.next();
}
+
if (n) *n = count;
return tmList;
-} // struct tm *VCalConduit::getExceptionDates(const VObject *vevent, int *n)
-
+}
-//////////////////////////////////////////////////////////////////////////
-void VCalConduit::firstSyncCopy(bool DeleteOnPilot) {
+void VCalConduit::firstSyncCopy(bool DeleteOnPilot)
+{
FUNCTIONSETUP;
bool insertall = false, skipall = false;
@@ -836,10 +548,8 @@ void VCalConduit::firstSyncCopy(bool Del
<< endl;
continue;
}
-
- VObject *vevent = findEntryInCalendar(rec->getID(),
- VCEventProp);
- if (vevent == 0L) {
+
+ if (findEvent(rec->getID())) {
DEBUGCONDUIT << __FUNCTION__
<< ": Entry found on pilot but not in vcalendar."
<< endl;
@@ -876,393 +586,173 @@ void VCalConduit::firstSyncCopy(bool Del
<< endl;
switch (response) {
- case 0:
- default:
- /* Default is to insert this single entry and ask again
- later. */
- updateVObject(rec);
- break;
- case 1:
- // Skip this item, deletion is handled by deleteFromPilot().
- break;
- case 2:
- insertall = true;
- skipall = false;
- updateVObject(rec);
- break;
- } // switch (response)
+ case 0:
+ default:
+ /* Default is to insert this single entry and ask again
+ later. */
+ updateEvent(rec);
+ break;
+ case 1:
+ // Skip this item, deletion is handled by deleteFromPilot().
+ break;
+ case 2:
+ insertall = true;
+ skipall = false;
+ updateEvent(rec);
+ break;
+ }
} else if (insertall) {
- // all records are to be inserted.
- updateVObject(rec);
- }
- } // if (!vevent)
- delete rec;
- } // while ((rec = readRecordByIndex(index++)) != 0)
-} // void VCalConduit::processDeleted()
-
-
-//////////////////////////////////////////////////////////////////////////
-
-struct VCalConduit::eventRepetition
-VCalConduit::getRepetition(VObject *vevent) {
- FUNCTIONSETUP;
-
- struct eventRepetition r;
- VObject *vo = isAPropertyOf(vevent, VCRRuleProp);
- if (vo) {
- r.startDate = getStartTime(vevent);
- char *s = fakeCString(vObjectUStringZValue(vo));
- QString tmpStr(s);
- deleteStr(s);
- tmpStr.simplifyWhiteSpace();
- tmpStr = tmpStr.upper();
-
- int start = 0;
- if (tmpStr.left(1) == "D") {
- DEBUGCONDUIT << __FUNCTION__ << ": repeat daily" << endl;
- r.type = ::repeatDaily;
- start = 1;
- } else if (tmpStr.left(1) == "W") {
- DEBUGCONDUIT << __FUNCTION__ << ": repeat weekly" << endl;
- r.type = ::repeatWeekly;
- start = 1;
- } else if (tmpStr.left(2) == "MP") {
- DEBUGCONDUIT << __FUNCTION__ << ": repeat monthly by day" << endl;
- r.type = ::repeatMonthlyByDay;
- start = 2;
- } else if (tmpStr.left(2) == "MD") {
- DEBUGCONDUIT << __FUNCTION__ << ": repeat monthly by date" << endl;
- r.type = ::repeatMonthlyByDate;
- start = 2;
- } else if (tmpStr.left(2) == "YD") {
- DEBUGCONDUIT << __FUNCTION__ << ": repeat yearly" << endl;
- r.type = ::repeatYearly;
- start = 2;
- } else
- r.type = ::repeatNone;
-
- int index = tmpStr.find(' ');
- int last = tmpStr.findRev(' ') + 1;
-
- r.freq = tmpStr.mid(start, (index - 1)).toInt();
- index++; // advance to beginning of stuff after freq
-
- r.hasEndDate = false;
-
- switch (r.type) {
-
- case ::repeatDaily:
- index = last; // advance to last field
- if (tmpStr.mid(index, 1) == "#") index++;
- if (tmpStr.find('T', index) != -1) {
- r.endDate = ISOToTm(tmpStr.mid(index, tmpStr.length() -
- index).latin1());
- r.hasEndDate = true;
- } else
- r.duration =
- tmpStr.mid(index, tmpStr.length() - index).toInt();
- break;
-
- case ::repeatWeekly:
- if (index == last) {
- QDate tmpDate(1900 + r.startDate.tm_year,
- r.startDate.tm_mon + 1,
- r.startDate.tm_mday);
- r.weekdays.setBit(tmpDate.dayOfWeek() - 1);
- } else {
- while (index < last) {
- QString dayStr = tmpStr.mid(index, 3);
- int dayNum = numFromDay(dayStr);
- r.weekdays.setBit(dayNum);
- index += 3; // advance to next day, or possibly "#"
- }
- }
- index = last;
- if (tmpStr.mid(index,1) == "#") index++;
- if (tmpStr.find('T', index) != -1) {
- // repeat until a given date
- r.endDate =
- ISOToTm(tmpStr.mid(index, tmpStr.length() -
- index).latin1());
- r.hasEndDate = true;
- } else
- // repeat a given number of times
- r.duration = tmpStr.mid(index, tmpStr.length() - index).toInt();
- break;
-
- case ::repeatMonthlyByDay:
- if (index == last) {
- QDate tmpDate(1900 + r.startDate.tm_year,
- r.startDate.tm_mon + 1,
- r.startDate.tm_mday);
- short tmpPos = tmpDate.day() / 7 + 1;
- if (tmpPos == 5) tmpPos = -1;
- r.repeatDay =
- (DayOfMonthType) (7 * (tmpPos - 1) +
- tmpDate.dayOfWeek() - 1);
- } else {
- while (index < last) {
- short tmpPos = tmpStr.mid(index, 1).toShort();
- index++;
- if (tmpStr.mid(index,1) == "-")
- // convert tmpPos to negative
- tmpPos = -tmpPos;
- index += 2; // advance to day(s)
- int dayNum = 0;
- while (numFromDay(tmpStr.mid(index, 3)) >= 0) {
- if (!dayNum) // pilot can only handle 1 day in month-by-pos
- dayNum = numFromDay(tmpStr.mid(index, 3));
- index += 3; // advance to next day, or possibly pos / "#"
- }
- r.repeatDay = (DayOfMonthType) (7 * (tmpPos - 1) + dayNum);
- }
+ // all records are to be inserted.
+ updateEvent(rec);
}
- index = last;
- if (tmpStr.mid(index,1) == "#") index++;
- if (tmpStr.find('T', index) != -1) {
- r.endDate = ISOToTm(tmpStr.mid(index, tmpStr.length() -
- index).latin1());
- r.hasEndDate = true;
- } else
- r.duration = tmpStr.mid(index, tmpStr.length() -
- index).toInt();
- break;
-
- case ::repeatMonthlyByDate:
- case ::repeatYearly:
- //if (index != last) // +++ ???
- //while (index < last)
- // index = tmpStr.find(' ', index) + 1;
- index = last;
- if (tmpStr.mid(index,1) == "#") index++;
- if (tmpStr.find('T', index) != -1) {
- r.endDate = ISOToTm(tmpStr.mid(index, tmpStr.length() -
- index).latin1());
- r.hasEndDate = true;
- } else
- r.duration = tmpStr.mid(index, tmpStr.length() -
- index).toInt();
- break;
-
- case ::repeatNone:
- break;
-
- default:
- kdError(CONDUIT_AREA) << __FUNCTION__
- << ": unknown repetition type!"
- << endl;
- break;
}
-
- } else
- r.type = ::repeatNone;
-
- return r;
+ delete rec;
+ }
}
-
-//////////////////////////////////////////////////////////////////////////
-
-void VCalConduit::setRepetition(PilotDateEntry *dateEntry,
- const eventRepetition &er) {
+void VCalConduit::setRepetition(PilotDateEntry *dateEntry,Incidence *incidence)
+{
FUNCTIONSETUP;
-
- // Default to repeat daily, since there is
- // no "None" element of PeriodConstants.
- //
- PeriodConstants period = DailyPeriod;
- dateEntry->setRepeatType(er.type);
+ KORecurrence *recur = incidence->recurrence();
- if (er.type != repeatNone) {
- DEBUGCONDUIT << __FUNCTION__
- << ": type " << er.type
- << ", freq " << er.freq
- << ", hasEndDate " << er.hasEndDate
- << ", duration " << er.duration
- << ", repeatDay" << er.repeatDay
- << endl;
+ // Default to repeat daily, since there is no "None" element of
+ // PeriodConstants.
+ PeriodConstants period = DailyPeriod;
- switch (er.type) {
- case repeatDaily:
+ switch (recur->doesRecur()) {
+ case KORecurrence::rNone:
+ dateEntry->setRepeatType(repeatNone);
+ break;
+ case KORecurrence::rDaily:
+ dateEntry->setRepeatType(repeatDaily);
period = DailyPeriod;
break;
- case repeatWeekly:
- dateEntry->setRepeatDays(er.weekdays);
+ case KORecurrence::rWeekly:
+ dateEntry->setRepeatType(repeatWeekly);
period = WeeklyPeriod;
+ dateEntry->setRepeatDays(recur->days());
break;
- case repeatMonthlyByDay:
- dateEntry->setRepeatDay(er.repeatDay);
+ case KORecurrence::rMonthlyPos:
+ dateEntry->setRepeatType(repeatMonthlyByDay);
period = MonthlyByPosPeriod;
+ {
+ QList<KORecurrence::rMonthPos> rl = recur->monthPositions();
+ KORecurrence::rMonthPos *r = rl.first();
+ if (!r) {
+ kdDebug() << "Recurrence monthlyPos, but no rMonthPos" << endl;
+ dateEntry->setRepeatType(repeatNone);
+ } else {
+ int pos = (r->rPos - 1) * 7;
+ for(int i=0;i<7;++i) {
+ if (r->rDays.testBit(i)) {
+ pos += i;
+ break;
+ }
+ }
+ dateEntry->setRepeatDay((DayOfMonthType) pos);
+ }
+ }
break;
- case repeatMonthlyByDate:
+ case KORecurrence::rMonthlyDay:
+ dateEntry->setRepeatType(repeatMonthlyByDate);
period = MonthlyByDayPeriod;
break;
- case repeatYearly:
+ case KORecurrence::rYearlyDay:
+ dateEntry->setRepeatType(repeatYearly);
period = YearlyByDayPeriod;
break;
default:
- kdError(CONDUIT_AREA) << __FUNCTION__
- << ": unknown repetition type "
- << er.type << endl;
+ kdDebug() << "This recurrence type is not supported." << endl;
break;
- }
-
- if (er.hasEndDate)
- {
- dateEntry->setRepeatFrequency(er.freq);
- dateEntry->setRepeatEnd(er.endDate);
- }
- else if (er.duration == 0)
- {
- dateEntry->setRepeatFrequency(er.freq);
- dateEntry->setRepeatForever();
- }
- else
- {
- repeatUntil(dateEntry, &er.startDate, er.freq, er.duration,
- period);
- }
}
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-
-struct tm VCalConduit::getStartTime(VObject *vevent) {
- FUNCTIONSETUP;
-
- struct tm start;
- VObject *vo = isAPropertyOf(vevent, VCDTstartProp);
- if (vo) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- start = ISOToTm(QString(s));
- deleteStr(s);
- } else
- memset(&start, 0, sizeof(start));
- return start;
-} // struct tm VCalConduit::getStartTime(const VObject *vevent)
-
-
-//////////////////////////////////////////////////////////////////////////
+ dateEntry->setRepeatFrequency(recur->frequency());
+ if (recur->duration() == 0) {
+ struct tm end = writeTm(recur->endDate());
+ dateEntry->setRepeatEnd(end);
+ } else if (recur->duration() < 0) {
+ dateEntry->setRepeatForever();
+ } else {
+ dateEntry->setRepeatEnd(repeatUntil(incidence->dtStart(),recur->frequency(),
+ recur->duration(),period));
+ }
+}
-struct tm VCalConduit::getEndTime(VObject *vevent) {
+struct tm VCalConduit::repeatUntil(const QDateTime &startDt,int rFreq,
+ int rDuration,PeriodConstants period)
+{
FUNCTIONSETUP;
-
- struct tm end;
- VObject *vo = isAPropertyOf(vevent, VCDTendProp);
- if (vo) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- end = ISOToTm(QString(s));
- deleteStr(s);
- } else
- memset(&end, 0, sizeof(end));
- return end;
-} // struct tm VCalConduit::getEndTime(const VObject *vevent)
-
-
-//////////////////////////////////////////////////////////////////////////
-
-void VCalConduit::setStartEndTimes(PilotDateEntry *dateEntry,
- VObject *vevent) {
- FUNCTIONSETUP;
+ struct tm start = writeTm(startDt);
+ time_t end_time = mktime(&start);
+ struct tm rEnd = start;
- int timeless_event = 0;
- struct tm start, end;
-
- if (getDateProperty(&start, vevent, VCDTstartProp)) {
- if (start.tm_hour == 0 &&
- start.tm_min == 0 &&
- start.tm_sec == 0)
- timeless_event = 1; // the event floats
- dateEntry->setEventStart(start);
+ switch(period) {
+ case DailyPeriod:
+ case WeeklyPeriod:
+ // Calculate the end time by adding the right number of
+ // repeat periods.
+ end_time += rFreq * (rDuration-1) * (int) period;
+ return *localtime(&end_time);
+ case MonthlyByDayPeriod:
+ case MonthlyByPosPeriod:
+ rEnd.tm_mon += rFreq * (rDuration - 1);
+ rEnd.tm_year += rEnd.tm_mon / 12;
+ rEnd.tm_mon %= 12;
+ return rEnd;
+ case YearlyByDayPeriod:
+ rEnd.tm_year += rFreq * (rDuration - 1);
+ return rEnd;
+ default:
+ kdWarning(CONDUIT_AREA) << __FUNCTION__
+ << ": Unknown repeat period "
+ << (int) period
+ << endl;
+ return rEnd;
}
-
- dateEntry->setEvent(timeless_event);
-
- if (getDateProperty(&end, vevent, VCDTendProp))
- dateEntry->setEventEnd(end);
- else
- // if the event has no DTend, get it from start time.
- dateEntry->setEventEnd(start);
-} // void VCalConduit::setStartEndTimes(PilotDateEntry *dateEntry, const VObject *vevent)
+}
-//////////////////////////////////////////////////////////////////////////
+void VCalConduit::setStartEndTimes(PilotDateEntry *dateEntry,Event *vevent)
+{
+ dateEntry->setEvent(vevent->doesFloat());
+ struct tm start, end;
-void VCalConduit::setAlarms(PilotDateEntry *dateEntry, VObject
- *vevent) const {
- FUNCTIONSETUP;
+ start = writeTm(vevent->dtStart());
+ dateEntry->setEventStart(start);
+
+ end = writeTm(vevent->dtEnd());
+ dateEntry->setEventEnd(end);
+}
- // ALARM(s) //
- VObject *vo;
- if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) {
- VObject *a = 0L, *b = 0L;
- if ((a = isAPropertyOf(vo, VCRunTimeProp)) &&
- (b = isAPropertyOf(vevent, VCDTstartProp))) {
- dateEntry->setAlarm(1);
- QDate tmpDate;
- QTime tmpTime;
- int year, month, day, hour, minute, second;
-
- QString tmpStr = fakeCString(vObjectUStringZValue(a));
- year = tmpStr.left(4).toInt();
- month = tmpStr.mid(4,2).toInt();
- day = tmpStr.mid(6,2).toInt();
- hour = tmpStr.mid(9,2).toInt();
- minute = tmpStr.mid(11,2).toInt();
- second = tmpStr.mid(13,2).toInt();
- tmpDate.setYMD(year, month, day);
- tmpTime.setHMS(hour, minute, second);
-
- ASSERT(tmpDate.isValid());
- ASSERT(tmpTime.isValid());
- QDateTime tmpDT(tmpDate, tmpTime);
- // correct for GMT if string is in Zulu format
- if (tmpStr.right(1) == QString("Z"))
- tmpDT = tmpDT.addSecs(60 * fTimeZone);
-
- tmpStr = fakeCString(vObjectUStringZValue(b));
- year = tmpStr.left(4).toInt();
- month = tmpStr.mid(4,2).toInt();
- day = tmpStr.mid(6,2).toInt();
- hour = tmpStr.mid(9,2).toInt();
- minute = tmpStr.mid(11,2).toInt();
- second = tmpStr.mid(13,2).toInt();
- tmpDate.setYMD(year, month, day);
- tmpTime.setHMS(hour, minute, second);
-
- ASSERT(tmpDate.isValid());
- ASSERT(tmpTime.isValid());
- QDateTime tmpDT2(tmpDate, tmpTime);
- // correct for GMT if string is in Zulu format
- if (tmpStr.right(1) == QString("Z"))
- tmpDT2 = tmpDT2.addSecs(60*fTimeZone);
-
- int diffSecs = tmpDT.secsTo(tmpDT2);
- if (diffSecs > 60*60*24) {
- dateEntry->setAdvanceUnits(advDays);
- dateEntry->setAdvance((int) diffSecs/(60*60*24));
- } else if (diffSecs > 60*60) {
- dateEntry->setAdvanceUnits(advHours);
- dateEntry->setAdvance((int) diffSecs/(60*60));
- } else {
- dateEntry->setAdvanceUnits(advMinutes);
- dateEntry->setAdvance((int) diffSecs/60);
- }
- } else
- dateEntry->setAlarm(0);
- } else
+void VCalConduit::setAlarms(PilotDateEntry *dateEntry,Event *vevent)
+{
+ if (vevent->alarm()->repeatCount() == 0) {
dateEntry->setAlarm(0);
-} // void VCalConduit::setAlarms(PilotDateEntry *dateEntry, const VObject *vevent) const
+ } else {
+ dateEntry->setAlarm(1);
+ QDateTime startDt = vevent->dtStart();
+ QDateTime alarmDt = vevent->alarm()->time();
+
+ int diffSecs = startDt.secsTo(alarmDt);
+ if (diffSecs > 60*60*24) {
+ dateEntry->setAdvanceUnits(advDays);
+ dateEntry->setAdvance((int) diffSecs/(60*60*24));
+ } else if (diffSecs > 60*60) {
+ dateEntry->setAdvanceUnits(advHours);
+ dateEntry->setAdvance((int) diffSecs/(60*60));
+ } else {
+ dateEntry->setAdvanceUnits(advMinutes);
+ dateEntry->setAdvance((int) diffSecs/60);
+ }
+ }
+}
-//////////////////////////////////////////////////////////////////////////
/* put up the about / setup dialog. */
QWidget* VCalConduit::aboutAndSetup()
@@ -1270,28 +760,10 @@ QWidget* VCalConduit::aboutAndSetup()
return new VCalSetup();
}
-
-//////////////////////////////////////////////////////////////////////////
-
-void mimeError(char *s)
-{
- kdWarning(CONDUIT_AREA) << __FUNCTION__
- << ": "
- << s
- << endl;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-
-/* virtual */ void VCalConduit::doTest()
+void VCalConduit::doTest()
{
- FUNCTIONSETUP;
-
- registerMimeErrorHandler(mimeError);
- getCalendar(VCalSetup::VCalGroup);
- printVObject(stderr,calendar());
+ // TODO: dump calendar
}
Index: conduits/vcalconduit/vcal-conduit.h
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/vcal-conduit.h,v
retrieving revision 1.16
diff -u -3 -d -p -r1.16 vcal-conduit.h
--- conduits/vcalconduit/vcal-conduit.h 2001/06/05 22:58:40 1.16
+++ conduits/vcalconduit/vcal-conduit.h 2001/06/17 22:03:21
@@ -1,8 +1,8 @@
-/* vcal-conduit.c VCalendar Conduit
-**
+/* vcal-conduit.c VCalendar Conduit
**
** Copyright (C) 1998-2000 by Dan Pilone, Preston Brown, and
** Herwin Jan Steehouwer
+** Copyright (C) 2001 by Cornelius Schumacher
**
** A program to synchronize KOrganizer's date book with the Palm
** Pilot / KPilot. This program is part of KPilot.
@@ -34,132 +34,77 @@
#include <time.h>
-#ifndef _PILOT_DATEBOOK_H_
#include <pi-datebook.h>
-#endif
-#ifndef _KPILOT_VCALBASE_H
-#include "vcalBase.h"
-#endif
-
-#ifndef QBITARRAY_H
#include <qbitarray.h>
-#endif
+#include <event.h>
+
+#include "vcalBase.h"
+
class PilotRecord;
class PilotDateEntry;
-class VObject;
-
+
+using namespace KCal;
+
class VCalConduit : public VCalBaseConduit
{
-public:
- VCalConduit(BaseConduit::eConduitMode mode);
- virtual ~VCalConduit();
+ public:
+ VCalConduit(eConduitMode mode,DatabaseSource source);
+ virtual ~VCalConduit();
- virtual void doSync();
- virtual void doBackup();
- virtual QWidget* aboutAndSetup();
- virtual void doTest();
+ virtual void doSync();
+ virtual void doBackup();
+ virtual QWidget* aboutAndSetup();
+ virtual void doTest();
- virtual const char* dbInfo() { return "DatebookDB"; }
+ virtual const char* dbInfo() { return "DatebookDB"; }
-
-
-protected:
- void doLocalSync();
- void updateVObject(PilotRecord *rec);
-
-private:
- struct tm getStartTime(VObject *vevent);
- struct tm getEndTime(VObject *vevent);
- void setAlarms(PilotDateEntry *dateEntry, VObject
- *vevent) const;
- void firstSyncCopy(bool DeleteOnPilot);
-
- /** Copy the start and end times from @arg *vevent to @arg
- *dateEntry. */
- void setStartEndTimes(PilotDateEntry *dateEntry,
- VObject *vevent);
-
- static void setVcalStartEndTimes(VObject *vevent,
- const PilotDateEntry &dateEntry);
- static void setVcalAlarms(VObject *vevent,
- const PilotDateEntry &dateEntry);
- static void setVcalRecurrence(VObject *vevent,
- const PilotDateEntry &dateEntry);
- static void setVcalExceptions(VObject *vevent,
- const PilotDateEntry &dateEntry);
-
- struct eventRepetition {
- enum ::repeatTypes type;
- int freq;
- bool hasEndDate;
- struct tm startDate, endDate;
- int duration; // 0 means forever
- QBitArray weekdays;
- DayOfMonthType repeatDay; // for monthlyByPos
-
- eventRepetition() {
- type = ::repeatNone;
- weekdays = QBitArray(7);
- }
-
- eventRepetition(const eventRepetition &e) {
- type = e.type;
- freq = e.freq;
- hasEndDate = e.hasEndDate;
- startDate = e.startDate;
- endDate = e.endDate;
- duration = e.duration;
- weekdays = e.weekdays;
- repeatDay = e.repeatDay;
- }
- };
+ protected:
+ void doLocalSync();
+ void updateEvent(PilotRecord *rec);
- eventRepetition getRepetition(VObject *vevent);
- void setRepetition(PilotDateEntry *dateEntry,
- const eventRepetition &er);
+ private:
+ void setAlarms(PilotDateEntry *dateEntry, Event *vevent);
+ void firstSyncCopy(bool DeleteOnPilot);
+ /** Copy the start and end times from @arg *vevent to @arg
+ *dateEntry. */
+ void setStartEndTimes(PilotDateEntry *dateEntry,Event *vevent);
+ void setRepetition(PilotDateEntry *dateEntry,Incidence *incidence);
- /** Get the list of exceptions for a repeating event. The
- result is an array of struct tm and should be free()d
- after use. The number of exceptions is written to @arg
- *n. */
- struct tm *getExceptionDates(VObject *vevent, int *n);
+ void setVcalStartEndTimes(Event *vevent,const PilotDateEntry &dateEntry);
+ void setVcalAlarms(Incidence *vevent,const PilotDateEntry &dateEntry);
+ void setVcalRecurrence(Incidence *vevent,const PilotDateEntry &dateEntry);
+ void setVcalExceptions(Incidence *vevent,const PilotDateEntry &dateEntry);
+ /** Get the list of exceptions for a repeating event. The
+ result is an array of struct tm and should be free()d
+ after use. The number of exceptions is written to @arg
+ *n. */
+ struct tm *getExceptionDates(Event *vevent, int *n);
- /**
- * Set the event to repeat forever, with repeat
- * frequency @arg rFreq. This function also
- * warns the user that this is probably not
- * *quite* the behavior intented but there's
- * no fix for that.
- */
- void repeatForever(PilotDateEntry *p,int rFreq,VObject *v=0L);
+ /**
+ * The following enums distinguish various repeat-by
+ * possiblities. Sometimes the specific value of the
+ * enum (like DailyPeriod) encodes something special,
+ * so these shouldn't be changed at whim without
+ * changing @ref repeatUntil as well.
+ */
- /**
- * The following enums distinguish various repeat-by
- * possiblities. Sometimes the specific value of the
- * enum (like DailyPeriod) encodes something special,
- * so these shouldn't be changed at whim without
- * changing @ref repeatUntil as well.
- */
- typedef enum { DailyPeriod=60*60*24, /* seconds per day */
- WeeklyPeriod=60*60*24*7, /* seconds per week */
- MonthlyByPosPeriod=1, /* just a constant */
- MonthlyByDayPeriod=2,
- YearlyByDayPeriod=3
- } PeriodConstants;
+ typedef enum { DailyPeriod=60*60*24, /* seconds per day */
+ WeeklyPeriod=60*60*24*7, /* seconds per week */
+ MonthlyByPosPeriod=1, /* just a constant */
+ MonthlyByDayPeriod=2,
+ YearlyByDayPeriod=3
+ } PeriodConstants;
- /**
- * Set the date entry to repeat every rFreq periods,
- * rDuration times, starting at start.
- *
- * This function contains code by Dag Nygren.
- */
- void repeatUntil(PilotDateEntry *dateEntry,
- const struct tm *start,
- int rFreq,
- int rDuration,
- PeriodConstants period);
+ /**
+ * Set the date entry to repeat every rFreq periods,
+ * rDuration times, starting at start.
+ *
+ * This function contains code by Dag Nygren.
+ */
+ struct tm repeatUntil(const QDateTime &startDt,int rFreq,int rDuration,
+ PeriodConstants period);
};
#endif
Index: conduits/vcalconduit/vcal-setup.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/vcal-setup.cc,v
retrieving revision 1.14
diff -u -3 -d -p -r1.14 vcal-setup.cc
--- conduits/vcalconduit/vcal-setup.cc 2001/06/05 22:58:40 1.14
+++ conduits/vcalconduit/vcal-setup.cc 2001/06/17 22:03:21
@@ -28,77 +28,35 @@
** Bug reports and questions can be sent to adridg@cs.kun.nl
*/
-
#include "options.h"
-#ifndef QDIR_H
#include <qdir.h>
-#endif
-
-#ifndef QLABEL_H
#include <qlabel.h>
-#endif
-
-#ifndef QPUSHBT_H
-#include <qpushbt.h>
-#endif
-
-#ifndef QDIALOG_H
+#include <qpushbutton.h>
#include <qdialog.h>
-#endif
-
-#ifndef QLINED_H
-#include <qlined.h>
-#endif
-
-#ifndef QCHKBOX_H
-#include <qchkbox.h>
-#endif
-
-#ifndef QLAYOUT_H
+#include <qlineedit.h>
+#include <qcheckbox.h>
#include <qlayout.h>
-#endif
-#ifndef _KAPP_H
#include <kapp.h>
-#endif
-
-#ifndef _KLOCALE_H
#include <klocale.h>
-#endif
-
-#ifndef _KDEBUG_H
#include <kdebug.h>
-#endif
-
-#ifndef _KFILEDIALOG_H
#include <kfiledialog.h>
-#endif
-#ifndef _KDEBUG_H
-#include <kdebug.h>
-#endif
-
-#ifndef _KPILOT_KPILOTCONFIG_H
#include "kpilotConfig.h"
-#endif
-
-#ifndef _KPILOT_VCAL_CONDUIT_H
#include "vcal-conduit.h"
-#endif
-
+#include "vcal-setup.h"
#include "vcal-setup.moc"
+const QString VCalSetup::VCalGroup("vcalOptions");
+
VCalSetupPage::VCalSetupPage(setupDialog *parent, KConfig& config) :
setupDialogPage(i18n("Calendar"),parent)
{
- FUNCTIONSETUP;
-
grid = new QGridLayout(this, 2, 4, SPACING);
- FileLabel =
- new QLabel(i18n("Calendar File:"), this);
+ FileLabel = new QLabel(i18n("Calendar File:"), this);
fCalendarFile = new QLineEdit(this);
fCalendarFile->setText(config.readEntry("CalFile", ""));
@@ -138,11 +96,8 @@ VCalSetupPage::~VCalSetupPage()
delete grid;
}
-
int VCalSetupPage::commitChanges(KConfig& config)
{
- FUNCTIONSETUP;
-
config.writeEntry("CalFile", fCalendarFile->text());
config.writeEntry("FirstTime",
fPromptFirstTime->isChecked() ? "true" : "false");
@@ -151,35 +106,28 @@ int VCalSetupPage::commitChanges(KConfig
return 0;
}
-
-
void VCalSetupPage::slotBrowse()
{
- FUNCTIONSETUP;
-
- QString fileName = KFileDialog::getOpenFileName(0L, "*.vcs");
- if(fileName.isNull()) return;
- fCalendarFile->setText(fileName);
+ QString fileName = KFileDialog::getOpenFileName(0L, "*.vcs *.ics");
+ if(fileName.isNull()) return;
+ fCalendarFile->setText(fileName);
}
-
-/* static */ const QString VCalSetup::VCalGroup("vcalOptions");
-
VCalSetup::VCalSetup(QWidget *parent) :
setupDialog(parent, VCalGroup)
{
- FUNCTIONSETUP;
- KConfig& config = KPilotConfig::getConfig(VCalGroup);
- sPage = new VCalSetupPage(this, config);
- if (sPage) addPage(sPage);
- iPage = new setupInfoPage(this);
- if (iPage) addPage(iPage);
+ KConfig& config = KPilotConfig::getConfig(VCalGroup);
+ sPage = new VCalSetupPage(this, config);
+ if (sPage) addPage(sPage);
+ iPage = new setupInfoPage(this);
+ if (iPage) addPage(iPage);
- setupDialog::setupWidget();
+ setupDialog::setupWidget();
}
-VCalSetup::~VCalSetup() {
+VCalSetup::~VCalSetup()
+{
delete sPage;
delete iPage;
}
Index: conduits/vcalconduit/vcalBase.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/vcalBase.cc,v
retrieving revision 1.8
diff -u -3 -d -p -r1.8 vcalBase.cc
--- conduits/vcalconduit/vcalBase.cc 2001/06/05 22:58:40 1.8
+++ conduits/vcalconduit/vcalBase.cc 2001/06/17 22:03:21
@@ -1,8 +1,8 @@
-/* vcalBase.cc Program
+/* vcalBase.cc Base class for KOrganizer Conduits
**
-** Copyright (C) 2001 by Adriaan de Groot
+** Copyright (C) 2001 by Adriaan de Groot, Cornelius Schumacher
**
-** Program description
+** This is the base class for the todo and datebook conduits
*/
/*
@@ -22,63 +22,36 @@
** MA 02139, USA.
*/
-/*
-** Bug reports and questions can be sent to adridg@cs.kun.nl
-*/
-
-
#include <cstdlib>
-#ifndef _KPILOT_OPTIONS_H
#include "options.h"
-#endif
-#ifndef QFILE_H
#include <qfile.h>
-#endif
-
-#ifndef QDATETIME_H
#include <qdatetime.h>
-#endif
-#ifndef _KMESSAGEBOX_H_
-#include "kmessagebox.h"
-#endif
+#include <kmessagebox.h>
+#include <kdebug.h>
-#ifndef _KPILOT_KPILOTCONFIG_H
-#include "kpilotConfig.h"
-#endif
+#include <calendarlocal.h>
+#include <icalformat.h>
-#ifndef _KDEBUG_H_
-#include <kdebug.h>
-#endif
+#include "kpilotConfig.h"
-#ifndef _VCAL_VCALBASE_H
#include "vcalBase.h"
-#endif
-VCalBaseConduit::VCalBaseConduit(BaseConduit::eConduitMode mode) :
- BaseConduit(mode),
- fTimeZone(0),
- calName(), // That's QString::null
- fCalendar(0)
+
+VCalBaseConduit::VCalBaseConduit(BaseConduit::eConduitMode mode,
+ BaseConduit::DatabaseSource source) :
+ BaseConduit(mode,source),
+ fTimeZone(0),
+ calName(), // That's QString::null
+ fCalendar(0)
{
- FUNCTIONSETUP;
-
- fCalendar = 0L;
}
-/* virtual */ VCalBaseConduit::~VCalBaseConduit()
+VCalBaseConduit::~VCalBaseConduit()
{
- FUNCTIONSETUP;
-
- if (fCalendar)
- {
- cleanVObject(fCalendar);
- cleanStrTbl();
- }
-
- fCalendar=0L;
+ delete fCalendar;
}
bool VCalBaseConduit::getCalendar(const QString &group)
@@ -104,9 +77,9 @@ bool VCalBaseConduit::getCalendar(const
QCString s = QFile::encodeName(calName);
- fCalendar = Parse_MIME_FromFileName((const char*)s);
+ fCalendar = new CalendarLocal();
- if(fCalendar == 0L) {
+ if(!fCalendar->load(s)) {
kdError(CONDUIT_AREA) << __FUNCTION__
<< ": Couldn't open "
<< calName
@@ -117,7 +90,7 @@ bool VCalBaseConduit::getCalendar(const
DEBUGCONDUIT << fname
<< ": Got calendar!"
<< endl;
- fTimeZone = getCalendarTimeZone(fCalendar);
+ fTimeZone = fCalendar->getTimeZone();
return true;
}
}
@@ -125,527 +98,76 @@ bool VCalBaseConduit::getCalendar(const
void VCalBaseConduit::saveVCal()
{
- FUNCTIONSETUP;
-
if (fCalendar) {
- QCString filename(QFile::encodeName(calName));
- writeVObjectToFile(const_cast<char *>((const char *) filename),
- fCalendar);
+ ICalFormat *format = new ICalFormat(fCalendar);
+ fCalendar->save(QFile::encodeName(calName),format);
}
fFirstTime = false;
}
-
void VCalBaseConduit::noCalendarError(const QString &conduitName)
{
- QString message = i18n(
- "The %1 could not open the file `%2'. "
- "Please configure the conduit with the correct "
- "filename and try again.")
- .arg(conduitName)
- .arg(calName);
-
- KMessageBox::error(0, message,
- i18n("%1 Fatal Error").arg(conduitName));
-}
-
-void VCalBaseConduit::setSummary(VObject *vevent,const char *summary)
-{
- FUNCTIONSETUP;
-
- VObject *vo = isAPropertyOf(vevent, VCSummaryProp);
- QString qsummary (summary);
- qsummary = qsummary.simplifyWhiteSpace();
- if (qsummary.isEmpty())
- {
- // We should probably update (empty) the
- // summary in the VObject if there
- // is one.
- // +++
- }
- else
- {
- if (vo)
- {
- setVObjectUStringZValue_(vo,
- fakeUnicode(qsummary.utf8(),0));
- }
- else
- {
- addPropValue(vevent, VCSummaryProp,
- qsummary.utf8());
- }
- }
-}
-
-void VCalBaseConduit::setNote(VObject *vevent,const char *s)
-{
- FUNCTIONSETUP;
-
- VObject *vo = isAPropertyOf(vevent, VCDescriptionProp);
+ QString message = i18n(
+ "The %1 could not open the file `%2'. "
+ "Please configure the conduit with the correct "
+ "filename and try again.")
+ .arg(conduitName)
+ .arg(calName);
- if (s) {
- if (*s) {
- QString qnote (s);
-
- // There is a note for this event
- //
- //
- if (vo)
- {
- setVObjectUStringZValue_(vo,
- fakeUnicode(qnote.utf8(),0));
- }
- else
- {
- vo = addPropValue(vevent, VCDescriptionProp,
- qnote.utf8());
- }
-
- // vo now certainly (?) points to the note property.
- //
- //
- if (!vo)
- {
- kdError() << __FUNCTION__
- << ": No object for note property."
- << endl;
- return;
- }
-
- if (strchr(s,'\n') &&
- !isAPropertyOf(vo, VCQuotedPrintableProp))
- {
- // Note takes more than one line so we need
- // to add the Quoted-Printable property
- //
- //
- addProp(vo,VCQuotedPrintableProp);
- }
- }
- else
- {
- // No note at all
- //
- //
- if (vo)
- {
- // So skip existing note
- //
- //
- addProp(vo,KPilotSkipProp);
- }
- }
- }
-}
-
-
-int VCalBaseConduit::getCalendarTimeZone(VObject *cal) {
- FUNCTIONSETUP;
-
- VObject *vo = isAPropertyOf(cal, VCTimeZoneProp);
- if (!vo) return 0;
-
- bool neg = FALSE;
- int hours, minutes;
- char *s;
-
- QString tmpStr(s = fakeCString(vObjectUStringZValue(vo)));
- DEBUGCONDUIT << __FUNCTION__
- << ": Got time zone string '"
- << s << "'" << endl;
- deleteStr(s);
-
- if (tmpStr.left(1) == "-") neg = TRUE;
- if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+")
- tmpStr.remove(0, 1);
-
- hours = tmpStr.left(2).toInt();
- if (tmpStr.length() > 2)
- minutes = tmpStr.right(2).toInt();
- else
- minutes = 0;
-
- int timeZone = 60 * hours + minutes;
- if (neg) timeZone = -timeZone;
-
- DEBUGCONDUIT << __FUNCTION__ << ": Calculated TZ offset "
- << timeZone << endl;
-
- return timeZone;
-}
-
-
-/*
- * Given an pilot id, search the vCalendar for a matching vobject, and return
- * the pointer to that object. If not found, return NULL.
- */
-VObject* VCalBaseConduit::findEntryInCalendar(recordid_t id, const
- char *entryType)
-{
- FUNCTIONSETUP;
-
- if (fCalendar == 0)
- kdFatal() << __FUNCTION__ << ": fCalendar == 0" << endl;
-
- VObjectIterator i;
- VObject* entry = 0L;
- VObject* objectID;
-
- initPropIterator(&i, fCalendar);
-
- // go through all the vobjects in the vcal
- while (moreIteration(&i))
- {
- entry = nextVObject(&i);
- if (!entry)
- {
- kdWarning() << __FUNCTION__
- << ": nextVObject returned NULL!"
- << endl;
- break;
- }
-
- objectID = isAPropertyOf(entry, KPilotIdProp);
-
- if (objectID &&
- (strcmp(vObjectName(entry), entryType) == 0))
- {
- const char *s = fakeCString(
- vObjectUStringZValue(objectID));
- if (!s)
- {
- kdWarning() << __FUNCTION__
- << ": fakeCString returned NULL!"
- << endl;
- continue;
- }
-#if 0
- else
- {
- DEBUGCONDUIT << fname
- << ": Looking at object with id "
- << s
- << endl;
- }
-#endif
-
- if(strtoul(s, 0L, 0) == id)
- {
- return entry;
- }
- }
- }
- return 0L;
-}
-
-void VCalBaseConduit::setNumProperty(VObject *vevent,
- const char *propertyname,
- int num)
-{
- FUNCTIONSETUP;
-
- VObject *vo = isAPropertyOf(vevent,propertyname);
- QString s;
- s.setNum(num);
-
- if (vo)
- {
- setVObjectUStringZValue_(vo,fakeUnicode(s.latin1(),0));
- }
- else
- {
- addPropValue(vevent,propertyname,s.latin1());
- }
-}
-
-void VCalBaseConduit::setSecret(VObject *vevent,bool secret)
-{
- FUNCTIONSETUP;
-
- VObject *vo = isAPropertyOf(vevent, VCClassProp);
- const char *s = secret ? "PRIVATE" : "PUBLIC" ;
-
- if (vo)
- {
- setVObjectUStringZValue_(vo,fakeUnicode(s,0));
- }
- else
- {
- addPropValue(vevent,VCClassProp,s);
- }
-}
-
-#if 0
-void VCalBaseConduit::setStatus(VObject *vevent, int status)
-{
- FUNCTIONSETUP;
-
- VObject *vo = isAPropertyOf(vevent, KPilotStatusProp);
- char buffer[2+4*sizeof(int)]; // One byte produces at most 3 digits
- // in decimal, add some slack and
- // space for a -
-
- snprintf(buffer, 2 + 4 * sizeof(int), "%d", status);
-
- if (vo)
- {
-
- setVObjectUStringZValue_(vo,fakeUnicode(buffer,0));
- }
- else
- {
- addPropValue(vevent,KPilotStatusProp,buffer);
- }
-}
-#endif
-
-
-int VCalBaseConduit::getStatus(VObject *vevent) {
- FUNCTIONSETUP;
-
- int status = 2;
- ASSERT(vevent);
- VObject *vo = isAPropertyOf(vevent, KPilotStatusProp);
- if (vo) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- status = atoi(s);
- deleteStr(s);
- }
- return status;
-}
-
-
-recordid_t VCalBaseConduit::getRecordID(VObject *vevent) {
- FUNCTIONSETUP;
- recordid_t id;
- VObject *vo = isAPropertyOf(vevent, KPilotIdProp);
- if (vo) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- id = atoi(s);
- deleteStr(s);
- } else
- id = 0;
- return id;
-}
-
-
-bool VCalBaseConduit::getDateProperty(struct tm *t,
- VObject *vevent,
- const char *prop) {
- FUNCTIONSETUP;
-
- if (!t)
- kdFatal() << fname << ": t == 0" << endl;
-
- VObject *vo = isAPropertyOf(vevent, prop);
-
- if (vo) {
- char *s = fakeCString(vObjectUStringZValue(vo));
- struct tm t2 = ISOToTm(QString(s));
- memcpy(t, &t2, sizeof(struct tm));
- deleteStr(s);
- } else
- return false;
- return true;
-}
-
-
-void VCalBaseConduit::addDateProperty(VObject *vevent,
- const char *prop,
- const QDateTime& dt,
- bool truncateTime)
-{
- QString dateString = TmToISO(dt,truncateTime);
- addPropValue(vevent, prop, dateString.latin1());
-}
-
-void VCalBaseConduit::addDateProperty(VObject *vevent,
- const char *prop,
- const struct tm *t,
- bool truncateTime)
-{
- QString dateString = TmToISO(t,truncateTime);
- addPropValue(vevent, prop, dateString.latin1());
+ KMessageBox::error(0, message,i18n("%1 Fatal Error").arg(conduitName));
}
-void VCalBaseConduit::setDateProperty(VObject *vevent,
- const QDateTime& dt,
- bool truncateTime)
+void VCalBaseConduit::setSummary(Incidence *incidence,const char *summary)
{
- setVObjectUStringZValue_(vevent,
- fakeUnicode(TmToISO(dt,truncateTime).latin1(), 0));
+ incidence->setSummary(summary);
}
-void VCalBaseConduit::setDateProperty(VObject *vevent,
- const struct tm *p,
- bool truncateTime)
+void VCalBaseConduit::setNote(Incidence *incidence,const char *s)
{
- setVObjectUStringZValue_(vevent,
- fakeUnicode(TmToISO(p,truncateTime).latin1(), 0));
+ incidence->setDescription(s);
}
-
-QString VCalBaseConduit::TmToISO(const QDateTime &dt,
- bool truncateTime)
+void VCalBaseConduit::setSecret(Incidence *vevent,bool secret)
{
- FUNCTIONSETUP;
-
- QString dateString;
-
- if (truncateTime)
- {
- dateString.sprintf("%.4d%.2d%.2dT000000",
- dt.date().year(), dt.date().month(), dt.date().day());
- }
- else
- {
- dateString.sprintf("%.4d%.2d%.2dT%.2d%.2d%.2d",
- dt.date().year(), dt.date().month(), dt.date().day(),
- dt.time().hour(), dt.time().minute(), dt.time().second());
- }
-
- return dateString;
+ vevent->setSecrecy(secret ? Incidence::SecrecyPrivate :
+ Incidence::SecrecyPublic);
}
-
-QString VCalBaseConduit::TmToISO(const struct tm *tm,
- bool truncateTime)
+QDateTime VCalBaseConduit::readTm(const struct tm &t)
{
- QString dStr;
-
- if (truncateTime)
- {
- dStr.sprintf("%.4d%.2d%.2dT000000",
- 1900 + tm->tm_year,
- tm->tm_mon + 1,
- tm->tm_mday);
- }
- else
- {
- dStr.sprintf("%.4d%.2d%.2dT%.2d%.2d%.2d",
- 1900 + tm->tm_year,
- tm->tm_mon + 1,
- tm->tm_mday,
- tm->tm_hour,
- tm->tm_min,
- tm->tm_sec);
- }
-
- return dStr;
+ QDateTime dt;
+ dt.setDate(QDate(1900 + t.tm_year, t.tm_mon + 1, t.tm_mday));
+ dt.setTime(QTime(t.tm_hour, t.tm_min, t.tm_sec));
+ return dt;
}
-/* static */ struct tm VCalBaseConduit::ISOToTm(const QString &tStr,int timeZone)
+struct tm VCalBaseConduit::writeTm(const QDateTime &dt)
{
- struct tm tm;
-
- tm.tm_wday = 0; // unimplemented
- tm.tm_yday = 0; // unimplemented
- tm.tm_isdst = 0; // unimplemented
-
- sscanf(tStr.latin1(),"%04d%02d%02dT%02d%02d%02d",
- &tm.tm_year, &tm.tm_mon,
- &tm.tm_mday, &tm.tm_hour,
- &tm.tm_min, &tm.tm_sec);
+ struct tm t;
- // possibly correct for timeZone
- if (timeZone && (tStr.right(1) == "Z")) {
- QDateTime tmpDT;
- tmpDT.setDate(QDate(tm.tm_year, tm.tm_mon, tm.tm_mday));
- tmpDT.setTime(QTime(tm.tm_hour, tm.tm_min, tm.tm_sec));
- tmpDT = tmpDT.addSecs(60*timeZone); // correct from GMT
- tm.tm_year = tmpDT.date().year();
- tm.tm_mon = tmpDT.date().month();
- tm.tm_mday = tmpDT.date().day();
- tm.tm_hour = tmpDT.time().hour();
- tm.tm_min = tmpDT.time().minute();
- tm.tm_sec = tmpDT.time().second();
- }
+ t.tm_wday = 0; // unimplemented
+ t.tm_yday = 0; // unimplemented
+ t.tm_isdst = 0; // unimplemented
- // tm_year is only since 1900
- tm.tm_year -= 1900;
- // pilot month is 0-based.
- tm.tm_mon -= 1;
+ t.tm_year = dt.date().year() - 1900;
+ t.tm_mon = dt.date().month() - 1;
+ t.tm_mday = dt.date().day();
+ t.tm_hour = dt.time().hour();
+ t.tm_min = dt.time().minute();
+ t.tm_sec = dt.time().second();
- return tm;
+ return t;
}
-
-int VCalBaseConduit::numFromDay(const QString &day)
+void VCalBaseConduit::deleteRecord(PilotRecord *rec)
{
- if (day == "SU ") return 0;
- if (day == "MO ") return 1;
- if (day == "TU ") return 2;
- if (day == "WE ") return 3;
- if (day == "TH ") return 4;
- if (day == "FR ") return 5;
- if (day == "SA ") return 6;
-
- return -1; // something bad happened. :)
+ kdDebug() << "VCalBaseConduit::deleteRecord() not yet implemented" << endl;
}
-/*
- * The pilot record specified was deleted on the pilot. Remove
- * the corresponding vobject from the vCalendar.
- */
-void VCalBaseConduit::deleteVObject(PilotRecord *rec, const char *type)
+void VCalBaseConduit::deleteFromPilot(int entryType)
{
- VObject *delvo;
-
- delvo = findEntryInCalendar(rec->getID(), type);
- // if the entry was found, it is still in the vCalendar. We need to
- // set the Status flag to Deleted, so that KOrganizer will not load
- // it next time the vCalendar is read in. If it is not found, the
- // user has also deleted it already in the vCalendar, and we can
- // safely do nothing.
- if (delvo) {
- // we now use the additional 'KPilotSkip' property, instead of a special
- // value for KPilotStatusProp.
- addProp(delvo, KPilotSkipProp);
- }
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-
-
-QString VCalBaseConduit::getSummary(VObject *vevent) {
- FUNCTIONSETUP;
-
- QString s;
- VObject *vo = isAPropertyOf(vevent, VCSummaryProp);
- if (vo) {
- const char *s2 = fakeCString(vObjectUStringZValue(vo));
- s = QString::fromUtf8(s2);
- deleteStr(s2);
- }
- return s;
-} // QString VCalConduit::getSummary(const VObject *vevent)
-
-
-//////////////////////////////////////////////////////////////////////////
-
-
-QString VCalBaseConduit::getDescription(VObject *vevent) {
- // what we call description pilot puts as a separate note
- FUNCTIONSETUP;
- VObject *vo = isAPropertyOf(vevent, VCDescriptionProp);
- QString str;
- if (vo) {
- const char *s = fakeCString(vObjectUStringZValue(vo));
- str = QString::fromUtf8(s);
- deleteStr(s);
- }
- return str;
-} // QString VCalConduit::getDescription(const VObject *vevent)
-
-
-/////////////////////////////////////////////////////////////////////////
-
-
-void VCalBaseConduit::deleteFromPilot(const char *entryType) {
QValueList<recordid_t> deletedList;
/* Build a list of records in the pilot calendar that are not
@@ -655,7 +177,10 @@ void VCalBaseConduit::deleteFromPilot(co
PilotRecord *rec;
int index = 0;
while ((rec = readRecordByIndex(index++)) != 0) {
- if (!findEntryInCalendar(rec->getID(), entryType)) {
+ bool found = false;
+ if ((entryType == TypeTodo) && findTodo(rec->getID())) found = true;
+ if ((entryType == TypeEvent) && findEvent(rec->getID())) found = true;
+ if (!found) {
DEBUGCONDUIT << __FUNCTION__
<< ": record "
<< rec->getID()
@@ -666,6 +191,11 @@ void VCalBaseConduit::deleteFromPilot(co
}
delete rec;
}
+
+ // Disable deletion to prevent data loss in case of logs.
+ // Will be removed, when the todo and datebook conduits are thoroughly tested
+ // TODO: Reenable deleteFromPilot()
+ return;
// Now process the list of deleted records.
for (QValueList<recordid_t>::Iterator it = deletedList.begin();
@@ -688,6 +218,31 @@ void VCalBaseConduit::deleteFromPilot(co
}
}
+Todo *VCalBaseConduit::findTodo(recordid_t id)
+{
+ QList<Todo> todos = calendar()->getTodoList();
+
+ Todo *todo = todos.first();
+ while(todo) {
+ if (todo->pilotId() == id) return todo;
+ todo = todos.next();
+ }
+
+ return 0;
+}
+
+Event *VCalBaseConduit::findEvent(recordid_t id)
+{
+ QList<Event> events = calendar()->getAllEvents();
+
+ Event *event = events.first();
+ while(event) {
+ if (event->pilotId() == id) return event;
+ event = events.next();
+ }
+
+ return 0;
+}
// $Log: vcalBase.cc,v $
// Revision 1.8 2001/06/05 22:58:40 adridg
Index: conduits/vcalconduit/vcalBase.h
===================================================================
RCS file: /home/kde/kdepim/kpilot/conduits/vcalconduit/vcalBase.h,v
retrieving revision 1.7
diff -u -3 -d -p -r1.7 vcalBase.h
--- conduits/vcalconduit/vcalBase.h 2001/06/05 22:58:40 1.7
+++ conduits/vcalconduit/vcalBase.h 2001/06/17 22:03:22
@@ -1,8 +1,7 @@
-/* vcalBase.h Program
+/* vcalBase.h Base class for KOrganizer conduits
**
-** Copyright (C) 2001 by Adriaan de Groot
+** Copyright (C) 2001 by Adriaan de Groot, Cornelius Schumacher
**
-** Program description
*/
/*
@@ -21,164 +20,88 @@
** the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
** MA 02139, USA.
*/
-
-/*
-** Bug reports and questions can be sent to adridg@cs.kun.nl
-*/
-
#ifndef _VCAL_VCALBASE_H
#define _VCAL_VCALBASE_H
-class PilotRecord;
-//class VObject;
-class QDateTime;
+#include "calendar.h"
-#ifndef _KPILOT_BASECONDUIT_H
#include "baseConduit.h"
-#endif
-
-#ifndef __VCC_H__
-#include "vcc.h"
-#endif
-
-class VCalBaseConduit : public BaseConduit {
- public:
- VCalBaseConduit(BaseConduit::eConduitMode mode);
- virtual ~VCalBaseConduit();
-
- virtual void doSync() = 0;
- virtual void doBackup() = 0;
- virtual QWidget *aboutAndSetup() = 0;
- virtual const char *dbInfo() = 0;
-
-public:
- /**
- * There are a whole bunch of methods that set particular
- * properties on VObjects. Probably they don't belong here
- * but in versit.
- */
- static void setSummary(VObject *vevent,const char *note);
- static void setNote(VObject *vevent,const char *note);
- static void setSecret(VObject *vevent,bool secret);
- static void setStatus(VObject *vevent,int status)
- { setNumProperty(vevent, KPilotStatusProp, status); }
-
- /**
- * Find the summary string of vcalendar event @arg
- * vevent. Returns an empty string if none found.
- */
- static QString getSummary(VObject *vevent);
-
- /** Find the description string of vcalendar event @arg
- vevent. Returns an empty string if none found. */
- static QString getDescription(VObject *vevent);
- /** Check @arg *vevent for KPilotStatus property. Returns 0 or
- 1 if the property exists, 2 otherwise (i.e. 0 if the record
- is unmodified, non-zero if it is modified or new). */
- static int getStatus(VObject *vevent);
+class PilotRecord;
+class QDateTime;
- /** Add the date property @arg *prop to the vevent. This
- *adds* the property as a sub-VObject to the given VObject,
- so use this primarily when an object is created. The
- meaning of @arg truncateTime is explained below at
- TmToISO(). */
- static void addDateProperty(VObject *vevent,
- const char *prop,
- const struct tm *p,
- bool truncateTime=false);
- static void addDateProperty(VObject *vevent,
- const char *prop,
- const QDateTime& dt,
- bool truncateTime=false);
+using namespace KCal;
- /** If you already have a date property and you want to change
- it, use setDateProperty(). The meaning of @arg
- truncateTime is explained below at TmToISO(). */
- static void setDateProperty(VObject *vevent,
- const struct tm *p,
- bool truncateTime=false);
- static void setDateProperty(VObject *vevent,
- const QDateTime &dt,
- bool truncateTime=false);
+class VCalBaseConduit : public BaseConduit {
+ public:
+ VCalBaseConduit(BaseConduit::eConduitMode mode,
+ DatabaseSource source=ConduitSocket);
+ virtual ~VCalBaseConduit();
- /** General set and reset function for numeric properties. */
- static void setNumProperty(VObject *vevent,
- const char *property,
- int num);
+ virtual void doSync() = 0;
+ virtual void doBackup() = 0;
+ virtual QWidget *aboutAndSetup() = 0;
+ virtual const char *dbInfo() = 0;
- /* More *static* utility functions. Setting truncateTime to
- true discards the time part and sets the time in the returned
- string to "000000". This indicates a floating event in
- vCal. */
- static QString TmToISO(const QDateTime&,
- bool truncateTime=false);
- static QString TmToISO(const struct tm *tm,
- bool truncateTime=false);
- static QString TmToISO(const struct tm &tm,
- bool truncateTime=false) { return TmToISO(&tm,truncateTime); }
- static struct tm ISOToTm(const QString &tStr,int timeZone);
- static int numFromDay(const QString &day);
- static QDateTime tmToQDateTime(const struct tm &t) {
- return QDateTime(QDate(1900 + t.tm_year, t.tm_mon + 1,
- t.tm_mday),
- QTime(t.tm_hour, t.tm_min, t.tm_sec)); }
+ /**
+ * There are a whole bunch of methods that set particular
+ * properties on Incidences. Probably they don't belong here
+ * but in versit.
+ */
+ static void setSummary(Incidence *vevent,const char *note);
+ static void setNote(Incidence *vevent,const char *note);
+ static void setSecret(Incidence *vevent,bool secret);
+ /**
+ * Find the summary string of vcalendar event @arg
+ * vevent. Returns an empty string if none found.
+ */
+ static QString getSummary(Incidence *vevent);
- // Inline non-static methods for the above.
- struct tm ISOToTm(const QString &tStr)
- { return ISOToTm(tStr,fTimeZone); } ;
+ /** Find the description string of vcalendar event @arg
+ vevent. Returns an empty string if none found. */
+ static QString getDescription(Incidence *vevent);
- /** Read the value of the KPilotID field of vcalendar record
- * @arg *vevent. Returns 0 if no ID found. */
- static recordid_t getRecordID(VObject *vevent);
+ /** Check @arg *vevent for KPilotStatus property. Returns 0 or
+ 1 if the property exists, 2 otherwise (i.e. 0 if the record
+ is unmodified, non-zero if it is modified or new). */
+ static int getStatus(Incidence *vevent);
+ QDateTime readTm(const struct tm &);
+ struct tm writeTm(const QDateTime &);
- static int getCalendarTimeZone(VObject *vevent);
-
-protected:
- /** Copy the value of a Date/Time property of @arg *vevent to
- @arg *t. Returns true if successful, false if the
- requested property was not found. */
- bool getDateProperty(struct tm *t,
- VObject *vevent,
- const char *prop);
+ protected:
+ void saveVCal();
- PilotRecord *findEntryInDB(recordid_t id);
- VObject *findEntryInCalendar(recordid_t id,
- const char *entryType);
- void deleteVObject(PilotRecord *rec, const char *type);
- void saveVCal();
+ // Deletes a record from the desktop calendar
+ void deleteRecord(PilotRecord *rec);
- bool getCalendar(const QString& group);
- void noCalendarError(const QString& conduitName);
+ bool getCalendar(const QString& group);
+ void noCalendarError(const QString& conduitName);
- /**
- * Retrieve the time zone set in the vcal file.
- * Returns number of minutes relative to UTC.
- */
- int getTimeZone() const;
- bool firstTime() const { return fFirstTime; } ;
+ bool firstTime() const { return fFirstTime; } ;
- /** Time zone offset to GMT in minutes. Set by
- getCalendar(). */
- int fTimeZone;
- QString calName;
+ /** Time zone offset to GMT in minutes. Set by
+ getCalendar(). */
+ int fTimeZone;
+
+ QString calName;
- VObject *calendar() { return fCalendar; } ;
+ Calendar *calendar() { return fCalendar; }
- /** Delete all records from the pilot that are not in the
- vcalendar. Meant to be run at the end of a hot-sync, after
- all new records from both sides have been inserted on the
- other. @arg entryType should be VCTodoProp or
- VCEventProp. */
- void deleteFromPilot(const char *entryType);
+ enum { TypeTodo, TypeEvent };
+ /** Delete all records from the pilot that are not in the
+ vcalendar. Meant to be run at the end of a hot-sync, after
+ all new records from both sides have been inserted on the
+ other. @arg entryType should be TypeTodo or TypeEvent */
+ void deleteFromPilot(int);
-private:
- VObject *fCalendar;
- bool fFirstTime;
-} ;
+ Todo *findTodo(recordid_t id);
+ Event *findEvent(recordid_t id);
-#else
-#warning "File doubly included."
+ private:
+ Calendar *fCalendar;
+ bool fFirstTime;
+};
+
#endif
Index: kpilot/conduitApp.cc
===================================================================
RCS file: /home/kde/kdepim/kpilot/kpilot/conduitApp.cc,v
retrieving revision 1.28
diff -u -3 -d -p -r1.28 conduitApp.cc
--- kpilot/conduitApp.cc 2001/05/25 16:06:52 1.28
+++ kpilot/conduitApp.cc 2001/06/17 22:03:23
@@ -357,7 +357,7 @@ int ConduitApp::exec(bool withDCOP,bool
switch(fMode)
{
case BaseConduit::DBInfo :
- cout << fConduit->dbInfo();
+ cout << fConduit->dbInfo() << endl;
keepRunning=false;
break;
case BaseConduit::Setup :
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic