|
From: Daniel G. <go...@b1...> - 2010-07-09 03:09:32
|
On Friday 09 July 2010 02:14:17 pm Chris Frey wrote:
> What is the difference between these two blocks of code?
>
>
> OSyncFormatEnv *formatenv1 =
> osync_plugin_info_get_format_env(info); format =
> osync_format_env_find_objformat(formatenv1,
> "xmlformat-event-doc");
> if( !format ) {
> osync_trace(TRACE_ERROR, "%s",
> "Failed to find objformat xmlformat-event-doc!");
> goto error;
> }
This one is using the OSyncFormatEnv which has access to all format plugins
which are available to the OpenSync installation. So it has access to all
available OSyncObjFormats as well ...
Basically this code seems to check if the xmlformat plugin is installed and
the xmlformat-event-doc objformat ist available.
>
>
> And...
>
> OSyncPluginConfig *config = osync_plugin_info_get_config(info);
> OSyncPluginResource *resource =
> osync_plugin_config_find_active_resource(config, "event");
>
> OSyncList *objformatsinks =
> osync_plugin_resource_get_objformat_sinks(resource);
>
> osync_bool has_format = false;
>
> OSyncList *r;
> for( r = objformatsinks; r ;r = r->next ) {
> OSyncObjFormatSink *objformatsink = (OSyncObjFormatSink *)
> r->data;
>
> if( !strcmp("xmlformat-event-doc",
> osync_objformat_sink_get_objformat(objformatsink))) { has_format = true;
> break;
> }
> }
>
> if( !has_format ) {
> osync_trace(TRACE_ERROR, "%s",
> "Failed to find objformat xmlformat-event-doc!");
> goto error;
> }
This one uses the Plugin configuration (OSyncPluginConfig) which contains a
resource configuraiton. It checks if there is a "event" resource configured
which uses the xmlformat-event-doc in the objformat-sink in this plugin/member
configuration.
So the basic difference is:
block #1: checks if xmlformat-event-doc is available in this particular
installation of OpenSync
block #2: checks if a plugin/member got configured to provide a <Resource>
using xmlformat-event-doc
Hope that helps!
Best Regards,
Daniel
--
Daniel Gollub Geschaeftsfuehrer: Ralph Dehner
Linux Consultant & Developer Unternehmenssitz: Vohburg
B1 Systems GmbH Amtsgericht: Ingolstadt
Mobil: +49-(0)-160 47 73 970 Handelsregister: HRB 3537
EMail: go...@b1... http://www.b1-systems.de
Adresse: B1 Systems GmbH, Osterfeldstraße 7, 85088 Vohburg
http://pgpkeys.pca.dfn.de/pks/lookup?op=get&search=0xED14B95C2F8CA78D
|