[ekiga/ds-opal-refactoring] SIP: Added outbound proxy support at the account level.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-opal-refactoring] SIP: Added outbound proxy support at the account level.
- Date: Sun, 12 Apr 2015 16:37:34 +0000 (UTC)
commit 2d60edd8710b8501991a2238376b37618e515bee
Author: Damien Sandras <dsandras seconix com>
Date: Sun Apr 12 18:36:29 2015 +0200
SIP: Added outbound proxy support at the account level.
This was a long time requested feature.
The Account code definitely needs a cleanup, but that's for later.
ekiga.convert.in | 1 -
lib/engine/components/opal/opal-account.cpp | 37 ++++++++++++++++++++
lib/engine/components/opal/opal-account.h | 3 ++
lib/engine/components/opal/opal-bank.cpp | 14 ++++++--
lib/engine/components/opal/opal-bank.h | 1 +
.../components/opal/process/sip-endpoint.cpp | 3 ++
lib/engine/components/opal/sip-call-manager.cpp | 6 ---
lib/engine/gui/gtk-frontend/preferences-window.cpp | 4 --
org.gnome.ekiga.gschema.xml.in.in | 5 ---
9 files changed, 55 insertions(+), 19 deletions(-)
---
diff --git a/ekiga.convert.in b/ekiga.convert.in
index 9011fa4..cde66dc 100644
--- a/ekiga.convert.in
+++ b/ekiga.convert.in
@@ -56,7 +56,6 @@ rtp-tos-field = /apps/@PACKAGE_NAME@/protocols/rtp_tos_field
[org gnome PACKAGE_NAME@.protocols.sip]
listen-port = /apps/@PACKAGE_NAME@/protocols/sip/listen_port
-outbound-proxy-host = /apps/@PACKAGE_NAME@/protocols/sip/outbound_proxy_host
forward-host = /apps/@PACKAGE_NAME@/protocols/sip/forward_host
dtmf-mode = /apps/@PACKAGE_NAME@/protocols/sip/dtmf_mode
binding-timeout = /apps/@PACKAGE_NAME@/protocols/sip/binding_timeout
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index fa0e328..178e790 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -83,6 +83,7 @@ xmlNodePtr
Opal::Account::build_node(Opal::Account::Type typus,
std::string name,
std::string host,
+ std::string outbound_proxy,
std::string user,
std::string auth_user,
std::string password,
@@ -136,6 +137,9 @@ Opal::Account::build_node(Opal::Account::Type typus,
xmlSetProp (node, BAD_CAST "type", BAD_CAST "SIP");
break;
}
+ if (typus != H323)
+ xmlNewChild (node, NULL, BAD_CAST "outbound_proxy",
+ BAD_CAST robust_xmlEscape (node->doc, outbound_proxy).c_str ());
xmlNewChild(node, NULL, BAD_CAST "roster", NULL);
@@ -377,6 +381,29 @@ Opal::Account::get_host () const
const std::string
+Opal::Account::get_outbound_proxy () const
+{
+ std::string result;
+ xmlChar* xml_str = NULL;
+
+ for (xmlNodePtr child = node->children; child != NULL; child = child->next) {
+
+ if (child->type == XML_ELEMENT_NODE && child->name != NULL && xmlStrEqual (BAD_CAST "outbound_proxy",
child->name)) {
+
+ xml_str = xmlNodeGetContent (child);
+ if (xml_str != NULL) {
+
+ result = (const char*)xml_str;
+ xmlFree (xml_str);
+ }
+ }
+ }
+
+ return result;
+}
+
+
+const std::string
Opal::Account::get_username () const
{
std::string result;
@@ -656,6 +683,8 @@ Opal::Account::edit ()
request->hidden ("authentication_user", get_authentication_username ());
request->text ("password", _("_Password"), get_password (), _("1234"),
Ekiga::FormVisitor::PASSWORD, false, false);
+ request->text ("outbound_proxy", _("Outbound _Proxy"), get_outbound_proxy (), _("proxy.company.com"),
+ Ekiga::FormVisitor::STANDARD, true, true);
request->hidden ("timeout", "3600");
break;
case Opal::Account::DiamondCard:
@@ -666,6 +695,8 @@ Opal::Account::edit ()
request->hidden ("authentication_user", get_authentication_username ());
request->text ("password", _("_PIN Code"), get_password (), _("1234"),
Ekiga::FormVisitor::NUMBER, false, false);
+ request->text ("outbound_proxy", _("Outbound _Proxy"), get_outbound_proxy (), _("proxy.company.com"),
+ Ekiga::FormVisitor::STANDARD, true, true);
request->hidden ("timeout", "3600");
break;
case Opal::Account::H323:
@@ -697,6 +728,8 @@ Opal::Account::edit ()
Ekiga::FormVisitor::STANDARD, false, false);
request->text ("password", _("_Password"), get_password (), _("1234"),
Ekiga::FormVisitor::PASSWORD, false, false);
+ request->text ("outbound_proxy", _("Outbound _Proxy"), get_outbound_proxy (), _("proxy.company.com"),
+ Ekiga::FormVisitor::STANDARD, true, true);
request->text ("timeout", _("_Timeout"), "3600", "3600",
Ekiga::FormVisitor::NUMBER, false, false);
}
@@ -716,6 +749,7 @@ Opal::Account::on_edit_form_submitted (bool submitted,
std::string new_name = result.text ("name");
std::string new_host = result.text ("host");
+ std::string new_outbound_proxy = result.text ("outbound_proxy");
std::string new_user = result.text ("user");
std::string new_authentication_user;
if (type == Account::Ekiga || type == Account::DiamondCard)
@@ -755,6 +789,7 @@ Opal::Account::on_edit_form_submitted (bool submitted,
else if (new_enabled) {
// Some critical setting just changed
if (get_host () != new_host
+ || get_outbound_proxy () != new_outbound_proxy
|| get_username () != new_user
|| get_authentication_username () != new_authentication_user
|| get_password () != new_password
@@ -785,6 +820,8 @@ Opal::Account::on_edit_form_submitted (bool submitted,
robust_xmlNodeSetContent (node, &child, "name", new_name);
if (xmlStrEqual (BAD_CAST "host", child->name))
robust_xmlNodeSetContent (node, &child, "host", new_host);
+ if (xmlStrEqual (BAD_CAST "outbound_proxy", child->name))
+ robust_xmlNodeSetContent (node, &child, "outbound_proxy", new_outbound_proxy);
if (xmlStrEqual (BAD_CAST "user", child->name))
robust_xmlNodeSetContent (node, &child, "user", new_user);
if (xmlStrEqual (BAD_CAST "auth_user", child->name))
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 858fa30..2cac2d7 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -80,6 +80,7 @@ public:
static xmlNodePtr build_node (Opal::Account::Type typus,
std::string name,
std::string host,
+ std::string outbound_proxy,
std::string user,
std::string auth_user,
std::string password,
@@ -138,6 +139,8 @@ public:
const std::string get_host () const;
+ const std::string get_outbound_proxy () const;
+
/** Returns the user name for the Opal::Account.
* This function is purely virtual and should be implemented by the
* Ekiga::Account descendant.
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index a860b54..63972bf 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -155,6 +155,8 @@ Opal::Bank::new_account (Account::Type acc_type,
request->hidden ("authentication_user", username);
request->text ("password", _("_Password"), password, _("1234"),
Ekiga::FormVisitor::PASSWORD, false, false);
+ request->text ("outbound_proxy", _("Outbound _Proxy"), "", _("proxy.company.com"),
+ Ekiga::FormVisitor::STANDARD, true, true);
request->hidden ("timeout", "3600");
break;
@@ -168,6 +170,8 @@ Opal::Bank::new_account (Account::Type acc_type,
request->hidden ("authentication_user", username);
request->text ("password", _("_PIN Code"), password, _("1234"),
Ekiga::FormVisitor::NUMBER, false, false);
+ request->text ("outbound_proxy", _("Outbound _Proxy"), "", _("proxy.company.com"),
+ Ekiga::FormVisitor::STANDARD, true, true);
request->hidden ("timeout", "3600");
break;
@@ -197,6 +201,8 @@ Opal::Bank::new_account (Account::Type acc_type,
Ekiga::FormVisitor::STANDARD, false, false);
request->text ("password", _("_Password"), password, _("1234"),
Ekiga::FormVisitor::PASSWORD, false, false);
+ request->text ("outbound_proxy", _("Outbound _Proxy"), "", _("proxy.company.com"),
+ Ekiga::FormVisitor::STANDARD, true, true);
request->text ("timeout", _("_Timeout"), "3600", "3600",
Ekiga::FormVisitor::NUMBER, false, false);
break;
@@ -225,6 +231,7 @@ Opal::Bank::on_new_account_form_submitted (bool submitted,
std::string new_user = result.text ("user");
std::string new_authentication_user = (acc_type == Opal::Account::SIP) ? result.text
("authentication_user") : new_user;
std::string new_password = result.text ("password");
+ std::string new_outbound_proxy = result.text ("outbound_proxy");
bool new_enabled = result.boolean ("enabled");
unsigned new_timeout = atoi ((acc_type == Opal::Account::SIP
|| acc_type == Opal::Account::H323) ?
@@ -252,7 +259,7 @@ Opal::Bank::on_new_account_form_submitted (bool submitted,
result.visit (*request);
- add (acc_type, new_name, new_host, new_user, new_authentication_user,
+ add (acc_type, new_name, new_host, new_outbound_proxy, new_user, new_authentication_user,
new_password, new_enabled, new_timeout);
return true;
@@ -263,13 +270,14 @@ void
Opal::Bank::add (Account::Type acc_type,
std::string name,
std::string host,
+ std::string outbound_proxy,
std::string user,
std::string auth_user,
std::string password,
bool enabled,
unsigned timeout)
{
- xmlNodePtr child = Opal::Account::build_node (acc_type, name, host, user, auth_user, password, enabled,
timeout);
+ xmlNodePtr child = Opal::Account::build_node (acc_type, name, host, outbound_proxy, user, auth_user,
password, enabled, timeout);
xmlAddChild (node, child);
@@ -542,7 +550,7 @@ Opal::Bank::migrate_from_gconf (const std::list<std::string> old)
else
acc_type = Account::H323;
- xmlNodePtr child = Opal::Account::build_node (acc_type, name, host, user, auth_user, password, enabled,
timeout);
+ xmlNodePtr child = Opal::Account::build_node (acc_type, name, host, "", user, auth_user, password,
enabled, timeout);
xmlAddChild (node, child);
}
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index bb7557e..22a2ae6 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -150,6 +150,7 @@ private:
void add (Account::Type acc_type,
std::string name,
std::string host,
+ std::string outbound_proxy,
std::string user,
std::string auth_user,
std::string password,
diff --git a/lib/engine/components/opal/process/sip-endpoint.cpp
b/lib/engine/components/opal/process/sip-endpoint.cpp
index 2081c1b..3786aa4 100644
--- a/lib/engine/components/opal/process/sip-endpoint.cpp
+++ b/lib/engine/components/opal/process/sip-endpoint.cpp
@@ -75,6 +75,9 @@ namespace Opal {
params.m_minRetryTime = PMaxTimeInterval; // use default value
params.m_maxRetryTime = PMaxTimeInterval; // use default value
+ if (!account.get_outbound_proxy ().empty ())
+ params.m_addressOfRecord = params.m_addressOfRecord + ";OPAL-proxy=" +
account.get_outbound_proxy ();
+
// Register the given aor to the given registrar
if (!ep.Register (params, _aor)) {
params.m_addressOfRecord = "sip:" + account.get_username () + "@" + account.get_host ();
diff --git a/lib/engine/components/opal/sip-call-manager.cpp b/lib/engine/components/opal/sip-call-manager.cpp
index 70c109f..e772476 100644
--- a/lib/engine/components/opal/sip-call-manager.cpp
+++ b/lib/engine/components/opal/sip-call-manager.cpp
@@ -174,12 +174,6 @@ void Opal::Sip::CallManager::setup (const std::string & setting)
sip_endpoint.SetKeepAlive (PTimeInterval (0, delay), SIPEndPoint::KeepAliveByOPTION);
}
- if (setting.empty () || setting == "outbound-proxy-host") {
- std::string uri = sip_settings->get_string ("outbound-proxy-host");
- PTRACE (4, "Opal::Sip::CallManager\tSet outbound proxy to " << uri);
- sip_endpoint.SetProxy (SIPURL (uri));
- }
-
if (setting.empty () || setting == "dtmf-mode")
set_dtmf_mode (sip_settings->get_enum ("dtmf-mode"));
diff --git a/lib/engine/gui/gtk-frontend/preferences-window.cpp
b/lib/engine/gui/gtk-frontend/preferences-window.cpp
index e19082d..de54f94 100644
--- a/lib/engine/gui/gtk-frontend/preferences-window.cpp
+++ b/lib/engine/gui/gtk-frontend/preferences-window.cpp
@@ -849,10 +849,6 @@ gm_pw_init_sip_page (PreferencesWindow *self,
capabilities_choices.push_back (boost::make_tuple (capabilities[i][0], capabilities[i][1]));
/* Add Misc Settings */
- gm_pw_entry_new (container, _("_Outbound proxy"),
- self->priv->sip_settings, "outbound-proxy-host",
- _("The SIP Outbound Proxy to use for outgoing calls"), false);
-
entry =
gm_pw_entry_new (container, _("Forward _URI"),
self->priv->sip_settings, "forward-host",
diff --git a/org.gnome.ekiga.gschema.xml.in.in b/org.gnome.ekiga.gschema.xml.in.in
index 6568900..1f813dc 100644
--- a/org.gnome.ekiga.gschema.xml.in.in
+++ b/org.gnome.ekiga.gschema.xml.in.in
@@ -418,11 +418,6 @@
<_summary>Listen port</_summary>
<_description>The port to listen to for incoming connections. Ekiga needs to be restarted for the new
value to take effect</_description>
</key>
- <key name="outbound-proxy-host" type="s">
- <default>''</default>
- <_summary>Outbound Proxy</_summary>
- <_description>The SIP Outbound Proxy to use for outgoing calls</_description>
- </key>
<key name="forward-host" type="s">
<default>'sip:'</default>
<_summary>Forward calls to host</_summary>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]