blob: ee2e415043368a539e3cbd05849afe86468fdf23 [file] [log] [blame]
// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "disk.h"
namespace cros_disks {
// Keys that libcros expects to see on the wire.
// TODO(rtc): We should probably stuff these in a shared header...
const char kDeviceIsDrive[] = "DeviceIsDrive";
const char kDevicePresentationHide[] = "DevicePresentationHide";
const char kDeviceIsMounted[] = "DeviceIsMounted";
const char kDeviceMountPaths[] = "DeviceMountPaths";
const char kDeviceIsMediaAvailable[] = "DeviceIsMediaAvailable";
const char kDeviceIsOnBootDevice[] = "DeviceIsOnBootDevice";
const char kDeviceIsVirtual[] = "DeviceIsVirtual";
const char kNativePath[] = "NativePath";
const char kDeviceFile[] = "DeviceFile";
const char kUuid[] = "IdUuid";
const char kLabel[] = "IdLabel";
const char kDriveModel[] = "DriveModel";
const char kDriveIsRotational[] = "DriveIsRotational";
const char kDeviceIsOpticalDisc[] = "DeviceIsOpticalDisc";
const char kDeviceSize[] = "DeviceSize";
const char kReadOnly[] = "DeviceIsReadOnly";
// TODO(rtc): Figure out what this field is and include it in the response.
const char kPartitionSlave[] = "PartitionSlave";
Disk::Disk()
: is_drive_(false),
is_hidden_(false),
is_mounted_(false),
is_media_available_(false),
is_on_boot_device_(true),
is_rotational_(false),
is_optical_disk_(false),
is_read_only_(false),
is_virtual_(true),
mount_paths_(),
native_path_(),
device_file_(),
uuid_(),
label_(),
drive_model_(),
device_capacity_(0),
bytes_remaining_(0) {
}
Disk::~Disk() {
}
DBusDisk Disk::ToDBusFormat() const {
DBusDisk disk;
disk[kDeviceIsDrive].writer().append_bool(is_drive());
disk[kDevicePresentationHide].writer().append_bool(is_hidden());
disk[kDeviceIsMounted].writer().append_bool(is_mounted());
disk[kDeviceIsMediaAvailable].writer().append_bool(is_media_available());
disk[kDeviceIsOnBootDevice].writer().append_bool(is_on_boot_device());
disk[kDeviceIsVirtual].writer().append_bool(is_virtual());
disk[kNativePath].writer().append_string(native_path().c_str());
disk[kDeviceFile].writer().append_string(device_file().c_str());
disk[kUuid].writer().append_string(uuid().c_str());
disk[kLabel].writer().append_string(label().c_str());
disk[kDriveModel].writer().append_string(drive_model().c_str());
disk[kDriveIsRotational].writer().append_bool(is_rotational());
disk[kDeviceIsOpticalDisc].writer().append_bool(is_optical_disk());
disk[kDeviceSize].writer().append_uint64(device_capacity());
disk[kReadOnly].writer().append_bool(is_read_only());
DBus::MessageIter iter = disk[kDeviceMountPaths].writer();
iter << mount_paths();
return disk;
}
} // namespace cros_disks