Changeset 3068 for pjproject/trunk
- Timestamp:
- Jan 21, 2010 10:04:26 AM (15 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsip/sip_dialog.h
r2855 r3068 373 373 374 374 /** 375 * Check if the specified module has been registered as usage to the dialog. 376 * 377 * @param dlg The dialog. 378 * @param module The module. 379 * 380 * @return PJ_TRUE if the specified module is currently 381 * registered as a usage to the dialog. 382 */ 383 PJ_DECL(pj_bool_t) pjsip_dlg_has_usage(pjsip_dialog *dlg, 384 pjsip_module *module); 385 386 /** 375 387 * Attach module specific data to the dialog. Application can also set 376 388 * the value directly by accessing dlg->mod_data[module_id]. -
pjproject/trunk/pjsip/src/pjsip-simple/evsub.c
r2822 r3068 736 736 737 737 738 /* Create subcription list: */ 739 740 dlgsub_head = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); 741 dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); 742 dlgsub->sub = sub; 743 744 pj_list_init(dlgsub_head); 745 pj_list_push_back(dlgsub_head, dlgsub); 746 747 748 /* Register as dialog usage: */ 749 750 status = pjsip_dlg_add_usage(dlg, &mod_evsub.mod, dlgsub_head); 751 if (status != PJ_SUCCESS) { 752 pjsip_dlg_dec_lock(dlg); 753 return status; 754 } 755 738 /* Check if another subscription has been registered to the dialog. In 739 * that case, just add ourselves to the subscription list, otherwise 740 * create and register a new subscription list. 741 */ 742 if (pjsip_dlg_has_usage(dlg, &mod_evsub.mod)) { 743 dlgsub_head = (struct dlgsub*) dlg->mod_data[mod_evsub.mod.id]; 744 dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); 745 dlgsub->sub = sub; 746 pj_list_push_back(dlgsub_head, dlgsub); 747 } else { 748 dlgsub_head = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); 749 dlgsub = PJ_POOL_ALLOC_T(sub->pool, struct dlgsub); 750 dlgsub->sub = sub; 751 752 pj_list_init(dlgsub_head); 753 pj_list_push_back(dlgsub_head, dlgsub); 754 755 756 /* Register as dialog usage: */ 757 758 status = pjsip_dlg_add_usage(dlg, &mod_evsub.mod, dlgsub_head); 759 if (status != PJ_SUCCESS) { 760 pjsip_dlg_dec_lock(dlg); 761 return status; 762 } 763 } 756 764 757 765 PJ_LOG(5,(sub->obj_name, "%s subscription created, using dialog %s", -
pjproject/trunk/pjsip/src/pjsip/sip_dialog.c
r3031 r3068 892 892 893 893 return PJ_SUCCESS; 894 } 895 896 /* 897 * Check if the module is registered as a usage 898 */ 899 PJ_DEF(pj_bool_t) pjsip_dlg_has_usage( pjsip_dialog *dlg, 900 pjsip_module *mod) 901 { 902 unsigned index; 903 pj_bool_t found = PJ_FALSE; 904 905 pjsip_dlg_inc_lock(dlg); 906 for (index=0; index<dlg->usage_cnt; ++index) { 907 if (dlg->usage[index] == mod) { 908 found = PJ_TRUE; 909 break; 910 } 911 } 912 pjsip_dlg_dec_lock(dlg); 913 914 return found; 894 915 } 895 916
Note: See TracChangeset
for help on using the changeset viewer.