home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / macros / proxy.kmm < prev    next >
Text File  |  2007-05-04  |  4KB  |  96 lines

  1. # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
  2.  
  3. # ---------- Custom Proxies ----------------------------------------------------------------------------------------
  4. #
  5. # Dependencies    : main.kmm ($macroPrefBranch)
  6. # Resources    : -
  7. # Preferences    : kmeleon.plugins.macros.proxy[1-3].name
  8. #          kmeleon.plugins.macros.proxy[1-3].http
  9. #          kmeleon.plugins.macros.proxy[1-3].http_port
  10. #
  11. # ------------------------------------------------------------------------------------------------------------------
  12.  
  13. Proxy_None{
  14. menuchecked=(getpref(INT,$_Proxy_Active."type")==0);
  15. setpref(INT,$_Proxy_Active."type",0); &_Proxy_Status;
  16. }
  17. Proxy_Auto{
  18. menuchecked=(getpref(INT,$_Proxy_Active."type")==4);
  19. setpref(INT,$_Proxy_Active."type",4); &_Proxy_Status;
  20. }
  21. Proxy_File{
  22. menuchecked=(getpref(INT,$_Proxy_Active."type")==2);
  23. getpref(STRING,$_Proxy_PACURL)==""?0:setpref(INT,$_Proxy_Active."type",2); &_Proxy_Status;
  24. }
  25. Proxy_Custom{
  26. menuchecked=((getpref(INT,$_Proxy_Active."type")==1)*(getpref(STRING,$_Proxy_Custom.$ARG.".http")==getpref(STRING,$_Proxy_Active."http")));
  27. $__srvr=getpref(STRING,$_Proxy_Custom.$ARG.".http");
  28. $__port=getpref(INT,$_Proxy_Custom.$ARG.".http_port");
  29. # When no server url is set, do not change anything!
  30. $__srvr==""?0:setpref(STRING,$_Proxy_Active."http",$__srvr);
  31. $__srvr==""?0:setpref(INT,$_Proxy_Active."http_port",$__port);
  32. $__srvr==""?0:setpref(INT,$_Proxy_Active."type",1); &_Proxy_Status;
  33. }
  34. Proxy_Configuration{
  35. $_tit=_("HTTP Proxy Configuration"); $_i=4;
  36. $__url=getpref(STRING,$_Proxy_PACURL);
  37. $__msg=sub("%n",$_i,_("Current settings for automatic proxy configuration:"))."\n\n".sub("%s",$__url==""?_("(not set)"):$__url,_("URL: %s"))."\n\n"._("Do you want to change these settings?");
  38. $__key=confirm($__msg,$_tit,YESNOCANCEL,QUESTION); $__key==YES?&_Proxy_ConfigurationFile:($__key==NO?$_i=1:0);
  39. while($_i!=4) &_Proxy_ConfigurationLoop;
  40. }
  41.  
  42. # ----- PRIVATE
  43.  
  44. $_Proxy_Active="network.proxy.";
  45. $_Proxy_PACURL=$_Proxy_Active."autoconfig_url";
  46. $_Proxy_Custom=$macroPrefBranch."proxy";
  47.  
  48. _Proxy_Status{
  49. $__data=getpref(INT,$_Proxy_Active."type");
  50. $__data==0?statusbar(_("Connecting directly")):0;
  51. $__data==1?statusbar(sub("%url",getpref(STRING,$_Proxy_Active."http"),sub("%port",getpref(INT,$_Proxy_Active."http_port"),_("Connecting over proxy %url:%port")))):0;
  52. $__data==2?statusbar(sub("%s",getpref(STRING,$_Proxy_PACURL),_("Connecting according to %s"))):0;
  53. $__data==4?statusbar(_("Connecting over any detected proxy")):0;
  54. }
  55.  
  56. _Proxy_ConfigurationFile{
  57. $__data=prompt(_("Automatic proxy configuration URL:"),$_tit,getpref(STRING,$_Proxy_PACURL));
  58. $__data==""?0:setpref(STRING,$_Proxy_PACURL,$__data);
  59. &Proxy_Configuration;
  60. }
  61. _Proxy_ConfigurationLoop{
  62. $_name=getpref(STRING,$_Proxy_Custom.$_i.".name");
  63. $_srvr=getpref(STRING,$_Proxy_Custom.$_i.".http");
  64. $_port=getpref(INT,$_Proxy_Custom.$_i.".http_port");
  65. $__msg=sub("%n",$_i,_("Current settings for proxy %n:"))."\n\n".sub("%s",$_name,_("Server name:\t%s"))."\n".sub("%s",$_srvr==""?_("(not set)"):$_srvr,_("Server URL:\t%s"))."\n".sub("%s",$_port==0?_("(not set)"):$_port,_("Server port:\t%s"))."\n\n"._("Do you want to change these settings?");
  66. $__key=confirm($__msg,$_tit,YESNOCANCEL,QUESTION); $__key==YES?&_Proxy_ConfigurationChange:($__key==NO?$_i=$_i+1:$_i=4);
  67. }
  68. _Proxy_ConfigurationChange{
  69. $_name=prompt(_("Server name:"),$_tit,$_name);
  70. $_name==""?0:setpref(STRING,$_Proxy_Custom.$_i.".name",$_name);
  71. $_name==""?$_srvr="":$_srvr=prompt(_("Server URL:"),$_tit,$_srvr);
  72. $_srvr==""?0:setpref(STRING,$_Proxy_Custom.$_i.".http",$_srvr);
  73. $_srvr==""?$_port="":$_port=prompt(_("Server port:"),$_tit,$_port);
  74. $_port==""?0:setpref(INT,$_Proxy_Custom.$_i.".http_port",$_port);
  75. &_Proxy_BuildMenu;
  76. }
  77.  
  78. _Proxy_BuildMenu{
  79. # tools menu
  80. $_p="Pro&xy";
  81. setmenu(PrivacySecurity,popup,$_p);
  82. setmenu($_p,macro,"&Direct Connection",Proxy_None);
  83. setmenu($_p,macro,"&Auto Detect",Proxy_Auto);
  84. setmenu($_p,macro,"Auto &Configure",Proxy_File);
  85. $_j=1; while($_j!=4) &_Proxy_BuildMenuLoop;
  86. setmenu($_p,macro,"Con&figure...",Proxy_Configuration);
  87. setmenu($_p,separator,"Con&figure...");
  88. rebuildmenu($_p);
  89. }
  90. _Proxy_BuildMenuLoop{
  91. setmenu($_p,macro,getpref(STRING,$_Proxy_Custom.$_j.".name"),"Proxy_Custom(".$_j.")"); $_j=$_j+1;
  92. }
  93. $OnInit=$OnInit."_Proxy_BuildMenu;";
  94.  
  95. # ------------------------------------------------------------------------------------------------------------------
  96. $macroModules=$macroModules."Proxy;";