fetch weechat configuration variables
Usage: fetchConfValue('weechat.look.buffer_time_format') will result in models.wconfig['weechat.look.buffer_time_format'] to be set when the result returns from WeeChat. Could maybe be extended to also call a callback when it's available if needed.
This commit is contained in:
parent
e1102522ac
commit
c9dbdc39e4
3 changed files with 37 additions and 1 deletions
|
@ -99,7 +99,7 @@ weechat.factory('connection',
|
||||||
$log.info("Connected to relay");
|
$log.info("Connected to relay");
|
||||||
$rootScope.connected = true;
|
$rootScope.connected = true;
|
||||||
},
|
},
|
||||||
function(e) {
|
function() {
|
||||||
handleWrongPassword();
|
handleWrongPassword();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -306,6 +306,17 @@ weechat.factory('connection',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var fetchConfValue = function(name) {
|
||||||
|
ngWebsockets.send(
|
||||||
|
weeChat.Protocol.formatInfolist({
|
||||||
|
name: "option",
|
||||||
|
pointer: 0,
|
||||||
|
args: name
|
||||||
|
})
|
||||||
|
).then(function(i) {
|
||||||
|
handlers.handleConfValue(i);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var fetchMoreLines = function(numLines) {
|
var fetchMoreLines = function(numLines) {
|
||||||
$log.debug('Fetching ', numLines, ' lines');
|
$log.debug('Fetching ', numLines, ' lines');
|
||||||
|
|
|
@ -13,6 +13,27 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
||||||
models.version = version.split(".").map(function(c) { return parseInt(c); });
|
models.version = version.split(".").map(function(c) { return parseInt(c); });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var handleConfValue = function(message) {
|
||||||
|
var infolist = message.objects[0].content;
|
||||||
|
for (var i = 0; i < infolist.length ; i++) {
|
||||||
|
var key, val;
|
||||||
|
var item = infolist[i];
|
||||||
|
for (var j = 0; j < item.length ; j++) {
|
||||||
|
var confitem = item[j];
|
||||||
|
if (confitem.full_name) {
|
||||||
|
key = confitem.full_name;
|
||||||
|
}
|
||||||
|
if (confitem.value) {
|
||||||
|
val = confitem.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (key && val) {
|
||||||
|
$log.debug('Setting wconfig "' + key + '" to value "' + val + '"');
|
||||||
|
models.wconfig[key] = val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var handleBufferClosing = function(message) {
|
var handleBufferClosing = function(message) {
|
||||||
var bufferMessage = message.objects[0].content[0];
|
var bufferMessage = message.objects[0].content[0];
|
||||||
var bufferId = bufferMessage.pointers[0];
|
var bufferId = bufferMessage.pointers[0];
|
||||||
|
@ -392,6 +413,7 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleVersionInfo: handleVersionInfo,
|
handleVersionInfo: handleVersionInfo,
|
||||||
|
handleConfValue: handleConfValue,
|
||||||
handleEvent: handleEvent,
|
handleEvent: handleEvent,
|
||||||
handleLineInfo: handleLineInfo,
|
handleLineInfo: handleLineInfo,
|
||||||
handleHotlistInfo: handleHotlistInfo,
|
handleHotlistInfo: handleHotlistInfo,
|
||||||
|
|
|
@ -11,6 +11,9 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
||||||
// WeeChat version
|
// WeeChat version
|
||||||
this.version = null;
|
this.version = null;
|
||||||
|
|
||||||
|
// WeeChat configuration values
|
||||||
|
this.wconfig = {};
|
||||||
|
|
||||||
// Save outgoing queries
|
// Save outgoing queries
|
||||||
this.outgoingQueries = [];
|
this.outgoingQueries = [];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue