├── _config.yml
├── qt
├── .gitignore
├── android-file-transfer.png
├── translations
│ └── translations.qrc.in
├── android-file-transfer.desktop
├── icons
│ ├── dark
│ │ ├── go-next.svg
│ │ ├── go-previous.svg
│ │ ├── folder-new.svg
│ │ └── view-refresh.svg
│ └── light
│ │ ├── go-next.svg
│ │ ├── go-previous.svg
│ │ ├── folder-new.svg
│ │ └── view-refresh.svg
├── android-file-transfer.qrc
├── utils.cpp
├── qtobjectstream.cpp
├── mtpmimedata.cpp
├── mtpmimedata.h
├── devicesdialog.h
├── android-file-transfer.appdata.xml
├── renamedialog.cpp
├── renamedialog.h
├── createdirectorydialog.cpp
├── utils.h
├── createdirectorydialog.h
├── Info.plist.in
├── mtpstoragesmodel.h
├── devicesdialog.ui
├── progressdialog.h
├── renamedialog.ui
├── createdirectorydialog.ui
├── fileuploader.h
├── mtpstoragesmodel.cpp
├── main.cpp
├── progressdialog.ui
└── qtobjectstream.h
├── python
├── example
│ ├── requirements.txt
│ └── menu.py
└── CMakeLists.txt
├── screenshot.png
├── cli
├── update.sh
├── Tokens.h
├── Command.cpp
├── arg_lexer.l
├── Tokenizer.h
├── CommandLineStub.cpp
├── CommandLine.h
├── Tokenizer.cpp
└── CommandLine.cpp
├── .gitignore
├── osx
├── android-file-transfer.icns
├── android-file-transfer.png
└── icns.sh
├── mtp
├── version.cpp.in
├── ptp
│ ├── PerceivedDeviceType.values.h
│ ├── EventCode.cpp
│ ├── OperationCode.cpp
│ ├── DataTypeCode.h
│ ├── EventCode.values.h
│ ├── DataTypeCode.cpp
│ ├── DataTypeCode.values.h
│ ├── DeviceProperty.cpp
│ ├── EventCode.h
│ ├── OperationCode.h
│ ├── ObjectProperty.h
│ ├── DeviceProperty.h
│ ├── Response.cpp
│ ├── ResponseType.values.h
│ ├── Messages.cpp
│ ├── DeviceProperty.values.h
│ ├── PipePacketer.h
│ ├── Container.h
│ ├── Device.h
│ ├── ObjectId.h
│ ├── Response.h
│ ├── ObjectFormat.h
│ ├── IObjectStream.h
│ ├── ObjectProperty.cpp
│ └── ObjectFormat.values.h
├── backend
│ ├── linux
│ │ └── usb
│ │ │ ├── linux
│ │ │ └── types.h
│ │ │ ├── Context.h
│ │ │ ├── Interface.cpp
│ │ │ ├── Endpoint.h
│ │ │ ├── Interface.h
│ │ │ ├── Context.cpp
│ │ │ ├── Endpoint.cpp
│ │ │ ├── DeviceDescriptor.cpp
│ │ │ └── Device.h
│ ├── haiku
│ │ └── usb
│ │ │ ├── Context.cpp
│ │ │ ├── DeviceDescriptor.cpp
│ │ │ ├── Context.h
│ │ │ ├── Interface.h
│ │ │ ├── Device.cpp
│ │ │ └── DeviceDescriptor.h
│ ├── libusb
│ │ └── usb
│ │ │ ├── Interface.cpp
│ │ │ ├── call.h
│ │ │ ├── Exception.h
│ │ │ ├── Exception.cpp
│ │ │ ├── Context.h
│ │ │ ├── Context.cpp
│ │ │ ├── DeviceDescriptor.cpp
│ │ │ ├── Interface.h
│ │ │ └── DeviceDescriptor.h
│ ├── posix
│ │ ├── FileHandler.cpp
│ │ ├── FileHandler.h
│ │ ├── Exception.h
│ │ └── Exception.cpp
│ └── darwin
│ │ └── usb
│ │ ├── Exception.h
│ │ ├── usb.h
│ │ ├── Exception.cpp
│ │ ├── Context.h
│ │ ├── call.h
│ │ ├── DeviceDescriptor.h
│ │ ├── Device.h
│ │ └── Interface.h
├── scope_guard.h
├── metadata
│ ├── Metadata.h
│ └── Metadata.cpp
├── ByteArray.cpp
├── version.h
├── ByteArray.h
├── usb
│ ├── types.h
│ ├── TimeoutException.h
│ ├── DeviceNotFoundException.h
│ ├── DeviceBusyException.h
│ └── BulkPipe.h
├── Token.h
├── Demangle.h
├── mtpz
│ └── TrustedApp.h
├── function_invoker.h
├── log.cpp
└── make_function.h
├── .editorconfig
├── .github
└── .editorconfig
├── pyproject.toml
├── android-file-transfer-linux.json
├── replace-guards.py
├── fuse
├── CMakeLists.txt
├── FuseId.h
├── Exception.h
├── FuseDirectory.h
└── FuseEntry.h
├── replace-license.py
├── cmake
└── FindReadline.cmake
└── FAQ.md
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-minimal
--------------------------------------------------------------------------------
/qt/.gitignore:
--------------------------------------------------------------------------------
1 | *.cxx_parameters
2 |
--------------------------------------------------------------------------------
/python/example/requirements.txt:
--------------------------------------------------------------------------------
1 | InquirerPy ~= 0.3.4
2 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whoozle/android-file-transfer-linux/HEAD/screenshot.png
--------------------------------------------------------------------------------
/cli/update.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | flex -L -F -o arg_lexer.l.cpp --header-file=arg_lexer.l.h arg_lexer.l
4 |
--------------------------------------------------------------------------------
/qt/android-file-transfer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whoozle/android-file-transfer-linux/HEAD/qt/android-file-transfer.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.ninja*
2 | cmake_*
3 | CMakeFiles*
4 | CMakeCache*
5 | nbproject
6 | build
7 | *.user
8 | doc
9 | .vscode
10 |
--------------------------------------------------------------------------------
/osx/android-file-transfer.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whoozle/android-file-transfer-linux/HEAD/osx/android-file-transfer.icns
--------------------------------------------------------------------------------
/osx/android-file-transfer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/whoozle/android-file-transfer-linux/HEAD/osx/android-file-transfer.png
--------------------------------------------------------------------------------
/qt/translations/translations.qrc.in:
--------------------------------------------------------------------------------
1 |
2 |
3 | ${QM_FILES_XML}
4 |
5 |
6 |
--------------------------------------------------------------------------------
/mtp/version.cpp.in:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | namespace mtp
4 | {
5 | std::string GetVersion()
6 | { return std::string("${AFT_VERSION}"); }
7 | }
8 |
--------------------------------------------------------------------------------
/mtp/ptp/PerceivedDeviceType.values.h:
--------------------------------------------------------------------------------
1 | ENUM_VALUE(GenericMtpDevice, 0)
2 | ENUM_VALUE(DigitalStillCamera, 1)
3 | ENUM_VALUE(MediaPlayer, 2)
4 | ENUM_VALUE(MobilePhone, 3)
5 | ENUM_VALUE(DigitalVideoCamera, 4)
6 | ENUM_VALUE(PDA, 5)
7 | ENUM_VALUE(AudioRecorder, 6)
8 |
--------------------------------------------------------------------------------
/mtp/backend/linux/usb/linux/types.h:
--------------------------------------------------------------------------------
1 | #ifndef LINUX_TYPES_STUB_H
2 | #define LINUX_TYPES_STUB_H
3 |
4 | #include
5 |
6 | typedef uint8_t __u8;
7 | typedef uint16_t __u16;
8 | typedef uint32_t __u32;
9 |
10 | #define __user
11 |
12 | #endif
13 |
14 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line = lf
9 | insert_final_newline = true
10 | indent_style = tab
11 | indent_size = 4
12 |
--------------------------------------------------------------------------------
/.github/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = false
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line = lf
9 | insert_final_newline = true
10 | indent_style = space
11 | indent_size = 2
12 |
--------------------------------------------------------------------------------
/qt/android-file-transfer.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Name=Android File Transfer (MTP)
3 | Comment=Transfer files from/to MTP devices
4 | Exec=android-file-transfer
5 | Icon=android-file-transfer
6 | StartupNotify=false
7 | Terminal=false
8 | Type=Application
9 | Categories=Utility;System;FileTools;Filesystem;Qt;
10 |
--------------------------------------------------------------------------------
/qt/icons/dark/go-next.svg:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/mtp/ptp/EventCode.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace mtp
5 | {
6 | std::string ToString(EventCode code)
7 | {
8 | switch(code)
9 | {
10 | # define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_TO_STRING(EventCode, NAME, VALUE)
11 | # include
12 | ENUM_VALUE_TO_STRING_DEFAULT(OperationCode, code, 4);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/qt/icons/dark/go-previous.svg:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/qt/icons/light/go-next.svg:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/qt/icons/light/go-previous.svg:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/mtp/ptp/OperationCode.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace mtp
5 | {
6 | std::string ToString(OperationCode property)
7 | {
8 | switch(property)
9 | {
10 | # define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_TO_STRING(OperationCode, NAME, VALUE)
11 | # include
12 | ENUM_VALUE_TO_STRING_DEFAULT(OperationCode, property, 4);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [project]
2 | name = "android-file-transfer-linux"
3 | version = "4.6"
4 |
5 | [build-system]
6 | requires = ["scikit-build-core", "pybind11"]
7 | build-backend = "scikit_build_core.build"
8 |
9 | [tool.scikit-build]
10 | build.targets = ["aftl"]
11 | install.components = ["aftl"]
12 | # Rely only on CMake install.
13 | wheel.packages = []
14 |
15 | [tool.scikit-build.cmake.define]
16 | BUILD_FUSE = false
17 | BUILD_QT_UI = false
18 |
--------------------------------------------------------------------------------
/mtp/scope_guard.h:
--------------------------------------------------------------------------------
1 | #ifndef AFTL_MTP_SCOPE_GUARD_H
2 | #define AFTL_MTP_SCOPE_GUARD_H
3 |
4 | #include
5 | #include
6 |
7 | namespace mtp
8 | {
9 | class scope_guard : Noncopyable
10 | {
11 | using Callback = std::function;
12 | Callback _callback;
13 |
14 | public:
15 | scope_guard(Callback && c): _callback(c)
16 | { }
17 |
18 | ~scope_guard()
19 | { _callback(); }
20 | };
21 |
22 | }
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/python/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | message(STATUS ${CMAKE_CURRENT_SOURCE_DIR})
2 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
3 | include(pybind11Tools)
4 |
5 | pybind11_add_module(aftl aftl.cpp)
6 | target_link_libraries(aftl PRIVATE ${LIB_NAME})
7 | # Use destination `.` to place `.so` file in `site-packages`, then it can be `import aftl`.
8 | # Set component to only install this target `.so` file.
9 | # See `pyproject.toml`.
10 | install(TARGETS aftl DESTINATION . COMPONENT aftl)
11 |
--------------------------------------------------------------------------------
/mtp/ptp/DataTypeCode.h:
--------------------------------------------------------------------------------
1 | #ifndef AFTL_MTP_PTP_DATATYPECODE_H
2 | #define AFTL_MTP_PTP_DATATYPECODE_H
3 |
4 | #include
5 | #include
6 |
7 | namespace mtp
8 | {
9 | enum struct DataTypeCode : u16
10 | {
11 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
12 | # include
13 | #undef ENUM_VALUE
14 | };
15 | DECLARE_ENUM(DataTypeCode, u16);
16 |
17 | bool IsArray(DataTypeCode type);
18 | std::string ToString(DataTypeCode type);
19 |
20 | }
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/qt/android-file-transfer.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | android-file-transfer.png
4 | icons/dark/folder-new.svg
5 | icons/dark/go-next.svg
6 | icons/dark/go-previous.svg
7 | icons/dark/view-refresh.svg
8 | icons/light/folder-new.svg
9 | icons/light/go-next.svg
10 | icons/light/go-previous.svg
11 | icons/light/view-refresh.svg
12 |
13 |
14 |
--------------------------------------------------------------------------------
/android-file-transfer-linux.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "io.github.whoozle.android-file-transfer-linux",
3 |
4 | "runtime": "org.kde.Platform",
5 | "runtime-version": "5.10",
6 |
7 | "sdk": "org.kde.Sdk",
8 |
9 | "modules" : [
10 | {
11 | "name": "android-file-transfer-linux",
12 | "buildsystem": "cmake",
13 | "config-opts": [ "-DCMAKE_BUILD_TYPE=Release" ],
14 | "sources": [{
15 | "type": "git",
16 | "tag": "v4.6",
17 | "url": "https://github.com/whoozle/android-file-transfer-linux.git"
18 | }]
19 | }
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/osx/icns.sh:
--------------------------------------------------------------------------------
1 | export PROJECT=android-file-transfer
2 | export ICONDIR=./$PROJECT.iconset
3 | export ORIGICON=./android-file-transfer.png
4 |
5 | mkdir $ICONDIR
6 |
7 | # Normal screen icons
8 | for SIZE in 16 32 64 128 256 512; do
9 | sips -z $SIZE $SIZE $ORIGICON --out $ICONDIR/icon_${SIZE}x${SIZE}.png ;
10 | done
11 |
12 | # Retina display icons
13 | for SIZE in 32 64 256 512 1024; do
14 | sips -z $SIZE $SIZE $ORIGICON --out $ICONDIR/icon_$(expr $SIZE / 2)x$(expr $SIZE / 2)@2x.png ;
15 | done
16 |
17 | # Make a multi-resolution Icon
18 | iconutil -c icns -o ./$PROJECT.icns $ICONDIR
19 | rm -rf $ICONDIR #it is useless now
20 |
--------------------------------------------------------------------------------
/qt/icons/dark/folder-new.svg:
--------------------------------------------------------------------------------
1 |
19 |
--------------------------------------------------------------------------------
/qt/icons/light/folder-new.svg:
--------------------------------------------------------------------------------
1 |
19 |
--------------------------------------------------------------------------------
/mtp/backend/haiku/usb/Context.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Context.cpp
3 | * Copyright (C) 2022 pulkomandy
4 | *
5 | * Distributed under terms of the MIT license.
6 | */
7 |
8 | #include "Context.h"
9 |
10 | namespace mtp { namespace usb
11 | {
12 | Context::Context(int debugLevel)
13 | : BUSBRoster()
14 | {
15 | Start();
16 | }
17 |
18 | Context::~Context() {
19 | Stop();
20 | }
21 |
22 | status_t Context::DeviceAdded(BUSBDevice* device) {
23 | _devices.emplace_back(std::make_shared(device));
24 |
25 | return B_OK;
26 | }
27 |
28 | void Context::DeviceRemoved(BUSBDevice* device) {
29 | // TODO _devices.remove(device);
30 | }
31 |
32 |
33 | } };
34 |
--------------------------------------------------------------------------------
/mtp/ptp/EventCode.values.h:
--------------------------------------------------------------------------------
1 | ENUM_VALUE(TransactionCancelled, 0x4001)
2 | ENUM_VALUE(ObjectAdded, 0x4002)
3 | ENUM_VALUE(ObjectRemoved, 0x4003)
4 | ENUM_VALUE(StoreAdded, 0x4004)
5 | ENUM_VALUE(StoreRemoved, 0x4005)
6 | ENUM_VALUE(DevicePropChanged, 0x4006)
7 | ENUM_VALUE(ObjectInfoChanged, 0x4007)
8 | ENUM_VALUE(DeviceInfoChanged, 0x4008)
9 | ENUM_VALUE(RequestObjectTransfer, 0x4009)
10 | ENUM_VALUE(StoreFull, 0x400a)
11 | ENUM_VALUE(DeviceReset, 0x400b)
12 | ENUM_VALUE(StorageInfoChanged, 0x400c)
13 | ENUM_VALUE(CaptureComplete, 0x400d)
14 | ENUM_VALUE(UnreportedStatus, 0x400e)
15 | ENUM_VALUE(ObjectPropChanged, 0xc801)
16 | ENUM_VALUE(ObjectPropDescChanged, 0xc802)
17 | ENUM_VALUE(ObjectReferenceChanged, 0xc803)
18 |
--------------------------------------------------------------------------------
/qt/icons/dark/view-refresh.svg:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/qt/icons/light/view-refresh.svg:
--------------------------------------------------------------------------------
1 |
9 |
--------------------------------------------------------------------------------
/mtp/ptp/DataTypeCode.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace mtp
5 | {
6 | std::string ToString(DataTypeCode type)
7 | {
8 | switch(type)
9 | {
10 | # define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_TO_STRING(DataTypeCode, NAME, VALUE)
11 | # include
12 | ENUM_VALUE_TO_STRING_DEFAULT(DataTypeCode, type, 4);
13 | }
14 | }
15 | bool IsArray(DataTypeCode type)
16 | {
17 | switch(type)
18 | {
19 | # define CASE(BITS) case DataTypeCode::ArrayInt##BITS : case DataTypeCode::ArrayUint##BITS :
20 | CASE(8)
21 | CASE(16)
22 | CASE(32)
23 | CASE(64)
24 | CASE(128)
25 | return true;
26 | default:
27 | return false;
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/mtp/ptp/DataTypeCode.values.h:
--------------------------------------------------------------------------------
1 | ENUM_VALUE(Undefined, 0x0000)
2 | ENUM_VALUE(Int8, 0x0001)
3 | ENUM_VALUE(Uint8, 0x0002)
4 | ENUM_VALUE(Int16, 0x0003)
5 | ENUM_VALUE(Uint16, 0x0004)
6 | ENUM_VALUE(Int32, 0x0005)
7 | ENUM_VALUE(Uint32, 0x0006)
8 | ENUM_VALUE(Int64, 0x0007)
9 | ENUM_VALUE(Uint64, 0x0008)
10 | ENUM_VALUE(Int128, 0x0009)
11 | ENUM_VALUE(Uint128, 0x000a)
12 | ENUM_VALUE(ArrayInt8, 0x4001)
13 | ENUM_VALUE(ArrayUint8, 0x4002)
14 | ENUM_VALUE(ArrayInt16, 0x4003)
15 | ENUM_VALUE(ArrayUint16, 0x4004)
16 | ENUM_VALUE(ArrayInt32, 0x4005)
17 | ENUM_VALUE(ArrayUint32, 0x4006)
18 | ENUM_VALUE(ArrayInt64, 0x4007)
19 | ENUM_VALUE(ArrayUint64, 0x4008)
20 | ENUM_VALUE(ArrayInt128, 0x4009)
21 | ENUM_VALUE(ArrayUint128, 0x400a)
22 | ENUM_VALUE(String, 0xffff)
23 |
--------------------------------------------------------------------------------
/mtp/metadata/Metadata.h:
--------------------------------------------------------------------------------
1 | #ifndef AFTL_MTP_METADATA_METADATA_H
2 | #define AFTL_MTP_METADATA_METADATA_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace mtp
10 | {
11 | struct Metadata;
12 | DECLARE_PTR(Metadata);
13 |
14 | struct MetadataPicture
15 | {
16 | std::string Type;
17 | std::string MimeType;
18 | std::string Description;
19 | mtp::ByteArray Data;
20 | };
21 |
22 | struct Metadata
23 | {
24 | std::string Title;
25 | std::string Artist;
26 | std::string Album;
27 | std::string Genre;
28 | unsigned Year;
29 | unsigned Track;
30 | MetadataPicture Picture;
31 |
32 | static MetadataPtr Read(const std::string & path);
33 | };
34 |
35 | }
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/mtp/ptp/DeviceProperty.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | namespace mtp
5 | {
6 | std::string ToString(DeviceProperty property)
7 | {
8 | switch(property)
9 | {
10 | # define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_TO_STRING(DeviceProperty, NAME, VALUE)
11 | # include
12 | ENUM_VALUE_TO_STRING_DEFAULT(DeviceProperty, property, 4);
13 | # undef ENUM_VALUE
14 | }
15 | }
16 |
17 | std::string ToString(PerceivedDeviceType property)
18 | {
19 | switch(property)
20 | {
21 | # define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_TO_STRING(PerceivedDeviceType, NAME, VALUE)
22 | # include
23 | ENUM_VALUE_TO_STRING_DEFAULT(PerceivedDeviceType, property, 8);
24 | # undef ENUM_VALUE
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/qt/utils.cpp:
--------------------------------------------------------------------------------
1 | #include "utils.h"
2 |
3 | int GetCoverScore(const QString & str_)
4 | {
5 | QString str = str_.toLower();
6 | int score = 0;
7 | if (str.contains("0001"))
8 | score += 1001;
9 | else if (str.contains("0000"))
10 | score += 1000;
11 | else if (str.contains("001"))
12 | score += 101;
13 | else if (str.contains("000"))
14 | score += 100;
15 | else if (str.contains("01"))
16 | score += 11;
17 | else if (str.contains("00"))
18 | score += 10;
19 | else if (str.contains("1"))
20 | score += 1;
21 |
22 | if (str.contains("art"))
23 | score += 10000;
24 | if (str.contains("album"))
25 | score += 10000;
26 | if (str.contains("cover"))
27 | score += 20000;
28 | if (str.contains("large"))
29 | score += 20000;
30 | if (str.contains("small"))
31 | score += 10000;
32 | if (str.contains("folder"))
33 | score += 10000;
34 | return score;
35 | }
36 |
--------------------------------------------------------------------------------
/qt/qtobjectstream.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include "qtobjectstream.h"
21 |
22 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/Interface.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include "Interface.h"
21 |
22 |
--------------------------------------------------------------------------------
/qt/mtpmimedata.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include "mtpmimedata.h"
21 |
22 | MtpMimeData::MtpMimeData()
23 | {
24 |
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/mtp/ByteArray.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace mtp
25 | {
26 | }
27 |
--------------------------------------------------------------------------------
/mtp/version.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_VERSION_H
21 | #define AFTL_MTP_VERSION_H
22 |
23 | #include
24 |
25 | namespace mtp
26 | {
27 | std::string GetVersion();
28 | }
29 |
30 | #endif
--------------------------------------------------------------------------------
/mtp/backend/haiku/usb/DeviceDescriptor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * DeviceDescriptor.cpp
3 | * Copyright (C) 2022 pulkomandy
4 | *
5 | * Distributed under terms of the MIT license.
6 | */
7 |
8 | #include "DeviceDescriptor.h"
9 |
10 |
11 |
12 | namespace mtp { namespace usb
13 | {
14 | DeviceDescriptor::DeviceDescriptor(BUSBDevice* dev)
15 | :_dev(dev)
16 | {
17 | }
18 |
19 | DeviceDescriptor::~DeviceDescriptor()
20 | {
21 | }
22 |
23 | ConfigurationPtr DeviceDescriptor::GetConfiguration(int conf)
24 | {
25 | return std::make_shared(_dev->ConfigurationAt(conf));
26 | }
27 |
28 | ByteArray DeviceDescriptor::GetDescriptor() const
29 | {
30 | const usb_device_descriptor* descriptor = _dev->Descriptor();
31 | ByteArray out;
32 | out.reserve(sizeof(usb_device_descriptor));
33 | memcpy(out.data(), descriptor, sizeof(usb_device_descriptor));
34 | return out;
35 | }
36 |
37 | DevicePtr DeviceDescriptor::TryOpen(ContextPtr context)
38 | {
39 | if (_dev->InitCheck() != B_OK)
40 | return nullptr;
41 | return std::make_shared(context, _dev);
42 | }
43 | }}
44 |
--------------------------------------------------------------------------------
/mtp/backend/posix/FileHandler.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace mtp { namespace posix
25 | {
26 |
27 | FileHandler::~FileHandler()
28 | { close(_fd); }
29 |
30 | }}
31 |
--------------------------------------------------------------------------------
/qt/mtpmimedata.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_QT_MTPMIMEDATA_H
21 | #define AFTL_QT_MTPMIMEDATA_H
22 |
23 |
24 | class MtpMimeData : public QMimeData
25 | {
26 | public:
27 | MtpMimeData();
28 | };
29 |
30 | #endif // MTPMIMEDATA_H
31 |
--------------------------------------------------------------------------------
/cli/Tokens.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_CLI_TOKENS_H
21 | #define AFTL_CLI_TOKENS_H
22 |
23 | #include
24 | #include
25 |
26 | namespace cli
27 | {
28 | typedef std::list Tokens;
29 | }
30 |
31 | #endif
32 |
33 |
--------------------------------------------------------------------------------
/qt/devicesdialog.h:
--------------------------------------------------------------------------------
1 | #ifndef DEVICESDIALOG_H
2 | #define DEVICESDIALOG_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace Ui {
10 | class DevicesDialog;
11 | }
12 | class QListWidgetItem;
13 |
14 | class DevicesDialog : public QDialog
15 | {
16 | Q_OBJECT
17 |
18 | private:
19 | struct Row
20 | {
21 | mtp::usb::DeviceDescriptorPtr Descriptor;
22 | mtp::DevicePtr Device;
23 | std::vector Processes;
24 | };
25 |
26 | bool _resetDevice;
27 | std::vector _devices;
28 |
29 | public:
30 | explicit DevicesDialog(bool resetDevice, QWidget *parent = nullptr);
31 | ~DevicesDialog();
32 |
33 | mtp::DevicePtr getDevice();
34 |
35 | int exec();
36 |
37 | private slots:
38 | void scan();
39 | void kill();
40 | void itemClicked(QListWidgetItem *);
41 | void itemDoubleClicked(QListWidgetItem *);
42 | void updateButtons();
43 |
44 | private:
45 | Ui::DevicesDialog * ui;
46 |
47 | QPushButton * _buttonScan;
48 | QPushButton * _buttonKill;
49 | };
50 |
51 | #endif // DEVICESDIALOG_H
52 |
--------------------------------------------------------------------------------
/replace-guards.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/python3
2 |
3 | #!/usr/bin/env python
4 |
5 | import os
6 | import os.path
7 | import re
8 |
9 | guard_re = re.compile(r'#ifndef\s+(\w+)\n#define\s+(\w+)', re.M | re.S)
10 | base_dir = os.path.dirname(os.path.realpath(__file__))
11 | clean_re = re.compile(r'[^\w]')
12 | print(base_dir)
13 |
14 | for root, dirs, files in os.walk('.'):
15 | root = os.path.relpath(root, base_dir)
16 | if (root[0] == '.' and len(root) > 1) or root.startswith("build"):
17 | dirs[:] = []
18 | continue
19 | if root == "mtp/backend/linux/usb/linux":
20 | continue
21 |
22 | for file in files:
23 | name, ext = os.path.splitext(file)
24 | if ext != '.h' or name == "arg_lexer.l" or name.endswith(".values"):
25 | continue
26 |
27 | fname = os.path.join(root, file)
28 | with open(fname) as f:
29 | data = f.read()
30 |
31 | guard = 'AFTL_' + clean_re.sub('_', os.path.relpath(os.path.join(root, file), base_dir)).upper()
32 |
33 | def replace_guard(m):
34 | return "#ifndef %s\n#define %s" %(guard, guard)
35 |
36 | data, n = guard_re.subn(replace_guard, data, count=1)
37 | if n == 0:
38 | print("missing guard in %s" %file)
39 | else:
40 | with open(fname, 'w') as f:
41 | f.write(data)
42 |
43 |
--------------------------------------------------------------------------------
/mtp/ByteArray.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BYTEARRAY_H
21 | #define AFTL_MTP_BYTEARRAY_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp
28 | {
29 | using ByteArray = std::vector; //! \typedef ByteArray : vector of bytes
30 | DECLARE_PTR(ByteArray);
31 | }
32 |
33 | #endif /* BYTEARRAY_H */
34 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/call.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LIBUSB_USB_CALL_H
21 | #define AFTL_MTP_BACKEND_LIBUSB_USB_CALL_H
22 |
23 | #include
24 |
25 | #include
26 |
27 | #define USB_CALL(...) do { int r = (__VA_ARGS__); if (r != 0) throw mtp::usb::Exception(#__VA_ARGS__, r) ; } while(false)
28 |
29 | #endif
30 |
31 |
--------------------------------------------------------------------------------
/mtp/usb/types.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_USB_TYPES_H
21 | #define AFTL_MTP_USB_TYPES_H
22 |
23 | namespace mtp { namespace usb
24 | {
25 |
26 | enum struct EndpointType
27 | {
28 | Control = 0, Isochronous = 1, Bulk = 2, Interrupt = 3
29 | };
30 |
31 | enum struct EndpointDirection
32 | {
33 | In, Out, Both
34 | };
35 |
36 | }}
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/mtp/Token.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_TOKEN_H
21 | #define AFTL_MTP_TOKEN_H
22 |
23 | #include
24 |
25 | namespace mtp
26 | {
27 | //! Token, base class for ref counted objects which hold some resources while they are alive
28 | struct IToken : Noncopyable
29 | {
30 | virtual ~IToken() = default;
31 | };
32 | DECLARE_PTR(IToken);
33 | }
34 |
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/qt/android-file-transfer.appdata.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | android-file-transfer
4 | CC0-1.0
5 | LGPL-2.0+
6 | Android File Transfer
7 | Interactive MTP client with Qt4/Qt5 GUI
8 |
9 |
10 |
Simple Qt UI with progress dialogs.
11 |
FUSE wrapper (If you'd prefer mounting your device),
12 | supporting partial read/writes, allowing instant access to your files.
13 |
No file size limits.
14 |
Automatically renames album cover to make it visible from media player.
15 |
No extra dependencies (e.g. libptp/libmtp).
16 |
Available as static/shared library.
17 |
Simple CLI tool.
18 |
19 |
20 | android-file-transfer.desktop
21 | https://whoozle.github.io/android-file-transfer-linux
22 | vladimir.menshakov@gmail.com
23 |
24 | android-file-transfer.desktop
25 |
26 |
27 |
--------------------------------------------------------------------------------
/cli/Command.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 |
23 | namespace cli
24 | {
25 |
26 | void impl::Completer::Complete(CompletionContext & ctx)
27 | { ctx.Session.CompletePath(ctx.Prefix, ctx.Result); }
28 |
29 | void impl::Completer::Complete(CompletionContext & ctx)
30 | { ctx.Session.CompleteStoragePath(ctx.Prefix, ctx.Result); }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/cli/arg_lexer.l:
--------------------------------------------------------------------------------
1 | %option noyywrap nounput
2 | %option reentrant
3 | %option 8bit
4 | %option nounistd
5 | %option batch
6 | %option never-interactive
7 | %option prefix="args_"
8 |
9 | %top {
10 | # include
11 | # define register
12 | }
13 |
14 | %{
15 | # include
16 | # include
17 | # include
18 | # include
19 |
20 | # define LVAL (yylval_param)
21 | # define PARSER (reinterpret_cast(yyget_extra(yyscanner)))
22 | # define YY_INPUT(buf,result,max_size) result = PARSER->Input(buf, max_size);
23 |
24 | static void yy_fatal_error(const char*, yyscan_t);
25 | void (*hide_warning)(const char*, yyscan_t) = &yy_fatal_error;
26 |
27 | %}
28 |
29 | %x STRING
30 |
31 | %%
32 |
33 | \" { BEGIN(STRING); }
34 |
35 | \\n { PARSER->Write('\n'); }
36 | \\t { PARSER->Write('\t'); }
37 | \\f { PARSER->Write('\f'); }
38 | \\r { PARSER->Write('\r'); }
39 | \\b { PARSER->Write('\b'); }
40 | \\. { PARSER->Write(yytext[1]); }
41 | \" { BEGIN(INITIAL); }
42 | [^\\\"]+ { PARSER->Write(yytext, yyleng); }
43 |
44 | "\\ " { PARSER->Write(' '); }
45 | [[:space:]]+ { PARSER->NextArgument(); }
46 | <*>. { PARSER->Write(yytext[0]); }
47 | %%
48 |
--------------------------------------------------------------------------------
/mtp/usb/TimeoutException.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_USB_TIMEOUTEXCEPTION_H
21 | #define AFTL_MTP_USB_TIMEOUTEXCEPTION_H
22 |
23 | #include
24 |
25 | namespace mtp { namespace usb
26 | {
27 |
28 | struct TimeoutException : public std::runtime_error //! Exception throw if USB URB transfer timeout occured
29 | {
30 | TimeoutException(const std::string &msg): std::runtime_error(msg) { }
31 | };
32 |
33 | }}
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/qt/renamedialog.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include "renamedialog.h"
21 | #include "ui_renamedialog.h"
22 |
23 | RenameDialog::RenameDialog(QString name, QWidget *parent) :
24 | QDialog(parent),
25 | ui(new Ui::RenameDialog)
26 | {
27 | ui->setupUi(this);
28 | ui->lineEdit->setText(name);
29 | }
30 |
31 | QString RenameDialog::name() const
32 | { return ui->lineEdit->text(); }
33 |
34 | RenameDialog::~RenameDialog()
35 | {
36 | delete ui;
37 | }
38 |
--------------------------------------------------------------------------------
/mtp/backend/darwin/usb/Exception.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_DARWIN_USB_EXCEPTION_H
21 | #define AFTL_MTP_BACKEND_DARWIN_USB_EXCEPTION_H
22 |
23 | #include
24 |
25 | namespace mtp { namespace usb
26 | {
27 | class Exception : public std::runtime_error
28 | {
29 | public:
30 | Exception(const std::string &what, int retCode) throw();
31 | static std::string GetErrorMessage(int retCode);
32 | };
33 | }}
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/Exception.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LIBUSB_USB_EXCEPTION_H
21 | #define AFTL_MTP_BACKEND_LIBUSB_USB_EXCEPTION_H
22 |
23 | #include
24 |
25 | namespace mtp { namespace usb
26 | {
27 | class Exception : public std::runtime_error
28 | {
29 | public:
30 | Exception(const std::string &what, int retCode) throw();
31 | static std::string GetErrorMessage(int retCode);
32 | };
33 | }}
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/mtp/Demangle.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_DEMANGLE_H
21 | #define AFTL_MTP_DEMANGLE_H
22 |
23 | #include
24 | #include
25 |
26 | namespace mtp
27 | {
28 | //! demangles c++ symbol
29 | inline std::string Demangle(const char *abiName)
30 | {
31 | int status;
32 | char *ret = abi::__cxa_demangle(abiName, 0, 0, &status);
33 |
34 | std::string name(ret);
35 | free(ret);
36 | return name;
37 | }
38 | }
39 |
40 | #endif
41 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/Exception.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace mtp { namespace usb
25 | {
26 | Exception::Exception(const std::string &what, int returnCode) throw() : std::runtime_error(what + ": " + GetErrorMessage(returnCode))
27 | { }
28 |
29 | std::string Exception::GetErrorMessage(int returnCode)
30 | {
31 | return libusb_error_name(returnCode);
32 | }
33 |
34 | }}
--------------------------------------------------------------------------------
/mtp/ptp/EventCode.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2025 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_EVENTCODE_H
21 | #define AFTL_MTP_PTP_EVENTCODE_H
22 |
23 | #include
24 |
25 | namespace mtp
26 | {
27 | enum struct EventCode : u16
28 | {
29 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
30 | # include
31 | #undef ENUM_VALUE
32 | };
33 | DECLARE_ENUM(EventCode, u16);
34 |
35 | std::string ToString(EventCode code);
36 | }
37 |
38 | #endif
39 |
--------------------------------------------------------------------------------
/qt/renamedialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_QT_RENAMEDIALOG_H
21 | #define AFTL_QT_RENAMEDIALOG_H
22 |
23 | #include
24 |
25 | namespace Ui {
26 | class RenameDialog;
27 | }
28 |
29 | class RenameDialog : public QDialog
30 | {
31 | Q_OBJECT
32 |
33 | public:
34 | explicit RenameDialog(QString name, QWidget *parent = 0);
35 | ~RenameDialog();
36 |
37 | QString name() const;
38 |
39 | private:
40 | Ui::RenameDialog *ui;
41 | };
42 |
43 | #endif // RENAMEDIALOG_H
44 |
--------------------------------------------------------------------------------
/mtp/backend/posix/FileHandler.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_POSIX_FILEHANDLER_H
21 | #define AFTL_MTP_BACKEND_POSIX_FILEHANDLER_H
22 |
23 | #include
24 | #include
25 |
26 | namespace mtp { namespace posix
27 | {
28 |
29 | class FileHandler : Noncopyable
30 | {
31 | int _fd;
32 |
33 | public:
34 | FileHandler(int fd): _fd(fd) { }
35 | ~FileHandler();
36 |
37 | int Get() const
38 | { return _fd; }
39 | };
40 |
41 | }}
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/qt/createdirectorydialog.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include "createdirectorydialog.h"
21 | #include "ui_createdirectorydialog.h"
22 |
23 | CreateDirectoryDialog::CreateDirectoryDialog(QWidget *parent) :
24 | QDialog(parent),
25 | ui(new Ui::CreateDirectoryDialog)
26 | {
27 | ui->setupUi(this);
28 | }
29 |
30 | CreateDirectoryDialog::~CreateDirectoryDialog()
31 | {
32 | delete ui;
33 | }
34 |
35 | QString CreateDirectoryDialog::name() const
36 | {
37 | return ui->lineEdit->text();
38 | }
39 |
--------------------------------------------------------------------------------
/mtp/backend/posix/Exception.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_POSIX_EXCEPTION_H
21 | #define AFTL_MTP_BACKEND_POSIX_EXCEPTION_H
22 |
23 | #include
24 |
25 | namespace mtp { namespace posix
26 | {
27 | class Exception : public std::runtime_error
28 | {
29 | public:
30 | Exception(const std::string &what) throw();
31 | Exception(const std::string &what, int retCode) throw();
32 | static std::string GetErrorMessage(int retCode);
33 | };
34 | }}
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/mtp/usb/DeviceNotFoundException.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_USB_DEVICENOTFOUNDEXCEPTION_H
21 | #define AFTL_MTP_USB_DEVICENOTFOUNDEXCEPTION_H
22 |
23 | #include
24 |
25 | namespace mtp { namespace usb
26 | {
27 |
28 | struct DeviceNotFoundException : public std::runtime_error //! Exception throw when device was disconnected or was not found
29 | {
30 | DeviceNotFoundException(): std::runtime_error("device was disconnected") { }
31 | };
32 |
33 | }}
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/qt/utils.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_QT_UTILS_H
21 | #define AFTL_QT_UTILS_H
22 |
23 | #include
24 | #include
25 |
26 | inline QString fromUtf8(const std::string &str)
27 | {
28 | return QString::fromUtf8(str.c_str(), str.size());
29 | }
30 |
31 | inline std::string toUtf8(const QString &str)
32 | {
33 | QByteArray utf8(str.toUtf8());
34 | return std::string(utf8.data(), utf8.size());
35 | }
36 |
37 | int GetCoverScore(const QString &str_);
38 |
39 | #endif // UTILS
40 |
41 |
--------------------------------------------------------------------------------
/mtp/backend/darwin/usb/usb.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace mtp { namespace usb
26 | {
27 | #if defined (kIOUSBDeviceInterfaceID500)
28 | typedef IOUSBDeviceInterface500 IOUSBDeviceType;
29 | #define DeviceInterfaceID kIOUSBDeviceInterfaceID500
30 | #else
31 | typedef IOUSBDeviceInterface IOUSBDeviceType;
32 | #define DeviceInterfaceID kIOUSBDeviceInterface
33 | #endif
34 | }}
--------------------------------------------------------------------------------
/mtp/backend/darwin/usb/Exception.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace mtp { namespace usb
25 | {
26 | Exception::Exception(const std::string &what, int returnCode) throw() : std::runtime_error(what + ": " + GetErrorMessage(returnCode))
27 | { }
28 |
29 | std::string Exception::GetErrorMessage(int returnCode)
30 | {
31 | char buf[128];
32 | snprintf(buf, sizeof(buf), "error 0x%08x", returnCode);
33 | return std::string(buf);
34 | }
35 |
36 | }}
--------------------------------------------------------------------------------
/mtp/ptp/OperationCode.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_OPERATIONCODE_H
21 | #define AFTL_MTP_PTP_OPERATIONCODE_H
22 |
23 | #include
24 |
25 | namespace mtp
26 | {
27 | enum class OperationCode : u16 //! MTP operation code
28 | {
29 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
30 | # include
31 | #undef ENUM_VALUE
32 | };
33 |
34 | DECLARE_ENUM(OperationCode, u16);
35 | std::string ToString(OperationCode property);
36 | }
37 |
38 | #endif /* OPERATIONCODE_H */
39 |
--------------------------------------------------------------------------------
/qt/createdirectorydialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_QT_CREATEDIRECTORYDIALOG_H
21 | #define AFTL_QT_CREATEDIRECTORYDIALOG_H
22 |
23 | #include
24 |
25 | namespace Ui {
26 | class CreateDirectoryDialog;
27 | }
28 |
29 | class CreateDirectoryDialog : public QDialog
30 | {
31 | Q_OBJECT
32 |
33 | public:
34 | explicit CreateDirectoryDialog(QWidget *parent = 0);
35 | ~CreateDirectoryDialog();
36 |
37 | QString name() const;
38 |
39 | private:
40 | Ui::CreateDirectoryDialog *ui;
41 | };
42 |
43 | #endif // CREATEDIRECTORYDIALOG_H
44 |
--------------------------------------------------------------------------------
/fuse/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_executable(aft-mtp-mount fuse.cpp)
2 |
3 | target_link_libraries(aft-mtp-mount ${MTP_LIBRARIES} ${FUSE_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT})
4 | install(TARGETS aft-mtp-mount RUNTIME DESTINATION bin)
5 |
6 | if (BUILD_QT_UI AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
7 | add_custom_command(TARGET aft-mtp-mount POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../../Frameworks/" $)
8 | add_custom_command(TARGET aft-mtp-mount POST_BUILD COMMAND ${OTOOL_BIN} -L $)
9 | set(AFT_MTP_MOUNT_PATH "${MACOSX_BUNDLE_ROOT_DIR}/Contents/SharedSupport/bin/aft-mtp-mount")
10 | set(MACOSX_BUNDLE_LIBS_INSTALL "
11 | ${MACOSX_BUNDLE_LIBS_INSTALL}
12 | file(INSTALL \"${CMAKE_CURRENT_BINARY_DIR}/aft-mtp-mount\" DESTINATION \"${MACOSX_BUNDLE_ROOT_DIR}/Contents/SharedSupport/bin\")
13 | ")
14 | foreach(DYNLIB ${MACOSX_BUNDLE_LIBS})
15 | get_filename_component(DYNLIB_NAME "${DYNLIB}" NAME)
16 | set(MACOSX_BUNDLE_LIBS_INSTALL "
17 | ${MACOSX_BUNDLE_LIBS_INSTALL}
18 | message(STATUS \"fuse: fixing ${DYNLIB_NAME}\")
19 | execute_process(COMMAND \"${CMAKE_INSTALL_NAME_TOOL}\" -change \"${DYNLIB}\" \"@executable_path/../../Frameworks/${DYNLIB_NAME}\" \"${AFT_MTP_MOUNT_PATH}\")
20 | ")
21 | endforeach()
22 |
23 | set(MACOSX_BUNDLE_LIBS_INSTALL "
24 | ${MACOSX_BUNDLE_LIBS_INSTALL}
25 | execute_process(COMMAND \"${OTOOL_BIN}\" -L \"${AFT_MTP_MOUNT_PATH}\")
26 | " PARENT_SCOPE)
27 |
28 | endif()
29 |
--------------------------------------------------------------------------------
/mtp/backend/linux/usb/Context.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LINUX_USB_CONTEXT_H
21 | #define AFTL_MTP_BACKEND_LINUX_USB_CONTEXT_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp { namespace usb
28 | {
29 |
30 | class Context : Noncopyable
31 | {
32 | private:
33 |
34 | public:
35 | typedef std::vector Devices;
36 |
37 | private:
38 | Devices _devices;
39 |
40 | public:
41 | Context();
42 | ~Context();
43 |
44 | const Devices & GetDevices() const
45 | { return _devices; }
46 | };
47 | DECLARE_PTR(Context);
48 |
49 | }}
50 |
51 | #endif
52 |
53 |
--------------------------------------------------------------------------------
/mtp/backend/darwin/usb/Context.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_DARWIN_USB_CONTEXT_H
21 | #define AFTL_MTP_BACKEND_DARWIN_USB_CONTEXT_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp { namespace usb
28 | {
29 |
30 | class Context : Noncopyable
31 | {
32 | public:
33 | typedef std::vector Devices;
34 |
35 | private:
36 | Devices _devices;
37 |
38 | public:
39 | Context();
40 | ~Context();
41 |
42 | void Wait();
43 |
44 | const Devices & GetDevices() const
45 | { return _devices; }
46 | };
47 | DECLARE_PTR(Context);
48 |
49 | }}
50 |
51 | #endif
52 |
53 |
--------------------------------------------------------------------------------
/mtp/ptp/ObjectProperty.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_OBJECTPROPERTY_H
21 | #define AFTL_MTP_PTP_OBJECTPROPERTY_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | namespace mtp
29 | {
30 |
31 | enum struct ObjectProperty : u16
32 | {
33 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
34 | # include
35 | #undef ENUM_VALUE
36 | };
37 | DECLARE_ENUM(ObjectProperty, u16);
38 |
39 | std::string ToString(ObjectProperty property);
40 | std::string ToString(DataTypeCode type, const ByteArray & value);
41 |
42 | }
43 |
44 | #endif /* OBJECTPROPERTY_H */
45 |
--------------------------------------------------------------------------------
/fuse/FuseId.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_FUSE_FUSEID_H
21 | #define AFTL_FUSE_FUSEID_H
22 |
23 | #include
24 |
25 | namespace mtp { namespace fuse
26 | {
27 |
28 | struct FuseId
29 | {
30 | static const FuseId Root;
31 |
32 | fuse_ino_t Inode; //generation here?
33 |
34 | explicit FuseId(fuse_ino_t inode): Inode(inode) { }
35 |
36 | bool operator == (const FuseId &o) const
37 | { return Inode == o.Inode; }
38 | bool operator != (const FuseId &o) const
39 | { return !((*this) == o); }
40 | bool operator < (const FuseId &o) const
41 | { return Inode < o.Inode; }
42 | };
43 |
44 | const FuseId FuseId::Root(FUSE_ROOT_ID);
45 |
46 |
47 | }}
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/mtp/backend/darwin/usb/call.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_DARWIN_USB_CALL_H
21 | #define AFTL_MTP_BACKEND_DARWIN_USB_CALL_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #define USB_CALL(...) \
29 | do { int _r_ = (__VA_ARGS__); \
30 | switch(_r_) { \
31 | case kIOReturnSuccess : break; \
32 | case kIOReturnNoDevice : throw mtp::usb::DeviceNotFoundException(); \
33 | case kIOReturnExclusiveAccess: throw mtp::usb::DeviceBusyException(); \
34 | default: throw mtp::usb::Exception(#__VA_ARGS__, _r_) ; \
35 | } \
36 | } while(false)
37 |
38 | #endif
39 |
40 |
--------------------------------------------------------------------------------
/qt/Info.plist.in:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 | Android File Transfer for Linux and macOS
9 | CFBundleExecutable
10 | ${MACOSX_BUNDLE_EXECUTABLE_NAME}
11 | CFBundleIconFile
12 | ${MACOSX_BUNDLE_ICON_FILE}
13 | CFBundleIdentifier
14 | ${MACOSX_BUNDLE_GUI_IDENTIFIER}
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleLocalizations
18 |
19 | en
20 | it
21 | ru
22 |
23 | CFBundleName
24 | ${MACOSX_BUNDLE_BUNDLE_NAME}
25 | CFBundlePackageType
26 | APPL
27 | CFBundleShortVersionString
28 | ${MACOSX_BUNDLE_SHORT_VERSION_STRING}
29 | CFBundleVersion
30 | ${MACOSX_BUNDLE_BUNDLE_VERSION}
31 | NSHumanReadableCopyright
32 | ${MACOSX_BUNDLE_COPYRIGHT}
33 | CSResourcesFileMapped
34 |
35 | NSPrincipalClass
36 | NSApplication
37 | NSHighResolutionCapable
38 | True
39 | LSMinimumSystemVersion
40 | 10.12.0
41 | CFBundleSignature
42 | ????
43 |
44 |
45 |
--------------------------------------------------------------------------------
/cli/Tokenizer.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_CLI_TOKENIZER_H
21 | #define AFTL_CLI_TOKENIZER_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace cli
28 | {
29 |
30 | class Tokenizer
31 | {
32 | public:
33 | const std::string & _text;
34 | Tokens & _tokens;
35 | size_t _inputPosition;
36 | std::stringstream _tempString;
37 |
38 | public:
39 | Tokenizer(const std::string &text, Tokens &tokens);
40 |
41 | void Write(const char *text, size_t size)
42 | { _tempString.write(text, size); }
43 | void Write(const char ch)
44 | { _tempString << ch; }
45 | void NextArgument();
46 | size_t Input(char *buf, size_t max_size);
47 | };
48 | }
49 |
50 | #endif
51 |
52 |
--------------------------------------------------------------------------------
/qt/mtpstoragesmodel.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_QT_MTPSTORAGESMODEL_H
21 | #define AFTL_QT_MTPSTORAGESMODEL_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | class MtpStoragesModel : public QAbstractListModel
29 | {
30 | QVector > _storages;
31 |
32 | public:
33 | MtpStoragesModel(QObject *parent = 0);
34 | bool update(const mtp::SessionPtr &session);
35 |
36 | mtp::StorageId getStorageId(int idx) const;
37 | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
38 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
39 | };
40 |
41 | #endif // MTPSTORAGESMODEL_H
42 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/Context.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LIBUSB_USB_CONTEXT_H
21 | #define AFTL_MTP_BACKEND_LIBUSB_USB_CONTEXT_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | namespace mtp { namespace usb
29 | {
30 |
31 | class Context : Noncopyable
32 | {
33 | private:
34 | libusb_context * _ctx;
35 |
36 | public:
37 | typedef std::vector Devices;
38 |
39 | private:
40 | Devices _devices;
41 |
42 | public:
43 | Context(int debugLevel = 3);
44 | ~Context();
45 |
46 | void Wait();
47 |
48 | const Devices & GetDevices() const
49 | { return _devices; }
50 | };
51 | DECLARE_PTR(Context);
52 |
53 | }}
54 |
55 | #endif
56 |
57 |
--------------------------------------------------------------------------------
/replace-license.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | import os
4 | import os.path
5 | import re
6 |
7 | license = """/*
8 | This file is part of Android File Transfer For Linux.
9 | Copyright (C) 2015-2020 Vladimir Menshakov
10 |
11 | This library is free software; you can redistribute it and/or modify it
12 | under the terms of the GNU Lesser General Public License as published by
13 | the Free Software Foundation; either version 2.1 of the License,
14 | or (at your option) any later version.
15 |
16 | This library is distributed in the hope that it will be useful, but
17 | WITHOUT ANY WARRANTY; without even the implied warranty of
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 | Lesser General Public License for more details.
20 |
21 | You should have received a copy of the GNU Lesser General Public License
22 | along with this library; if not, write to the Free Software Foundation,
23 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | */
25 |
26 | """
27 |
28 | license_re = re.compile(r'^/\*.*?\*/\s+', re.M | re.S)
29 |
30 | for root, dirs, files in os.walk('.'):
31 | if root == "./mtp/backend/linux/usb/linux":
32 | continue
33 |
34 | for file in files:
35 | name, ext = os.path.splitext(file)
36 | if ext != '.h' and ext != '.cpp':
37 | continue
38 | if name == "arg_lexer.l":
39 | continue
40 |
41 | fname = os.path.join(root, file)
42 | with open(fname) as f:
43 | data = f.read()
44 |
45 | if license_re.match(data):
46 | data = license_re.sub(license, data, 1)
47 | else:
48 | data = license + data
49 |
50 | with open(fname, 'w') as f:
51 | f.write(data)
52 |
--------------------------------------------------------------------------------
/mtp/ptp/DeviceProperty.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_DEVICEPROPERTY_H
21 | #define AFTL_MTP_PTP_DEVICEPROPERTY_H
22 |
23 | #include
24 | #include
25 |
26 | namespace mtp
27 | {
28 | enum struct PerceivedDeviceType : u32
29 | {
30 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
31 | # include "PerceivedDeviceType.values.h"
32 | #undef ENUM_VALUE
33 | };
34 | std::string ToString(PerceivedDeviceType property);
35 |
36 | enum struct DeviceProperty : u16
37 | {
38 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
39 | # include "DeviceProperty.values.h"
40 | #undef ENUM_VALUE
41 | };
42 | DECLARE_ENUM(DeviceProperty, u16);
43 |
44 | std::string ToString(DeviceProperty property);
45 |
46 | }
47 |
48 | #endif /* OBJECTPROPERTY_H */
49 |
--------------------------------------------------------------------------------
/mtp/backend/linux/usb/Interface.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace mtp { namespace usb
25 | {
26 |
27 | Interface::Interface(int index, const std::string &path): _path(path)
28 | {
29 | _class = Directory::ReadInt(path + "/bInterfaceClass");
30 | _subclass = Directory::ReadInt(path + "/bInterfaceSubClass");
31 | _index = Directory::ReadInt(path + "/bInterfaceNumber");
32 |
33 | Directory dir(path);
34 | while(true)
35 | {
36 | std::string entry = dir.Read();
37 | if (entry.empty())
38 | break;
39 |
40 | if (entry.compare(0, 3, "ep_") == 0)
41 | {
42 | EndpointPtr ep = Endpoint::TryOpen(path + "/" + entry);
43 | if (ep)
44 | _endpoints.push_back(ep);
45 | }
46 | }
47 | }
48 |
49 | }}
50 |
--------------------------------------------------------------------------------
/mtp/backend/haiku/usb/Context.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LIBUSB_USB_CONTEXT_H
21 | #define AFTL_MTP_BACKEND_LIBUSB_USB_CONTEXT_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp { namespace usb
28 | {
29 |
30 | class Context : public BUSBRoster, Noncopyable
31 | {
32 | public:
33 | typedef std::vector Devices;
34 |
35 | private:
36 | Devices _devices;
37 |
38 | status_t DeviceAdded(BUSBDevice*) final override;
39 | void DeviceRemoved(BUSBDevice*) final override;
40 |
41 | public:
42 | Context(int debugLevel = 3);
43 | ~Context();
44 |
45 | void Wait();
46 |
47 | const Devices & GetDevices() const
48 | { return _devices; }
49 | };
50 | DECLARE_PTR(Context);
51 |
52 | }}
53 |
54 | #endif
55 |
56 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/Context.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace mtp { namespace usb
25 | {
26 |
27 | Context::Context(int debugLevel)
28 | {
29 | USB_CALL(libusb_init(&_ctx));
30 | libusb_set_debug(_ctx, debugLevel);
31 | libusb_device **devs;
32 | int count = libusb_get_device_list(_ctx, &devs);
33 | if (count < 0)
34 | throw Exception("libusb_get_device_list", count);
35 |
36 | _devices.reserve(count);
37 | for(int i = 0; i < count; ++i)
38 | _devices.push_back(std::make_shared(devs[i]));
39 | libusb_free_device_list(devs, 0);
40 | }
41 |
42 | Context::~Context()
43 | {
44 | libusb_exit(_ctx);
45 | }
46 |
47 | void Context::Wait()
48 | {
49 | USB_CALL(libusb_handle_events(_ctx));
50 | }
51 |
52 |
53 | }}
54 |
--------------------------------------------------------------------------------
/cli/CommandLineStub.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 |
22 | #include
23 |
24 | namespace cli
25 | {
26 | CommandLine::CommandLine()
27 | { }
28 |
29 | CommandLine::~CommandLine()
30 | { }
31 |
32 | CommandLine & CommandLine::Get()
33 | {
34 | static CommandLine cmd;
35 | return cmd;
36 | }
37 |
38 | bool CommandLine::ReadLine(const std::string &prompt, std::string &input)
39 | {
40 | fputs(prompt.c_str(), stdout);
41 | fflush(stdout);
42 | return ReadRawLine(input);
43 | }
44 |
45 | bool CommandLine::ReadRawLine(std::string &input)
46 | {
47 | char buf[4096];
48 | char *r = fgets(buf, sizeof(buf), stdin);
49 | if (r)
50 | input.assign(r);
51 | else
52 | input.clear();
53 | return r;
54 | }
55 |
56 | std::string CommandLine::GetLineBuffer() const
57 | { return std::string(); }
58 | }
59 |
--------------------------------------------------------------------------------
/mtp/usb/DeviceBusyException.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_USB_DEVICEBUSYEXCEPTION_H
21 | #define AFTL_MTP_USB_DEVICEBUSYEXCEPTION_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp { namespace usb
28 | {
29 |
30 | struct DeviceBusyException : public std::runtime_error //! Exception thrown when device is busy (claimed by other process)
31 | {
32 | struct ProcessDescriptor
33 | {
34 | int Id;
35 | std::string Name;
36 | };
37 |
38 | std::vector Processes;
39 |
40 | DeviceBusyException(int fd = -1, const std::string &msg = "Device is already used by another process");
41 |
42 | void Kill() const;
43 | static void Kill(const ProcessDescriptor & desc);
44 | static void Kill(const std::vector & processes);
45 | };
46 |
47 | }}
48 |
49 | #endif
50 |
--------------------------------------------------------------------------------
/mtp/backend/posix/Exception.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 |
26 | namespace mtp { namespace posix
27 | {
28 |
29 | Exception::Exception(const std::string &what) throw() : std::runtime_error(what + ": " + GetErrorMessage(errno))
30 | { }
31 |
32 | Exception::Exception(const std::string &what, int returnCode) throw() : std::runtime_error(what + ": " + GetErrorMessage(returnCode))
33 | { }
34 |
35 | std::string Exception::GetErrorMessage(int returnCode)
36 | {
37 | char buf[1024];
38 | #if defined(_GNU_SOURCE) && defined(__GLIBC__)
39 | std::string text(strerror_r(returnCode, buf, sizeof(buf)));
40 | #else
41 | int r = strerror_r(returnCode, buf, sizeof(buf));
42 | std::string text(r == 0? buf: "strerror_r() failed");
43 | #endif
44 | return text;
45 | }
46 |
47 | }}
48 |
--------------------------------------------------------------------------------
/qt/devicesdialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | DevicesDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 615
10 | 447
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | Qt::Horizontal
24 |
25 |
26 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | buttonBox
36 | accepted()
37 | DevicesDialog
38 | accept()
39 |
40 |
41 | 248
42 | 254
43 |
44 |
45 | 157
46 | 274
47 |
48 |
49 |
50 |
51 | buttonBox
52 | rejected()
53 | DevicesDialog
54 | reject()
55 |
56 |
57 | 316
58 | 260
59 |
60 |
61 | 286
62 | 274
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/cli/CommandLine.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_CLI_COMMANDLINE_H
21 | #define AFTL_CLI_COMMANDLINE_H
22 |
23 | #include
24 | #include
25 |
26 | namespace cli
27 | {
28 | class CommandLine
29 | {
30 | public:
31 | typedef std::function Callback;
32 |
33 | protected:
34 | CommandLine();
35 | ~CommandLine();
36 |
37 | private:
38 | static char ** CompletionCallback(const char *text, int start, int end);
39 | static char * CompletionGenerator(const char *text, int state);
40 |
41 | std::string _historyPath;
42 | Callback _callback;
43 |
44 | public:
45 | static CommandLine & Get();
46 |
47 | bool ReadLine(const std::string &prompt, std::string &input);
48 | bool ReadRawLine(std::string &input);
49 | void SetCallback(const Callback &callback)
50 | { _callback = callback; }
51 | std::string GetLineBuffer() const;
52 | };
53 | }
54 |
55 | #endif
56 |
57 |
--------------------------------------------------------------------------------
/cli/Tokenizer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace cli
25 | {
26 | Tokenizer::Tokenizer(const std::string &text, Tokens &tokens): _text(text), _tokens(tokens), _inputPosition(0)
27 | {
28 | void *scanner;
29 | args_lex_init_extra(this, &scanner);
30 | //token_set_debug(1, scanner);
31 | args_lex(scanner);
32 | args_lex_destroy(scanner); //not exception safe
33 | NextArgument();
34 | }
35 |
36 | void Tokenizer::NextArgument()
37 | {
38 | std::string arg = _tempString.str();
39 | if (!arg.empty())
40 | {
41 | _tokens.push_back(arg);
42 | _tempString.str(std::string());
43 | }
44 | }
45 |
46 | size_t Tokenizer::Input(char *buf, size_t max_size)
47 | {
48 | size_t n = std::min(max_size, _text.size() - _inputPosition);
49 | std::copy_n(_text.begin() + _inputPosition, n, buf);
50 | _inputPosition += n;
51 | return n;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/mtp/backend/linux/usb/Endpoint.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LINUX_USB_ENDPOINT_H
21 | #define AFTL_MTP_BACKEND_LINUX_USB_ENDPOINT_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp { namespace usb
28 | {
29 |
30 | class Endpoint;
31 | DECLARE_PTR(Endpoint);
32 |
33 | class Endpoint
34 | {
35 | EndpointDirection _direction;
36 | EndpointType _type;
37 | u8 _addr;
38 | u16 _maxPacketSize;
39 |
40 | public:
41 | Endpoint(const std::string &path);
42 |
43 | u8 GetAddress() const
44 | { return _addr; }
45 |
46 | int GetMaxPacketSize() const
47 | { return _maxPacketSize; }
48 |
49 | EndpointDirection GetDirection() const
50 | { return _direction; }
51 |
52 | EndpointType GetType() const
53 | { return _type; }
54 |
55 | static EndpointPtr TryOpen(const std::string &path);
56 | };
57 | DECLARE_PTR(Endpoint);
58 |
59 | }}
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/mtp/mtpz/TrustedApp.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_MTPZ_TRUSTEDAPP_H
21 | #define AFTL_MTP_MTPZ_TRUSTEDAPP_H
22 |
23 | #include
24 | #include
25 |
26 | namespace mtp
27 | {
28 | class Session;
29 | DECLARE_PTR(Session);
30 |
31 | class TrustedApp;
32 | DECLARE_PTR(TrustedApp);
33 |
34 | class TrustedApp
35 | {
36 | private:
37 | struct Keys;
38 | DECLARE_PTR(Keys);
39 |
40 | private:
41 | SessionPtr _session;
42 | KeysPtr _keys;
43 |
44 | public:
45 | static bool Probe(const SessionPtr & session);
46 |
47 | ~TrustedApp();
48 |
49 | static TrustedAppPtr Create(const SessionPtr & session, const std::string &mtpzDataPath);
50 | void Authenticate();
51 |
52 | bool KeysLoaded() const
53 | { return !!_keys; }
54 |
55 | private:
56 | TrustedApp(const SessionPtr & session, const std::string & mtpzDataPath);
57 | static KeysPtr LoadKeys(const std::string & path);
58 |
59 | };
60 | }
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/mtp/ptp/Response.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace mtp
25 | {
26 | # define R(NAME) case ResponseType::NAME: return #NAME
27 |
28 | std::string ToString(ResponseType responseType)
29 | {
30 | switch(responseType)
31 | {
32 | # define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_TO_STRING(ResponseType, NAME, VALUE)
33 | # include
34 | ENUM_VALUE_TO_STRING_DEFAULT(ResponseType, responseType, 4);
35 | }
36 | }
37 |
38 | namespace
39 | {
40 | std::string FormatMessage(ResponseType r)
41 | {
42 | char buf[1024];
43 | snprintf(buf, sizeof(buf), "invalid response code %s (0x%04hx)", ToString(r).c_str(), static_cast(r));
44 | return buf;
45 | }
46 | }
47 |
48 | InvalidResponseException::InvalidResponseException(const std::string &where, ResponseType type): std::runtime_error(where + ": " + FormatMessage(type)), Type(type)
49 | { }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/mtp/function_invoker.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_FUNCTION_INVOKER_H
21 | #define AFTL_MTP_FUNCTION_INVOKER_H
22 |
23 | #include
24 |
25 | namespace mtp
26 | {
27 |
28 | namespace impl
29 | {
30 | template struct seq {};
31 |
32 | template struct gens : gens {};
33 |
34 | template struct gens<0, S...>{ typedef seq type; };
35 |
36 | template
37 | struct function_invoker
38 | {
39 | std::tuple params;
40 | std::function func;
41 |
42 | R dispatch()
43 | { return call(typename gens::type()); }
44 |
45 | template
46 | R call(seq)
47 | { return func(std::get(params) ...); }
48 | };
49 | }
50 |
51 | template
52 | void invoke(const std::function &func, const TupleType &tuple)
53 | {
54 | impl::function_invoker invoker = { tuple, func };
55 | invoker.dispatch();
56 | }
57 |
58 | }
59 |
60 |
61 | #endif
62 |
63 |
--------------------------------------------------------------------------------
/qt/progressdialog.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_QT_PROGRESSDIALOG_H
21 | #define AFTL_QT_PROGRESSDIALOG_H
22 |
23 | #include
24 |
25 | namespace Ui {
26 | class ProgressDialog;
27 | }
28 |
29 | class QPropertyAnimation;
30 |
31 | class ProgressDialog : public QDialog
32 | {
33 | Q_OBJECT
34 | Q_PROPERTY(float progress READ progress WRITE setProgress);
35 |
36 | public:
37 | explicit ProgressDialog(QWidget *parent = 0, bool showAbort = true);
38 | ~ProgressDialog();
39 |
40 | float progress() const
41 | { return _progress; }
42 |
43 | void setProgress(float value);
44 |
45 | signals:
46 | void abort();
47 |
48 | public slots:
49 | void setSpeed(qint64 speed);
50 | void setFilename(const QString &filename);
51 | void setValue(float current);
52 | virtual void reject();
53 |
54 | private slots:
55 | void onAbortButtonPressed();
56 |
57 | private:
58 | void closeEvent(QCloseEvent *event);
59 |
60 | private:
61 | Ui::ProgressDialog *ui;
62 | QPropertyAnimation *_animation;
63 | float _progress;
64 | int _duration;
65 | };
66 |
67 | #endif // PROGRESSDIALOG_H
68 |
--------------------------------------------------------------------------------
/mtp/ptp/ResponseType.values.h:
--------------------------------------------------------------------------------
1 | ENUM_VALUE(OK, 0x2001)
2 | ENUM_VALUE(GeneralError, 0x2002)
3 | ENUM_VALUE(SessionNotOpen, 0x2003)
4 | ENUM_VALUE(InvalidTransaction, 0x2004)
5 | ENUM_VALUE(OperationNotSupported, 0x2005)
6 | ENUM_VALUE(ParameterNotSupported, 0x2006)
7 | ENUM_VALUE(IncompleteTransfer, 0x2007)
8 | ENUM_VALUE(InvalidStorageID, 0x2008)
9 | ENUM_VALUE(InvalidObjectHandle, 0x2009)
10 | ENUM_VALUE(DevicePropNotSupported, 0x200a)
11 | ENUM_VALUE(InvalidObjectFormatCode, 0x200b)
12 | ENUM_VALUE(StoreFull, 0x200c)
13 | ENUM_VALUE(ObjectWriteProtected, 0x200d)
14 | ENUM_VALUE(StoreReadOnly, 0x200e)
15 | ENUM_VALUE(AccessDenied, 0x200f)
16 | ENUM_VALUE(NoThumbnailPresent, 0x2010)
17 | ENUM_VALUE(SelfTestFailed, 0x2011)
18 | ENUM_VALUE(PartialDeletion, 0x2012)
19 | ENUM_VALUE(StoreNotAvailable, 0x2013)
20 | ENUM_VALUE(SpecificationByFormatUnsupported, 0x2014)
21 | ENUM_VALUE(NoValidObjectInfo, 0x2015)
22 | ENUM_VALUE(InvalidCodeFormat, 0x2016)
23 | ENUM_VALUE(UnknownVendorCode, 0x2017)
24 | ENUM_VALUE(CaptureAlreadyTerminated, 0x2018)
25 | ENUM_VALUE(DeviceBusy, 0x2019)
26 | ENUM_VALUE(InvalidParentObject, 0x201a)
27 | ENUM_VALUE(InvalidDevicePropFormat, 0x201b)
28 | ENUM_VALUE(InvalidDevicePropValue, 0x201c)
29 | ENUM_VALUE(InvalidParameter, 0x201d)
30 | ENUM_VALUE(SessionAlreadyOpen, 0x201e)
31 | ENUM_VALUE(TransactionCancelled, 0x201f)
32 | ENUM_VALUE(SpecificationOfDestinationUnsupported, 0x2020)
33 | ENUM_VALUE(InvalidServiceID, 0xa301)
34 | ENUM_VALUE(InvalidServicePropCode, 0xa302)
35 | ENUM_VALUE(TinyCLRNotResponding, 0xa401)
36 | ENUM_VALUE(NoDataWaiting, 0xa402)
37 | ENUM_VALUE(InvalidObjectPropCode, 0xa801)
38 | ENUM_VALUE(InvalidObjectPropFormat, 0xa802)
39 | ENUM_VALUE(InvalidObjectPropValue, 0xa803)
40 | ENUM_VALUE(InvalidObjectReference, 0xa804)
41 | ENUM_VALUE(GroupNotSupported, 0xa805)
42 | ENUM_VALUE(InvalidDataset, 0xa806)
43 | ENUM_VALUE(UnsupportedSpecByGroup, 0xa807)
44 | ENUM_VALUE(UnsupportedSpecByDepth, 0xa808)
45 | ENUM_VALUE(ObjectTooLarge, 0xa809)
46 | ENUM_VALUE(ObjectPropNotSupported, 0xa80)
47 |
--------------------------------------------------------------------------------
/fuse/Exception.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_FUSE_EXCEPTION_H
21 | #define AFTL_FUSE_EXCEPTION_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | namespace mtp { namespace fuse
29 | {
30 |
31 | class Exception : public std::runtime_error
32 | {
33 | public:
34 | Exception(const std::string &what) throw() : std::runtime_error(what + ": " + GetErrorMessage(errno)) { }
35 | Exception(const std::string &what, int returnCode) throw() : std::runtime_error(what + ": " + GetErrorMessage(returnCode)) { }
36 | static std::string GetErrorMessage(int returnCode)
37 | {
38 | char buf[1024];
39 | #if defined(_GNU_SOURCE) && defined(__GLIBC__)
40 | std::string text(strerror_r(returnCode, buf, sizeof(buf)));
41 | #else
42 | int r = strerror_r(returnCode, buf, sizeof(buf));
43 | std::string text(r == 0? buf: "strerror_r() failed");
44 | #endif
45 | return text;
46 | }
47 | };
48 |
49 | #define FUSE_CALL(...) do { int _r = __VA_ARGS__ ; if (_r < 0) throw mtp::fuse::Exception(#__VA_ARGS__ " failed", -_r); } while(false)
50 |
51 | }}
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/mtp/ptp/Messages.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | namespace mtp { namespace msg
7 | {
8 | bool DeviceInfo::Supports(OperationCode opcode) const
9 | {
10 | auto i = std::find(OperationsSupported.begin(), OperationsSupported.end(), opcode);
11 | return i != OperationsSupported.end();
12 | }
13 |
14 | bool DeviceInfo::Supports(DeviceProperty property) const
15 | {
16 | auto i = std::find(DevicePropertiesSupported.begin(), DevicePropertiesSupported.end(), property);
17 | return i != DevicePropertiesSupported.end();
18 | }
19 |
20 | bool DeviceInfo::Supports(EventCode event) const
21 | {
22 | auto i = std::find(EventsSupported.begin(), EventsSupported.end(), event);
23 | return i != EventsSupported.end();
24 | }
25 |
26 | bool DeviceInfo::Supports(ObjectFormat format) const
27 | {
28 | auto i = std::find(ImageFormats.begin(), ImageFormats.end(), format);
29 | return i != ImageFormats.end();
30 | }
31 |
32 | bool DeviceInfo::Matches(const std::string & haystack, const std::string & needle)
33 | { return strcasestr(haystack.c_str(), needle.c_str()); }
34 |
35 | bool DeviceInfo::Matches(const std::string & filter) const
36 | {
37 | if (filter.empty())
38 | return true;
39 | auto fsname = GetFilesystemFriendlyName();
40 | return Matches(fsname, filter);
41 | }
42 |
43 |
44 | namespace
45 | {
46 | std::string Strip(std::string str)
47 | {
48 | str.erase(std::remove_if(str.begin(), str.end(), isspace), str.end());
49 | return str;
50 | }
51 | }
52 |
53 | std::string DeviceInfo::GetFilesystemFriendlyName() const
54 | {
55 | std::stringstream ss;
56 | ss << Strip(Manufacturer);
57 | ss << '-';
58 | ss << Strip(Model);
59 | ss << '-';
60 | ss << Strip(SerialNumber);
61 | return ss.str();
62 | }
63 |
64 | bool ObjectPropertiesSupported::Supports(ObjectProperty prop) const
65 | { return std::find(ObjectPropertyCodes.begin(), ObjectPropertyCodes.end(), prop) != ObjectPropertyCodes.end(); }
66 |
67 |
68 | }}
69 |
--------------------------------------------------------------------------------
/mtp/backend/linux/usb/Interface.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_BACKEND_LINUX_USB_INTERFACE_H
21 | #define AFTL_MTP_BACKEND_LINUX_USB_INTERFACE_H
22 |
23 | #include
24 | #include
25 | #include //remove me later, when Endpoint.h will be available in all ports
26 | #include
27 |
28 | namespace mtp { namespace usb
29 | {
30 |
31 | class Endpoint;
32 | DECLARE_PTR(Endpoint);
33 |
34 | class Configuration;
35 | DECLARE_PTR(Configuration);
36 |
37 | class Interface
38 | {
39 | std::string _path;
40 | std::vector _endpoints;
41 | u8 _class;
42 | u8 _subclass;
43 | int _index;
44 |
45 |
46 | public:
47 | Interface(int index, const std::string &path);
48 |
49 | u8 GetClass() const
50 | { return _class; }
51 |
52 | u8 GetSubclass() const
53 | { return _subclass; }
54 |
55 | int GetIndex() const
56 | { return _index; }
57 |
58 | EndpointPtr GetEndpoint(int idx) const
59 | { return _endpoints.at(idx); }
60 |
61 | int GetEndpointsCount() const
62 | { return _endpoints.size(); }
63 | };
64 | DECLARE_PTR(Interface);
65 |
66 | }}
67 |
68 | #endif
69 |
--------------------------------------------------------------------------------
/qt/renamedialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | RenameDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 433
10 | 99
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 |
20 | Rename Object
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Qt::Horizontal
33 |
34 |
35 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | buttonBox
45 | accepted()
46 | RenameDialog
47 | accept()
48 |
49 |
50 | 248
51 | 254
52 |
53 |
54 | 157
55 | 274
56 |
57 |
58 |
59 |
60 | buttonBox
61 | rejected()
62 | RenameDialog
63 | reject()
64 |
65 |
66 | 316
67 | 260
68 |
69 |
70 | 286
71 | 274
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/mtp/metadata/Metadata.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #ifdef HAVE_TAGLIB
5 | # include
6 | # include
7 | # include
8 | #endif
9 |
10 | namespace mtp
11 | {
12 | #ifdef HAVE_TAGLIB
13 | MetadataPtr Metadata::Read(const std::string & path)
14 | {
15 | TagLib::FileRef f(path.c_str());
16 | auto tag = f.tag();
17 | if (f.isNull() || !tag)
18 | return nullptr;
19 |
20 | auto meta = std::make_shared();
21 | auto artist = tag->artist();
22 |
23 | const auto & props = tag->properties();
24 | auto album_it = props.find("ALBUMARTIST");
25 | if (album_it == props.end())
26 | album_it = props.find("ALBUM ARTIST");
27 | if (album_it == props.end())
28 | album_it = props.find("MUSICBRAINZ_ALBUMARTIST");
29 | if (album_it != props.end())
30 | artist = album_it->second.toString();
31 |
32 | meta->Title = tag->title().to8Bit(true);
33 | meta->Artist = artist.to8Bit(true);
34 | meta->Album = tag->album().to8Bit(true);
35 | meta->Genre = tag->genre().to8Bit(true);
36 | meta->Year = tag->year();
37 | meta->Track = tag->track();
38 |
39 | #if TAGLIB_MAJOR_VERSION >= 2
40 | for(auto & props : tag->complexProperties("PICTURE"))
41 | {
42 | auto &picture = meta->Picture;
43 | for(auto &kv : props)
44 | {
45 | auto &name = kv.first;
46 | auto &value = kv.second;
47 | if (name == "data") {
48 | auto data = value.toByteVector();
49 | picture.Data.assign(data.begin(), data.end());
50 | } else if (name == "pictureType") {
51 | picture.Type = value.toString().to8Bit(true);
52 | } else if (name == "mimeType") {
53 | picture.MimeType = value.toString().to8Bit(true);
54 | } else if (name == "description") {
55 | picture.Description = value.toString().to8Bit(true);
56 | } else {
57 | mtp::debug("unhandled PICTURE property ", name.toCString(true));
58 | }
59 | }
60 | }
61 | #endif
62 | return meta;
63 | }
64 |
65 | #else
66 | MetadataPtr Metadata::Read(const std::string & path)
67 | { return nullptr; }
68 | #endif
69 | }
70 |
--------------------------------------------------------------------------------
/mtp/ptp/DeviceProperty.values.h:
--------------------------------------------------------------------------------
1 | ENUM_VALUE(Undefined, 0x5000)
2 | ENUM_VALUE(BatteryLevel, 0x5001)
3 | ENUM_VALUE(FunctionalMode, 0x5002) //0 - normal, 1 - sleeping
4 | ENUM_VALUE(ImageSize, 0x5003)
5 | ENUM_VALUE(CompressionSetting, 0x5004)
6 | ENUM_VALUE(WhiteBalance, 0x5005)
7 | ENUM_VALUE(RgbGain, 0x5006)
8 | ENUM_VALUE(FNumber, 0x5007)
9 | ENUM_VALUE(FocalLength, 0x5008)
10 | ENUM_VALUE(FocusDistance, 0x5009)
11 | ENUM_VALUE(FocusMode, 0x500a)
12 | ENUM_VALUE(ExposureMeteringMode, 0x500b)
13 | ENUM_VALUE(FlashMode, 0x500c)
14 | ENUM_VALUE(ExposureTime, 0x500d)
15 | ENUM_VALUE(ExposureProgramMode, 0x500e)
16 | ENUM_VALUE(ExposureIndex, 0x500f)
17 | ENUM_VALUE(ExposureBiasCompensation, 0x5010)
18 | ENUM_VALUE(Datetime, 0x5011)
19 | ENUM_VALUE(CaptureDelay, 0x5012)
20 | ENUM_VALUE(StillCaptureMode, 0x5013)
21 | ENUM_VALUE(Contrast, 0x5014)
22 | ENUM_VALUE(Sharpness, 0x5015)
23 | ENUM_VALUE(DigitalZoom, 0x5016)
24 | ENUM_VALUE(EffectMode, 0x5017)
25 | ENUM_VALUE(BurstNumber, 0x5018)
26 | ENUM_VALUE(BurstInterval, 0x5019)
27 | ENUM_VALUE(TimelapseNumber, 0x501a)
28 | ENUM_VALUE(TimelapseInterval, 0x501b)
29 | ENUM_VALUE(FocusMeteringMode, 0x501c)
30 | ENUM_VALUE(UploadUrl, 0x501d)
31 | ENUM_VALUE(Artist, 0x501e)
32 | ENUM_VALUE(CopyrightInfo, 0x501f)
33 |
34 | ENUM_VALUE(SecureTime, 0xd101)
35 | ENUM_VALUE(DeviceCertificate, 0xd102)
36 | ENUM_VALUE(RevocationInfo, 0xd103)
37 | ENUM_VALUE(PlaysForSureID, 0xd131)
38 |
39 | ENUM_VALUE(DeviceEUI64, 0xd210)
40 | ENUM_VALUE(FirmwareVersion, 0xd233)
41 | ENUM_VALUE(SerialNumber, 0xd235)
42 |
43 | ENUM_VALUE(FunctionalID, 0xd301)
44 | ENUM_VALUE(ModelID, 0xd302)
45 | ENUM_VALUE(UseDeviceStage, 0xd303)
46 |
47 | ENUM_VALUE(SynchronizationPartner, 0xd401)
48 | ENUM_VALUE(DeviceFriendlyName, 0xd402)
49 | ENUM_VALUE(Volume, 0xd403)
50 | ENUM_VALUE(SupportedFormatsOrdered, 0xd404)
51 | ENUM_VALUE(DeviceIcon, 0xd405)
52 | ENUM_VALUE(SessionInitiatorVersionInfo, 0xd406)
53 | ENUM_VALUE(PerceivedDeviceType, 0xd407)
54 | ENUM_VALUE(PlaybackRate, 0xd410)
55 | ENUM_VALUE(PlaybackObject, 0xd411)
56 | ENUM_VALUE(PlaybackContainerIndex, 0xd412)
57 | ENUM_VALUE(PlaybackPosition, 0xd413)
58 |
--------------------------------------------------------------------------------
/qt/createdirectorydialog.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | CreateDirectoryDialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 401
10 | 99
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 |
20 | Create New Directory
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | Qt::Horizontal
33 |
34 |
35 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 | buttonBox
45 | accepted()
46 | CreateDirectoryDialog
47 | accept()
48 |
49 |
50 | 248
51 | 254
52 |
53 |
54 | 157
55 | 274
56 |
57 |
58 |
59 |
60 | buttonBox
61 | rejected()
62 | CreateDirectoryDialog
63 | reject()
64 |
65 |
66 | 316
67 | 260
68 |
69 |
70 | 286
71 | 274
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/mtp/backend/libusb/usb/DeviceDescriptor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 |
23 | namespace mtp { namespace usb
24 | {
25 | DeviceDescriptor::DeviceDescriptor(libusb_device *dev): _dev(dev)
26 | {
27 | USB_CALL(libusb_get_device_descriptor(_dev, &_descriptor));
28 | }
29 |
30 | ConfigurationPtr DeviceDescriptor::GetConfiguration(int conf)
31 | {
32 | libusb_config_descriptor *desc;
33 | USB_CALL(libusb_get_config_descriptor(_dev, conf, &desc));
34 | return std::make_shared(desc);
35 | }
36 |
37 | DevicePtr DeviceDescriptor::Open(ContextPtr context)
38 | {
39 | libusb_device_handle *handle;
40 | USB_CALL(libusb_open(_dev, &handle));
41 | return std::make_shared(context, handle);
42 | }
43 |
44 | DevicePtr DeviceDescriptor::TryOpen(ContextPtr context)
45 | {
46 | libusb_device_handle *handle;
47 | int r = libusb_open(_dev, &handle);
48 | return r == 0? std::make_shared(context, handle): nullptr;
49 | }
50 |
51 | DeviceDescriptor::~DeviceDescriptor()
52 | { libusb_unref_device(_dev); }
53 |
54 | ByteArray DeviceDescriptor::GetDescriptor() const
55 | { throw std::runtime_error("not possible with libusb"); }
56 |
57 | }}
58 |
--------------------------------------------------------------------------------
/mtp/log.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 | #include
20 | #include
21 |
22 | namespace mtp
23 | {
24 |
25 | bool g_debug = false;
26 |
27 | void HexDump(std::stringstream & ss, const std::string &prefix, size_t size, InputStream & is)
28 | {
29 | ss << prefix << "[" << size << "]:\n";
30 | size_t i;
31 |
32 | std::string chars;
33 | chars.reserve(16);
34 | for(i = 0; i < size; ++i)
35 | {
36 | bool first = ((i & 0xf) == 0);
37 | bool last = ((i & 0xf) == 0x0f);
38 | if (first)
39 | ss << hex(i, 8) << ": ";
40 |
41 | u8 value = is.Read8();
42 | ss << hex(value, 2);
43 | chars.push_back(value < 0x20 || value >= 0x7f? '.': value);
44 | if (last)
45 | {
46 | ss << " " << chars << "\n";
47 | chars.clear();
48 | }
49 | else
50 | ss << " ";
51 | }
52 | if (chars.size())
53 | {
54 | ss << std::string((size_t)(16 - chars.size()) * 3, ' ') << chars << "\n";
55 | }
56 | }
57 |
58 | void HexDump(const std::string &prefix, const ByteArray &data, bool force)
59 | {
60 | if (!g_debug && !force)
61 | return;
62 |
63 | std::stringstream ss;
64 | InputStream is(data);
65 | HexDump(ss, prefix, data.size(), is);
66 | error(ss.str());
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/mtp/ptp/PipePacketer.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_PIPEPACKETER_H
21 | #define AFTL_MTP_PTP_PIPEPACKETER_H
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | namespace mtp
28 | {
29 | class Device;
30 | DECLARE_PTR(Device);
31 |
32 | class PipePacketer //! BulkPipe high-level controller class, package all read/write operation into streams and send it to BulkPipe
33 | {
34 | usb::BulkPipePtr _pipe;
35 |
36 | public:
37 | PipePacketer(const usb::BulkPipePtr &pipe): _pipe(pipe) { }
38 |
39 | usb::BulkPipePtr GetPipe() const
40 | { return _pipe; }
41 |
42 | void Write(const IObjectInputStreamPtr &inputStream, int timeout);
43 | void Write(const ByteArray &data, int timeout);
44 |
45 | void Read(u32 transaction, const IObjectOutputStreamPtr &outputStream, ResponseType &code, ByteArray &response, int timeout);
46 | void Read(u32 transaction, ByteArray &data, ResponseType &code, ByteArray &response, int timeout);
47 |
48 | void PollEvent(int timeout);
49 | void Abort(u32 transaction, int timeout);
50 |
51 | private:
52 | void ReadMessage(const IObjectOutputStreamPtr &outputStream, int timeout);
53 | };
54 |
55 | }
56 |
57 | #endif
58 |
--------------------------------------------------------------------------------
/fuse/FuseDirectory.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_FUSE_FUSEDIRECTORY_H
21 | #define AFTL_FUSE_FUSEDIRECTORY_H
22 |
23 | #include
24 |
25 | #include
26 |
27 | namespace mtp { namespace fuse
28 | {
29 |
30 | using CharArray = std::vector;
31 |
32 | struct FuseDirectory
33 | {
34 | fuse_req_t Request;
35 |
36 | FuseDirectory(fuse_req_t request): Request(request) { }
37 |
38 | void Add(CharArray & data, const std::string &name, const struct stat & entry)
39 | {
40 | if (data.empty())
41 | data.reserve(4096);
42 | size_t size = fuse_add_direntry(Request, NULL, 0, name.c_str(), NULL, 0);
43 | size_t offset = data.size();
44 | data.resize(data.size() + size);
45 | fuse_add_direntry(Request, data.data() + offset, size, name.c_str(), &entry, data.size()); //request is not used inside fuse here, so we could cache resulting dirent data
46 | }
47 |
48 | static void Reply(fuse_req_t req, const CharArray &data, off_t off, size_t size)
49 | {
50 | if (off >= (off_t)data.size())
51 | FUSE_CALL(fuse_reply_buf(req, NULL, 0));
52 | else
53 | {
54 | FUSE_CALL(fuse_reply_buf(req, data.data() + off, std::min(size, data.size() - off)));
55 | }
56 | }
57 | };
58 |
59 | }}
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/mtp/ptp/Container.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_CONTAINER_H
21 | #define AFTL_MTP_PTP_CONTAINER_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | namespace mtp
30 | {
31 | struct Container //! MTP container for MTP message, appends type and size
32 | {
33 | ByteArray Data;
34 |
35 | void WriteSize(OutputStream &stream, u64 size)
36 | {
37 | if (size > MaxObjectSize)
38 | size = MaxObjectSize;
39 | stream << (u32)size;
40 | }
41 |
42 | template
43 | Container(const Message &msg)
44 | {
45 | OutputStream stream(Data);
46 | WriteSize(stream, msg.Data.size() + 6);
47 | stream << Message::Type;
48 | std::copy(msg.Data.begin(), msg.Data.end(), std::back_inserter(Data));
49 | }
50 |
51 | template
52 | Container(const Message &msg, IObjectInputStreamPtr inputStream)
53 | {
54 | OutputStream stream(Data);
55 | WriteSize(stream, inputStream->GetSize() + msg.Data.size() + 6);
56 | stream << Message::Type;
57 | std::copy(msg.Data.begin(), msg.Data.end(), std::back_inserter(Data));
58 | }
59 | };
60 |
61 | }
62 |
63 | #endif /* CONTAINER_H */
64 |
--------------------------------------------------------------------------------
/mtp/ptp/Device.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_DEVICE_H
21 | #define AFTL_MTP_PTP_DEVICE_H
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | namespace mtp
29 | {
30 | class Device //! Generic MTP Device class representing physical device, creates \ref Session
31 | {
32 | PipePacketer _packeter;
33 |
34 | private:
35 | static u8 GetInterfaceStringIndex(usb::DeviceDescriptorPtr desc, u8 number);
36 |
37 | public:
38 | Device(usb::BulkPipePtr pipe);
39 |
40 | msg::DeviceInfo GetInfo();
41 |
42 | ///This could be very expensive, it calls GetDeviceInfo
43 | bool Matches(const std::string & filter);
44 |
45 | SessionPtr OpenSession(u32 sessionId, int timeout = Session::DefaultTimeout);
46 |
47 | static DevicePtr Open(usb::ContextPtr context, usb::DeviceDescriptorPtr desc, bool claimInterface = true, bool resetDevice = false); //fixme: add flags here
48 | static DevicePtr FindFirst(usb::ContextPtr context, const std::string & filter = std::string(), bool claimInterface = true, bool resetDevice = false);
49 | static DevicePtr FindFirst(const std::string & filter = std::string(), bool claimInterface = true, bool resetDevice = false);
50 | };
51 | }
52 |
53 | #endif
54 |
--------------------------------------------------------------------------------
/mtp/ptp/ObjectId.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_OBJECTID_H
21 | #define AFTL_MTP_PTP_OBJECTID_H
22 |
23 | #include
24 |
25 | namespace mtp
26 | {
27 |
28 | #define DECLARE_ID(NAME, TYPE, MEMBER) \
29 | struct NAME { \
30 | TYPE MEMBER; \
31 | static const TYPE Canary = 0xaaaaaaaau; \
32 | \
33 | NAME ( ): MEMBER ( Canary ) { } \
34 | explicit NAME ( TYPE id ): MEMBER ( id ) { } \
35 | \
36 | bool operator == (const NAME &o) const \
37 | { return MEMBER == o.MEMBER; } \
38 | bool operator != (const NAME &o) const \
39 | { return !((*this) == o); } \
40 | bool operator < (const NAME &o) const \
41 | { return MEMBER < o.MEMBER; } \
42 | }; \
43 | template Stream & operator >> (Stream &stream, NAME & value) \
44 | { stream >> value. MEMBER ; return stream; } \
45 | template Stream & operator << (Stream &stream, const NAME &value) \
46 | { stream << value. MEMBER ; return stream; } \
47 |
48 |
49 | DECLARE_ID(ObjectId, mtp::u32, Id);
50 | DECLARE_ID(StorageId, mtp::u32, Id);
51 |
52 | #undef DECLARE_ID
53 |
54 | }
55 |
56 | namespace std
57 | {
58 | template<> struct hash
59 | { public: size_t operator()(const mtp::ObjectId &id) const { return id.Id; } };
60 | template<> struct hash
61 | { public: size_t operator()(const mtp::StorageId &id) const { return id.Id; } };
62 | }
63 | #endif
64 |
65 |
66 |
--------------------------------------------------------------------------------
/cmake/FindReadline.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find readline include dirs and libraries
2 | #
3 | # Usage of this module as follows:
4 | #
5 | # find_package(Readline)
6 | #
7 | # Variables used by this module, they can change the default behaviour and need
8 | # to be set before calling find_package:
9 | #
10 | # Readline_ROOT_DIR Set this variable to the root installation of
11 | # readline if the module has problems finding the
12 | # proper installation path.
13 | #
14 | # Variables defined by this module:
15 | #
16 | # READLINE_FOUND System has readline, include and lib dirs found
17 | # Readline_INCLUDE_DIR The readline include directories.
18 | # Readline_LIBRARY The readline library.
19 |
20 | find_path(Readline_ROOT_DIR
21 | NAMES include/readline/readline.h includes/editline/readline.h
22 | develop/headers/x86/readline/readline.h develop/headers/x86/editline/readline.h
23 | develop/headers/readline/readline.h develop/headers/editline/readline.h
24 | )
25 |
26 | find_path(Readline_INCLUDE_DIR
27 | NAMES readline.h
28 | HINTS ${Readline_ROOT_DIR}/include/readline ${Readline_ROOT_DIR}/develop/headers/x86/readline
29 | ${Readline_ROOT_DIR}/develop/headers/readline
30 | ${Readline_ROOT_DIR}/include/editline ${Readline_ROOT_DIR}/develop/headers/x86/editline
31 | ${Readline_ROOT_DIR}/develop/headers/editline
32 | )
33 |
34 | if(EXISTS ${Readline_INCLUDE_DIR}/history.h)
35 | add_definitions(-DHAVE_READLINE_HISTORY_H=1)
36 | endif()
37 |
38 | find_library(Readline_LIBRARY
39 | NAMES readline edit
40 | HINTS ${Readline_ROOT_DIR}/lib ${Readline_ROOT_DIR}/develop/lib/x86
41 | ${Readline_ROOT_DIR}/develop/lib
42 | )
43 |
44 | if(Readline_INCLUDE_DIR AND Readline_LIBRARY)
45 | set(READLINE_FOUND TRUE)
46 | else(Readline_INCLUDE_DIR AND Readline_LIBRARY)
47 | FIND_LIBRARY(Readline_LIBRARY NAMES readline edit)
48 | include(FindPackageHandleStandardArgs)
49 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG Readline_INCLUDE_DIR Readline_LIBRARY )
50 | MARK_AS_ADVANCED(Readline_INCLUDE_DIR Readline_LIBRARY)
51 | endif(Readline_INCLUDE_DIR AND Readline_LIBRARY)
52 |
53 | mark_as_advanced(
54 | Readline_ROOT_DIR
55 | Readline_INCLUDE_DIR
56 | Readline_LIBRARY
57 | )
58 |
--------------------------------------------------------------------------------
/mtp/ptp/Response.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #ifndef AFTL_MTP_PTP_RESPONSE_H
21 | #define AFTL_MTP_PTP_RESPONSE_H
22 |
23 | #include
24 | #include
25 |
26 | namespace mtp
27 | {
28 | enum struct ContainerType : u16
29 | {
30 | Command = 1,
31 | Data = 2,
32 | Response = 3,
33 | Event = 4,
34 | };
35 | DECLARE_ENUM(ContainerType, u16);
36 |
37 | enum struct ResponseType : u16
38 | {
39 | #define ENUM_VALUE(NAME, VALUE) ENUM_VALUE_DECL(NAME, VALUE)
40 | # include
41 | #undef ENUM_VALUE
42 | };
43 | std::string ToString(ResponseType response);
44 | DECLARE_ENUM(ResponseType, u16);
45 |
46 | struct Response //! MTP Response class
47 | {
48 | static const size_t Size = 8;
49 |
50 | mtp::ContainerType ContainerType;
51 | mtp::ResponseType ResponseType;
52 | u32 Transaction;
53 |
54 | Response() { }
55 |
56 | template
57 | Response(Stream &stream)
58 | { Read(stream); }
59 |
60 | template
61 | void Read(Stream &stream)
62 | {
63 | stream >> ContainerType;
64 | stream >> ResponseType;
65 | stream >> Transaction;
66 | }
67 | };
68 |
69 | struct InvalidResponseException : public std::runtime_error //!Invalid MTP Response Exception
70 | {
71 | ResponseType Type;
72 | InvalidResponseException(const std::string &where, ResponseType type);
73 | };
74 |
75 | }
76 |
77 | #endif /* RESPONSE_H */
78 |
--------------------------------------------------------------------------------
/mtp/backend/linux/usb/Context.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of Android File Transfer For Linux.
3 | Copyright (C) 2015-2020 Vladimir Menshakov
4 |
5 | This library is free software; you can redistribute it and/or modify it
6 | under the terms of the GNU Lesser General Public License as published by
7 | the Free Software Foundation; either version 2.1 of the License,
8 | or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful, but
11 | WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public License
16 | along with this library; if not, write to the Free Software Foundation,
17 | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | #include
21 | #include
22 | #include
23 | #include