int wdon = -1;
if (argc > 1) {
+ if (!strcasecmp(argv[1], "debug")) {
+
+ if (argc > 2) {
+ if (strstr(argv[2], "presence")) {
+ mod_sofia_globals.debug_presence = 1;
+ stream->write_function(stream, "+OK Debugging presence\n");
+ }
+
+ if (strstr(argv[2], "sla")) {
+ mod_sofia_globals.debug_sla = 1;
+ stream->write_function(stream, "+OK Debugging sla\n");
+ }
+
+ if (strstr(argv[2], "none")) {
+ stream->write_function(stream, "+OK Debugging nothing\n");
+ mod_sofia_globals.debug_presence = 0;
+ mod_sofia_globals.debug_sla = 0;
+ }
+ }
+
+ stream->write_function(stream, "+OK Debugging summary: presence: %s sla: %s\n",
+ mod_sofia_globals.debug_presence ? "on" : "off",
+ mod_sofia_globals.debug_sla ? "on" : "off");
+
+ goto done;
+ }
+
if (!strcasecmp(argv[1], "siptrace")) {
if (argc > 2) {
ston = switch_true(argv[2]);
}
}
+
if (!strcasecmp(argv[1], "watchdog")) {
if (argc > 2) {
wdon = switch_true(argv[2]);
sofia_glue_global_watchdog(wdon);
stream->write_function(stream, "+OK Global watchdog %s", wdon ? "on" : "off");
} else {
- stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>");
+ stream->write_function(stream, "-ERR Usage: siptrace <on|off>|watchdog <on|off>|debug <sla|presence|none");
}
goto done;
switch_console_set_complete("add sofia global siptrace ::[on:off");
switch_console_set_complete("add sofia global watchdog ::[on:off");
+ switch_console_set_complete("add sofia global debug ::[presence:sla:none");
+
+
switch_console_set_complete("add sofia profile");
switch_console_set_complete("add sofia profile restart all");
} else {
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
}
+
+ } else if (!strcasecmp(var, "send-presence-on-register")) {
+ if (switch_true(val)) {
+ sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
+ } else if (!strcasecmp(val, "first-only")) {
+ sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
+ sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
+ } else {
+ sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
+ sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
+ }
} else if (!strcasecmp(var, "cid-in-1xx")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
+ sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
profile->shutdown_type = "false";
profile->local_network = "localnet.auto";
sofia_set_flag(profile, TFLAG_ENABLE_SOA);
} else {
sofia_clear_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER);
}
+ } else if (!strcasecmp(var, "send-presence-on-register")) {
+ if (switch_true(val)) {
+ sofia_set_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
+ } else if (!strcasecmp(val, "first-only")) {
+ sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
+ sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
+ } else {
+ sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_REGISTER);
+ sofia_clear_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
+ }
} else if (!strcasecmp(var, "cid-in-1xx")) {
if (switch_true(val)) {
sofia_set_pflag(profile, PFLAG_CID_IN_1XX);
long reg_count = 0;
int delete_subs;
const char *agent = "unknown";
-
+ const char *pres_on_reg = NULL;
+ int send_pres = 0;
+
delete_subs = sofia_test_pflag(profile, PFLAG_DEL_SUBS_ON_REG);
+ if (v_event && *v_event) pres_on_reg = switch_event_get_header(*v_event, "send-presence-on-register");
+
+ if (!(send_pres = switch_true(pres_on_reg))) {
+ if (pres_on_reg && !strcasecmp(pres_on_reg, "first-only")) {
+ send_pres = 2;
+ }
+ }
+
/* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
}
}
-
if (send && switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
}
}
- if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
- if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
- switch_event_fire(&s_event);
+ if (sofia_test_pflag(profile, PFLAG_PRESENCE_ON_REGISTER) ||
+ (reg_count == 1 && sofia_test_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER))
+ || send_pres == 1 || (reg_count == 1 && send_pres == 2)) {
+
+ if (sofia_test_pflag(profile, PFLAG_PRESENCE_PROBE_ON_REGISTER)) {
+ if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event_type", "presence");
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
+ switch_event_fire(&s_event);
+ }
+ } else {
+ if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
+ switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
+ switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered");
+ switch_event_fire(&s_event);
+ }
}
- } else {
- if (switch_event_create(&s_event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "login", profile->name);
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", "unknown");
- switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "status", "Registered");
- switch_event_fire(&s_event);
- }
}
-
} else {
if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_UNREGISTER) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);