Changeset 347

Show
Ignore:
Timestamp:
01/31/08 21:22:32 (10 months ago)
Author:
dgollub
Message:

Handle "ParamName?" as (direct) child of DevInf?. "ParamName?" nodes
appears twice in the DTD of DevInf? (at least in SyncML 1.2 - what about

SyncML 1.1?):

<!ELEMENT PropParam? (ParamName?, DataType??, ValEnum?*, DisplayName??)>
<!ELEMENT ParamName? (#PCDATA)>

Added getter/setter function for Property->ParamName? node.
Added xmlparser testcase. Regression check for #131

Hopefully fixes #131
jaymzh, Thanks for testing!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libsyncml/parser/sml_xml_parse.c

    r339 r347  
    24312431                                        goto error; 
    24322432                                smlDevInfPropertyAddPropParam(property, param); 
     2433                                break; 
     2434                        case SML_DEVINF_CTCAP_PARAMNAME: 
     2435                                smlDevInfPropertySetParamName(property, value); 
    24332436                                break; 
    24342437                        case SML_DEVINF_CTCAP_SIZE: 
  • trunk/libsyncml/sml_devinf.c

    r345 r347  
    156156                                SmlDevInfProperty *prop = p->data; 
    157157                                g_free(prop->propName); 
     158                                g_free(prop->paramName); 
    158159                                g_free(prop->dataType); 
    159160                                g_free(prop->displayName); 
     
    927928 
    928929    property->propName = NULL; 
     930    property->paramName = NULL; 
    929931    property->dataType = NULL; 
    930932    property->maxOccur = 0; 
     
    954956} 
    955957 
     958void smlDevInfPropertySetParamName( 
     959                        SmlDevInfProperty *property, 
     960                        const char *paramName) 
     961{ 
     962    smlTrace(TRACE_ENTRY, "%s(%p, %s)", __func__, property, paramName); 
     963    smlAssert(property); 
     964    smlAssert(paramName); 
     965 
     966    if (property->paramName != NULL) 
     967        g_free(property->paramName); 
     968    property->paramName = g_strdup(paramName); 
     969 
     970    smlTrace(TRACE_EXIT, "%s", __func__); 
     971} 
     972 
    956973void smlDevInfPropertySetDataType( 
    957974                        SmlDevInfProperty *property, 
     
    10581075    smlAssert(property); 
    10591076    char *result = g_strdup(property->propName); 
     1077    smlTrace(TRACE_EXIT, "%s - %s", __func__, result); 
     1078    return result; 
     1079} 
     1080 
     1081char *smlDevInfPropertyGetParamName(const SmlDevInfProperty *property) 
     1082{ 
     1083    smlTrace(TRACE_ENTRY, "%s(%p)", __func__, property); 
     1084    smlAssert(property); 
     1085    char *result = g_strdup(property->paramName); 
    10601086    smlTrace(TRACE_EXIT, "%s - %s", __func__, result); 
    10611087    return result; 
  • trunk/libsyncml/sml_devinf.h

    r345 r347  
    126126                        SmlDevInfProperty *property, 
    127127                        const char *propName); 
     128void smlDevInfPropertySetParamName( 
     129                        SmlDevInfProperty *property, 
     130                        const char *paramName); 
    128131void smlDevInfPropertySetDataType( 
    129132                        SmlDevInfProperty *property, 
     
    148151 
    149152char *smlDevInfPropertyGetPropName(const SmlDevInfProperty *property); 
     153char *smlDevInfPropertyGetParamName(const SmlDevInfProperty *property); 
    150154char *smlDevInfPropertyGetDataType(const SmlDevInfProperty *property); 
    151155unsigned int smlDevInfPropertyGetMaxOccur(const SmlDevInfProperty *property); 
  • trunk/libsyncml/sml_devinf_internals.h

    r296 r347  
    7979struct SmlDevInfProperty { 
    8080        char *propName; 
     81        char *paramName; 
    8182        char *dataType; 
    8283        unsigned int maxOccur; 
  • trunk/tests/check_xml_parser.c

    r316 r347  
    15671567} 
    15681568END_TEST 
     1569 
     1570 
     1571START_TEST (check_parser_ctcap12_property_paramname) 
     1572{ 
     1573 
     1574        /* libsyncml ticket: #131 */ 
     1575        char *data = "<?xml version=\"1.0\"?><!DOCTYPE SyncML PUBLIC \"-//SYNCML//DTD SyncML 1.2//EN\" \"http://www.openmobilealliance.org/tech/DTD/OMA-TS-SyncML_RepPro_DTD-V1_2.dtd\"><SyncML xmlns=\"syncml:SYNCML1.2\"><SyncHdr><VerDTD>1.2</VerDTD><VerProto>SyncML/1.2</VerProto><SessionID>1</SessionID><MsgID>1</MsgID><Target><LocURI>PC Suite Data Sync</LocURI></Target><Source><LocURI>IMEI:............</LocURI></Source><Meta><MaxMsgSize xmlns=\"syncml:metinf\">8000</MaxMsgSize></Meta></SyncHdr><SyncBody><Status><CmdID>1</CmdID><MsgRef>1</MsgRef><CmdRef>0</CmdRef><Cmd>SyncHdr</Cmd><TargetRef>/</TargetRef><SourceRef>PC Suite Data Sync</SourceRef><Data>200</Data></Status><Status><CmdID>2</CmdID><MsgRef>1</MsgRef><CmdRef>1</CmdRef><Cmd>Alert</Cmd><SourceRef>Contacts</SourceRef><Data>200</Data></Status><Put><CmdID>3</CmdID><Meta><Type xmlns=\"syncml:metinf\">application/vnd.syncml-devinf+xml</Type></Meta><Item><Source><LocURI>./devinf12</LocURI></Source><Data><DevInf xmlns=\"syncml:devinf\"><VerDTD>1.2</VerDTD><Man>Nokia</Man><Mod>Nokia 6555b</Mod><FwV>V 03.31\n01-08-07\nRM-289\n(c) N..</FwV><SwV>V 03.31\n01-08-07\nRM-289\n(c) N..</SwV><HwV>5005</HwV><DevID>IMEI:..............</DevID><DevTyp>phone</DevTyp><SupportLargeObjs/><SupportNumberOfChanges/><DataStore><SourceRef>/telecom/pb.vcf</SourceRef><MaxGUIDSize>8</MaxGUIDSize><Rx-Pref><CTType>text/x-vcard</CTType><VerCT>2.1</VerCT></Rx-Pref><Tx-Pref><CTType>text/x-vcard</CTType><VerCT>2.1</VerCT></Tx-Pref><SyncCap><SyncType>1</SyncType><SyncType>2</SyncType><SyncType>4</SyncType><SyncType>6</SyncType><SyncType>7</SyncType></SyncCap><CTCap><CTType>text/x-vcard</CTType><VerCT>2.1</VerCT><Property><PropName>BEGIN</PropName><ValEnum>VCARD</ValEnum></Property><Property><PropName>END</PropName><ValEnum>VCARD</ValEnum></Property><Property><PropName>N</PropName></Property><Property><PropName>FN</PropName></Property><Property><PropName>TEL</PropName><ParamName>PREF</ParamName><ParamName>WORK</ParamName><ParamName>HOME</ParamName><ParamName>VOICE</ParamName><ParamName>FAX</ParamName><ParamName>CELL</ParamName><ParamName>VIDEO</ParamName><ParamName>POC</ParamName></Property><Property><PropName>NOTE</PropName></Property><Property><PropName>URL</PropName></Property><Property><PropName>EMAIL</PropName></Property><Property><PropName>ADR</PropName></Property><Property><PropName>PHOTO</PropName></Property><Property><PropName>BDAY</PropName></Property><Property><PropName>TITLE</PropName></Property><Property><PropName>ORG</PropName></Property><Property><PropName>X-NICKNAME</PropName></Property><Property><PropName>X-SIP</PropName></Property><Property><PropName>X-WV-ID</PropName></Property></CTCap></DataStore><DataStore><SourceRef>/telecom/cal.vcs</SourceRef><MaxGUIDSize>8</MaxGUIDSize><Rx-Pref><CTType>text/x-vcalendar</CTType><VerCT>1.0</VerCT></Rx-Pref><Tx-Pref><CTType>text/x-vcalendar</CTType><VerCT>1.0</VerCT></Tx-Pref><SyncCap><SyncType>1</SyncType><SyncType>2</SyncType><SyncType>4</SyncType><SyncType>6</SyncType><SyncType>7</SyncType></SyncCap><CTCap><CTType>text/x-vcalendar</CTType><VerCT>1.0</VerCT><Property><PropName>BEGIN</PropName><ValEnum>VCALENDAR</ValEnum><ValEnum>VEVENT</ValEnum><ValEnum>VTODO</ValEnum></Property><Property><PropName>END</PropName><ValEnum>VCALENDAR</ValEnum><ValEnum>VEVENT</ValEnum><ValEnum>VTODO</ValEnum></Property><Property><PropName>DTSTART</PropName></Property><Property><PropName>DTEND</PropName></Property><Property><PropName>SUMMARY</PropName></Property><Property><PropName>DESCRIPTION</PropName></Property><Property><PropName>DUE</PropName></Property><Property><PropName>AALARM</PropName></Property><Property><PropName>DALARM</PropName></Property><Property><PropName>RRULE</PropName></Property><Property><PropName>CATEGORIES</PropName><ParamName>SPECIAL OCCASION</ParamName><ParamName>MEETING</ParamName><ParamName>PHONE CALL</ParamName><ParamName>MISCELLANEOUS</ParamName><ParamName>REMINDER</ParamName></Property><Property><PropName>LOCATION</PropName></Property><Property><PropName>STATUS</PropName><ParamName>NEEDS ACTION</ParamName><ParamName>COMPLETED</ParamName></Property><Property><PropName>PRIORITY</PropName><ParamName>1</ParamName><ParamName>2</ParamName><ParamName>3</ParamName></Property><Property><PropName>EXDATE</PropName></Property></CTCap></DataStore><DataStore><SourceRef>/telecom/note.txt</SourceRef><MaxGUIDSize>8</MaxGUIDSize><Rx-Pref><CTType>text/plain</CTType><VerCT/></Rx-Pref><Tx-Pref><CTType>text/plain</CTType><VerCT/></Tx-Pref><SyncCap><SyncType>1</SyncType><SyncType>2</SyncType><SyncType>4</SyncType><SyncType>6</SyncType><SyncType>7</SyncType></SyncCap><CTCap><CTType>text/plain</CTType><VerCT/><Property><PropName/><DataType>chr</DataType><Size>3000</Size></Property></CTCap></DataStore></DevInf></Data></Item></Put><Get><CmdID>4</CmdID><Meta><Type xmlns=\"syncml:metinf\">application/vnd.syncml-devinf+xml</Type></Meta><Item><Target><LocURI>./devinf12</LocURI></Target></Item></Get><Alert><CmdID>5</CmdID><Data>201</Data><Item><Target><LocURI>Contacts</LocURI></Target><Source><LocURI>/telecom/pb.vcf</LocURI></Source><Meta><Anchor xmlns=\"syncml:metinf\"><Last>0</Last><Next>92</Next></Anchor></Meta></Item></Alert><Final/></SyncBody></SyncML>"; 
     1576 
     1577        SmlParser *parser = start_parser(data); 
     1578        fail_unless(parser != NULL, NULL); 
     1579         
     1580        SmlError *error = NULL; 
     1581        SmlHeader *header = NULL; 
     1582        SmlCred *cred = NULL; 
     1583         
     1584        fail_unless(smlParserGetHeader(parser, &header, &cred, &error), NULL); 
     1585        fail_unless(header != NULL, NULL); 
     1586        fail_unless(cred == NULL, NULL); 
     1587        fail_unless(error == NULL, NULL); 
     1588         
     1589        fail_unless(header->messageID == 1, NULL); 
     1590        smlHeaderFree(header); 
     1591         
     1592        SmlStatus *status = NULL; 
     1593        fail_unless(smlParserGetStatus(parser, &status, &error), NULL); 
     1594        fail_unless(status != NULL, NULL); 
     1595        fail_unless(error == NULL, NULL); 
     1596         
     1597        fail_unless(smlParserGetStatus(parser, &status, &error), NULL); 
     1598        fail_unless(status != NULL, NULL); 
     1599        fail_unless(error == NULL, NULL); 
     1600 
     1601        SmlCommand *cmd = NULL; fail_unless(smlParserGetCommand(parser, &cmd, &error) == SML_PARSER_RESULT_NORMAL, NULL); 
     1602        fail_unless(cmd != NULL, NULL); 
     1603        fail_unless(error == NULL, NULL); 
     1604        fail_unless(cmd->cmdID == 3, NULL); 
     1605        fail_unless(cmd->type == SML_COMMAND_TYPE_PUT, NULL); 
     1606        fail_unless(cmd->private.access.item != NULL, NULL); 
     1607         
     1608        char *buffer = NULL; 
     1609        unsigned int size = 0; 
     1610        fail_unless(smlItemGetData(cmd->private.access.item, &buffer, &size, &error), NULL); 
     1611        fail_unless(error == NULL, NULL); 
     1612         
     1613        SmlDevInf *devinf = smlDevInfParse(buffer, size, &error); 
     1614        fail_unless(devinf != NULL, NULL); 
     1615        fail_unless(error == NULL, NULL); 
     1616        smlDevInfUnref(devinf); 
     1617         
     1618        smlCommandUnref(cmd); 
     1619         
     1620        fail_unless(smlParserGetCommand(parser, &cmd, &error) == SML_PARSER_RESULT_NORMAL, NULL); 
     1621        fail_unless(cmd != NULL, NULL); 
     1622        fail_unless(error == NULL, NULL); 
     1623         
     1624        smlCommandUnref(cmd); 
     1625         
     1626        fail_unless(smlParserGetCommand(parser, &cmd, &error) == SML_PARSER_RESULT_NORMAL, NULL); 
     1627        fail_unless(cmd != NULL, NULL); 
     1628        fail_unless(error == NULL, NULL); 
     1629 
     1630        SmlBool final = FALSE; 
     1631        SmlBool end = TRUE; 
     1632        fail_unless(smlParserEnd(parser, &final, &end, &error), NULL); 
     1633        fail_unless(error == NULL, NULL); 
     1634        fail_unless(final == TRUE, NULL); 
     1635        fail_unless(end == FALSE, NULL); 
     1636         
     1637        smlParserFree(parser); 
     1638} 
     1639END_TEST 
     1640 
    15691641 
    15701642Suite *parser_suite(void) 
     
    16181690        create_case(s, "check_parser_ctcap_property_size", check_parser_ctcap_property_size); 
    16191691        create_case(s, "check_parser_ctcap11_size", check_parser_ctcap11_size); 
     1692        create_case(s, "check_parser_ctcap12_property_paramname", check_parser_ctcap12_property_paramname); 
    16201693         
    16211694        return s;