Changeset 3393

Show
Ignore:
Timestamp:
07/07/08 09:44:38 (1 month ago)
Author:
dgollub
Message:

Update plugin_config.xsd schema to store "ObjType?" of
OSyncPluginRessource in the plugin config.
Updated assembler/parser for plugin_config.
Exteneded tests for assembler/parser for plugin_config.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/misc/schemas/plugin_config.xsd

    r3329 r3393  
    5353    <xsd:sequence> 
    5454      <xsd:element maxOccurs="1" minOccurs="1" name="Enabled" type="xsd:integer" /> 
     55      <xsd:element maxOccurs="1" minOccurs="0" name="Formats" type="Formats" /> 
    5556      <xsd:element maxOccurs="1" minOccurs="0" name="Name" type="xsd:string" /> 
    5657      <xsd:element maxOccurs="1" minOccurs="0" name="MIME" type="xsd:string" /> 
    57       <xsd:element maxOccurs="1" minOccurs="0" name="Formats" type="Formats" /> 
     58      <xsd:element maxOccurs="1" minOccurs="1" name="ObjType" type="xsd:string" /> 
    5859      <xsd:element maxOccurs="1" minOccurs="0" name="Path" type="xsd:string" /> 
    5960      <xsd:element maxOccurs="1" minOccurs="0" name="Url" type="xsd:string" /> 
  • trunk/opensync/plugin/opensync_plugin_config.c

    r3329 r3393  
    451451                if (!xmlStrcmp(cur->name, (const xmlChar *)"Enabled")) { 
    452452                        osync_plugin_ressource_enable(res, atoi(str)); 
     453                } else if (!xmlStrcmp(cur->name, (const xmlChar *)"Formats")) { 
     454                        if (!_osync_plugin_config_parse_ressource_formats(res, cur->xmlChildrenNode, error)) 
     455                                goto error_free_str; 
    453456                } else if (!xmlStrcmp(cur->name, (const xmlChar *)"Name")) { 
    454457                        osync_plugin_ressource_set_name(res, str); 
    455458                } else if (!xmlStrcmp(cur->name, (const xmlChar *)"MIME")) { 
    456459                        osync_plugin_ressource_set_mime(res, str); 
    457                 } else if (!xmlStrcmp(cur->name, (const xmlChar *)"Formats")) { 
    458                         if (!_osync_plugin_config_parse_ressource_formats(res, cur->xmlChildrenNode, error)) 
    459                                 goto error_free_str; 
     460                } else if (!xmlStrcmp(cur->name, (const xmlChar *)"ObjType")) { 
     461                        osync_plugin_ressource_set_objtype(res, str); 
    460462                } else if (!xmlStrcmp(cur->name, (const xmlChar *)"Path")) { 
    461463                        osync_plugin_ressource_set_path(res, str); 
     
    804806 
    805807        OSyncList *o; 
    806         const char *name, *mime, *path, *url; 
     808        const char *name, *mime, *objtype, *path, *url; 
    807809 
    808810        xmlNode *next, *node = xmlNewChild(cur, NULL, (xmlChar*)"Ressource", NULL); 
     
    814816        osync_bool res_enabled = osync_plugin_ressource_is_enabled(res); 
    815817        xmlNewChild(node, NULL, (xmlChar*)"Enabled", res_enabled ? (xmlChar*) "1" : (xmlChar*) "0"); 
    816  
    817         if ((name = osync_plugin_ressource_get_name(res))) 
    818                 xmlNewChild(node, NULL, (xmlChar*)"Name", (xmlChar*)name); 
    819  
    820         if ((mime = osync_plugin_ressource_get_mime(res))) 
    821                 xmlNewChild(node, NULL, (xmlChar*)"MIME", (xmlChar*)mime); 
    822818 
    823819        next = xmlNewChild(node, NULL, (xmlChar*)"Formats", NULL); 
     
    827823                        goto error; 
    828824        } 
     825 
     826        if ((name = osync_plugin_ressource_get_name(res))) 
     827                xmlNewChild(node, NULL, (xmlChar*)"Name", (xmlChar*)name); 
     828 
     829        if ((mime = osync_plugin_ressource_get_mime(res))) 
     830                xmlNewChild(node, NULL, (xmlChar*)"MIME", (xmlChar*)mime); 
     831 
     832        objtype = osync_plugin_ressource_get_objtype(res); 
     833        osync_assert(objtype); /* ObjType for Ressource MUST be set! */ 
     834        xmlNewChild(node, NULL, (xmlChar*)"ObjType", (xmlChar*) objtype); 
    829835 
    830836        if ((path = osync_plugin_ressource_get_path(res))) 
  • trunk/tests/plugin-tests/check_plugin_config.c

    r3330 r3393  
    451451        osync_objformat_sink_unref(format_sink2); 
    452452 
     453        /* ObjType */ 
     454        osync_plugin_ressource_set_objtype(ressource, "foobar"); 
     455        fail_unless(!strcmp(osync_plugin_ressource_get_objtype(ressource), "foobar"), NULL); 
     456 
     457        /* Overwrite (leak check) */ 
     458        osync_plugin_ressource_set_objtype(ressource, "barfoo"); 
     459        fail_unless(!strcmp(osync_plugin_ressource_get_objtype(ressource), "barfoo"), NULL); 
     460 
    453461        /* Path */ 
    454462        osync_plugin_ressource_set_path(ressource, "foobar"); 
     
    540548        osync_plugin_ressource_set_mime(ressource1, "foobar1"); 
    541549        osync_plugin_ressource_add_objformat_sink(ressource1, format_sink1); 
     550        osync_plugin_ressource_set_objtype(ressource1, "foobar1"); 
    542551        osync_plugin_ressource_set_path(ressource1, "foobar1"); 
    543552        osync_plugin_ressource_set_url(ressource1, "foobar1"); 
     
    556565        osync_plugin_ressource_set_mime(ressource2, "foobar2"); 
    557566        osync_plugin_ressource_add_objformat_sink(ressource2, format_sink2); 
     567        osync_plugin_ressource_set_objtype(ressource2, "foobar2"); 
    558568        osync_plugin_ressource_set_path(ressource2, "foobar2"); 
    559569        osync_plugin_ressource_set_url(ressource2, "foobar2"); 
     
    599609                fail_unless(!strcmp(osync_plugin_ressource_get_mime(r->data), value), NULL); 
    600610                fail_unless(!strcmp(_format_sink_get_objformat(r->data), value), NULL); 
     611                fail_unless(!strcmp(osync_plugin_ressource_get_objtype(r->data), value), NULL); 
     612 
    601613                fail_unless(!strcmp(osync_plugin_ressource_get_path(r->data), value), NULL); 
    602614                fail_unless(!strcmp(osync_plugin_ressource_get_url(r->data), value), NULL);