mtp

Merge lp:~cyphermox/mtp/design-fixes into lp:mtp

Proposed by Mathieu Trudel-Lapierre
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 33
Merged at revision: 29
Proposed branch: lp:~cyphermox/mtp/design-fixes
Merge into: lp:mtp
Prerequisite: lp:~cyphermox/mtp/relicense
Diff against target: 197 lines (+50/-15)
6 files modified
CMakeLists.txt (+5/-0)
debian/control (+1/-0)
server/CMakeLists.txt (+1/-0)
server/UbuntuMtpDatabase.h (+25/-4)
server/server.cpp (+14/-8)
src/MtpServer.cpp (+4/-3)
To merge this branch: bzr merge lp:~cyphermox/mtp/design-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ricardo Salveti (community) Approve
Review via email: mp+185548@code.launchpad.net

This proposal supersedes a proposal from 2013-09-13.

Commit message

Expose only Music, Videos, Pictures, Downloads and Documents, plus set the name of the device storage to the device model

Description of the change

Expose only Music, Videos, Pictures, Downloads and Documents, plus set the name of the device storage to the device model

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
lp:~cyphermox/mtp/design-fixes updated
32. By Mathieu Trudel-Lapierre

Only add content directories if they are found.

33. By Mathieu Trudel-Lapierre

