Javascript: alternative to Xmlhttprequest and Fecth - General Questions and Answers

I have an Human Machine Interface from an European producer called Exor.
The device have an embedded version of Javascript which does not support Xmlhttprequest nor Fecth.
I wish to use these two functions to perform an API call.
If I try to use one of these two functions the system return an error "Can't find variables".
I am struggling in order to find a possible function (alternative to Xmlhttprequest or Fecth) to be able to allow the API call to work in Javascript.
Any idea which could be a function to be used?
Andrew

Related

[Q] PROBLEM SYSTEM NAMESPACE - Visual C++

Hi!!
I'm developing a custom app on visual studio 2008 with visual c++: smart device win32 project with CF 3.5 (same problem on 2.0) for WM6.
It's my first WM app so I'd like to learn how all is workin and not just how to make all work!!
Anyway my app involves a Timer, a serialized FileWriter (to save config parameters taken from user interface) and some bluetooth tasks.
I discover that CF doesn't support binary file writers and the timer class contained in System::Windows::Forms.. i solved this task tryin to use XML file writer and System::Threading::Timer.
(msdn.microsoft.com/en-us/library/aa446549.aspx here i have what is supported and what is not)
But here i had the main problem:
'System' : is not a class or namespace name
'System' : a namespace with this name does not exist
I had this one everytime i try to use features of System namespace, i googled this problem and he answered to compile with '/clr' opt .. ye i know i have to do that but it works just on usual win32 project!!!
There isn't '/clr' opt on smart device's property page!!! I think cause you can't apart from managed code in this kind of project (??).
Does someone know how to solve this?
I can't believe we cannot use System nsp in mobile programming -.-'
Thanks to all!!!
Yuri
So.. i begin understanding that the main problem is stupid use of managed and native code. I got that this is not solvable just in vc++ and absumed that just VB and C# can handle mixed programming (both managed and native) i decide to:
Create the mainapp in vb that handle the form control (to get user input data) and the timer.
In the methot that handle the ElapsedTimerEvent call a MY.dll compiled with VC++ in MFC for CF. This lib will contain method for xml file writing and Bluetooth tasks.
Does someone know if this kind of approach contains any error??
Best Regards
Yuri

[Q] Can a P/Invoke be used to call native APIs?

