[polari] connections: Expose setting to connect through TLS
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] connections: Expose setting to connect through TLS
- Date: Thu, 18 Feb 2016 00:16:22 +0000 (UTC)
commit b766dcb80b5eb33207d6a9fd93e17b71c5d6724b
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 3 03:31:49 2016 +0100
connections: Expose setting to connect through TLS
For predefined networks, we can do The Right Thing(tm) and always use
secure connections when supported. Unfortunately we don't have a way
to do the same for arbitrary servers, so bite the bullet and expose
the setting for custom connections.
https://bugzilla.gnome.org/show_bug.cgi?id=730892
data/resources/connection-details.ui | 26 ++++++++++++++++++++------
src/connections.js | 22 +++++++++++++++++++---
2 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/data/resources/connection-details.ui b/data/resources/connection-details.ui
index dbc0233..aed0000 100644
--- a/data/resources/connection-details.ui
+++ b/data/resources/connection-details.ui
@@ -31,7 +31,6 @@
bind-property="has-service"
bind-flags="invert-boolean|sync-create"/>
<property name="halign">end</property>
- <property name="margin-bottom">24</property>
<property name="label" translatable="yes">_Server</property>
<property name="use-underline">True</property>
<property name="mnemonic-widget">serverEntry</property>
@@ -47,7 +46,6 @@
bind-property="has-service"
bind-flags="invert-boolean|sync-create"/>
<property name="hexpand">True</property>
- <property name="margin-bottom">24</property>
<property name="activates-default">True</property>
</object>
<packing>
@@ -56,6 +54,22 @@
</packing>
</child>
<child>
+ <object class="GtkCheckButton" id="sslCheckbox">
+ <property name="visible" bind-source="Gjs_ConnectionDetails"
+ bind-property="has-service"
+ bind-flags="invert-boolean|sync-create"/>
+ <property name="label" translatable="yes">Use secure c_onnection</property>
+ <property name="margin-bottom">24</property>
+ <property name="xalign">0</property>
+ <property name="draw-indicator">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">2</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkLabel" id="nickname_label">
<property name="visible">True</property>
<property name="halign">end</property>
@@ -65,7 +79,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -77,7 +91,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">2</property>
+ <property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -90,7 +104,7 @@
</object>
<packing>
<property name="left-attach">0</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -103,7 +117,7 @@
</object>
<packing>
<property name="left-attach">1</property>
- <property name="top-attach">3</property>
+ <property name="top-attach">4</property>
</packing>
</child>
</template>
diff --git a/src/connections.js b/src/connections.js
index eaeda41..5ccb10c 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -8,6 +8,9 @@ const Tp = imports.gi.TelepathyGLib;
const AccountsMonitor = imports.accountsMonitor;
const NetworksManager = imports.networksManager;
+const DEFAULT_PORT = 6667;
+const DEFAULT_SSL_PORT = 6697;
+
const ErrorHint = {
NONE: 0,
SERVER: 1,
@@ -174,7 +177,8 @@ const ConnectionDetails = new Lang.Class({
InternalChildren: ['nameEntry',
'serverEntry',
'nickEntry',
- 'realnameEntry'],
+ 'realnameEntry',
+ 'sslCheckbox'],
Properties: { 'can-confirm': GObject.ParamSpec.boolean('can-confirm',
'can-confirm',
'can-confirm',
@@ -204,6 +208,8 @@ const ConnectionDetails = new Lang.Class({
Lang.bind(this, this._onCanConfirmChanged));
this._realnameEntry.connect('changed',
Lang.bind(this, this._onCanConfirmChanged));
+ this._sslCheckbox.connect('toggled',
+ Lang.bind(this, this._onCanConfirmChanged));
let realnameStore = new Gtk.ListStore();
realnameStore.set_column_types([GObject.TYPE_STRING]);
@@ -247,6 +253,8 @@ const ConnectionDetails = new Lang.Class({
params.port = port;
if (this._realnameEntry.text)
params.fullname = this._realnameEntry.text.trim();
+ if (this._sslCheckbox.active)
+ params.use_ssl = true;
return params;
},
@@ -256,11 +264,13 @@ const ConnectionDetails = new Lang.Class({
this._savedServer = '';
this._savedNick = GLib.get_user_name();
this._savedRealname = '';
+ this._savedSSL = false;
this._nameEntry.text = this._savedName;
this._serverEntry.text = this._savedServer;
this._nickEntry.text = this._savedNick;
this._realnameEntry.text = this._savedRealname;
+ this._sslCheckbox.active = this._savedSSL;
if (this._serverEntry.visible)
this._serverEntry.grab_focus();
@@ -277,8 +287,10 @@ const ConnectionDetails = new Lang.Class({
for (let p in params)
params[p] = params[p].deep_unpack();
+ this._savedSSL = params['use-ssl'] || false;
+ let defaultPort = this._savedSSL ? DEFAULT_SSL_PORT : DEFAULT_PORT;
this._savedServer = params.server || '';
- let port = params.port || 6667;
+ let port = params.port || defaultPort;
this._savedNick = params.account || '';
this._savedRealname = params.fullname || '';
@@ -292,13 +304,15 @@ const ConnectionDetails = new Lang.Class({
this._nickEntry.text = this._savedNick;
this._realnameEntry.text = this._savedRealname;
this._nameEntry.text = this._savedName;
+ this._sslCheckbox.active = this._savedSSL;
},
get can_confirm() {
let paramsChanged = this._nameEntry.text != this._savedName ||
this._serverEntry.text != this._savedServer ||
this._nickEntry.text != this._savedNick ||
- this._realnameEntry.text != this._savedRealname;
+ this._realnameEntry.text != this._savedRealname ||
+ this._sslCheckbox.active != this._savedSSL;
return this._serverEntry.get_text_length() > 0 &&
this._nickEntry.get_text_length() > 0 &&
@@ -376,6 +390,8 @@ const ConnectionDetails = new Lang.Class({
details.port = GLib.Variant.new('u', params.port);
if (params.fullname)
details.fullname = GLib.Variant.new('s', params.fullname);
+ if (params.use_ssl)
+ details['use-ssl'] = GLib.Variant.new('b', params.use_ssl);
let removed = Object.keys(oldDetails).filter(
function(p) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]