Merge lp:~e7appew/ubuntu/wily/bombono-dvd/mux-files-with-spaces-wily into lp:ubuntu/wily/bombono-dvd

Proposed by Carlos Maddela
Status: Needs review
Proposed branch: lp:~e7appew/ubuntu/wily/bombono-dvd/mux-files-with-spaces-wily
Merge into: lp:ubuntu/wily/bombono-dvd
Diff against target: 346 lines (+292/-2)
6 files modified
.pc/0002-Allow-muxing-of-files-with-spaces.patch/src/mgui/mux.cpp (+242/-0)
.pc/applied-patches (+1/-0)
debian/changelog (+7/-0)
debian/patches/0002-Allow-muxing-of-files-with-spaces.patch (+39/-0)
debian/patches/series (+1/-0)
src/mgui/mux.cpp (+2/-2)
To merge this branch: bzr merge lp:~e7appew/ubuntu/wily/bombono-dvd/mux-files-with-spaces-wily
Reviewer Review Type Date Requested Status
Brian Murray Needs Fixing
Review via email: mp+279986@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

The patch's quoting of %2% is inconsistent, in one part it is bordered by \" and in another it isn't.

review: Needs Fixing
Revision history for this message
Carlos Maddela (e7appew) wrote :

It's been a while since I looked at this, but if I remember correctly,
when you quote %2% as well, all the rest of the arguments would be
treated as a single string, and the command fails.

