[haiku-bugs] [Haiku] #9443: API for unified preference storing

  • From: "mks" <trac@xxxxxxxxxxxx>
  • Date: Wed, 06 Feb 2013 22:07:59 -0000

#9443: API for unified preference storing
----------------------------------+---------------------
 Reporter:  mks                   |        Owner:  axeld
     Type:  enhancement           |       Status:  new
 Priority:  low                   |    Milestone:  R1
Component:  Kits/Application Kit  |      Version:
 Keywords:                        |   Blocked By:
 Blocking:                        |  Has a Patch:  0
 Platform:  All                   |
----------------------------------+---------------------
 Ticket for something I wrote in the forum before, as requested by mmadia,
 so I'm quoting myself …

 I think application development on Haiku would benefit from a unified and
 endorsed way for programmers to save application preferences. That's
 something almost every program needs and yet on many platforms there is no
 simple API for that. Mac OS X has NSUserDefaults [1] for it and Android
 uses SharedPreferences [2]. Systems like GSettings in the Gnome world and
 the Windows registry got the premises wrong and are thus not nearly as
 comfortable to use.

 However, Haiku is "almost there". BMessage can be flattened to and
 unflattened from files. The data you can store in a BMessage is sufficient
 for almost any kind of preferences and I think I read somewhere that some
 programs already use flattened BMessages for that purpose.

 What I'd like to see on top of that would be roughly something like a
 be_app->GetPreferences(), which would return a BMessage and
 be_app->StorePreferences(BMessage). Didn't put too much thought into the
 details, but that would be essentially what Android offers. This way the
 OS could decide *where* and *how* to store the actual physical data. Which
 would mean 2 things: a) application programmers don't need to think about
 tedious stuff like storing preferences and can concentrate on more
 important things and b) it allows for something like OS X's defaults
 system [3].

 The important thing here is, that the application does not decide the
 where and how, but the OS does, e. g. by using the app signature.

 Once applications would use such a system, moving the settings without
 breaking app compatibility would be an easy thing to do. If one would
 really want to do that. (That was just the point the forum thread was
 about)

 [1]
 
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
 [2]
 http://developer.android.com/reference/android/content/SharedPreferences.html
 [3]
 
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/defaults.1.html

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/9443>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: