[IDEA] And what about file association ? - Windows Phone 7 Q&A, Help & Troubleshooting

When I search in the wp7 forum I see few thread about file association in wp7 but I just remark that it's not so difficult to do using the excellent wp7 root tools SDK:
Code:
string Me = "1ff297cf-853f-4c7c-b9ca-1d255cb4c387".ToUpper(); //our Application's AppId
string Format = ".xml";
//set the defaut file association for .xml to FileAssoc instead of xmlfile
Registry.SetValue(RegistryHyve.ClassesRoot, Format, "Default", "FileAssoc");
//create the corresponding registry key
try { Registry.DeleteKey(RegistryHyve.ClassesRoot, "FileAssoc"); }
catch { }
Registry.CreateKey(RegistryHyve.ClassesRoot, "FileAssoc");
//create the key BrowseInPlace (I don't know why, I just do it, it takes one line)
Registry.SetValue(RegistryHyve.ClassesRoot, "FileAssoc", "BrowseInPlace", 0x0);
//and the app that must open .xml file (our app)
Registry.CreateKey(RegistryHyve.ClassesRoot, "FileAssoc\\shell\\open\\command");
Registry.SetValue(RegistryHyve.ClassesRoot, "FileAssoc\\shell\\open\\command", "Default", "app://" + Me + "/_default?type=FileAssoc&file=%s");
But if each application try to play with those settings it wil be the mess in the phone that's why I suggest that someone create an app that manage file associations for the user to choose what application he want use for a given file type and to support more file type (like .epub or .rar).
moreover the application that create File association must use native code but it's not necessarily the case for the application that read the file it would allow developers to publish this app on the marketplace (by adding an other source like skydrive or url) and the application that create File association would just be a big plus for Interop-unlocked phones.
Here is an app that display xml file in a textbox it's just an exemple of how it works:
fbe.am/8ld ==> xap
fbe.am/8le ==> source
What do you think ?

I actually knocked up an app very similar to this a little while ago, I didn't get around to finishing it but it was fully capable of searching the registry and compiling a list of known file extensions. As well as searching the installation directories of app's for certain .xml which contained the file extension that the app wanted to be associated with.
It was all written as a managed app, and I don't know if someone would want to look at it, but if there is some interest I can put it up.

Related

Hyperlink code to force ftp download

What is the proper format for html hyperlink code that will cause a file to download to the phone and not have the browser try to open it? I have files that are text, they are GPS files, but they don't have a TXT extension and IE keeps opening the files as text.
If it matters (but I don't think so) I'm running a reasonably stock HTC WM 6.0 ROM on a Hermes.
Regards,
GPSGary
You want to do this server-side? Or client-side?
FTP download code
I'm trying to write html code that will cause a file on my web site to download directly to the phone file directory without the browser trying to open it. It would be extra useful if I could make it download to a specific existing directory.
Regards,
GPSGary
Well, I hate to say this but you can't. That's the simple answer.
The complicated answer is that you need to set up some sort of server-side script to place the headers manually, or you need to modify some of the settings for your server's remote access handler. On Apache servers, this can be done via a file called .htaccess.
If you have a .htaccess file that you can modify, just enter this at the top of it:
Code:
RewriteEngine on
RewriteCond %{REQUEST_URI} \.(gps|cab)$
RewriteRule .* - [T=application/octet-stream,L]
Note that I didn't know the extension you're talking about so I put "gps" up there. I also added "cab" because many servers have a tendency to not send the proper headers for cab files. Feel free to add other extensions using this same method.
Again, this is assuming you have an Apache server, and you have the privileges to modify a .htaccess file.
Forcing ftp type download
No Apache server so isn't there some other way?
Anyone got a good Java script?
Regards,
GPSGary
Hi there,
as far as I know, you don't need java:
ftp-links are always proposed to "Save File", so your link should be ftp://www.domain.com/folder/filename.txt
This will cause any browser to download the file instead of opening it.
In that case, you definitely need an real ftp access to your file ... (ftp = FIleTransferProtocol).
Best regards,
I've encountered this before and resorted to zipping the file. You can also spoof the system by renaming the file to *.AAA The user, of course, will have to rename the file on their end. I have better luck with .zip unless it's for my own use. Any file which is recognized natively by the browser will open within the browser. This includes .txt, .htm, .html, and any other file associations you've successfully loaded.
gepp said:
No Apache server so isn't there some other way?
Anyone got a good Java script?
Regards,
GPSGary
Click to expand...
Click to collapse
That's what I'm tellin' ya. It's IMPOSSIBLE to do this with client-side scripting, i.e., Javascript.
I'd like to help you get this resolved. Can you clarify some things for me?
Are you using Geocities, Fortunecity, Google Pages, or one of the other free site services out there?
Do you understand the distinction I'm making between client-side and server-side scripting?
What server software are you using, if not Apache?
Are you able to utilize a PHP or Perl engine? (I can tell you how to send the file headers manually through either of those.)
I promise I'm not trying to be rude or anything. I just want to make sure we're both on the same page here. I can tell you the best way of getting this resolved, but I need to know where you stand, and I need to know the extent of your web development knowledge.
PHP or Perl will work
I'm on a Yahoo small business server. I've used PHP so that will work on my site and I know enough to fiddle with it if need be. Less proficient with Perl but have some exposure.
Regards,
GPSGary
Awesome. That works. Here is what you will basically be doing with PHP then.
PHP:
ob_start()
$GPSFile = '/path/to/file.gps'; //This is where the file is located on your Yahoo Business server
$DownloadName = "File.gps"; //This is the name that pops up when you're prompted to download the file (it can be different than the name above).
$TypeOfFile = 'text/plain'; //If you still have issues, change this to 'application/octet-stream'
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $TypeOfFile);
header("Content-Length: " .(string)(filesize($GPSFile)) );
header('Content-Disposition: attachment; filename=' . $DownloadName);
header("Content-Transfer-Encoding: binary\n");
od_end_clean();
readfile($GPSFile);

[Q] project resource

There are many json files containing the information {"color": "red"}. I want to create a listBox of colors of these files,data must be read. The most simple (which I wrote):
Code:
int i = 1;
while (i < 300)
{
var file = Application.GetResourceStream(new Uri("files/color"+i+".json", UriKind.Relative));
i++;
if (file == null)
{
Debug.WriteLine("file not found");
break;
}
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Color));
Color example = (Color)ser.ReadObject(file.Stream);
}
I have not found how to work with directories of the project so just go over everything.
I read about IsolatedStorageFile, this store is used as a sandbox for the application. How to install the application can put files there?
This is a simple example I used just to find out, in fact, much more data.
P.S. Sorry for my bad english
Quick tip: you should be using the "using" keyword, or manually cleaning up your stream.
That said, there's no official way to write to the isolated storage on program installation. Unofficially, you can use the XAP deployer hack (read about it on the dev&hacking sub-forum) if you really want to do this, although it almost certainly won't survive market ingestion (if you want to publish it).
The best official way is to check, when the program starts up, whether it has populated its isostore. If not, it uses the GetResourceStream to read from its install folder and write to the isostore.
If that's not enough info or doesn't answer your question, please try to be more precise.
evgen_wp said:
There are many json files containing the information {"color": "red"}. I want to create a listBox of colors of these files,data must be read. The most simple (which I wrote):
Code:
int i = 1;
while (i < 300)
{
var file = Application.GetResourceStream(new Uri("files/color"+i+".json", UriKind.Relative));
i++;
if (file == null)
{
Debug.WriteLine("file not found");
break;
}
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Color));
Color example = (Color)ser.ReadObject(file.Stream);
}
I have not found how to work with directories of the project so just go over everything.
I read about IsolatedStorageFile, this store is used as a sandbox for the application. How to install the application can put files there?
This is a simple example I used just to find out, in fact, much more data.
P.S. Sorry for my bad english
Click to expand...
Click to collapse
Indeed, clearly, is better.
thank you
Every time you hit the page will load data from files. It's slow. Probably better to use the database. What do you suggest?
an additional question: how to view the contents of the folder in the install folder
Loading the app's IsolatedStorageSettings.ApplicationSettings data (which is a simple text file in the data folder) is quite fast; I really doubt you'll notice it. Just save their once the fact that you imported the files from the install folder to the isostore. I just about guarantee that any kind of database access will take much longer, at least for the initial hit. Reading a short plain-text file and parsing it should take maybe a few miliseconds, at worst.
As for viewing folder contents, technically this can be done using native code, but it can't be done with the official API (I get the feeling you want to publish this app, so that matters). However, that shouldn't matter, really - you know what files are in the install folder and its subfolders, because you put them there. If you want to know how to use GetResourceStream on sub-folders of the install folder, that's easy; your code as listed above should work. Note that the files must be build action "content" and not "resource". You can still access "resource" files but the URI is different.

