2 * Copyright 2010-2017, Haiku, Inc. All Rights Reserved.
3 * Copyright 2008-2009, Pier Luigi Fiorini. All Rights Reserved.
4 * Copyright 2004-2008, Michael Davidson. All Rights Reserved.
5 * Copyright 2004-2007, Mikael Eiman. All Rights Reserved.
6 * Distributed under the terms of the MIT License.
9 * Michael Davidson, slaad@bong.com.au
10 * Mikael Eiman, mikael@eiman.tv
11 * Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
12 * Brian Hill, supernova@tycho.email
18 #include <NotificationReceived.h>
20 const type_code kTypeCode
= 'ipau';
32 AppUsage::AppUsage(const char* name
, const char* signature
, bool allow
)
35 fSignature(signature
),
42 AppUsage::AllowsTypeCode(type_code code
) const
44 return code
== kTypeCode
;
49 AppUsage::Flatten(void* buffer
, ssize_t numBytes
) const
52 msg
.AddString("name", fAppName
);
53 msg
.AddString("signature", fSignature
);
54 msg
.AddBool("allow", fAllow
);
56 if (numBytes
< msg
.FlattenedSize())
59 return msg
.Flatten((char*)buffer
, numBytes
);
64 AppUsage::FlattenedSize() const
67 msg
.AddString("name", fAppName
);
68 msg
.AddString("signature", fSignature
);
69 msg
.AddBool("allow", fAllow
);
71 return msg
.FlattenedSize();
76 AppUsage::IsFixedSize() const
83 AppUsage::TypeCode() const
90 AppUsage::Unflatten(type_code code
, const void* buffer
,
93 if (code
!= kTypeCode
)
97 status_t status
= B_ERROR
;
99 status
= msg
.Unflatten((const char*)buffer
);
101 if (status
== B_OK
) {
102 msg
.FindString("name", &fAppName
);
103 msg
.FindString("signature", &fSignature
);
104 msg
.FindBool("allow", &fAllow
);
114 return fAppName
.String();
119 AppUsage::Signature()
121 return fSignature
.String();
133 AppUsage::SetAllowed(bool allow
)