* Cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37094 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-06-11 07:29:16 +00:00
parent fc0d49483e
commit be816234e8
2 changed files with 53 additions and 47 deletions
+5 -14
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -87,8 +87,6 @@ const static settings_template kServicesTemplate[] = {
Settings::Settings() Settings::Settings()
:
fUpdated(false)
{ {
_Load(); _Load();
} }
@@ -96,15 +94,6 @@ Settings::Settings()
Settings::~Settings() Settings::~Settings()
{ {
// only save the settings if something has changed
if (!fUpdated)
return;
#if 0
BFile file;
if (_Open(&file, B_CREATE_FILE | B_WRITE_ONLY) != B_OK)
return;
#endif
} }
@@ -260,8 +249,10 @@ Settings::_ConvertFromDriverSettings(const char* name,
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
const driver_settings* settings = get_driver_settings(handle); const driver_settings* settings = get_driver_settings(handle);
if (settings != NULL) if (settings != NULL) {
status = _ConvertFromDriverSettings(*settings, settingsTemplate, message); status = _ConvertFromDriverSettings(*settings, settingsTemplate,
message);
}
unload_driver_settings(handle); unload_driver_settings(handle);
return status; return status;
+30 -15
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -23,8 +23,10 @@ class Settings {
Settings(); Settings();
~Settings(); ~Settings();
status_t GetNextInterface(uint32& cookie, BMessage& interface); status_t GetNextInterface(uint32& cookie,
status_t GetNextService(uint32& cookie, BMessage& service); BMessage& interface);
status_t GetNextService(uint32& cookie,
BMessage& service);
const BMessage& Services() const; const BMessage& Services() const;
status_t StartMonitoring(const BMessenger& target); status_t StartMonitoring(const BMessenger& target);
@@ -33,34 +35,47 @@ class Settings {
status_t Update(BMessage* message); status_t Update(BMessage* message);
private: private:
status_t _Load(const char* name = NULL, uint32* _type = NULL); status_t _Load(const char* name = NULL,
uint32* _type = NULL);
status_t _GetPath(const char* name, BPath& path); status_t _GetPath(const char* name, BPath& path);
status_t _StartWatching(const char* name, const BMessenger& target); status_t _StartWatching(const char* name,
const BMessenger& target);
const settings_template* _FindSettingsTemplate( const settings_template* _FindSettingsTemplate(
const settings_template* settingsTemplate, const char* name); const settings_template* settingsTemplate,
const char* name);
const settings_template* _FindParentValueTemplate( const settings_template* _FindParentValueTemplate(
const settings_template* settingsTemplate); const settings_template* settingsTemplate);
status_t _AddParameter(const driver_parameter& parameter, status_t _AddParameter(const driver_parameter& parameter,
const char* name, uint32 type, BMessage& message); const char* name, uint32 type,
BMessage& message);
status_t _ConvertFromDriverParameter(const driver_parameter& parameter, status_t _ConvertFromDriverParameter(
const settings_template* settingsTemplate, BMessage& message); const driver_parameter& parameter,
status_t _ConvertFromDriverSettings(const driver_settings& settings, const settings_template* settingsTemplate,
const settings_template* settingsTemplate, BMessage& message); BMessage& message);
status_t _ConvertFromDriverSettings(
const driver_settings& settings,
const settings_template* settingsTemplate,
BMessage& message);
status_t _ConvertFromDriverSettings(const char* path, status_t _ConvertFromDriverSettings(const char* path,
const settings_template* settingsTemplate, BMessage& message); const settings_template* settingsTemplate,
BMessage& message);
bool _IsWatching(const BMessenger& target) const { return fListener == target; } bool _IsWatching(const BMessenger& target) const
bool _IsWatching() const { return fListener.IsValid(); } { return fListener == target; }
bool _IsWatching() const
{ return fListener.IsValid(); }
private:
BMessenger fListener; BMessenger fListener;
BMessage fInterfaces; BMessage fInterfaces;
BMessage fServices; BMessage fServices;
bool fUpdated;
}; };
static const uint32 kMsgInterfaceSettingsUpdated = 'SUif'; static const uint32 kMsgInterfaceSettingsUpdated = 'SUif';
static const uint32 kMsgServiceSettingsUpdated = 'SUsv'; static const uint32 kMsgServiceSettingsUpdated = 'SUsv';
#endif // SETTINGS_H #endif // SETTINGS_H