run indent on the whole tree and update copyright dates in prep for 1.0.5

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16579 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2010-02-06 03:38:24 +00:00
1 parent 7b347417e5
commit 886e1ddb4d
229 files changed
+20252 -20192

No files matched your search

+47 -57
View File
@@ -1,6 +1,6 @@
/*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
* Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
@@ -74,7 +74,7 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const
char exp_str[256] = "";
char my_contact[256] = "";
char *sql;
struct sla_helper sh = { { 0 } };
struct sla_helper sh = { {0} };
char *contact_str = sofia_glue_strip_uri(full_contact);
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
char network_ip[80];
@@ -83,17 +83,17 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const
char *route_uri = NULL;
char port_str[25] = "";
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
mod_sofia_globals.hostname, profile->name, contact_str);
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, get_call_id_callback, &sh);
free(sql);
if (*sh.call_id) {
if (!(nh = nua_handle_by_call_id(profile->nua, sh.call_id))) {
if ((sql = switch_mprintf("delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
if ((sql = switch_mprintf("delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
mod_sofia_globals.hostname, profile->name, contact_str))) {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
}
@@ -110,15 +110,15 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const
switch_snprintf(port_str, sizeof(port_str), ":%ld", sofia_glue_transport_has_tls(transport) ? profile->tls_sip_port : profile->sip_port);
if (sofia_glue_check_nat(profile, network_ip)) {
switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
if (sofia_glue_check_nat(profile, network_ip)) {
switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
profile->extsipip, port_str, sofia_glue_transport2str(transport), exp_str);
} else {
switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
profile->sipip, port_str, sofia_glue_transport2str(transport), exp_str);
}
dst = sofia_glue_get_destination((char*) full_contact);
dst = sofia_glue_get_destination((char *) full_contact);
if (dst->route_uri) {
route_uri = sofia_glue_strip_uri(dst->route_uri);
@@ -130,9 +130,7 @@ void sofia_sla_handle_register(nua_t *nua, sofia_profile_t *profile, sip_t const
SIPTAG_FROM(sip->sip_to),
SIPTAG_CONTACT_STR(my_contact),
SIPTAG_EXPIRES_STR(exp_str),
SIPTAG_EVENT_STR("dialog;sla;include-session-description"),
SIPTAG_ACCEPT_STR("application/dialog-info+xml"),
TAG_NULL());
SIPTAG_EVENT_STR("dialog;sla;include-session-description"), SIPTAG_ACCEPT_STR("application/dialog-info+xml"), TAG_NULL());
sofia_glue_free_destination(dst);
@@ -158,13 +156,13 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
/*
* XXX MTK FIXME - we don't look at the tag to see if NUTAG_SUBSTATE(nua_substate_terminated) or
* a Subscription-State header with state "terminated" and/or expiration of 0. So we never forget
* about them here.
* likewise, we also don't have a hook against nua_r_notify events, so we can't see nua_substate_terminated there.
*/
*/
/*
* extracting AOR is weird...
@@ -180,30 +178,29 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
* ok, and now that we HAVE the AOR, we REALLY should go check in the XML config and see if this particular
* extension is set up to have shared appearances managed. right now it is all-or-nothing on the profile,
* which won't be sufficient for real life. FIXME XXX MTK
*/
*/
/* then the subscriber is the user at their network location... this is arguably the wrong way, but works so far... */
subscriber = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_from->a_url->url_user,
sip->sip_contact->m_url->url_host, sofia_glue_transport2str(transport));
if ((sql =
switch_mprintf("delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'",
subscriber, profile->name, mod_sofia_globals.hostname
))) {
switch_mprintf("delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'",
subscriber, profile->name, mod_sofia_globals.hostname))) {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
}
if ((sql =
switch_mprintf("insert into sip_shared_appearance_subscriptions (subscriber, call_id, aor, profile_name, hostname, contact_str, network_ip) "
"values ('%q','%q','%q','%q','%q','%q','%q')",
subscriber, sip->sip_call_id->i_id, aor, profile->name, mod_sofia_globals.hostname, contact_str, network_ip))) {
"values ('%q','%q','%q','%q','%q','%q','%q')",
subscriber, sip->sip_call_id->i_id, aor, profile->name, mod_sofia_globals.hostname, contact_str, network_ip))) {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
}
if (strstr(contact_str, ";fs_nat")) {
char *p;
route_uri = sofia_glue_get_url_from_contact((char *)contact_str, 1);
route_uri = sofia_glue_get_url_from_contact((char *) contact_str, 1);
if ((p = strstr(contact_str, ";fs_"))) {
*p = '\0';
}
@@ -222,21 +219,17 @@ void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia
switch_snprintf(port_str, sizeof(port_str), ":%ld", sofia_glue_transport_has_tls(transport) ? profile->tls_sip_port : profile->sip_port);
if (sofia_glue_check_nat(profile, network_ip)) {
sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->extsipip,
port_str, sofia_glue_transport2str(transport));
if (sofia_glue_check_nat(profile, network_ip)) {
sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->extsipip, port_str, sofia_glue_transport2str(transport));
} else {
sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->sipip,
port_str, sofia_glue_transport2str(transport));
sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->sipip, port_str, sofia_glue_transport2str(transport));
}
nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(sla_contact), NUTAG_WITH_THIS(nua),
TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
SIPTAG_EXPIRES_STR("300"), /* likewise, totally fake - FIXME XXX MTK */
nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(sla_contact), NUTAG_WITH_THIS(nua), TAG_IF(route_uri, NUTAG_PROXY(route_uri)), SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
SIPTAG_EXPIRES_STR("300"), /* likewise, totally fake - FIXME XXX MTK */
/* sofia_presence says something about needing TAG_IF(sticky, NUTAG_PROXY(sticky)) for NAT stuff? */
TAG_END());
switch_safe_free(aor);
switch_safe_free(subscriber);
switch_safe_free(route_uri);
@@ -251,7 +244,8 @@ struct sla_notify_helper {
void sofia_sla_handle_sip_r_subscribe(int status,
char const *phrase,
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
tagi_t tags[])
{
if (status >= 300) {
nua_handle_destroy(nh);
@@ -267,8 +261,8 @@ void sofia_sla_handle_sip_r_subscribe(int status,
}
if ((sql = switch_mprintf("insert into sip_shared_appearance_dialogs (profile_name, hostname, contact_str, call_id, expires) "
"values ('%q','%q','%q','%q','%ld')",
profile->name, mod_sofia_globals.hostname, contact_str, sip->sip_call_id->i_id, (long)expires))) {
"values ('%q','%q','%q','%q','%ld')",
profile->name, mod_sofia_globals.hostname, contact_str, sip->sip_call_id->i_id, (long) expires))) {
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
}
@@ -298,20 +292,20 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han
* yet check each AOR as it comes in to see if it is to be managed, is more subscribers than we probably
* should have). for the current prototype stage, this works ok anyway.
* and because we don't parse the XML, we even reflect it right back to the notifier/sender (which is called
* "target" in the payload XML, of course).
* "target" in the payload XML, of course).
* also because we don't track on a per-appearance basis, there IS NOT a hook back from sofia_glue to add
* an appearance index to the outbound invite for the "next free appearance". this can lead to race
* conditions where a call shows up on slightly different line key numbers at different phones, making
* "pick up on line X" meaningless if such a race occurs. again, it is a prototype. we can fix it later.
*/
*/
/* the dispatcher calls us just because it is aimed at us, so check to see if it is dialog;sla at the very least... */
if ( (!sip->sip_event)
|| (strcasecmp(sip->sip_event->o_type, "dialog"))
|| !msg_params_find(sip->sip_event->o_params, "sla") ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,"sent to sla-agent but not dialog;sla\n");
if ((!sip->sip_event)
|| (strcasecmp(sip->sip_event->o_type, "dialog"))
|| !msg_params_find(sip->sip_event->o_params, "sla")) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "sent to sla-agent but not dialog;sla\n");
return;
}
@@ -326,16 +320,15 @@ void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_han
* so we don't reflect it back at anyone who is the "boss" config, but we do reflect it back at the "secretary"
* config. if that breaks the phone, just set them all up as the "boss" config where ext#==third-party#
*/
contact = switch_mprintf("sip:%s@%s;transport=%s",sip->sip_contact->m_url->url_user,
contact = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_contact->m_url->url_user,
sip->sip_contact->m_url->url_host, sofia_glue_transport2str(transport));
if (sip->sip_payload && sip->sip_payload->pl_data) {
sql = switch_mprintf("select subscriber,call_id,aor,profile_name,hostname,contact_str,network_ip from sip_shared_appearance_subscriptions where "
"aor='%q' and profile_name='%q' and hostname='%q'",
aor, profile->name, mod_sofia_globals.hostname);
"aor='%q' and profile_name='%q' and hostname='%q'", aor, profile->name, mod_sofia_globals.hostname);
helper.profile = profile;
helper.payload = sip->sip_payload->pl_data; /* could just send the WHOLE payload. you'd get the type that way. */
helper.payload = sip->sip_payload->pl_data; /* could just send the WHOLE payload. you'd get the type that way. */
/* which mutex if any is correct to hold in this callback? XXX MTK FIXME */
sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_sla_sub_callback, &helper);
@@ -360,7 +353,7 @@ static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **colu
char *route_uri = NULL;
char *xml_fixup = NULL;
char *fixup = NULL;
nh = nua_handle_by_call_id(helper->profile->nua, call_id); /* that's all you need to find the subscription's nh */
nh = nua_handle_by_call_id(helper->profile->nua, call_id); /* that's all you need to find the subscription's nh */
if (nh) {
@@ -384,24 +377,21 @@ static int sofia_sla_sub_callback(void *pArg, int argc, char **argv, char **colu
}
if (helper->profile->extsipip) {
if (sofia_glue_check_nat(helper->profile, network_ip)) {
if (sofia_glue_check_nat(helper->profile, network_ip)) {
fixup = switch_string_replace(helper->payload, helper->profile->sipip, helper->profile->extsipip);
} else {
} else {
fixup = switch_string_replace(helper->payload, helper->profile->extsipip, helper->profile->sipip);
}
xml_fixup = fixup;
} else {
xml_fixup = helper->payload;
}
nua_notify(nh,
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* XXX MTK FIXME - this is totally fake calculation */
TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
SIPTAG_CONTENT_TYPE_STR("application/dialog-info+xml"), /* could've just kept the type from the payload */
SIPTAG_PAYLOAD_STR(xml_fixup),
TAG_END());
nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* XXX MTK FIXME - this is totally fake calculation */
TAG_IF(route_uri, NUTAG_PROXY(route_uri)), SIPTAG_CONTENT_TYPE_STR("application/dialog-info+xml"), /* could've just kept the type from the payload */
SIPTAG_PAYLOAD_STR(xml_fixup), TAG_END());
switch_safe_free(route_uri);
if (fixup && fixup != helper->payload) {
if (fixup && fixup != helper->payload) {
free(fixup);
}
}