Internet Connection Sharing & OpenNETCF problems - Windows Mobile Software Development

Hello everyone,
I am new to Windows Mobile development and I am actually trying to activate and configure the ICS programmatically. I want to share the connection so from what I understood from the Reference Library, I have to modify the Public Interface Key and Private Interface Key in HKLM/Comm/ConnectionSharing with the corresponding interfaces.
To get these interfaces names, I decided to use the OpenNETCF framework but this one only returns two interfaces (not the bluetooth one nor the usb one). I looked in the reference library but didn't find any other method that could fit. Is there a method that I missed which lists every interfaces?
I don't care of using it but I have been unable to find a good documentation for the .Net Compact Framework 3.5 with a listing of the namespaces, classes and members. If you can point me to this kind of ressource it would be great!
Last question, how can I start the ICS programmatically?
Thank you very much for your help

Related

Help with making a script/CAB to configure WIFI in WM6

Like many other people here, I'm trying to automate (as far as possible) the process of setting up / reconfiguring my device every time I flash a new ROM or hard reset. I've been following the threads on WAP/MMS CABs and, especially, the email client setup method described in this thread:
http://forum.xda-developers.com/showthread.php?p=1153518
I want to do something along the lines of the email client setup (using xml to provision a connection and then turning it into a CAB file) to set up my WIFI connection, especially the chore of entering a WPA key each time.
I dug around a bit on the MSDN site and found these sections with sample code for service providers to provision WIFI in WM5.
http://msdn2.microsoft.com/en-us/library/ms890771.aspx
http://msdn2.microsoft.com/en-us/library/ms890780.aspx
I'm not a developer and don't know anything about the WM5 SDK so several things are not that clear to me, for example, what is the difference between OMA and OMA DM and which should I use to create a cab that runs off the storage card (does it matter, etc.)?
I'm quite prepared to spend some time experimenting with the sample code with the hope that, with some common sense and trial and error I can produce a single block of xml code that anyone on this forum can copy and edit in notepad to insert their own SSID , type of connection, type of security, network key, etc. and then just turn it into a CAB to run after each time they flash their device.
However, before I spend several hours trying to figure this out, I just wanted to throw this out to the Gurus in our community. I'd be grateful for your help if you:
a) Are knowledgeable in the OMA / OMA DM protocols and can answer a few basic questions I have in order to get me started in the right direction, or
b) Have actually done this already and have created a WIFI connection setup script that is easy to edit and tailor (no point in reinventing the wheel), or
c) Know of a an alternative (easier) way to do this altogether
Thanks in advance for any help,
Rob
NOTE TO MODS: I started a new thread here because I could not find this specific topic anywhere else, and I thought it might be most relevant to WM6, because this is where the highest frequency of flashing is going on right now. However, please feel free to move the post if you think it belongs in another section of the forum.
DONE IT. Moved to another section of the forum.
I figured it out. You can now make a CAB with your WIFI settings.
I posted the method here, since there was already a thread by MrVanx dedicated to creating CABs for all kind of settings.
http://forum.xda-developers.com/showthread.php?p=1227587
Enjoy.

[Q] Reading value from registry

Hello,
I'm new to prgramming with C# and wanted to know how I can read a value from the phone's registry and display its data in a TextBox on WP7?
Thanks
The problem isn't C# per se, but the public phone API doesn't allow registry access. If you only need read support, there's a library out there that will give you read capability on most of the registry, though you won't get write (permissions issue). Write surrport is also available on some devices, though that gets... tricky.
One place you can find this library, along with an example of how to use it, is in my IE Search Switcher app, located on this site. The short version is you include the native.dll library, enable some optional application capabilities, use the phone's interop library to get COM import into C#, and import the nativle library using COM. You can then call them from the managed (C#/.NET) code.
The Homebrew library comments and and included readme should explain enough to get you started. Be aware that any app doing this will fail Marketplace certification; you'll only be able to distribute it to people who have developer-unlocked phones.

