diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c
index aabf444ad8..7be0b5925c 100644
--- a/src/mod/endpoints/mod_sofia/sofia_glue.c
+++ b/src/mod/endpoints/mod_sofia/sofia_glue.c
@@ -2471,7 +2471,9 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" sip_host VARCHAR(255),\n"
" contact VARCHAR(1024),\n"
" status VARCHAR(255),\n"
- " rpid VARCHAR(255),\n" " expires INTEGER,\n" " user_agent VARCHAR(255)\n" ");\n";
+ " rpid VARCHAR(255),\n"
+ " expires INTEGER,\n"
+ " user_agent VARCHAR(255)\n" ");\n";
char dialog_sql[] =
"CREATE TABLE sip_dialogs (\n"
@@ -2483,7 +2485,10 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" sip_from_host VARCHAR(255),\n"
" contact_user VARCHAR(255),\n"
" contact_host VARCHAR(255),\n"
- " state VARCHAR(255),\n" " direction VARCHAR(255),\n" " user_agent VARCHAR(255)\n" ");\n";
+ " state VARCHAR(255),\n"
+ " direction VARCHAR(255),\n"
+ " user_agent VARCHAR(255)\n"
+ ");\n";
char sub_sql[] =
"CREATE TABLE sip_subscriptions (\n"
@@ -2497,10 +2502,15 @@ int sofia_glue_init_sql(sofia_profile_t *profile)
" call_id VARCHAR(255),\n"
" full_from VARCHAR(255),\n"
" full_via VARCHAR(255),\n"
- " expires INTEGER,\n" " user_agent VARCHAR(255),\n" " accept VARCHAR(255)\n" ");\n";
+ " expires INTEGER,\n"
+ " user_agent VARCHAR(255),\n"
+ " accept VARCHAR(255)\n"
+ ");\n";
-
- char auth_sql[] = "CREATE TABLE sip_authentication (\n" " nonce VARCHAR(255),\n" " expires INTEGER" ");\n";
+ char auth_sql[] =
+ "CREATE TABLE sip_authentication (\n"
+ " nonce VARCHAR(255),\n"
+ " expires INTEGER" ");\n";
if (profile->odbc_dsn) {
#ifdef SWITCH_HAVE_ODBC
diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c
index 30842954a5..4656919b11 100644
--- a/src/mod/endpoints/mod_sofia/sofia_presence.c
+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c
@@ -743,6 +743,50 @@ static char *translate_rpid(char *in)
}
+static char *gen_pidf(char *user_agent, char *id, char *url, char *open, char *rpid, char *prpid, char *status, char *note, const char **ct)
+{
+ if (switch_stristr("polycom", user_agent)) {
+ *ct = "application/xpidf+xml";
+ return switch_mprintf(
+ "\n"
+ "\n"
+ "\n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ " \n"
+ "\n", id, id, url, open, prpid
+ );
+ } else {
+ *ct = "application/pidf+xml";
+ return switch_mprintf(
+ "\n"
+ "\n"
+ " \n"
+ " %s\n"
+ " \n"
+ " \n"
+ " \r\n"
+ " %s\n"
+ " \n"
+ " \n"
+ " \n"
+ " \r\n"
+ " \n"
+ " "
+ " \n"
+ "", id, status, prpid, rpid);
+ }
+}
+
+
static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char **columnNames)
{
struct presence_helper *helper = (struct presence_helper *) pArg;
@@ -761,6 +805,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
char *event = argv[5];
char *call_id = argv[7];
char *expires = argv[10];
+ char *user_agent = argv[11];
//char *accept = argv[12];
nua_handle_t *nh;
char *to = NULL;
@@ -974,30 +1019,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
}
prpid = translate_rpid(rpid);
- pl = switch_mprintf("\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "%s\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "%s\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n" "\r\n"
- "%s\r\n" "", id, id, profile->url, open, status, prpid, open, rpid, note);
- ct = "application/pidf+xml";
+ pl = gen_pidf(user_agent, id, profile->url, open, rpid, prpid, status, note, &ct);
}
} else {
@@ -1008,31 +1030,8 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
note = NULL;
open = "closed";
}
-
- pl = switch_mprintf("\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "%s\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "%s\r\n"
- "\r\n"
- "\r\n"
- "\r\n"
- "\r\n" "\r\n"
- "%s\r\n" "", id, id, profile->url, open, status, prpid, open, rpid, note);
- ct = "application/pidf+xml";
+ prpid = translate_rpid(rpid);
+ pl = gen_pidf(user_agent, id, profile->url, open, rpid, prpid, status, note, &ct);
}
switch_snprintf(exp, sizeof(exp), "active;expires=%ld", (long) exptime);