Changeset 2149 for pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
- Timestamp:
- Jul 17, 2008 1:53:41 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
r2147 r2149 222 222 pjsip_evsub_state dst_state; /**< Pending state to be set. */ 223 223 pj_str_t dst_state_str;/**< Pending state to be set. */ 224 pj_str_t term_reason; /**< Termination reason. */ 224 225 pjsip_method method; /**< Method that established subscr.*/ 225 226 pjsip_event_hdr *event; /**< Event description. */ … … 551 552 */ 552 553 static void set_state( pjsip_evsub *sub, pjsip_evsub_state state, 553 const pj_str_t *state_str, pjsip_event *event) 554 const pj_str_t *state_str, pjsip_event *event, 555 const pj_str_t *reason) 554 556 { 555 557 pjsip_evsub_state prev_state = sub->state; … … 562 564 else 563 565 sub->state_str = evsub_state_names[state]; 566 567 if (reason && sub->term_reason.slen==0) 568 pj_strdup(sub->pool, &sub->term_reason, reason); 564 569 565 570 PJ_LOG(4,(sub->obj_name, … … 639 644 case TIMER_TYPE_UAC_TERMINATE: 640 645 { 646 pj_str_t timeout = {"timeout", 7}; 647 641 648 PJ_LOG(5,(sub->obj_name, "Timeout waiting for final NOTIFY. " 642 649 "Terminating..")); 643 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL); 650 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL, 651 &timeout); 644 652 } 645 653 break; … … 913 921 914 922 sub->call_cb = notify; 915 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL );923 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL, NULL); 916 924 917 925 pjsip_dlg_dec_lock(sub->dlg); … … 935 943 } 936 944 945 /* 946 * Get termination reason. 947 */ 948 PJ_DEF(const pj_str_t*) pjsip_evsub_get_termination_reason(pjsip_evsub *sub) 949 { 950 return &sub->term_reason; 951 } 937 952 938 953 /* … … 1086 1101 case PJSIP_EVSUB_STATE_NULL: 1087 1102 case PJSIP_EVSUB_STATE_SENT: 1088 case PJSIP_EVSUB_STATE_ACCEPTED:1089 1103 pj_assert(!"Invalid state!"); 1090 1104 /* Treat as pending */ 1091 1105 1106 case PJSIP_EVSUB_STATE_ACCEPTED: 1092 1107 case PJSIP_EVSUB_STATE_PENDING: 1093 1108 sub_state->sub_state = STR_PENDING; … … 1156 1171 pjsip_auth_clt_init_req( &sub->dlg->auth_sess, tdata ); 1157 1172 1158 1173 /* Update reason */ 1174 if (reason) 1175 pj_strdup(sub->dlg->pool, &sub->term_reason, reason); 1159 1176 1160 1177 /* Save destination state. */ … … 1219 1236 set_state(sub, sub->dst_state, 1220 1237 (sub->dst_state_str.slen ? &sub->dst_state_str : NULL), 1221 NULL );1238 NULL, NULL); 1222 1239 1223 1240 sub->dst_state = PJSIP_EVSUB_STATE_NULL; … … 1547 1564 tsx->state == PJSIP_TSX_STATE_CALLING) 1548 1565 { 1549 set_state(sub, PJSIP_EVSUB_STATE_SENT, NULL, event );1566 set_state(sub, PJSIP_EVSUB_STATE_SENT, NULL, event, NULL); 1550 1567 return; 1551 1568 } … … 1588 1605 /* Authentication failed! */ 1589 1606 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, 1590 NULL, 1591 event); 1607 NULL, event, &tsx->status_text); 1592 1608 return; 1593 1609 } … … 1647 1663 pj_assert(sub->state != PJSIP_EVSUB_STATE_NULL); 1648 1664 if (sub->state == PJSIP_EVSUB_STATE_SENT) { 1649 set_state(sub, PJSIP_EVSUB_STATE_ACCEPTED, NULL, event );1665 set_state(sub, PJSIP_EVSUB_STATE_ACCEPTED, NULL, event, NULL); 1650 1666 } 1651 1667 … … 1686 1702 /* Set state to TERMINATED */ 1687 1703 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, 1688 NULL, event );1704 NULL, event, &tsx->status_text); 1689 1705 1690 1706 } … … 1772 1788 set_timer(sub, TIMER_TYPE_UAC_WAIT_NOTIFY, timeout); 1773 1789 } else { 1774 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL); 1790 char errmsg[PJ_ERR_MSG_SIZE]; 1791 pj_str_t reason; 1792 1793 reason = pj_strerror(status, errmsg, sizeof(errmsg)); 1794 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL, 1795 &reason); 1775 1796 } 1776 1797 … … 1816 1837 /* Set the state */ 1817 1838 if (status == PJ_SUCCESS) { 1818 set_state(sub, new_state, new_state_str, event); 1839 set_state(sub, new_state, new_state_str, event, 1840 &sub_state->reason_param); 1819 1841 } else { 1820 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event); 1842 char errmsg[PJ_ERR_MSG_SIZE]; 1843 pj_str_t reason; 1844 1845 reason = pj_strerror(status, errmsg, sizeof(errmsg)); 1846 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event, 1847 &reason); 1821 1848 } 1822 1849 … … 1859 1886 pjsip_evsub_state old_state; 1860 1887 pj_str_t old_state_str; 1888 pj_str_t reason = { NULL, 0 }; 1861 1889 pj_status_t status; 1862 1890 … … 1945 1973 1946 1974 if (sub->expires->ivalue == 0) { 1947 set_state(sub, sub->state, NULL, event );1975 set_state(sub, sub->state, NULL, event, &reason); 1948 1976 } else if (sub->state == PJSIP_EVSUB_STATE_NULL) { 1949 set_state(sub, sub->state, NULL, event );1977 set_state(sub, sub->state, NULL, event, &reason); 1950 1978 } 1951 1979 … … 1981 2009 if (status != PJ_SUCCESS) { 1982 2010 /* Can't authenticate. Terminate session (?) */ 1983 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL); 2011 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, NULL, 2012 &tsx->status_text); 1984 2013 return; 1985 2014 } … … 1994 2023 tsx->status_code/100 == 7)) 1995 2024 { 1996 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event); 2025 set_state(sub, PJSIP_EVSUB_STATE_TERMINATED, NULL, event, 2026 &tsx->status_text); 1997 2027 return; 1998 2028 }
Note: See TracChangeset
for help on using the changeset viewer.