PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

An easy way of switching proxy/VPN settings

At http://www.firstloox.org//forums/showthread.php?t=3815 , a question has been asked about an easy way of switching proxy/VPN settings before connecting to a different Wi-Fi network. As this question is very important - you may often want to switch, for example, proxy servers while you're browsing and you don't want to re-enter the entire proxy address each time you do this -, I've decided to spend some time on explaining this and diving into the Registry to find out how it internally stores connectivity-related information.

It's, fortunately, pretty easy to dynamically change the proxy/VPN info before switching networks with the built-in Connection Manager in any Pocket PC PDA from PPC2k2 on. PPC2k2 was revolutionary in that it introduced the 'Work'/'The Internet' distinction and, also, the ability to define more than one so-called 'connection groups', each having separate VPN and proxy server information (which are common to all connections defined in these connection groups). This means that, in Wi-Fi, where you don't need to specify any connection inside connection groups, you can just switch connection groups to make the changes visible. (With modem-based connections like GPRS, on the other hand, you need to re-create each connection in all the connection groups you define. This definitely leads to some additional work and data duplication, but can't be circumvented.)

You only need to create two or more connection groups in Connection Manager with the proxy/VPN data pairs necessary. Then, before connecting to a given Wi-Fi network, just click the Connectivity icon on the taskbar, click the Settings links, click the Advanced tab and the Select Networks button. Then, just choose the connection group in the drop-down list at the bottom (in the Programs that automatically connect to a private network should connect using section) that has the right proxy and VPN info for your particular Wi-Fi connection and connect.

How can you create the right connection group? It's pretty easy. Just click the New... button in the above-mentioned Programs that automatically connect to a private network should connect using section:

Image

Just enter a new name for this group; say, 'serverConfig1', in the 'Enter a name for these settings:' input field.

Then, if the particular server requires VPN (if it doesn't, ignore this step) click the VPN tab and, there, click New. Fill in the necessary VPN info, by pressing the Next each time between the pages; finally, press Finish.

To set up the proxy server, click the Proxy Settings tab. Check in both checkboxes. If the proxy server is listening at port 80, then, just enter its address in the Proxy server: input field here:

Image

Otherwise (the proxy server is listening on some other port), press Advanced and fill in the HTTP Server and Port addresses:

Image

When you're finished, just click OK.

Do the same for all different configuration pairs - always create a new connection group for all of them in the 'Work' (Programs that automatically connect to a private network should connect using) section. Make sure you name them properly so that their name reflects to what they configure.

That's all you need to know about easy switching the proxy/VPN information.

Please note that, if you (or anyone you know) happen to speak Hungarian, you may want to read my 170 kchar-long article on all this stuff at http://menneisyys.freeweb.hu/gprs/ . It contains everything about connectivity issues you need to know. Unfortunately, online English resources discussing how the Connectivity works are pretty rare; see for example http://www.pocketpcthoughts.com/forums/ ... hp?t=39784 on this.

Advanced stuff - how the Connectivity-related registry does work?

If you want to know what's happening behind the scenes and want to know how the Connectivity-related registry entries link each other, where they are located etc, read on.

1, If you use, for example, The Internet connection group (the default with Wi-Fi connections), go to Connectivity/Settings/Advanced/Select Networks and see what's listed in the upper drop-down menu. Any other group than My ISP can have a proxy server. Let's say it lists Bluetooth Settings - it's a connection group created by Bluetooth Manager when you set up a mobile phone-based connection. Anything else can be here - if the above-mentioned, restricted My ISP is here, just change it to, say, My Work Network to be able to set the proxy.

Image

2, now, if you haven't already done so, set up a proxy for the connection group you use. It has already been explained in the first section.

3, now, you'll need to find out the DestID value of Bluetooth Settings. Again, it's the group name I'm using for this example. It may be anything; the point is that it must be the chosen connection group in the above (that is, "The Internet") drop-down list on the Connectivity/Settings/Advanced/Select Networks screen. Go to with Resco Registry Editor (the only PPC regeditor that is able to export a given regkey and not just the entire registry structure; unfortunately, its best, free alternatives, PHM Registry Editor and Tascal Registry Editor, can't do the same) [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Destinations\Bluetooth Settings] and write down (for example, copy it to the clipboard) the value of DestID:

Image

To be able to use exact figures in this tutorial, let's say it's {8831E4CC-C397-4337-B08D-0C66A6347D2F}.

4, now, go to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers].

