From: <svn...@op...> - 2009-09-03 00:38:41
|
Author: dgollub Date: Thu Sep 3 02:30:29 2009 New Revision: 5731 URL: http://www.opensync.org/changeset/5731 Log: Drop syncml_vformat.{c,h} since SyncML plugin should be completely indepdent of any objformat. Ported syncml plugin to latest OSyncCapabilities API. Initial port, more detailed capabilities is WIP Deleted: plugins/syncml/src/syncml_vformat.c plugins/syncml/src/syncml_vformat.h Modified: plugins/syncml/src/CMakeLists.txt plugins/syncml/src/syncml_devinf.c plugins/syncml/src/syncml_devinf.h Modified: plugins/syncml/src/CMakeLists.txt ============================================================================== --- plugins/syncml/src/CMakeLists.txt Thu Sep 3 02:28:18 2009 (r5730) +++ plugins/syncml/src/CMakeLists.txt Thu Sep 3 02:30:29 2009 (r5731) @@ -2,7 +2,7 @@ INCLUDE_DIRECTORIES(${OPENSYNC_INCLUDE_DIRS} ${GLIB2_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIRS} ${LIBSYNCML_INCLUDE_DIRS}) SET(SOURCE_FILES syncml_plugin.c syncml_common.c) -SET(SOURCE_FILES ${SOURCE_FILES} syncml_devinf.c syncml_callbacks.c syncml_vformat.c) +SET(SOURCE_FILES ${SOURCE_FILES} syncml_devinf.c syncml_callbacks.c) SET(SOURCE_FILES ${SOURCE_FILES} syncml_ds_client.c syncml_ds_server.c) IF (ENABLE_OBEX) Modified: plugins/syncml/src/syncml_devinf.c ============================================================================== --- plugins/syncml/src/syncml_devinf.c Thu Sep 3 02:28:18 2009 (r5730) +++ plugins/syncml/src/syncml_devinf.c Thu Sep 3 02:30:29 2009 (r5731) @@ -38,6 +38,74 @@ return ct; } +SmlBool _handle_remote_devinf( + SmlDataSyncObject *dsObject, + SmlDevInf *devinf, + void *userdata, + SmlError **error) +{ + osync_trace(TRACE_ENTRY, "%s", __func__); + SmlPluginEnv *env = userdata; + OSyncError *oerror; + + /*check the requirements */ + g_assert(devinf); + g_assert(env->pluginInfo); + osync_trace(TRACE_INTERNAL, "%s: assertions ok", __func__); + + /* create fresh capabilties */ + OSyncCapabilities *caps = osync_capabilities_new("syncml-caps", &oerror); + osync_assert(caps); + + /* now manage all content type capabilities */ + unsigned int capCount = smlDevInfNumCTCaps(devinf); + unsigned int i; + for (i=0; i < capCount; i++) + { + const SmlDevInfCTCap *ctcap = smlDevInfGetNthCTCap(devinf, i); + + /* define objtype */ + char *cttype = smlDevInfCTCapGetCTType(ctcap); + + OSyncCapabilitiesObjType *capsobjtype = NULL; + if (strstr(cttype, "calendar")) { + capsobjtype = osync_capabilities_objtype_new(caps, "event", &oerror); + } else if (strstr(cttype, "vcard")) { + capsobjtype = osync_capabilities_objtype_new(caps, "contact", &oerror); + } + + /* iterate over properties */ + if (capsobjtype) { + + unsigned int propCount = smlDevInfCTCapNumProperties(ctcap); + unsigned int k; + for (k=0; k < propCount; k++) + { + const SmlDevInfProperty *prop = smlDevInfCTCapGetNthProperty(ctcap, k); + + OSyncCapability *cap = osync_capability_new(capsobjtype, &oerror); + if (!cap) + goto error; + + char *name = smlDevInfPropertyGetPropName(prop); + osync_capability_set_name(cap, (const char *) name); + safe_cfree(&name); + } + } + safe_cfree(&cttype); + } + + osync_plugin_info_set_capabilities(env->pluginInfo, caps); + osync_capabilities_unref(caps); + + osync_trace(TRACE_EXIT, "%s - success", __func__); + return TRUE; + +error: + osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(&oerror)); + return FALSE; +} + #if 0 /* MISSING OSYNC CAPABILITIES - #1079 */ /* ************************ */ Modified: plugins/syncml/src/syncml_devinf.h ============================================================================== --- plugins/syncml/src/syncml_devinf.h Thu Sep 3 02:28:18 2009 (r5730) +++ plugins/syncml/src/syncml_devinf.h Thu Sep 3 02:30:29 2009 (r5731) @@ -24,4 +24,11 @@ void *userdata, SmlError **error); + +SmlBool _handle_remote_devinf( + SmlDataSyncObject *dsObject, + SmlDevInf *devinf, + void *userdata, + SmlError **error); + #endif //_SYNCML_DEVINF_H |