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 // Client code to talk to the Media Transfer Protocol daemon. The MTP daemon is | 5 // Client code to talk to the Media Transfer Protocol daemon. The MTP daemon is |
6 // responsible for communicating with PTP / MTP capable devices like cameras | 6 // responsible for communicating with PTP / MTP capable devices like cameras |
7 // and smartphones. | 7 // and smartphones. |
8 | 8 |
9 #ifndef CHROMEOS_DBUS_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ | 9 #ifndef CHROMEOS_DBUS_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ |
10 #define CHROMEOS_DBUS_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ | 10 #define CHROMEOS_DBUS_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // A callback to handle the result of ReadDirectoryByPath/Id. | 189 // A callback to handle the result of ReadDirectoryByPath/Id. |
190 // The argument is a vector of file entries. | 190 // The argument is a vector of file entries. |
191 typedef base::Callback<void(const std::vector<FileEntry>& file_entries) | 191 typedef base::Callback<void(const std::vector<FileEntry>& file_entries) |
192 > ReadDirectoryCallback; | 192 > ReadDirectoryCallback; |
193 | 193 |
194 // A callback to handle the result of ReadFileByPath/Id. | 194 // A callback to handle the result of ReadFileByPath/Id. |
195 // The argument is a string containing the file data. | 195 // The argument is a string containing the file data. |
196 // TODO(thestig) Consider using a file descriptor instead of the data. | 196 // TODO(thestig) Consider using a file descriptor instead of the data. |
197 typedef base::Callback<void(const std::string& data)> ReadFileCallback; | 197 typedef base::Callback<void(const std::string& data)> ReadFileCallback; |
198 | 198 |
| 199 // A callback to handle the result of GetFileInfoByPath/Id. |
| 200 // The argument is a file entry. |
| 201 typedef base::Callback<void(const FileEntry& file_entry) |
| 202 > GetFileInfoCallback; |
| 203 |
199 // A callback to handle storage attach/detach events. | 204 // A callback to handle storage attach/detach events. |
200 // The first argument is true for attach, false for detach. | 205 // The first argument is true for attach, false for detach. |
201 // The second argument is the storage name. | 206 // The second argument is the storage name. |
202 typedef base::Callback<void(bool is_attach, | 207 typedef base::Callback<void(bool is_attach, |
203 const std::string& storage_name) | 208 const std::string& storage_name) |
204 > MTPStorageEventHandler; | 209 > MTPStorageEventHandler; |
205 | 210 |
206 virtual ~MediaTransferProtocolDaemonClient(); | 211 virtual ~MediaTransferProtocolDaemonClient(); |
207 | 212 |
208 // Calls EnumerateStorage method. |callback| is called after the | 213 // Calls EnumerateStorage method. |callback| is called after the |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 const ErrorCallback& error_callback) = 0; | 260 const ErrorCallback& error_callback) = 0; |
256 | 261 |
257 // Calls ReadFileById method. |callback| is called after the method call | 262 // Calls ReadFileById method. |callback| is called after the method call |
258 // succeeds, otherwise, |error_callback| is called. | 263 // succeeds, otherwise, |error_callback| is called. |
259 // |file_id| is a MTP-device specific id for a file. | 264 // |file_id| is a MTP-device specific id for a file. |
260 virtual void ReadFileById(const std::string& handle, | 265 virtual void ReadFileById(const std::string& handle, |
261 uint32 file_id, | 266 uint32 file_id, |
262 const ReadFileCallback& callback, | 267 const ReadFileCallback& callback, |
263 const ErrorCallback& error_callback) = 0; | 268 const ErrorCallback& error_callback) = 0; |
264 | 269 |
| 270 // Calls GetFileInfoByPath method. |callback| is called after the method |
| 271 // call succeeds, otherwise, |error_callback| is called. |
| 272 virtual void GetFileInfoByPath(const std::string& handle, |
| 273 const std::string& path, |
| 274 const GetFileInfoCallback& callback, |
| 275 const ErrorCallback& error_callback) = 0; |
| 276 |
| 277 // Calls GetFileInfoById method. |callback| is called after the method |
| 278 // call succeeds, otherwise, |error_callback| is called. |
| 279 // |file_id| is a MTP-device specific id for a file. |
| 280 virtual void GetFileInfoById(const std::string& handle, |
| 281 uint32 file_id, |
| 282 const GetFileInfoCallback& callback, |
| 283 const ErrorCallback& error_callback) = 0; |
| 284 |
265 // Registers given callback for events. | 285 // Registers given callback for events. |
266 // |storage_event_handler| is called when a mtp storage attach or detach | 286 // |storage_event_handler| is called when a mtp storage attach or detach |
267 // signal is received. | 287 // signal is received. |
268 virtual void SetUpConnections(const MTPStorageEventHandler& handler) = 0; | 288 virtual void SetUpConnections(const MTPStorageEventHandler& handler) = 0; |
269 | 289 |
270 // Factory function, creates a new instance and returns ownership. | 290 // Factory function, creates a new instance and returns ownership. |
271 // For normal usage, access the singleton via DBusThreadManager::Get(). | 291 // For normal usage, access the singleton via DBusThreadManager::Get(). |
272 static MediaTransferProtocolDaemonClient* | 292 static MediaTransferProtocolDaemonClient* |
273 Create(DBusClientImplementationType type, dbus::Bus* bus); | 293 Create(DBusClientImplementationType type, dbus::Bus* bus); |
274 | 294 |
275 protected: | 295 protected: |
276 // Create() should be used instead. | 296 // Create() should be used instead. |
277 MediaTransferProtocolDaemonClient(); | 297 MediaTransferProtocolDaemonClient(); |
278 | 298 |
279 private: | 299 private: |
280 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDaemonClient); | 300 DISALLOW_COPY_AND_ASSIGN(MediaTransferProtocolDaemonClient); |
281 }; | 301 }; |
282 | 302 |
283 } // namespace chromeos | 303 } // namespace chromeos |
284 | 304 |
285 #endif // CHROMEOS_DBUS_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ | 305 #endif // CHROMEOS_DBUS_MEDIA_TRANSFER_PROTOCOL_DAEMON_CLIENT_H_ |
OLD | NEW |