There, there will be four groups:

Image

You need to iterate over them until you find the group that also has subkeys that have HTTP in their names. It's the third group named {EF097F4C-DC4B-4c98-8FF6-AEF805DC0E8E} in the following picture:

Image

(note that 'default' is an access point name I've used on the test machine. I didn't use other Access Points (AP); this is why there're no more AP names listed in the same group.)

5, now, go to [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers\{EF097F4C-DC4B-4c98-8FF6-AEF805DC0E8E}\HTTP-{8831E4CC-C397-4337-B08D-0C66A6347D2F}]. Here, I've used bold to denote the DestID found in step 3 and underline to denote the proxy setting group under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ConnMgr\Providers found in step 4:

Image

Export it.

Image

6, transfer it to the desktop via, say, Total Commander and the WinCE FS plug-in (see http://pocketpcmag.com/forum/topic.asp?TOPIC_ID=15577 on setting it up and using) and edit it there by making differently-named copies of it and only editing the

"Proxy"="some proxy addy listening at port 80:8081"

row in it.

I recommend that you name the files according to the proxy server/port they use so that you always know what you load.

7, copy they back to the PDA, into any directory.

8, then, just click the given registry file before connecting to a network that uses the proxy in question. Fortunately, you don't need to reset your device to make the proxy change visible.
I'd also add that if you go on with the direct registry hacking method, you save a lot of effort:

- if you use this trick with modem-based connections (and not Wi-Fi, which is quite independent from the Connectivity mechanism defined here), the need for setting up the same connection in different connection groups. Then, as you only have one group to change its proxy server, you don't need to re-setup the same connection in several connection groups, which, if you have several proxy servers you want to frequently switch between, can be pretty tiring. Furthermore, keeping all those connections on sync is pretty complicated and error-prone if anything changes (for example, the dial-in [pseudo-]number).

- the need for clicking into Connectivtiy is eliminated, particularly if you put your registry files on your Today screen, changing proxy servers becomes really-really easy - you just click them on the Today screen and voilá - the new registry entry is imported.

How this can be done? It's pretty simple. As I consider Spb Pocket Plus (SPP) the best all-in-one today and generic system plug-in (you may want to read my SPP benchmarks at http://www.pocketpcthoughts.com/forums/ ... hp?t=36376 and my tutorial about relocating it to File Store at http://www.firstloox.org//forums/showthread.php?t=3752 ), I use it to show how it can be done.

1. click-and-tap the Today screen in the screen area of the plug-in where there're no icons, and choose Add/Remove Items...

Image

2. on the next scren, choose Add/File, and go to the previously-uploaded registry file. Select it and press OK:

Image

It'll be put in the Custom category:

Image

Repeat the above steps (Add/File etc) for all the registry import files you want to put on your Today screen.

After this, simply clicking a registry file will automatically import its contents into the Registry (again, assuming Resco Registry Editor is installed).
Chris: Posts like this make me realize PM needs some sort of thumbnail system, even if it is clientside. Garry's Mod Forums has one where it resizes the pics small, and using JS, shows original size when you click on them.
Code:

<script language="Javascript">
// Thubnail image's width & height:
smallWidth = 320;
smallHeight = 240;

// How long the timeout should last (hovering over image before it jumps to it's orignal size, in miliseconds!)
timeoutlength = 500;

timeouts = new Array();

id=1;
function checkSize(obj, storeVars){

if(storeVars){
obj.origWidth=obj.width;
obj.origHeight=obj.height;
obj.id=id;
id++;
}

if(obj.width>obj.height){
if(obj.width>smallWidth){
obj.height=obj.height*(smallWidth/obj.width);
obj.width=smallWidth;
}
}
else{
if(obj.height>obj.width){
if(obj.height>smallHeight){
obj.width=obj.width*(smallHeight/obj.height);
obj.height=smallHeight;
}
}
else{
obj.width=smallHeight;
obj.height=smallHeight;
}
}
}

function origSize(obj){
if(obj.height==obj.origHeight){
checkSize(obj, false);
}
else{
obj.height=obj.origHeight;
obj.width=obj.origWidth;
}
}

function allBig(){
if(document.images){
for(i=0; i < document.images.length; i++){
if(document.images[i].origWidth && document.images[i].origHeight){
document.images[i].width=document.images[i].origWidth;
document.images[i].height=document.images[i].origHeight;
}
}
}
}

// Almost identical to allBig(), but this one puts the width/height to 'smallWidth' or 'smallHeight', instead of it's original size
function allSmall(){
if(document.images){
for(i=0; i < document.images.length; i++){
if(document.images[i].origWidth && document.images[i].origHeight){
checkSize(document.images[i], false);
}
}
}
}

function waitForMe(obj){
if(obj.id){
if(timeouts[obj.id]){
clearTimeout(timeouts[obj.id]);
}

theobj=obj;

if(obj.width != obj.origWidth && obj.height != obj.origHeight){
timeouts[obj.id] = setTimeout("origSize(theobj)", timeoutlength);
}
}
}

function stopWaiting(obj){
if(obj.id){
if(timeouts[obj.id]){
clearTimeout(timeouts[obj.id]);
}

if(obj.width == obj.origWidth && obj.height == obj.origHeight){
theobj=obj;
timeouts[obj.id] = setTimeout("checkSize(theobj, false)", timeoutlength);
}
}
}
</script>

<img src="the_img.jpg" width="800" height="600" onLoad="checkSize(this, true)" onClick="origSize(this)" style="cursor:hand;">

// Onmouseover/out image example:
<a href="some_link.html"><img src="the_img.jpg" width="800" height="600" onLoad="checkSize(this, true)" onnmouseover="waitForMe(this)" onmouseout="stopWaiting(this)"></a>


I have no idea if this works (just threw it here out of my head...), but it should do the trick. Rememeber to let PHP fetch the image size and hard print it in the source (as I did in my example). This is easily done using the getImageSize() function (as you probably already know). I don't know if javascript can read the image's width and height if it's not provided in the source.

Just my 0.00002349556 cents (exchange rate applied :roll:)

EDIT: Fixed error in code (320/width instead of width/320...), and it works like a charm :). Check link.

EDIT 2: To make it even more complete, I've added the big/small click function to it. Ask and you shall receive ;).

EDIT 3: Added two links (for fun) to make all available images big or small, and 'centralized' the thumbnail width & height in the code. That's the last update for now ;).

EDIT 4: Ok Ok, so I finally gave in... sue me :). I've added a PHP getImageSize() function example to the page (so the URL is changed to *.php), to show you how easily PHP can read the size of an offsite image. Just type in a full (meaning: include the 'http://' part!) url to an offsite image and press the magic button ;).

