Changeset 415

Show
Ignore:
Timestamp:
03/14/08 15:25:16 (8 months ago)
Author:
bellmich
Message:

- target reset initiated on session end if RespURI was used
- error messages for ADD, REPLACE and DELETE are now handled more correctly

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libsyncml/objects/sml_devinf_obj.c

    r361 r415  
    271271void smlDevInfAgentSetDevInf(SmlDevInfAgent *agent, SmlDevInf *devinf) 
    272272{ 
     273        smlTrace(TRACE_ENTRY, "%s(%p, %p)", __func__, agent, devinf); 
    273274        smlAssert(agent); 
    274275        smlAssert(devinf); 
    275276        agent->recvDevInf = devinf; 
     277        smlTrace(TRACE_EXIT, "%s", __func__);    
    276278} 
    277279 
     
    279281SmlDevInf *smlDevInfAgentGetDevInf(SmlDevInfAgent *agent) 
    280282{ 
     283        smlTrace(TRACE_INTERNAL, "%s(%p)", __func__, agent); 
    281284        smlAssert(agent); 
    282285        return agent->recvDevInf; 
  • trunk/libsyncml/parser/sml_xml_parse.c

    r412 r415  
    18761876                                goto error_free_status; 
    18771877                } else if (!strcmp((char *)xmlTextReaderConstName(parser->reader), SML_ELEMENT_ITEM)) { 
    1878                         item = _smlItemParse(parser, NULL, SML_COMMAND_TYPE_ALERT, error); 
     1878                        /* Do not send SML_COMMAND_TYPE_ALERT 
     1879                         * because this can give trouble. 
     1880                         * Example: Error message for a failed ADD 
     1881                         */ 
     1882                        item = _smlItemParse(parser, NULL, (*status)->type, error); 
    18791883                        if (!item) 
    18801884                                goto error_free_status; 
     
    18941898                goto error_free_status; 
    18951899        } 
    1896          
    1897         if (item && (*status)->type != SML_COMMAND_TYPE_ALERT) { 
    1898                 smlErrorSet(error, SML_ERROR_GENERIC, "Got wrong item"); 
    1899                 smlItemUnref(item); 
    1900                 goto error_free_status; 
    1901         } 
    1902          
    1903         if (item && (*status)->type == SML_COMMAND_TYPE_ALERT) { 
    1904                 (*status)->anchor = item->anchor; 
    1905                 item->anchor = NULL; 
     1900 
     1901        if (item) 
     1902        { 
     1903                if ((*status)->type == SML_COMMAND_TYPE_ALERT) { 
     1904                        (*status)->anchor = item->anchor; 
     1905                        item->anchor = NULL; 
     1906                } else if ((*status)->type == SML_COMMAND_TYPE_ADD || 
     1907                           (*status)->type == SML_COMMAND_TYPE_REPLACE || 
     1908                           (*status)->type == SML_COMMAND_TYPE_DELETE) { 
     1909                        /* Usually Sync is commited at once or together with an anchor. 
     1910                         * If a single ADD, REPLACE or DELETE gets an item 
     1911                         * then there is something going wrong. 
     1912                         */ 
     1913                        g_warning("%s", xmlBufferContent(item->buffer)); 
     1914                } else { 
     1915                        smlErrorSet(error, SML_ERROR_GENERIC, "Got wrong item"); 
     1916                        smlItemUnref(item); 
     1917                        goto error_free_status; 
     1918                } 
    19061919                smlItemUnref(item); 
    19071920        } 
  • trunk/libsyncml/sml_session.c

    r412 r415  
    139139                smlTrace(TRACE_INTERNAL, "Ending session now"); 
    140140                session->end = TRUE; 
     141                smlSessionRestoreTargetURI(session); 
    141142                smlSessionDispatchEvent(session, SML_SESSION_EVENT_END, NULL, NULL, NULL, NULL); 
    142143        } 
     
    608609         * then the URI in the transport layer must be adjusted. */ 
    609610        if (header->responseURI) { 
    610                 SmlLocation *old = session->target; 
     611                if (!session->orgTarget) { 
     612                        /* If the original target is already set 
     613                         * then it MUST NOT be set again 
     614                         * because this would destroy the real original 
     615                         * target and an earlier RespURI would be used 
     616                         * as original target. 
     617                         */ 
     618                        session->orgTarget = session->target; 
     619                } 
     620 
     621                /* build the new target and publish it*/ 
    611622                session->target = smlLocationNew( 
    612623                                        header->responseURI, 
    613                                         smlLocationGetName(session->target), 
     624                                        smlLocationGetName(session->orgTarget), 
    614625                                        error); 
    615                 smlLocationUnref(old); 
    616626                if (!session->target) 
    617627                        goto error; 
    618628                smlSessionDispatchEvent(session, SML_SESSION_EVENT_RESPONSE_URI, NULL, NULL, NULL, NULL); 
     629                smlTrace(TRACE_INTERNAL, "%s: RespURI: %s, Target: %s", __func__, 
     630                        smlLocationGetURI(session->target), 
     631                        smlLocationGetURI(session->orgTarget)); 
    619632        } 
    620633        smlTrace(TRACE_EXIT, "%s", __func__); 
     
    12991312                 */ 
    13001313                if (!final || session->sessionType != SML_SESSION_TYPE_SERVER) 
     1314                { 
     1315                        smlSessionRestoreTargetURI(session); 
    13011316                        smlSessionDispatchEvent(session, SML_SESSION_EVENT_END, NULL, NULL, NULL, NULL); 
     1317                } 
    13021318        } 
    13031319 
     
    16571673                 */ 
    16581674                smlTrace(TRACE_INTERNAL, "%s: no status/command ... only sending event", __func__); 
     1675                smlSessionRestoreTargetURI(session); 
    16591676                smlSessionDispatchEvent(session, SML_SESSION_EVENT_END, NULL, NULL, NULL, NULL); 
    16601677        } 
     
    16661683        smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 
    16671684        return FALSE; 
     1685} 
     1686 
     1687void smlSessionRestoreTargetURI(SmlSession *session) 
     1688{ 
     1689        smlTrace(TRACE_ENTRY, "%s(%p)", __func__, session); 
     1690        smlAssert(session); 
     1691 
     1692        if (session->orgTarget) { 
     1693                /* Restore original target if RespURI was used. 
     1694                 * This is important if somebody re-use the transport layer. 
     1695                 * Example: Sometimes an OMA DS client needs two OMA DS sessions 
     1696                 *          to synchronize (e.g. OpenSync's SyncML plugin). 
     1697                 */ 
     1698                smlLocationUnref(session->target); 
     1699                session->target = session->orgTarget; 
     1700                session->orgTarget = NULL; 
     1701                smlSessionDispatchEvent(session, SML_SESSION_EVENT_RESPONSE_URI, NULL, NULL, NULL, NULL); 
     1702        } 
     1703 
     1704        smlTrace(TRACE_EXIT, "%s", __func__); 
    16681705} 
    16691706 
  • trunk/libsyncml/sml_session_internals.h

    r366 r415  
    4141         
    4242        SmlLocation *target; 
     43        SmlLocation *orgTarget; 
    4344        SmlLocation *source; 
    4445        SmlCred *cred; 
     
    9798void smlSessionUnlock(SmlSession *session); 
    9899 
     100void smlSessionRestoreTargetURI(SmlSession *session); 
     101 
    99102#endif //_SML_SESSION_INTERNALS_H_