Hi Guys!
I'd like to create a webserver on wm6 so I can contact to Localhost (127.0.0.1) to retrieve Phone info.
Purpose is a Flash app which uses GPS and Camera (Those or not accessable with actionscript)
I want the server to put GPS and Camera information on the localhost.
I know Freestyl (aka WhoNeedsAnIphone) uses a http server to pass some device variables to their flash app. But the project stopt and no code was released.
For Nokia Phone there's a Tool called KuneriLite to acces phone info with Flash.
I Also found Depeche But I don't really understand it....
Any Help/Code/App is welcome.
Jeff
Hi, take a look here: http://goahead.com/products/webserver/download.aspx
I played around with it some time ago.
It has a lot of features like cgi and so on.
Nice Solution....
It Works but im more into C# then C++..
Is there a C# solution for this?
All help is welcome
Depending on how many of the HTTP verbs you really need to support (ie, do you just want to respond to a HTTP get for a certain url?) you could knock up a simple HTTP server in C# in an hour or two tops.
There's tonnes of examples of simple HTTP servers in C# on the web...
Sounds good,
But i'm only able to find C# webservers for PC, not for windows mobile...
The only thing the server has to do is respond from the code, so i dont have to load actual ASP/HTML pages...
Just a listener on Localhost, if i request localhost/req?GetVar=Cam
I can do something like WriteRespone("Cam=" + SomeSysVar)
Here you go
Attached is a C# simple http server application that I knocked up based on the MSDN sample at http://msdn.microsoft.com/en-us/library/bb397809.aspx.
I've not tested it on a phone.
The sample is for the compact framework.
Should work without any hassle.
Complete source included and the simplest parsing possible (currently responds to a http GET request for / with a chunk of HTML with "1" as the body).
Good luck, have fun.
(Oh and I just noticed there's a confusingly commented out line that says "write response" in the source, remove / ignore it.)
You can test the windows app from a web browser by pointing at http://localhost:83
edit:
apologies, i meant to close another thread.
Thnx Alot
Found this solution: http://bansky.net/blog/2007/10/compact-web-server-in-compact-framework/
It Worked for me ;-)
That looks like a good general purpose solution
My example is tailored towards specific custom processing over HTTP rather than serving of files -> in the style of a RESTful API.
From the look of it you can do a similar thing with the Compact Web server by hooking up what the author labels a "Special file type" and adding your custom handling code in there.
[edit]
That said, you could actually edit my example to File.Open whatever was passed as a parameter off the disk and stream that back to the client, providing a more standard HTTP server without configuration.
Nice simple solution u've got!
I will try to get it to work the way i want,
lookin' @ the amount of code it should be a lot faster then my previous solution.
Just noticed a very small bug. I'm refactoring the code to be a little better engineered. I'll upload a new sample shortly (you may have already managed to make use of it).
Right, I've re-engineered the code a little.
While the example now isn't contained in a single file, the source is now far more logical, readable and maintainable.
You'll notice the code that actually deals with the request is now hidden away in the HttpVerbs namespace.
Basically if you look at the file HttpGet.cs there's a good working example of how to implement whatever behaviour you like based off of a HTTP Get request to the server.
Code's pretty decent now, slightly more ready for prime time than previously, generally more type-safe and doesn't rely on string parsing all over the place.
Enjoy.
Binary?
Can you please put here binary (exe file) for Windows Mobile 6.1?
Thanks
Related
NOTES:
The projects if developed will become a generic code baseline for each and every developer seeking codes.
This means projects in this thread is just to give everyone a basic working conceptual code which can be used anywhere in similar projects.
Just think people has great ideas to work on, but they dont have baseline code from where to start as most of them might be learning.
So this thread should help them out giving a working base code..
Any1 interested in building couple of OpenSource Projects for PPC? Ill post concepts.
Lets built next generations of applications together as open source which people can use to learn things as well.
The reason open source is so that everyone can contribute code for a project, and work together to built the best.
Anyone Interested???
------------------------------------------------------------------------------------------------------------------
Project 1: File Indexer for PPC [FIndexer]
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
To index each and every file on PPC with custom options on indexing.
Purpose:
In todays world where 1gb,2gb,4gb cards are available, we store tons of file on our PPC like ebooks, songs, music, videos.
Many times it is not possible to search using a search utility as it may consume battery and we need to wait till file is being search.
This is the place where this FIndexer comes in to picture, where we index our file either manualy or scheduled.
And then searching a file will just take 1 second to return the results.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB.
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 2: File System for PPC [PFS (Pocket File System)]
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
Idea came from Microsoft new file system WinFS.
Correct me if i am wrong, this File system is a file table itself where it keeps track of each and every files in details in Real Time.
Purpose:
In todays world where 1gb,2gb,4gb cards are available, we store tons of file on our PPC like ebooks, songs, music, videos.
Many times it is not possible to search using a search utility as it may consume battery and we need to wait till file is being search.
This is the place where this PFS comes in to picture.
Why use any indexing software also?, let this File system handle it in real time.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB.
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 3: Tic Tac Toe (x & 0) Game (BlueTooth Enabled)
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
This is a game which we always played for fun in good old days and still we play.
We might have wasted good amount of papers to play this game. Classic X & 0
Purpose:
We hardly see any bluetooth enabled games for PPC. Thats the purpose to built a very basic game with 2 players mode on bluetooth.
This may be a good code for all the developers round here who wants to start with some bluetooth code.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB or XML
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 4: Multipurpose Single Line Marquee Scrolling Today Screen Plugin [Like Stock Tickers]
Not Sure if it exists or already available.
Added:
01 Feb 2008
Description:
A today plugin which scrolls like a stock ticker in 1 or 2 lines, and provides useful configurable information like battery info, world time, live money rates, notifications, one liner quotes, jokes, appointments, bluetooth status, and much more, in 1 or 2 scrolling lines.
Purpose:
Many might have noticed too many of today plugin gives a scroll bar to your today screen which dont look good.
This is where this plugin comes in to picture.
This should be completely customizable right from scrolling speed to colors to information to flashing colors speed, bold and much more.
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB.
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 5: Application Specific Backup Tool (Can be a great tool)
Not Sure if it exists or already available.
Added:
04 Feb 2008
Description:
There are several backup tools which takes backup of PPC as a whole and can be restored easily, but:
How many times you feel that you had installed tones of applications and had taken a backup of those, and now when you get a new PDA, you feel like you dont want to again install all the applications installed previously due to certain reasons. By restoring the backup you end up again with all unrequired applications again.
This tool will help you to eliminate those problems by taking backup of each and every application configurations seperately with version informations. Yes now you can backup configurations of your games, your theme managers, your music player configurations and everything and have choice to restore them back again seperately as required.
Yes people who develope tools with configurations involved may have to coporate to tell us where they save the data of their application so we coders can add a plugin code to backup that particular application.
You can say that this tool has a builtin database information of most of the application to backup the configs.
Purpose:
Description above says it all
Language:
C++ is best language for this kind of project because of speed.
Database:
Not sure, but either SQL or Access DB or XML
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Project 6: Application data which synchronizes with Web Services.
Not Sure if it exists or already available.
Added:
07 Feb 2008
Description:
Again this is an application which most coders are going to like who are learning mobile codings. This application mainly shows how to communicate with mobile device application with web service to keep data in sync. Data can be either contacts, games scores, or any text based details.
Yes a today screen plugin would be nice to show some information on sync or other details.
Purpose:
To provide generic code to each coder seeking this kind of communication.
Language:
C++ is best language for this kind of project because of speed.
And either .Net or Java for Web Services.
Database:
Not sure, but either SQL or Access DB or XML
Type:
Open Source
------------------------------------------------------------------------------------------------------------------
All Projects should be easily skinnable by anyone.
People willing to part of this project, than please post your details as follows:
Name:
Skills:
Comments:
Once we have a team than we will go ahead and create documents like
RUD (Requirement Understandings Document)
SRS (Software Requirement Specifications)
What do you guys say??
Wanna work together as one, and built a new world for everyone?
Wait for everyone's view, either good or bad.
I am not sure how good above to projects are, but this thread mainly wants every coder, designer, tester to work together and built something.
List of Contributers (Coders, Designer, Tester, Others)
This place will list all the Contributers (Coders, Designer, Tester, Others)
Screen Design for each Projects goes here
Screen designed by contributers goes in this post.
NOTE:All screens designed will be copyright of the designer and should not be distributed or used without a permission.
Attached a Screen for an idea for Project 4
Notice the first Plugin in Yellow border.
Created by me.
List of Features and Request for Features and Suggestions
List of Features and Request for Features and suggestions goes in this post whomsoever wants. Then the team can make it happen.
Builts / Releases
Builts / Releases Goes in this section.
Technical Disscutions
Important Technical Disscutions will be posted and collected in this post.
Intentionally kept blank 1
Intentionally kept blank 1
Intentionally kept blank 2
Intentionally kept blank 2
Intentionally kept blank 3
Intentionally kept blank 3
Intentionally kept blank 4
Intentionally kept blank 4
Intentionally kept blank 5
Intentionally kept blank 5
zbop has done something similar to what you are looking for in number 4. You place info in reg. keys and then update that info via Mortscript (or however you want) and then it gets scrolled on a today screen line. Check out http://discussion.treocentral.com/showthread.php?t=141375 post #269 for the latest version.
more than 600 views but just 1 reply!
I wonder how does open source developers meets and work together
I decided to give this initiative a fighting chance so I am going to 'sticky' this thread for one week.
If there are no takers I will 'unsticky' it.
Unfortunately, I do not currently have time to take part in this project my self as I am learning to program for Linux and OpenMoko specifically.
greenhacks said:
more than 600 views but just 1 reply!
I wonder how does open source developers meets and work together
Click to expand...
Click to collapse
They don't, they start by making something, small, runnable, interresting, then share it, with the source.
This is more than i could expect from this forum. Thanks a lot.
This is a try to bring many great people in this forum and to develop something great for the forum.
Projects mentioned in this thread is just for start.
People can give their own new ideas so all work together and make something great for all the forum users.
i have no other intentions to start this thread other then bringing all together.
Starting this thread i thought i will also put my skills to help new guys.
Thanks again, and i hope this works out.
Here's a project idea that came up in the herald forums - use your touchscreen as a psudo-wacom tablet while tethered. Yes it would only be on/off and wouldn't sense pressure differences, but would still make for a cool project.
Heared of Android?
I guess you have heared about android,an all open-source linux based platform.And about the total of 10M bounty by Google as an award for the top 50 applications tha will be developed for the platform.So I'm guessing any developers with the skills to do such projects will have their hands full.
After all it sould be reasonably easyer to programm for an all opensource platform than for WM,a closed source platform.
Just my 2 cents.
nstamoul said:
I guess you have heared about android,an all open-source linux based platform.And about the total of 10M bounty by Google as an award for the top 50 applications tha will be developed for the platform.So I'm guessing any developers with the skills to do such projects will have their hands full.
After all it sould be reasonably easyer to programm for an all opensource platform than for WM,a closed source platform.
Just my 2 cents.
Click to expand...
Click to collapse
Count the number of applications developed in this forum by everyone for so called 'closed source platform of wm6'
I do agree with your thoughts and dont say you are wrong, but hey thats a whole different ball game.
Always remember
When a company runs out of concepts, then company organises a competition with great prices. At the end company gets thousands of new concepts. winner gets the price, company gets new product.
same thing happens in open source world as well as close sourced.
If all think in this direction then i can bet, xda will run out of members.
not trying to defend, but this is something which simply cannot be debated or this is not a right place.
tene said:
They don't, they start by making something, small, runnable, interresting, then share it, with the source.
Click to expand...
Click to collapse
Then lets make something small, runnable, interresting, and share with the whole world!
It was very dificult to find this kind of groups, thats the reason internet became so famouse, where we can find different people with great skills from different country and make things possible.
This might not be completely Wizard related, but thats what I have so I'll shoot. I was wondering if anyone had any idea on where to start looking for an ap to view Video Feeds from Security Cameras that are normally accessed via a Java Applet in IE. Like is there possibly a Java app that can display a feed that would be seerate of PIE? Maybe a program that can be changed or slightly modified?
The provider/manufacturer of the equipment doesn't offer anything. Their newer equipment uses ActiveX Controls rather than Java so maybe an upgrade could help? Any ideas/help would be appreciated.
The Company has a Demo of the Java Applet that is used to view the feeds. Same as we use for the bar but we only have 9 feeds. Viewing one feed at a time would be perfectly fine and probaly desired on the smaller screen.
See the demo here...
http://208.50.31.214/ Java VM Page. Login for the Demo is admin : admin
Any Ideas??
Cliffs: Can anyone think of a way to view the feeds in the demo above on a PPC? Java VM related...
ANy good places to go for Java related resources for the WM5? I would like to at least play around with it. Maybe try to tweak and work up a different solution. Any help would be appreciated.
pookrat said:
Maybe try to tweak and work up a different solution. Any help would be appreciated.
Click to expand...
Click to collapse
I'd just hold out for a real browser than can display your java-based feed. Never fear, one's coming...
See: Skyfire.
Take a look: http://webcam-holmes.en.softonic.com/pocket
If your desired feed is actually a "Webcam" then this might be the ticket for you...
SkyFire looks promising. Can't wait to get my hands on a copy. Maybe a Beta a little early?
pookrat said:
Maybe a Beta a little early?
Click to expand...
Click to collapse
Good luck. I think they've passed them all out already, and the licenses are utterly non-transferable, so any beta copies that have been shared out have been unusable by anyone but the authorized recipient.
There's a thread on this board (somewhere, you search...I don't want to) that includes a copy. Your mileage may vary, but I don't think anyone's been able to use it yet.
One last note of caution: Skyfire's license agreement clearly states that they can, if they wish, capture all data transferred to and from (this includes keystrokes, BTW) websites. Privacy on their browser is not reality. This means, for example, if your camera feed was providing illicit or illegal images (like a voyeur cam in a public restroom, for example), they can, and presumably will, point the finger at you. This may change in the future, but hey, they've gotta protect themselves, if they're acting as a go-between for the web and dirty, untrustworthy end-users.
pookrat said:
This might not be completely Wizard related, but thats what I have so I'll shoot. I was wondering if anyone had any idea on where to start looking for an ap to view Video Feeds from Security Cameras that are normally accessed via a Java Applet in IE. Like is there possibly a Java app that can display a feed that would be seerate of PIE? Maybe a program that can be changed or slightly modified?
The provider/manufacturer of the equipment doesn't offer anything. Their newer equipment uses ActiveX Controls rather than Java so maybe an upgrade could help? Any ideas/help would be appreciated.
The Company has a Demo of the Java Applet that is used to view the feeds. Same as we use for the bar but we only have 9 feeds. Viewing one feed at a time would be perfectly fine and probaly desired on the smaller screen.
See the demo here...
http://208.50.31.214/ Java VM Page. Login for the Demo is admin : admin
Any Ideas??
Cliffs: Can anyone think of a way to view the feeds in the demo above on a PPC? Java VM related...
Click to expand...
Click to collapse
Most Java VM's for Windows Mobile are not robust enough to handle Java webcams. At least that's been my experience. I have a Toshiba IK-WB11A webcam in my house. It also uses Java and I've tried PIE, Opera, Minimo, and other WM browsers - none will work.
The only work around I'm aware of is to deconstruct the Java Script to see where / how the webcam is streaming the "video". I was able to do that by loading up and opening all the HTML pages that my webcam served to my PC browser (Firefox > View > Page Source). Typically the video stream is in fact just a JPG that's refreshed every fraction of a second. Once you identify the JPG path / name you can open it directly. Or if you're ambitious you could create your own simple HTML page, add the JPG image, and add some code to auto-refresh in PIE. Something like this code should do the trick...
<meta http-equiv="refresh" content="10;url=http://path/to/my/image/page.html"/>
Ok I am looking for the same thing mate and doing a little search for web goodies to work on the phone . If anybody has any ideas or software let us know.
http://www.getjar.com/products/11112/QSpyCam
http://www.getjar.com/products/13204/LiveStream
wyzepro said:
http://www.getjar.com/products/11112/QSpyCam
Click to expand...
Click to collapse
Nice link I will test it out .
Hi guys,
isn't there someway to develop my Android apps on a webserver so I can work on them via FTP on any machine ?
I have a problem of not being able to continue work on a project once I leave work or leave home.
Please help me.
http://www.google.com/search?hl=&q=remote+desktop
http://www.google.com/search?hl=&q=VNC
http://www.google.com/search?hl=&q=VPN
Maybe even use a SVN.
It's a bit of a hassle, but I just use dropbox. When I finish working at home I copy the project to dropbox. When I get to work it's ready to go. Copy it back again before I leave work.
________________________________
http://ron-droid.blogspot.com
Actually I seccond SVN (or GIT if that's your fancy). It can sometimes be tricky to setup on a remote server but the versioning is well worth it.
I got the impression it wasnt just going from home to work and back that he was having trouble with though. All good suggestions though
OK ?
alostpacket said:
http://www.google.com/search?hl=&q=remote+desktop
http://www.google.com/search?hl=&q=VNC
http://www.google.com/search?hl=&q=VPN
Click to expand...
Click to collapse
Hmm!
just wondering what any of those have to do with Android development ?!?
Thanks
rigman said:
It's a bit of a hassle, but I just use dropbox. When I finish working at home I copy the project to dropbox. When I get to work it's ready to go. Copy it back again before I leave work.
________________________________
http://ron-droid.blogspot.com
Click to expand...
Click to collapse
I appreciate the dropbox suggestion.
As an aside, I put a document into my dropbox on my Linux computer at home and immediately checked for it on my dropbox app on my Android phone - it was not there.
Neighter was it avaiable at work hours later at work - don't know how I might force it to refresh.
How about Eclipse RSE ?
As an Android developer using Eclipse comes with the territory.
I came across some thing called RSE( remote system explorer ).
From what I've read, it should give me FTP access to remote files.
But it fails when I try to configure a "Remote system Type".
Does anyone have sucessful experience with this ?
captsisko said:
Hmm!
just wondering what any of those have to do with Android development ?!?
Click to expand...
Click to collapse
They do stuff like this:
I came across some thing called RSE( remote system explorer ).
From what I've read, it should give me FTP access to remote files.
But it fails when I try to configure a "Remote system Type".
Does anyone have sucessful experience with this ?
Click to expand...
Click to collapse
It sounds like you need to better explain what you're actually trying to do. Are you trying to just take some files with you, or are you trying to be able to access your home computer remotely?
They have different solutions. It sounds like maybe you are confusing the two.
VPN/RemoteDesktop/VNC all have to do with accessing a computer remotely which is what you said you were trying to do originally. However it sounds like that's not what you need. Maybe I misintepreted your post. My appologies.
If you're just trying to take your project from home to work and back, then you should set up a server with SVN (or Git or Mercurial) somewhere, possiblly over SSH.
This can be on your home computer, or work (depending what ports your network admin allows), or on a hosted third party server (such as a shared hosting server like BlueHost, DreamHost, or iPowerWeb or something). I'd recommend the hosted 3rd party solution.
Though, if you use linux at home SSH is built into your system.
Dropbox and FTP are OKish, but you might as well just use a USB stick or something...
But SVN and Git have real version control and intgrate with eclipse. If you have it setup properly you can just hit a command in eclipse's project explorer and all the changes are commited to the remote repository.
So anyways, SVN is my advice too
Thank you very much alostpacket !
You were right about needing to explain better. I was not trying to achieve a remote desktop access solution. I was looking for a way to work on my Android projects without have to copy then on a USB or email them to myself.
I use a VPS to host my websites and I assumed I might be able to work on my Andoird projects via FTP from my server so regardless where I am, I have access to the same project - I don't know if you guys think that is possible ?!?
However, I will start to investigate SVN and Git.
Thanks again.
No problem, I'd say check with you VPS provider too, often times they have tutorials on how to set up SVN, or sometimes even automated one click installs.
There will be some learning curve with using SVN, but it will give you a lot of control over versioning your work. It's WELL worth the effort.
If you ever make a mistake you can easily roll back to an earlier version, or you can "branch" off from the main codebase to try out a beta feature and merge it back later with side by side views showing you where all the changes are.
Most every experienced developer uses some type of versioning control software (SVN, Git, Mecurial, CVS, or SourceSafe).
Git does many of the same things but is a bit more advanced and more designed around larger projects with teams of developers working remotely. (Git was developed by Linus Torvalds for Linux kernel teams to use). Mecurial I think costs $$ and is like git. CVS is a bit old, and SourceSafe is a Microsoft produc that I think also costs $$.
SVN is based on CVS and is intended to be the successor and more user friendly than CVS, but it's still takes some time to learn and some patience.
Many Android developers use Git though, so the choice is up to you, however I think SVN is a bit easier to learn.
FYI a SVN inside a dropbox works too.
Sent from my GT-I9000 using XDA App
Hi there, i'm new to developing Android Apps, so i have some questions.
1. I know that always have a chance of breaking security on computer world
2. Whats the most secure method to generate a UniqueID? because my app needs to work on china tablets, original tablets, cellphones, hacked phones, etc. I need this for verification of paid things (wait, xda will have a free version ;o)
3. There is any way to encript the program without affecting the performance too much? I'm new to java and comming from C++, so there is any compaction, encrypt, etc? Because if anybody knows the NEW IDA will come with android support.
4. There is any HTML parser on java? Because i need to fetch a html page with httpclient and after i need to parse it to get content... the contect is dynamic (html table with N rows), so i need a parser... or there is any other way?
5. I know how to make a tabed interface, but how is the best way to know the app state? Like it:
App Start -> User Already Logged (Save on SQLite?) ?
Yes = Display app interface and unlock config menu (here is the tabed interface)
No = Display login interface and lock config menu (here is just a relative layout with login bnts)
Thanks in advance.
1: Number one is not a question.
2: Do you mean most secure possible, or most secure practical? Those concerns should be addressed. Most secure would be to have a courier bring the user one-time-pads for every session, but that's not very practical. That said, what is the nature of your ID? Depending on what you are using it for, I would think a few randomly generated bits from some user entered entropy (like touchpad event timing) should suffice.
3: Again, what is the nature of your need for encryption? Do you want to keep it from being decompiled and analysed? If so, you're pretty much out of luck as there is always a way for a dedicated hacker to disassemble the code that does the decryption unless you use some sort of challenge-handshaking algorithm to load the keys at runtime for every session from some secure source but that requires connectivity and user interaction which necessarily complicates the process.
4: The XML parsers available as part of the Android SDK do a pretty good job of parsing HTML if it is clean compliant HTM> See, i.e. the Sax classes:
http://developer.android.com/reference/org/xml/sax/package-summary.html
5: You can use the API included preference classes to save state between sessions:
http://developer.android.com/reference/android/preference/package-summary.html
Note: for general application cryptography information, you still can't beat the venerated Applied Cryptography by Bruce Schneier.
Thanks for the answers.
I just wanna know how the most used programs like rom manager, power amp, titanium backup and whatsapp protect their paid versions, and how they validate it.
Another question that leaves on it is that some programs have a dedicated paid version, and some have just a key that you download and unlock the free version, how they did it? They just check if key is installed assuming that it was downloaded from market?
My uses is just for two reasons:
1.) protect my app as possible from newbie crackers
2.) transmit user information with a secure method to my server. Its important because my app will be used on open networks.
As for UniqueID generating, i just wanna a "unique world global super id" for each user of my app, and it will be installed on cellphones, tablets without phone, tv with android, and all of this.
Also, what to do if html is not well formated?
Hi guys, could you tell me how to open file for writing in the phone app LocalStorage for the non-unlocked handset (regular app for store)?
Code below doesn't work
Code:
FILE *tmp;
auto tmpPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path + "\\tmp.txt";
auto tmpErr = _wfopen_s(&tmp, tmpPath->Data(), L"w");
Any suggestions?
Try looking though msdn articles. I found it somewhere in there. But I have forgotten it now.
Sent from Board Express on my Nokia Lumia 1020. Best phone ever!!
Note to noobs: DON'T PM ME WITH QUESTIONS. POST IN THE FORUMS. THAT'S WHAT THEY ARE HERE FOR!
@wcomhelp, please keep your rtfm advices for yourself, OK? I'm not a noob and of course I've searched msdn, google, codeplex, github etc. and so on before posting here. If you don't know how, much better be silent (like others who read this post but have no idea what I'm talking about)
I've tried a few possible methods including ugly "MS-way" with task & lambda syntax (see below) but nothing worked as it should be (code below works if no file exist and fails if file already exist - CreationCollisionOption::ReplaceExisting options is not worked/not implemented/buggy/billgates_knows_only ).
Code:
auto folder = Windows::Storage::ApplicationData::Current->LocalFolder;
Concurrency::task<Windows::Storage::StorageFile^> createFileOp(
folder->CreateFileAsync(CONFIG_FILE_NAME, Windows::Storage::CreationCollisionOption::ReplaceExisting));
createFileOp.then([=](Windows::Storage::StorageFile^ file)
{
return file->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite);
})
.then([=](Windows::Storage::Streams::IRandomAccessStream^ stream)
{
auto outputStream = stream->GetOutputStreamAt(0);
auto dataWriter = ref new Windows::Storage::Streams::DataWriter(outputStream);
// data save code skipped
return dataWriter->StoreAsync();
})
.wait();
BTW, I've used workaround, to save ported C++ app data to the LocalSettings instead of text file (as it was in original code).
"Doesn't work" doesn't give us a lot to go on, troubleshooting-wise. Can you tell us what error you get?
Only thing I see in the code that looks a little weird is that the
Code:
"\\tmp.txt"
part isn't explicitly a wide-character string, but I'd expect string concatenation to take care of that.
Also, out of curiosity, why libc functions instead of Win32? Obviously, the code you're writing here isn't intended for much portability...
@GoodDayToDie, there is no error code at all - standard POSIX functions returns NULL FILE, the ::GetLastError() also return 0.
I'm porting old C-style app to WinRT platform and don't care about portability (but the first post code - just a simplified example, nothing more).
POSIX (libc) functions works pretty well for reading only but not for writing - that's the problem...
As I said before, I resolved my issue by workaround but still curious why the POSIX calls fails for file writing in the app storage.
buuuuuuuuuuuuuuuuh
No need for lambdas
https://paoloseverini.wordpress.com/2014/04/22/async-await-in-c/
You may also want to rethink your strategy
You can't create files at arbitrary locations, so your method is kinda redundant. All the locations you are allowed to create and read files to/from are available through KnowFolders and ApplicationData classes. These return StorageFolders which in turn can create files with CreateFileAsync (used for both creating and opening existing files) and get files with GetFilesAsync ( I recommend against this one though) and similar methods.
@mcosmin222, could you please re-read my posts one more time? I'm not trying to create files at "arbitrary locations"; I wanna create/write simple text file at the app's local storage (which one should be available for reading/writing). And the problem not in the lambdas or task usage (yes, it looks ugly but it works as it supposed to be).
Could you provide a working example instead of words? And I'll be glad to say you "thanks a lot"; can't say now...
sensboston said:
@mcosmin222, could you please re-read my posts one more time? I'm not trying to create files at "arbitrary locations"; I wanna create/write simple text file at the app's local storage (which one should be available for reading/writing). And the main problem not in the task (async execution).
Could you provide a working example instead of words? And I'll be glad to say you "thanks a lot"; can't say now...
Click to expand...
Click to collapse
Sure, just gimmie a few hours till I can get near a compiler that is capable of doing that
Of course, no rush at all, take your time. It's not a showstopper for me now (actually, my workaround with AppSettings is more preferable way - at least for universal app and roaming settings) but the issue still has an "academic interest" and maybe will be useful in the next projects for porting old C/C++ code to WinRT.
sensboston said:
Of course, no rush at all, take your time. It's not a showstopper for me now (actually, my workaround with AppSettings is more preferable way - at least for universal app and roaming settings) but the issue still has an "academic interest" and maybe will be useful in the next projects for porting old C/C++ code to WinRT.
Click to expand...
Click to collapse
hi
in vs 2015
#include <pplawait.h>
Something of the like should work
Code:
WriteSomeFile() __resumable
{
auto local = ApplicationData::Current->LocalFolder;
auto file = __await local->CreateFileAsync("some file", CreationCollisionOption::eek:penIfExists);
__await FileIO::WriteTextAsync(file, "this is some text");
}
However, as of right now, in VS 2015 RC, you have a host of limitations when dealing with this, but I do not believe this will be of any issue to you.
Code:
Cannot use Windows Runtime (WinRT) types in the signature of resumable function and resumable function cannot be a member function in a WinRT class. (This is fixed, but didn't make it in time for RC release)
We may give a wrong diagnostic if return statement appears in resumable function prior to seeing an await expression or yield statement. (Workaround: restructure your code so that the first return happens after yield or await)
Compiling code with resumable functions may result in compilation errors or bad codegen if compiled with /ZI flag (Edit and Continue debugging)
Parameters of a resumable function may not be visible while debugging
Please see this link for additional details
http://blogs.msdn.com/b/vcblog/archive/2015/04/29/more-about-resumable-functions-in-c.aspx
you should also note that this works with native, standard C++ types.
@mcosmin222, looks like unbuffered writing works (i.e. without streams) fine but it still not an answer for my initial question
I'm curious why the standard POSIX libc writing operations are not working on the app's local storage (but reading from files works fine). Actually, it's all about porting old C/C++ code for WinRT; of course for the new app it's not a problem but re-writing old code to FileIO should be a huge pain in the ass. What I did: I've "mechanically" changed all libc formatted outputs from file to string, and use LocalSettings class (actually it's XML file) to store that string (I'm planning also change LocalSettings to RoamingSettings, to provide settings consistency between WP & desktop app).
P.S. <pplawait.h> is not available in my VS 2015 (release pro version) so I've tested by using lambda pattern.
OK, first things first, LIBC != POSIX! The POSIX way to do this would be to call the open() function and get back an int as an "fd" (file descriptor), which is of course not implemented on Windows Phone because Windows Phone is not a POSIX platform (you might find the Windows compatibility functions _open() and _wopen(), but I doubt it). You are attempting to use the standard C library functions, which are portable but implement kind of a lowest common denominator of functionality and are generally slightly slower than native APIs because they go through a portability wrapper.
Second, sorry to be all RTFM on you but you should really Read The Manual (or manpage, or, since this is Windows, the MSDN page)! Libc APIs set errno (include errno.h) and use different error values than Windows system error codes (or HRESULT codes, or NTSTATUS codes, or...). Error reporting in C is a mess. If you were calling CreateFile(), you would check GetLastError(), but since you're calling _wfopen(), you check errno (not a function).
@GoodDayToDie, _wfopen_s returns 0 (i.e. "no error") but tmp pointer receives also 0 (NULL) Could you explain why libc file functions are working for reading (at the app installation & local data folders of course) but not for writing? Any logical ("msdn based") explanation? Or you just... don't know, heh?
sensboston said:
@GoodDayToDie, _wfopen_s returns 0 (i.e. "no error") but tmp pointer receives also 0 (NULL) Could you explain why libc file functions are working for reading (at the app installation & local data folders of course) but not for writing? Any logical ("msdn based") explanation? Or you just... don't know, heh?
Click to expand...
Click to collapse
LIBC functions will most likely work just in debug mode. The moment you try to publish the app it will fail. You can do lots of crazy stuff on your developer device with basic C functions, but if you try publishing, it won't pass the marketplace verification.
Most C APIs are simply not supported, since they do not comply with the sandbox environment of the Windows Runtime.
The code I gave you is tested with VS 2015 RC. You should be able to include <pplawait.h> just fine, if you are targeting toolchains newer than November 2013.
mcosmin222 said:
The moment you try to publish the app it will fail. You can do lots of crazy stuff on your developer device with basic C functions, but if you try publishing, it won't pass the marketplace verification.
Click to expand...
Click to collapse
Hmm... Are you sure or it's just your assumption? My app is still under development but (just for test!) I've made store app package for WP and it passed local store verification I also uploaded package to the store (via browser) and it also passed. I don't have time to create all tiles and fill all fields to complete beta-submission (actually, I don't know how to mark app as beta in the new dashboard) but for me it looks like app don't have any problem and will pass store certification easily. And you may be sure - it uses A LOT of libc calls 'cause originally it was written for Linux (or kind of UX system)
sensboston said:
Hmm... Are you sure or it's just your assumption? My app is still under development but (just for test!) I've made store app package for WP and it passed local store verification I also uploaded package to the store (via browser) and it also passed. I don't have time to create all tiles and fill all fields to complete beta-submission (actually, I don't know how to mark app as beta in the new dashboard) but for me it looks like app don't have any problem and will pass store certification easily. And you may be sure - it uses A LOT of libc calls 'cause originally it was written for Linux (or kind of UX system)
Click to expand...
Click to collapse
Once usage reports get up to microsoft, you will be given a notice to fix the offending API (happened to be once). You are much better off using the platform specific tools: not only they are much faster, they are also much safer and you won't have problems later on.
You might get away with reading stuff (since reading is not that harmful), but you should be using the winRT APIs each time they are available.
Simply uploading your app to the marketplace just reruns the local tests in their cloud servers: once you submit the actual app (not beta, not tests) for consumers, it will be much more aggressively checked. This is because the store allows specific scenarios for distributing apps in close circles that may break the usual validation rules.
@mcosmin222, one more time: is it your assumptions or personal experience? I don't know how many apps you have in store (I do have a lot) but I never heard that you said. I've used C++ libraries with WP hacks in some of published apps but never had any problem with "aggressive checks". What I know: if you are using some "prohibited" calls, your app will not pass uploading to the store (uploading, not a certification).
P.S. I'll send you personally a link when I publish release Hope, you'll like it
sensboston said:
@mcosmin222, one more time: is it your assumptions or personal experience? I don't know how many apps you have in store (I do have a lot) but I never heard that you said. I've used C++ libraries with WP hacks in some of published apps but never had any problem with "aggressive checks". What I know: if you are using some "prohibited" calls, your app will not pass uploading to the store (uploading, not a certification).
P.S. I'll send you personally a link when I publish release Hope, you'll like it
Click to expand...
Click to collapse
By "hacking" you mean recompiling the code to fit the windows phone toolchain? if so, then you shouldn't have to worry about too many things.
but even so, calling stuff like fopen in locations other than local storage will get your app banned. Even if it makes past the first publication, you can get noticed weeks later or even months (yes, it did happen to me personally).
In most cases, calling C APIs that can potentially break the sandbox (like opening a file in doc library with fopen) will always fail the marketplace verification, eventually. If it hasn't happened to you yet, then you may have not been using such APIs.
No, my C++ code is not accessing other than approved locations but the app has a lot of libс (and of course other C/C++ libs) calls; I'm 99.9% sure it's legitimate and will be not a source of any problem. Otherwise what is the advantages of having C++ compiler?!
As far as I know, just some of API's are prohibited but you will notice it right after local store compatibility test run...
As for "hacks" I mean usage of undocumented ShellChromeAPI calls (including loading hack).
P.S. I've found why <pplawait.h> header is missing. Initially I've created solution with the 12.0 toolset but now I can't (or don't know how to) change it to 14. However creating the new empty universal solution in VS 2015 also gives me toolset 12 by default. What is the toolset 14 for? Windows 10?
sensboston said:
No, my C++ code is not accessing other than approved locations but the app has a lot of libс (and of course other C/C++ libs) calls; I'm 99.9% sure it's legitimate and will be not a source of any problem. Otherwise what is the advantages of having C++ compiler?!
As far as I know, just some of API's are prohibited but you will notice it right after local store compatibility test run...
As for "hacks" I mean usage of undocumented ShellChromeAPI calls (including loading hack).
P.S. I've found why <pplawait.h> header is missing. Initially I've created solution with the 12.0 toolset but now I can't (or don't know how to) change it to 14. However creating the new empty universal solution in VS 2015 also gives me toolset 12 by default. What is the toolset 14 for? Windows 10?
Click to expand...
Click to collapse
The advantage of C++ is the obvious versatility: the standard C++ APIs will work fine for you as long as you stay inside the sandbox (this means you can't access files even in locations that are outside of sandbox but you have permission to them, such as music library). You can use most classic C/C++ libraries without issues as long as you do the interface with the runtime broker yourself. That means using windows runtime APIs instead of classic C APIs when dealing with stuff such as file access, for example. This is a pretty extensive topic and It is rather difficult to explain it all with 100% accuracy, especially when there is lots of docs running around.
You also get deterministic memory management, which is huge in specific scenarios.
Long story short
You will be fine with standard C/C++ when using
any in-memory functions supported by the compiler (you can manipulate data types, string, mutex, etc).
File IO in isolated storage only (applicationData folder)
Threads (although you are better off using threadpool or the like, it is much easier and cleaner). You can also use futures, and std::this_thread.
You will have to use winRT replacement
File system access in any other location than application data (you must use the windows::storage APIs)
sockets, internet access and the like.
any hardware related thing: music&video playerback must be interfaced through winRT (although the underlying decoders can be classic C/C++), messing around with the device sensors.
Retrieving system properties (internet connection state etc)
cross process communications
communicating with other apps
There are also win32 equivalents
mutex, threading, fileIO (isolated storage only)
Media playback with custom rendering pipeline.
Basically, winRT functions as an abstraction layer between the hardware and your code. You can use classic C++ up to the point where you need to interact with the system in any way. At that point, system interaction must be done with winRT. This way, microsoft ensures a higher degree of stability and security for devices.
check this link out for more information on the toolchains. You should be able to use this in VS 2013 as well with windows 8 (this is a compiler feature, has nothing to do with supported platform)
https://paoloseverini.wordpress.com/2014/04/22/async-await-in-c/