Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS 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 | #ifndef MTPD_FILE_ENTRY_H_ |
| 6 | #define MTPD_FILE_ENTRY_H_ |
| 7 | |
| 8 | #include <libmtp.h> |
| 9 | |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
Alex Vakulenko | f695ea0 | 2016-01-22 19:20:14 -0800 | [diff] [blame] | 13 | #include <base/macros.h> |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 14 | |
Eric Caruso | 0076fa7 | 2017-08-21 15:31:19 -0700 | [diff] [blame] | 15 | #include "system_api/proto_bindings/mtp_file_entry.pb.h" |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 16 | |
Lei Zhang | fa9e19a | 2012-08-31 14:36:59 -0700 | [diff] [blame] | 17 | namespace mtpd { |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 18 | |
| 19 | class FileEntry { |
| 20 | public: |
| 21 | explicit FileEntry(const LIBMTP_file_struct& file); |
Lei Zhang | fa9e19a | 2012-08-31 14:36:59 -0700 | [diff] [blame] | 22 | FileEntry(); |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 23 | ~FileEntry(); |
| 24 | |
Lei Zhang | fa9e19a | 2012-08-31 14:36:59 -0700 | [diff] [blame] | 25 | MtpFileEntry ToProtobuf() const; |
Lei Zhang | 6cd0bfc | 2012-09-06 20:18:26 -0700 | [diff] [blame] | 26 | std::vector<uint8_t> ToDBusFormat() const; |
Lei Zhang | fa9e19a | 2012-08-31 14:36:59 -0700 | [diff] [blame] | 27 | |
Lei Zhang | 6cd0bfc | 2012-09-06 20:18:26 -0700 | [diff] [blame] | 28 | static std::vector<uint8_t> EmptyFileEntriesToDBusFormat(); |
| 29 | static std::vector<uint8_t> FileEntriesToDBusFormat( |
Ben Chan | 81757a0 | 2018-01-23 14:06:08 -0800 | [diff] [blame] | 30 | const std::vector<FileEntry>& entries); |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 31 | |
Lei Zhang | 12f55c2 | 2012-09-05 14:54:48 -0700 | [diff] [blame] | 32 | uint32_t item_id() const { return item_id_; } |
| 33 | uint32_t parent_id() const { return parent_id_; } |
| 34 | const std::string& file_name() const { return file_name_; } |
| 35 | uint64_t file_size() const { return file_size_; } |
| 36 | time_t modification_time() const { return modification_time_; } |
| 37 | LIBMTP_filetype_t file_type() const { return file_type_; } |
| 38 | |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 39 | private: |
| 40 | uint32_t item_id_; |
| 41 | uint32_t parent_id_; |
| 42 | std::string file_name_; |
| 43 | uint64_t file_size_; |
Lei Zhang | fa9e19a | 2012-08-31 14:36:59 -0700 | [diff] [blame] | 44 | time_t modification_time_; |
Lei Zhang | 91af91d | 2012-08-03 11:02:20 -0700 | [diff] [blame] | 45 | LIBMTP_filetype_t file_type_; |
| 46 | }; |
| 47 | |
| 48 | } // namespace mtpd |
| 49 | |
| 50 | #endif // MTPD_FILE_ENTRY_H_ |