Usually we set XULRunner app preferences:
var pref = Cc["#mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
pref.setBoolPref(name,value);
But these preferences are stored in the user profile. This means that the preference will be lost if you create a new XULRunner app profile.
Is there a way to set preferences globally or share preference between profiles?
XULRunner stores all data in profile - starting from scratch when a new profile is created is the whole point of it. You should really reconsider storing data outside the user profile, normally that's unexpected and simply a bad idea.
But if you really want to do it then you are on your own, you need to store a custom file somewhere outside the user profile. For example, you could store a file in user's home directory:
Components.utils.import("resource://gre/modules/FileUtils.jsm");
var file = FileUtils.getFile("Home", ["data.txt"]);
// Write to file here
That file would be shared for all profiles of this computer user. For more information see the documentation.
Note that even this approach won't give you a way to share preferences between different users on the same computer - normally there are no directories that all users are guaranteed to have write access to.
Related
I have 10 qlikview app in AccessPoint and for specific user i want to show only 7 app.
I don't wont to use Section Access.
I use NTFS authorization
And on folder Production (where save qvw app for browser) in Properties Security i remove specific user but he still see app...
How can I handle this?
By your description it sounds like you are using publisher.
If you want to display certain QVW's to certain users, then you need to setup the distribution to "Named Users", that way you can only add users to the relevant apps and the people that are not named will not see the QVW on the accesspoint.
Also make sure on the actual QVW (right click on it, properties, security) that only the relevant people have security rights on the file.
OK, so I know that under the new SandBox guidelines, opening a file must abide by certain rules (a.k.a. the opening action must be triggered by the user using an NSOpenPanel, given of course the necessary "open" permissions).
However, here's the catch :
In my application, I've got an NSOutlineView with a complete file manager in it (the full tree structure)
The user is supposed to be able to select a file from the outline view and then the app will open it.
How am I supposed to do that, given that the app should be 100% sandbox-compliant? Is there any known workaround? Is it even possible?
Any ideas?
Short answer: You can't do that. In order to show the contents of a folder within your app's UI, you'd first have to get the user to open it either using an open panel or dragging it in from the Finder.
You can do this, as #omz said, your application needs to request permission to access the folder containing all the files/folders that your application is showing. You don't need permission of individual files, but can get an entire directory structure as a single permission, and then store that as a security scoped bookmark so future executions of your application will already have that permission.
You could even at app launch ask the user for permission to access the entire hard drive, or their entire user directory.
You can use this class I wrote to wrap all that up into a single function call, which will then persist the permission so they are only asked on first run. https://github.com/leighmcculloch/AppSandboxFileAccess
Alternatively if you want to do it with NSOpenPanel manually, just take a look at the code in AppSandboxFileAccess as it uses it to get permissions and then persist those permissions.
I need a way to get & keep permission to write to a specific directory in OS X. How can that be done while abiding with the new Sandbox requirements?
The recipe:
Ask the user to select the directory - use a standard open dialog limited to directory selection. Apart from a few special directories (music, pictures etc.) there is no way to gain access apart from asking the user.
Create a security-scoped bookmark using the URL returned by the standard open dialog, just search the Apple docs for "security-scoped bookmark".
Persist that bookmark, either in user preferences or in the Application Support folder for your app.
On application launch, or before you need access, read in the saved bookmark and activate - you'll find out how to do this in the Apple docs as above.
I'd like to save the user selection of a Rally artifact so that when the page is reloaded details about that artifact are displayed. There may be several instances of the app on the smae dashboard; whats the best way to uniquely identify a specific instance. I plan to use the preferences api to save the state.
If we're talking about SDK 2.0p3: Each copy of the app has a unique ID that you can use "getAppID()" to find. However, if you use the updateSettingsValues, it will save it uniquely by AppID automatically. Sadly, the updateSettingsValues is app specific only, not user or project specific.
I'm new in Cocoa. My app is getting information from server, and displaying UNC paths of shared folders. I want to be able to store information of my Absoulte paths for each folder, so later I can display them in my APP. With more details
UNC Path - //CompName/sharedFolder
Absoulte Path -/Users/user/desktop/SharedFolder
So I need to store somewhere all that ABsolute paths locally on computer, after I can browse UNC paths from server, and display their Absoule paths.
What is the best way to store information? I know it is possible to use Core DAta. But I haven't designed for that my App. Can I store infromation in hiden file, and read it from there? How can I do it?
Thanks a lot.
It looks like you are looking for the NSUserDefaults class. From the documentation:
The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an application to customize its behavior to match a user’s preferences. For example, you can allow users to determine what units of measurement your application displays or how often documents are automatically saved. Applications record such preferences by assigning values to a set of parameters in a user’s defaults database. The parameters are referred to as defaults since they’re commonly used to determine an application’s default state at startup or the way it acts by default.
You just tell it what data you want to store.