The trick is that you should HAVE IT ALREADY SET, this proxy - in order to use this option.
And setting the proxy is the manual realtime dynamic procedure made through proxy config (New Configuration) and backended with script, built in XUL-file along with proxy.kmm macro.
Macro creates menu at startup (as always) and script updates it with new Proxy name in real-time while defining this new one.
My problem is that I cannot get how to force KM to create new menu item for my [predefined] proxy.
May be I should create new macro using the same script (but I cannot understand all this stuff
I think this is the part of that script from
pref-proxy.xul (it uses JS-Bridge functions also):
init : function () {
this.list.value = [];
this.name.value = [];
var lst = getPrefValue(this.base + this.list.pref);
if (lst) {
lst = lst.split(";");
for (var i = 0; i < lst.length; i++)
if (lst != "") {
this.list.value[this.list.value.length] = lst;
this.name.value[this.name.value.length] = getPrefValue(this.base + lst + this.name.pref);
}
} // else
// this.compatibility();
var v = getPrefValue(this.base + this.crrnt.pref);
this.crrnt.value = (v == null && this.list.value.length) ? this.list.value[0] : v;
this._setDefaults();
this._initMenulist();
this._initTab(this.temp);
this._setControls("new");
for (var i = 0; i < this.list.value.length; i++)
this._createTab(i);
this._setButtonState();
},
compatibility : function () {
// check for old (macro-generated) configurations
var oldID = this._getNextListID(),
oldName = getPrefValue(this.base + oldID + this.name.pref);
while (oldName) {
this.list.value[this.list.value.length] = oldID;
this.name.value[this.name.value.length] = oldName;
// move these prefs:
pref.setIntPref(this.base + oldID + this.pref.name[6], pref.getIntPref(this.base + oldID + this.pref.name[6].replace(/\.proxy/, "")));
restoreDefault(this.base + oldID + this.pref.name[6].replace(/\.proxy/, ""));
setCharPref(this.base + oldID + this.pref.name[13], getPrefValue(this.base + oldID + this.pref.name[13].replace(/\.proxy/, "")));
restoreDefault(this.base + oldID + this.pref.name[13].replace(/\.proxy/, ""));
oldID = this._getNextListID();
oldName = getPrefValue(this.base + oldID + this.name.pref);
}
if (this.list.value.length)
setCharPref(this.base + this.list.pref, this.list.value.join(";") + (";"));
for (var i = 0; i < this.list.value.length; i++)
for (var j = 0, p, v; j < this.pref.name.length; j++) {
p = this.base + this.list.value + this.pref.name[j];
v = getPrefValue(p);
if (v == null) {
v = this.pref.dflt[j];
switch (this.pref.type[j]) {
case 0:
pref.setBoolPref(p, (v == "true"));
break;
case 1:
pref.setIntPref(p, parseInt(v));
break;
case 2:
setCharPref(p, v);
}
}
}
// check whether any proxy was set through the pre-1.5 native pref panel
var a = [],
old = false;
for (i = 0; i < this.pref.name.length; i++)
switch (i) {
case 0:
a = this.pref.dflt;
break; // type
case 11:
a = "";
break; // name
default:
a = getPrefValue("network" + this.pref.name);
if (a != this.pref.dflt)
old = true;
}
if (old) {
oldID = this._getNextListID();
oldName = document.getElementById("prox_bundle").getString("default_name").replace("%S", oldID.replace("proxy", ""));
this.list.value[this.list.value.length] = oldID;
this.name.value[this.name.value.length] = oldName;
a[0] = (a[12]) ? "2" : "1"; // PAC or manual?
a[11] = oldName;
setCharPref(this.base + this.list.pref, this.list.value.join(";") + (";"));
for (i = 0; i < this.pref.name.length; i++) {
p = this.base + oldID + this.pref.name;
v = a;
switch (this.pref.type) {
case 0:
pref.setBoolPref(p, (v == "true"));
break;
case 1:
pref.setIntPref(p, parseInt(v));
break;
case 2:
setCharPref(p, v);
}
}
}
// update menu
for (i = 0; i < this.list.value.length; i++)
this._addMenu(this.list.value);
},
apply : function (prefID) {
if (prefID) {
for (var i = 0, p, v; i < this.pref.name.length; i++) {
p = "network" + this.pref.name;
v = getPrefValue(this.base + prefID + this.pref.name);
switch (this.pref.type) {
case 0:
pref.setBoolPref(p, (v == "true"));
break;
case 1:
pref.setIntPref(p, parseInt(v));
break;
case 2:
pref.setCharPref(p, v);
}
}
this.crrnt.value = prefID;
setCharPref(this.base + this.crrnt.pref, prefID)
this._initMenulist();
this._setButtonState();
}
},
add : function () {
if (this._invalidName())
return;
var id = this._getNextListID();
for (var i = 0, p, v; i < this.pref.name.length; i++) {
p = this.base + id + this.pref.name;
v = getPrefValue(this.base + this.temp + this.pref.name);
switch (this.pref.type) {
case 0:
pref.setBoolPref(p, (v == "true"));
break;
case 1:
pref.setIntPref(p, parseInt(v));
break;
case 2:
setCharPref(p, v);
}
}
this.list.value[this.list.value.length] = id;
this.name.value[this.name.value.length] = getPrefValue(this.base + id + this.name.pref);
if (this.crrnt.value == null) {
setCharPref(this.base + this.crrnt.pref, id);
this.crrnt.value = id;
}
v = getPrefValue(this.base + this.list.pref);
setCharPref(this.base + this.list.pref, (v == null ? "" : v) + id + ";");
this._addMenu(id);
this._initMenulist();
this._createTab(this.list.value.length - 1);
this._setDefaults();
this._initTab(this.temp);
this._setControls("new");
this.selectTab(id);
},
Edited 1 time(s). Last edit at 11/01/2017 11:44AM by rodocop.