From 48f570b5c78b1d6ac999923434e08edf2fe7cb18 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 18 Jan 2005 01:19:23 +0000 Subject: [PATCH] * The settings file is now called "HaikuRosterSettings" instead of "OpenBeOS...". * Obtain the path of the settings dir via find_directory(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10817 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/registrar/TRoster.cpp | 36 +++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/servers/registrar/TRoster.cpp b/src/servers/registrar/TRoster.cpp index 6805b63c33..00d5042f2e 100644 --- a/src/servers/registrar/TRoster.cpp +++ b/src/servers/registrar/TRoster.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -42,6 +44,8 @@ #include "TRoster.h" #include "EventMaskWatcher.h" +using namespace BPrivate; + //------------------------------------------------------------------------------ // Private local function declarations //------------------------------------------------------------------------------ @@ -82,8 +86,28 @@ static bool larger_index(const recent_entry *entry1, const recent_entry *entry2) //! The maximal period of time an app may be early pre-registered (60 s). const bigtime_t kMaximalEarlyPreRegistrationPeriod = 60000000LL; -const char *TRoster::kDefaultRosterSettingsFile = - "/boot/home/config/settings/Roster/OpenBeOSRosterSettings"; + +// get_default_roster_settings_file +/*! \brief Returns the path to the default roster settings. + \param path BPath to be set to the roster settings path. + \return the settings path as C string (\code path.Path() \endcode). +*/ +static +const char * +get_default_roster_settings_file(BPath &path) +{ + // 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"); + + // 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(); +} // constructor /*! \brief Creates a new roster. @@ -1396,7 +1420,9 @@ TRoster::_HandleGetRecentEntries(BMessage *request) status_t TRoster::_LoadRosterSettings(const char *path) { - const char *settingsPath = path ? path : kDefaultRosterSettingsFile; + BPath _path; + const char *settingsPath + = path ? path : get_default_roster_settings_file(_path); RosterSettingsCharStream stream; status_t error; @@ -1554,7 +1580,9 @@ TRoster::_LoadRosterSettings(const char *path) status_t TRoster::_SaveRosterSettings(const char *path) { - const char *settingsPath = path ? path : kDefaultRosterSettingsFile; + BPath _path; + const char *settingsPath + = path ? path : get_default_roster_settings_file(_path); status_t error; FILE* file;