EDIT 5: While thinking about how you should be able to put a link in an image, I've added another part of the code that automatically shows the image in it's full glory after you've paused your mouse over it (0,5sec. in my example). This way you can even make a link in your image and it'll still work :). I've also updated the code in this post.

All codes mentioned above are tested & confirmed working both in Safari, Windows Internet Explorer, Sunrise (mac), FireFox (Firefox doesn't show the hand cursor when using style="cursor: hand;" option) and Mac's Internet Explorer. I've made the javascript fairly compatible so it should work on all browsers worth mentioning ;).

Let me know what you think of it :).
*bump*

I guess nobody is interested in this after all... Could've saved me a shitload of time :lol:.

Ah well, it was fun making it :). Now back to flash we go! (Flash + PHP = *heaven*)
Chris Edwards · 18 May 2005, 15:10 UTC
It does thumbnail stuff if you use the forum upload feature. But yeah, could be useful if it was actually integrated. That javascript thing seems pretty neat. Thanks!
Well, if you want I can help you out :). For reviews (like this one, or the reviews you write, etc.), this could be rather helpful. And the addition of the topmost links in the 'demo' page can be used for people who do not want this feature :).
Chris Edwards · 19 May 2005, 01:14 UTC
Our reviews system already has a thumbnail system built in now. But this would be useful for the forums.
Ah ok, didn't know that about the review system :).

If you're interested in me helping you out (if you want to implement this), contact me anytime :). I'm at my work right now, but this evening (dutch time, that's GMT+1) I can probably help you out.

I've made the code as simple as I could (I mean to implement it), and I can also give you the PHP source code to let you see how I fetched the width/height of an external image (It's described in the code above aswell).

Let me know :).