bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to C++ |
| 17 | */ |
| 18 | |
| 19 | #ifndef MTP_MTPSERVER_HPP |
| 20 | #define MTP_MTPSERVER_HPP |
| 21 | #include <utils/Log.h> |
| 22 | |
| 23 | #include <string> |
| 24 | #include <stdio.h> |
| 25 | #include <assert.h> |
| 26 | #include <limits.h> |
| 27 | #include <unistd.h> |
| 28 | #include <fcntl.h> |
| 29 | #include <utils/threads.h> |
| 30 | |
| 31 | #include "MtpServer.h" |
| 32 | #include "MtpStorage.h" |
| 33 | #include "mtp_MtpDatabase.hpp" |
| 34 | |
| 35 | typedef struct Storage { |
| 36 | std::string display; |
| 37 | std::string mount; |
| 38 | int mtpid; |
bigbiff | 7cb4c33 | 2014-11-26 20:36:07 -0500 | [diff] [blame] | 39 | uint64_t maxFileSize; |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 40 | } storage; |
| 41 | |
| 42 | typedef std::vector<storage*> storages; |
| 43 | |
bigbiff bigbiff | af32bb9 | 2018-12-18 18:39:53 -0500 | [diff] [blame] | 44 | struct mtp_info { |
| 45 | MtpStringBuffer deviceInfoManufacturer; |
| 46 | MtpStringBuffer deviceInfoModel; |
| 47 | MtpStringBuffer deviceInfoDeviceVersion; |
| 48 | MtpStringBuffer deviceInfoSerialNumber; |
| 49 | }; |
| 50 | |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 51 | class twmtp_MtpServer { |
| 52 | public: |
| 53 | void start(); |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 54 | void cleanup(); |
| 55 | void send_object_added(int handle); |
| 56 | void send_object_removed(int handle); |
| 57 | void add_storage(); |
| 58 | void remove_storage(int storageId); |
| 59 | void set_storages(storages* mtpstorages); |
Ethan Yonker | 726a020 | 2014-12-16 20:01:38 -0600 | [diff] [blame] | 60 | void set_read_pipe(int pipe); |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 61 | storages *stores; |
bigbiff bigbiff | af32bb9 | 2018-12-18 18:39:53 -0500 | [diff] [blame] | 62 | struct mtp_info mtpinfo; |
| 63 | void set_device_info(); |
| 64 | |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 65 | private: |
Ethan Yonker | 726a020 | 2014-12-16 20:01:38 -0600 | [diff] [blame] | 66 | typedef int (twmtp_MtpServer::*ThreadPtr)(void); |
| 67 | typedef void* (*PThreadPtr)(void *); |
| 68 | int mtppipe_thread(void); |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 69 | bool usePtp; |
| 70 | MtpServer* server; |
| 71 | MtpServer* refserver; |
Ethan Yonker | 726a020 | 2014-12-16 20:01:38 -0600 | [diff] [blame] | 72 | int mtp_read_pipe; |
bigbiff bigbiff | af32bb9 | 2018-12-18 18:39:53 -0500 | [diff] [blame] | 73 | MtpStringBuffer deviceInfoManufacturer; |
| 74 | MtpStringBuffer deviceInfoModel; |
| 75 | MtpStringBuffer deviceInfoDeviceVersion; |
| 76 | MtpStringBuffer deviceInfoSerialNumber; |
bigbiff bigbiff | c7eee6f | 2014-09-02 18:59:01 -0400 | [diff] [blame] | 77 | }; |
| 78 | #endif |