Mail Message Link Handling - macos

I have written an AppleScript which when supplied with a Windows network link, will convert it to the correct smb:// equivalent for the server in our office, mount the network drive, and open the requested folder in Finder.
I have this built in an application which just takes a pasted network path. Ideally I need this to trigger on clicking a link in a Mail.app email message so that it can check if the link is in the correct format, and if so run the script and attempt to mount the drive and load the folder in Finder.
How would I go about doing this?

In order to do this I think you'd need to create a Cocoa application that was registered with OS X Launch Services as the default role handler for smb:// links.
I've written some stuff about how to do this on another question: How do you set your Cocoa application as the default web browser?
If there's a pure AppleScript solution or a way of only handling links within Mail.app I'm not aware of it.

Related

How do I start a desktop application from the browser on a Mac?

I'm building a web application that when finished will need to trigger a desktop app to open and load a specific file (or connect to a URL I'm passing to the desktop app).
I'm having a hard time finding documentation about how to do that on a Mac, can you point me to the right place?
You want to define a custom URL protocol.
Here is an example;
http://weblogs.asp.net/morteza/How-to-run-a-desktop-application-from-a-web-page
Here are some notes about how to do it on a Mac;
https://superuser.com/questions/548119/how-do-i-configure-custom-url-handlers-on-os-x
https://onflapp.wordpress.com/lincastor/

Write folder in Mac OS X with sandbox active

