]> sjero.net Git - linphone/blobdiff - coreapi/presence.c
Set UTC time in received chat messages.
[linphone] / coreapi / presence.c
index 0ff498ff7a830d7a2f28fab754a80d0e8fb86039..ca63572588c764cfcde05fa5b7ff39f8d6e13cc9 100644 (file)
@@ -31,9 +31,9 @@ void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalO
        linphone_friend_set_inc_subscribe_policy(fl,LinphoneSPAccept);
        fl->inc_subscribe_pending=TRUE;
        lc->subscribers=ms_list_append(lc->subscribers,(void *)fl);
-       if (lc->vtable.new_unknown_subscriber!=NULL) {
+       if (lc->vtable.new_subscription_request!=NULL) {
                char *tmp=linphone_address_as_string(fl->uri);
-               lc->vtable.new_unknown_subscriber(lc,fl,tmp);
+               lc->vtable.new_subscription_request(lc,fl,tmp);
                ms_free(tmp);
        }
 }
@@ -57,11 +57,24 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
        LinphoneFriend *lf=NULL;
        char *tmp;
        LinphoneAddress *uri;
+       LinphoneProxyConfig *cfg;
+       const char *fixed_contact;
        
        uri=linphone_address_new(from);
        linphone_address_clean(uri);
        tmp=linphone_address_as_string(uri);
        ms_message("Receiving new subscription from %s.",from);
+
+       cfg=linphone_core_lookup_known_proxy(lc,uri);
+       if (cfg!=NULL){
+               if (cfg->op){
+                       fixed_contact=sal_op_get_contact(cfg->op);
+                       if (fixed_contact) {
+                               sal_op_set_contact (op,fixed_contact);
+                               ms_message("Contact for next subscribe answer has been fixed using proxy to %s",fixed_contact);
+                       }
+               }
+       }
        /* check if we answer to this subscription */
        if (linphone_find_friend(lc->friends,uri,&lf)!=NULL){
                lf->insub=op;
@@ -84,43 +97,44 @@ void linphone_subscription_new(LinphoneCore *lc, SalOp *op, const char *from){
                        linphone_core_add_subscriber(lc,tmp,op);
                }
        }
+       linphone_address_destroy(uri);
        ms_free(tmp);
 }
 
-void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeState ss, SalPresenceStatus sal_status){
+void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeStatus ss, SalPresenceStatus sal_status){
        char *tmp;
        LinphoneFriend *lf;
        LinphoneAddress *friend=NULL;
-       LinphoneOnlineStatus estatus=LINPHONE_STATUS_OFFLINE;
+       LinphoneOnlineStatus estatus=LinphoneStatusOffline;
        
        switch(sal_status){
                case SalPresenceOffline:
-                       estatus=LINPHONE_STATUS_OFFLINE;
+                       estatus=LinphoneStatusOffline;
                break;
                case SalPresenceOnline:
-                       estatus=LINPHONE_STATUS_ONLINE;
+                       estatus=LinphoneStatusOnline;
                break;
                case SalPresenceBusy:
-                       estatus=LINPHONE_STATUS_BUSY;
+                       estatus=LinphoneStatusBusy;
                break;
                case SalPresenceBerightback:
-                       estatus=LINPHONE_STATUS_AWAY;
+                       estatus=LinphoneStatusBeRightBack;
                break;
                case SalPresenceAway:
-                       estatus=LINPHONE_STATUS_AWAY;
+                       estatus=LinphoneStatusAway;
                break;
                case SalPresenceOnthephone:
-                       estatus=LINPHONE_STATUS_ONTHEPHONE;
+                       estatus=LinphoneStatusOnThePhone;
                break;
                case SalPresenceOuttolunch:
-                       estatus=LINPHONE_STATUS_OUTTOLUNCH;
+                       estatus=LinphoneStatusOutToLunch;
                break;
                case SalPresenceDonotdisturb:
-                       estatus=LINPHONE_STATUS_BUSY;
+                       estatus=LinphoneStatusDoNotDisturb;
                break;
                case SalPresenceMoved:
                case SalPresenceAltService:
-                       estatus=LINPHONE_STATUS_AWAY;
+                       estatus=LinphoneStatusMoved;
                break;
        }
        lf=linphone_find_friend_by_out_subscribe(lc->friends,op);
@@ -128,15 +142,19 @@ void linphone_notify_recv(LinphoneCore *lc, SalOp *op, SalSubscribeState ss, Sal
                friend=lf->uri;
                tmp=linphone_address_as_string(friend);
                lf->status=estatus;
-               lc->vtable.notify_recv(lc,(LinphoneFriend*)lf);
+               lf->subscribe_active=TRUE;
+               if (lc->vtable.notify_presence_recv)
+                       lc->vtable.notify_presence_recv(lc,(LinphoneFriend*)lf);
                ms_free(tmp);
        }else{
                ms_message("But this person is not part of our friend list, so we don't care.");
        }
        if (ss==SalSubscribeTerminated){
                sal_op_release(op);
-               if (lf)
+               if (lf){
                        lf->outsub=NULL;
+                       lf->subscribe_active=FALSE;
+               }
        }
 }