Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "third_party/protobuf/src/google/protobuf/message_lite.h" | |
|
satorux1
2012/01/31 21:42:31
I think you can remove the include from .h file, b
rharrison
2012/02/01 19:03:20
Done.
| |
| 14 | 15 |
| 15 namespace dbus { | 16 namespace dbus { |
| 16 | 17 |
| 17 class MessageWriter; | 18 class MessageWriter; |
| 18 class MessageReader; | 19 class MessageReader; |
| 19 | 20 |
| 20 // Message is the base class of D-Bus message types. Client code must use | 21 // Message is the base class of D-Bus message types. Client code must use |
| 21 // sub classes such as MethodCall and Response instead. | 22 // sub classes such as MethodCall and Response instead. |
| 22 // | 23 // |
| 23 // The class name Message is very generic, but there should be no problem | 24 // The class name Message is very generic, but there should be no problem |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 // Appends the array of strings. Arrays of strings are often used for | 288 // Appends the array of strings. Arrays of strings are often used for |
| 288 // exchanging lists of names hence it's worth having a specialized | 289 // exchanging lists of names hence it's worth having a specialized |
| 289 // function. | 290 // function. |
| 290 void AppendArrayOfStrings(const std::vector<std::string>& strings); | 291 void AppendArrayOfStrings(const std::vector<std::string>& strings); |
| 291 | 292 |
| 292 // Appends the array of object paths. Arrays of object paths are often | 293 // Appends the array of object paths. Arrays of object paths are often |
| 293 // used when exchanging object paths, hence it's worth having a | 294 // used when exchanging object paths, hence it's worth having a |
| 294 // specialized function. | 295 // specialized function. |
| 295 void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths); | 296 void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths); |
| 296 | 297 |
| 298 // Appends the protocol buffer. The buffer is serialized into an array of | |
|
satorux1
2012/01/31 21:42:31
Appends the protocol buffer as an array of bytes.
rharrison
2012/02/01 19:03:20
Done.
| |
| 299 // bytes before communication, since protocol buffers are not a native dbus | |
| 300 // type. On the receiving size the array of bytes needs to be read and | |
| 301 // deserialized into a protocol buffer of the correct type. There are methods | |
| 302 // in MessageReader to assist in this. | |
| 303 // Return true on succes and fail when serialization is not successful. | |
| 304 bool AppendProtocolBuffer(const google::protobuf::MessageLite& protobuf); | |
|
satorux1
2012/01/31 21:42:31
AppendProtoAsArrayOfBytes() would make it clear th
rharrison
2012/02/01 19:03:20
Done.
| |
| 305 | |
| 297 // Appends the byte wrapped in a variant data container. Variants are | 306 // Appends the byte wrapped in a variant data container. Variants are |
| 298 // widely used in D-Bus services so it's worth having a specialized | 307 // widely used in D-Bus services so it's worth having a specialized |
| 299 // function. For instance, The third parameter of | 308 // function. For instance, The third parameter of |
| 300 // "org.freedesktop.DBus.Properties.Set" is a variant. | 309 // "org.freedesktop.DBus.Properties.Set" is a variant. |
| 301 void AppendVariantOfByte(uint8 value); | 310 void AppendVariantOfByte(uint8 value); |
| 302 void AppendVariantOfBool(bool value); | 311 void AppendVariantOfBool(bool value); |
| 303 void AppendVariantOfInt16(int16 value); | 312 void AppendVariantOfInt16(int16 value); |
| 304 void AppendVariantOfUint16(uint16 value); | 313 void AppendVariantOfUint16(uint16 value); |
| 305 void AppendVariantOfInt32(int32 value); | 314 void AppendVariantOfInt32(int32 value); |
| 306 void AppendVariantOfUint32(uint32 value); | 315 void AppendVariantOfUint32(uint32 value); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 bool PopArrayOfStrings(std::vector<std::string>* strings); | 394 bool PopArrayOfStrings(std::vector<std::string>* strings); |
| 386 | 395 |
| 387 // Gets the array of object paths at the current iterator position. | 396 // Gets the array of object paths at the current iterator position. |
| 388 // Returns true and advances the iterator on success. | 397 // Returns true and advances the iterator on success. |
| 389 // | 398 // |
| 390 // Arrays of object paths are often used to communicate with D-Bus | 399 // Arrays of object paths are often used to communicate with D-Bus |
| 391 // services like NetworkManager, hence it's worth having a specialized | 400 // services like NetworkManager, hence it's worth having a specialized |
| 392 // function. | 401 // function. |
| 393 bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths); | 402 bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths); |
| 394 | 403 |
| 404 // Gets the array of bytes at the current iterator position. It then parses | |
| 405 // this binary blob into the protocol buffer supplied. | |
| 406 // Returns true and advances the iterator on success. On failure returns false | |
| 407 // and emits an error message on the source of the failure. The two most | |
| 408 // common errors come from the iterator not currently being at a byte array or | |
| 409 // the wrong type of protocol buffer is passed in and the parse fails. | |
| 410 bool PopProtocolBuffer(google::protobuf::MessageLite* protobuf); | |
|
satorux1
2012/01/31 21:42:31
PopArrayOfBytesAsProto() ?
rharrison
2012/02/01 19:03:20
Done.
| |
| 411 | |
| 395 // Gets the byte from the variant data container at the current iterator | 412 // Gets the byte from the variant data container at the current iterator |
| 396 // position. | 413 // position. |
| 397 // Returns true and advances the iterator on success. | 414 // Returns true and advances the iterator on success. |
| 398 // | 415 // |
| 399 // Variants are widely used in D-Bus services so it's worth having a | 416 // Variants are widely used in D-Bus services so it's worth having a |
| 400 // specialized function. For instance, The return value type of | 417 // specialized function. For instance, The return value type of |
| 401 // "org.freedesktop.DBus.Properties.Get" is a variant. | 418 // "org.freedesktop.DBus.Properties.Get" is a variant. |
| 402 bool PopVariantOfByte(uint8* value); | 419 bool PopVariantOfByte(uint8* value); |
| 403 bool PopVariantOfBool(bool* value); | 420 bool PopVariantOfBool(bool* value); |
| 404 bool PopVariantOfInt16(int16* value); | 421 bool PopVariantOfInt16(int16* value); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 432 | 449 |
| 433 Message* message_; | 450 Message* message_; |
| 434 DBusMessageIter raw_message_iter_; | 451 DBusMessageIter raw_message_iter_; |
| 435 | 452 |
| 436 DISALLOW_COPY_AND_ASSIGN(MessageReader); | 453 DISALLOW_COPY_AND_ASSIGN(MessageReader); |
| 437 }; | 454 }; |
| 438 | 455 |
| 439 } // namespace dbus | 456 } // namespace dbus |
| 440 | 457 |
| 441 #endif // DBUS_MESSAGE_H_ | 458 #endif // DBUS_MESSAGE_H_ |
| OLD | NEW |