I created a small application in Xcode with Cocoa Desktop and this application has to create a folder in the current user's desktop Mac OS X
When I run the application without using the app creates a sandbox folder properly on desktop
If I use the sandbox putting right files for read / write I can not create a folder on the desktop
Does anyone know how to solve this as to send the application to the AppStore is necessary to use sandbox?
You shouldn't just create a folder on the desktop, regardless of whether you are using the sandbox or not. Instead use NSOpenPanel configured to select folders and ask your user to provide you either a folder to use. That is compatible with both open and sandboxed apps.
In the sandbox world once you've asked the user for a folder you can create a security scoped bookmark and save it in your apps preferences; on subsequent runs you can use that bookmark to re-establish rights to access the folder without user intervention. E.g. a browser might ask once for access to a folder to store downloads and then save a security scoped bookmark to that folder.
HTH
For some applications it just better to use some directory as default directory (Eg. Mail and Firefox uses Downloads as default directory). I guess this is your case. But, for better user experience (and for higher chances of your App's acceptance in AppStore) follow best practices - like avoiding direct Desktop access. And, mostly you will find the answer yourself if you go through these guides:
App Sandbox Design Guide (https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AboutAppSandbox/AboutAppSandbox.html)
Entitlement Key Reference (https://developer.apple.com/library/ios/DOCUMENTATION/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html)

Sandbox mac osx application

I have developed a mac application without using sandbox.
now i want to send it to the mac appSore, i buy my certificate, all is good.
I read this: Apple doc and in xcode i set the user selected file,music folder... to read/write access.
My application let the user chose from a folder any type of file, do some treatment and let the user chose where to save the new file.
To chose files, user can open folder with NSOpenPanel or with the open with functionality or drag-and-drop files.
Also the application can delete files.
I dont know if there's other things to do to sandbox the application (or a tool to test if it is sandboxed)
I come from ios this is why i'm asking :)
You can look in the Console when the application is running to view if sandboxd or pboxd logs messages referring to your application.
The format is: sandboxd[53037] ([53035]): AppName(53035)
I don't know if there are other processes who may log sandbox violation, but you can see them, if they are referring to your application.

Can Mac app store apps access local file system?

I am wondering what limitations are imposed on the Mac app store. Can someone point me in the right direction? For instance, lets say I wanted to write an app that does incremental auto-backups of files on the Mac file system, is that possible with an app in the Mac app store, or would my only option be a standalone mac app?
On the iPhone, apps are self contained in their own "sandbox"? Does this same principal apply to mac app store apps?
Fellows, what the OP is really referring to is described here:
http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html
It is all about
Containers
Entitlements
PowerBox (daemon)
Once an application is "sandboxed" its view of the ~ "home" directory is that of a Container (which happens to be created upon first start in $HOME/Library/Containers/appBundleID/Data). Therein it finds its "private copy" of config, cache and data files. And off course it can't read anything else, unless...
... you give the application the appropriate Entitlements in the form of a codesign-ed property file (in fact, codesigning is integral part of the sandboxing concept).
One of these Entitlements is the "com.apple.security.files.user-selected.read-write" which allows the application to read and write exactly those files which the user has explicitly chosen via the standard save and open dialog respectively.
The PowerBox (pboxd) daemon then renders the appropriate file dialog in its own process space and adds the selected file paths to the list of allowed files. This is transparent to the application, that is no code changes are required - as long as the application uses the standard NSOpenPanel or NSSavePanel dialogs.
"To facilitate application sandboxing, Mac OS X v10.7 provides a trusted system daemon that is tasked with presenting open and save panels on behalf of applications running in an application sandbox. That daemon is called Powerbox (its process name is pboxd). These Powerbox-presented remote panels appear fully indistinguishable from in-process panels in terms of user experience.
Any time an application running inside a sandbox invokes an NSOpenPanel or NSSavePanel dialog, rather than showing the panels directly, AppKit automatically asks the Powerbox to present the dialog. From a developer perspective, there are no code changes required in terms of how these panels are used; this process is fully transparent." [end quote from Apple docs]
Given all that, what the OP would need (for a backup solution) are "unmediated read/writes":
"If an application chooses to derive the user's home directory in a way that bypasses Cocoa APIs (by directly invoking getpwent, for example), the application sandbox prohibits it from writing to the paths it receives (unless the application has the unmediated write entitlement, which is strongly discouraged for obvious security reasons." [end quote from Apple docs]
However the closest Entitlements which would give "free access to the file system" I could fine would be:
"
Absolute file read-only—The ability to read the files or directories at the specified absolute paths. (com.apple.security.temporary-exception.files.absolute-path.read-only)
Absolute file read/write—The ability to read or write the files or directories at the specified absolute paths. (com.apple.security.temporary-exception.files.absolute-path.read-write)
" [end quote from Apple docs]
And I am not sure whether an application could simply provide the root directory "/"
Anyway, carefully note that these entitlements are marked "temporary": Apple might remove/deprecate those entitlements at seen fit!
I believe that starting in November, Mac App Store submissions must adopt the App Sandbox. There are specific entitlements that you can request when your app is submitted to the app store, along with an explanation of why you need those entitlements. More information can be found in WWDC Session 204 video on the Developer site.
Technically, there is sandboxing on the OS X. However, applicants started manually by the user bypass those sandboxing restrictions (sometimes requiring escalation / admin verification screens).
Take a look at:
http://techjournal.318.com/security/a-brief-introduction-to-mac-os-x-sandbox-technology/
The are changing or have changed with the Lion release. Mac Store apps used to be able to do anything within the filesystem that the logged in user privs could allow but I think you are now required to use the entitlements system and hence sandbox your App.
Read this for more ideas
https://developer.apple.com/library/mac/#releasenotes/General/SubmittingToMacAppStore/_index.html#//apple_ref/doc/uid/TP40010572
This will help. Take a good look at it.
http://developer.apple.com/library/mac/#documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW16
You can currently find Hype or Pixelmator on the Mac App Store.
This proves evidently that you can save to disk and read from disk, which seems a basic feature of any serious application. Moreover, Apple is pushing developers to start using incremental auto-backups of files, it would therefore be very surprising if they forbade that in the App Store, wouldn't it?

Launching other applications in Windows phone 7 Programatically

I am downloading a file from Internet, and I am saving this in IsolatedStorage. and Now I want to Open that file, ie if it is excel we should open a file with excel if excel is installed, or otherwise prompt the user to choose the application to open that file as like in PC windows os, How can we do this.. give me some Idea..
As general rule, there is no way to do what you are describing. The exception to this is for media, for which you can integrate with the Music and Video hub. This would allow you to, for instance, download a movie and then play it in the same way as if it was part of the zune collection, even though it's in IsolatedStorage.
If you want to download office files from the internet you can simply link to them directly by opening them in a WebBrowserTask. The user would then be able to open the file in the relevant office program. So, if you did the follwoing, the file would be opened in Excel:
var wbt = new WebBrowserTask();
wbt.URL = "http://example.com/file.xlsx";
wbt.Show();
This would not allow you to store the file in IsolatedStorage and that may or may not be an issue for you.
Windows Phone applications run in isolation and with very few exceptions cannot interact with other programs. So there's not a way for you to present a program chooser to allow the user to choose another application to launch.
I am pretty sure there are system launchers for different applications. For example, the YouTube application can be launched programatically the way I showed here - basically it is similar to the way Matt showed. Ultimately, each app is launched via a UIX reference (catched here), but there is no public endpoint to open a res URL.

Resources