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 #include "dbus/message.h" | 5 #include "dbus/message.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 // Generate headers first. | 256 // Generate headers first. |
257 std::string headers; | 257 std::string headers; |
258 AppendStringHeader("message_type", GetMessageTypeAsString(), &headers); | 258 AppendStringHeader("message_type", GetMessageTypeAsString(), &headers); |
259 AppendStringHeader("destination", GetDestination(), &headers); | 259 AppendStringHeader("destination", GetDestination(), &headers); |
260 AppendStringHeader("path", GetPath().value(), &headers); | 260 AppendStringHeader("path", GetPath().value(), &headers); |
261 AppendStringHeader("interface", GetInterface(), &headers); | 261 AppendStringHeader("interface", GetInterface(), &headers); |
262 AppendStringHeader("member", GetMember(), &headers); | 262 AppendStringHeader("member", GetMember(), &headers); |
263 AppendStringHeader("error_name", GetErrorName(), &headers); | 263 AppendStringHeader("error_name", GetErrorName(), &headers); |
264 AppendStringHeader("sender", GetSender(), &headers); | 264 AppendStringHeader("sender", GetSender(), &headers); |
265 AppendStringHeader("signature", GetDataSignature(), &headers); | 265 AppendStringHeader("signature", GetSignature(), &headers); |
266 AppendUint32Header("serial", GetSerial(), &headers); | 266 AppendUint32Header("serial", GetSerial(), &headers); |
267 AppendUint32Header("reply_serial", GetReplySerial(), &headers); | 267 AppendUint32Header("reply_serial", GetReplySerial(), &headers); |
268 | 268 |
269 // Generate the payload. | 269 // Generate the payload. |
270 MessageReader reader(this); | 270 MessageReader reader(this); |
271 return headers + "\n" + ToStringInternal(std::string(), &reader); | 271 return headers + "\n" + ToStringInternal(std::string(), &reader); |
272 } | 272 } |
273 | 273 |
274 bool Message::SetDestination(const std::string& destination) { | 274 bool Message::SetDestination(const std::string& destination) { |
275 return dbus_message_set_destination(raw_message_, destination.c_str()); | 275 return dbus_message_set_destination(raw_message_, destination.c_str()); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 std::string Message::GetErrorName() { | 326 std::string Message::GetErrorName() { |
327 const char* error_name = dbus_message_get_error_name(raw_message_); | 327 const char* error_name = dbus_message_get_error_name(raw_message_); |
328 return error_name ? error_name : ""; | 328 return error_name ? error_name : ""; |
329 } | 329 } |
330 | 330 |
331 std::string Message::GetSender() { | 331 std::string Message::GetSender() { |
332 const char* sender = dbus_message_get_sender(raw_message_); | 332 const char* sender = dbus_message_get_sender(raw_message_); |
333 return sender ? sender : ""; | 333 return sender ? sender : ""; |
334 } | 334 } |
335 | 335 |
336 std::string Message::GetDataSignature() { | 336 std::string Message::GetSignature() { |
337 const char* signature = dbus_message_get_signature(raw_message_); | 337 const char* signature = dbus_message_get_signature(raw_message_); |
338 return signature ? signature : ""; | 338 return signature ? signature : ""; |
339 } | 339 } |
340 | 340 |
341 uint32 Message::GetSerial() { | 341 uint32 Message::GetSerial() { |
342 return dbus_message_get_serial(raw_message_); | 342 return dbus_message_get_serial(raw_message_); |
343 } | 343 } |
344 | 344 |
345 uint32 Message::GetReplySerial() { | 345 uint32 Message::GetReplySerial() { |
346 return dbus_message_get_reply_serial(raw_message_); | 346 return dbus_message_get_reply_serial(raw_message_); |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); | 992 const bool success = PopBasic(DBUS_TYPE_UNIX_FD, &fd); |
993 if (!success) | 993 if (!success) |
994 return false; | 994 return false; |
995 | 995 |
996 value->PutValue(fd); | 996 value->PutValue(fd); |
997 // NB: the caller must check validity before using the value | 997 // NB: the caller must check validity before using the value |
998 return true; | 998 return true; |
999 } | 999 } |
1000 | 1000 |
1001 } // namespace dbus | 1001 } // namespace dbus |
OLD | NEW |