Home | History | Annotate | Download | only in dbus
      1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chromeos/dbus/audio_node.h"
      6 
      7 #include "base/format_macros.h"
      8 #include "base/strings/string_number_conversions.h"
      9 #include "base/strings/stringprintf.h"
     10 
     11 namespace chromeos {
     12 
     13 AudioNode::AudioNode()
     14     : is_input(false),
     15       id(0),
     16       active(false),
     17       plugged_time(0) {
     18 }
     19 
     20 AudioNode::AudioNode(bool is_input,
     21                      uint64 id,
     22                      std::string device_name,
     23                      std::string type,
     24                      std::string name,
     25                      bool active,
     26                      uint64 plugged_time)
     27     : is_input(is_input),
     28       id(id),
     29       device_name(device_name),
     30       type(type),
     31       name(name),
     32       active(active),
     33       plugged_time(plugged_time) {
     34 }
     35 
     36 std::string AudioNode::ToString() const {
     37   std::string result;
     38   base::StringAppendF(&result,
     39                       "is_input = %s ",
     40                       is_input ? "true" : "false");
     41   base::StringAppendF(&result,
     42                       "id = 0x%" PRIx64 " ",
     43                       id);
     44   base::StringAppendF(&result,
     45                       "device_name = %s ",
     46                       device_name.c_str());
     47   base::StringAppendF(&result,
     48                       "type = %s ",
     49                       type.c_str());
     50   base::StringAppendF(&result,
     51                       "name = %s ",
     52                       name.c_str());
     53   base::StringAppendF(&result,
     54                       "active = %s ",
     55                       active ? "true" : "false");
     56   base::StringAppendF(&result,
     57                       "plugged_time= %s ",
     58                       base::Uint64ToString(plugged_time).c_str());
     59 
     60   return result;
     61 }
     62 
     63 }  // namespace chromeos
     64