enums.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-or-later OR BSD-3-Clause
2 /***************************************************************************
3  * Copyright (C) 2007,2010 by Rick L. Vinyard, Jr. *
4  * rvinyard@cs.nmsu.edu *
5  * *
6  * This file is part of the dbus-cxx library. *
7  ***************************************************************************/
8 #include <cstdint>
9 #include <ostream>
10 
11 #ifndef DBUSCXX_ENUMS_H
12 #define DBUSCXX_ENUMS_H
13 
14 namespace DBus {
15 
16 enum class BusType {
17  NONE = -1,
18  SESSION,
19  SYSTEM,
20  STARTER
21 };
22 
23 enum class PropertyUpdateType {
28  Updates,
37  Const,
44 };
45 
46 enum class PropertyAccess {
47  ReadOnly,
48  WriteOnly,
49  ReadWrite
50 };
51 
52 enum class DataType {
53  INVALID = '\0',
54  BYTE = 'y',
55  BOOLEAN = 'b',
56  INT16 = 'n',
57  UINT16 = 'q',
58  INT32 = 'i',
59  UINT32 = 'u',
60  INT64 = 'x',
61  UINT64 = 't',
62  DOUBLE = 'd',
63  STRING = 's',
64  OBJECT_PATH = 'o',
65  SIGNATURE = 'g',
66  ARRAY = 'a',
67  VARIANT = 'v',
68  STRUCT = 'r',
69  DICT_ENTRY = 'e',
70  UNIX_FD = 'h',
71 };
72 
73 enum class ContainerType {
74  None,
75  ARRAY = 'a',
76  VARIANT = 'v',
77  STRUCT = 'r',
78  DICT_ENTRY = 'e',
79 };
80 
81 enum class MessageType : int32_t {
82  INVALID = 0,
83  CALL = 1,
84  RETURN = 2,
85  ERROR = 3,
86  SIGNAL = 4,
87 };
88 
89 enum class DispatchStatus {
91  COMPLETE,
93 };
94 
95 enum class HandlerResult {
97  Handled,
103  Invalid_Path,
105  Not_Handled,
106 };
107 
108 enum class StartReply {
109  FAILED = 0,
110  SUCCESS,
112 };
113 
114 enum class Endianess {
115  Little,
116  Big,
117 };
118 
119 enum class RegistrationStatus {
120  Success,
127 };
128 
133 enum class ThreadForCalling {
138 };
139 
141  Invalid = 0,
142  Path = 1,
143  Interface = 2,
144  Member = 3,
145  Error_Name = 4,
146  Reply_Serial = 5,
147  Destination = 6,
148  Sender = 7,
149  Signature = 8,
150  Unix_FDs = 9,
151 };
152 
158  PrimaryOwner,
160  NameInQueue,
162  NameExists,
165 };
166 
169  NameReleased,
173  NotOwner
174 };
175 
176 inline uint8_t header_field_to_int( MessageHeaderFields header ) {
177  switch( header ) {
179  return 1;
180 
182  return 2;
183 
185  return 3;
186 
188  return 4;
189 
191  return 5;
192 
194  return 6;
195 
197  return 7;
198 
200  return 8;
201 
203  return 9;
204 
205  default:
206  return 0;
207  }
208 }
209 
211  switch( val ) {
212  case 1:
214 
215  case 2:
217 
218  case 3:
220 
221  case 4:
223 
224  case 5:
226 
227  case 6:
229 
230  case 7:
232 
233  case 8:
235 
236  case 9:
238  }
239 
241 }
242 
243 inline std::ostream& operator<<( std::ostream& os, Endianess endian ) {
244  if( endian == Endianess::Little ) {
245  os << "Little";
246  } else {
247  os << "Big";
248  }
249 
250  return os;
251 }
252 
253 inline std::ostream& operator<<( std::ostream& os, MessageType type ) {
254  os << "MessageType::";
255 
256  switch( type ) {
258  os << "INVALID";
259  break;
260 
261  case MessageType::CALL:
262  os << "CALL";
263  break;
264 
265  case MessageType::RETURN:
266  os << "RETURN";
267  break;
268 
269  case MessageType::ERROR:
270  os << "ERROR";
271  break;
272 
273  case MessageType::SIGNAL:
274  os << "SIGNAL";
275  break;
276  }
277 
278  return os;
279 }
280 
281 inline std::ostream& operator<<( std::ostream& os, DispatchStatus status ) {
282  os << "DispatchStatus::";
283 
284  switch( status ) {
286  os << "DATA_REMAINS";
287  break;
288 
290  os << "COMPLETE";
291  break;
292 
294  os << "NEED_MEMORY";
295  break;
296  }
297 
298  return os;
299 }
300 
301 inline std::ostream& operator<<( std::ostream& os, HandlerResult res ) {
302  os << "HandlerResult::";
303 
304  switch( res ) {
306  os << "Handled";
307  break;
308 
310  os << "Not_Handled";
311  break;
312 
314  os << "Invalid_Path";
315  break;
316 
318  os << "Invalid_Method";
319  break;
320 
322  os << "Invalid_Interface";
323  }
324 
325  return os;
326 }
327 
328 }
329 
330 #endif
331 
An Interface represents a local copy of a DBus interface.
Definition: interface.h:41
Represents a DBus Path.
Definition: path.h:21
Represents a DBus signature.
Definition: signature.h:74
Global DBus namespace, where everything happens.
Definition: callmessage.cpp:18
DispatchStatus
Definition: enums.h:89
ContainerType
Definition: enums.h:73
MessageHeaderFields
Definition: enums.h:140
uint8_t header_field_to_int(MessageHeaderFields header)
Definition: enums.h:176
PropertyAccess
Definition: enums.h:46
std::shared_ptr< DBus::Connection > operator<<(std::shared_ptr< DBus::Connection > ptr, std::shared_ptr< DBus::Message > msg)
Definition: connection.h:431
StartReply
Definition: enums.h:108
BusType
Definition: enums.h:16
@ SESSION
The login session bus.
@ STARTER
The bus that started us, if any.
@ SYSTEM
The systemwide bus.
ReleaseNameResponse
Definition: enums.h:167
@ NotOwner
We are not the owner, and we also were not in the queue waiting to own the name.
@ NameNonExistant
The given name does not exist on the bus.
@ NameReleased
The name has been released.
DataType type(const uint8_t &)
Definition: types.h:137
MessageType
Definition: enums.h:81
HandlerResult
Definition: enums.h:95
@ Not_Handled
This message was not handled for some reason.
@ Invalid_Path
This message had an invalid path.
@ Invalid_Method
This message had an invalid method to call.
@ Handled
This message was handled appropriately.
@ Invalid_Interface
This message had an invalid interface.
RequestNameResponse
Response status to attempting to register a name on the bus.
Definition: enums.h:156
@ NameExists
The name exists and we cannot get it.
@ AlreadyOwner
We are already the owner of the specified name.
@ PrimaryOwner
The caller is now the primary owner.
@ NameInQueue
The caller is in the queue.
RegistrationStatus
Definition: enums.h:119
@ Failed_Path_in_Use
Unable to register object: There is already an object exported on this path.
@ Failed_No_Thread_Dispatcher
Unable to register object: No thread dispatcher for the given thread found.
@ Failed_Invalid_Object
Unable to register object: invalid object.
MessageHeaderFields int_to_header_field(uint8_t val)
Definition: enums.h:210
DataType
Definition: enums.h:52
Endianess
Definition: enums.h:114
PropertyUpdateType
Definition: enums.h:23
@ DoesNotUpdate
The property does not emit the PropertyChanged signal whenever it changes.
@ Const
This property does not change during the lifetime.
@ Updates
When this property changes, the PropertyChanged signal will be emitted with the new value.
@ Invalidates
When this property cahnges, the PropertyChanged signal will be emitted but the new value will not be ...
ThreadForCalling
Gives hints to the connection as to which thread should be the one to call the methods on the given o...
Definition: enums.h:133
@ CurrentThread
Always call methods for this object from the current thread.
@ DispatcherThread
Always call methods for this object from the dispatcher thread.