| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DBUS_MESSAGE_H_ | 5 #ifndef DBUS_MESSAGE_H_ |
| 6 #define DBUS_MESSAGE_H_ | 6 #define DBUS_MESSAGE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include <dbus/dbus.h> | 11 #include <dbus/dbus.h> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "dbus/file_descriptor.h" |
| 14 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
| 15 | 16 |
| 16 namespace google { | 17 namespace google { |
| 17 namespace protobuf { | 18 namespace protobuf { |
| 18 | 19 |
| 19 class MessageLite; | 20 class MessageLite; |
| 20 | 21 |
| 21 } // namespace protobuf | 22 } // namespace protobuf |
| 22 } // namespace google | 23 } // namespace google |
| 23 | 24 |
| 24 | 25 |
| 25 namespace dbus { | 26 namespace dbus { |
| 26 | 27 |
| 27 class MessageWriter; | 28 class MessageWriter; |
| 28 class MessageReader; | 29 class MessageReader; |
| 29 | 30 |
| 31 // DBUS_TYPE_UNIX_FD was added in D-Bus version 1.4 |
| 32 #if defined(DBUS_TYPE_UNIX_FD) |
| 33 const bool kDBusTypeUnixFdIsSupported = true; |
| 34 #else |
| 35 const bool kDBusTypeUnixFdIsSupported = false; |
| 36 #define DBUS_TYPE_UNIX_FD ((int) 'h') |
| 37 #endif |
| 38 |
| 30 // Message is the base class of D-Bus message types. Client code must use | 39 // Message is the base class of D-Bus message types. Client code must use |
| 31 // sub classes such as MethodCall and Response instead. | 40 // sub classes such as MethodCall and Response instead. |
| 32 // | 41 // |
| 33 // The class name Message is very generic, but there should be no problem | 42 // The class name Message is very generic, but there should be no problem |
| 34 // as the class is inside 'dbus' namespace. We chose to name this way, as | 43 // as the class is inside 'dbus' namespace. We chose to name this way, as |
| 35 // libdbus defines lots of types starting with DBus, such as | 44 // libdbus defines lots of types starting with DBus, such as |
| 36 // DBusMessage. We should avoid confusion and conflict with these types. | 45 // DBusMessage. We should avoid confusion and conflict with these types. |
| 37 class Message { | 46 class Message { |
| 38 public: | 47 public: |
| 39 // The message type used in D-Bus. Redefined here so client code | 48 // The message type used in D-Bus. Redefined here so client code |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 UINT32 = DBUS_TYPE_UINT32, | 69 UINT32 = DBUS_TYPE_UINT32, |
| 61 INT64 = DBUS_TYPE_INT64, | 70 INT64 = DBUS_TYPE_INT64, |
| 62 UINT64 = DBUS_TYPE_UINT64, | 71 UINT64 = DBUS_TYPE_UINT64, |
| 63 DOUBLE = DBUS_TYPE_DOUBLE, | 72 DOUBLE = DBUS_TYPE_DOUBLE, |
| 64 STRING = DBUS_TYPE_STRING, | 73 STRING = DBUS_TYPE_STRING, |
| 65 OBJECT_PATH = DBUS_TYPE_OBJECT_PATH, | 74 OBJECT_PATH = DBUS_TYPE_OBJECT_PATH, |
| 66 ARRAY = DBUS_TYPE_ARRAY, | 75 ARRAY = DBUS_TYPE_ARRAY, |
| 67 STRUCT = DBUS_TYPE_STRUCT, | 76 STRUCT = DBUS_TYPE_STRUCT, |
| 68 DICT_ENTRY = DBUS_TYPE_DICT_ENTRY, | 77 DICT_ENTRY = DBUS_TYPE_DICT_ENTRY, |
| 69 VARIANT = DBUS_TYPE_VARIANT, | 78 VARIANT = DBUS_TYPE_VARIANT, |
| 79 UNIX_FD = DBUS_TYPE_UNIX_FD, |
| 70 }; | 80 }; |
| 71 | 81 |
| 72 // Returns the type of the message. Returns MESSAGE_INVALID if | 82 // Returns the type of the message. Returns MESSAGE_INVALID if |
| 73 // raw_message_ is NULL. | 83 // raw_message_ is NULL. |
| 74 MessageType GetMessageType(); | 84 MessageType GetMessageType(); |
| 75 | 85 |
| 76 // Returns the type of the message as string like "MESSAGE_METHOD_CALL" | 86 // Returns the type of the message as string like "MESSAGE_METHOD_CALL" |
| 77 // for instance. | 87 // for instance. |
| 78 std::string GetMessageTypeAsString(); | 88 std::string GetMessageTypeAsString(); |
| 79 | 89 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 void AppendBool(bool value); | 271 void AppendBool(bool value); |
| 262 void AppendInt16(int16 value); | 272 void AppendInt16(int16 value); |
| 263 void AppendUint16(uint16 value); | 273 void AppendUint16(uint16 value); |
| 264 void AppendInt32(int32 value); | 274 void AppendInt32(int32 value); |
| 265 void AppendUint32(uint32 value); | 275 void AppendUint32(uint32 value); |
| 266 void AppendInt64(int64 value); | 276 void AppendInt64(int64 value); |
| 267 void AppendUint64(uint64 value); | 277 void AppendUint64(uint64 value); |
| 268 void AppendDouble(double value); | 278 void AppendDouble(double value); |
| 269 void AppendString(const std::string& value); | 279 void AppendString(const std::string& value); |
| 270 void AppendObjectPath(const ObjectPath& value); | 280 void AppendObjectPath(const ObjectPath& value); |
| 281 void AppendFileDescriptor(const FileDescriptor& value); |
| 271 | 282 |
| 272 // Opens an array. The array contents can be added to the array with | 283 // Opens an array. The array contents can be added to the array with |
| 273 // |sub_writer|. The client code must close the array with | 284 // |sub_writer|. The client code must close the array with |
| 274 // CloseContainer(), once all contents are added. | 285 // CloseContainer(), once all contents are added. |
| 275 // | 286 // |
| 276 // |signature| parameter is used to supply the D-Bus type signature of | 287 // |signature| parameter is used to supply the D-Bus type signature of |
| 277 // the array contents. For instance, if you want an array of strings, | 288 // the array contents. For instance, if you want an array of strings, |
| 278 // then you pass "s" as the signature. | 289 // then you pass "s" as the signature. |
| 279 // | 290 // |
| 280 // See the spec for details about the type signatures. | 291 // See the spec for details about the type signatures. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 bool PopBool(bool* value); | 381 bool PopBool(bool* value); |
| 371 bool PopInt16(int16* value); | 382 bool PopInt16(int16* value); |
| 372 bool PopUint16(uint16* value); | 383 bool PopUint16(uint16* value); |
| 373 bool PopInt32(int32* value); | 384 bool PopInt32(int32* value); |
| 374 bool PopUint32(uint32* value); | 385 bool PopUint32(uint32* value); |
| 375 bool PopInt64(int64* value); | 386 bool PopInt64(int64* value); |
| 376 bool PopUint64(uint64* value); | 387 bool PopUint64(uint64* value); |
| 377 bool PopDouble(double* value); | 388 bool PopDouble(double* value); |
| 378 bool PopString(std::string* value); | 389 bool PopString(std::string* value); |
| 379 bool PopObjectPath(ObjectPath* value); | 390 bool PopObjectPath(ObjectPath* value); |
| 391 bool PopFileDescriptor(FileDescriptor* value); |
| 380 | 392 |
| 381 // Sets up the given message reader to read an array at the current | 393 // Sets up the given message reader to read an array at the current |
| 382 // iterator position. | 394 // iterator position. |
| 383 // Returns true and advances the iterator on success. | 395 // Returns true and advances the iterator on success. |
| 384 // Returns false if the data type is not an array | 396 // Returns false if the data type is not an array |
| 385 bool PopArray(MessageReader* sub_reader); | 397 bool PopArray(MessageReader* sub_reader); |
| 386 bool PopStruct(MessageReader* sub_reader); | 398 bool PopStruct(MessageReader* sub_reader); |
| 387 bool PopDictEntry(MessageReader* sub_reader); | 399 bool PopDictEntry(MessageReader* sub_reader); |
| 388 bool PopVariant(MessageReader* sub_reader); | 400 bool PopVariant(MessageReader* sub_reader); |
| 389 | 401 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 | 473 |
| 462 Message* message_; | 474 Message* message_; |
| 463 DBusMessageIter raw_message_iter_; | 475 DBusMessageIter raw_message_iter_; |
| 464 | 476 |
| 465 DISALLOW_COPY_AND_ASSIGN(MessageReader); | 477 DISALLOW_COPY_AND_ASSIGN(MessageReader); |
| 466 }; | 478 }; |
| 467 | 479 |
| 468 } // namespace dbus | 480 } // namespace dbus |
| 469 | 481 |
| 470 #endif // DBUS_MESSAGE_H_ | 482 #endif // DBUS_MESSAGE_H_ |
| OLD | NEW |