[polari/gnome-3-20] connections: Factor out getAccountParams() method
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/gnome-3-20] connections: Factor out getAccountParams() method
- Date: Thu, 6 Oct 2016 00:17:50 +0000 (UTC)
commit e36cc5c31ac35988b67b617fe7e133661758e5ab
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Sep 9 02:50:12 2016 +0200
connections: Factor out getAccountParams() method
There are cases where we don't just want to retrieve and unpack
account parameters, but also make sure that appropriate fallbacks
for missing values are in place; split out an appropriate help
function for that.
https://bugzilla.gnome.org/show_bug.cgi?id=771217
src/connections.js | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/connections.js b/src/connections.js
index b64cba8..27b29ef 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -17,6 +17,17 @@ const ErrorHint = {
NICK: 2
};
+function getAccountParams(account) {
+ let params = account.dup_parameters_vardict().deep_unpack();
+ for (let p in params)
+ params[p] = params[p].deep_unpack();
+
+ params['use-ssl'] = !!params['use-ssl'];
+ params['port'] = params['port'] || params['use-ssl'] ? DEFAULT_SSL_PORT
+ : DEFAULT_PORT;
+ return params;
+};
+
const ConnectionRow = new Lang.Class({
Name: 'ConnectionRow',
Extends: Gtk.ListBoxRow,
@@ -299,14 +310,12 @@ const ConnectionDetails = new Lang.Class({
},
_populateFromAccount: function(account) {
- let params = account.dup_parameters_vardict().deep_unpack();
- for (let p in params)
- params[p] = params[p].deep_unpack();
+ let params = getAccountParams(account);
- this._savedSSL = params['use-ssl'] || false;
+ this._savedSSL = params['use-ssl'];
let defaultPort = this._savedSSL ? DEFAULT_SSL_PORT : DEFAULT_PORT;
this._savedServer = params.server || '';
- let port = params.port || defaultPort;
+ let port = params.port;
this._savedNick = params.account || '';
this._savedRealname = params.fullname || '';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]