Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 17 additions & 39 deletions pjsip-apps/src/pjsua/pjsua_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,51 +667,29 @@ static void on_buddy_state(pjsua_buddy_id buddy_id)


/*
* Handler on buddy "busy lamp field" state changed.
* Handler on buddy dialog event state changed.
*/
static void on_buddy_dlg_event_state(pjsua_buddy_id buddy_id)
{
pjsua_buddy_dlg_event_info info;
pjsua_buddy_get_dlg_event_info(buddy_id, &info);

PJ_LOG(3,(THIS_FILE, "%.*s dialog-info-state: %.*s, dialog-info-entity: %.*s, "
"dialog-id: %.*s, dialog-call-id: %.*s, dialog-remote-tag: %.*s, "
"dialog-local-tag: %.*s, dialog-direction: %.*s, dialog-state: %.*s, "
"dialog-duration: %.*s, local-identity: %.*s, local-target-uri: %.*s, "
"remote-identity: %.*s, remote-target-uri: %.*s, subscription blf state: %s, "
"(last termination reason code=%d %.*s)",
(int)info.uri.slen,
info.uri.ptr,
(int)info.dialog_info_state.slen,
info.dialog_info_state.ptr,
(int)info.dialog_info_entity.slen,
info.dialog_info_entity.ptr,
(int)info.dialog_id.slen,
info.dialog_id.ptr,
(int)info.dialog_call_id.slen,
info.dialog_call_id.ptr,
(int)info.dialog_remote_tag.slen,
info.dialog_remote_tag.ptr,
(int)info.dialog_local_tag.slen,
info.dialog_local_tag.ptr,
(int)info.dialog_direction.slen,
info.dialog_direction.ptr,
(int)info.dialog_state.slen,
info.dialog_state.ptr,
(int)info.dialog_duration.slen,
info.dialog_duration.ptr,
(int)info.local_identity.slen,
info.local_identity.ptr,
(int)info.local_target_uri.slen,
info.local_target_uri.ptr,
(int)info.remote_identity.slen,
info.remote_identity.ptr,
(int)info.remote_target_uri.slen,
info.remote_target_uri.ptr,
info.sub_state_name,
info.sub_term_code,
(int)info.sub_term_reason.slen,
info.sub_term_reason.ptr));
PJ_LOG(3,(THIS_FILE,
"%.*s dialog-call-id: %.*s, dialog-direction: %.*s, "
"dialog-state: %.*s, dialog-duration: %.*s, "
"local-identity: %.*s, local-target-uri: %.*s, "
"remote-identity: %.*s, remote-target-uri: %.*s, "
"subscription state: %s",
(int)info.uri.slen, info.uri.ptr,
(int)info.dialog_call_id.slen, info.dialog_call_id.ptr,
(int)info.dialog_direction.slen, info.dialog_direction.ptr,
(int)info.dialog_state.slen, info.dialog_state.ptr,
(int)info.dialog_duration.slen, info.dialog_duration.ptr,
(int)info.local_identity.slen, info.local_identity.ptr,
(int)info.local_target_uri.slen, info.local_target_uri.ptr,
(int)info.remote_identity.slen, info.remote_identity.ptr,
(int)info.remote_target_uri.slen, info.remote_target_uri.ptr,
info.sub_state_name));
}

