Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
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
63 changes: 62 additions & 1 deletion pjsip-apps/src/pjsua/pjsua_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,40 @@ static void on_buddy_state(pjsua_buddy_id buddy_id)
}


/*
* 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-direction: %.*s, "
"dialog-state: %.*s, dialog-duration: %.*s, "
"local-identity: %.*s, local-target-uri: %.*s, "
"remote-identity: %.*s, remote-target-uri: %.*s, "
"dialog-local-tag: %.*s, dialog-remote-tag: %.*s, "
"subscription 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_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,
(int)info.dialog_local_tag.slen, info.dialog_local_tag.ptr,
(int)info.dialog_remote_tag.slen, info.dialog_remote_tag.ptr,
info.sub_state_name, info.sub_term_code,
(int)info.sub_term_reason.slen, info.sub_term_reason.ptr));
}

/*
* Subscription state has changed.
*/
Expand Down Expand Up @@ -696,11 +730,36 @@ static void on_buddy_evsub_state(pjsua_buddy_id buddy_id,

}

static void on_buddy_evsub_dlg_event_state(pjsua_buddy_id buddy_id,
pjsip_evsub *sub,
pjsip_event *event)
{
char event_info[80];

PJ_UNUSED_ARG(sub);

event_info[0] = '\0';

if (event->type == PJSIP_EVENT_TSX_STATE &&
event->body.tsx_state.type == PJSIP_EVENT_RX_MSG)
{
pjsip_rx_data *rdata = event->body.tsx_state.src.rdata;
snprintf(event_info, sizeof(event_info),
" (RX %s)",
pjsip_rx_data_get_info(rdata));
}

PJ_LOG(4,(THIS_FILE,
"Buddy %d: dialog event subscription state: %s (event: %s%s)",
buddy_id, pjsip_evsub_get_state_name(sub),
pjsip_event_str(event->type), event_info));
}


/**
* Incoming IM message (i.e. MESSAGE request)!
*/
static void on_pager(pjsua_call_id call_id, const pj_str_t *from,
static void on_pager(pjsua_call_id call_id, const pj_str_t *from,
const pj_str_t *to, const pj_str_t *contact,
const pj_str_t *mime_type, const pj_str_t *text)
{
Expand Down Expand Up @@ -1391,7 +1450,9 @@ static pj_status_t app_init(void)
app_config.cfg.cb.on_reg_state = &on_reg_state;
app_config.cfg.cb.on_incoming_subscribe = &on_incoming_subscribe;
app_config.cfg.cb.on_buddy_state = &on_buddy_state;
app_config.cfg.cb.on_buddy_dlg_event_state = &on_buddy_dlg_event_state;
app_config.cfg.cb.on_buddy_evsub_state = &on_buddy_evsub_state;
app_config.cfg.cb.on_buddy_evsub_dlg_event_state = &on_buddy_evsub_dlg_event_state;
app_config.cfg.cb.on_pager = &on_pager;
app_config.cfg.cb.on_typing = &on_typing;
app_config.cfg.cb.on_call_transfer_status = &on_call_transfer_status;
Expand Down
38 changes: 37 additions & 1 deletion pjsip-apps/src/pjsua/pjsua_app_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +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 dlg event | |");
puts("| | Du 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 @@ -991,7 +993,10 @@ static void ui_add_buddy()
pj_bzero(&buddy_cfg, sizeof(pjsua_buddy_config));

buddy_cfg.uri = pj_str(buf);
buddy_cfg.subscribe = PJ_TRUE;
/* Only one subscription can be active, so we need to disable this
* to allow user to choose between presence or dialog event.
*/
// buddy_cfg.subscribe = PJ_TRUE;

status = pjsua_buddy_add(&buddy_cfg, &buddy_id);
if (status == PJ_SUCCESS) {
Expand Down Expand Up @@ -1496,6 +1501,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 @@ -1987,6 +2018,11 @@ void legacy_main(void)
ui_subscribe(menuin);
break;

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

case 'r':
ui_register(menuin);
break;
Expand Down
4 changes: 2 additions & 2 deletions pjsip/build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export PJSIP_UA_LDFLAGS += $(PJSIP_SIMPLE_LDLIB) \
export PJSIP_SIMPLE_SRCDIR = ../src/pjsip-simple
export PJSIP_SIMPLE_OBJS += $(OS_OBJS) $(M_OBJS) $(CC_OBJS) $(HOST_OBJS) \
errno.o evsub.o evsub_msg.o iscomposing.o \
mwi.o pidf.o presence.o presence_body.o publishc.o \
rpid.o xpidf.o
mwi.o pidf.o dialog_info.o presence.o dlg_event.o presence_body.o \
publishc.o rpid.o xpidf.o
export PJSIP_SIMPLE_CFLAGS += $(_CFLAGS)
export PJSIP_SIMPLE_CXXFLAGS += $(_CXXFLAGS)
export PJSIP_SIMPLE_LDFLAGS += $(PJSIP_LDLIB) \
Expand Down
4 changes: 4 additions & 0 deletions pjsip/build/pjsip_simple.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,8 @@
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\src\pjsip-simple\dlg_event.c" />
<ClCompile Include="..\src\pjsip-simple\dialog_info.c" />
<ClCompile Include="..\src\pjsip-simple\errno.c" />
<ClCompile Include="..\src\pjsip-simple\evsub.c" />
<ClCompile Include="..\src\pjsip-simple\evsub_msg.c" />
Expand All @@ -687,6 +689,8 @@
<ClCompile Include="..\src\pjsip-simple\xpidf.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\pjsip-simple\dlg_event.h" />
<ClInclude Include="..\include\pjsip-simple\dialog_info.h" />
<ClInclude Include="..\include\pjsip-simple\errno.h" />
<ClInclude Include="..\include\pjsip-simple\evsub.h" />
<ClInclude Include="..\include\pjsip-simple\evsub_msg.h" />
Expand Down
12 changes: 12 additions & 0 deletions pjsip/build/pjsip_simple.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
<ClCompile Include="..\src\pjsip-simple\xpidf.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\pjsip-simple\dlg_event.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\pjsip-simple\dialog_info.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\pjsip-simple\errno.h">
Expand Down Expand Up @@ -82,5 +88,11 @@
<ClInclude Include="..\include\pjsip-simple\xpidf.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\pjsip-simple\dlg_event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\pjsip-simple\dialog_info.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
Loading