Changeset 4172 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
- Timestamp:
- Jun 19, 2012 2:35:18 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r3841 r4172 2012 2012 }; 2013 2013 2014 void pjsua_start_mwi(pjsua_acc *acc) 2015 { 2014 pj_status_t pjsua_start_mwi(pjsua_acc_id acc_id, pj_bool_t force_renew) 2015 { 2016 pjsua_acc *acc; 2016 2017 pj_pool_t *tmp_pool = NULL; 2017 2018 pj_str_t contact; 2018 2019 pjsip_tx_data *tdata; 2019 pj_status_t status; 2020 pj_status_t status = PJ_SUCCESS; 2021 2022 PJ_ASSERT_RETURN(acc_id>=0 && acc_id<(int)PJ_ARRAY_SIZE(pjsua_var.acc) 2023 && pjsua_var.acc[acc_id].valid, PJ_EINVAL); 2024 2025 acc = &pjsua_var.acc[acc_id]; 2020 2026 2021 2027 if (!acc->cfg.mwi_enabled) { 2022 2028 if (acc->mwi_sub) { 2023 2029 /* Terminate MWI subscription */ 2024 pjsip_tx_data *tdata;2025 2030 pjsip_evsub *sub = acc->mwi_sub; 2026 2031 … … 2036 2041 } 2037 2042 } 2038 return; 2039 } 2040 2043 return status; 2044 } 2045 2046 /* Subscription is already active */ 2041 2047 if (acc->mwi_sub) { 2042 /* Subscription is already active */ 2043 return; 2044 2048 if (!force_renew) 2049 return PJ_SUCCESS; 2050 2051 /* Update MWI subscription */ 2052 pj_assert(acc->mwi_dlg); 2053 pjsip_dlg_inc_lock(acc->mwi_dlg); 2054 2055 status = pjsip_mwi_initiate(acc->mwi_sub, acc->cfg.mwi_expires, &tdata); 2056 if (status == PJ_SUCCESS) { 2057 pjsua_process_msg_data(tdata, NULL); 2058 status = pjsip_pres_send_request(acc->mwi_sub, tdata); 2059 } 2060 2061 pjsip_dlg_dec_lock(acc->mwi_dlg); 2062 return status; 2045 2063 } 2046 2064 … … 2060 2078 pjsua_perror(THIS_FILE, "Unable to generate Contact header", 2061 2079 status); 2062 pj_pool_release(tmp_pool); 2063 pj_log_pop_indent(); 2064 return; 2080 goto on_return; 2065 2081 } 2066 2082 } … … 2074 2090 if (status != PJ_SUCCESS) { 2075 2091 pjsua_perror(THIS_FILE, "Unable to create dialog", status); 2076 if (tmp_pool) pj_pool_release(tmp_pool); 2077 pj_log_pop_indent(); 2078 return; 2092 goto on_return; 2079 2093 } 2080 2094 … … 2089 2103 if (status != PJ_SUCCESS) { 2090 2104 pjsua_perror(THIS_FILE, "Error creating MWI subscription", status); 2091 if (tmp_pool) pj_pool_release(tmp_pool);2092 2105 if (acc->mwi_dlg) pjsip_dlg_dec_lock(acc->mwi_dlg); 2093 pj_log_pop_indent(); 2094 return; 2106 goto on_return; 2095 2107 } 2096 2108 … … 2121 2133 pjsip_evsub_set_mod_data(acc->mwi_sub, pjsua_var.mod.id, acc); 2122 2134 2123 status = pjsip_mwi_initiate(acc->mwi_sub, -1, &tdata);2135 status = pjsip_mwi_initiate(acc->mwi_sub, acc->cfg.mwi_expires, &tdata); 2124 2136 if (status != PJ_SUCCESS) { 2125 2137 if (acc->mwi_dlg) pjsip_dlg_dec_lock(acc->mwi_dlg); … … 2131 2143 pjsua_perror(THIS_FILE, "Unable to create initial MWI SUBSCRIBE", 2132 2144 status); 2133 if (tmp_pool) pj_pool_release(tmp_pool); 2134 pj_log_pop_indent(); 2135 return; 2145 goto on_return; 2136 2146 } 2137 2147 … … 2148 2158 pjsua_perror(THIS_FILE, "Unable to send initial MWI SUBSCRIBE", 2149 2159 status); 2150 if (tmp_pool) pj_pool_release(tmp_pool); 2151 pj_log_pop_indent(); 2152 return; 2160 goto on_return; 2153 2161 } 2154 2162 2155 2163 pjsip_dlg_dec_lock(acc->mwi_dlg); 2164 2165 on_return: 2156 2166 if (tmp_pool) pj_pool_release(tmp_pool); 2157 2167 2158 2168 pj_log_pop_indent(); 2169 return status; 2159 2170 } 2160 2171 … … 2270 2281 /* Re-subscribe MWI subscription if it's terminated prematurely */ 2271 2282 if (acc->cfg.mwi_enabled && !acc->mwi_sub) 2272 pjsua_start_mwi(acc );2283 pjsua_start_mwi(acc->index, PJ_FALSE); 2273 2284 } 2274 2285
Note: See TracChangeset
for help on using the changeset viewer.