[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...

Export Notes?

Many many notes using the Notes app on the Mate 7. Is there any way to export these notes so I can transfer them to PC/ another phone?
You can press "Share" for each note and share it via E-mail, or alternatively you can share it to "Google Keep" which is also an app for taking notes made by google. With google keep you can sync your note across all your devices.
Another way is to backup your notes with the "Backup" app which came with the phone's software, or the "HiSuit" program which is the official application from Huawei to backup files on your PC.
Feel free to ask any question if anything wasn't very clear.
Thanks for your response-
Too many notes to share individually and I think I would need to share individually to migrate to Google Keep...?
I believe the Backup and Hisuit program store in a format that is only useful for restoring to the phone or another Huawei phone; I need to transfer notes to pc/another non-Huawei phone.
Please clarify if I've missed something here. Hope someone has a solution...
Thanks-
Sam
SAbboushi said:
Too many notes to share individually and I think I would need to share individually to migrate to Google Keep...?
Click to expand...
Click to collapse
Unfortunately, yes you need to transfer each one individually.
SAbboushi said:
I believe the Backup and Hisuit program store in a format that is only useful for restoring to the phone or another Huawei phone; I need to transfer notes to pc/another non-Huawei phone.
Click to expand...
Click to collapse
Yea that's true, it only works with Huawei phones.
Huawei's notes app doesn't have many features to try, it only allows to "share" each note individually, Yes that will take time but once you switch into Google keep, Evernote, OneNote ..etc you can sync your notes across all your devices.
hi there,
I lost all my notes from my huawei p9 lite after i format my phone.
My questio is where can I find my old saved notes? I backed upmy phone before reseting it, and i copied all my files in my PC.
Thanks for your help.
If anyone else struggles with transfering notes from their phone to a different device, you could use the cloud option, back up the notes in phone settings (Cloud section), and then login to : cloud.huawei.com where you will be able to copy-paste all the notes to your computer. I assume this is easier for most people than copy-pasting on phone.
Hi,
I had similar situation - a stock Huawei phone with stock notes app and a user trying to migrate to Xiaomi... So it happened as follows:
Export Huawei notes from cloud, using browser access
Create "Standard Notes" account
Convert Huawei exported notes into "Standard Notes" backup format
Import "Standard Notes" backup
Here are details of operation:
Login into your Huawei cloud on some browser (preferably on computer)
Choose to download your data, click on notes
It will generate ZIP with JSONs of every note (use 7z to extract, as unzip on Linux fails with error 99)
Create a "Standard Notes" account at https://app.standardnotes.org (basic account is free, FOSS app is available on F-droid, nice interface, e2e encrypted)
Add one "My test note WOO-HOO!" to your new account
Export "Standard Notes" backup (using computer)
It will also make you download ZIP file, with a structure inside, however you only need top level "Standard Notes Backup and Import File.txt" file, which is, in fact, a JSON
You can make your own solution or just use my Ruby code (attached) to convert into a Standard Notes backup format, please adjust path at line #11 to match your needs.
Run ruby (it converted 2000+ notes in a few seconds for me), redirect output into a file, remove array markers in the very beginning and very end (first and last "[ ]" symbols)
Carefully edit "Standard Notes Backup and Import File.txt" file, insert the JSON block generated by Ruby code. In my case, my test note started at line 102 and finished at line 119, so I inserted my JSON starting with line 120 (do not forget add one comma in the end of line 119)
Run resulting TXT file through jq or any other JSON validation tool to make sure everything is fine.
Import into your Standard Notes
Sorry to leave some manual work to do, however this is just one time operation.
Cheers!
chockophone said:
Hi,
I had similar situation - a stock Huawei phone with stock notes app and a user trying to migrate to Xiaomi... So it happened as follows:
Export Huawei notes from cloud, using browser access
Create "Standard Notes" account
Convert Huawei exported notes into "Standard Notes" backup format
Import "Standard Notes" backup
Here are details of operation:
Login into your Huawei cloud on some browser (preferably on computer)
Choose to download your data, click on notes
It will generate ZIP with JSONs of every note (use 7z to extract, as unzip on Linux fails with error 99)
Create a "Standard Notes" account at https://app.standardnotes.org (basic account is free, FOSS app is available on F-droid, nice interface, e2e encrypted)
Add one "My test note WOO-HOO!" to your new account
Export "Standard Notes" backup (using computer)
It will also make you download ZIP file, with a structure inside, however you only need top level "Standard Notes Backup and Import File.txt" file, which is, in fact, a JSON
You can make your own solution or just use my Ruby code (attached) to convert into a Standard Notes backup format, please adjust path at line #11 to match your needs.
Run ruby (it converted 2000+ notes in a few seconds for me), redirect output into a file, remove array markers in the very beginning and very end (first and last "[ ]" symbols)
Carefully edit "Standard Notes Backup and Import File.txt" file, insert the JSON block generated by Ruby code. In my case, my test note started at line 102 and finished at line 119, so I inserted my JSON starting with line 120 (do not forget add one comma in the end of line 119)
Run resulting TXT file through jq or any other JSON validation tool to make sure everything is fine.
Import into your Standard Notes
Sorry to leave some manual work to do, however this is just one time operation.
Cheers!
Click to expand...
Click to collapse
hello i can't find the ruby code...
mcnick50 said:
hello i can't find the ruby code...
Click to expand...
Click to collapse
Sorry mate, looks like I can't attach it successfully. Let me try to paste into the body... Hopefully it won't get transformed into a emoticons
#!/usr/bin/ruby
#
require "pp"
require "json"
require "securerandom"
#json_in = File.read("../Notes-2021050323205147761/Notes/20210401133344621/json.js");
s_notes = []
Dir.glob('../Notes-2021050323205147761/Notes/*/json.js').each do |j|
json_in = File.read(j)
json_hash = JSON.parse(json_in[11..-1]);
uuid = SecureRandom.uuid
text = json_hash["content"]["title"].to_s
created_u = json_hash["content"]["created"].to_s[0..9].to_i
modified_u = json_hash["content"]["modified"].to_s[0..9].to_i
created = Time.at(created_u).strftime('%Y-%m-%dT%H:%M:%S.%LZ')
modified = Time.at(modified_u).strftime('%Y-%m-%dT%H:%M:%S.%LZ')
title_length = json_hash["content"]["title"].to_s.index("\n")
title = ""
if title_length > 30
title = json_hash["content"]["title"].to_s[0..30]
else
title = json_hash["content"]["title"].to_s[0..title_length-1]
end
s_note = {
:uuid => uuid,
:content_type => "Note",
:content => {
:text => text,
:title => title,
:references => [],
:appData => {
"org.standardnotes.sn" => {
:client_updated_at => modified
}
},
: preview_plain => "" # DELETE SPACE BETWEEN : and the "p"...
},
:created_at => created,
:updated_at => modified
}
s_notes.push s_note
end
puts s_notes.to_json
chockophone said:
Sorry mate, looks like I can't attach it successfully. Let me try to paste into the body... Hopefully it won't get transformed into a emoticons
#!/usr/bin/ruby
#
require "pp"
require "json"
require "securerandom"
#json_in = File.read("../Notes-2021050323205147761/Notes/20210401133344621/json.js");
s_notes = []
Dir.glob('../Notes-2021050323205147761/Notes/*/json.js').each do |j|
json_in = File.read(j)
json_hash = JSON.parse(json_in[11..-1]);
uuid = SecureRandom.uuid
text = json_hash["content"]["title"].to_s
created_u = json_hash["content"]["created"].to_s[0..9].to_i
modified_u = json_hash["content"]["modified"].to_s[0..9].to_i
created = Time.at(created_u).strftime('%Y-%m-%dT%H:%M:%S.%LZ')
modified = Time.at(modified_u).strftime('%Y-%m-%dT%H:%M:%S.%LZ')
title_length = json_hash["content"]["title"].to_s.index("\n")
title = ""
if title_length > 30
title = json_hash["content"]["title"].to_s[0..30]
else
title = json_hash["content"]["title"].to_s[0..title_length-1]
end
s_note = {
:uuid => uuid,
:content_type => "Note",
:content => {
:text => text,
:title => title,
:references => [],
:appData => {
"org.standardnotes.sn" => {
:client_updated_at => modified
}
},
: preview_plain => "" # DELETE SPACE BETWEEN : and the "p"... otherwise it becomes
},
:created_at => created,
:updated_at => modified
}
s_notes.push s_note
end
puts s_notes.to_json
Click to expand...
Click to collapse
Could you describe to me exactly how this ruby works, what it takes. i have 2000 notes and i can't convert as described you can't.
glehel said:
Could you describe to me exactly how this ruby works, what it takes. i have 2000 notes and i can't convert as described you can't.
Click to expand...
Click to collapse
You will need little experience with running things on command line (preferably Linux or Mac, but can also work on Windows). Basically, I already escribed all steps in the post above: export Huawei notes, export empty Standard Notes. Use ruby to transform Huawei notes into Standard Notes fragment, which you will have then manually copy-paste into empty SN backup form above.
chockophone said:
You will need little experience with running things on command line (preferably Linux or Mac, but can also work on Windows). Basically, I already escribed all steps in the post above: export Huawei notes, export empty Standard Notes. Use ruby to transform Huawei notes into Standard Notes fragment, which you will have then manually copy-paste into empty SN backup form above.
Click to expand...
Click to collapse
I tried running your code but I'm getting the following error
Traceback (most recent call last): 2: from Notes.rb:11:in <main>' 1: from Notes.rb:11:in each' Notes.rb:27:in block in <main>': undefined method >' for nil:NilClass (NoMethodError)
RajtheKing said:
I tried running your code but I'm getting the following error
Traceback (most recent call last): 2: from Notes.rb:11:in <main>' 1: from Notes.rb:11:in each' Notes.rb:27:in block in <main>': undefined method >' for nil:NilClass (NoMethodError)
Click to expand...
Click to collapse
I guess that in your case problem actually is on line 11. Please make sure you put correct file pattern there. Or maybe they changed format since then and there is no more title field present. In any case, if you run into issues, do not hesitate to PM me.

How to hard code a url and port number into existing android application APKTOOL

I am attempting to learn more about SMALI and reverse engineering android apks. I am using apktool to decompile the application. I am working with an app that allows you to enter the url and port thru an input box, but my question is, How do I hard code the server URL in so I dont need to type it in the input box? Can I create a string name called "host" in strings.xml and somehow point to that string in another file? Also if that does work, or not, is it possible to remove the actual input box from the application thru smali?? If I can add "host" to strings.xml, what other files needs to point to that string xml? I am n00b, but curious about modifying smali, but I cant find much info related to smali in a way I can understand. Also, i read about creating an android sql database file and entering in the url and port there and adding it into assets, but how would I point to the database so the app uses my server url and port I put in the database file and skip the input box where user types in url and port???

Categories

Resources