Changeset 2549
- Timestamp:
- 10/11/07 01:54:01 (1 year ago)
- Files:
-
- plugins/gpe/ChangeLog (modified) (1 diff)
- plugins/gpe/src/gpe-sync (modified) (5 diffs)
- plugins/gpe/src/gpe_sync.c (modified) (6 diffs)
- plugins/gpe/src/gpe_sync.h (modified) (1 diff)
- plugins/gpe/src/gpe_xml.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/gpe/ChangeLog
r2546 r2549 1 2007-10-11 Graham Cobb <g+770@cobb.uk.net> 2 3 * src/gpe_sync.c, src/gpe_sync.h: Add multiple calendar support 4 * src/gpe_xml.c, src/gpe-sync: Add <calendar> configuration support 5 1 6 2007-10-09 Graham Cobb <g+770@cobb.uk.net> 2 7 plugins/gpe/src/gpe-sync
r2521 r2549 6 6 7 7 In this case you can specify <command>shell command</command> 8 to change the shell command which is invoked. 9 10 Specifying the <command> tag is not recommended. 8 to change the shell command which is invoked. However, specifying 9 the <command> tag is not recommended. 11 10 12 11 2) You can use SSH to connect to the device by specifying the 13 <ssh>...< ssh> option.12 <ssh>...</ssh> option. 14 13 15 14 In this case, the <handheld_ip>, <handheld_user> and <command> … … 28 27 <remote>...</remote> option. 29 28 30 In this case, the <handheld_ip> and <handheld_port> tags are used.29 In this case, the <handheld_ip> and <handheld_port> tags can be used. 31 30 32 Either use the <ssh> configuration shown below or remove it and uncomment31 Either customise the <ssh> configuration shown below or remove it and uncomment 33 32 one of the other sections. Each section is configured to show the default values 34 33 used if the tags are not specified. 35 34 --> 36 37 35 <ssh> 38 36 <handheld_ip>127.0.0.1</handheld_ip> … … 40 38 <command>gpesyncd --remote</command> 41 39 </ssh> 42 43 40 <!-- 44 41 <local> … … 46 43 </local> 47 44 --> 48 49 45 <!-- 50 46 <remote> … … 54 50 --> 55 51 52 <!-- 53 The <calendar> tag can be used to specify which GPE calendar 54 should be used for this synchronisation. If the <calendar> 55 tag is specified then only the named calendar is considered 56 (only events in that calendar wil be sent from GPE and all 57 events sent to GPE will be stored in that calendar). If the 58 <calendar> tag is not specified, then all events, from all 59 calendars, will be sent from GPE and new events will be created 60 in the default calendar. 61 62 Note that an error occurs if the named calendar does not exist 63 and calendar names are case-sensitive. 64 --> 65 <!-- <calendar>Some Calendar</calendar> --> 56 66 </config> plugins/gpe/src/gpe_sync.c
r2546 r2549 21 21 22 22 #include "gpe_sync.h" 23 24 /*! \brief Closes the connection to the databases 25 * 26 * \brief ctx The context of the plugin 27 */ 28 static void gpe_disconnect_internal(gpe_environment *env) 29 { 30 osync_trace(TRACE_ENTRY, "GPE-SYNC %s(%p)", __func__, env); 31 32 if (env->client) { 33 gpesync_client_close (env->client); 34 env->client = NULL; 35 } 36 37 osync_trace(TRACE_EXIT, "GPE-SYNC %s", __func__); 38 } 39 static void gpe_disconnect(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx) 40 { 41 osync_trace(TRACE_ENTRY, "GPE-SYNC %s(%p, %p, %p)", __func__, userdata, info, ctx); 42 gpe_environment *env = ((sink_environment *)userdata)->gpe_env; 43 44 gpe_disconnect_internal(env); 45 46 //Answer the call 47 osync_context_report_success(ctx); 48 osync_trace(TRACE_EXIT, "GPE-SYNC %s", __func__); 49 } 23 50 24 51 /*! \brief Connects to the databases of GPE … … 66 93 } 67 94 95 // Set calendar name 96 if (env->calendar) { 97 gchar *response = NULL; 98 gpesync_client_exec_printf(env->client, "path vevent %s", client_callback_string, &response, NULL, env->calendar); 99 if (strncmp(response, "OK", 2) != 0) { 100 osync_context_report_error(ctx, OSYNC_ERROR_MISCONFIGURATION, "calendar %s not found", 101 env->calendar); 102 osync_trace(TRACE_EXIT_ERROR, "GPE-SYNC %s: calendar %s not found", 103 __func__, env->calendar); 104 gpe_disconnect_internal(env); 105 g_free(response); 106 return; 107 } 108 g_free(response); 109 } 110 68 111 osync_context_report_success(ctx); 69 112 … … 78 121 { 79 122 osync_trace(TRACE_ENTRY, "GPE-SYNC %s(%p, %p, %p)", __func__, userdata, info, ctx); 80 gpe_environment *env = ((sink_environment *)userdata)->gpe_env;123 //gpe_environment *env = ((sink_environment *)userdata)->gpe_env; 81 124 82 125 //If we use anchors we have to update it now. 83 126 84 //Answer the call85 osync_context_report_success(ctx);86 osync_trace(TRACE_EXIT, "GPE-SYNC %s", __func__);87 }88 89 /*! \brief Closes the connection to the databases90 *91 * \brief ctx The context of the plugin92 */93 static void gpe_disconnect_internal(gpe_environment *env)94 {95 osync_trace(TRACE_ENTRY, "GPE-SYNC %s(%p)", __func__, env);96 97 if (env->client) {98 gpesync_client_close (env->client);99 env->client = NULL;100 }101 102 osync_trace(TRACE_EXIT, "GPE-SYNC %s", __func__);103 }104 static void gpe_disconnect(void *userdata, OSyncPluginInfo *info, OSyncContext *ctx)105 {106 osync_trace(TRACE_ENTRY, "GPE-SYNC %s(%p, %p, %p)", __func__, userdata, info, ctx);107 gpe_environment *env = ((sink_environment *)userdata)->gpe_env;108 109 gpe_disconnect_internal(env);110 111 127 //Answer the call 112 128 osync_context_report_success(ctx); … … 241 257 osync_trace(TRACE_EXIT_ERROR, "GPE-SYNC %s: gpesyncd version %d.%d not supported -- require %d.%d", 242 258 __func__, v_major, v_minor, MIN_PROTOCOL_MAJOR, MIN_PROTOCOL_MINOR); 259 g_free(response); 243 260 return FALSE; 244 261 } … … 255 272 g_free(version_string); 256 273 257 // Report avaliable sinks... 274 if (env->calendar) { 275 // Calendar support requires at least version 1.2 276 if (v_minor < 2) { 277 osync_error_set(error, OSYNC_ERROR_NOT_SUPPORTED, "gpesyncd version %d.%d does not support <calendar> -- require %d.%d", 278 v_major, v_minor, MIN_PROTOCOL_MAJOR, 2); 279 osync_trace(TRACE_EXIT_ERROR, "GPE-SYNC %s: gpesyncd version %d.%d does not support <calendar> -- require %d.%d", 280 __func__, v_major, v_minor, MIN_PROTOCOL_MAJOR, 2); 281 gpe_disconnect_internal(env); 282 g_free(response); 283 return FALSE; 284 } 285 286 // Verify calendar name 287 gpesync_client_exec_printf(env->client, "path vevent %s", client_callback_string, &response, NULL, env->calendar); 288 if (strncmp(response, "OK", 2) != 0) { 289 osync_error_set(error, OSYNC_ERROR_MISCONFIGURATION, "calendar %s not found", 290 env->calendar); 291 osync_trace(TRACE_EXIT_ERROR, "GPE-SYNC %s: calendar %s not found", 292 __func__, env->calendar); 293 gpe_disconnect_internal(env); 294 g_free(response); 295 } 296 } 297 298 // Report available sinks... 258 299 // GPE always supports contacts, todos and events 259 300 if (env->contact_sink.sink) osync_objtype_sink_set_available(env->contact_sink.sink, TRUE); … … 264 305 gpe_disconnect_internal(env); 265 306 307 g_free(response); 266 308 osync_trace(TRACE_EXIT, "GPE-SYNC %s", __func__); 267 309 return TRUE; plugins/gpe/src/gpe_sync.h
r2546 r2549 68 68 int use_local; 69 69 int use_remote; 70 char *calendar; // Name of GPE calendar to use or NULL 70 71 71 72 int debuglevel; plugins/gpe/src/gpe_xml.c
r2521 r2549 41 41 env->use_remote = 0; 42 42 env->debuglevel = 0; 43 env->calendar = NULL; 43 44 44 45 xmlInitParser(); … … 53 54 ctx = xmlXPathNewContext(doc); 54 55 55 /* Work out which type connection to use */56 /* Work out which type of connection to use */ 56 57 obj = xmlXPathEval("/config/local", ctx); 57 58 if (obj && obj->nodesetval && obj->nodesetval->nodeNr) { … … 149 150 150 151 if (obj) xmlXPathFreeObject(obj); 152 obj = xmlXPathEval("//calendar/text()", ctx); 153 if (obj && obj->nodesetval && obj->nodesetval->nodeNr) { 154 xmlChar *str=xmlXPathCastToString(obj); 155 env->calendar = g_strdup(str); 156 xmlFree(str); 157 osync_trace(TRACE_INTERNAL, "GPE-SYNC %s: <calendar> = %s", __func__, env->calendar); 158 } 159 160 if (obj) xmlXPathFreeObject(obj); 151 161 xmlXPathFreeContext(ctx); 152 162 xmlFreeDoc(doc);
