mtp

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

Proposed by Mathieu Trudel-Lapierre
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 52
Merged at revision: 49
Proposed branch: lp:~cyphermox/mtp/fixes-20140902
Merge into: lp:mtp
Diff against target: 373 lines (+147/-10)
11 files modified
CMakeLists.txt (+2/-1)
debian/control (+2/-0)
debian/mtp-server.install (+1/-0)
debian/rules (+1/-1)
include/MtpDatabase.h (+1/-0)
po/CMakeLists.txt (+36/-0)
po/fr.po (+37/-0)
po/mtp-server.pot (+38/-0)
server/UbuntuMtpDatabase.h (+10/-5)
server/server.cpp (+18/-2)
tests/MockMtpDatabase.h (+1/-1)
To merge this branch: bzr merge lp:~cyphermox/mtp/fixes-20140902
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+233295@code.launchpad.net

Commit message

Fixes for critical bugs:
 - Avoid crashing in dbus timeouts, just don't ask for the locking state, we can save that.
 - Allow dragging/copying files on the root of the SD card.
 - Add support for translating the display name of storage paths; only used for local storage.

Description of the change

Fixes for critical bugs:
 - Avoid crashing in dbus timeouts, just don't ask for the locking state, we can save that.
 - Allow dragging/copying files on the root of the SD card.
 - Add support for translating the display name of storage paths; only used for local storage.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Need to add this to debian/control for the source package
X-Ubuntu-Use-Langpack: yes

review: Needs Fixing
lp:~cyphermox/mtp/fixes-20140902 updated
52. By Mathieu Trudel-Lapierre

Add X-Ubuntu-Use-Langpack: yes to source package.

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

