2 * Copyright 2015, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
5 #include "TeamSignalSettings.h"
8 static const char* skDefaultSignalFieldName
= "signal:default_disposition";
9 static const char* skSignalNumberFieldName
= "signal:number";
10 static const char* skSignalDispositionFieldName
= "signal:disposition";
11 static const char* skSignalSettingName
= "signal:setting";
14 TeamSignalSettings::TeamSignalSettings()
21 TeamSignalSettings::~TeamSignalSettings()
27 TeamSignalSettings::operator=(const TeamSignalSettings
& other
)
29 fValues
= other
.fValues
;
36 TeamSignalSettings::ID() const
43 TeamSignalSettings::SetTo(const BMessage
& archive
)
56 TeamSignalSettings::WriteTo(BMessage
& archive
) const
69 TeamSignalSettings::Unset()
76 TeamSignalSettings::SetDefaultSignalDisposition(int32 disposition
)
78 fValues
.SetInt32(skDefaultSignalFieldName
, disposition
);
83 TeamSignalSettings::DefaultSignalDisposition() const
85 return fValues
.GetInt32(skDefaultSignalFieldName
,
86 SIGNAL_DISPOSITION_IGNORE
);
91 TeamSignalSettings::CountCustomSignalDispositions() const
96 if (fValues
.GetInfo(skSignalSettingName
, &type
, &count
) == B_OK
)
104 TeamSignalSettings::AddCustomSignalDisposition(int32 signal
, int32 disposition
)
107 if (setting
.AddInt32(skSignalNumberFieldName
, signal
) != B_OK
108 || setting
.AddInt32(skSignalDispositionFieldName
, disposition
) != B_OK
109 || fValues
.AddMessage(skSignalSettingName
, &setting
) != B_OK
) {
118 TeamSignalSettings::RemoveCustomSignalDispositionAt(int32 index
)
120 return fValues
.RemoveData(skSignalSettingName
, index
);
125 TeamSignalSettings::GetCustomSignalDispositionAt(int32 index
, int32
& signal
,
126 int32
& disposition
) const
129 status_t error
= fValues
.FindMessage(skSignalSettingName
, index
, &setting
);
133 error
= setting
.FindInt32(skSignalNumberFieldName
, &signal
);
137 return setting
.FindInt32(skSignalDispositionFieldName
, &disposition
);
142 TeamSignalSettings::Clone() const
144 TeamSignalSettings
* settings
= new(std::nothrow
)
145 TeamSignalSettings();
147 if (settings
== NULL
)
150 if (settings
->SetTo(fValues
) != B_OK
) {