void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) { stats* counters = get_stats(lc); LinphoneCoreManager *mgr=get_manager(lc); LinphoneContent* content; const LinphoneAddress* from_addr = linphone_event_get_from(lev); char* from = linphone_address_as_string(from_addr); content = linphone_core_create_content(lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml2"); linphone_content_set_buffer(content,notify_content,strlen(notify_content)); ms_message("Subscription state [%s] from [%s]",linphone_subscription_state_to_string(state),from); ms_free(from); switch(state){ case LinphoneSubscriptionNone: break; case LinphoneSubscriptionIncomingReceived: counters->number_of_LinphoneSubscriptionIncomingReceived++; mgr->lev=lev; if (!mgr->decline_subscribe) linphone_event_accept_subscription(lev); else linphone_event_deny_subscription(lev, LinphoneReasonDeclined); break; case LinphoneSubscriptionOutgoingInit: counters->number_of_LinphoneSubscriptionOutgoingInit++; break; case LinphoneSubscriptionPending: counters->number_of_LinphoneSubscriptionPending++; break; case LinphoneSubscriptionActive: counters->number_of_LinphoneSubscriptionActive++; if (linphone_event_get_subscription_dir(lev)==LinphoneSubscriptionIncoming){ mgr->lev=lev; linphone_event_notify(lev,content); } break; case LinphoneSubscriptionTerminated: counters->number_of_LinphoneSubscriptionTerminated++; mgr->lev=NULL; break; case LinphoneSubscriptionError: counters->number_of_LinphoneSubscriptionError++; mgr->lev=NULL; break; case LinphoneSubscriptionExpiring: counters->number_of_LinphoneSubscriptionExpiring++; mgr->lev=NULL; break; } linphone_content_unref(content); }
static void subscription_state_changed(LinphoneCore *lc, LinphoneEvent *ev, LinphoneSubscriptionState state){ MyAppData *data=(MyAppData*)linphone_core_get_user_data(lc); if (state==LinphoneSubscriptionIncomingReceived){ printf("Receiving new subscription for event %s\n",linphone_event_get_name(ev)); if (data->ev==NULL) { linphone_event_accept_subscription(ev); data->ev=linphone_event_ref(ev); }else{ linphone_event_deny_subscription(ev,LinphoneReasonBusy); } }else if (state==LinphoneSubscriptionTerminated){ if (data->ev==ev){ linphone_event_unref(data->ev); data->ev=NULL; } } }
void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, LinphoneSubscriptionState state) { stats* counters = get_stats(lc); LinphoneCoreManager *mgr=get_manager(lc); LinphoneContent content; content.type="application"; content.subtype="somexml2"; content.data=(void*)notify_content; content.size=strlen(notify_content); switch(state){ case LinphoneSubscriptionNone: break; case LinphoneSubscriptionIncomingReceived: counters->number_of_LinphoneSubscriptionIncomingReceived++; if (!mgr->decline_subscribe) linphone_event_accept_subscription(lev); else linphone_event_deny_subscription(lev, LinphoneReasonDeclined); break; case LinphoneSubscriptionOutoingInit: counters->number_of_LinphoneSubscriptionOutgoingInit++; break; case LinphoneSubscriptionPending: counters->number_of_LinphoneSubscriptionPending++; break; case LinphoneSubscriptionActive: counters->number_of_LinphoneSubscriptionActive++; if (linphone_event_get_subscription_dir(lev)==LinphoneSubscriptionIncoming){ mgr->lev=lev; linphone_event_notify(lev,&content); } break; case LinphoneSubscriptionTerminated: counters->number_of_LinphoneSubscriptionTerminated++; mgr->lev=NULL; break; case LinphoneSubscriptionError: counters->number_of_LinphoneSubscriptionError++; mgr->lev=NULL; break; } }