]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
issue #7608: Notifications with wrong content-type. Reported by jsiddall.
authorOlle Johansson <oej@edvina.net>
Sun, 29 Oct 2006 19:00:27 +0000 (19:00 +0000)
committerOlle Johansson <oej@edvina.net>
Sun, 29 Oct 2006 19:00:27 +0000 (19:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@46402 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index c2063bb8d958624dceb27a90c69fb1b3996702c9..2e97b20050975f4029ccfcb71ee9c6b31a5d8d97 100644 (file)
@@ -159,7 +159,6 @@ static const char notify_config[] = "sip_notify.conf";
 
 enum subscriptiontype { 
        NONE = 0,
-       TIMEOUT,
        XPIDF_XML,
        DIALOG_INFO_XML,
        CPIM_PIDF_XML,
@@ -930,7 +929,7 @@ static void append_date(struct sip_request *req);   /* Append date to SIP packet *
 static int determine_firstline_parts(struct sip_request *req);
 static void sip_dump_history(struct sip_pvt *dialog);  /* Dump history to LOG_DEBUG at end of dialog, before destroying data */
 static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
-static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate);
+static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate, int timeout);
 static char *gettag(struct sip_request *req, char *header, char *tagbuf, int tagbufsize);
 
 /*! \brief Definition of this channel for PBX channel registration */
@@ -1321,8 +1320,7 @@ static int __sip_autodestruct(void *data)
 
        /* If this is a subscription, tell the phone that we got a timeout */
        if (p->subscribed) {
-               p->subscribed = TIMEOUT;
-               transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, 1);      /* Send first notification */
+               transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, 1, 1);   /* Send first notification */
                p->subscribed = NONE;
                append_history(p, "Subscribestatus", "timeout");
                return 10000;   /* Reschedule this destruction so that we know that it's gone */
@@ -5114,7 +5112,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
 }
 
 /*! \brief  transmit_state_notify: Used in the SUBSCRIBE notification subsystem ----*/
-static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate)
+static int transmit_state_notify(struct sip_pvt *p, int state, int full, int substate, int timeout)
 {
        char tmp[4000], from[256], to[256];
        char *t = tmp, *c, *a, *mfrom, *mto;
@@ -5210,7 +5208,7 @@ static int transmit_state_notify(struct sip_pvt *p, int state, int full, int sub
        add_header(&req, "Content-Type", subscriptiontype->mediatype);
        switch(state) {
        case AST_EXTENSION_DEACTIVATED:
-               if (p->subscribed == TIMEOUT)
+               if (timeout)
                        add_header(&req, "Subscription-State", "terminated;reason=timeout");
                else {
                        add_header(&req, "Subscription-State", "terminated;reason=probation");
@@ -6500,7 +6498,7 @@ static int cb_extensionstate(char *context, char* exten, int state, void *data)
                p->laststate = state;
                break;
        }
-       transmit_state_notify(p, state, 1, 1);
+       transmit_state_notify(p, state, 1, 1, 0);
 
        if (option_verbose > 1)
                ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
@@ -11098,7 +11096,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
                        struct sip_pvt *p_old;
 
                        transmit_response(p, "200 OK", req);
-                       transmit_state_notify(p, firststate, 1, 1);     /* Send first notification */
+                       transmit_state_notify(p, firststate, 1, 1, 0);  /* Send first notification */
                        append_history(p, "Subscribestatus", ast_extension_state2str(firststate));
 
                        /* remove any old subscription from this peer for the same exten/context,