tested on rtm krillin 16 and mako 26 (french)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-14 15:12:55 +0000
3+++ CMakeLists.txt 2014-09-04 15:31:05 +0000
4@@ -3,6 +3,7 @@
5 cmake_minimum_required(VERSION 2.8)
6
7 include(FindPkgConfig)
8+include(GNUInstallDirs)
9
10 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
11
12@@ -100,4 +101,4 @@
13 add_subdirectory(libusbhost)
14 add_subdirectory(server)
15 add_subdirectory(tests)
16-
17+add_subdirectory(po)
18
19=== modified file 'debian/control'
20--- debian/control 2014-08-14 15:12:55 +0000
21+++ debian/control 2014-09-04 15:31:05 +0000
22@@ -4,6 +4,7 @@
23 Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
24 XSBC-Original-Maintainer: Thomas Voß <thomas.voss@canonical.com>
25 Build-Depends: debhelper (>= 9),
26+ dh-translations,
27 cmake,
28 pkg-config,
29 libboost-dev,
30@@ -21,6 +22,7 @@
31 # just go ahead. ~phablet-team will notice and sync up the code again.
32 Vcs-Bzr: https://code.launchpad.net/~phablet-team/mtp/trunk
33 Vcs-Browser: https://bazaar.launchpad.net/~phablet-team/mtp/trunk/files
34+X-Ubuntu-Use-Langpack: yes
35
36 Package: libmtpserver1
37 Section: libs
38
39=== modified file 'debian/mtp-server.install'
40--- debian/mtp-server.install 2013-09-10 15:55:18 +0000
41+++ debian/mtp-server.install 2014-09-04 15:31:05 +0000
42@@ -1,2 +1,3 @@
43 usr/bin/mtp-server
44+usr/share/locale
45 debian/mtp-server.conf /usr/share/upstart/sessions/
46
47=== modified file 'debian/rules'
48--- debian/rules 2014-03-07 19:11:20 +0000
49+++ debian/rules 2014-09-04 15:31:05 +0000
50@@ -6,7 +6,7 @@
51 export DPKG_GENSYMBOLS_CHECK_LEVEL = 4
52
53 %:
54- dh $@ -- --fail-missing
55+ dh $@ --with translations -- --fail-missing
56
57 override_dh_installinit:
58 dh_installinit -pmtp-server --name=mtp-state --no-start -r -n
59
60=== modified file 'include/MtpDatabase.h'
61--- include/MtpDatabase.h 2014-08-14 15:12:55 +0000
62+++ include/MtpDatabase.h 2014-09-04 15:31:05 +0000
63@@ -32,6 +32,7 @@
64
65 // called to add a path to include in the database.
66 virtual void addStoragePath(const MtpString& path,
67+ const MtpString& displayName,
68 MtpStorageID storage,
69 bool hidden) = 0;
70
71
72=== added directory 'po'
73=== added file 'po/CMakeLists.txt'
74--- po/CMakeLists.txt 1970-01-01 00:00:00 +0000
75+++ po/CMakeLists.txt 2014-09-04 15:31:05 +0000
76@@ -0,0 +1,36 @@
77+project(mtp-server-translations)
78+
79+# for dh_translations to extract the domain
80+# (regarding syntax consistency, see http://pad.lv/1181187)
81+set (GETTEXT_PACKAGE "mtp-server")
82+
83+include(FindGettext)
84+
85+set(DOMAIN mtp-server)
86+set(POT_FILE ${DOMAIN}.pot)
87+file(GLOB PO_FILES *.po)
88+file(GLOB_RECURSE I18N_SRCS RELATIVE ${CMAKE_SOURCE_DIR}
89+ ${CMAKE_SOURCE_DIR}/server/server.cpp
90+)
91+
92+foreach(PO_FILE ${PO_FILES})
93+ get_filename_component(LANG ${PO_FILE} NAME_WE)
94+ gettext_process_po_files(${LANG} ALL PO_FILES ${PO_FILE})
95+ set(INSTALL_DIR ${CMAKE_INSTALL_LOCALEDIR}/${LANG}/LC_MESSAGES)
96+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG}.gmo
97+ DESTINATION ${INSTALL_DIR}
98+ RENAME ${DOMAIN}.mo)
99+endforeach(PO_FILE)
100+
101+find_program(XGETTEXT_EXECUTABLE xgettext)
102+if(XGETTEXT_EXECUTABLE)
103+ add_custom_target(${POT_FILE})
104+ add_custom_command(TARGET ${POT_FILE}
105+ COMMAND ${XGETTEXT_EXECUTABLE} --c++ --qt --add-comments=TRANSLATORS --keyword=tr --keyword=tr:1,2 -D ${CMAKE_SOURCE_DIR} -s -p ${CMAKE_CURRENT_SOURCE_DIR} -o ${POT_FILE} ${I18N_SRCS}
106+ )
107+ foreach(PO_FILE ${PO_FILES})
108+ add_custom_command(TARGET ${POT_FILE}
109+ COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} ${PO_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${POT_FILE} -o ${PO_FILE}
110+ )
111+ endforeach(PO_FILE)
112+endif()
113
114=== added file 'po/fr.po'
115--- po/fr.po 1970-01-01 00:00:00 +0000
116+++ po/fr.po 2014-09-04 15:31:05 +0000
117@@ -0,0 +1,37 @@
118+# SOME DESCRIPTIVE TITLE.
119+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
120+# This file is distributed under the same license as the PACKAGE package.
121+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
122+#
123+msgid ""
124+msgstr ""
125+"Project-Id-Version: PACKAGE VERSION\n"
126+"Report-Msgid-Bugs-To: \n"
127+"POT-Creation-Date: 2014-09-03 11:35-0400\n"
128+"PO-Revision-Date: 2014-09-03 11:40-0500\n"
129+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
130+"Language-Team: LANGUAGE <LL@li.org>\n"
131+"MIME-Version: 1.0\n"
132+"Content-Type: text/plain; charset=UTF-8\n"
133+"Content-Transfer-Encoding: 8bit\n"
134+"X-Generator: Poedit 1.5.4\n"
135+
136+#: ../server/server.cpp:298
137+msgid "Documents"
138+msgstr "Documents"
139+
140+#: ../server/server.cpp:310
141+msgid "Downloads"
142+msgstr "Téléchargements"
143+
144+#: ../server/server.cpp:301
145+msgid "Music"
146+msgstr "Musique"
147+
148+#: ../server/server.cpp:307
149+msgid "Pictures"
150+msgstr "Images"
151+
152+#: ../server/server.cpp:304
153+msgid "Videos"
154+msgstr "Vidéos"
155
156=== added file 'po/mtp-server.pot'
157--- po/mtp-server.pot 1970-01-01 00:00:00 +0000
158+++ po/mtp-server.pot 2014-09-04 15:31:05 +0000
159@@ -0,0 +1,38 @@
160+# SOME DESCRIPTIVE TITLE.
161+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
162+# This file is distributed under the same license as the PACKAGE package.
163+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
164+#
165+#, fuzzy
166+msgid ""
167+msgstr ""
168+"Project-Id-Version: PACKAGE VERSION\n"
169+"Report-Msgid-Bugs-To: \n"
170+"POT-Creation-Date: 2014-09-03 11:35-0400\n"
171+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
172+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
173+"Language-Team: LANGUAGE <LL@li.org>\n"
174+"Language: \n"
175+"MIME-Version: 1.0\n"
176+"Content-Type: text/plain; charset=CHARSET\n"
177+"Content-Transfer-Encoding: 8bit\n"
178+
179+#: ../server/server.cpp:298
180+msgid "Documents"
181+msgstr ""
182+
183+#: ../server/server.cpp:310
184+msgid "Downloads"
185+msgstr ""
186+
187+#: ../server/server.cpp:301
188+msgid "Music"
189+msgstr ""
190+
191+#: ../server/server.cpp:307
192+msgid "Pictures"
193+msgstr ""
194+
195+#: ../server/server.cpp:304
196+msgid "Videos"
197+msgstr ""
198
199=== modified file 'server/UbuntuMtpDatabase.h'
200--- server/UbuntuMtpDatabase.h 2014-08-21 19:42:19 +0000
201+++ server/UbuntuMtpDatabase.h 2014-09-04 15:31:05 +0000
202@@ -185,18 +185,22 @@
203 }
204 }
205
206- void readFiles(const std::string& sourcedir, MtpStorageID storage, bool hidden)
207+ void readFiles(const std::string& sourcedir, const std::string& display, MtpStorageID storage, bool hidden)
208 {
209 path p (sourcedir);
210 DbEntry entry;
211 MtpObjectHandle handle = counter++;
212+ std::string display_name = std::string(p.filename().string());
213+
214+ if (!display.empty())
215+ display_name = display;
216
217 try {
218 if (exists(p)) {
219 if (is_directory(p)) {
220 entry.storage_id = storage;
221 entry.parent = hidden ? MTP_PARENT_ROOT : 0;
222- entry.display_name = std::string(p.filename().string());
223+ entry.display_name = display_name;
224 entry.path = p.string();
225 entry.object_format = MTP_FORMAT_ASSOCIATION;
226 entry.object_size = 0;
227@@ -214,7 +218,7 @@
228 else {
229 entry.storage_id = storage;
230 entry.parent = -1;
231- entry.display_name = std::string(p.parent_path().filename().string());
232+ entry.display_name = display_name;
233 entry.path = p.parent_path().string();
234 entry.object_format = MTP_FORMAT_ASSOCIATION;
235 entry.object_size = 0;
236@@ -343,10 +347,11 @@
237 }
238
239 virtual void addStoragePath(const MtpString& path,
240+ const MtpString& displayName,
241 MtpStorageID storage,
242 bool hidden)
243 {
244- readFiles(path, storage, hidden);
245+ readFiles(path, displayName, storage, hidden);
246 }
247
248 virtual void removeStorage(MtpStorageID storage)
249@@ -370,7 +375,7 @@
250 DbEntry entry;
251 MtpObjectHandle handle = counter;
252
253- if (parent == 0)
254+ if (storage == MTP_STORAGE_FIXED_RAM && parent == 0)
255 return kInvalidObjectHandle;
256
257 VLOG(1) << __PRETTY_FUNCTION__ << ": " << path << " - " << parent
258
259=== modified file 'server/server.cpp'
260--- server/server.cpp 2014-08-26 20:49:29 +0000
261+++ server/server.cpp 2014-09-04 15:31:05 +0000
262@@ -28,6 +28,8 @@
263 #include <fcntl.h>
264 #include <unistd.h>
265 #include <pwd.h>
266+#include <libintl.h>
267+#include <locale.h>
268
269 #include <hybris/properties/properties.h>
270 #include <glog/logging.h>
271@@ -43,6 +45,7 @@
272 #include <core/dbus/types/stl/vector.h>
273 #include <core/dbus/types/struct.h>
274
275+
276 namespace dbus = core::dbus;
277 using namespace android;
278
279@@ -119,6 +122,7 @@
280
281 // Security
282 std::shared_ptr<core::dbus::Property<core::UnityGreeter::Properties::IsActive> > is_active;
283+ bool screen_locked = true;
284
285 // inotify stuff
286 boost::thread notifier_thread;
287@@ -152,10 +156,9 @@
288
289 storageID++;
290
291- bool screen_locked = is_active->get();
292-
293 if (!screen_locked) {
294 mtp_database->addStoragePath(path,
295+ std::string(),
296 removable->getStorageID(),
297 true);
298 server->addStorage(removable);
299@@ -295,14 +298,19 @@
300 false,
301 1024 * 1024 * 1024 * 2 /* 2GB arbitrary max file size */);
302 mtp_database->addStoragePath(std::string(userdata->pw_dir) + "/Documents",
303+ gettext("Documents"),
304 MTP_STORAGE_FIXED_RAM, false);
305 mtp_database->addStoragePath(std::string(userdata->pw_dir) + "/Music",
306+ gettext("Music"),
307 MTP_STORAGE_FIXED_RAM, false);
308 mtp_database->addStoragePath(std::string(userdata->pw_dir) + "/Videos",
309+ gettext("Videos"),
310 MTP_STORAGE_FIXED_RAM, false);
311 mtp_database->addStoragePath(std::string(userdata->pw_dir) + "/Pictures",
312+ gettext("Pictures"),
313 MTP_STORAGE_FIXED_RAM, false);
314 mtp_database->addStoragePath(std::string(userdata->pw_dir) + "/Downloads",
315+ gettext("Downloads"),
316 MTP_STORAGE_FIXED_RAM, false);
317 home_storage_added = false;
318
319@@ -342,6 +350,7 @@
320 is_active->changed().connect([this](bool active)
321 {
322 if (!active) {
323+ screen_locked = active;
324 VLOG(2) << "device was unlocked, adding storage";
325 if (home_storage && !home_storage_added) {
326 server->addStorage(home_storage);
327@@ -353,6 +362,7 @@
328 bool added = std::get<1>(t);
329 if (!added) {
330 mtp_database->addStoragePath(storage->getPath(),
331+ std::string(),
332 storage->getStorageID(),
333 true);
334 server->addStorage(storage);
335@@ -361,6 +371,7 @@
336 }
337 });
338 } else {
339+ screen_locked = false;
340 VLOG(2) << "device is not locked, adding storage";
341 if (home_storage) {
342 server->addStorage(home_storage);
343@@ -372,6 +383,7 @@
344 bool added = std::get<1>(t);
345 if (!added) {
346 mtp_database->addStoragePath(storage->getPath(),
347+ std::string(),
348 storage->getStorageID(),
349 true);
350 server->addStorage(storage);
351@@ -388,6 +400,10 @@
352 {
353 google::InitGoogleLogging(argv[0]);
354
355+ bindtextdomain("mtp-server", "/usr/share/locale");
356+ setlocale(LC_ALL, "");
357+ textdomain("mtp-server");
358+
359 LOG(INFO) << "MTP server starting...";
360
361 int fd = open("/dev/mtp_usb", O_RDWR);
362
363=== modified file 'tests/MockMtpDatabase.h'
364--- tests/MockMtpDatabase.h 2014-08-14 15:12:55 +0000
365+++ tests/MockMtpDatabase.h 2014-09-04 15:31:05 +0000
366@@ -74,7 +74,7 @@
367
368 virtual ~MockMtpDatabase() {}
369
370- virtual void addStoragePath(const MtpString& path, MtpStorageID storage, bool hidden)
371+ virtual void addStoragePath(const MtpString& path, const MtpString& displayName, MtpStorageID storage, bool hidden)
372 {
373 }
374

Subscribers

People subscribed via source and target branches