On 08/06/16 04:51, Brian Murray wrote:
> Review: Needs Fixing
>
> The patch's quoting of %2% is inconsistent, in one part it is bordered by \" and in another it isn't.
>
> Diff comments:
>
>> === added file 'debian/patches/0002-Allow-muxing-of-files-with-spaces.patch'
>> --- debian/patches/0002-Allow-muxing-of-files-with-spaces.patch 1970-01-01 00:00:00 +0000
>> +++ debian/patches/0002-Allow-muxing-of-files-with-spaces.patch 2015-12-09 09:32:38 +0000
>> @@ -0,0 +1,39 @@
>> +From: Carlos Maddela <email address hidden>
>> +Date: Thu, 13 Aug 2015 15:05:04 +1000
>> +Subject: Allow muxing of files whose name or path contains spaces
>> +
>> +Description: Allow muxing of files whose name or path contains spaces.
>> + Arguments to mplex command should be quoted in case the files to be
>> + muxed have names or paths containing spaces.
>> +Author: Carlos Maddela <email address hidden>
>> +Origin: vendor
>> +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/bombono-dvd/+bug/1484397
>> +Last-Update: 2015-12-09
>> +---
>> +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
>> +---
>> + src/mgui/mux.cpp | 4 ++--
>> + 1 file changed, 2 insertions(+), 2 deletions(-)
>> +
>> +diff --git a/src/mgui/mux.cpp b/src/mgui/mux.cpp
>> +index 427058e..cc4922b 100644
>> +--- a/src/mgui/mux.cpp
>> ++++ b/src/mgui/mux.cpp
>> +@@ -99,7 +99,7 @@ static bool RunMuxing(const std::string& dest_path, const std::string& args)
>> + ExitData ed;
>> + {
>> + Execution::Pulse pls(prg_bar);
>> +- std::string cmd = boost::format("mplex -f 8 -o %1% %2%") % dest_path % args % bf::stop;
>> ++ std::string cmd = boost::format("mplex -f 8 -o \"%1%\" %2%") % dest_path % args % bf::stop;
> Shouldn't %2% be treated the same way as %1% here?
>
>> + AppendCommandText(txt_view, cmd);
>> + ed = ExecuteAsync(0, cmd.c_str(), TextViewAppender(txt_view), &edat.pid);
>> + }
>> +@@ -234,7 +234,7 @@ bool MuxStreams(std::string& dest_fname, const std::string& src_fname)
>> + if( res )
>> + {
>> + dlg.hide();
>> +- res = RunMuxing(dest_fname, boost::format("%1% %2%") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
>> ++ res = RunMuxing(dest_fname, boost::format("\"%1%\" \"%2%\"") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
>> + }
>> +
>> + return res;
>

Unmerged revisions

27. By Carlos Maddela

Merge branch 'mux-files-with-spaces-vivid' into mux-files-with-spaces-wily

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc/0002-Allow-muxing-of-files-with-spaces.patch'
2=== added directory '.pc/0002-Allow-muxing-of-files-with-spaces.patch/src'
3=== added directory '.pc/0002-Allow-muxing-of-files-with-spaces.patch/src/mgui'
4=== added file '.pc/0002-Allow-muxing-of-files-with-spaces.patch/src/mgui/mux.cpp'
5--- .pc/0002-Allow-muxing-of-files-with-spaces.patch/src/mgui/mux.cpp 1970-01-01 00:00:00 +0000
6+++ .pc/0002-Allow-muxing-of-files-with-spaces.patch/src/mgui/mux.cpp 2015-12-09 09:32:38 +0000
7@@ -0,0 +1,242 @@
8+//
9+// mgui/mux.cpp
10+// This file is part of Bombono DVD project.
11+//
12+// Copyright (c) 2010 Ilya Murav'jov
13+//
14+// This program is free software; you can redistribute it and/or modify
15+// it under the terms of the GNU General Public License as published by
16+// the Free Software Foundation; either version 2 of the License, or
17+// (at your option) any later version.
18+//
19+// This program is distributed in the hope that it will be useful,
20+// but WITHOUT ANY WARRANTY; without even the implied warranty of
21+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+// GNU General Public License for more details.
23+//
24+// You should have received a copy of the GNU General Public License
25+// along with this program; if not, write to the Free Software
26+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27+//
28+
29+#include <mgui/_pc_.h>
30+
31+#include "mux.h"
32+#include "execution.h" // ExecuteAsync()
33+
34+#include <mgui/sdk/textview.h>
35+#include <mgui/sdk/packing.h>
36+#include <mgui/sdk/widget.h>
37+
38+#include <mgui/execution.h>
39+#include <mgui/gettext.h>
40+#include <mgui/dialog.h>
41+
42+#include <mlib/filesystem.h>
43+
44+#include <gtk/gtkwindow.h> // gtk_window_set_geometry_hints()
45+
46+static void OnNewText(Gtk::TextView& txt_view, const char* dat, int sz, bool is_out,
47+ const ReadReadyFnr& add_fnr, const std::string& prefix)
48+{
49+ AppendNewText(txt_view, prefix + std::string(dat, sz), is_out);
50+ if( add_fnr )
51+ add_fnr(dat, sz, is_out);
52+}
53+
54+ReadReadyFnr TextViewAppender(Gtk::TextView& txt_view, const ReadReadyFnr& add_fnr,
55+ const std::string& prefix)
56+{
57+ return bb::bind(&OnNewText, boost::ref(txt_view), _1, _2, _3, add_fnr, prefix);
58+}
59+
60+static void OnResponse(Execution::Data& edat, int resp)
61+{
62+ if( resp == Gtk::RESPONSE_CANCEL)
63+ {
64+ // повтороне нажатие - закрытие диалога
65+ if( !edat.userAbort )
66+ edat.StopExecution(_("muxing"));
67+ }
68+}
69+
70+void SetDialogStrict(Gtk::Dialog& dlg, int min_wdh, int min_hgt, bool set_resizable)
71+{
72+ dlg.set_resizable(set_resizable); // чтоб при закрытии экспандера диалог уменьшался
73+ // размер окна пошире
74+ GdkGeometry geom;
75+ geom.min_width = min_wdh;
76+ geom.min_height = min_hgt;
77+ gtk_window_set_geometry_hints(static_cast<Gtk::Window&>(dlg).gobj(), 0, &geom, GDK_HINT_MIN_SIZE);
78+}
79+
80+static bool RunMuxing(const std::string& dest_path, const std::string& args)
81+{
82+ Gtk::Dialog dlg(BF_("Muxing \"%1%\"") % fs::name_str(dest_path) % bf::stop);
83+ SetDialogStrict(dlg, 400, -1);
84+
85+ Gtk::TextView& txt_view = NewManaged<Gtk::TextView>();
86+ Execution::Data edat;
87+ Gtk::ProgressBar& prg_bar = NewManaged<Gtk::ProgressBar>();
88+
89+ {
90+ Gtk::VBox& box = *dlg.get_vbox();
91+ PackStart(box, prg_bar);
92+
93+ Gtk::Expander& expdr = PackStart(box, NewManaged<Gtk::Expander>(_("Show/_hide Details"), true));
94+ txt_view.set_editable(false);
95+ txt_view.set_size_request(0, 200);
96+ expdr.add(PackDetails(txt_view));
97+
98+ dlg.get_action_area()->set_layout(Gtk::BUTTONBOX_CENTER);
99+ dlg.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
100+ dlg.signal_response().connect(bb::bind(&OnResponse, boost::ref(edat), _1));
101+
102+ dlg.show_all();
103+ }
104+
105+ //dlg.run();
106+ ExitData ed;
107+ {
108+ Execution::Pulse pls(prg_bar);
109+ std::string cmd = boost::format("mplex -f 8 -o %1% %2%") % dest_path % args % bf::stop;
110+ AppendCommandText(txt_view, cmd);
111+ ed = ExecuteAsync(0, cmd.c_str(), TextViewAppender(txt_view), &edat.pid);
112+ }
113+
114+ if( !ed.IsGood() && !edat.userAbort )
115+ {
116+ MessageBox(_("Muxing error"), Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK,
117+ BF_("The reason is \"%1%\" (see Details)") % ExitDescription(ed) % bf::stop);
118+ dlg.run();
119+ }
120+ return ed.IsGood();
121+}
122+
123+struct SaveChooser: public Gtk::Table
124+{
125+ Gtk::Entry& ent;
126+ Gtk::FileChooserButton& fcb;
127+
128+ SaveChooser(const char* type);
129+};
130+
131+SaveChooser::SaveChooser(const char* type):
132+ ent(NewManaged<Gtk::Entry>()),
133+ fcb(NewManaged<Gtk::FileChooserButton>(_("Select a folder"), Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER))
134+{
135+ // вариант с виджетом - слишком большой, хоть и более функциональный
136+ //Gtk::FileChooserWidget& fcw = NewManaged<Gtk::FileChooserWidget>(Gtk::FILE_CHOOSER_ACTION_SAVE);
137+ //Gtk::Frame& frm = PackStart(vbox, NewManagedFrame(Gtk::SHADOW_ETCHED_IN, " Output: "), Gtk::PACK_EXPAND_WIDGET);
138+ //Add(Add(frm, NewPaddingAlg(0, 5, 5, 5)), fcw);
139+
140+ set_col_spacings(5);
141+ Gtk::Label& o_lbl = NewManaged<Gtk::Label>(type);
142+ SetAlign(o_lbl, true);
143+ attach(o_lbl, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL);
144+ attach(ent, 1, 2, 0, 1);
145+ Gtk::Label& i_lbl = NewManaged<Gtk::Label>(_("in"));
146+ SetAlign(i_lbl, false);
147+ attach(i_lbl, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL);
148+ attach(fcb, 1, 2, 1, 2);
149+}
150+
151+fs::path GetFilename(Gtk::FileChooser& fc)
152+{
153+ // fs::path v3 не понимает ustring
154+ // однако в gtkmm >= будет возвращать std::string, и это не понадобится
155+ return fs::path(fc.get_filename().raw());
156+}
157+
158+std::string GetFilename(SaveChooser& sc)
159+{
160+ std::string fname = sc.ent.get_text();
161+ if( !fname.empty() )
162+ fname = (GetFilename(sc.fcb)/fname).string();
163+
164+ return fname;
165+}
166+
167+static void OnVideoSelected(Gtk::FileChooserButton& v_btn, Gtk::FileChooserButton& a_btn, SaveChooser& sc)
168+{
169+ fs::path pth = GetFilename(v_btn);
170+ if( pth.empty() )
171+ return;
172+ std::string folder = pth.branch_path().string();
173+
174+ if( a_btn.get_filename().empty() )
175+ a_btn.set_current_folder(folder);
176+
177+ if( GetFilename(sc).empty() )
178+ {
179+ sc.fcb.set_current_folder(folder);
180+ sc.ent.set_text(get_basename(pth) + ".mpg");
181+ }
182+}
183+
184+bool MuxStreams(std::string& dest_fname, const std::string& src_fname)
185+{
186+ Gtk::Dialog dlg(_("Mux streams"));
187+ SetDialogStrict(dlg, 400, -1);
188+ SaveChooser& sc = NewManaged<SaveChooser>(SMCLN_("Output"));
189+ Gtk::FileChooserButton& v_btn = NewManaged<Gtk::FileChooserButton>(_("Select elementary video"), Gtk::FILE_CHOOSER_ACTION_OPEN);
190+ Gtk::FileChooserButton& a_btn = NewManaged<Gtk::FileChooserButton>(_("Select audio"), Gtk::FILE_CHOOSER_ACTION_OPEN);
191+ {
192+ DialogVBox& vbox = AddHIGedVBox(dlg);
193+
194+ AppendWithLabel(vbox, v_btn, SMCLN_("Video"));
195+ {
196+ Gtk::FileFilter f;
197+ f.set_name(_("MPEG2 elementary video (m2v)"));
198+ f.add_pattern("*.m2v");
199+ v_btn.add_filter(f);
200+ }
201+
202+ AppendWithLabel(vbox, a_btn, SMCLN_("Audio"));
203+ {
204+ Gtk::FileFilter f;
205+ f.set_name(_("Audio for DVD") + std::string(" (mp2/mpa, ac3, dts or 16bit lpcm)"));
206+ FillSoundFilter(f);
207+ a_btn.add_filter(f);
208+ }
209+
210+ PackStart(vbox, sc);
211+
212+ CompleteDialog(dlg);
213+ }
214+
215+ v_btn.signal_selection_changed().connect(bb::bind(&OnVideoSelected, boost::ref(v_btn), boost::ref(a_btn), boost::ref(sc)));
216+ if( !src_fname.empty() )
217+ {
218+ if( get_extension(src_fname) == "m2v" )
219+ v_btn.set_filename(src_fname);
220+ else
221+ a_btn.set_filename(src_fname);
222+ }
223+
224+ bool res = false;
225+ for( ; res = Gtk::RESPONSE_OK == dlg.run(), res; )
226+ {
227+ dest_fname = GetFilename(sc);
228+
229+ if( v_btn.get_filename().empty() )
230+ ErrorBox(_("Elementary video file is not selected."));
231+ else if( a_btn.get_filename().empty() )
232+ ErrorBox(_("Audio file is not selected."));
233+ else if( dest_fname.empty() )
234+ ErrorBox(_("Output file name is empty."));
235+ else if( CheckKeepOrigin(dest_fname) )
236+ ;
237+ else
238+ break;
239+ }
240+
241+ if( res )
242+ {
243+ dlg.hide();
244+ res = RunMuxing(dest_fname, boost::format("%1% %2%") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
245+ }
246+
247+ return res;
248+}
249+
250
251=== modified file '.pc/applied-patches'
252--- .pc/applied-patches 2015-08-12 12:16:58 +0000
253+++ .pc/applied-patches 2015-12-09 09:32:38 +0000
254@@ -1,2 +1,3 @@
255 0001-ffmpeg-has-renamed-CodecID-AVCodecID.patch
256+0002-Allow-muxing-of-files-with-spaces.patch
257 1000-ubuntu-stop-using-ffmpeg-AVFormatContext-data_offset-now-private.patch
258
259=== modified file 'debian/changelog'
260--- debian/changelog 2015-09-07 08:27:53 +0000
261+++ debian/changelog 2015-12-09 09:32:38 +0000
262@@ -1,3 +1,10 @@
263+bombono-dvd (1.2.2-0ubuntu9) wily; urgency=medium
264+
265+ * Allow muxing of files whose name or path contains spaces
266+ (LP: #1484397).
267+
268+ -- Carlos Maddela <maddela@labyrinth.net.au> Wed, 09 Dec 2015 15:08:55 +1000
269+
270 bombono-dvd (1.2.2-0ubuntu8) wily; urgency=medium
271
272 * No-change rebuild for libxml++ soname change.
273
274=== added file 'debian/patches/0002-Allow-muxing-of-files-with-spaces.patch'
275--- debian/patches/0002-Allow-muxing-of-files-with-spaces.patch 1970-01-01 00:00:00 +0000
276+++ debian/patches/0002-Allow-muxing-of-files-with-spaces.patch 2015-12-09 09:32:38 +0000
277@@ -0,0 +1,39 @@
278+From: Carlos Maddela <maddela@labyrinth.net.au>
279+Date: Thu, 13 Aug 2015 15:05:04 +1000
280+Subject: Allow muxing of files whose name or path contains spaces
281+
282+Description: Allow muxing of files whose name or path contains spaces.
283+ Arguments to mplex command should be quoted in case the files to be
284+ muxed have names or paths containing spaces.
285+Author: Carlos Maddela <maddela@labyrinth.net.au>
286+Origin: vendor
287+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/bombono-dvd/+bug/1484397
288+Last-Update: 2015-12-09
289+---
290+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
291+---
292+ src/mgui/mux.cpp | 4 ++--
293+ 1 file changed, 2 insertions(+), 2 deletions(-)
294+
295+diff --git a/src/mgui/mux.cpp b/src/mgui/mux.cpp
296+index 427058e..cc4922b 100644
297+--- a/src/mgui/mux.cpp
298++++ b/src/mgui/mux.cpp
299+@@ -99,7 +99,7 @@ static bool RunMuxing(const std::string& dest_path, const std::string& args)
300+ ExitData ed;
301+ {
302+ Execution::Pulse pls(prg_bar);
303+- std::string cmd = boost::format("mplex -f 8 -o %1% %2%") % dest_path % args % bf::stop;
304++ std::string cmd = boost::format("mplex -f 8 -o \"%1%\" %2%") % dest_path % args % bf::stop;
305+ AppendCommandText(txt_view, cmd);
306+ ed = ExecuteAsync(0, cmd.c_str(), TextViewAppender(txt_view), &edat.pid);
307+ }
308+@@ -234,7 +234,7 @@ bool MuxStreams(std::string& dest_fname, const std::string& src_fname)
309+ if( res )
310+ {
311+ dlg.hide();
312+- res = RunMuxing(dest_fname, boost::format("%1% %2%") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
313++ res = RunMuxing(dest_fname, boost::format("\"%1%\" \"%2%\"") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
314+ }
315+
316+ return res;
317
318=== modified file 'debian/patches/series'
319--- debian/patches/series 2015-08-12 12:16:58 +0000
320+++ debian/patches/series 2015-12-09 09:32:38 +0000
321@@ -1,2 +1,3 @@
322 0001-ffmpeg-has-renamed-CodecID-AVCodecID.patch
323+0002-Allow-muxing-of-files-with-spaces.patch
324 1000-ubuntu-stop-using-ffmpeg-AVFormatContext-data_offset-now-private.patch
325
326=== modified file 'src/mgui/mux.cpp'
327--- src/mgui/mux.cpp 2013-11-07 19:03:05 +0000
328+++ src/mgui/mux.cpp 2015-12-09 09:32:38 +0000
329@@ -99,7 +99,7 @@
330 ExitData ed;
331 {
332 Execution::Pulse pls(prg_bar);
333- std::string cmd = boost::format("mplex -f 8 -o %1% %2%") % dest_path % args % bf::stop;
334+ std::string cmd = boost::format("mplex -f 8 -o \"%1%\" %2%") % dest_path % args % bf::stop;
335 AppendCommandText(txt_view, cmd);
336 ed = ExecuteAsync(0, cmd.c_str(), TextViewAppender(txt_view), &edat.pid);
337 }
338@@ -234,7 +234,7 @@
339 if( res )
340 {
341 dlg.hide();
342- res = RunMuxing(dest_fname, boost::format("%1% %2%") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
343+ res = RunMuxing(dest_fname, boost::format("\"%1%\" \"%2%\"") % v_btn.get_filename() % a_btn.get_filename() % bf::stop );
344 }
345
346 return res;

Subscribers

People subscribed via source and target branches