]> sjero.net Git - linphone/blobdiff - coreapi/sal_eXosip2.c
fix publish request, whose request uri must identify the resources for which the...
[linphone] / coreapi / sal_eXosip2.c
index 1777c0d42cf07c28cecce35cf4cf7b3da0433b9d..e577b6422ad43b4de8802e232456eae23eb7c477 100644 (file)
@@ -1771,6 +1771,26 @@ static bool_t comes_from_local_if(osip_message_t *msg){
 static const char *days[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};\r
 static const char *months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};\r
 \r
+static int utc_offset() {\r
+       time_t ref = 24 * 60 * 60L;\r
+       struct tm * timeptr;\r
+       int gmtime_hours;\r
+\r
+       /* get the local reference time for Jan 2, 1900 00:00 UTC */\r
+       timeptr = localtime(&ref);\r
+       gmtime_hours = timeptr->tm_hour;\r
+\r
+       /* if the local time is the "day before" the UTC, subtract 24 hours\r
+       from the hours to get the UTC offset */\r
+       if (timeptr->tm_mday < 2) gmtime_hours -= 24;\r
+\r
+       return gmtime_hours;\r
+}\r
+\r
+time_t mktime_utc(struct tm *timeptr) {\r
+       return mktime(timeptr) + utc_offset() * 3600;\r
+}\r
+\r
 static void text_received(Sal *sal, eXosip_event_t *ev){\r
        osip_body_t *body=NULL;\r
        char *from=NULL,*msg=NULL;\r
@@ -1798,9 +1818,9 @@ static void text_received(Sal *sal, eXosip_event_t *ev){
                for(j=0;j<12;j++) { \r
                        if(strcmp(tmp2,months[j])==0) ret.tm_mon=j; \r
                }\r
+               ret.tm_isdst=0;\r
        }else ms_warning("No date header in SIP MESSAGE, we don't know when it was sent.");\r
        \r
-       \r
        content_type= osip_message_get_content_type(ev->request);\r
        if (!content_type) {\r
                ms_error("Could not get message because no content type");\r
@@ -1842,14 +1862,12 @@ static void text_received(Sal *sal, eXosip_event_t *ev){
        salmsg.text=msg;\r
        salmsg.url=external_body_size>0 ? unquoted_external_body_url : NULL;\r
        salmsg.message_id=message_id;\r
-       salmsg.time=date!=NULL ? mktime(&ret) : time(NULL);\r
+       salmsg.time=date!=NULL ? mktime_utc(&ret) : time(NULL);\r
        sal->callbacks.text_received(op,&salmsg);\r
        sal_op_release(op);\r
        osip_free(from);\r
 }\r
 \r
-\r
-\r
 static void other_request(Sal *sal, eXosip_event_t *ev){\r
        ms_message("in other_request");\r
        if (ev->request==NULL) return;\r
@@ -2299,7 +2317,7 @@ static void register_set_contact(osip_message_t *msg, const char *contact){
        osip_uri_uparam_add(ct->url,osip_strdup("line"),line);\r
 }\r
 \r
-static void sal_register_add_route(osip_message_t *msg, const char *proxy){\r
+void sal_message_add_route(osip_message_t *msg, const char *proxy){\r
        osip_route_t *route;\r
 \r
        osip_list_special_free(&msg->routes,(void (*)(void*))osip_route_free);\r
@@ -2346,7 +2364,7 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){
                h->rid=eXosip_register_build_initial_register(from,domain,NULL,expires,&msg);\r
                if (msg){\r
                        if (contact) register_set_contact(msg,contact);\r
-                       sal_register_add_route(msg,proxy);\r
+                       sal_message_add_route(msg,proxy);\r
                        sal_add_register(h->base.root,h);\r
                }else{\r
                        ms_error("Could not build initial register.");\r
@@ -2356,7 +2374,7 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){
        }else{\r
                eXosip_lock();\r
                eXosip_register_build_register(h->rid,expires,&msg);\r
-               sal_register_add_route(msg,proxy);\r
+               sal_message_add_route(msg,proxy);\r
        }\r
        if (msg){\r
                eXosip_register_send_register(h->rid,msg);\r
@@ -2394,7 +2412,7 @@ int sal_register_refresh(SalOp *op, int expires){
        eXosip_register_build_register(op->rid,expires,&msg);\r
        if (msg!=NULL){\r
                if (contact) register_set_contact(msg,contact);\r
-               sal_register_add_route(msg,sal_op_get_route(op));\r
+               sal_message_add_route(msg,sal_op_get_route(op));\r
                eXosip_register_send_register(op->rid,msg);\r
        }else ms_error("Could not build REGISTER refresh message.");\r
        eXosip_unlock();\r