Hello community,
here is the log from the commit of package libopensync-plugin-google-calendar
checked in at Fri Aug 3 15:05:28 CEST 2007.
--------
--- libopensync-plugin-google-calendar/libopensync-plugin-google-calendar.changes 2007-03-29 20:30:31.000000000 +0200
+++ /mounts/work_src_done/STABLE/libopensync-plugin-google-calendar/libopensync-plugin-google-calendar.changes 2007-08-02 15:44:07.000000000 +0200
@@ -1,0 +2,6 @@
+Thu Aug 2 15:43:51 CEST 2007 - cstender@suse.de
+
+- updated to version 0.32
+ o ported to the new OpenSync 0.3x API
+
+-------------------------------------------------------------------
Old:
----
libopensync-plugin-google-calendar-0.22.tar.bz2
New:
----
libopensync-plugin-google-calendar-0.32.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libopensync-plugin-google-calendar.spec ++++++
--- /var/tmp/diff_new_pack.S20600/_old 2007-08-03 15:04:20.000000000 +0200
+++ /var/tmp/diff_new_pack.S20600/_new 2007-08-03 15:04:20.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package libopensync-plugin-google-calendar (Version 0.22)
+# spec file for package libopensync-plugin-google-calendar (Version 0.32)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
@@ -13,15 +13,15 @@
Name: libopensync-plugin-google-calendar
BuildRequires: libopensync-devel python-httplib2
URL: http://www.opensync.org
-Version: 0.22
+Version: 0.32
Release: 1
Summary: Google Calendar Synchronization Plug-In for OpenSync
-License: GNU General Public License (GPL)
+License: GPL v2 or later
Group: Productivity/Other
Autoreqprov: on
Source: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-Requires: python-httplib2 pyxml
+Requires: python-httplib2 pyxml libopensync1 >= 0.32
%define prefix /usr
%description
@@ -67,6 +67,9 @@
%{_libdir}/opensync/google-cal-helper
%changelog
+* Thu Aug 02 2007 - cstender@suse.de
+- updated to version 0.32
+ o ported to the new OpenSync 0.3x API
* Thu Mar 29 2007 - cstender@suse.de
- bumped up version to 0.22
* Tue Nov 14 2006 - dgollub@suse.de
++++++ libopensync-plugin-google-calendar-0.22.tar.bz2 -> libopensync-plugin-google-calendar-0.32.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-google-calendar-0.22/configure.ac new/libopensync-plugin-google-calendar-0.32/configure.ac
--- old/libopensync-plugin-google-calendar-0.22/configure.ac 2007-03-25 18:17:30.000000000 +0200
+++ new/libopensync-plugin-google-calendar-0.32/configure.ac 2007-08-02 12:21:29.000000000 +0200
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.58)
-AC_INIT([OpenSync Google Calendar Plugin], 0.22, [], [libopensync-plugin-google-calendar])
+AC_INIT([OpenSync Google Calendar Plugin], 0.32, [], [libopensync-plugin-google-calendar])
AM_INIT_AUTOMAKE(foreign)
AC_CONFIG_SRCDIR(src/gcalendar.c)
AM_CONFIG_HEADER(config.h)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-google-calendar-0.22/src/gcalendar.c new/libopensync-plugin-google-calendar-0.32/src/gcalendar.c
--- old/libopensync-plugin-google-calendar-0.22/src/gcalendar.c 2006-10-15 20:59:49.000000000 +0200
+++ new/libopensync-plugin-google-calendar-0.32/src/gcalendar.c 2007-07-21 11:21:17.000000000 +0200
@@ -20,7 +20,12 @@
*/
#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
@@ -38,10 +43,28 @@
char *url;
char *username;
char *password;
- OSyncMember *member;
OSyncHashTable *hashtable;
+ OSyncObjTypeSink *sink;
+ OSyncObjFormat *objformat;
};
+static void free_plg(struct gc_plgdata *plgdata)
+{
+ if (plgdata->url)
+ xmlFree(plgdata->url);
+ if (plgdata->username)
+ xmlFree(plgdata->username);
+ if (plgdata->password)
+ xmlFree(plgdata->password);
+ if (plgdata->hashtable)
+ osync_hashtable_free(plgdata->hashtable);
+ if (plgdata->sink)
+ osync_objtype_sink_unref(plgdata->sink);
+ if (plgdata->objformat)
+ osync_objformat_unref(plgdata->objformat);
+ g_free(plgdata);
+}
+
/** Run gchelper and return the file descriptors for its stdin/stdout
*
*/
@@ -161,13 +184,13 @@
return NULL;
}
-osync_bool gc_parse_config(struct gc_plgdata *plgdata, char *cfg, int cfgsize, OSyncError **error)
+osync_bool gc_parse_config(struct gc_plgdata *plgdata, const char *cfg, OSyncError **error)
{
xmlNode *node;
xmlDoc *doc;
osync_bool ret = FALSE;
- doc = xmlParseMemory(cfg, cfgsize);
+ doc = xmlParseMemory(cfg, strlen(cfg) + 1);
if (!doc) {
osync_error_set(error, OSYNC_ERROR_GENERIC, "Couldn't parse configuration");
goto out;
@@ -208,55 +231,35 @@
goto out_freedoc;
}
-static void *gc_initialize(OSyncMember *member, OSyncError **error)
+static void gc_connect(void *data, OSyncPluginInfo *info, OSyncContext *ctx)
{
- struct gc_plgdata *plgdata = NULL;
- char *cfg;
- int cfgsize;
-
- if (!osync_member_get_config(member, &cfg, &cfgsize, error)) {
- osync_error_update(error, "Unable to get config data: %s", osync_error_print(error));
- goto out;
- }
-
- plgdata = osync_try_malloc0(sizeof(struct gc_plgdata), error);
- if (!plgdata)
- goto out_freecfg;
-
- if (!gc_parse_config(plgdata, cfg, cfgsize, error))
- goto error_freedata;
-
- plgdata->member = member;
- plgdata->hashtable = osync_hashtable_new();
-
-out_freecfg:
- g_free(cfg);
-out:
- return plgdata;
+ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx);
+ struct gc_plgdata *plgdata = data;
+ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info);
+ OSyncError *error = NULL;
-error_freedata:
- g_free(plgdata);
- plgdata = NULL;
- goto out_freecfg;
-}
+ char *tablepath = g_strdup_printf("%s/hashtable.db", osync_plugin_info_get_configdir(info));
-static void gc_connect(OSyncContext *ctx)
-{
- struct gc_plgdata *plgdata = (struct gc_plgdata*)osync_context_get_plugin_data(ctx);
+ plgdata->hashtable = osync_hashtable_new(tablepath, osync_objtype_sink_get_name(sink), &error);
+ g_free(tablepath);
- OSyncError *error = NULL;
- if (!osync_hashtable_load(plgdata->hashtable, plgdata->member, &error)) {
+ if (!plgdata->hashtable) {
osync_context_report_osyncerror(ctx, &error);
return;
}
osync_context_report_success(ctx);
+
+ osync_trace(TRACE_EXIT, "%s", __func__);
}
-static void gc_get_changeinfo(OSyncContext *ctx)
+static void gc_get_changes(void *data, OSyncPluginInfo *info, OSyncContext *ctx)
{
- struct gc_plgdata *plgdata = (struct gc_plgdata*)osync_context_get_plugin_data(ctx);
+ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx);
+
+ struct gc_plgdata *plgdata = data;
+ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info);
OSyncError *error = NULL;
int output;
@@ -265,8 +268,8 @@
char sizeline[1024];
int status;
- if (osync_member_get_slow_sync(plgdata->member, "event")) {
- osync_hashtable_set_slow_sync(plgdata->hashtable, "event");
+ if (osync_objtype_sink_get_slowsync(sink)) {
+ osync_hashtable_reset(plgdata->hashtable);
}
if (!run_helper(plgdata, "get_all", NULL,
@@ -277,7 +280,7 @@
out = fdopen(output, "r");
if (!out) {
- osync_context_report_error(ctx, OSYNC_ERROR_GENERIC,"Couldn't open helper output");
+ osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't open helper output");
close(output);
goto error_fdopen;
}
@@ -311,59 +314,75 @@
if (fread(xmldata, size, 1, out) < 1) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Error reading xml data from helper");
- goto error_readxml;
-
+ goto error_xml;
}
if (fread(uid, uidsize, 1, out) < 1) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Error reading xml data from helper");
- goto error_readxml;
+ goto error_xml;
}
uid[uidsize] = '\0';
if (fread(hash, hashsize, 1, out) < 1) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Error reading xml data from helper");
- goto error_readxml;
+ goto error_xml;
}
hash[hashsize] = '\0';
- xmlDoc *doc = xmlParseMemory(xmldata, size);
+ OSyncXMLFormat *doc = osync_xmlformat_parse(xmldata, size, &error);
if (!doc) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Invalid XML data from helper");
- goto error_invalidxml;
+ osync_error_unref(&error);
+ goto error_xml;
}
+ /* osync_merge_merge() seems to like its input sorted... */
+ osync_xmlformat_sort(doc);
- OSyncChange *chg = osync_change_new();
+ OSyncData *odata = osync_data_new((char *)doc, osync_xmlformat_size(), plgdata->objformat, &error);
+ if (!odata) {
+ osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "No memory");
+ osync_error_unref(&error);
+ /* osync_data_new() does not increase the reference count of
+ its 'data' member, but osync_data_unref() will decrease it,
+ so this is the only case where 'doc' has to be unreferenced
+ manually */
+ osync_xmlformat_unref(doc);
+ goto error_xml;
+ }
+
+ OSyncChange *chg = osync_change_new(&error);
if (!chg) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "No memory");
+ osync_error_unref(&error);
goto error_chg;
}
osync_change_set_uid(chg, uid);
- osync_change_set_member(chg, plgdata->member);
- osync_change_set_objtype_string(chg, "event");
- osync_change_set_objformat_string(chg, "xml-event");
- osync_change_set_data(chg, (char*)doc, sizeof(doc), 1);
-
+ osync_change_set_data(chg, odata);
+ osync_data_unref(odata);
+ osync_change_set_objtype(chg, osync_objtype_sink_get_name(sink));
osync_change_set_hash(chg, hash);
- if (osync_hashtable_detect_change(plgdata->hashtable, chg)) {
+
+ osync_change_set_changetype(chg, osync_hashtable_get_changetype(plgdata->hashtable, uid, hash));
+ osync_hashtable_report(plgdata->hashtable, uid);
+
+ if (osync_change_get_changetype(chg) != OSYNC_CHANGE_TYPE_UNMODIFIED) {
osync_context_report_change(ctx, chg);
- osync_hashtable_update_hash(plgdata->hashtable, chg);
+ osync_hashtable_update_hash(plgdata->hashtable, osync_change_get_changetype(chg), uid, hash);
}
- xmlFreeDoc(doc);
+ osync_change_unref(chg);
free(hash);
free(uid);
free(xmldata);
- /* end of loop */
- continue;
+ /* end of loop */
+ continue;
- /* error handling in the loop */
+ /* error handling in the loop */
error_chg:
- xmlFreeDoc(doc);
- error_invalidxml:
- error_readxml:
+ osync_data_unref(odata);
+ error_xml:
free(hash);
error_hash:
free(uid);
@@ -372,7 +391,31 @@
goto error_xmldata;
}
- osync_hashtable_report_deleted(plgdata->hashtable, ctx, "event");
+ char **uids = osync_hashtable_get_deleted(plgdata->hashtable);
+ int i;
+ for (i = 0; uids[i]; i++) {
+ OSyncChange *change = osync_change_new(&error);
+ if (!change) {
+ osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "ERROR is: %s", osync_error_print(&error));
+ goto error_fdopen;
+ }
+ OSyncData *data = osync_data_new(NULL, 0, plgdata->objformat, &error);
+ if (!data) {
+ osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "ERROR is: %s", osync_error_print(&error));
+ goto error_fdopen;
+ }
+ osync_data_set_objtype(data, "event");
+
+ osync_change_set_data(change, data);
+ osync_change_set_changetype(change, OSYNC_CHANGE_TYPE_DELETED);
+ osync_change_set_uid(change, uids[i]);
+ osync_context_report_change(ctx, change);
+ osync_hashtable_update_hash(plgdata->hashtable, OSYNC_CHANGE_TYPE_DELETED, uids[i], NULL);
+ osync_change_unref(change);
+ osync_data_unref(data);
+ g_free(uids[i]);
+ }
+ g_free(uids);
fclose(out);
waitpid(pid, &status, 0);
@@ -384,6 +427,7 @@
osync_context_report_success(ctx);
+ osync_trace(TRACE_EXIT, "%s", __func__);
return;
error_xmldata:
@@ -393,12 +437,17 @@
kill(pid, SIGTERM);
waitpid(pid, NULL, 0);
error:
+ osync_trace(TRACE_EXIT, "%s", __func__);
return;
}
-static osync_bool gc_commit_change(OSyncContext *ctx, OSyncChange *change)
+static void gc_commit_change(void *data, OSyncPluginInfo *info,
+ OSyncContext *ctx, OSyncChange *change)
{
- struct gc_plgdata *plgdata = (struct gc_plgdata*)osync_context_get_plugin_data(ctx);
+ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx, change);
+
+ OSyncObjTypeSink *sink = osync_plugin_info_get_sink(info);
+ struct gc_plgdata *plgdata = data;
pid_t pid;
int input, output;
@@ -408,21 +457,22 @@
FILE *out;
int status;
char sizeline[1024];
+ char *hash;
- osync_hashtable_get_hash(plgdata->hashtable, change);
+ hash = osync_hashtable_get_hash(plgdata->hashtable, osync_change_get_uid(change));
switch (osync_change_get_changetype(change)) {
- case CHANGE_ADDED:
+ case OSYNC_CHANGE_TYPE_ADDED:
cmd = "add";
arg = NULL;
break;
- case CHANGE_MODIFIED:
+ case OSYNC_CHANGE_TYPE_MODIFIED:
cmd = "edit";
- arg = osync_change_get_hash(change);
+ arg = hash;
break;
- case CHANGE_DELETED:
+ case OSYNC_CHANGE_TYPE_DELETED:
cmd = "delete";
- arg = osync_change_get_hash(change);
+ arg = hash;
break;
default:
osync_context_report_error(ctx, OSYNC_ERROR_NOT_SUPPORTED, "Unknown change type");
@@ -436,6 +486,8 @@
goto error;
}
+ g_free(hash);
+
out = fdopen(output, "r");
if (!out) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't open helper output");
@@ -444,23 +496,27 @@
}
switch (osync_change_get_changetype(change)) {
- case CHANGE_ADDED:
- case CHANGE_MODIFIED:
+ case OSYNC_CHANGE_TYPE_ADDED:
+ case OSYNC_CHANGE_TYPE_MODIFIED:
{
- xmlDoc *doc = (xmlDoc*)osync_change_get_data(change);
- xmlChar *data;
+ OSyncXMLFormat *doc = (OSyncXMLFormat *)osync_data_get_data_ptr(osync_change_get_data(change));
int size;
- int xmlsize, uidsize, hashsize;
- char *xmldata, *uid, *hash;
+ char *buffer;
- xmlDocDumpMemory(doc, &data, &size);
- if (write(input, data, size) < size) {
+ osync_xmlformat_assemble(doc, &buffer, &size);
+ osync_trace(TRACE_INTERNAL, "input to helper:\n%s", buffer);
+ if (write(input, buffer, size) < size) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't write data to helper");
close(input);
+ g_free(buffer);
goto error_write;
}
close(input);
+ g_free(buffer);
+
+ int xmlsize, uidsize, hashsize;
+ char *xmldata, *uid, *hash;
if (!fgets(sizeline, sizeof(sizeline), out)) {
osync_context_report_error(ctx, OSYNC_ERROR_GENERIC, "Couldn't read from helper");
@@ -530,14 +586,17 @@
break;
}
break;
- case CHANGE_DELETED:
+ case OSYNC_CHANGE_TYPE_DELETED:
close(input);
break;
default:
g_assert_not_reached();
}
- osync_hashtable_update_hash(plgdata->hashtable, change);
+ osync_hashtable_update_hash(plgdata->hashtable,
+ osync_change_get_changetype(change),
+ osync_change_get_uid(change),
+ osync_change_get_hash(change));
fclose(out);
@@ -550,7 +609,8 @@
osync_context_report_success(ctx);
- return TRUE;
+ osync_trace(TRACE_EXIT, "%s", __func__);
+ return;
error_read:
error_write:
@@ -559,44 +619,132 @@
kill(pid, SIGTERM);
waitpid(pid, NULL, 0);
error:
- return FALSE;
+ osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&error));
+ return;
}
-static void gc_disconnect(OSyncContext *ctx)
+static void gc_disconnect(void *data, OSyncPluginInfo *info, OSyncContext *ctx)
{
- struct gc_plgdata *plgdata = (struct gc_plgdata*)osync_context_get_plugin_data(ctx);
+ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, ctx);
+ struct gc_plgdata *plgdata = data;
- osync_hashtable_close(plgdata->hashtable);
+ osync_hashtable_free(plgdata->hashtable);
+ plgdata->hashtable = NULL;
osync_context_report_success(ctx);
+ osync_trace(TRACE_EXIT, "%s", __func__);
}
static void gc_finalize(void *data)
{
- struct gc_plgdata *plgdata = (struct gc_plgdata*)data;
+ osync_trace(TRACE_ENTRY, "%s(%p)", __func__, data);
+ struct gc_plgdata *plgdata = data;
- osync_hashtable_free(plgdata->hashtable);
- g_free(data);
+ free_plg(plgdata);
+ osync_trace(TRACE_EXIT, "%s", __func__);
}
-void get_info(OSyncEnv *env)
+static void *gc_initialize(OSyncPlugin *plugin,
+ OSyncPluginInfo *info,
+ OSyncError **error)
+{
+ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, plugin, info, error);
+ struct gc_plgdata *plgdata;
+ const char *cfg;
+
+ plgdata = osync_try_malloc0(sizeof(struct gc_plgdata), error);
+ if (!plgdata)
+ goto out;
+
+ cfg = osync_plugin_info_get_config(info);
+ if (!cfg) {
+ osync_error_set(error, OSYNC_ERROR_GENERIC,
+ "Unable to get config data.");
+ goto error_freeplg;
+ }
+
+ if (!gc_parse_config(plgdata, cfg, error))
+ goto error_freeplg;
+
+ OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info);
+ plgdata->objformat = osync_format_env_find_objformat(formatenv, "xmlformat-event");
+ if (!plgdata->objformat)
+ goto error_freeplg;
+ osync_objformat_ref(plgdata->objformat);
+
+ plgdata->sink = osync_objtype_sink_new("event", error);
+ if (!plgdata->sink)
+ goto error_freeplg;
+
+ osync_objtype_sink_add_objformat(plgdata->sink, "xmlformat-event");
+
+ OSyncObjTypeSinkFunctions functions;
+ memset(&functions, 0, sizeof(functions));
+ functions.connect = gc_connect;
+ functions.disconnect = gc_disconnect;
+ functions.get_changes = gc_get_changes;
+ functions.commit = gc_commit_change;
+
+ osync_objtype_sink_set_functions(plgdata->sink, functions, plgdata);
+ osync_plugin_info_add_objtype(info, plgdata->sink);
+
+ osync_trace(TRACE_EXIT, "%s", __func__);
+
+ return plgdata;
+
+error_freeplg:
+ free_plg(plgdata);
+out:
+ osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
+ return NULL;
+}
+
+static osync_bool gc_discover(void *data, OSyncPluginInfo *info, OSyncError **error)
+{
+ osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, error);
+
+ struct gc_plgdata *plgdata = data;
+
+ osync_objtype_sink_set_available(plgdata->sink, TRUE);
+
+ OSyncVersion *version = osync_version_new(error);
+ osync_version_set_plugin(version, "google-calendar");
+ osync_plugin_info_set_version(info, version);
+ osync_version_unref(version);
+
+ osync_trace(TRACE_EXIT, "%s", __func__);
+ return TRUE;
+}
+
+osync_bool get_sync_info(OSyncPluginEnv *env, OSyncError **error)
{
- OSyncPluginInfo *info = osync_plugin_new_info(env);
- info->version = 1;
- info->name = "google-calendar";
+ osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, env, error);
+ OSyncPlugin *plugin = osync_plugin_new(error);
+ if (!plugin)
+ goto error;
- info->longname = "Google Calendar";
- info->description = "Google Calendar plugin";
- info->config_type = NEEDS_CONFIGURATION;
+ osync_plugin_set_name(plugin, "google-calendar");
+ osync_plugin_set_longname(plugin, "Google Calendar");
+ osync_plugin_set_description(plugin, "Google Calendar plugin");
+ osync_plugin_set_config_type(plugin, OSYNC_PLUGIN_NEEDS_CONFIGURATION);
+
+ osync_plugin_set_initialize(plugin, gc_initialize);
+ osync_plugin_set_finalize(plugin, gc_finalize);
+ osync_plugin_set_discover(plugin, gc_discover);
- info->functions.initialize = gc_initialize;
- info->functions.connect = gc_connect;
- info->functions.disconnect = gc_disconnect;
- info->functions.finalize = gc_finalize;
- info->functions.get_changeinfo = gc_get_changeinfo;
+ osync_plugin_env_register_plugin(env, plugin);
+ osync_plugin_unref(plugin);
- osync_plugin_accept_objtype(info, "event");
- osync_plugin_accept_objformat(info, "event", "xml-event", NULL);
- osync_plugin_set_commit_objformat(info, "event", "xml-event", gc_commit_change);
- osync_plugin_set_access_objformat(info, "event", "xml-event", gc_commit_change);
+ osync_trace(TRACE_EXIT, "%s", __func__);
+ return TRUE;
+
+error:
+ osync_trace(TRACE_EXIT_ERROR, "Unable to register: %s", osync_error_print(error));
+ osync_error_unref(error);
+ return FALSE;
+}
+
+int get_version(void)
+{
+ return 1;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-google-calendar-0.22/src/google-calendar.xsd new/libopensync-plugin-google-calendar-0.32/src/google-calendar.xsd
--- old/libopensync-plugin-google-calendar-0.22/src/google-calendar.xsd 1970-01-01 01:00:00.000000000 +0100
+++ new/libopensync-plugin-google-calendar-0.32/src/google-calendar.xsd 2007-07-09 13:27:46.000000000 +0200
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+http://opensync.org/Schema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ http://opensync.org/Schema" schemaLocation="plugin_config.xsd"/>
+
+ xsd:complexContent
+
+ xsd:sequence
+ http://www.google.com/calendar/feeds/USER@gmail.com/private/full" name="url" type="os:String"/>
+
+
+
+
+
+
+
+ xsd:complexContent
+
+ xsd:sequence
+
+
+
+
+
+
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-google-calendar-0.22/src/google-cal-helper.py new/libopensync-plugin-google-calendar-0.32/src/google-cal-helper.py
--- old/libopensync-plugin-google-calendar-0.22/src/google-cal-helper.py 2006-11-05 20:21:27.000000000 +0100
+++ new/libopensync-plugin-google-calendar-0.32/src/google-cal-helper.py 2007-07-21 11:21:17.000000000 +0200
@@ -138,6 +138,41 @@
sys.stderr.write("xs to osync: %s => %s\n" % (s, r))
return r
+GDEND_RE = re.compile("DTEND;[^:]*:(\S+)")
+def gdRecurToEnd(recur):
+ m = GDEND_RE.search(recur)
+ if m is None:
+ raise DateConversionError("failed to find end in \"%s\"" % recur)
+ start = m.group(1)
+ year = start[0:4]
+ month = start[4:6]
+ day = start[6:8]
+ hour = start[9:11]
+ min = start[11:13]
+ sec = start[13:15]
+ return "%s-%2s-%2sT%2s:%2s:%2s" % (year, month, day, hour, min, sec)
+
+GDSTART_RE = re.compile("DTSTART;[^:]*:(\S+)")
+def gdRecurToStart(recur):
+ m = GDSTART_RE.search(recur)
+ if m is None:
+ raise DateConversionError("failed to find start in \"%s\"" % recur)
+ start = m.group(1)
+ year = start[0:4]
+ month = start[4:6]
+ day = start[6:8]
+ hour = start[9:11]
+ min = start[11:13]
+ sec = start[13:15]
+ return "%s-%2s-%2sT%2s:%2s:%2s" % (year, month, day, hour, min, sec)
+
+GDRECUR_RE = re.compile("RRULE:(\S+)")
+def gdRecurToORecur(recur):
+ m = GDRECUR_RE.search(recur)
+ if m is None:
+ raise DateConversionError("failed to find rule in \"%s\"" % recur)
+ return m.group(1)
+
class GCalRequestError(Exception):
def __init__(self, response):
self.response = response
@@ -159,49 +194,60 @@
self.id = self.elementValue('atom:id/text()')
self.editUri = self.elementValue('atom:link[@rel="edit"]/@href')
self.content = self.elementValue('atom:content[@type="text"]/text()')
- self.dtstart = self.elementValue('gd:when/@startTime')
- self.dtend = self.elementValue('gd:when/@endTime')
+ self.dtrecur = self.elementValue('gd:recurrence/text()')
+ if self.dtrecur:
+ pass
+ self.dtstart = gdRecurToStart(self.dtrecur)
+ self.dtend = gdRecurToEnd(self.dtrecur)
+ self.dtrecur = gdRecurToORecur(self.dtrecur)
+ else:
+ self.dtstart = self.elementValue('gd:when/@startTime')
+ self.dtend = self.elementValue('gd:when/@endTime')
self.eventStatus = self.elementValue('gd:eventStatus/@value')
self.whereString = self.elementValue('gd:where/@valueString')
- #FIXME: Handle recurrency
#FIXME: Handle gd:eventStatus
def parseOsync(self, element):
self.element = element
- self.title = self.elementValue('Event/Summary/Content/text()')
- self.content = self.elementValue('Event/Description/Content/text()')
+ self.title = self.elementValue('Summary/Content/text()')
+ self.content = self.elementValue('Description/Content/text()')
- dtstart = self.elementValue('Event/DateStarted/Content/text()')
+ dtstart = self.elementValue('DateStarted/Content/text()')
self.dtstart = osyncToXsdate(dtstart)
- dtend = self.elementValue('Event/DateEnd/Content/text()')
+ dtend = self.elementValue('DateEnd/Content/text()')
if not dtend:
dtend = dtstart
self.dtend = osyncToXsdate(dtend)
- self.whereString = self.elementValue('Event/Location/Content/text()')
+ self.whereString = self.elementValue('Location/Content/text()')
#TODO: UID, editUri, dtstart, dtend, recurrency, eventStatus
def dumpOsync(self):
di = md.getDOMImplementation()
- doc = di.createDocument(None, 'vcal', None)
- vcal = doc.documentElement
- event = self.addElement(doc, vcal, 'Event')
+ doc = di.createDocument(None, 'Event', None)
+ event = doc.documentElement
- self.addElementContent(doc, event, 'Summary', self.title)
- self.addElementContent(doc, event, 'Description', self.content)
+ if self.title:
+ self.addElementContent(doc, event, 'Summary', self.title)
+ if self.content:
+ self.addElementContent(doc, event, 'Description', self.content)
self.addElementContent(doc, event, 'DateStarted', xsdateToOsync(self.dtstart))
self.addElementContent(doc, event, 'DateEnd', xsdateToOsync(self.dtend))
- self.addElementContent(doc, event, 'Location', self.whereString)
+ if self.dtrecur:
+ self.addElementContent(doc, event, 'RecurrenceRule',
+ self.dtrecur)
+ if self.whereString:
+ self.addElementContent(doc, event, 'Location', self.whereString)
- #TODO: UID, editUri, dtstart, dtend, recurrency, eventStatus
+ #TODO: UID, editUri, dtstart, dtend, eventStatus
return doc.toxml(encoding='utf-8')
def dumpGdata(self):
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/libopensync-plugin-google-calendar-0.22/src/Makefile.am new/libopensync-plugin-google-calendar-0.32/src/Makefile.am
--- old/libopensync-plugin-google-calendar-0.22/src/Makefile.am 2007-02-11 20:30:32.000000000 +0100
+++ new/libopensync-plugin-google-calendar-0.32/src/Makefile.am 2007-07-21 11:21:17.000000000 +0200
@@ -19,7 +19,7 @@
gcalendar_la_SOURCES = gcalendar.c
gcalendar_la_CFLAGS = -DGCAL_HELPER=\"$(libexecdir)/google-cal-helper\"
gcalendar_la_LDFLAGS = -avoid-version -export-dynamic -module
-gcalendar_la_LIBADD = @PACKAGE_LIBS@ @LIBS@ -lopensync-xml
+gcalendar_la_LIBADD = @PACKAGE_LIBS@ @LIBS@
google-cal-helper: $(srcdir)/google-cal-helper.py
cp $(srcdir)/google-cal-helper.py google-cal-helper
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org