Nodo with SQL

Hello there,
I am developing a game for wp7, and I want to have a user login with skills an level. This users and levels I want toread and write from an SQL database.
But until now I found no API to connect. Is there any free solution to implement a database in wp7 (not linq)?
Thank you
Sent from my HD7 T9292 using Board Express
Nope, not in Nodo. You have to use linq-To-XML. This should be perfectly fine for small amounts of data.
If you can wait for Mango you can use a SQL CE database, but you still need to use Linq-to-SQL:
http://msdn.microsoft.com/en-us/library/hh202860(v=VS.92).aspx
Sent from my 7 Pro T7576 using Board Express
I know linq as a local database.
If I understand right linq-to-SQL is a one time sync? So I have to sync linq and SQL in the beginning and end of game.
So I would create for each user a linq db and then all linq dbs would be synced in SQL?
Sounds difficult, but I will give it a try this we
Sent from my HD2 with NoDo using Board Express
win98 said:
I know linq as a local database.
If I understand right linq-to-SQL is a one time sync? So I have to sync linq and SQL in the beginning and end of game.
So I would create for each user a linq db and then all linq dbs would be synced in SQL?
Sounds difficult, but I will give it a try this we
Sent from my HD2 with NoDo using Board Express
Click to expand...
Click to collapse
Sorry, do you want to connect to a remote SQL database on a webserver, or a just store a database on the phone itself? If on the phone itself, you can create on database for each user (Mango only).
If you want to sync with a remote server, you will need to interact with the server using some sort of Web Services. Then the Web Services do the reading/writing to/from the SQL sevrer and send the information back to the phone (you can currently do this in Nodo).
It should not be local, if its possible.
I want to subscribe on a free SQL host like I've of these: http://www.free-webhosts.com/free-mysql-database.php
Then I want to do the user management there and want do update the level and skills of the user who is logged in. A bit like a windows live account with the gamer points.
I would be glad if I can use SQL commands with c#.
I hope it become more easier to understand . Thank you for helping.
Do you got any sample code or tutorial how to use SQL in wp7? I failed :-D
Sent from my HD2 with NoDo using Board Express
With NoDo, you can't directly access an SQL server.
And even with Mango, I'd be careful doing such a thing, it can really be dangerous on many levels.
The best solution would be to use a web service, which could be accessed from your phone (via the WebClient class) and would handle the dirty work of connecting to the database and executing SQL queries (eg. inserting or retrieving data and outputting in XML format). This way even if you alter the structure of your database you don't have to change a single line of code in the app (that means you'll avoid resubmission), but only the web service code.
As a general suggestion, handle the more things you can server-side.
SQL Protocols are not really designed to work over slow/unreliable connections like the Internet, especially when it comes to 3G and so on. So it really would be best to encapsulate everything into a WebService to which you then send the Nickname, Game and Score and which allows to get the top rankings as well as a given players rankings.
I guess we won't see the ability to connect to remote SQL Servers through ADO.Net as it most likely would lead to bad user experience anyhow.
StevieBallz said:
SQL Protocols are not really designed to work over slow/unreliable connections like the Internet, especially when it comes to 3G and so on. So it really would be best to encapsulate everything into a WebService to which you then send the Nickname, Game and Score and which allows to get the top rankings as well as a given players rankings.
I guess we won't see the ability to connect to remote SQL Servers through ADO.Net as it most likely would lead to bad user experience anyhow.
Click to expand...
Click to collapse
i am good in sql and there are free sql hosters, thats why i wanted to try it with sql.
so, the webservice, is this kind of php? can i also get some free hosters for these services?
i found in google some sample code, but i dont understand where the data will be "stored". Is this going to be like a "cloud app"
edit: grrr looking for "free webservices" in goog but i just find free homepage hosting sites
I find this topic really interesting because it tackles something I just can't wrap my head around: getting Windows Phone 7 to interact with a SQL database just doesn't seem like it's been explained in a straightforward enough manner.
For instance, my case is one where I need my app to extract info from a MySQL db stored on my website, parse that data and display each entry as an item in a pivot control. Turns out that no, SQL is not supported natively so I must go out of my way and recode my data into something that WP7 can understand; I read it's XML and that makes sense, so I have designed an auto-updating XML file on my website with data I want fed into the WP7 app. This is a workaround to connecting directly to a SQL database, as it only requires there to be a PHP file periodically creating an XML file with the info I need and it won't expose any SQL connection credentials, etc. I do not manage users on my site, so maybe win98 needs to find a way for WP7 to call a PHP page, send it a user ID or something and then retrieve that user's info. But any way, I think XML can work perfectly as a means to communicate between SQL and WP7 apps.
But, I don't know how to make this XML file populate the pages of my app. In Expression Blend I can import the XML as sample data, but it does this during design time and not at run time. This means that Blend can see my data and display it how I want it displayed, but I can't take this to runtime and have it displayed like that on the phone. So far, I haven't seen a single easy to follow step by step tutorial on how to parse information coming from an XML file on a WP7 app.
Any suggestions on how to overcome this hurdle we both face? I am familiar with web programming, but I know jack sh*t about C#, so Linq is greek to me.
Ok so I really got this wrong, that with Mango you get SQL and ports support so that you can remotely interact with an SQL server, with sql commands pretty much like you would do on a desktop and how you could do with WinMo ??
Best practices aside, You still get to do that with webservices ?

