Changeset 3637
- Timestamp:
- 09/05/08 06:27:32 (3 months ago)
- Location:
- plugins/evolution2/src
- Files:
-
- 1 removed
- 7 modified
-
evo2-sync (modified) (1 diff)
-
evo2-sync.xsd (deleted)
-
evolution2_ebook.c (modified) (3 diffs)
-
evolution2_ecal.c (modified) (3 diffs)
-
evolution2_etodo.c (modified) (3 diffs)
-
evolution2_memo.c (modified) (3 diffs)
-
evolution2_sync.c (modified) (9 diffs)
-
evolution2_sync.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/evolution2/src/evo2-sync
r2815 r3637 1 1 <?xml version="1.0"?> 2 <config> 3 <address_path>default</address_path> 4 <calendar_path>default</calendar_path> 5 <memos_path>default</memos_path> 6 <tasks_path>default</tasks_path> 2 <config version="1.0"> 3 <Resources> 4 <Resource> 5 <Enabled>1</Enabled> 6 <Formats> 7 <Format> 8 <Config>VCARD_EXTENSION=Evolution</Config> 9 <Name>vcard21</Name> 10 </Format> 11 <Format> 12 <Config>VCARD_EXTENSION=Evolution</Config> 13 <Name>vcard30</Name> 14 </Format> 15 </Formats> 16 <ObjType>contact</ObjType> 17 <Url>default</Url> 18 </Resource> 19 <Resource> 20 <Enabled>1</Enabled> 21 <Formats> 22 <Format> 23 <Name>vevent20</Name> 24 </Format> 25 </Formats> 26 <ObjType>event</ObjType> 27 <Url>default</Url> 28 </Resource> 29 <Resource> 30 <Enabled>1</Enabled> 31 <Formats> 32 <Format> 33 <Name>vtodo20</Name> 34 </Format> 35 </Formats> 36 <ObjType>todo</ObjType> 37 <Url>default</Url> 38 </Resource> 39 <Resource> 40 <Enabled>1</Enabled> 41 <Formats> 42 <Format> 43 <Name>vjournal</Name> 44 </Format> 45 </Formats> 46 <ObjType>note</ObjType> 47 <Url>default</Url> 48 </Resource> 49 </Resources> 7 50 </config> -
plugins/evolution2/src/evolution2_ebook.c
r3082 r3637 43 43 } 44 44 45 if (!(source = evo2_find_source(sources, env->addressbook_path))) {45 if (!(source = evo2_find_source(sources, g_strdup(env->addressbook_path)))) { 46 46 osync_error_set(&error, OSYNC_ERROR_GENERIC, "Error finding source \"%s\"", env->addressbook_path); 47 47 goto error; … … 302 302 } 303 303 304 304 305 osync_bool evo2_ebook_initialize(OSyncEvoEnv *env, OSyncPluginInfo *info, OSyncError **error) 305 306 { 306 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 307 env->contact_format = osync_format_env_find_objformat(formatenv, "vcard30"); 308 if (!env->contact_format) { 309 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find vcard30 object format. vformat plugin installed?"); 307 OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(info, "contact"); 308 if (!sink) 310 309 return FALSE; 311 } 312 osync_objformat_set_config(env->contact_format, "VCARD_EXTENSION=Evolution"); 313 314 315 env->contact_sink = osync_objtype_sink_new("contact", error); 316 if (!env->contact_sink) 310 osync_bool sinkEnabled = osync_objtype_sink_is_enabled(sink); 311 osync_trace(TRACE_INTERNAL, "%s: enabled => %d", __func__, sinkEnabled); 312 if (!sinkEnabled) 317 313 return FALSE; 318 314 319 osync_objtype_sink_add_objformat_with_config(env->contact_sink, "vcard30", "VCARD_EXTENSION=Evolution");320 osync_objtype_sink_add_objformat_with_config(env->contact_sink, "vcard21", "VCARD_EXTENSION=Evolution");321 322 /* All sinks have the same functions of course */323 315 OSyncObjTypeSinkFunctions functions; 324 316 memset(&functions, 0, sizeof(functions)); … … 328 320 functions.commit = evo2_ebook_modify; 329 321 functions.sync_done = evo2_ebook_sync_done; 330 331 /* We pass the OSyncFileDir object to the sink, so we dont have to look it up 332 * again once the functions are called */ 333 osync_objtype_sink_set_functions(env->contact_sink, functions, NULL); 334 osync_plugin_info_add_objtype(info, env->contact_sink); 322 323 OSyncPluginConfig *config = osync_plugin_info_get_config(info); 324 OSyncPluginResource *resource = osync_plugin_config_find_active_resource(config, "contact"); 325 env->addressbook_path = osync_plugin_resource_get_url(resource); 326 if(!env->addressbook_path) { 327 osync_error_set(error,OSYNC_ERROR_GENERIC, "Addressbook url not set"); 328 return FALSE; 329 } 330 OSyncList *objformatsinks = osync_plugin_resource_get_objformat_sinks(resource); 331 osync_bool hasObjFormat = FALSE; 332 OSyncList *r; 333 for(r = objformatsinks;r;r = r->next) { 334 OSyncObjFormatSink *objformatsink = r->data; 335 if(!strcmp("vcard30", osync_objformat_sink_get_objformat(objformatsink))) { hasObjFormat = TRUE; break;} 336 } 337 if (!hasObjFormat) { 338 osync_error_set(error, OSYNC_ERROR_GENERIC, "Format vcard30 not set."); 339 return FALSE; 340 } 341 342 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 343 env->contact_format = osync_format_env_find_objformat(formatenv, "vcard30"); 344 345 env->contact_sink = sink; 346 347 osync_objtype_sink_set_functions(sink, functions, NULL); 335 348 return TRUE; 336 349 } 350 -
plugins/evolution2/src/evolution2_ecal.c
r2340 r3637 43 43 } 44 44 45 if (!(source = evo2_find_source(sources, env->calendar_path))) {45 if (!(source = evo2_find_source(sources, g_strdup(env->calendar_path)))) { 46 46 osync_error_set(&error, OSYNC_ERROR_GENERIC, "Error finding source \"%s\"", env->calendar_path); 47 47 goto error; … … 311 311 osync_bool evo2_ecal_initialize(OSyncEvoEnv *env, OSyncPluginInfo *info, OSyncError **error) 312 312 { 313 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 314 env->calendar_format = osync_format_env_find_objformat(formatenv, "vevent20"); 315 316 if (!env->calendar_format) { 317 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find vevent20 object format. vformat plugin installed?"); 313 OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(info, "event"); 314 if (!sink) 318 315 return FALSE; 319 } 320 321 322 env->calendar_sink = osync_objtype_sink_new("event", error); 323 if (!env->calendar_sink){ 324 printf("calendar sink failed to initialize\n"); 316 osync_bool sinkEnabled = osync_objtype_sink_is_enabled(sink); 317 osync_trace(TRACE_INTERNAL, "%s: enabled => %d", __func__, sinkEnabled); 318 if (!sinkEnabled) 325 319 return FALSE; 326 } 327 328 osync_objtype_sink_add_objformat(env->calendar_sink, "vevent20"); 329 330 /* All sinks have the same functions of course */ 320 331 321 OSyncObjTypeSinkFunctions functions; 332 322 memset(&functions, 0, sizeof(functions)); … … 337 327 functions.sync_done = evo2_ecal_sync_done; 338 328 339 /* We pass the OSyncFileDir object to the sink, so we dont have to look it up 340 * again once the functions are called */ 329 OSyncPluginConfig *config = osync_plugin_info_get_config(info); 330 OSyncPluginResource *resource = osync_plugin_config_find_active_resource(config, "event"); 331 env->calendar_path = osync_plugin_resource_get_url(resource); 332 if(!env->calendar_path) { 333 osync_error_set(error,OSYNC_ERROR_GENERIC, "Calendar url not set"); 334 return FALSE; 335 } 336 OSyncList *objformatsinks = osync_plugin_resource_get_objformat_sinks(resource); 337 osync_bool hasObjFormat = FALSE; 338 OSyncList *r; 339 for(r = objformatsinks;r;r = r->next) { 340 OSyncObjFormatSink *objformatsink = r->data; 341 if(!strcmp("vevent20", osync_objformat_sink_get_objformat(objformatsink))) { hasObjFormat = TRUE; break;} 342 } 343 if (!hasObjFormat) { 344 osync_error_set(error, OSYNC_ERROR_GENERIC, "Format vevent20 not set."); 345 return FALSE; 346 } 347 348 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 349 env->calendar_format = osync_format_env_find_objformat(formatenv, "vevent20"); 350 351 env->calendar_sink = sink; 352 341 353 osync_objtype_sink_set_functions(env->calendar_sink, functions, NULL); 342 osync_plugin_info_add_objtype(info, env->calendar_sink);343 354 return TRUE; 344 355 } -
plugins/evolution2/src/evolution2_etodo.c
r2340 r3637 43 43 } 44 44 45 if (!(source = evo2_find_source(sources, env->tasks_path))) {45 if (!(source = evo2_find_source(sources, g_strdup(env->tasks_path)))) { 46 46 osync_error_set(&error, OSYNC_ERROR_GENERIC, "Error finding source \"%s\"", env->tasks_path); 47 47 goto error; … … 311 311 osync_bool evo2_etodo_initialize(OSyncEvoEnv *env, OSyncPluginInfo *info, OSyncError **error) 312 312 { 313 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 314 env->tasks_format = osync_format_env_find_objformat(formatenv, "vtodo20"); 315 316 if (!env->tasks_format) { 317 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find vtodo20 object format. vformat plugin installed?"); 313 OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(info, "todo"); 314 if (!sink) 318 315 return FALSE; 319 } 320 321 322 env->tasks_sink = osync_objtype_sink_new("todo", error); 323 if (!env->tasks_sink){ 324 printf("tasks sink failed to initialize\n"); 316 osync_bool sinkEnabled = osync_objtype_sink_is_enabled(sink); 317 osync_trace(TRACE_INTERNAL, "%s: enabled => %d", __func__, sinkEnabled); 318 if (!sinkEnabled) 325 319 return FALSE; 326 } 327 328 osync_objtype_sink_add_objformat(env->tasks_sink, "vtodo20"); 329 330 /* All sinks have the same functions of course */ 320 331 321 OSyncObjTypeSinkFunctions functions; 332 322 memset(&functions, 0, sizeof(functions)); … … 337 327 functions.sync_done = evo2_etodo_sync_done; 338 328 339 /* We pass the OSyncFileDir object to the sink, so we dont have to look it up 340 * again once the functions are called */ 329 OSyncPluginConfig *config = osync_plugin_info_get_config(info); 330 OSyncPluginResource *resource = osync_plugin_config_find_active_resource(config, "todo"); 331 env->tasks_path = osync_plugin_resource_get_url(resource); 332 if(!env->tasks_path) { 333 osync_error_set(error,OSYNC_ERROR_GENERIC, "Tasks url not set"); 334 return FALSE; 335 } 336 OSyncList *objformatsinks = osync_plugin_resource_get_objformat_sinks(resource); 337 osync_bool hasObjFormat = FALSE; 338 OSyncList *r; 339 for(r = objformatsinks;r;r = r->next) { 340 OSyncObjFormatSink *objformatsink = r->data; 341 if(!strcmp("vtodo20", osync_objformat_sink_get_objformat(objformatsink))) { hasObjFormat = TRUE; break;} 342 } 343 if (!hasObjFormat) { 344 osync_error_set(error, OSYNC_ERROR_GENERIC, "Format vtodo20 not set."); 345 return FALSE; 346 } 347 348 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 349 env->tasks_format = osync_format_env_find_objformat(formatenv, "vtodo20"); 350 351 env->tasks_sink = sink; 352 341 353 osync_objtype_sink_set_functions(env->tasks_sink, functions, NULL); 342 osync_plugin_info_add_objtype(info, env->tasks_sink);343 354 return TRUE; 344 355 } -
plugins/evolution2/src/evolution2_memo.c
r2794 r3637 43 43 } 44 44 45 if (!(source = evo2_find_source(sources, env->memos_path))) {45 if (!(source = evo2_find_source(sources, g_strdup(env->memos_path)))) { 46 46 osync_error_set(&error, OSYNC_ERROR_GENERIC, "Error finding source \"%s\"", env->memos_path); 47 47 goto error; … … 311 311 osync_bool evo2_memo_initialize(OSyncEvoEnv *env, OSyncPluginInfo *info, OSyncError **error) 312 312 { 313 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 314 env->memos_format = osync_format_env_find_objformat(formatenv, "vjournal"); 315 316 if (!env->memos_format) { 317 osync_error_set(error, OSYNC_ERROR_GENERIC, "Unable to find vjournal object format. vformat plugin installed?"); 313 OSyncObjTypeSink *sink = osync_plugin_info_find_objtype(info, "note"); 314 if (!sink) 318 315 return FALSE; 319 } 320 321 322 env->memos_sink = osync_objtype_sink_new("note", error); 323 if (!env->memos_sink){ 324 printf("memos sink failed to initialize\n"); 316 osync_bool sinkEnabled = osync_objtype_sink_is_enabled(sink); 317 osync_trace(TRACE_INTERNAL, "%s: enabled => %d", __func__, sinkEnabled); 318 if (!sinkEnabled) 325 319 return FALSE; 326 } 327 328 osync_objtype_sink_add_objformat(env->memos_sink, "vjournal"); 329 330 /* All sinks have the same functions of course */ 320 331 321 OSyncObjTypeSinkFunctions functions; 332 322 memset(&functions, 0, sizeof(functions)); … … 337 327 functions.sync_done = evo2_memo_sync_done; 338 328 339 /* We pass the OSyncFileDir object to the sink, so we dont have to look it up 340 * again once the functions are called */ 329 OSyncPluginConfig *config = osync_plugin_info_get_config(info); 330 OSyncPluginResource *resource = osync_plugin_config_find_active_resource(config, "note"); 331 env->memos_path = osync_plugin_resource_get_url(resource); 332 if(!env->memos_path) { 333 osync_error_set(error,OSYNC_ERROR_GENERIC, "Memo url not set"); 334 return FALSE; 335 } 336 OSyncList *objformatsinks = osync_plugin_resource_get_objformat_sinks(resource); 337 osync_bool hasObjFormat = FALSE; 338 OSyncList *r; 339 for(r = objformatsinks;r;r = r->next) { 340 OSyncObjFormatSink *objformatsink = r->data; 341 if(!strcmp("vjournal", osync_objformat_sink_get_objformat(objformatsink))) { hasObjFormat = TRUE; break;} 342 } 343 if (!hasObjFormat) { 344 osync_error_set(error, OSYNC_ERROR_GENERIC, "Format vjournal not set."); 345 return FALSE; 346 } 347 348 OSyncFormatEnv *formatenv = osync_plugin_info_get_format_env(info); 349 env->memos_format = osync_format_env_find_objformat(formatenv, "vjournal"); 350 351 env->memos_sink = sink; 352 341 353 osync_objtype_sink_set_functions(env->memos_sink, functions, NULL); 342 osync_plugin_info_add_objtype(info, env->memos_sink);343 354 return TRUE; 344 355 } -
plugins/evolution2/src/evolution2_sync.c
r2952 r3637 24 24 static void free_env(OSyncEvoEnv *env) 25 25 { 26 if (env->addressbook_path)27 g_free(env->addressbook_path);28 29 if (env->calendar_path)30 g_free(env->calendar_path);31 32 if (env->tasks_path)33 g_free(env->tasks_path);34 35 26 if (env->contact_sink) 36 27 osync_objtype_sink_unref(env->contact_sink); … … 197 188 } 198 189 199 /*Load the state from a xml file and return it in the conn struct*/200 static osync_bool evo2_parse_settings(OSyncEvoEnv *env, const char *data, OSyncError **error)201 {202 xmlDocPtr doc;203 xmlNodePtr cur;204 205 //set defaults206 env->addressbook_path = NULL;207 env->calendar_path = NULL;208 env->memos_path = NULL;209 env->tasks_path = NULL;210 211 doc = xmlParseMemory(data, strlen(data));212 213 if (!doc)214 return FALSE;215 216 217 cur = xmlDocGetRootElement(doc);218 219 if (!cur) {220 xmlFreeDoc(doc);221 return FALSE;222 }223 224 if (xmlStrcmp(cur->name, (xmlChar*)"config")) {225 xmlFreeDoc(doc);226 return FALSE;227 }228 229 cur = cur->xmlChildrenNode;230 231 while (cur != NULL) {232 char *str = (char*)xmlNodeGetContent(cur);233 if (str) {234 if (!xmlStrcmp(cur->name, (const xmlChar *)"address_path")) {235 env->addressbook_path = g_strdup(str);236 }237 if (!xmlStrcmp(cur->name, (const xmlChar *)"calendar_path")) {238 env->calendar_path = g_strdup(str);239 }240 if (!xmlStrcmp(cur->name, (const xmlChar *)"memos_path")) {241 env->memos_path = g_strdup(str);242 }243 if (!xmlStrcmp(cur->name, (const xmlChar *)"tasks_path")) {244 env->tasks_path = g_strdup(str);245 }246 xmlFree(str);247 }248 cur = cur->next;249 }250 251 xmlFreeDoc(doc);252 return TRUE;253 }254 255 190 /* In initialize, we get the config for the plugin. Here we also must register 256 191 * all _possible_ objtype sinks. */ … … 262 197 if (!env) 263 198 goto error; 199 200 env->pluginInfo = info; 264 201 265 202 osync_trace(TRACE_INTERNAL, "Setting change id: %s", osync_plugin_info_get_groupname(info)); … … 267 204 env->change_id = g_strdup(osync_plugin_info_get_groupname(info)); 268 205 269 osync_trace(TRACE_INTERNAL, "The config: %s", osync_plugin_info_get_config(info)); 270 271 if (!evo2_parse_settings(env, osync_plugin_info_get_config(info), error)) 272 goto error_free_env; 206 osync_trace(TRACE_INTERNAL, "The config: %p", osync_plugin_info_get_config(info)); 273 207 274 208 if (!evo2_ebook_initialize(env, info, error)) 275 209 goto error_free_env; 276 210 277 211 if (!evo2_ecal_initialize(env, info, error)) 278 212 goto error_free_env; … … 299 233 OSyncEvoEnv *env = data; 300 234 301 if (env->contact_sink) 302 osync_objtype_sink_unref(env->contact_sink); 303 304 if (env->calendar_sink) 305 osync_objtype_sink_unref(env->calendar_sink); 306 307 if (env->memos_sink) 308 osync_objtype_sink_unref(env->memos_sink); 309 310 if (env->tasks_sink) 311 osync_objtype_sink_unref(env->tasks_sink); 312 235 /* cleanup OpenSync stuff */ 236 if (env->pluginInfo) { 237 osync_plugin_info_unref(env->pluginInfo); 238 env->pluginInfo = NULL; 239 } 240 osync_trace(TRACE_INTERNAL, "%s - plugin info cleaned", __func__); 241 242 /* Final cleanup */ 313 243 free_env(env); 314 244 osync_trace(TRACE_EXIT, "%s", __func__); … … 321 251 osync_trace(TRACE_ENTRY, "%s(%p, %p, %p)", __func__, data, info, error); 322 252 253 /* 323 254 GError* gerror = NULL; 324 255 GList* fields = NULL; 325 256 OSyncEvoEnv *env = (OSyncEvoEnv *)data; 326 327 if (env->addressbook_path) 328 osync_objtype_sink_set_available(env->contact_sink, TRUE); 329 330 if (env->calendar_path) 331 osync_objtype_sink_set_available(env->calendar_sink, TRUE); 332 333 if (env->memos_path) 334 osync_objtype_sink_set_available(env->memos_sink, TRUE); 335 336 if (env->tasks_path) 337 osync_objtype_sink_set_available(env->tasks_sink, TRUE); 338 257 */ 258 int i, numobjs = osync_plugin_info_num_objtypes(info); 259 for (i = 0; i < numobjs; i++) { 260 OSyncObjTypeSink *sink = osync_plugin_info_nth_objtype(info, i); 261 g_assert(sink); 262 263 osync_objtype_sink_set_available(sink, TRUE); 264 } 265 339 266 OSyncVersion *version = osync_version_new(error); 340 267 osync_version_set_plugin(version, "Evolution"); … … 382 309 return TRUE; 383 310 311 /* 384 312 error_free_book: 385 313 g_object_unref(env->addressbook); 314 */ 386 315 error: 387 316 osync_trace(TRACE_ERROR, "%s: %s", __func__, osync_error_print(error)); … … 398 327 osync_plugin_set_longname(plugin, "Evolution 2.x"); 399 328 osync_plugin_set_description(plugin, "Address book, calendar and task list of Evolution 2"); 400 osync_plugin_set_config_type(plugin, OSYNC_PLUGIN_OPTIONAL_CONFIGURATION);401 /**402 * Bug 477227 â libebook isn't designed to be loaded and unloaded403 * see: http://bugzilla.gnome.org/show_bug.cgi?id=477227404 * see: http://mail.gnome.org/archives/evolution-hackers/2007-September/msg00027.html405 * also the other EDS client libraries; so we start the plugin in a own process.406 */407 osync_plugin_set_start_type(plugin, OSYNC_START_TYPE_PROCESS);408 329 409 330 osync_plugin_set_initialize(plugin, evo2_initialize); … … 426 347 return 1; 427 348 } 349 350 /** 351 * Bug 477227 â libebook isn't designed to be loaded and unloaded 352 * see: http://bugzilla.gnome.org/show_bug.cgi?id=477227 353 * see: http://mail.gnome.org/archives/evolution-hackers/2007-September/msg00027.html 354 * also the other EDS client libraries; so prevent unloading this module as the api provides 355 * this facility which is the same as would be the g_module_make_resident that is : 356 * "Any future g_module_close() calls on the module will be ignored.". 357 */ 358 int dont_free(void) 359 { 360 return 1; 361 } -
plugins/evolution2/src/evolution2_sync.h
r2794 r3637 34 34 char *change_id; 35 35 36 c har *addressbook_path;36 const char *addressbook_path; 37 37 EBook *addressbook; 38 38 OSyncObjTypeSink *contact_sink; 39 39 OSyncObjFormat *contact_format; 40 40 41 c har *calendar_path;41 const char *calendar_path; 42 42 ECal *calendar; 43 43 OSyncObjTypeSink *calendar_sink; 44 44 OSyncObjFormat *calendar_format; 45 45 46 c har *memos_path;46 const char *memos_path; 47 47 ECal *memos; 48 48 OSyncObjTypeSink *memos_sink; 49 49 OSyncObjFormat *memos_format; 50 50 51 c har *tasks_path;51 const char *tasks_path; 52 52 ECal *tasks; 53 53 OSyncObjTypeSink *tasks_sink; 54 54 OSyncObjFormat *tasks_format; 55 55 56 OSyncPluginInfo *pluginInfo; 56 57 } OSyncEvoEnv; 57 58
