Changeset 1401 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
- Timestamp:
- Jun 28, 2007 7:20:26 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_pres.c
r1398 r1401 24 24 25 25 #ifndef PJSUA_PRES_TIMER 26 # define PJSUA_PRES_TIMER 12026 # define PJSUA_PRES_TIMER 2 27 27 #endif 28 28 … … 71 71 72 72 return PJ_SUCCESS; 73 74 73 } 75 74 … … 208 207 pjsua_var.buddy_cnt++; 209 208 209 PJSUA_UNLOCK(); 210 210 211 pjsua_buddy_subscribe_pres(index, cfg->subscribe); 211 212 PJSUA_UNLOCK();213 212 214 213 return PJ_SUCCESS; … … 225 224 PJ_EINVAL); 226 225 227 PJSUA_LOCK();228 229 226 if (pjsua_var.buddy[buddy_id].uri.slen == 0) { 230 PJSUA_UNLOCK();231 227 return PJ_SUCCESS; 232 228 } … … 234 230 /* Unsubscribe presence */ 235 231 pjsua_buddy_subscribe_pres(buddy_id, PJ_FALSE); 232 233 PJSUA_LOCK(); 236 234 237 235 /* Remove buddy */ … … 263 261 buddy = &pjsua_var.buddy[buddy_id]; 264 262 buddy->monitor = subscribe; 263 264 PJSUA_UNLOCK(); 265 265 266 pjsua_pres_refresh(); 266 267 PJSUA_UNLOCK();268 267 269 268 return PJ_SUCCESS; … … 1015 1014 pjsua_acc *acc; 1016 1015 pj_str_t contact; 1017 pjsip_dialog *dlg;1018 1016 pjsip_tx_data *tdata; 1019 1017 pj_status_t status; … … 1040 1038 &contact, 1041 1039 &buddy->uri, 1042 NULL, & dlg);1040 NULL, &buddy->dlg); 1043 1041 if (status != PJ_SUCCESS) { 1044 1042 pjsua_perror(THIS_FILE, "Unable to create dialog", … … 1047 1045 } 1048 1046 1049 status = pjsip_pres_create_uac( dlg, &pres_callback,1047 status = pjsip_pres_create_uac( buddy->dlg, &pres_callback, 1050 1048 PJSIP_EVSUB_NO_EVENT_ID, &buddy->sub); 1051 1049 if (status != PJ_SUCCESS) { … … 1053 1051 pjsua_perror(THIS_FILE, "Unable to create presence client", 1054 1052 status); 1055 pjsip_dlg_terminate( dlg);1053 pjsip_dlg_terminate(buddy->dlg); 1056 1054 return; 1057 1055 } … … 1064 1062 1065 1063 pjsua_init_tpselector(acc->cfg.transport_id, &tp_sel); 1066 pjsip_dlg_set_transport( dlg, &tp_sel);1064 pjsip_dlg_set_transport(buddy->dlg, &tp_sel); 1067 1065 } 1068 1066 1069 1067 /* Set route-set */ 1070 1068 if (!pj_list_empty(&acc->route_set)) { 1071 pjsip_dlg_set_route_set( dlg, &acc->route_set);1069 pjsip_dlg_set_route_set(buddy->dlg, &acc->route_set); 1072 1070 } 1073 1071 1074 1072 /* Set credentials */ 1075 1073 if (acc->cred_cnt) { 1076 pjsip_auth_clt_set_credentials( & dlg->auth_sess,1074 pjsip_auth_clt_set_credentials( &buddy->dlg->auth_sess, 1077 1075 acc->cred_cnt, acc->cred); 1078 1076 } … … 1138 1136 1139 1137 1138 /* Lock all buddies */ 1139 #define LOCK_BUDDIES unsigned cnt_ = 0; \ 1140 pjsip_dialog *dlg_list_[PJSUA_MAX_BUDDIES]; \ 1141 unsigned i_; \ 1142 for (i_=0; i_<PJ_ARRAY_SIZE(pjsua_var.buddy);++i_) { \ 1143 if (pjsua_var.buddy[i_].sub) { \ 1144 dlg_list_[cnt_++] = pjsua_var.buddy[i_].dlg; \ 1145 pjsip_dlg_inc_lock(pjsua_var.buddy[i_].dlg); \ 1146 } \ 1147 } \ 1148 PJSUA_LOCK(); 1149 1150 /* Unlock all buddies */ 1151 #define UNLOCK_BUDDIES PJSUA_UNLOCK(); \ 1152 for (i_=0; i_<cnt_; ++i_) { \ 1153 pjsip_dlg_dec_lock(dlg_list_[i_]); \ 1154 } 1155 1156 1157 1140 1158 /* It does what it says.. */ 1141 1159 static void refresh_client_subscriptions(void) … … 1143 1161 unsigned i; 1144 1162 1163 LOCK_BUDDIES; 1164 1145 1165 for (i=0; i<PJ_ARRAY_SIZE(pjsua_var.buddy); ++i) { 1146 1166 … … 1156 1176 } 1157 1177 } 1178 1179 UNLOCK_BUDDIES; 1158 1180 } 1159 1181 … … 1164 1186 pj_time_val delay = { PJSUA_PRES_TIMER, 0 }; 1165 1187 1166 PJ_UNUSED_ARG(th);1167 1168 PJSUA_LOCK();1169 1170 1188 entry->id = PJ_FALSE; 1171 1189 refresh_client_subscriptions(); … … 1174 1192 entry->id = PJ_TRUE; 1175 1193 1176 PJ SUA_UNLOCK();1194 PJ_UNUSED_ARG(th); 1177 1195 } 1178 1196
Note: See TracChangeset
for help on using the changeset viewer.