TAP/TUN drivers and OpenVPN

So... this is less the announcement of a hack than the announcement of a plan to attempt a hack, but this one is big enough I thought I should get it started now.
Short version: I want to get an OpenVPN client working on my phone (ideally on a stock ROM, with Root Tools).
Somewhat longer explanation: OpenVPN itself is actually a very simple program; it takes a network traffic stream from the "TAP" virtual network device, and sends it over an SSL connection to an OpenVPN server. This is also reversible (listen on the SSL connection, then route the traffic from it to the TAP "device"). It's an incredibly simple way to implement VPN, but is high-performance and secure nonetheless. The entirely to OpenVPN itself is actually implemented in user-space; I don't expect porting it to WP7 to be too difficult (in fact, there's already a WinMo port in progress that would probably be pretty easy to adapt).
The catch is the TAP driver. In short, this is a virtual network adapter that, instead of connecting the computer to a LAN or WAN, connects the computer to a program running on the computer. This program can be any number of things, but in the specific case I'm interested in, it's the OpenVPN client. The idea is that you make TAP the default network device, so every other program sends and receives its traffic over TAP... which in reality means sending and receiving over whatever the program connected to TAP is using where normally a LAN or WAN would be.
The TAP driver, so far as I know, needs to be kernel-mode; it might be possible to implement it as user-mode driver but I'm not sure if this is practical. The trick is to install a third-party driver on WP7 at all. On WinMo / PocketPC devices it was possible (see http://ovpnppc.ziggurat29.com/ovpnppc-main.htm) but those operating systems both lacked the WP7 policy system and had rather better-documented security features and APIs.
Anyhow, I wanted to announce this project, to see who else might have anything - information, code, experience, or simple suggestions - that they could contribute. The repurcussions of this project go far beyond OpenVPN, but since I find myself currently in need of that particular software, that is the goal I'm pursuing. I welcome you to join me.
I'll post updates and such about the project here, along with any code for testing.
Now this is something DEFINITELY that I will follow. I could use this... A guy that I work with has recently parted from his WinMo 6.1 (he hated 6.5) device and one of the things he said he would like to do on his WP is to VPN. I'll be glad to test or help any way I can for this
me too volunteering as beta tester for VPN!!!
I support the
Thank you my friend
Volunteering as beta tester. I have custom full rom
Sent from my 7 Trophy T8686 using Board Express
IPSec or PPTP?
i have worked on a ipsec client for linux before, but it only handle the IKE packets, ah or esp is handled by kernel protocol stack, if there are correct sp & sa, so i think you should make a driver, wp7 cut the builtin ipsec driver.really a very big project, maybe ipsec driver in ce7 can work on wp7.
IPSec and PPTP are both tunneling approaches which are implemented at the driver level. There's nothing wrong with that, but it's not my corrent and immediate goal. OpenVPN's tunneling is achieved over a simple SSL connection, entirely in user-space. This makes it trivial to implement the encryption, but offers the full power of the OpenSSL library for authentication.
While I appreciate the offers of testing, that's going to be some time off. The most useful thing would be developers. For example, has anybody worked with NDIS (Network Driver Interface Specification) before, on CE or even NT? I have not, and while I'm certainly interested in learning it, I was hoping to get this off the ground faster than will be possible if I have to learn it all myself.
I'll be working with the OpenVPN for PocketPC codebase as a starting point. It's still going to take a lot of work, though. I'll probably set up a public version control system to aid in sharing the code and (hopefully) contributing changes.
I'm also going to take a look at CE7 user-mode drivers. If it's possible to write a network driver that way, it may be easier to test and install than a kernel-mode one would be.
On my Mozart:
View attachment 1079356
View attachment 1079398
Thanks, spavlin! Unfortunately, it looks like the app queries a bunch of provisioning providers that WP7 doesn't have. There might be newer variants of those characteristics that I can try to query, though.
It's good that we're able to dump the routing info; that means there's a decent chance we'll also be able to change it. Thanks for checking that for me! Running those on my phone would take some work (not full-unlocked).

Include local JavaScript within PhoneGap on Windows Phone 7

I have a PhoneGap application designed to work on multiple mobile platforms. I'm loading a dynamic HTML content from an external page on the Internet using jQuery Mobile. The problematic system is Windows Phone 7.
This is what I get from the external page, with the URL of the script tag already replaced to load from the phone instead of from the net to save bandwidth:
HTML:
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
This works fine on Android, iPhone and even BlackBerry when I replaced the x-wmapp1: part by a respective counterpart (e.g. file:///android_asset/www/ on Android). However, on Windows Phone 7 it doesn't seem to work at all.
When I try to load the same URL via $.getScript function, it always returns a 404 eror, even if I try and load it with a relative path only.
Any suggestions?
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Thanks for the reply, I will try to post this into the more appropriate forum.
With regards to paths - you can see the path in the HTML snippet I provided in the original question. It's all a bit specific and we cannot afford to load JS directly from page, since that does increase the size of the resulting HTML, sent from an external PHP page, thus increasing bandwidth. This is the first reason why we chose to have all JS and CSS files directly bundled with the application and load them internally rather than from Internet.
Also, all of JS files are included alongside the application as content. I'm using the same approach for all images, since if they were included as a resource, they would not show in the application.
GoodDayToDie said:
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Click to expand...
Click to collapse
First question: have you set the IsScriptEnabled proerty on the control to True? It defaults to False, preventing scripting within the control. Also, changing it only takes effect
on navigation, so if you already loaded the page and then set this property, it still won't work.
Anyhow, I missed that your HTML was coming externally, and only the scripts and stylesheets were local. That's... interesting, and seems reasonable enough, and I can't find any info online that exactly matches your use case. The way you're structuring the script src URI looks weird to me, but I haven't messed with the WebBrowserControl very much at all.
One solution, though a bit hacky:
Use the WebBrowserControl's InvokeScript function to dynamically load scripts into your pages. To do this, you would first need to load the script file content into a .NET String object. The GetResourceStream function is probably your best friend here, combined with ReadToEnd(). Then, just invoke the eval() JS function, which should be built-in, and pass it the JS file content. That will load the JS into the web page, creating objects (including functions) and executing instructions as the files are eval()ed.
Of course, you'd need to do this on every page navigation, but you can actually automate it such that the page itself requests that the app load those scripts. In your app, bind the script-loading function to the ScriptNotify event handler, probably with some parameter such as the name of the script to load. Then, on each page served from your server to the app, instead of including standard <script src=...> tags, use <script>window.external.notify('load localscript1.js')</script> and so on; this will trigger the app's ScriptNotify function for you.
I hope that helps. I can see your use case, but somewhat surprisingly, I couldn't find anybody else online who had either run into your problem or written a tutorial on doing it your way.
Thank you for your reply, it was very informative. One question though - why do you think the way I'm structuring the SCRIPT URI is wierd? I tried to mess around with relative URIs and the such, however those would load the JavaScript file from Internet rather than from the application itself.
The problem I'm running into with your proposed solutions, however is that:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
2. injecting a script programmatically on each navigation would require me to rewrite much of the code we already use for other platforms, not to mention those custom Cordova components, which I don't even know if they can handle such thing
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well. So it either works for everyone else or nobody really thought of doing it my way, since it's basically an Internet application (maybe the don't want to disclose their sources, who knows).
CyberGhost636 said:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
Click to expand...
Click to collapse
In the WebBrowser properties.
CyberGhost636 said:
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well.
Click to expand...
Click to collapse
Of course you not "the only guy". I've tried to port/run a few HTML java-script based games on WP7 (Digger and couple more) more then year ago; they runs well with one HUGE exception - touch screen events are freezing scripts execution and make games not playable.
The "x-wmapp1:" URI scheme was what I was referring to. Not sure where that comes from, but I haven't done anything really with the WebBrowser control.
I have no knowledge of PhoneGap or Cordova; I assume they're "we write your app for you" frameworks? One would assume that such tools would know to set IsScriptEnabled, but you may have to do so manually. A bit of web searching on that direction may be fruitful - maybe earlier versions enabled scripting by default, and now it's disabled by default so you have to specify an option somewhere?
Injecting the script on navigation really doesn't require any major change to the server-side code. I mean, is sending
<script>window.external.notify('load localscript1.js')</script>
really much different from sending
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
? If that's too different, you could instead send
<script src="http://yourserver.com/LoadLocalScripts.js"></script>
and put "LoadLocalScripts.js" on your server with the following code:
window.external.notify('load localscript1.js');
This has only a trivial increase in server traffic and load time, but lets you continue using external scripts instead of inline ones. Very little server-side change needed at all.
Now, the additional client-side code to support the window.external.notify and call InvokeScript... normally I'd say that's dead easy, because it is if you have any experience with the .NET framework, but in your case I get the feeling that this isn't so? I code to the framework, or to the underlying native code, and I tend to code "raw" (very little auto-generated code), so I'm not going to be able to help you solve the problems with a "make me an app" wizard unless I can see the code it generates for you.
For what it's worth, here's the approximate raw code that I'd use (it's over-simplified, but close enough):
void HandleNotify (String param) {
String[] parts = param.split(" ");
if (parts[0] == "load") LoadScript(parts[1]);
}
void LoadScript (String script) {
String content = Application.GetResourceStream(new Uri(script, UriType.Absolute)).ReadToEnd();
theBrowserControl.InvokeScript("eval", content);
}
void theBrowserControl_Loaded (...event handler args here...) {
theBrowserControl.IsScriptEnabled = true;
theBrowserControl.ScriptNotify += HandleNotify;
theBrowserControl.Navigate("http://yoursite.com");
}
the URI comes from Windows Phone itself, with this code, you can see for yourself:
var a = document.createElement('a');
a.setAttribute('href', '.');
alert(a.href);
also, I've been informed that this works in Cordova 2.0, so it might be a 1.8.1 bug... will try and see how it goes
thanks for your help so far!
Looks like it was a problem with PhoneGap 1.8.1 - after upgading to Cordova 2.0 (PhoneGap got renamed) it all works now... thanks for all the help!

Categories

Resources