On Mon, May 20, 2013 at 2:09 PM, Dave Hylands <dhyla...@mozilla.com> wrote:
> Hi Jonas,
>
> ----- Original Message -----
>> From: "Jonas Sicking" <jo...@sicking.cc>
>> To: "Dave Hylands" <dhyla...@mozilla.com>
>> Cc: "dev-b2g" <dev-b2g@lists.mozilla.org>
>> Sent: Monday, May 20, 2013 1:39:18 PM
>> Subject: Re: [b2g] Device Storage Changes
>>
>> On Mon, May 20, 2013 at 8:17 AM, Dave Hylands <dhyla...@mozilla.com>
>> wrote:
>> >> And I also think we should enable applications to let users choose
>> >> where a given picture should be shown, while by default selecting
>> >> the
>> >> one the user had picked through settings. I think the only thing
>> >> we
>> >> need to enable this is to have a boolean DeviceStorage.default
>> >> property.
>> >
>> > There is nothing to stop an app from prompting the user where to
>> > store a file. There are 3 ways that an app could choose to store a
>> > file:
>> >
>> > 1 - Using the composite storage area, you could do:
>> > storage.addNamed('/storageName/filename', blob);
>> > and blob will be storerd on the real storage area with the name
>> > give by storageName.
>> >
>> > 2 - Using the composite storage area, you could do:
>> > storage.addNamed('filename', blob);
>> > and blob will be stored on the real storage area indicated by the
>> > user (in the settings app) as the default place to store new
>> > files.
>> >
>> > 3 - Using a real storage area (obtainable via getDeviceStorages),
>> > you could do:
>> > storage.addNamed('filename', blob);
>> > and blob will be stored on that storage area.
>>
>> Yup. Understood.
>>
>> But what you can't do, as far as I can tell, is to create a UI which
>> lets the user choose which location to store a file. While also
>> selecting by default the storage area that the user has chosen as the
>> default.
>
> Why not? The default is stored in a setting. Can't the UI query the setting 
> just like the settings app does?

3rd party apps doesn't have access to settings. And we're not planning
on exposing it to them since, in addition to the security issues, it
would mean that we'd have to standardize what settings we have and
what they can contain as part of the web platform.

>> What you can do, is to list all available store areas, and then in
>> addition to that have an option which says "default" without showing
>> the user any indication of where the file will be stored if "default"
>> is chosen.
>>
>> I would think that in a good UI you'd want to just list the available
>> storage areas, without a separate "default" option. And by default
>> select the area which the user has previously indicated should be the
>> default. That way the user can see where the file will be stored if
>> no
>> action is taken, and he/she can take action to store the file
>> elsewhere if desired.
>>
>> I guess you could accomplish that with the current API by writing a
>> dummy-file to the composite storage and see where that file will get
>> saved. But that seems pretty hacky and could result in security
>> dialogs being displayed to the user.
>
> Just query the setting and have the same named storage are pre-selected.
>
>> I think a better solution would be to simply add a .default property
>> to DeviceStorage which is set to true for the default area, and false
>> for all other ones.
>
> I'm perfectly happy to add such an attribute and it would be quite simple to 
> do. We could even make it so that setting that attribute to true causes the 
> appropriate setting/preference to change as well. I went ahead and filed bug 
> 874213 to implement this.

I'd rather not allow 3rd party apps to be able to set this, at least
not unless we have very good use cases as well as the security
infrastructure (dialogs etc) to support it.

> The real issue I've been having is to get you, Doug Turner, and the UI folks 
> to all agree on what's wanted and put forward a consistent set of 
> requirements. That's all I've ever really wanted. I'm happy to implement 
> whatever, I just can't have it changing every 3 days.

Totally understandable. I'm ok with waiting on doing any more changes
here until we have a more comprehensive look at changes that we need
to do to DeviceStorage. The issues that I know about now are:

* How make the API support USB keys and sdcards on desktop platforms
where there's not an enumerable set of available slots.
* It's not good that every application has to scan all of device
storage on startup. It should be possible to only scan once.
* We should use a standardized filesystem API.

/ Jonas
_______________________________________________
dev-b2g mailing list
dev-b2g@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to