Since I'm not strong in C++, is it possible in a native/hybrid app to use a P/Invoke call to call native APIs from C# code?
So far what I have seen is COM interop where you have to code the bulk of what you want to do in native C++.
Any possibility here and if so how?
No. At least not that we know of. You have to create COM wrappers for native functions.
Various Marshaling APIs, which makes P/Invoke tick, are off-limits.
WP7 apps run under silverlight - the best place to learn about the security model and why p/invoke is not possible is here:
http://msdn.microsoft.com/en-us/library/dd470128(v=vs.95).aspx
As you can see the restriction is quite deep routed in the framework.
It still might be possible to run proper .NET CF executables in the future though if we can get it installed.
pInvoke
I just met a guy today, who successfully published WP7 app, that uses pInvoke - he just filled the Technical Exception form and ... done
It's used for muting system volume when the phone is in range of specified WiFi network (using BG agent) - for example when in range of school Wifi, turn the speaker off.
http://www.windowsphone.com/en-US/apps/6813ea1f-8d71-4ad5-a6d2-f80c193c6ac9
Can anybody confirm this actually works? He haven't tested it, because it won't work in emulator and even not in default developer unlock.
Here's the code he used, disassembled from the app:
http://pastebin.com/PfFm9Wxg
Do you know about any other apps, except apps from OEMs and Microsoft, that use pInvoke?
This gave me an idea, what else could be possible using small use of pInvoke? Maybe even something lot of users are asking for, like battery status on the start screen, who knows?
Thread Moved To WP7 Q&A​
This is a development section, not Q&A. Please post in the correct section!​
OK, a few things:
P/Invoke not working is *very* well documented. The DllImport attribute *appears* to be available, but calling a function that uses it invariably fails. The work-around for native code access is to use COM. There's also a project to re-implement DllImport.
Native code access has been available to homebrew developers for about a year, now. There are many apps which use it, ranging from web servers to registery browsers to yes, even an app that shows your battery status as a live tile on your Start screen...
These apps are not, however, permitted by Microsoft's Marketplace rules. It may be possible to get an exemption (some Marketplace apps do use native code) but by default, all apps that try to use native APIs (either via COM or P/Invoke) are automatically detected and rejected during analysis of the app prior to its approval.
As for the code you linked, it doesn't even compile (WP7 doesn't include CharSet.None, apparently). If you remove the CharSet directive, or if you set it to CharSet.Auto, it will compile but fails when used. You also didn't include any of the #using directives (OK, without the # in C#). Better would have been to just send us the XAP directly (yes we can get it, but a copy/pasted smidge is a lot less useful)
Downloaded the XAP. It's a paid app, so many tools won't find it.
Examining now. Nothing exotic so far. Possibly P/Invoke only works on signed apps?
The actual message signature that I see:
[PreserveSig]
[DllImport("coredll.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi, SetLastError = true)]
private static extern int waveOutGetVolume(IntPtr device, out uint volume);
Note that CharSet.Ansi still doesn't seem to exist. That said, this might simply be due to an outdated interop library that shipped with NoDo, and the Mango one does support this? More investigation...
"Possibly P/Invoke only works on signed apps?"
That's the question! If this actually works, it's possible we can get exception for more pInvoke calls and it might be even possible to certify app in marketplace for showing battery status or similar goodies. It won't be possible using that dllImport project, that's more than sure, but if we use only well defined set of safe pInvoke calls, we might get submission exception. It's definitely worth finding it out, what's possible here

[Q] RichtTextBox control, add Xaml text on runtime

I have a string variable with:
Code:
<Paragraph>Hello <Run FontWeight="bold">bold text</Run> and <Run FontStyle="italic">italic text.</Run> Nice!</Paragraph>
How can I set this text to a RichtTextBox on runtime? My tries ended up in the above text as plaintext in the RichTextBox.
Try RTF or working with the Blocks collection
If the WP7 RichTextBox control is anything like other such controls Microsoft built over the years, it may work with RTF internally:
http://en.wikipedia.org/wiki/Rich_Text_Format
It's a long shot, but you might try that.
Alternative: Try to work with the Blocks collection, like they do here:
http://msdn.microsoft.com/en-us/library/system.windows.controls.richtextbox.blocks(v=vs.95).aspx
Thank you rbrunner7
That the solution for me was to use the RichTextBox.Xaml property and insert Xaml code into it. Unfortunately this wasn't ideal for my app, so currently I'm using the Webbrowser control
Hmm, the very first link returned by Google has all info you need: http://www.silverlightshow.net/items/Working-with-the-Silverlight-Rich-Text-Box-control.aspx
Nice link
That's really quite a good article about this control.
Interesting how different this "Rich Text" control is from earlier such controls from Microsoft.
I suspected another one of those WP7 Silverlight controls that are mostly wrappers around native controls like the TextBox control. But this looks like a true Silverlight control written in C# instead.
So there might be no native RTF based Rich Text control in WP7? Was there one in Windows Mobile?

[Q]how to use ShellExecute() in wp7RootToolsSDK 0.2.1.0 alpha

hi.Heathcliff74 released the wp7RootToolsSDK 0.2.1.0 alpha,i want to test ShellExecute(string a).i post the GUID of App (or the name of app )to the argument,but it doest work.
SO anybody konws the meanings of ShellExecute or the
use of it?
ShellExecute is usually used to "open" a file. Basically, if the HKEY_CLASSES_ROOT defines a way to handle a given filetype (for example, .PDF files or HTTP: URIs), ShellExecute can be used to invoke the defalt action on that file or URI or whatever.
It's possible to use it for launching apps, but it's not so easy as what you're trying. There's another API (CreateSession, I think) which is specifically for launching built-in or third-party tasks (apps, essentially).
sorry,there isn't a API named CreateSession ~~~~
You're right, it's actually SHLaunchSessionByUri. It's in aygshell (like many things). It appears to be totally undocumented, but it's what the DllImport project uses.
Of course, I could probably easily enough write an app that handles the "app://" URI scheme; the app would get started and then it would use LaunchSessionByUri to start whatever you were trying to call in the first place. This would also be a way to launch apps from the browser...

Hiding Android API Calls

I wanted to know that whether an app uses a specific Android API (e.g. that API can be getApkContentSigners()). So, is it possible that we can hide the Android API call without Reflections?
Because, if it is through reflections, then even the method which we will be invoking, we have to specify it as a string literal and store it in a variable. So, if we are decompiling the apk (through jadx-gui), we can still see the Android API call. Is there any other methodology, that can be used to hide the Android API calls?
Are commercial tools like dex-guard has the capability to hide the Android API calls, so that when we try to disassemble/decompile it, and we are doing a pattern-based search to find the API call, we won't be able to see it?
Thanks a lot for helping me

Categories

Resources