[haiku-commits] r33827 - haiku/trunk/src/servers/registrar

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 29 Oct 2009 14:55:48 +0100 (CET)

Author: axeld
Date: 2009-10-29 14:55:47 +0100 (Thu, 29 Oct 2009)
New Revision: 33827
Changeset: http://dev.haiku-os.org/changeset/33827/haiku

Modified:
   haiku/trunk/src/servers/registrar/TRoster.cpp
Log:
* TRoster now actually stores its settings, ie. the recent file list now
  survives a reboot.
* The target directory is now created if needed.
* Relocated/renamed the settings file to
  ~/config/settings/system/registrar/RosterSettings.


Modified: haiku/trunk/src/servers/registrar/TRoster.cpp
===================================================================
--- haiku/trunk/src/servers/registrar/TRoster.cpp       2009-10-29 12:31:02 UTC 
(rev 33826)
+++ haiku/trunk/src/servers/registrar/TRoster.cpp       2009-10-29 13:55:47 UTC 
(rev 33827)
@@ -3,10 +3,12 @@
  * Distributed under the terms of the MIT License.
  */
 
+
 /*!    TRoster is the incarnation of The Roster. It manages the running
        applications.
 */
 
+
 #include "TRoster.h"
 
 #include <new>
@@ -16,14 +18,16 @@
 #include <string.h>
 
 #include <Application.h>
-#include <AppMisc.h>
 #include <AutoDeleter.h>
 #include <Autolock.h>
+#include <Directory.h>
 #include <File.h>
 #include <FindDirectory.h>
+#include <Path.h>
+
+#include <AppMisc.h>
 #include <MessagePrivate.h>
 #include <MessengerPrivate.h>
-#include <Path.h>
 #include <ServerProtocol.h>
 #include <storage_support.h>
 
@@ -76,22 +80,24 @@
 
 
 /*!    \brief Returns the path to the default roster settings.
+
        \param path BPath to be set to the roster settings path.
+       \param createDirectory makes sure the target directory exists if \c 
true.
+
        \return the settings path as C string (\code path.Path() \endcode).
 */
 static const char*
-get_default_roster_settings_file(BPath& path)
+get_default_roster_settings_path(BPath& path, bool createDirectory)
 {
        // get the path of the settings dir and append the subpath of our file
        status_t error = find_directory(B_USER_SETTINGS_DIRECTORY, &path);
        if (error == B_OK)
-               error = path.Append("Roster/HaikuRosterSettings");
+               error = path.Append("system/registrar");
+       if (error == B_OK && createDirectory)
+               error = create_directory(path.Path(), 0777);
+       if (error == B_OK)
+               error = path.Append("RosterSettings");
 
-       // If some error occurred, set the standard path (can only fail, if 
there's
-       // insufficient memory, which can't be helped anyway).
-       if (error != B_OK)
-               
path.SetTo("/boot/home/config/settings/Roster/HaikuRosterSettings");
-
        return path.Path();
 }
 
@@ -1343,6 +1349,9 @@
        BAutolock _(fLock);
 
        fShuttingDown = shuttingDown;
+
+       if (shuttingDown)
+               _SaveRosterSettings();
 }
 
 
@@ -1816,7 +1825,7 @@
 {
        BPath _path;
        const char* settingsPath
-               = path ? path : get_default_roster_settings_file(_path);
+               = path ? path : get_default_roster_settings_path(_path, false);
 
        RosterSettingsCharStream stream;
        status_t error;
@@ -1984,7 +1993,7 @@
 {
        BPath _path;
        const char* settingsPath
-               = path != NULL ? path : get_default_roster_settings_file(_path);
+               = path != NULL ? path : get_default_roster_settings_path(_path, 
true);
 
        status_t error;
        FILE* file;


Other related posts:

  • » [haiku-commits] r33827 - haiku/trunk/src/servers/registrar - axeld