diff options
Diffstat (limited to '')
-rw-r--r-- | src/chrome/content/dialogs/about.xul | 38 | ||||
-rw-r--r-- | src/chrome/content/dialogs/editcommon.js | 18 | ||||
-rw-r--r-- | src/chrome/content/dialogs/editproxy.js | 311 | ||||
-rw-r--r-- | src/chrome/content/dialogs/editproxy.xul | 119 | ||||
-rw-r--r-- | src/chrome/content/dialogs/manager.xul | 36 |
5 files changed, 522 insertions, 0 deletions
diff --git a/src/chrome/content/dialogs/about.xul b/src/chrome/content/dialogs/about.xul new file mode 100644 index 0000000..3363c81 --- /dev/null +++ b/src/chrome/content/dialogs/about.xul @@ -0,0 +1,38 @@ +<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
+
+<!DOCTYPE dialog SYSTEM "chrome://mproxy/locale/locale.dtd">
+
+<dialog buttons="accept"
+ id="aboutmproxy"
+ ondialogaccept="return true"
+ title="&about.title;"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="mproxy_setVersion()" >
+
+ <script type="application/x-javascript" src="chrome://mproxy/content/globals.js"></script>
+ <script type="application/x-javascript" src="chrome://mproxy/content/about.js"></script>
+ <script language="JavaScript">
+ <![CDATA[
+ function mproxy_setVersion(){
+ var oLabel = document.getElementById("mproxy-version");
+
+ if(oLabel != null && gmproxy_Version != null){
+ oLabel.value += " "+ gmproxy_Version;
+ }
+ }
+ ]]>
+ </script>
+
+ <vbox style="width: 200px;">
+ <hbox>
+ <label value="&common.product.name;" style="font-weight: bold; margin-right: 2px;" />
+ <label value="v" id="mproxy-version" style="margin-left: 2px;" />
+ </hbox>
+ <label value="Based on SwitchProxy by Jeremy Gillick" />
+ <label value="http://multiproxyswitch.blogspot.com"
+ style="color: #0000FF; text-decoration: underline; cursor: pointer;"
+ onclick="open_tab('http://multiproxyswitch.blogspot.com');" />
+ </vbox>
+</dialog>
\ No newline at end of file diff --git a/src/chrome/content/dialogs/editcommon.js b/src/chrome/content/dialogs/editcommon.js new file mode 100644 index 0000000..c24b619 --- /dev/null +++ b/src/chrome/content/dialogs/editcommon.js @@ -0,0 +1,18 @@ +//Has Special Chars
+// + returns true if it only
+// + contains allowed chars
+function mproxy_allowedChars(str){
+ //var regex = new RegExp("[\\s\\.a-zA-Z0-9_]", "g"); //This does not allow utf-8 text!
+ var regex = new RegExp("[(){}\\\[\\\]<>,;:/~`'\"*?^$#&\\t\\n\\r\\\\]", "g");
+ return !regex.test(str);
+}
+
+// Used to test strings
+// + converts space to underscore
+// + and converts to lowercase
+function mproxy_simplify(str){
+ str = str.replace(new RegExp("\\s{2,}", "g"), " ");
+ str = str.replace(new RegExp("\\s", "g"), "_");
+ str = str.toLowerCase();
+ return str;
+}
\ No newline at end of file diff --git a/src/chrome/content/dialogs/editproxy.js b/src/chrome/content/dialogs/editproxy.js new file mode 100644 index 0000000..3e01c58 --- /dev/null +++ b/src/chrome/content/dialogs/editproxy.js @@ -0,0 +1,311 @@ +
+var gIsEdit = false;
+var gList;
+var mproxyURI;
+var mproxy;
+var mproxyConfig;
+var mproxyNameField;
+var gFromProxyManager;
+
+function mproxy_initVals(){
+
+
+ //Set Globals
+ mproxyNameField = document.getElementById("proxy-name");
+
+ //Edit
+ if(window.arguments.length > 1 && window.arguments[0] == "edit" && !mproxy_isEmpty(window.arguments[1])){
+
+ //Proxy URI
+ mproxyURI = window.arguments[1];
+
+ gIsEdit = true;
+ try{
+ mproxy = mproxy_ds_getResource(mproxyURI);
+
+ //Load Fields
+ var mproxyConfig = mproxy_ds_getPropertyValuesFor(mproxyURI);
+ for(key in gmproxy_options){
+ var oField = document.getElementById(key);
+ var sValue = mproxyConfig[gSProxyRdfNodeUriRoot + "#" + key];
+
+ oField.value = sValue;
+ }
+
+ //Label
+ mproxyNameField.value = mproxyConfig[gSProxyRdfNodeName];
+
+ //Set Socks Radio
+ oSocks = document.getElementById("networkProxySOCKSVersion");
+ if(oSocks.value == "4")
+ oSocks.selectedItem = document.getElementById("networkProxySOCKSVersion4");
+ else
+ oSocks.selectedItem = document.getElementById("networkProxySOCKSVersion5");
+
+ //Share one proxy
+ oShare = document.getElementById("networkProxyHTTPShare");
+ if (oShare.value == "true")
+ //oShare.checked = true;
+ document.getElementById("networkProxyHTTPShare").checked = oShare.value;
+
+ else
+ oShare.checked = false;
+
+ //Sharing box
+ //if (document.getElementById("networkProxyHTTPShare").value == "true");
+
+
+
+ }catch(err){ alert(mproxy_getString("error.unknown")); self.close(); }
+ }
+
+ //Enable Fields
+
+ mproxy_enableShareSettingOnStart();
+ mproxy_enableOptions();
+
+ // Thunderbird
+ if(navigator.userAgent.search(/Thunderbird/gi) > -1){
+ document.getElementById("ftp_row").style.display = "none";
+ document.getElementById("gopher_row").style.display = "none";
+ document.getElementById("none_row").style.display = "none";
+ document.getElementById("none_example_row").style.display = "none";
+ }
+}
+
+function mproxy_saveProxy(){
+
+ try{
+
+ /*
+ * Validation
+ */
+ //Empty
+ if(mproxyNameField.value == ""){
+ alert(mproxy_getString("error.add.empty"));
+
+ mproxyNameField.focus();
+ mproxyNameField.setSelectionRange(0, mproxyNameField.textLength);
+
+ return false;
+ }
+ //Special Chars
+ else if(!mproxy_allowedChars(mproxyNameField.value)){
+ alert(mproxy_getString("error.add.invalid"));
+ return false;
+ }
+ //Can't be named 'None' or 'tor'
+ else if(mproxy_simplify(mproxyNameField.value) == mproxy_simplify(mproxy_getString("common.proxy.none"))){
+ alert(mproxy_getString("error.add.duplicate"));
+ return false;
+ }
+ //else if((!gIsEdit) && (mproxy_simplify(mproxyNameField.value) == mproxy_simplify("tor"))){
+ // alert(mproxy_getString("error.add.duplicate"));
+ // return false;
+ // }
+ // else if((!gIsEdit) && (mproxy_simplify(mproxyNameField.value) == mproxy_simplify(mproxy_getString("common.proxy.tor")))){
+ // alert(mproxy_getString("error.add.duplicate"));
+ // return false;
+ // }
+
+ //Is This a Duplicate Label?
+ var oTestProxy = mproxy_ds_getElementForValue(gSProxyRdfNodeName, mproxyNameField.value);
+ if(oTestProxy != null && (!gIsEdit || oTestProxy.Value != mproxy.Value)){
+ alert(mproxy_getString("error.add.duplicate"));
+ return false;
+ }
+
+ //save share setting
+ document.getElementById("networkProxyHTTPShare").value = document.getElementById("networkProxyHTTPShare").checked;
+
+ /*
+ * Edit
+ */
+ if(gIsEdit){
+ //Update RDF Properties
+ for(key in gmproxy_options){
+ mproxy_ds_changePropertyValue(mproxy, (gSProxyRdfNodeUriRoot + "#" + key), document.getElementById(key).value);
+ }
+
+ //Update Name
+ mproxy_ds_changePropertyValue(mproxy, gSProxyRdfNodeName, mproxyNameField.value);
+ }
+ /*
+ * Add
+ */
+ else{
+ var sProxyUri = opener.mproxy_getUniqueProxyUri();
+ var oProxy = mproxy_ds_getResource(sProxyUri);
+
+ //Add Element
+ mproxy_ds_addElement(sProxyUri);
+
+ //Add Properties
+ for(key in gmproxy_options){
+ var oProp = mproxy_ds_getResource(gSProxyRdfNodeUriRoot + "#" + key);
+ mproxy_ds_addProperty(oProxy, oProp, document.getElementById(key).value, true);
+ }
+
+ //Add Name
+ mproxy_ds_addProperty(oProxy, mproxy_ds_getResource(gSProxyRdfNodeName), mproxyNameField.value, true);
+ }
+ /*
+ * Finish
+ */
+ opener.mproxy_populateList();
+
+ if(gIsEdit){
+
+ //Is this proxy is in use, refresh proxy
+ var oPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ if(oPrefs.prefHasUserValue("mproxy.proxy.current")
+ && oPrefs.getCharPref("mproxy.proxy.current") == mproxy.Value){
+
+ opener.mproxy_doCommand("mproxy_setProxy()");
+ }
+ //If not in use, select proxy
+ else{
+ opener.mproxy_doCommand("mproxy_selectItem('"+ mproxyNameField.value +"')");
+ }
+
+ //alert("Proxy Info Changed");
+ }
+ else{
+ opener.mproxy_doCommand("mproxy_selectItem('"+ mproxyNameField.value +"')");
+ //alert("Proxy Added");
+ }
+
+
+ }catch(e){
+ alert(mproxy_getString("error.unknown") +"\n("+ e +")");
+ return;
+ }
+
+ mproxy_openerFocus()
+ return true;
+}
+
+
+//Enable or disable Manual
+// + config options
+function mproxy_enableOptions(){
+
+ var disable = !(document.getElementById("networkProxyType").value == "1"); //if 1 then manual is selected
+
+ //Set Radios
+ oType = document.getElementById("networkProxyType");
+ if(!disable){
+ oType.selectedItem = document.getElementById("type-manual-radio");
+
+ }
+ else{
+ oType.selectedItem = document.getElementById("type-auto-radio");
+ }
+ if (document.getElementById("networkProxyType").value == "2"){
+
+ //Manual Options
+ document.getElementById("networkProxyHTTP").disabled = true;
+ document.getElementById("networkProxyHTTP_Port").disabled = true;
+ document.getElementById("networkProxyHTTPShare").disabled = true;
+ document.getElementById("networkProxySSL").disabled = true;
+ document.getElementById("networkProxySSL_Port").disabled = true;
+ document.getElementById("networkProxyFTP").disabled = true;
+ document.getElementById("networkProxyFTP_Port").disabled = true;
+ document.getElementById("networkProxyGopher").disabled = true;
+ document.getElementById("networkProxyGopher_Port").disabled = true;
+ document.getElementById("networkProxySOCKS").disabled = true;
+ document.getElementById("networkProxySOCKS_Port").disabled = true;
+ document.getElementById("networkProxySOCKSVersion4").disabled = true;
+ document.getElementById("networkProxySOCKSVersion5").disabled = true;
+ document.getElementById("networkProxyNone").disabled = true;
+
+ //Auto
+ document.getElementById("networkProxyAutoconfigURL").disabled = false;
+
+}
+else{
+//When manual setting is checked
+ mproxy_enableShareSetting();
+ document.getElementById("networkProxyHTTP").disabled = false;
+ document.getElementById("networkProxyHTTP_Port").disabled = false;
+ document.getElementById("networkProxyHTTPShare").disabled = false;
+ document.getElementById("networkProxyNone").disabled = false;
+ document.getElementById("networkProxyAutoconfigURL").disabled = true;
+}
+}
+//Set setting on start-up
+function mproxy_enableShareSettingOnStart(){
+var disabletextbox = (document.getElementById("networkProxyHTTPShare").value == "true");
+
+ document.getElementById("networkProxySSL").disabled = disabletextbox;
+ document.getElementById("networkProxySSL_Port").disabled = disabletextbox;
+ document.getElementById("networkProxyFTP").disabled = disabletextbox;
+ document.getElementById("networkProxyFTP_Port").disabled = disabletextbox;
+ document.getElementById("networkProxyGopher").disabled = disabletextbox;
+ document.getElementById("networkProxyGopher_Port").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKS").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKS_Port").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKSVersion4").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKSVersion5").disabled = disabletextbox;
+
+}
+//Disable below when check sharing setting
+function mproxy_enableShareSetting(){
+var disabletextbox = (document.getElementById("networkProxyHTTPShare").checked == true);
+
+ document.getElementById("networkProxySSL").disabled = disabletextbox;
+ document.getElementById("networkProxySSL_Port").disabled = disabletextbox;
+ document.getElementById("networkProxyFTP").disabled = disabletextbox;
+ document.getElementById("networkProxyFTP_Port").disabled = disabletextbox;
+ document.getElementById("networkProxyGopher").disabled = disabletextbox;
+ document.getElementById("networkProxyGopher_Port").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKS").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKS_Port").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKSVersion4").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKSVersion5").disabled = disabletextbox;
+
+ //if (document.getElementById("networkProxyHTTPShare").value == "true"){
+ //mproxy_copySetting();
+//}
+}
+function mproxy_enableShareSettingSelect(){
+var disabletextbox = (document.getElementById("networkProxyHTTPShare").checked == true);
+
+ document.getElementById("networkProxySSL").disabled = disabletextbox;
+ document.getElementById("networkProxySSL_Port").disabled = disabletextbox;
+ document.getElementById("networkProxyFTP").disabled = disabletextbox;
+ document.getElementById("networkProxyFTP_Port").disabled = disabletextbox;
+ document.getElementById("networkProxyGopher").disabled = disabletextbox;
+ document.getElementById("networkProxyGopher_Port").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKS").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKS_Port").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKSVersion4").disabled = disabletextbox;
+ document.getElementById("networkProxySOCKSVersion5").disabled = disabletextbox;
+
+ //if (document.getElementById("networkProxyHTTPShare").value == "true"){
+ mproxy_copySetting();
+//}
+}
+//Copy http proxy
+function mproxy_copySetting(){
+if (document.getElementById("networkProxyHTTPShare").checked == true){
+ document.getElementById("networkProxySSL").value = document.getElementById("networkProxyHTTP").value;
+ document.getElementById("networkProxySSL_Port").value = document.getElementById("networkProxyHTTP_Port").value;
+ document.getElementById("networkProxyFTP").value = document.getElementById("networkProxyHTTP").value;
+ document.getElementById("networkProxyFTP_Port").value = document.getElementById("networkProxyHTTP_Port").value;
+ document.getElementById("networkProxyGopher").value = document.getElementById("networkProxyHTTP").value;
+ document.getElementById("networkProxyGopher_Port").value = document.getElementById("networkProxyHTTP_Port").value;
+ document.getElementById("networkProxySOCKS").value = document.getElementById("networkProxyHTTP").value;
+ document.getElementById("networkProxySOCKS_Port").value = document.getElementById("networkProxyHTTP_Port").value;
+}
+else{
+ document.getElementById("networkProxySSL").value = "";
+ document.getElementById("networkProxySSL_Port").value = "";
+ document.getElementById("networkProxyFTP").value = "";
+ document.getElementById("networkProxyFTP_Port").value = "";
+ document.getElementById("networkProxyGopher").value = "";
+ document.getElementById("networkProxyGopher_Port").value = "";
+ document.getElementById("networkProxySOCKS").value = "";
+ document.getElementById("networkProxySOCKS_Port").value = "";
+}
+}
diff --git a/src/chrome/content/dialogs/editproxy.xul b/src/chrome/content/dialogs/editproxy.xul new file mode 100644 index 0000000..1a1cb01 --- /dev/null +++ b/src/chrome/content/dialogs/editproxy.xul @@ -0,0 +1,119 @@ +<?xml version="1.0"?>
+
+<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
+
+<!DOCTYPE dialog SYSTEM "chrome://mproxy/locale/locale.dtd">
+
+<dialog buttons="accept, cancel"
+ id="mproxyCookieDialog"
+ ondialogaccept="return mproxy_saveProxy()"
+ ondialogcancel="mproxy_openerFocus(); return true;"
+ onload="mproxy_initVals();"
+ title="&add.title;"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/x-javascript" src="chrome://mproxy/content/globals.js"></script>
+ <script type="application/x-javascript" src="chrome://mproxy/content/datasource.js"></script>
+ <script type="application/x-javascript" src="chrome://mproxy/content/dialogs/editcommon.js"></script>
+ <script type="application/x-javascript" src="chrome://mproxy/content/dialogs/editproxy.js"></script>
+
+ <hbox>
+ <label value="&add.proxyLabel;" id="proxy-name-label" />
+ <textbox id="proxy-name" size="30" flex="0" />
+ </hbox>
+ <groupbox>
+ <radiogroup id="networkProxyType" value="1" persist="value">
+ <radio value="1" label="&add.option.manual;" oncommand="mproxy_enableOptions();" id="type-manual-radio" />
+
+ <grid class="indent" flex="1">
+ <columns>
+ <column/>
+ <column flex="1"/>
+ </columns>
+
+ <rows>
+ <row align="center">
+ <hbox align="center" pack="end">
+ <label value="&add.http.proxy.label;" accesskey="&add.http.proxy.key;" control="networkProxyHTTP"/>
+ </hbox>
+ <hbox align="center">
+ <textbox id="networkProxyHTTP" flex="1" oninput="mproxy_copySetting();"/>
+ <label value="&add.port.label;" control="networkProxyHTTP_Port"/>
+ <textbox id="networkProxyHTTP_Port" size="5" oninput="mproxy_copySetting();"/>
+ </hbox>
+ </row>
+
+<row align="center">
+<hbox align="center" pack="end">
+<label value=""/>
+</hbox>
+<hbox align="center">
+<checkbox id="networkProxyHTTPShare" label ="&add.sharing.proxy.label;" checked="false" oncommand="mproxy_enableShareSettingSelect();"/>
+</hbox>
+</row>
+
+ <row align="center">
+ <hbox align="center" pack="end">
+ <label value="&add.ssl.proxy.label;" accesskey="&add.ssl.proxy.key;" control="networkProxySSL"/>
+ </hbox>
+ <hbox align="center">
+ <textbox id="networkProxySSL" flex="1"/>
+ <label value="&add.port.label;" control="networkProxySSL_Port"/>
+ <textbox id="networkProxySSL_Port" size="5"/>
+ </hbox>
+ </row>
+ <row align="center" id="ftp_row">
+ <hbox align="center" pack="end">
+ <label value="&add.ftp.proxy.label;" accesskey="&add.ftp.proxy.key;" control="networkProxyFTP"/>
+ </hbox>
+ <hbox align="center">
+ <textbox id="networkProxyFTP" flex="1"/>
+ <label value="&add.port.label;" control="networkProxyFTP_Port"/>
+ <textbox id="networkProxyFTP_Port" size="5"/>
+ </hbox>
+ </row>
+ <row align="center" id="gopher_row">
+ <hbox align="center" pack="end">
+ <label value="&add.gopher.proxy.label;" accesskey="&add.gopher.proxy.key;" control="networkProxyGopher"/>
+ </hbox>
+ <hbox align="center">
+ <textbox id="networkProxyGopher" flex="1"/>
+ <label value="&add.port.label;" control="networkProxyGopher_Port"/>
+ <textbox id="networkProxyGopher_Port" size="5"/>
+ </hbox>
+ </row>
+ <row align="center">
+ <hbox align="center" pack="end">
+ <label value="&add.socks.proxy.label;" accesskey="&add.socks.proxy.key;" control="networkProxySOCKS"/>
+ </hbox>
+ <hbox align="center">
+ <textbox id="networkProxySOCKS" flex="1"/>
+ <label value="&add.port.label;" control="networkProxySOCKS_Port"/>
+ <textbox id="networkProxySOCKS_Port" size="5"/>
+ </hbox>
+ </row>
+ <row>
+ <spacer/>
+ <radiogroup id="networkProxySOCKSVersion" orient="horizontal">
+ <radio id="networkProxySOCKSVersion4" value="4" label="&add.socks.option.v4;" />
+ <radio id="networkProxySOCKSVersion5" value="5" label="&add.socks.option.v5;" />
+ </radiogroup>
+ </row>
+
+ <row align="center" id="none_row">
+ <hbox align="center" pack="end">
+ <label value="&add.none.label;" accesskey="&add.none.key;" control="networkProxyNone"/>
+ </hbox>
+ <textbox id="networkProxyNone" value="localhost, 127.0.0.1" />
+ </row>
+ <row id="none_example_row">
+ <spacer/>
+ <label value="&add.none.example;" control="networkProxyNone"/>
+ </row>
+ </rows>
+ </grid>
+ <radio value="2" label="&add.option.auto;" oncommand="mproxy_enableOptions();" id="type-auto-radio" />
+ <textbox id="networkProxyAutoconfigURL" size="50" flex="0" disabled="true" />
+ </radiogroup>
+ </groupbox>
+</dialog>
\ No newline at end of file diff --git a/src/chrome/content/dialogs/manager.xul b/src/chrome/content/dialogs/manager.xul new file mode 100644 index 0000000..3cd0cdd --- /dev/null +++ b/src/chrome/content/dialogs/manager.xul @@ -0,0 +1,36 @@ +<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<!DOCTYPE dialog SYSTEM "chrome://mproxy/locale/locale.dtd">
+
+<dialog buttons="accept"
+ id="mproxyCookieDialog"
+ ondialogaccept="mproxy_managerClose(); mproxy_openerFocus(); return true;"
+ ondialogcancel="mproxy_openerFocus(); return true;"
+ onload="mproxy_initProxy();"
+ title="&common.manage.label;" persist="height, width"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+ <script type="application/x-javascript" src="chrome://mproxy/content/globals.js"></script>
+ <script type="application/x-javascript" src="chrome://mproxy/content/datasource.js"></script>
+ <script type="application/x-javascript" src="chrome://mproxy/content/proxy.js"></script>
+ <script>
+ <![CDATA[
+ function mproxy_managerClose(){
+ try{
+ var oPrefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
+ oPrefs.setIntPref("mproxy.proxy.rdf.lastupdate", (new Date()).getTime());
+ } catch(e){ alert(e); }
+ }
+ ]]>
+ </script>
+
+ <hbox align="top" flex="1" style="overflow: auto;">
+ <listbox id="manage-proxy-list" flex="2" rows="10"></listbox>
+ <vbox>
+ <button id="new-button" label=" &common.add.label;" oncommand="mproxy_editProxyDialog(true)" image="chrome://mproxy/content/icons/new.png" />
+ <button id="edit-button" label=" &common.edit.label;" oncommand="mproxy_editProxyDialog(false)" image="chrome://mproxy/content/icons/pencil.png" />
+ <button id="remove-button" label=" &common.remove.label;" oncommand="mproxy_removeProxy(false)" image="chrome://mproxy/content/icons/cross.png" />
+ </vbox>
+ </hbox>
+</dialog>
\ No newline at end of file |