Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: dbus/message.h

Issue 9363045: Revert 121920 - dbus: add ObjectPath type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dbus/exported_object.cc ('k') | dbus/message.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/object_path.h"
15 14
16 namespace google { 15 namespace google {
17 namespace protobuf { 16 namespace protobuf {
18 17
19 class MessageLite; 18 class MessageLite;
20 19
21 } // namespace protobuf 20 } // namespace protobuf
22 } // namespace google 21 } // namespace google
23 22
24 23
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 MessageType GetMessageType(); 73 MessageType GetMessageType();
75 74
76 // Returns the type of the message as string like "MESSAGE_METHOD_CALL" 75 // Returns the type of the message as string like "MESSAGE_METHOD_CALL"
77 // for instance. 76 // for instance.
78 std::string GetMessageTypeAsString(); 77 std::string GetMessageTypeAsString();
79 78
80 DBusMessage* raw_message() { return raw_message_; } 79 DBusMessage* raw_message() { return raw_message_; }
81 80
82 // Sets the destination, the path, the interface, the member, etc. 81 // Sets the destination, the path, the interface, the member, etc.
83 void SetDestination(const std::string& destination); 82 void SetDestination(const std::string& destination);
84 void SetPath(const ObjectPath& path); 83 void SetPath(const std::string& path);
85 void SetInterface(const std::string& interface); 84 void SetInterface(const std::string& interface);
86 void SetMember(const std::string& member); 85 void SetMember(const std::string& member);
87 void SetErrorName(const std::string& error_name); 86 void SetErrorName(const std::string& error_name);
88 void SetSender(const std::string& sender); 87 void SetSender(const std::string& sender);
89 void SetSerial(uint32 serial); 88 void SetSerial(uint32 serial);
90 void SetReplySerial(uint32 reply_serial); 89 void SetReplySerial(uint32 reply_serial);
91 // SetSignature() does not exist as we cannot do it. 90 // SetSignature() does not exist as we cannot do it.
92 91
93 // Gets the destination, the path, the interface, the member, etc. 92 // Gets the destination, the path, the interface, the member, etc.
94 // If not set, an empty string is returned. 93 // If not set, an empty string is returned.
95 std::string GetDestination(); 94 std::string GetDestination();
96 ObjectPath GetPath(); 95 std::string GetPath();
97 std::string GetInterface(); 96 std::string GetInterface();
98 std::string GetMember(); 97 std::string GetMember();
99 std::string GetErrorName(); 98 std::string GetErrorName();
100 std::string GetSender(); 99 std::string GetSender();
101 std::string GetSignature(); 100 std::string GetSignature();
102 // Gets the serial and reply serial numbers. Returns 0 if not set. 101 // Gets the serial and reply serial numbers. Returns 0 if not set.
103 uint32 GetSerial(); 102 uint32 GetSerial();
104 uint32 GetReplySerial(); 103 uint32 GetReplySerial();
105 104
106 // Returns the string representation of this message. Useful for 105 // Returns the string representation of this message. Useful for
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void AppendByte(uint8 value); 258 void AppendByte(uint8 value);
260 void AppendBool(bool value); 259 void AppendBool(bool value);
261 void AppendInt16(int16 value); 260 void AppendInt16(int16 value);
262 void AppendUint16(uint16 value); 261 void AppendUint16(uint16 value);
263 void AppendInt32(int32 value); 262 void AppendInt32(int32 value);
264 void AppendUint32(uint32 value); 263 void AppendUint32(uint32 value);
265 void AppendInt64(int64 value); 264 void AppendInt64(int64 value);
266 void AppendUint64(uint64 value); 265 void AppendUint64(uint64 value);
267 void AppendDouble(double value); 266 void AppendDouble(double value);
268 void AppendString(const std::string& value); 267 void AppendString(const std::string& value);
269 void AppendObjectPath(const ObjectPath& value); 268 void AppendObjectPath(const std::string& value);
270 269
271 // Opens an array. The array contents can be added to the array with 270 // Opens an array. The array contents can be added to the array with
272 // |sub_writer|. The client code must close the array with 271 // |sub_writer|. The client code must close the array with
273 // CloseContainer(), once all contents are added. 272 // CloseContainer(), once all contents are added.
274 // 273 //
275 // |signature| parameter is used to supply the D-Bus type signature of 274 // |signature| parameter is used to supply the D-Bus type signature of
276 // the array contents. For instance, if you want an array of strings, 275 // the array contents. For instance, if you want an array of strings,
277 // then you pass "s" as the signature. 276 // then you pass "s" as the signature.
278 // 277 //
279 // See the spec for details about the type signatures. 278 // See the spec for details about the type signatures.
(...skipping 16 matching lines...) Expand all
296 void AppendArrayOfBytes(const uint8* values, size_t length); 295 void AppendArrayOfBytes(const uint8* values, size_t length);
297 296
298 // Appends the array of strings. Arrays of strings are often used for 297 // Appends the array of strings. Arrays of strings are often used for
299 // exchanging lists of names hence it's worth having a specialized 298 // exchanging lists of names hence it's worth having a specialized
300 // function. 299 // function.
301 void AppendArrayOfStrings(const std::vector<std::string>& strings); 300 void AppendArrayOfStrings(const std::vector<std::string>& strings);
302 301
303 // Appends the array of object paths. Arrays of object paths are often 302 // Appends the array of object paths. Arrays of object paths are often
304 // used when exchanging object paths, hence it's worth having a 303 // used when exchanging object paths, hence it's worth having a
305 // specialized function. 304 // specialized function.
306 void AppendArrayOfObjectPaths(const std::vector<ObjectPath>& object_paths); 305 void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths);
307 306
308 // Appends the protocol buffer as an array of bytes. The buffer is serialized 307 // Appends the protocol buffer as an array of bytes. The buffer is serialized
309 // into an array of bytes before communication, since protocol buffers are not 308 // into an array of bytes before communication, since protocol buffers are not
310 // a native dbus type. On the receiving size the array of bytes needs to be 309 // a native dbus type. On the receiving size the array of bytes needs to be
311 // read and deserialized into a protocol buffer of the correct type. There are 310 // read and deserialized into a protocol buffer of the correct type. There are
312 // methods in MessageReader to assist in this. Return true on succes and fail 311 // methods in MessageReader to assist in this. Return true on succes and fail
313 // when serialization is not successful. 312 // when serialization is not successful.
314 bool AppendProtoAsArrayOfBytes(const google::protobuf::MessageLite& protobuf); 313 bool AppendProtoAsArrayOfBytes(const google::protobuf::MessageLite& protobuf);
315 314
316 // Appends the byte wrapped in a variant data container. Variants are 315 // Appends the byte wrapped in a variant data container. Variants are
317 // widely used in D-Bus services so it's worth having a specialized 316 // widely used in D-Bus services so it's worth having a specialized
318 // function. For instance, The third parameter of 317 // function. For instance, The third parameter of
319 // "org.freedesktop.DBus.Properties.Set" is a variant. 318 // "org.freedesktop.DBus.Properties.Set" is a variant.
320 void AppendVariantOfByte(uint8 value); 319 void AppendVariantOfByte(uint8 value);
321 void AppendVariantOfBool(bool value); 320 void AppendVariantOfBool(bool value);
322 void AppendVariantOfInt16(int16 value); 321 void AppendVariantOfInt16(int16 value);
323 void AppendVariantOfUint16(uint16 value); 322 void AppendVariantOfUint16(uint16 value);
324 void AppendVariantOfInt32(int32 value); 323 void AppendVariantOfInt32(int32 value);
325 void AppendVariantOfUint32(uint32 value); 324 void AppendVariantOfUint32(uint32 value);
326 void AppendVariantOfInt64(int64 value); 325 void AppendVariantOfInt64(int64 value);
327 void AppendVariantOfUint64(uint64 value); 326 void AppendVariantOfUint64(uint64 value);
328 void AppendVariantOfDouble(double value); 327 void AppendVariantOfDouble(double value);
329 void AppendVariantOfString(const std::string& value); 328 void AppendVariantOfString(const std::string& value);
330 void AppendVariantOfObjectPath(const ObjectPath& value); 329 void AppendVariantOfObjectPath(const std::string& value);
331 330
332 private: 331 private:
333 // Helper function used to implement AppendByte etc. 332 // Helper function used to implement AppendByte etc.
334 void AppendBasic(int dbus_type, const void* value); 333 void AppendBasic(int dbus_type, const void* value);
335 334
336 // Helper function used to implement AppendVariantOfByte() etc. 335 // Helper function used to implement AppendVariantOfByte() etc.
337 void AppendVariantOfBasic(int dbus_type, const void* value); 336 void AppendVariantOfBasic(int dbus_type, const void* value);
338 337
339 Message* message_; 338 Message* message_;
340 DBusMessageIter raw_message_iter_; 339 DBusMessageIter raw_message_iter_;
(...skipping 27 matching lines...) Expand all
368 bool PopByte(uint8* value); 367 bool PopByte(uint8* value);
369 bool PopBool(bool* value); 368 bool PopBool(bool* value);
370 bool PopInt16(int16* value); 369 bool PopInt16(int16* value);
371 bool PopUint16(uint16* value); 370 bool PopUint16(uint16* value);
372 bool PopInt32(int32* value); 371 bool PopInt32(int32* value);
373 bool PopUint32(uint32* value); 372 bool PopUint32(uint32* value);
374 bool PopInt64(int64* value); 373 bool PopInt64(int64* value);
375 bool PopUint64(uint64* value); 374 bool PopUint64(uint64* value);
376 bool PopDouble(double* value); 375 bool PopDouble(double* value);
377 bool PopString(std::string* value); 376 bool PopString(std::string* value);
378 bool PopObjectPath(ObjectPath* value); 377 bool PopObjectPath(std::string* value);
379 378
380 // Sets up the given message reader to read an array at the current 379 // Sets up the given message reader to read an array at the current
381 // iterator position. 380 // iterator position.
382 // Returns true and advances the iterator on success. 381 // Returns true and advances the iterator on success.
383 // Returns false if the data type is not an array 382 // Returns false if the data type is not an array
384 bool PopArray(MessageReader* sub_reader); 383 bool PopArray(MessageReader* sub_reader);
385 bool PopStruct(MessageReader* sub_reader); 384 bool PopStruct(MessageReader* sub_reader);
386 bool PopDictEntry(MessageReader* sub_reader); 385 bool PopDictEntry(MessageReader* sub_reader);
387 bool PopVariant(MessageReader* sub_reader); 386 bool PopVariant(MessageReader* sub_reader);
388 387
(...skipping 14 matching lines...) Expand all
403 // services like KWallet, hence it's worth having a specialized 402 // services like KWallet, hence it's worth having a specialized
404 // function. 403 // function.
405 bool PopArrayOfStrings(std::vector<std::string>* strings); 404 bool PopArrayOfStrings(std::vector<std::string>* strings);
406 405
407 // Gets the array of object paths at the current iterator position. 406 // Gets the array of object paths at the current iterator position.
408 // Returns true and advances the iterator on success. 407 // Returns true and advances the iterator on success.
409 // 408 //
410 // Arrays of object paths are often used to communicate with D-Bus 409 // Arrays of object paths are often used to communicate with D-Bus
411 // services like NetworkManager, hence it's worth having a specialized 410 // services like NetworkManager, hence it's worth having a specialized
412 // function. 411 // function.
413 bool PopArrayOfObjectPaths(std::vector<ObjectPath>* object_paths); 412 bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths);
414 413
415 // Gets the array of bytes at the current iterator position. It then parses 414 // Gets the array of bytes at the current iterator position. It then parses
416 // this binary blob into the protocol buffer supplied. 415 // this binary blob into the protocol buffer supplied.
417 // Returns true and advances the iterator on success. On failure returns false 416 // Returns true and advances the iterator on success. On failure returns false
418 // and emits an error message on the source of the failure. The two most 417 // and emits an error message on the source of the failure. The two most
419 // common errors come from the iterator not currently being at a byte array or 418 // common errors come from the iterator not currently being at a byte array or
420 // the wrong type of protocol buffer is passed in and the parse fails. 419 // the wrong type of protocol buffer is passed in and the parse fails.
421 bool PopArrayOfBytesAsProto(google::protobuf::MessageLite* protobuf); 420 bool PopArrayOfBytesAsProto(google::protobuf::MessageLite* protobuf);
422 421
423 // Gets the byte from the variant data container at the current iterator 422 // Gets the byte from the variant data container at the current iterator
424 // position. 423 // position.
425 // Returns true and advances the iterator on success. 424 // Returns true and advances the iterator on success.
426 // 425 //
427 // Variants are widely used in D-Bus services so it's worth having a 426 // Variants are widely used in D-Bus services so it's worth having a
428 // specialized function. For instance, The return value type of 427 // specialized function. For instance, The return value type of
429 // "org.freedesktop.DBus.Properties.Get" is a variant. 428 // "org.freedesktop.DBus.Properties.Get" is a variant.
430 bool PopVariantOfByte(uint8* value); 429 bool PopVariantOfByte(uint8* value);
431 bool PopVariantOfBool(bool* value); 430 bool PopVariantOfBool(bool* value);
432 bool PopVariantOfInt16(int16* value); 431 bool PopVariantOfInt16(int16* value);
433 bool PopVariantOfUint16(uint16* value); 432 bool PopVariantOfUint16(uint16* value);
434 bool PopVariantOfInt32(int32* value); 433 bool PopVariantOfInt32(int32* value);
435 bool PopVariantOfUint32(uint32* value); 434 bool PopVariantOfUint32(uint32* value);
436 bool PopVariantOfInt64(int64* value); 435 bool PopVariantOfInt64(int64* value);
437 bool PopVariantOfUint64(uint64* value); 436 bool PopVariantOfUint64(uint64* value);
438 bool PopVariantOfDouble(double* value); 437 bool PopVariantOfDouble(double* value);
439 bool PopVariantOfString(std::string* value); 438 bool PopVariantOfString(std::string* value);
440 bool PopVariantOfObjectPath(ObjectPath* value); 439 bool PopVariantOfObjectPath(std::string* value);
441 440
442 // Get the data type of the value at the current iterator 441 // Get the data type of the value at the current iterator
443 // position. INVALID_DATA will be returned if the iterator points to the 442 // position. INVALID_DATA will be returned if the iterator points to the
444 // end of the message. 443 // end of the message.
445 Message::DataType GetDataType(); 444 Message::DataType GetDataType();
446 445
447 private: 446 private:
448 // Returns true if the data type at the current iterator position 447 // Returns true if the data type at the current iterator position
449 // matches the given D-Bus type, such as DBUS_TYPE_BYTE. 448 // matches the given D-Bus type, such as DBUS_TYPE_BYTE.
450 bool CheckDataType(int dbus_type); 449 bool CheckDataType(int dbus_type);
451 450
452 // Helper function used to implement PopByte() etc. 451 // Helper function used to implement PopByte() etc.
453 bool PopBasic(int dbus_type, void *value); 452 bool PopBasic(int dbus_type, void *value);
454 453
455 // Helper function used to implement PopArray() etc. 454 // Helper function used to implement PopArray() etc.
456 bool PopContainer(int dbus_type, MessageReader* sub_reader); 455 bool PopContainer(int dbus_type, MessageReader* sub_reader);
457 456
458 // Helper function used to implement PopVariantOfByte() etc. 457 // Helper function used to implement PopVariantOfByte() etc.
459 bool PopVariantOfBasic(int dbus_type, void* value); 458 bool PopVariantOfBasic(int dbus_type, void* value);
460 459
461 Message* message_; 460 Message* message_;
462 DBusMessageIter raw_message_iter_; 461 DBusMessageIter raw_message_iter_;
463 462
464 DISALLOW_COPY_AND_ASSIGN(MessageReader); 463 DISALLOW_COPY_AND_ASSIGN(MessageReader);
465 }; 464 };
466 465
467 } // namespace dbus 466 } // namespace dbus
468 467
469 #endif // DBUS_MESSAGE_H_ 468 #endif // DBUS_MESSAGE_H_
OLDNEW
« no previous file with comments | « dbus/exported_object.cc ('k') | dbus/message.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698