/*
Expand Down
84 changes: 33 additions & 51 deletions pjsip-apps/src/pjsua/pjsua_app_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ static void keystroke_help()
puts("| a Answer call | i Send IM | !a Modify accnt. |");
puts("| h Hangup call (ha=all) | s Subscribe presence | rr (Re-)register |");
puts("| H Hold call | u Unsubscribe presence | ru Unregister |");
puts("| | +d Subscribe blf | |");
puts("| | -d Unsubscribe blf | |");
puts("| | E Subscribe dlg event | |");
puts("| | Eu Unsub dlg event | |");
puts("| v re-inVite (release hold) | t Toggle online status | > Cycle next ac.|");
puts("| U send UPDATE | T Set online status | < Cycle prev ac.|");
puts("| ],[ Select next/prev call +--------------------------+-------------------+");
Expand Down Expand Up @@ -1002,33 +1002,6 @@ static void ui_add_buddy()
}
}

static void ui_add_buddy_blf()
{
char buf[128];
pjsua_buddy_config buddy_cfg;
pjsua_buddy_id buddy_id;
pj_status_t status;

if (!simple_input("Enter buddy's URI:", buf, sizeof(buf)))
return;

if (pjsua_verify_url(buf) != PJ_SUCCESS) {
printf("Invalid URI '%s'\n", buf);
return;
}

pj_bzero(&buddy_cfg, sizeof(pjsua_buddy_config));

buddy_cfg.uri = pj_str(buf);
buddy_cfg.subscribe = PJ_TRUE;

status = pjsua_buddy_add_blf(&buddy_cfg, &buddy_id);
if (status == PJ_SUCCESS) {
printf("New buddy '%s' added at index %d\n",
buf, buddy_id+1);
}
}

static void ui_add_account(pjsua_transport_config *rtp_cfg)
{
char id[80], registrar[80], realm[80], uname[80], passwd[30];
Expand Down Expand Up @@ -1083,24 +1056,6 @@ static void ui_delete_buddy()
}
}

static void ui_delete_buddy_blf()
{
char buf[128];
int i;

if (!simple_input("Enter blf buddy ID to delete",buf,sizeof(buf)))
return;

i = my_atoi(buf) - 1;

if (!pjsua_buddy_is_valid(i)) {
printf("Invalid buddy id %d\n", i);
} else {
pjsua_buddy_del_blf(i);
printf("BLF buddy %d deleted\n", i);
}
}

static void ui_delete_account()
{
char buf[128];
Expand Down Expand Up @@ -1543,6 +1498,32 @@ static void ui_subscribe(char menuin[])
}
}

static void ui_subscribe_dlg_event(pj_bool_t sub)
{
char buf[128];
input_result result;

ui_input_url("(un)Subscribe dialog event of", buf, sizeof(buf), &result,
PJ_TRUE);
if (result.nb_result != PJSUA_APP_NO_NB) {
if (result.nb_result == -1) {
int i, count;
count = pjsua_get_buddy_count();
for (i=0; i<count; ++i)
pjsua_buddy_subscribe_dlg_event(i, sub);
} else if (result.nb_result == 0) {
puts("Sorry, can only subscribe to buddy's dialog event, "
"not from existing call");
} else {
pjsua_buddy_subscribe_dlg_event(result.nb_result-1, sub);
}

} else if (result.uri_result) {
puts("Sorry, can only subscribe to buddy's dialog event, "
"not arbitrary URL (for now)");
}
}

static void ui_register(char menuin[])
{
switch (menuin[1]) {
Expand Down Expand Up @@ -1932,8 +1913,6 @@ void legacy_main(void)
ui_add_buddy();
} else if (menuin[1] == 'a') {
ui_add_account(&app_config.rtp_cfg);
} else if (menuin[1] == 'd') {
ui_add_buddy_blf();
} else {
printf("Invalid input %s\n", menuin);
}
Expand All @@ -1944,8 +1923,6 @@ void legacy_main(void)
ui_delete_buddy();
} else if (menuin[1] == 'a') {
ui_delete_account();
} else if (menuin[1] == 'd') {
ui_delete_buddy_blf();
} else {
printf("Invalid input %s\n", menuin);
}
Expand Down Expand Up @@ -2038,6 +2015,11 @@ void legacy_main(void)
ui_subscribe(menuin);
break;

case 'E':
/* Subscribe/unsubscribe dialog event */
ui_subscribe_dlg_event(menuin[1] != 'u');
break;

case 'r':
ui_register(menuin);
break;
Expand Down
6 changes: 6 additions & 0 deletions pjsip/include/pjsip/sip_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,12 @@ PJ_INLINE(pjsip_cfg_t*) pjsip_cfg(void)
#endif


/**
* Specify the status code value to respond to bad message body in NOTIFY
* request for dialog event.
*
* Default: 488 (Not Acceptable Here)
*/
#ifndef PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE
# define PJSIP_DLG_EVENT_BAD_CONTENT_RESPONSE 488
#endif
Expand Down
Loading