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

Side by Side Diff: dbus/message.h

Issue 9315006: Adding support for sending/receiving proto bufs to dbus library. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added in the DEPS file as suggested 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
OLDNEW
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 14
15 namespace google {
16 namespace protobuf {
17
18 class MessageLite;
19
20 } // namespace protobuf
21 } // namespace google
22
23
15 namespace dbus { 24 namespace dbus {
16 25
17 class MessageWriter; 26 class MessageWriter;
18 class MessageReader; 27 class MessageReader;
19 28
20 // Message is the base class of D-Bus message types. Client code must use 29 // Message is the base class of D-Bus message types. Client code must use
21 // sub classes such as MethodCall and Response instead. 30 // sub classes such as MethodCall and Response instead.
22 // 31 //
23 // The class name Message is very generic, but there should be no problem 32 // The class name Message is very generic, but there should be no problem
24 // as the class is inside 'dbus' namespace. We chose to name this way, as 33 // as the class is inside 'dbus' namespace. We chose to name this way, as
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // Appends the array of strings. Arrays of strings are often used for 296 // Appends the array of strings. Arrays of strings are often used for
288 // exchanging lists of names hence it's worth having a specialized 297 // exchanging lists of names hence it's worth having a specialized
289 // function. 298 // function.
290 void AppendArrayOfStrings(const std::vector<std::string>& strings); 299 void AppendArrayOfStrings(const std::vector<std::string>& strings);
291 300
292 // Appends the array of object paths. Arrays of object paths are often 301 // Appends the array of object paths. Arrays of object paths are often
293 // used when exchanging object paths, hence it's worth having a 302 // used when exchanging object paths, hence it's worth having a
294 // specialized function. 303 // specialized function.
295 void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths); 304 void AppendArrayOfObjectPaths(const std::vector<std::string>& object_paths);
296 305
306 // Appends the protocol buffer as an array of bytes. The buffer is serialized
307 // into an array of bytes before communication, since protocol buffers are not
308 // a native dbus type. On the receiving size the array of bytes needs to be
309 // read and deserialized into a protocol buffer of the correct type. There are
310 // methods in MessageReader to assist in this. Return true on succes and fail
311 // when serialization is not successful.
312 bool AppendProtoAsArrayOfBytes(const google::protobuf::MessageLite& protobuf);
313
297 // Appends the byte wrapped in a variant data container. Variants are 314 // 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 315 // widely used in D-Bus services so it's worth having a specialized
299 // function. For instance, The third parameter of 316 // function. For instance, The third parameter of
300 // "org.freedesktop.DBus.Properties.Set" is a variant. 317 // "org.freedesktop.DBus.Properties.Set" is a variant.
301 void AppendVariantOfByte(uint8 value); 318 void AppendVariantOfByte(uint8 value);
302 void AppendVariantOfBool(bool value); 319 void AppendVariantOfBool(bool value);
303 void AppendVariantOfInt16(int16 value); 320 void AppendVariantOfInt16(int16 value);
304 void AppendVariantOfUint16(uint16 value); 321 void AppendVariantOfUint16(uint16 value);
305 void AppendVariantOfInt32(int32 value); 322 void AppendVariantOfInt32(int32 value);
306 void AppendVariantOfUint32(uint32 value); 323 void AppendVariantOfUint32(uint32 value);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 bool PopArrayOfStrings(std::vector<std::string>* strings); 402 bool PopArrayOfStrings(std::vector<std::string>* strings);
386 403
387 // Gets the array of object paths at the current iterator position. 404 // Gets the array of object paths at the current iterator position.
388 // Returns true and advances the iterator on success. 405 // Returns true and advances the iterator on success.
389 // 406 //
390 // Arrays of object paths are often used to communicate with D-Bus 407 // Arrays of object paths are often used to communicate with D-Bus
391 // services like NetworkManager, hence it's worth having a specialized 408 // services like NetworkManager, hence it's worth having a specialized
392 // function. 409 // function.
393 bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths); 410 bool PopArrayOfObjectPaths(std::vector<std::string>* object_paths);
394 411
412 // Gets the array of bytes at the current iterator position. It then parses
413 // this binary blob into the protocol buffer supplied.
414 // Returns true and advances the iterator on success. On failure returns false
415 // and emits an error message on the source of the failure. The two most
416 // common errors come from the iterator not currently being at a byte array or
417 // the wrong type of protocol buffer is passed in and the parse fails.
418 bool PopArrayOfBytesAsProto(google::protobuf::MessageLite* protobuf);
419
395 // Gets the byte from the variant data container at the current iterator 420 // Gets the byte from the variant data container at the current iterator
396 // position. 421 // position.
397 // Returns true and advances the iterator on success. 422 // Returns true and advances the iterator on success.
398 // 423 //
399 // Variants are widely used in D-Bus services so it's worth having a 424 // Variants are widely used in D-Bus services so it's worth having a
400 // specialized function. For instance, The return value type of 425 // specialized function. For instance, The return value type of
401 // "org.freedesktop.DBus.Properties.Get" is a variant. 426 // "org.freedesktop.DBus.Properties.Get" is a variant.
402 bool PopVariantOfByte(uint8* value); 427 bool PopVariantOfByte(uint8* value);
403 bool PopVariantOfBool(bool* value); 428 bool PopVariantOfBool(bool* value);
404 bool PopVariantOfInt16(int16* value); 429 bool PopVariantOfInt16(int16* value);
(...skipping 27 matching lines...) Expand all
432 457
433 Message* message_; 458 Message* message_;
434 DBusMessageIter raw_message_iter_; 459 DBusMessageIter raw_message_iter_;
435 460
436 DISALLOW_COPY_AND_ASSIGN(MessageReader); 461 DISALLOW_COPY_AND_ASSIGN(MessageReader);
437 }; 462 };
438 463
439 } // namespace dbus 464 } // namespace dbus
440 465
441 #endif // DBUS_MESSAGE_H_ 466 #endif // DBUS_MESSAGE_H_
OLDNEW
« no previous file with comments | « dbus/dbus.gyp ('k') | dbus/message.cc » ('j') | dbus/test_proto.proto » ('J')

Powered by Google App Engine
This is Rietveld 408576698