175c44a83Sstippi/*
25c2095b4Sstippi * Copyright 2008-2010, Stephan A��mus <superstippi@gmx.de>.
375c44a83Sstippi * Copyright 1998, Eric Shepherd.
475c44a83Sstippi * All rights reserved. Distributed under the terms of the Be Sample Code
575c44a83Sstippi * license.
675c44a83Sstippi */
775c44a83Sstippi
875c44a83Sstippi//! Be Newsletter Volume II, Issue 35; September 2, 1998 (Eric Shepherd)
975c44a83Sstippi
1075c44a83Sstippi#include "SettingsMessage.h"
1175c44a83Sstippi
120ba16dd4Sstippi#include <new>
130ba16dd4Sstippi
14636f175bSstippi#include <Autolock.h>
1575c44a83Sstippi#include <Entry.h>
1675c44a83Sstippi#include <File.h>
170ba16dd4Sstippi#include <Messenger.h>
1875c44a83Sstippi#include <String.h>
1975c44a83Sstippi
2075c44a83Sstippi
2175c44a83SstippiSettingsMessage::SettingsMessage(directory_which directory,
2275c44a83Sstippi		const char* filename)
230ba16dd4Sstippi	:
240ba16dd4Sstippi	BMessage('pref'),
250ba16dd4Sstippi	fListeners(4)
2675c44a83Sstippi{
2775c44a83Sstippi	fStatus = find_directory(directory, &fPath);
2875c44a83Sstippi
2975c44a83Sstippi	if (fStatus == B_OK)
3075c44a83Sstippi		fStatus = fPath.Append(filename);
3175c44a83Sstippi
3275c44a83Sstippi	if (fStatus == B_OK)
3375c44a83Sstippi		fStatus = Load();
3475c44a83Sstippi}
3575c44a83Sstippi
3675c44a83Sstippi
3775c44a83SstippiSettingsMessage::~SettingsMessage()
3875c44a83Sstippi{
3975c44a83Sstippi	Save();
400ba16dd4Sstippi
410ba16dd4Sstippi	for (int32 i = fListeners.CountItems() - 1; i >= 0; i--)
420ba16dd4Sstippi		delete reinterpret_cast<BMessenger*>(fListeners.ItemAtFast(i));
4375c44a83Sstippi}
4475c44a83Sstippi
4575c44a83Sstippi
4675c44a83Sstippistatus_t
4775c44a83SstippiSettingsMessage::InitCheck() const
4875c44a83Sstippi{
4975c44a83Sstippi	return fStatus;
5075c44a83Sstippi}
5175c44a83Sstippi
5275c44a83Sstippi
5375c44a83Sstippistatus_t
5475c44a83SstippiSettingsMessage::Load()
5575c44a83Sstippi{
56636f175bSstippi	BAutolock _(this);
57636f175bSstippi
5875c44a83Sstippi	BFile file(fPath.Path(), B_READ_ONLY);
5975c44a83Sstippi	status_t status = file.InitCheck();
6075c44a83Sstippi
6175c44a83Sstippi	if (status == B_OK)
6275c44a83Sstippi		status = Unflatten(&file);
6375c44a83Sstippi
6475c44a83Sstippi	return status;
6575c44a83Sstippi}
6675c44a83Sstippi
6775c44a83Sstippi
6875c44a83Sstippistatus_t
6975c44a83SstippiSettingsMessage::Save() const
7075c44a83Sstippi{
71636f175bSstippi	BAutolock _(const_cast<SettingsMessage*>(this));
72636f175bSstippi
7375c44a83Sstippi	BFile file(fPath.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
7475c44a83Sstippi	status_t status = file.InitCheck();
7575c44a83Sstippi
7675c44a83Sstippi	if (status == B_OK)
7775c44a83Sstippi		status = Flatten(&file);
7875c44a83Sstippi
7975c44a83Sstippi	return status;
8075c44a83Sstippi}
8175c44a83Sstippi
8275c44a83Sstippi
830ba16dd4Sstippibool
840ba16dd4SstippiSettingsMessage::AddListener(const BMessenger& listener)
850ba16dd4Sstippi{
86636f175bSstippi	BAutolock _(this);
87636f175bSstippi
880ba16dd4Sstippi	BMessenger* listenerCopy = new(std::nothrow) BMessenger(listener);
890ba16dd4Sstippi	if (listenerCopy && fListeners.AddItem(listenerCopy))
900ba16dd4Sstippi		return true;
910ba16dd4Sstippi	delete listenerCopy;
920ba16dd4Sstippi	return false;
930ba16dd4Sstippi}
940ba16dd4Sstippi
950ba16dd4Sstippi
960ba16dd4Sstippivoid
970ba16dd4SstippiSettingsMessage::RemoveListener(const BMessenger& listener)
980ba16dd4Sstippi{
99636f175bSstippi	BAutolock _(this);
100636f175bSstippi
1010ba16dd4Sstippi	for (int32 i = fListeners.CountItems() - 1; i >= 0; i--) {
1020ba16dd4Sstippi		BMessenger* listenerItem = reinterpret_cast<BMessenger*>(
1030ba16dd4Sstippi			fListeners.ItemAtFast(i));
1040ba16dd4Sstippi		if (*listenerItem == listener) {
1050ba16dd4Sstippi			fListeners.RemoveItem(i);
1060ba16dd4Sstippi			delete listenerItem;
1070ba16dd4Sstippi			return;
1080ba16dd4Sstippi		}
1090ba16dd4Sstippi	}
1100ba16dd4Sstippi}
1110ba16dd4Sstippi
1120ba16dd4Sstippi
11375c44a83Sstippi// #pragma mark -
11475c44a83Sstippi
11575c44a83Sstippi
11675c44a83Sstippistatus_t
11775c44a83SstippiSettingsMessage::SetValue(const char* name, bool value)
11875c44a83Sstippi{
1190ba16dd4Sstippi	status_t ret = ReplaceBool(name, value);
1200ba16dd4Sstippi	if (ret != B_OK)
1210ba16dd4Sstippi		ret = AddBool(name, value);
1220ba16dd4Sstippi	if (ret == B_OK)
1230ba16dd4Sstippi		_NotifyValueChanged(name);
1240ba16dd4Sstippi	return ret;
12575c44a83Sstippi}
12675c44a83Sstippi
12775c44a83Sstippi
12875c44a83Sstippistatus_t
12975c44a83SstippiSettingsMessage::SetValue(const char* name, int8 value)
13075c44a83Sstippi{
1310ba16dd4Sstippi	status_t ret = ReplaceInt8(name, value);
1320ba16dd4Sstippi	if (ret != B_OK)
1330ba16dd4Sstippi		ret = AddInt8(name, value);
1340ba16dd4Sstippi	if (ret == B_OK)
1350ba16dd4Sstippi		_NotifyValueChanged(name);
1360ba16dd4Sstippi	return ret;
13775c44a83Sstippi}
13875c44a83Sstippi
13975c44a83Sstippi
14075c44a83Sstippistatus_t
14175c44a83SstippiSettingsMessage::SetValue(const char* name, int16 value)
14275c44a83Sstippi{
1430ba16dd4Sstippi	status_t ret = ReplaceInt16(name, value);
1440ba16dd4Sstippi	if (ret != B_OK)
1450ba16dd4Sstippi		ret = AddInt16(name, value);
1460ba16dd4Sstippi	if (ret == B_OK)
1470ba16dd4Sstippi		_NotifyValueChanged(name);
1480ba16dd4Sstippi	return ret;
14975c44a83Sstippi}
15075c44a83Sstippi
15175c44a83Sstippi
15275c44a83Sstippistatus_t
15375c44a83SstippiSettingsMessage::SetValue(const char* name, int32 value)
15475c44a83Sstippi{
1550ba16dd4Sstippi	status_t ret = ReplaceInt32(name, value);
1560ba16dd4Sstippi	if (ret != B_OK)
1570ba16dd4Sstippi		ret = AddInt32(name, value);
1580ba16dd4Sstippi	if (ret == B_OK)
1590ba16dd4Sstippi		_NotifyValueChanged(name);
1600ba16dd4Sstippi	return ret;
16175c44a83Sstippi}
16275c44a83Sstippi
16375c44a83Sstippi
16475c44a83Sstippistatus_t
16575c44a83SstippiSettingsMessage::SetValue(const char* name, uint32 value)
16675c44a83Sstippi{
1670ba16dd4Sstippi	status_t ret = ReplaceUInt32(name, value);
1680ba16dd4Sstippi	if (ret != B_OK)
1690ba16dd4Sstippi		ret = AddUInt32(name, value);
1700ba16dd4Sstippi	if (ret == B_OK)
1710ba16dd4Sstippi		_NotifyValueChanged(name);
1720ba16dd4Sstippi	return ret;
17375c44a83Sstippi}
17475c44a83Sstippi
17575c44a83Sstippi
17675c44a83Sstippistatus_t
17775c44a83SstippiSettingsMessage::SetValue(const char* name, int64 value)
17875c44a83Sstippi{
1790ba16dd4Sstippi	status_t ret = ReplaceInt64(name, value);
1800ba16dd4Sstippi	if (ret != B_OK)
1810ba16dd4Sstippi		ret = AddInt64(name, value);
1820ba16dd4Sstippi	if (ret == B_OK)
1830ba16dd4Sstippi		_NotifyValueChanged(name);
1840ba16dd4Sstippi	return ret;
18575c44a83Sstippi}
18675c44a83Sstippi
18775c44a83Sstippi
18875c44a83Sstippistatus_t
18975c44a83SstippiSettingsMessage::SetValue(const char* name, float value)
19075c44a83Sstippi{
1910ba16dd4Sstippi	status_t ret = ReplaceFloat(name, value);
1920ba16dd4Sstippi	if (ret != B_OK)
1930ba16dd4Sstippi		ret = AddFloat(name, value);
1940ba16dd4Sstippi	if (ret == B_OK)
1950ba16dd4Sstippi		_NotifyValueChanged(name);
1960ba16dd4Sstippi	return ret;
19775c44a83Sstippi}
19875c44a83Sstippi
19975c44a83Sstippi
20075c44a83Sstippistatus_t
20175c44a83SstippiSettingsMessage::SetValue(const char* name, double value)
20275c44a83Sstippi{
2030ba16dd4Sstippi	status_t ret = ReplaceDouble(name, value);
2040ba16dd4Sstippi	if (ret != B_OK)
2050ba16dd4Sstippi		ret = AddDouble(name, value);
2060ba16dd4Sstippi	if (ret == B_OK)
2070ba16dd4Sstippi		_NotifyValueChanged(name);
2080ba16dd4Sstippi	return ret;
20975c44a83Sstippi}
21075c44a83Sstippi
21175c44a83Sstippi
21275c44a83Sstippistatus_t
21375c44a83SstippiSettingsMessage::SetValue(const char* name, const char* value)
21475c44a83Sstippi{
2150ba16dd4Sstippi	status_t ret = ReplaceString(name, value);
2160ba16dd4Sstippi	if (ret != B_OK)
2170ba16dd4Sstippi		ret = AddString(name, value);
2180ba16dd4Sstippi	if (ret == B_OK)
2190ba16dd4Sstippi		_NotifyValueChanged(name);
2200ba16dd4Sstippi	return ret;
22175c44a83Sstippi}
22275c44a83Sstippi
22375c44a83Sstippi
22475c44a83Sstippistatus_t
22575c44a83SstippiSettingsMessage::SetValue(const char* name, const BString& value)
22675c44a83Sstippi{
2270ba16dd4Sstippi	status_t ret = ReplaceString(name, value);
2280ba16dd4Sstippi	if (ret != B_OK)
2290ba16dd4Sstippi		ret = AddString(name, value);
2300ba16dd4Sstippi	if (ret == B_OK)
2310ba16dd4Sstippi		_NotifyValueChanged(name);
2320ba16dd4Sstippi	return ret;
23375c44a83Sstippi}
23475c44a83Sstippi
23575c44a83Sstippi
23675c44a83Sstippistatus_t
23775c44a83SstippiSettingsMessage::SetValue(const char* name, const BPoint& value)
23875c44a83Sstippi{
2390ba16dd4Sstippi	status_t ret = ReplacePoint(name, value);
2400ba16dd4Sstippi	if (ret != B_OK)
2410ba16dd4Sstippi		ret = AddPoint(name, value);
2420ba16dd4Sstippi	if (ret == B_OK)
2430ba16dd4Sstippi		_NotifyValueChanged(name);
2440ba16dd4Sstippi	return ret;
24575c44a83Sstippi}
24675c44a83Sstippi
24775c44a83Sstippi
24875c44a83Sstippistatus_t
24975c44a83SstippiSettingsMessage::SetValue(const char* name, const BRect& value)
25075c44a83Sstippi{
2510ba16dd4Sstippi	status_t ret = ReplaceRect(name, value);
2520ba16dd4Sstippi	if (ret != B_OK)
2530ba16dd4Sstippi		ret = AddRect(name, value);
2540ba16dd4Sstippi	if (ret == B_OK)
2550ba16dd4Sstippi		_NotifyValueChanged(name);
2560ba16dd4Sstippi	return ret;
25775c44a83Sstippi}
25875c44a83Sstippi
25975c44a83Sstippi
26075c44a83Sstippistatus_t
26175c44a83SstippiSettingsMessage::SetValue(const char* name, const entry_ref& value)
26275c44a83Sstippi{
2630ba16dd4Sstippi	status_t ret = ReplaceRef(name, &value);
2640ba16dd4Sstippi	if (ret != B_OK)
2650ba16dd4Sstippi		ret = AddRef(name, &value);
2660ba16dd4Sstippi	if (ret == B_OK)
2670ba16dd4Sstippi		_NotifyValueChanged(name);
2680ba16dd4Sstippi	return ret;
26975c44a83Sstippi}
27075c44a83Sstippi
27175c44a83Sstippi
27275c44a83Sstippistatus_t
2737239ea75SstippiSettingsMessage::SetValue(const char* name, const BMessage& value)
27475c44a83Sstippi{
2750ba16dd4Sstippi	status_t ret = ReplaceMessage(name, &value);
2760ba16dd4Sstippi	if (ret != B_OK)
2770ba16dd4Sstippi		ret = AddMessage(name, &value);
2780ba16dd4Sstippi	if (ret == B_OK)
2790ba16dd4Sstippi		_NotifyValueChanged(name);
2800ba16dd4Sstippi	return ret;
28175c44a83Sstippi}
28275c44a83Sstippi
28375c44a83Sstippi
28475c44a83Sstippistatus_t
28575c44a83SstippiSettingsMessage::SetValue(const char* name, const BFlattenable* value)
28675c44a83Sstippi{
2870ba16dd4Sstippi	status_t ret = ReplaceFlat(name, const_cast<BFlattenable*>(value));
2880ba16dd4Sstippi	if (ret != B_OK)
2890ba16dd4Sstippi		ret = AddFlat(name, const_cast<BFlattenable*>(value));
2900ba16dd4Sstippi	if (ret == B_OK)
2910ba16dd4Sstippi		_NotifyValueChanged(name);
2920ba16dd4Sstippi	return ret;
29375c44a83Sstippi}
29475c44a83Sstippi
29575c44a83Sstippi
2965c2095b4Sstippistatus_t
2975c2095b4SstippiSettingsMessage::SetValue(const char* name, const BFont& value)
2985c2095b4Sstippi{
2995c2095b4Sstippi	font_family family;
3005c2095b4Sstippi	font_style style;
3015c2095b4Sstippi	value.GetFamilyAndStyle(&family, &style);
3025c2095b4Sstippi
3035c2095b4Sstippi	BMessage fontMessage;
3045c2095b4Sstippi	status_t ret = fontMessage.AddString("family", family);
3055c2095b4Sstippi	if (ret == B_OK)
3065c2095b4Sstippi		ret = fontMessage.AddString("style", style);
3075c2095b4Sstippi	if (ret == B_OK)
3085c2095b4Sstippi		ret = fontMessage.AddFloat("size", value.Size());
3095c2095b4Sstippi
3105c2095b4Sstippi	if (ret == B_OK) {
3115c2095b4Sstippi		if (ReplaceMessage(name, &fontMessage) != B_OK)
3125c2095b4Sstippi			ret = AddMessage(name, &fontMessage);
3135c2095b4Sstippi	}
3140ba16dd4Sstippi	if (ret == B_OK)
3150ba16dd4Sstippi		_NotifyValueChanged(name);
3165c2095b4Sstippi	return ret;
3175c2095b4Sstippi}
3185c2095b4Sstippi
3195c2095b4Sstippi
32075c44a83Sstippi// #pragma mark -
32175c44a83Sstippi
3225c2095b4Sstippi
32375c44a83Sstippibool
32475c44a83SstippiSettingsMessage::GetValue(const char* name, bool defaultValue) const
32575c44a83Sstippi{
32675c44a83Sstippi	bool value;
32775c44a83Sstippi	if (FindBool(name, &value) != B_OK)
32875c44a83Sstippi		return defaultValue;
32975c44a83Sstippi	return value;
33075c44a83Sstippi}
33175c44a83Sstippi
33275c44a83Sstippi
33375c44a83Sstippiint8
33475c44a83SstippiSettingsMessage::GetValue(const char* name, int8 defaultValue) const
33575c44a83Sstippi{
33675c44a83Sstippi	int8 value;
33775c44a83Sstippi	if (FindInt8(name, &value) != B_OK)
33875c44a83Sstippi		return defaultValue;
33975c44a83Sstippi	return value;
34075c44a83Sstippi}
34175c44a83Sstippi
34275c44a83Sstippi
34375c44a83Sstippiint16
34475c44a83SstippiSettingsMessage::GetValue(const char* name, int16 defaultValue) const
34575c44a83Sstippi{
34675c44a83Sstippi	int16 value;
34775c44a83Sstippi	if (FindInt16(name, &value) != B_OK)
34875c44a83Sstippi		return defaultValue;
34975c44a83Sstippi	return value;
35075c44a83Sstippi}
35175c44a83Sstippi
35275c44a83Sstippi
35375c44a83Sstippiint32
35475c44a83SstippiSettingsMessage::GetValue(const char* name, int32 defaultValue) const
35575c44a83Sstippi{
35675c44a83Sstippi	int32 value;
35775c44a83Sstippi	if (FindInt32(name, &value) != B_OK)
35875c44a83Sstippi		return defaultValue;
35975c44a83Sstippi	return value;
36075c44a83Sstippi}
36175c44a83Sstippi
36275c44a83Sstippi
36375c44a83Sstippiuint32
36475c44a83SstippiSettingsMessage::GetValue(const char* name, uint32 defaultValue) const
36575c44a83Sstippi{
366a8d1c85dSstippi	uint32 value;
367a8d1c85dSstippi	if (FindUInt32(name, &value) != B_OK)
36875c44a83Sstippi		return defaultValue;
369a8d1c85dSstippi	return value;
37075c44a83Sstippi}
37175c44a83Sstippi
37275c44a83Sstippi
37375c44a83Sstippiint64
37475c44a83SstippiSettingsMessage::GetValue(const char* name, int64 defaultValue) const
37575c44a83Sstippi{
37675c44a83Sstippi	int64 value;
37775c44a83Sstippi	if (FindInt64(name, &value) != B_OK)
37875c44a83Sstippi		return defaultValue;
37975c44a83Sstippi	return value;
38075c44a83Sstippi}
38175c44a83Sstippi
38275c44a83Sstippi
38375c44a83Sstippifloat
38475c44a83SstippiSettingsMessage::GetValue(const char* name, float defaultValue) const
38575c44a83Sstippi{
38675c44a83Sstippi	float value;
38775c44a83Sstippi	if (FindFloat(name, &value) != B_OK)
38875c44a83Sstippi		return defaultValue;
38975c44a83Sstippi	return value;
39075c44a83Sstippi}
39175c44a83Sstippi
39275c44a83Sstippi
39375c44a83Sstippidouble
39475c44a83SstippiSettingsMessage::GetValue(const char* name, double defaultValue) const
39575c44a83Sstippi{
39675c44a83Sstippi	double value;
39775c44a83Sstippi	if (FindDouble(name, &value) != B_OK)
39875c44a83Sstippi		return defaultValue;
39975c44a83Sstippi	return value;
40075c44a83Sstippi}
40175c44a83Sstippi
40275c44a83Sstippi
40375c44a83SstippiBString
40475c44a83SstippiSettingsMessage::GetValue(const char* name, const BString& defaultValue) const
40575c44a83Sstippi{
40675c44a83Sstippi	BString value;
40775c44a83Sstippi	if (FindString(name, &value) != B_OK)
40875c44a83Sstippi		return defaultValue;
40975c44a83Sstippi	return value;
41075c44a83Sstippi}
41175c44a83Sstippi
41275c44a83Sstippi
413636f175bSstippiconst char*
414636f175bSstippiSettingsMessage::GetValue(const char* name, const char* defaultValue) const
415636f175bSstippi{
416636f175bSstippi	const char* value;
417636f175bSstippi	if (FindString(name, &value) != B_OK)
418636f175bSstippi		return defaultValue;
419636f175bSstippi	return value;
420636f175bSstippi}
421636f175bSstippi
422636f175bSstippi
42375c44a83SstippiBPoint
42475c44a83SstippiSettingsMessage::GetValue(const char *name, BPoint defaultValue) const
42575c44a83Sstippi{
42675c44a83Sstippi	BPoint value;
42775c44a83Sstippi	if (FindPoint(name, &value) != B_OK)
42875c44a83Sstippi		return defaultValue;
42975c44a83Sstippi	return value;
43075c44a83Sstippi}
43175c44a83Sstippi
43275c44a83Sstippi
43375c44a83SstippiBRect
43475c44a83SstippiSettingsMessage::GetValue(const char* name, BRect defaultValue) const
43575c44a83Sstippi{
43675c44a83Sstippi	BRect value;
43775c44a83Sstippi	if (FindRect(name, &value) != B_OK)
43875c44a83Sstippi		return defaultValue;
43975c44a83Sstippi	return value;
44075c44a83Sstippi}
44175c44a83Sstippi
44275c44a83Sstippi
44375c44a83Sstippientry_ref
44475c44a83SstippiSettingsMessage::GetValue(const char* name, const entry_ref& defaultValue) const
44575c44a83Sstippi{
44675c44a83Sstippi	entry_ref value;
44775c44a83Sstippi	if (FindRef(name, &value) != B_OK)
44875c44a83Sstippi		return defaultValue;
44975c44a83Sstippi	return value;
45075c44a83Sstippi}
45175c44a83Sstippi
45275c44a83Sstippi
45375c44a83SstippiBMessage
45475c44a83SstippiSettingsMessage::GetValue(const char* name, const BMessage& defaultValue) const
45575c44a83Sstippi{
45675c44a83Sstippi	BMessage value;
45775c44a83Sstippi	if (FindMessage(name, &value) != B_OK)
45875c44a83Sstippi		return defaultValue;
45975c44a83Sstippi	return value;
46075c44a83Sstippi}
46175c44a83Sstippi
4625c2095b4Sstippi
4635c2095b4SstippiBFont
4645c2095b4SstippiSettingsMessage::GetValue(const char* name, const BFont& defaultValue) const
4655c2095b4Sstippi{
4665c2095b4Sstippi	BMessage fontMessage;
4675c2095b4Sstippi	if (FindMessage(name, &fontMessage) != B_OK)
4685c2095b4Sstippi		return defaultValue;
4695c2095b4Sstippi
4705c2095b4Sstippi	const char* family;
4715c2095b4Sstippi	const char* style;
4725c2095b4Sstippi	float size;
4735c2095b4Sstippi	if (fontMessage.FindString("family", &family) != B_OK
4745c2095b4Sstippi		|| fontMessage.FindString("style", &style) != B_OK
4755c2095b4Sstippi		|| fontMessage.FindFloat("size", &size) != B_OK) {
4765c2095b4Sstippi		return defaultValue;
4775c2095b4Sstippi	}
4785c2095b4Sstippi
4795c2095b4Sstippi	BFont value;
4805c2095b4Sstippi	if (value.SetFamilyAndStyle(family, style) != B_OK)
4815c2095b4Sstippi		return defaultValue;
4825c2095b4Sstippi
4835c2095b4Sstippi	value.SetSize(size);
4845c2095b4Sstippi
4855c2095b4Sstippi	return value;
4865c2095b4Sstippi}
4875c2095b4Sstippi
4880ba16dd4Sstippi
4890ba16dd4Sstippi// #pragma mark - private
4900ba16dd4Sstippi
4910ba16dd4Sstippi
4920ba16dd4Sstippivoid
4930ba16dd4SstippiSettingsMessage::_NotifyValueChanged(const char* name) const
4940ba16dd4Sstippi{
495636f175bSstippi	BMessage message(SETTINGS_VALUE_CHANGED);
4960ba16dd4Sstippi	message.AddString("name", name);
4976463044eSstippi
4986463044eSstippi	// Add the value of that name to the notification.
4996463044eSstippi	type_code type;
5006463044eSstippi	if (GetInfo(name, &type) == B_OK) {
5016463044eSstippi		const void* data;
5026463044eSstippi		ssize_t numBytes;
5036463044eSstippi		if (FindData(name, type, &data, &numBytes) == B_OK)
5046463044eSstippi			message.AddData("value", type, data, numBytes);
5056463044eSstippi	}
5066463044eSstippi
5070ba16dd4Sstippi	int32 count = fListeners.CountItems();
5080ba16dd4Sstippi	for (int32 i = 0; i < count; i++) {
5090ba16dd4Sstippi		BMessenger* listener = reinterpret_cast<BMessenger*>(
5100ba16dd4Sstippi			fListeners.ItemAtFast(i));
5110ba16dd4Sstippi		listener->SendMessage(&message);
5120ba16dd4Sstippi	}
5130ba16dd4Sstippi}
5140ba16dd4Sstippi
515