2 * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org>
3 * Copyright (C) 2008 Instituto Nokia de Tecnologia
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * @file gdata_format.c
23 * @author Adenilson Cavalcanti da Silva <adenilson.silva@indt.org.br>
24 * @date Wed Sep 3 12:33:08 2008
26 * @brief A google data (contacts/calendar events) format plugin.
28 * It seems to be requirement to make the whole thing work, yada, yada, yada. I'm taking
29 * as a base the mock_format.c/vformat-xmlformat.c files from opensync trunk and
30 * hoping for the best.
32 * - make the convertion (should be easy thanks to xslt_aux functions)
39 #include <opensync/opensync.h>
40 #include <opensync/opensync-xmlformat.h>
41 #include <opensync/opensync-format.h>
42 #include <opensync/opensync-time.h>
44 osync_bool
xmlcontact_to_gcontact(char *input
, unsigned int inpsize
,
45 char **output
, unsigned int *outpsize
,
46 osync_bool
*free_input
, const char *config
,
47 void *userdata
, OSyncError
**error
)
52 osync_bool
xmlevent_to_gevent(char *input
, unsigned int inpsize
,
53 char **output
, unsigned int *outpsize
,
54 osync_bool
*free_input
, const char *config
,
55 void *userdata
, OSyncError
**error
)
60 osync_bool
gcontact_to_xmlcontact(char *input
, unsigned int inpsize
,
61 char **output
, unsigned int *outpsize
,
62 osync_bool
*free_input
, const char *config
,
63 void *userdata
, OSyncError
**error
)
68 osync_bool
gevent_to_xmlevent(char *input
, unsigned int inpsize
,
69 char **output
, unsigned int *outpsize
,
70 osync_bool
*free_input
, const char *config
,
71 void *userdata
, OSyncError
**error
)
78 osync_bool
get_format_info(OSyncFormatEnv
*env
, OSyncError
**error
)
80 OSyncObjFormat
*gcont
= osync_objformat_new("google-contact", "contact", error
);
84 OSyncObjFormat
*gevent
= osync_objformat_new("google-event", "event", error
);
88 /* TODO: register (and write) auxiliary functions: compare/create/destroy/blah...*/
90 osync_format_env_register_objformat(env
, gcont
);
91 osync_objformat_unref(gcont
);
93 osync_format_env_register_objformat(env
, gevent
);
94 osync_objformat_unref(gevent
);
97 void *initialize(OSyncError
**error
)
99 /* TODO: create XSLT context */
104 void finalize(void *userdata
)
106 /* Cleanup XSLT context */
111 osync_bool
get_conversion_info(OSyncFormatEnv
*env
)
113 OSyncFormatConverter
*conv
= NULL
;
114 OSyncError
*error
= NULL
;
116 /* osync xml formats */
117 OSyncObjFormat
*xml_contact
= osync_format_env_find_objformat(env
, "xmlformat-contact");
118 OSyncObjFormat
*xml_event
= osync_format_env_find_objformat(env
, "xmlformat-event");
121 OSyncObjFormat
*gevent
= osync_format_env_find_objformat(env
, "google-event");
122 osync_assert(gevent
);
123 OSyncObjFormat
*gcontact
= osync_format_env_find_objformat(env
, "google-contact");
124 osync_assert(gcontact
);
126 /* from xmlformat to gdata */
127 conv
= osync_converter_new(OSYNC_CONVERTER_CONV
, xml_contact
, gcontact
,
128 xmlcontact_to_gcontact
, &error
);
130 osync_converter_set_initialize_func(conv
, initialize
);
131 osync_converter_set_finalize_func(conv
, finalize
);
132 osync_format_env_register_converter(env
, conv
);
133 osync_converter_unref(conv
);
135 conv
= osync_converter_new(OSYNC_CONVERTER_CONV
, xml_event
, gevent
,
136 xmlevent_to_gevent
, &error
);
138 osync_converter_set_initialize_func(conv
, initialize
);
139 osync_converter_set_finalize_func(conv
, finalize
);
140 osync_format_env_register_converter(env
, conv
);
141 osync_converter_unref(conv
);
143 /* from gdata to xmlformat */
144 conv
= osync_converter_new(OSYNC_CONVERTER_CONV
, gcontact
, xml_contact
,
145 gcontact_to_xmlcontact
, &error
);
147 osync_converter_set_initialize_func(conv
, initialize
);
148 osync_converter_set_finalize_func(conv
, finalize
);
149 osync_format_env_register_converter(env
, conv
);
150 osync_converter_unref(conv
);
152 conv
= osync_converter_new(OSYNC_CONVERTER_CONV
, gevent
, xml_event
,
153 gevent_to_xmlevent
, &error
);
155 osync_converter_set_initialize_func(conv
, initialize
);
156 osync_converter_set_finalize_func(conv
, finalize
);
158 osync_format_env_register_converter(env
, conv
);
159 osync_converter_unref(conv
);
164 int get_version(void)