Remove extra whitespace.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Good, tested, works fine.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-09-12 17:41:22 +0000
+++ CMakeLists.txt 2013-09-13 17:12:07 +0000
@@ -63,6 +63,11 @@
63 ${MTP_SRCS}63 ${MTP_SRCS}
64)64)
6565
66target_link_libraries(
67 mtpserver
68 android-properties
69)
70
66set_target_properties(71set_target_properties(
67 mtpserver72 mtpserver
6873
6974
=== modified file 'debian/control'
--- debian/control 2013-09-12 17:41:22 +0000
+++ debian/control 2013-09-13 17:12:07 +0000
@@ -8,6 +8,7 @@
8 libboost-dev,8 libboost-dev,
9 libboost-filesystem-dev,9 libboost-filesystem-dev,
10 libboost-test-dev,10 libboost-test-dev,
11 libandroid-properties-dev,
11Standards-Version: 3.9.412Standards-Version: 3.9.4
12Homepage: http://launchpad.net/mtp13Homepage: http://launchpad.net/mtp
13# If you aren't ~phablet-team but need to upload packaging changes,14# If you aren't ~phablet-team but need to upload packaging changes,
1415
=== modified file 'server/CMakeLists.txt'
--- server/CMakeLists.txt 2013-09-12 17:41:22 +0000
+++ server/CMakeLists.txt 2013-09-13 17:12:07 +0000
@@ -11,6 +11,7 @@
11 mtp-server11 mtp-server
12 mtpserver12 mtpserver
13 usbhost13 usbhost
14 android-properties
14 ${Boost_LIBRARIES}15 ${Boost_LIBRARIES}
15 ${Boost_system_LIBRARIES}16 ${Boost_system_LIBRARIES}
16 ${Boost_filesystem_LIBRARIES}17 ${Boost_filesystem_LIBRARIES}
1718
=== modified file 'server/UbuntuMtpDatabase.h'
--- server/UbuntuMtpDatabase.h 2013-09-13 17:12:07 +0000
+++ server/UbuntuMtpDatabase.h 2013-09-13 17:12:07 +0000
@@ -97,13 +97,25 @@
97 void readFiles(const std::string& sourcedir)97 void readFiles(const std::string& sourcedir)
98 {98 {
99 path p (sourcedir);99 path p (sourcedir);
100 DbEntry entry;
101 MtpObjectHandle handle = counter++;
100102
101 try {103 try {
102 if (exists(p)) {104 if (exists(p)) {
103 if (is_directory(p)) {105 if (is_directory(p)) {
104 std::cout << p << " is a directory containing:\n";106 std::cout << p << " is a directory containing:\n";
105107
106 parse_directory (p, MTP_PARENT_ROOT);108 entry.storage_id = MTP_STORAGE_FIXED_RAM;
109 entry.parent = MTP_PARENT_ROOT;
110 entry.object_name = p.filename().string();
111 entry.display_name = p.filename().string();
112 entry.path = p.string();
113 entry.object_format = MTP_FORMAT_ASSOCIATION;
114 entry.object_size = 0;
115
116 db.insert( std::pair<MtpObjectHandle, DbEntry>(handle, entry) );
117
118 parse_directory (p, handle);
107 }119 }
108 } else120 } else
109 std::cout << p << " does not exist\n";121 std::cout << p << " does not exist\n";
@@ -117,8 +129,15 @@
117public:129public:
118 UbuntuMtpDatabase(const char *dir) : counter(1)130 UbuntuMtpDatabase(const char *dir) : counter(1)
119 {131 {
132 std::string basedir (dir);
133
120 db = std::map<MtpObjectHandle, DbEntry>();134 db = std::map<MtpObjectHandle, DbEntry>();
121 readFiles(std::string(dir));135
136 readFiles(basedir + "/Documents");
137 readFiles(basedir + "/Music");
138 readFiles(basedir + "/Videos");
139 readFiles(basedir + "/Pictures");
140 readFiles(basedir + "/Downloads");
122 141
123 std::cout << __PRETTY_FUNCTION__ << ": object count:" << db.size() << std::endl;142 std::cout << __PRETTY_FUNCTION__ << ": object count:" << db.size() << std::endl;
124 }143 }
@@ -136,12 +155,14 @@
136 {155 {
137 DbEntry entry;156 DbEntry entry;
138 MtpObjectHandle handle = counter;157 MtpObjectHandle handle = counter;
139 MtpObjectHandle parent_id = parent == 0 ? MTP_PARENT_ROOT : parent;158
159 if (parent == 0)
160 return kInvalidObjectHandle;
140161
141 std::cout << __PRETTY_FUNCTION__ << ": " << path << " - " << parent << std::endl;162 std::cout << __PRETTY_FUNCTION__ << ": " << path << " - " << parent << std::endl;
142163
143 entry.storage_id = storage;164 entry.storage_id = storage;
144 entry.parent = parent_id;165 entry.parent = parent;
145 entry.object_name = std::string(basename(path.c_str()));166 entry.object_name = std::string(basename(path.c_str()));
146 entry.display_name = std::string(basename(path.c_str()));167 entry.display_name = std::string(basename(path.c_str()));
147 entry.path = path;168 entry.path = path;
148169
=== modified file 'server/server.cpp'
--- server/server.cpp 2013-09-13 17:12:07 +0000
+++ server/server.cpp 2013-09-13 17:12:07 +0000
@@ -29,6 +29,8 @@
29#include <unistd.h>29#include <unistd.h>
30#include <pwd.h>30#include <pwd.h>
3131
32#include <hybris/properties/properties.h>
33
32namespace34namespace
33{35{
34struct FileSystemConfig36struct FileSystemConfig
@@ -44,6 +46,7 @@
44int main(int argc, char** argv)46int main(int argc, char** argv)
45{47{
46 struct passwd *userdata = getpwuid (getuid());48 struct passwd *userdata = getpwuid (getuid());
49 char product_name[PROP_VALUE_MAX];
47 int fd = open("/dev/mtp_usb", O_RDWR);50 int fd = open("/dev/mtp_usb", O_RDWR);
48 51
49 if (fd < 0)52 if (fd < 0)
@@ -51,14 +54,6 @@
51 std::cout << "Error opening /dev/mtp_usb, aborting now..." << std::endl;54 std::cout << "Error opening /dev/mtp_usb, aborting now..." << std::endl;
52 }55 }
53 56
54 home_storage = new android::MtpStorage(
55 MTP_STORAGE_FIXED_RAM,
56 userdata->pw_dir,
57 userdata->pw_name,
58 1024 * 1024 * 100, /* 100 MB reserved space, to avoid filling the disk */
59 false,
60 1024 * 1024 * 1024 * 2 /* 2GB arbitrary max file size */);
61
62 std::shared_ptr<android::MtpServer> server57 std::shared_ptr<android::MtpServer> server
63 {58 {
64 new android::MtpServer(59 new android::MtpServer(
@@ -69,6 +64,17 @@
69 FileSystemConfig::file_perm, 64 FileSystemConfig::file_perm,
70 FileSystemConfig::directory_perm)65 FileSystemConfig::directory_perm)
71 };66 };
67
68 property_get ("ro.product.model", product_name, "Ubuntu Touch device");
69
70 home_storage = new android::MtpStorage(
71 MTP_STORAGE_FIXED_RAM,
72 userdata->pw_dir,
73 product_name,
74 1024 * 1024 * 100, /* 100 MB reserved space, to avoid filling the disk */
75 false,
76 1024 * 1024 * 1024 * 2 /* 2GB arbitrary max file size */);
77
72 server->addStorage(home_storage);78 server->addStorage(home_storage);
73 server->run();79 server->run();
7480
7581
=== modified file 'src/MtpServer.cpp'
--- src/MtpServer.cpp 2013-06-13 10:22:21 +0000
+++ src/MtpServer.cpp 2013-09-13 17:12:07 +0000
@@ -39,6 +39,8 @@
3939
40#include <linux/usb/f_mtp.h>40#include <linux/usb/f_mtp.h>
4141
42#include <hybris/properties/properties.h>
43
42namespace android {44namespace android {
4345
44static const MtpOperationCode kSupportedOperationCodes[] = {46static const MtpOperationCode kSupportedOperationCodes[] = {
@@ -423,7 +425,7 @@
423MtpResponseCode MtpServer::doGetDeviceInfo() {425MtpResponseCode MtpServer::doGetDeviceInfo() {
424 ALOGV("%s", __PRETTY_FUNCTION__);426 ALOGV("%s", __PRETTY_FUNCTION__);
425 MtpStringBuffer string;427 MtpStringBuffer string;
426 // char prop_value[PROPERTY_VALUE_MAX];428 char prop_value[PROP_VALUE_MAX];
427429
428 MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats();430 MtpObjectFormatList* playbackFormats = mDatabase->getSupportedPlaybackFormats();
429 MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats();431 MtpObjectFormatList* captureFormats = mDatabase->getSupportedCaptureFormats();
@@ -455,7 +457,6 @@
455 mData.putAUInt16(captureFormats); // Capture Formats457 mData.putAUInt16(captureFormats); // Capture Formats
456 mData.putAUInt16(playbackFormats); // Playback Formats458 mData.putAUInt16(playbackFormats); // Playback Formats
457459
458 /* TODO(tvoss): Wire up to our system property handling here.
459 property_get("ro.product.manufacturer", prop_value, "unknown manufacturer");460 property_get("ro.product.manufacturer", prop_value, "unknown manufacturer");
460 string.set(prop_value);461 string.set(prop_value);
461 mData.putString(string); // Manufacturer462 mData.putString(string); // Manufacturer
@@ -468,7 +469,7 @@
468469
469 property_get("ro.serialno", prop_value, "????????");470 property_get("ro.serialno", prop_value, "????????");
470 string.set(prop_value);471 string.set(prop_value);
471 mData.putString(string); // Serial Number*/472 mData.putString(string); // Serial Number
472473
473 delete playbackFormats;474 delete playbackFormats;
474 delete captureFormats;475 delete captureFormats;

Subscribers

People subscribed via source and target branches