- Timestamp:
- Jun 19, 2012 2:35:18 PM (12 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_config.h
r4094 r4172 995 995 996 996 997 /** 998 * Specify the default expiration time for Message Waiting Indication 999 * (RFC 3842) event subscription, for both client and server subscription. 1000 * For client subscription, application can override this by specifying 1001 * positive non-zero value in "expires" parameter when calling 1002 * #pjsip_mwi_initiate(). For server subscription, we would take the 1003 * expiration value from the Expires header sent by client in the SUBSCRIBE 1004 * request if the header exists and its value is less than this setting, 1005 * otherwise this setting will be used. 1006 * 1007 * Default: 3600 seconds 1008 */ 1009 #ifndef PJSIP_MWI_DEFAULT_EXPIRES 1010 # define PJSIP_MWI_DEFAULT_EXPIRES 3600 1011 #endif 1012 1013 997 1014 PJ_END_DECL 998 1015 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r4164 r4172 2616 2616 2617 2617 /** 2618 * Specify the default expiration time for Message Waiting Indication 2619 * (RFC 3842) event subscription. This must not be zero. 2620 * 2621 * Default: PJSIP_MWI_DEFAULT_EXPIRES 2622 */ 2623 unsigned mwi_expires; 2624 2625 /** 2618 2626 * If this flag is set, the presence information of this account will 2619 2627 * be PUBLISH-ed to the server where the account belongs. -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r4145 r4172 671 671 * Start MWI subscription 672 672 */ 673 void pjsua_start_mwi(pjsua_acc *acc);673 pj_status_t pjsua_start_mwi(pjsua_acc_id acc_id, pj_bool_t force_renew); 674 674 675 675 /** -
pjproject/trunk/pjsip/src/pjsip-simple/mwi.c
r3553 r4172 33 33 34 34 #define THIS_FILE "mwi.c" 35 #define MWI_DEFAULT_EXPIRES 360036 35 37 36 /* … … 139 138 /* Register event package to event module. */ 140 139 status = pjsip_evsub_register_pkg( &mod_mwi, &STR_MWI, 141 MWI_DEFAULT_EXPIRES,140 PJSIP_MWI_DEFAULT_EXPIRES, 142 141 PJ_ARRAY_SIZE(accept), accept); 143 142 if (status != PJ_SUCCESS) { -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
r4155 r4172 470 470 /* Otherwise subscribe to MWI, if it's enabled */ 471 471 if (pjsua_var.acc[id].cfg.mwi_enabled) 472 pjsua_start_mwi( &pjsua_var.acc[id]);472 pjsua_start_mwi(id, PJ_TRUE); 473 473 } 474 474 … … 680 680 pj_bool_t update_reg = PJ_FALSE; 681 681 pj_bool_t unreg_first = PJ_FALSE; 682 pj_bool_t update_mwi = PJ_FALSE; 682 683 pj_status_t status = PJ_SUCCESS; 683 684 … … 839 840 840 841 /* MWI */ 841 acc->cfg.mwi_enabled = cfg->mwi_enabled; 842 if (acc->cfg.mwi_enabled != cfg->mwi_enabled) { 843 acc->cfg.mwi_enabled = cfg->mwi_enabled; 844 update_mwi = PJ_TRUE; 845 } 846 if (acc->cfg.mwi_expires != cfg->mwi_expires && cfg->mwi_expires > 0) { 847 acc->cfg.mwi_expires = cfg->mwi_expires; 848 update_mwi = PJ_TRUE; 849 } 842 850 843 851 /* PIDF tuple ID */ … … 1133 1141 if (acc->cfg.reg_uri.slen) 1134 1142 pjsua_acc_set_registration(acc->index, PJ_TRUE); 1135 else { 1136 /* Otherwise subscribe to MWI, if it's enabled */ 1137 if (acc->cfg.mwi_enabled) 1138 pjsua_start_mwi(acc); 1139 }1143 } 1144 1145 /* Update MWI subscription */ 1146 if (update_mwi) { 1147 pjsua_start_mwi(acc_id, PJ_TRUE); 1140 1148 } 1141 1149 … … 1876 1884 /* Subscribe to MWI, if it's enabled */ 1877 1885 if (acc->cfg.mwi_enabled) 1878 pjsua_start_mwi(acc );1886 pjsua_start_mwi(acc->index, PJ_FALSE); 1879 1887 } 1880 1888 -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r4154 r4172 238 238 cfg->call_hold_type = PJSUA_CALL_HOLD_TYPE_DEFAULT; 239 239 cfg->register_on_acc_add = PJ_TRUE; 240 cfg->mwi_expires = PJSIP_MWI_DEFAULT_EXPIRES; 240 241 } 241 242 -
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.