presence tweaks

This commit is contained in:
Anthony Minessale 2010-08-17 13:00:32 -05:00
parent 6626211ab6
commit 93b3139092
1 changed files with 43 additions and 41 deletions

View File

@ -1080,62 +1080,59 @@ static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *r
" </atom>\n" " </atom>\n"
"</presence>\n", status, id, id, url, open, prpid); "</presence>\n", status, id, id, url, open, prpid);
} else { } else {
char *xml_rpid = NULL;
*ct = "application/pidf+xml"; *ct = "application/pidf+xml";
if (!strcasecmp(open, "closed")) {
status = "Unregistered";
prpid = NULL;
}
if (!strncasecmp(status, "Registered", 10)) { if (!strncasecmp(status, "Registered", 10)) {
prpid = NULL; prpid = NULL;
status = "Available"; status = "Available";
} }
if (!strcasecmp(status, "Unregistered")) { if (!strcasecmp(status, "Unregistered")) {
prpid = NULL; prpid = NULL;
open = "closed"; open = "closed";
} }
if (zstr(status)) {
status = "Available";
}
if (zstr(rpid)) { if (zstr(rpid)) {
prpid = NULL; prpid = NULL;
} }
if (prpid) { if (zstr(status) && !zstr(prpid)) {
ret = switch_mprintf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n" status = "Available";
"<presence xmlns='urn:ietf:params:xml:ns:pidf' \n"
"xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n"
"xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n"
"xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'>\n"
" <tuple id='t6a5ed77e'>\n"
" <status>\r\n"
" <basic>%s</basic>\n"
" </status>\n"
" </tuple>\n"
" <dm:person id='p06360c4a'>\n"
" <rpid:activities>\r\n"
" <rpid:%s/>\n"
" </rpid:activities>\n"
" <dm:note>%s</dm:note>\n"
" </dm:person>\n"
"</presence>", id, open, prpid, status);
} else {
ret = switch_mprintf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n"
"<presence xmlns='urn:ietf:params:xml:ns:pidf' \n"
"xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n"
"xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n"
"xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'>\n"
" <tuple id='t6a5ed77e'>\n"
" <status>\r\n"
" <basic>%s</basic>\n"
" </status>\n"
" </tuple>\n"
" <dm:person id='p06360c4a'>\n"
" <dm:note>%s</dm:note>\n"
" </dm:person>\n"
"</presence>", id, open, status);
} }
if (prpid) {
xml_rpid = switch_mprintf(" <rpid:activities>\r\n"
" <rpid:%s/>\n"
" </rpid:activities>\n", prpid);
}
ret = switch_mprintf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n"
"<presence xmlns='urn:ietf:params:xml:ns:pidf' \n"
"xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n"
"xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n"
"xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'>\n"
" <tuple id='t6a5ed77e'>\n"
" <status>\r\n"
" <basic>%s</basic>\n"
" </status>\n"
" </tuple>\n"
" <dm:person id='p06360c4a'>\n"
"%s"
" <dm:note>%s</dm:note>\n"
" </dm:person>\n"
"</presence>", id, open, switch_str_nil(xml_rpid), status);
switch_safe_free(xml_rpid);
} }
@ -1186,9 +1183,13 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
//printf("arg %d[%s] = [%s]\n", i, columnNames[i], argv[i]); //printf("arg %d[%s] = [%s]\n", i, columnNames[i], argv[i]);
//} //}
if (argc > 18 && !zstr(argv[17]) && !zstr(argv[18])) { if (argc > 18) {
status = argv[17]; if (!zstr(argv[17])) {
rpid = argv[18]; status = argv[17];
}
if (!zstr(argv[18])) {
rpid = argv[18];
}
open_closed = argv[19]; open_closed = argv[19];
} }
@ -2478,6 +2479,7 @@ void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, n
" profile_name, hostname, open_closed) " " profile_name, hostname, open_closed) "
"values ('%q','%q','%q','%q',%ld,'%q','%q','%q','%q')", "values ('%q','%q','%q','%q',%ld,'%q','%q','%q','%q')",
from_user, from_host, note_txt, rpid, exp, full_agent, profile->name, mod_sofia_globals.hostname, open_closed))) { from_user, from_host, note_txt, rpid, exp, full_agent, profile->name, mod_sofia_globals.hostname, open_closed))) {
sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
} }