Commit d85fd78f authored by Florian Müllner's avatar Florian Müllner
Browse files

app: Add 'save-identify-password' action

Implement saving of cached "identify" parameters and expose a
corresponding action, so the components that ask for user
confirmation can actually work as promised :-)

https://bugzilla.gnome.org/show_bug.cgi?id=709982
parent d5f3c5fd
......@@ -78,6 +78,8 @@ const Application = new Lang.Class({
{ name: 'edit-connection',
activate: Lang.bind(this, this._onEditConnection),
parameter_type: GLib.VariantType.new('o') },
{ name: 'save-identify-password',
parameter_type: GLib.VariantType.new('o') },
{ name: 'help',
activate: Lang.bind(this, this._onShowHelp),
accels: ['F1'] },
......
......@@ -151,6 +151,8 @@ const TelepathyClient = new Lang.Class({
handler: Lang.bind(this, this._onReconnectAccountActivated) },
{ name: 'authenticate-account',
handler: Lang.bind(this, this._onAuthenticateAccountActivated) },
{ name: 'save-identify-password',
handler: Lang.bind(this, this._onSaveIdentifyPasswordActivated) }
];
actions.forEach(a => {
this._app.lookup_action(a.name).connect('activate', a.handler);
......@@ -337,6 +339,35 @@ const TelepathyClient = new Lang.Class({
});
},
_onSaveIdentifyPasswordActivated: function(action, parameter) {
let accountPath = parameter.deep_unpack();
let account = this._accountsMonitor.lookupAccount(accountPath);
if (!account)
return;
let data = this._pendingBotPasswords.get(account.object_path);
if (!data)
return;
Utils.storeIdentifyPassword(account, data.password, (res) => {
if (res)
this._saveIdentifySettings(account, data);
this._pendingBotPasswords.delete(account.object_path);
});
},
_saveIdentifySettings: function(account, data) {
let settings = this._accountsMonitor.getAccountSettings(account);
if (data.botname == 'NickServ')
settings.reset('identify-botname');
else
settings.set_string('identify-botname', data.botname);
settings.set_string('identify-username', data.username);
},
_isAuthChannel: function(channel) {
return channel.channel_type == Tp.IFACE_CHANNEL_TYPE_SERVER_AUTHENTICATION;
},
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment