* Cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37094 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -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:
|
||||||
@@ -42,7 +42,7 @@ const static settings_template kInterfaceAddressTemplate[] = {
|
|||||||
|
|
||||||
const static settings_template kInterfaceTemplate[] = {
|
const static settings_template kInterfaceTemplate[] = {
|
||||||
{B_STRING_TYPE, "device", NULL, true},
|
{B_STRING_TYPE, "device", NULL, true},
|
||||||
{B_BOOL_TYPE, "disabled", NULL},
|
{B_BOOL_TYPE, "disabled", NULL},
|
||||||
{B_MESSAGE_TYPE, "address", kInterfaceAddressTemplate},
|
{B_MESSAGE_TYPE, "address", kInterfaceAddressTemplate},
|
||||||
{B_INT32_TYPE, "flags", NULL},
|
{B_INT32_TYPE, "flags", NULL},
|
||||||
{B_INT32_TYPE, "metric", NULL},
|
{B_INT32_TYPE, "metric", NULL},
|
||||||
@@ -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;
|
||||||
|
|||||||
+47
-32
@@ -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:
|
||||||
@@ -19,48 +19,63 @@ struct settings_template;
|
|||||||
|
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
public:
|
public:
|
||||||
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);
|
||||||
const BMessage& Services() const;
|
status_t GetNextService(uint32& cookie,
|
||||||
|
BMessage& service);
|
||||||
|
const BMessage& Services() const;
|
||||||
|
|
||||||
status_t StartMonitoring(const BMessenger& target);
|
status_t StartMonitoring(const BMessenger& target);
|
||||||
status_t StopMonitoring(const BMessenger& target);
|
status_t StopMonitoring(const BMessenger& target);
|
||||||
|
|
||||||
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,
|
||||||
status_t _GetPath(const char* name, BPath& path);
|
uint32* _type = NULL);
|
||||||
|
status_t _GetPath(const char* name, BPath& path);
|
||||||
|
|
||||||
status_t _StartWatching(const char* name, const BMessenger& target);
|
status_t _StartWatching(const char* name,
|
||||||
const settings_template* _FindSettingsTemplate(
|
const BMessenger& target);
|
||||||
const settings_template* settingsTemplate, const char* name);
|
const settings_template* _FindSettingsTemplate(
|
||||||
const settings_template* _FindParentValueTemplate(
|
const settings_template* settingsTemplate,
|
||||||
const settings_template* settingsTemplate);
|
const char* name);
|
||||||
status_t _AddParameter(const driver_parameter& parameter,
|
const settings_template* _FindParentValueTemplate(
|
||||||
const char* name, uint32 type, BMessage& message);
|
const settings_template* settingsTemplate);
|
||||||
|
status_t _AddParameter(const driver_parameter& parameter,
|
||||||
|
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 char* path,
|
status_t _ConvertFromDriverSettings(
|
||||||
const settings_template* settingsTemplate, BMessage& message);
|
const driver_settings& settings,
|
||||||
|
const settings_template* settingsTemplate,
|
||||||
|
BMessage& message);
|
||||||
|
status_t _ConvertFromDriverSettings(const char* path,
|
||||||
|
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(); }
|
||||||
|
|
||||||
BMessenger fListener;
|
private:
|
||||||
BMessage fInterfaces;
|
BMessenger fListener;
|
||||||
BMessage fServices;
|
BMessage fInterfaces;
|
||||||
bool fUpdated;
|
BMessage fServices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user