Merge lp:~dobey/rhythmbox-ubuntuone/work-again-sort-of into lp:rhythmbox-ubuntuone

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 107
Merged at revision: 105
Proposed branch: lp:~dobey/rhythmbox-ubuntuone/work-again-sort-of
Merge into: lp:rhythmbox-ubuntuone
Diff against target: 2092 lines (+957/-890)
14 files modified
COPYING (+668/-159)
COPYING.LIB (+165/-0)
MANIFEST.in (+3/-4)
po/POTFILES.in (+3/-4)
rb.py (+0/-39)
rhythmdb.py (+0/-12)
run-tests (+1/-1)
setup.cfg (+1/-1)
setup.py (+11/-12)
ubuntuone/MusicStoreWidget.py (+52/-123)
ubuntuone/ubuntuone.plugin.in (+7/-6)
ubuntuone/ubuntuone.py (+46/-41)
umusicstore/U1MSLinks.py (+0/-380)
umusicstore/u1msurl.glade (+0/-108)
To merge this branch: bzr merge lp:~dobey/rhythmbox-ubuntuone/work-again-sort-of
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+88571@code.launchpad.net

Commit message

Update the plug-in to load in Rhythmbox 3.x, with a minimal set of functionality
Remove the U1MSLinks code and UI, as it's not the best way to implement the feature, and is more complex now

Description of the change

This gets us back a minimally working plug-in for rhythmbox, which adds the U1 Purchased Music folder to the library locations, if it isn't already in there. As libu1 still isn't fixed yet, the music store is disabled. And, as we probably want to do the u1ms links stuff a bit differently now that we have more music search related stuff going on, and the UX wasn't that great here anyway, I've scrapped that code.

To test IRL, you need to do the following:

$: mkdir -p ~/.local/share/rhythmbox/plugins
$: ./setup.py build
$: cp -a ubuntuone ~/.local/share/rhythmbox/plugins
$: cp build/lib/rhythmbox/plugins/ubuntuone.plugin ~/.local/share/rhythmbox/plugins/ubuntuone/

Then run rhythmbox, and "Ubuntu One" should appear in the Edit->Plugins UI, and when enabled, should add your Purcahsed from Ubuntu One UDF to the library locations config, and your purchased music should show up. If you haven't purchased any music, or don't have the UDF enabled on that computer, then it will seem nothing has happend (but the plug-in will remain active).

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'COPYING'
--- COPYING 2010-01-06 15:26:32 +0000
+++ COPYING 2012-01-14 02:17:23 +0000
@@ -1,165 +1,674 @@
1 GNU LESSER GENERAL PUBLIC LICENSE1 GNU GENERAL PUBLIC LICENSE
2 Version 3, 29 June 20072 Version 3, 29 June 2007
33
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.6 of this license document, but changing it is not allowed.
77
88 Preamble
9 This version of the GNU Lesser General Public License incorporates9
10the terms and conditions of version 3 of the GNU General Public10 The GNU General Public License is a free, copyleft license for
11License, supplemented by the additional permissions listed below.11software and other kinds of works.
1212
13 0. Additional Definitions. 13 The licenses for most software and other practical works are designed
1414to take away your freedom to share and change the works. By contrast,
15 As used herein, "this License" refers to version 3 of the GNU Lesser15the GNU General Public License is intended to guarantee your freedom to
16General Public License, and the "GNU GPL" refers to version 3 of the GNU16share and change all versions of a program--to make sure it remains free
17General Public License.17software for all its users. We, the Free Software Foundation, use the
1818GNU General Public License for most of our software; it applies also to
19 "The Library" refers to a covered work governed by this License,19any other work released this way by its authors. You can apply it to
20other than an Application or a Combined Work as defined below.20your programs, too.
2121
22 An "Application" is any work that makes use of an interface provided22 When we speak of free software, we are referring to freedom, not
23by the Library, but which is not otherwise based on the Library.23price. Our General Public Licenses are designed to make sure that you
24Defining a subclass of a class defined by the Library is deemed a mode24have the freedom to distribute copies of free software (and charge for
25of using an interface provided by the Library.25them if you wish), that you receive source code or can get it if you
2626want it, that you can change the software or use pieces of it in new
27 A "Combined Work" is a work produced by combining or linking an27free programs, and that you know you can do these things.
28Application with the Library. The particular version of the Library28
29with which the Combined Work was made is also called the "Linked29 To protect your rights, we need to prevent others from denying you
30Version".30these rights or asking you to surrender the rights. Therefore, you have
3131certain responsibilities if you distribute copies of the software, or if
32 The "Minimal Corresponding Source" for a Combined Work means the32you modify it: responsibilities to respect the freedom of others.
33Corresponding Source for the Combined Work, excluding any source code33
34for portions of the Combined Work that, considered in isolation, are34 For example, if you distribute copies of such a program, whether
35based on the Application, and not on the Linked Version.35gratis or for a fee, you must pass on to the recipients the same
3636freedoms that you received. You must make sure that they, too, receive
37 The "Corresponding Application Code" for a Combined Work means the37or can get the source code. And you must show them these terms so they
38object code and/or source code for the Application, including any data38know their rights.
39and utility programs needed for reproducing the Combined Work from the39
40Application, but excluding the System Libraries of the Combined Work.40 Developers that use the GNU GPL protect your rights with two steps:
4141(1) assert copyright on the software, and (2) offer you this License
42 1. Exception to Section 3 of the GNU GPL.42giving you legal permission to copy, distribute and/or modify it.
4343
44 You may convey a covered work under sections 3 and 4 of this License44 For the developers' and authors' protection, the GPL clearly explains
45without being bound by section 3 of the GNU GPL.45that there is no warranty for this free software. For both users' and
4646authors' sake, the GPL requires that modified versions be marked as
47 2. Conveying Modified Versions.47changed, so that their problems will not be attributed erroneously to
4848authors of previous versions.
49 If you modify a copy of the Library, and, in your modifications, a49
50facility refers to a function or data to be supplied by an Application50 Some devices are designed to deny users access to install or run
51that uses the facility (other than as an argument passed when the51modified versions of the software inside them, although the manufacturer
52facility is invoked), then you may convey a copy of the modified52can do so. This is fundamentally incompatible with the aim of
53version:53protecting users' freedom to change the software. The systematic
5454pattern of such abuse occurs in the area of products for individuals to
55 a) under this License, provided that you make a good faith effort to55use, which is precisely where it is most unacceptable. Therefore, we
56 ensure that, in the event an Application does not supply the56have designed this version of the GPL to prohibit the practice for those
57 function or data, the facility still operates, and performs57products. If such problems arise substantially in other domains, we
58 whatever part of its purpose remains meaningful, or58stand ready to extend this provision to those domains in future versions
5959of the GPL, as needed to protect the freedom of users.
60 b) under the GNU GPL, with none of the additional permissions of60
61 this License applicable to that copy.61 Finally, every program is threatened constantly by software patents.
6262States should not allow patents to restrict development and use of
63 3. Object Code Incorporating Material from Library Header Files.63software on general-purpose computers, but in those that do, we wish to
6464avoid the special danger that patents applied to a free program could
65 The object code form of an Application may incorporate material from65make it effectively proprietary. To prevent this, the GPL assures that
66a header file that is part of the Library. You may convey such object66patents cannot be used to render the program non-free.
67code under terms of your choice, provided that, if the incorporated67
68material is not limited to numerical parameters, data structure68 The precise terms and conditions for copying, distribution and
69layouts and accessors, or small macros, inline functions and templates69modification follow.
70(ten or fewer lines in length), you do both of the following:70
7171 TERMS AND CONDITIONS
72 a) Give prominent notice with each copy of the object code that the72
73 Library is used in it and that the Library and its use are73 0. Definitions.
74 covered by this License.74
7575 "This License" refers to version 3 of the GNU General Public License.
76 b) Accompany the object code with a copy of the GNU GPL and this license76
77 document.77 "Copyright" also means copyright-like laws that apply to other kinds of
7878works, such as semiconductor masks.
79 4. Combined Works.79
8080 "The Program" refers to any copyrightable work licensed under this
81 You may convey a Combined Work under terms of your choice that,81License. Each licensee is addressed as "you". "Licensees" and
82taken together, effectively do not restrict modification of the82"recipients" may be individuals or organizations.
83portions of the Library contained in the Combined Work and reverse83
84engineering for debugging such modifications, if you also do each of84 To "modify" a work means to copy from or adapt all or part of the work
85the following:85in a fashion requiring copyright permission, other than the making of an
8686exact copy. The resulting work is called a "modified version" of the
87 a) Give prominent notice with each copy of the Combined Work that87earlier work or a work "based on" the earlier work.
88 the Library is used in it and that the Library and its use are88
89 covered by this License.89 A "covered work" means either the unmodified Program or a work based
9090on the Program.
91 b) Accompany the Combined Work with a copy of the GNU GPL and this license91
92 document.92 To "propagate" a work means to do anything with it that, without
9393permission, would make you directly or secondarily liable for
94 c) For a Combined Work that displays copyright notices during94infringement under applicable copyright law, except executing it on a
95 execution, include the copyright notice for the Library among95computer or modifying a private copy. Propagation includes copying,
96 these notices, as well as a reference directing the user to the96distribution (with or without modification), making available to the
97 copies of the GNU GPL and this license document.97public, and in some countries other activities as well.
9898
99 d) Do one of the following:99 To "convey" a work means any kind of propagation that enables other
100100parties to make or receive copies. Mere interaction with a user through
101 0) Convey the Minimal Corresponding Source under the terms of this101a computer network, with no transfer of a copy, is not conveying.
102 License, and the Corresponding Application Code in a form102
103 suitable for, and under terms that permit, the user to103 An interactive user interface displays "Appropriate Legal Notices"
104 recombine or relink the Application with a modified version of104to the extent that it includes a convenient and prominently visible
105 the Linked Version to produce a modified Combined Work, in the105feature that (1) displays an appropriate copyright notice, and (2)
106 manner specified by section 6 of the GNU GPL for conveying106tells the user that there is no warranty for the work (except to the
107 Corresponding Source.107extent that warranties are provided), that licensees may convey the
108108work under this License, and how to view a copy of this License. If
109 1) Use a suitable shared library mechanism for linking with the109the interface presents a list of user commands or options, such as a
110 Library. A suitable mechanism is one that (a) uses at run time110menu, a prominent item in the list meets this criterion.
111 a copy of the Library already present on the user's computer111
112 system, and (b) will operate properly with a modified version112 1. Source Code.
113 of the Library that is interface-compatible with the Linked113
114 Version. 114 The "source code" for a work means the preferred form of the work
115115for making modifications to it. "Object code" means any non-source
116 e) Provide Installation Information, but only if you would otherwise116form of a work.
117 be required to provide such information under section 6 of the117
118 GNU GPL, and only to the extent that such information is118 A "Standard Interface" means an interface that either is an official
119 necessary to install and execute a modified version of the119standard defined by a recognized standards body, or, in the case of
120 Combined Work produced by recombining or relinking the120interfaces specified for a particular programming language, one that
121 Application with a modified version of the Linked Version. (If121is widely used among developers working in that language.
122 you use option 4d0, the Installation Information must accompany122
123 the Minimal Corresponding Source and Corresponding Application123 The "System Libraries" of an executable work include anything, other
124 Code. If you use option 4d1, you must provide the Installation124than the work as a whole, that (a) is included in the normal form of
125 Information in the manner specified by section 6 of the GNU GPL125packaging a Major Component, but which is not part of that Major
126 for conveying Corresponding Source.)126Component, and (b) serves only to enable use of the work with that
127127Major Component, or to implement a Standard Interface for which an
128 5. Combined Libraries.128implementation is available to the public in source code form. A
129129"Major Component", in this context, means a major essential component
130 You may place library facilities that are a work based on the130(kernel, window system, and so on) of the specific operating system
131Library side by side in a single library together with other library131(if any) on which the executable work runs, or a compiler used to
132facilities that are not Applications and are not covered by this132produce the work, or an object code interpreter used to run it.
133License, and convey such a combined library under terms of your133
134choice, if you do both of the following:134 The "Corresponding Source" for a work in object code form means all
135135the source code needed to generate, install, and (for an executable
136 a) Accompany the combined library with a copy of the same work based136work) run the object code and to modify the work, including scripts to
137 on the Library, uncombined with any other library facilities,137control those activities. However, it does not include the work's
138 conveyed under the terms of this License.138System Libraries, or general-purpose tools or generally available free
139139programs which are used unmodified in performing those activities but
140 b) Give prominent notice with the combined library that part of it140which are not part of the work. For example, Corresponding Source
141 is a work based on the Library, and explaining where to find the141includes interface definition files associated with source files for
142 accompanying uncombined form of the same work.142the work, and the source code for shared libraries and dynamically
143143linked subprograms that the work is specifically designed to require,
144 6. Revised Versions of the GNU Lesser General Public License.144such as by intimate data communication or control flow between those
145145subprograms and other parts of the work.
146 The Free Software Foundation may publish revised and/or new versions146
147of the GNU Lesser General Public License from time to time. Such new147 The Corresponding Source need not include anything that users
148versions will be similar in spirit to the present version, but may148can regenerate automatically from other parts of the Corresponding
149differ in detail to address new problems or concerns.149Source.
150150
151 Each version is given a distinguishing version number. If the151 The Corresponding Source for a work in source code form is that
152Library as you received it specifies that a certain numbered version152same work.
153of the GNU Lesser General Public License "or any later version"153
154applies to it, you have the option of following the terms and154 2. Basic Permissions.
155conditions either of that published version or of any later version155
156published by the Free Software Foundation. If the Library as you156 All rights granted under this License are granted for the term of
157received it does not specify a version number of the GNU Lesser157copyright on the Program, and are irrevocable provided the stated
158General Public License, you may choose any version of the GNU Lesser158conditions are met. This License explicitly affirms your unlimited
159General Public License ever published by the Free Software Foundation.159permission to run the unmodified Program. The output from running a
160160covered work is covered by this License only if the output, given its
161 If the Library as you received it specifies that a proxy can decide161content, constitutes a covered work. This License acknowledges your
162whether future versions of the GNU Lesser General Public License shall162rights of fair use or other equivalent, as provided by copyright law.
163apply, that proxy's public statement of acceptance of any version is163
164permanent authorization for you to choose that version for the164 You may make, run and propagate covered works that you do not
165Library.165convey, without conditions so long as your license otherwise remains
166in force. You may convey covered works to others for the sole purpose
167of having them make modifications exclusively for you, or provide you
168with facilities for running those works, provided that you comply with
169the terms of this License in conveying all material for which you do
170not control copyright. Those thus making or running the covered works
171for you must do so exclusively on your behalf, under your direction
172and control, on terms that prohibit them from making any copies of
173your copyrighted material outside their relationship with you.
174
175 Conveying under any other circumstances is permitted solely under
176the conditions stated below. Sublicensing is not allowed; section 10
177makes it unnecessary.
178
179 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
181 No covered work shall be deemed part of an effective technological
182measure under any applicable law fulfilling obligations under article
18311 of the WIPO copyright treaty adopted on 20 December 1996, or
184similar laws prohibiting or restricting circumvention of such
185measures.
186
187 When you convey a covered work, you waive any legal power to forbid
188circumvention of technological measures to the extent such circumvention
189is effected by exercising rights under this License with respect to
190the covered work, and you disclaim any intention to limit operation or
191modification of the work as a means of enforcing, against the work's
192users, your or third parties' legal rights to forbid circumvention of
193technological measures.
194
195 4. Conveying Verbatim Copies.
196
197 You may convey verbatim copies of the Program's source code as you
198receive it, in any medium, provided that you conspicuously and
199appropriately publish on each copy an appropriate copyright notice;
200keep intact all notices stating that this License and any
201non-permissive terms added in accord with section 7 apply to the code;
202keep intact all notices of the absence of any warranty; and give all
203recipients a copy of this License along with the Program.
204
205 You may charge any price or no price for each copy that you convey,
206and you may offer support or warranty protection for a fee.
207
208 5. Conveying Modified Source Versions.
209
210 You may convey a work based on the Program, or the modifications to
211produce it from the Program, in the form of source code under the
212terms of section 4, provided that you also meet all of these conditions:
213
214 a) The work must carry prominent notices stating that you modified
215 it, and giving a relevant date.
216
217 b) The work must carry prominent notices stating that it is
218 released under this License and any conditions added under section
219 7. This requirement modifies the requirement in section 4 to
220 "keep intact all notices".
221
222 c) You must license the entire work, as a whole, under this
223 License to anyone who comes into possession of a copy. This
224 License will therefore apply, along with any applicable section 7
225 additional terms, to the whole of the work, and all its parts,
226 regardless of how they are packaged. This License gives no
227 permission to license the work in any other way, but it does not
228 invalidate such permission if you have separately received it.
229
230 d) If the work has interactive user interfaces, each must display
231 Appropriate Legal Notices; however, if the Program has interactive
232 interfaces that do not display Appropriate Legal Notices, your
233 work need not make them do so.
234
235 A compilation of a covered work with other separate and independent
236works, which are not by their nature extensions of the covered work,
237and which are not combined with it such as to form a larger program,
238in or on a volume of a storage or distribution medium, is called an
239"aggregate" if the compilation and its resulting copyright are not
240used to limit the access or legal rights of the compilation's users
241beyond what the individual works permit. Inclusion of a covered work
242in an aggregate does not cause this License to apply to the other
243parts of the aggregate.
244
245 6. Conveying Non-Source Forms.
246
247 You may convey a covered work in object code form under the terms
248of sections 4 and 5, provided that you also convey the
249machine-readable Corresponding Source under the terms of this License,
250in one of these ways:
251
252 a) Convey the object code in, or embodied in, a physical product
253 (including a physical distribution medium), accompanied by the
254 Corresponding Source fixed on a durable physical medium
255 customarily used for software interchange.
256
257 b) Convey the object code in, or embodied in, a physical product
258 (including a physical distribution medium), accompanied by a
259 written offer, valid for at least three years and valid for as
260 long as you offer spare parts or customer support for that product
261 model, to give anyone who possesses the object code either (1) a
262 copy of the Corresponding Source for all the software in the
263 product that is covered by this License, on a durable physical
264 medium customarily used for software interchange, for a price no
265 more than your reasonable cost of physically performing this
266 conveying of source, or (2) access to copy the
267 Corresponding Source from a network server at no charge.
268
269 c) Convey individual copies of the object code with a copy of the
270 written offer to provide the Corresponding Source. This
271 alternative is allowed only occasionally and noncommercially, and
272 only if you received the object code with such an offer, in accord
273 with subsection 6b.
274
275 d) Convey the object code by offering access from a designated
276 place (gratis or for a charge), and offer equivalent access to the
277 Corresponding Source in the same way through the same place at no
278 further charge. You need not require recipients to copy the
279 Corresponding Source along with the object code. If the place to
280 copy the object code is a network server, the Corresponding Source
281 may be on a different server (operated by you or a third party)
282 that supports equivalent copying facilities, provided you maintain
283 clear directions next to the object code saying where to find the
284 Corresponding Source. Regardless of what server hosts the
285 Corresponding Source, you remain obligated to ensure that it is
286 available for as long as needed to satisfy these requirements.
287
288 e) Convey the object code using peer-to-peer transmission, provided
289 you inform other peers where the object code and Corresponding
290 Source of the work are being offered to the general public at no
291 charge under subsection 6d.
292
293 A separable portion of the object code, whose source code is excluded
294from the Corresponding Source as a System Library, need not be
295included in conveying the object code work.
296
297 A "User Product" is either (1) a "consumer product", which means any
298tangible personal property which is normally used for personal, family,
299or household purposes, or (2) anything designed or sold for incorporation
300into a dwelling. In determining whether a product is a consumer product,
301doubtful cases shall be resolved in favor of coverage. For a particular
302product received by a particular user, "normally used" refers to a
303typical or common use of that class of product, regardless of the status
304of the particular user or of the way in which the particular user
305actually uses, or expects or is expected to use, the product. A product
306is a consumer product regardless of whether the product has substantial
307commercial, industrial or non-consumer uses, unless such uses represent
308the only significant mode of use of the product.
309
310 "Installation Information" for a User Product means any methods,
311procedures, authorization keys, or other information required to install
312and execute modified versions of a covered work in that User Product from
313a modified version of its Corresponding Source. The information must
314suffice to ensure that the continued functioning of the modified object
315code is in no case prevented or interfered with solely because
316modification has been made.
317
318 If you convey an object code work under this section in, or with, or
319specifically for use in, a User Product, and the conveying occurs as
320part of a transaction in which the right of possession and use of the
321User Product is transferred to the recipient in perpetuity or for a
322fixed term (regardless of how the transaction is characterized), the
323Corresponding Source conveyed under this section must be accompanied
324by the Installation Information. But this requirement does not apply
325if neither you nor any third party retains the ability to install
326modified object code on the User Product (for example, the work has
327been installed in ROM).
328
329 The requirement to provide Installation Information does not include a
330requirement to continue to provide support service, warranty, or updates
331for a work that has been modified or installed by the recipient, or for
332the User Product in which it has been modified or installed. Access to a
333network may be denied when the modification itself materially and
334adversely affects the operation of the network or violates the rules and
335protocols for communication across the network.
336
337 Corresponding Source conveyed, and Installation Information provided,
338in accord with this section must be in a format that is publicly
339documented (and with an implementation available to the public in
340source code form), and must require no special password or key for
341unpacking, reading or copying.
342
343 7. Additional Terms.
344
345 "Additional permissions" are terms that supplement the terms of this
346License by making exceptions from one or more of its conditions.
347Additional permissions that are applicable to the entire Program shall
348be treated as though they were included in this License, to the extent
349that they are valid under applicable law. If additional permissions
350apply only to part of the Program, that part may be used separately
351under those permissions, but the entire Program remains governed by
352this License without regard to the additional permissions.
353
354 When you convey a copy of a covered work, you may at your option
355remove any additional permissions from that copy, or from any part of
356it. (Additional permissions may be written to require their own
357removal in certain cases when you modify the work.) You may place
358additional permissions on material, added by you to a covered work,
359for which you have or can give appropriate copyright permission.
360
361 Notwithstanding any other provision of this License, for material you
362add to a covered work, you may (if authorized by the copyright holders of
363that material) supplement the terms of this License with terms:
364
365 a) Disclaiming warranty or limiting liability differently from the
366 terms of sections 15 and 16 of this License; or
367
368 b) Requiring preservation of specified reasonable legal notices or
369 author attributions in that material or in the Appropriate Legal
370 Notices displayed by works containing it; or
371
372 c) Prohibiting misrepresentation of the origin of that material, or
373 requiring that modified versions of such material be marked in
374 reasonable ways as different from the original version; or
375
376 d) Limiting the use for publicity purposes of names of licensors or
377 authors of the material; or
378
379 e) Declining to grant rights under trademark law for use of some
380 trade names, trademarks, or service marks; or
381
382 f) Requiring indemnification of licensors and authors of that
383 material by anyone who conveys the material (or modified versions of
384 it) with contractual assumptions of liability to the recipient, for
385 any liability that these contractual assumptions directly impose on
386 those licensors and authors.
387
388 All other non-permissive additional terms are considered "further
389restrictions" within the meaning of section 10. If the Program as you
390received it, or any part of it, contains a notice stating that it is
391governed by this License along with a term that is a further
392restriction, you may remove that term. If a license document contains
393a further restriction but permits relicensing or conveying under this
394License, you may add to a covered work material governed by the terms
395of that license document, provided that the further restriction does
396not survive such relicensing or conveying.
397
398 If you add terms to a covered work in accord with this section, you
399must place, in the relevant source files, a statement of the
400additional terms that apply to those files, or a notice indicating
401where to find the applicable terms.
402
403 Additional terms, permissive or non-permissive, may be stated in the
404form of a separately written license, or stated as exceptions;
405the above requirements apply either way.
406
407 8. Termination.
408
409 You may not propagate or modify a covered work except as expressly
410provided under this License. Any attempt otherwise to propagate or
411modify it is void, and will automatically terminate your rights under
412this License (including any patent licenses granted under the third
413paragraph of section 11).
414
415 However, if you cease all violation of this License, then your
416license from a particular copyright holder is reinstated (a)
417provisionally, unless and until the copyright holder explicitly and
418finally terminates your license, and (b) permanently, if the copyright
419holder fails to notify you of the violation by some reasonable means
420prior to 60 days after the cessation.
421
422 Moreover, your license from a particular copyright holder is
423reinstated permanently if the copyright holder notifies you of the
424violation by some reasonable means, this is the first time you have
425received notice of violation of this License (for any work) from that
426copyright holder, and you cure the violation prior to 30 days after
427your receipt of the notice.
428
429 Termination of your rights under this section does not terminate the
430licenses of parties who have received copies or rights from you under
431this License. If your rights have been terminated and not permanently
432reinstated, you do not qualify to receive new licenses for the same
433material under section 10.
434
435 9. Acceptance Not Required for Having Copies.
436
437 You are not required to accept this License in order to receive or
438run a copy of the Program. Ancillary propagation of a covered work
439occurring solely as a consequence of using peer-to-peer transmission
440to receive a copy likewise does not require acceptance. However,
441nothing other than this License grants you permission to propagate or
442modify any covered work. These actions infringe copyright if you do
443not accept this License. Therefore, by modifying or propagating a
444covered work, you indicate your acceptance of this License to do so.
445
446 10. Automatic Licensing of Downstream Recipients.
447
448 Each time you convey a covered work, the recipient automatically
449receives a license from the original licensors, to run, modify and
450propagate that work, subject to this License. You are not responsible
451for enforcing compliance by third parties with this License.
452
453 An "entity transaction" is a transaction transferring control of an
454organization, or substantially all assets of one, or subdividing an
455organization, or merging organizations. If propagation of a covered
456work results from an entity transaction, each party to that
457transaction who receives a copy of the work also receives whatever
458licenses to the work the party's predecessor in interest had or could
459give under the previous paragraph, plus a right to possession of the
460Corresponding Source of the work from the predecessor in interest, if
461the predecessor has it or can get it with reasonable efforts.
462
463 You may not impose any further restrictions on the exercise of the
464rights granted or affirmed under this License. For example, you may
465not impose a license fee, royalty, or other charge for exercise of
466rights granted under this License, and you may not initiate litigation
467(including a cross-claim or counterclaim in a lawsuit) alleging that
468any patent claim is infringed by making, using, selling, offering for
469sale, or importing the Program or any portion of it.
470
471 11. Patents.
472
473 A "contributor" is a copyright holder who authorizes use under this
474License of the Program or a work on which the Program is based. The
475work thus licensed is called the contributor's "contributor version".
476
477 A contributor's "essential patent claims" are all patent claims
478owned or controlled by the contributor, whether already acquired or
479hereafter acquired, that would be infringed by some manner, permitted
480by this License, of making, using, or selling its contributor version,
481but do not include claims that would be infringed only as a
482consequence of further modification of the contributor version. For
483purposes of this definition, "control" includes the right to grant
484patent sublicenses in a manner consistent with the requirements of
485this License.
486
487 Each contributor grants you a non-exclusive, worldwide, royalty-free
488patent license under the contributor's essential patent claims, to
489make, use, sell, offer for sale, import and otherwise run, modify and
490propagate the contents of its contributor version.
491
492 In the following three paragraphs, a "patent license" is any express
493agreement or commitment, however denominated, not to enforce a patent
494(such as an express permission to practice a patent or covenant not to
495sue for patent infringement). To "grant" such a patent license to a
496party means to make such an agreement or commitment not to enforce a
497patent against the party.
498
499 If you convey a covered work, knowingly relying on a patent license,
500and the Corresponding Source of the work is not available for anyone
501to copy, free of charge and under the terms of this License, through a
502publicly available network server or other readily accessible means,
503then you must either (1) cause the Corresponding Source to be so
504available, or (2) arrange to deprive yourself of the benefit of the
505patent license for this particular work, or (3) arrange, in a manner
506consistent with the requirements of this License, to extend the patent
507license to downstream recipients. "Knowingly relying" means you have
508actual knowledge that, but for the patent license, your conveying the
509covered work in a country, or your recipient's use of the covered work
510in a country, would infringe one or more identifiable patents in that
511country that you have reason to believe are valid.
512
513 If, pursuant to or in connection with a single transaction or
514arrangement, you convey, or propagate by procuring conveyance of, a
515covered work, and grant a patent license to some of the parties
516receiving the covered work authorizing them to use, propagate, modify
517or convey a specific copy of the covered work, then the patent license
518you grant is automatically extended to all recipients of the covered
519work and works based on it.
520
521 A patent license is "discriminatory" if it does not include within
522the scope of its coverage, prohibits the exercise of, or is
523conditioned on the non-exercise of one or more of the rights that are
524specifically granted under this License. You may not convey a covered
525work if you are a party to an arrangement with a third party that is
526in the business of distributing software, under which you make payment
527to the third party based on the extent of your activity of conveying
528the work, and under which the third party grants, to any of the
529parties who would receive the covered work from you, a discriminatory
530patent license (a) in connection with copies of the covered work
531conveyed by you (or copies made from those copies), or (b) primarily
532for and in connection with specific products or compilations that
533contain the covered work, unless you entered into that arrangement,
534or that patent license was granted, prior to 28 March 2007.
535
536 Nothing in this License shall be construed as excluding or limiting
537any implied license or other defenses to infringement that may
538otherwise be available to you under applicable patent law.
539
540 12. No Surrender of Others' Freedom.
541
542 If conditions are imposed on you (whether by court order, agreement or
543otherwise) that contradict the conditions of this License, they do not
544excuse you from the conditions of this License. If you cannot convey a
545covered work so as to satisfy simultaneously your obligations under this
546License and any other pertinent obligations, then as a consequence you may
547not convey it at all. For example, if you agree to terms that obligate you
548to collect a royalty for further conveying from those to whom you convey
549the Program, the only way you could satisfy both those terms and this
550License would be to refrain entirely from conveying the Program.
551
552 13. Use with the GNU Affero General Public License.
553
554 Notwithstanding any other provision of this License, you have
555permission to link or combine any covered work with a work licensed
556under version 3 of the GNU Affero General Public License into a single
557combined work, and to convey the resulting work. The terms of this
558License will continue to apply to the part which is the covered work,
559but the special requirements of the GNU Affero General Public License,
560section 13, concerning interaction through a network will apply to the
561combination as such.
562
563 14. Revised Versions of this License.
564
565 The Free Software Foundation may publish revised and/or new versions of
566the GNU General Public License from time to time. Such new versions will
567be similar in spirit to the present version, but may differ in detail to
568address new problems or concerns.
569
570 Each version is given a distinguishing version number. If the
571Program specifies that a certain numbered version of the GNU General
572Public License "or any later version" applies to it, you have the
573option of following the terms and conditions either of that numbered
574version or of any later version published by the Free Software
575Foundation. If the Program does not specify a version number of the
576GNU General Public License, you may choose any version ever published
577by the Free Software Foundation.
578
579 If the Program specifies that a proxy can decide which future
580versions of the GNU General Public License can be used, that proxy's
581public statement of acceptance of a version permanently authorizes you
582to choose that version for the Program.
583
584 Later license versions may give you additional or different
585permissions. However, no additional obligations are imposed on any
586author or copyright holder as a result of your choosing to follow a
587later version.
588
589 15. Disclaimer of Warranty.
590
591 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
600 16. Limitation of Liability.
601
602 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610SUCH DAMAGES.
611
612 17. Interpretation of Sections 15 and 16.
613
614 If the disclaimer of warranty and limitation of liability provided
615above cannot be given local legal effect according to their terms,
616reviewing courts shall apply local law that most closely approximates
617an absolute waiver of all civil liability in connection with the
618Program, unless a warranty or assumption of liability accompanies a
619copy of the Program in return for a fee.
620
621 END OF TERMS AND CONDITIONS
622
623 How to Apply These Terms to Your New Programs
624
625 If you develop a new program, and you want it to be of the greatest
626possible use to the public, the best way to achieve this is to make it
627free software which everyone can redistribute and change under these terms.
628
629 To do so, attach the following notices to the program. It is safest
630to attach them to the start of each source file to most effectively
631state the exclusion of warranty; and each file should have at least
632the "copyright" line and a pointer to where the full notice is found.
633
634 <one line to give the program's name and a brief idea of what it does.>
635 Copyright (C) <year> <name of author>
636
637 This program is free software: you can redistribute it and/or modify
638 it under the terms of the GNU General Public License as published by
639 the Free Software Foundation, either version 3 of the License, or
640 (at your option) any later version.
641
642 This program is distributed in the hope that it will be useful,
643 but WITHOUT ANY WARRANTY; without even the implied warranty of
644 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 GNU General Public License for more details.
646
647 You should have received a copy of the GNU General Public License
648 along with this program. If not, see <http://www.gnu.org/licenses/>.
649
650Also add information on how to contact you by electronic and paper mail.
651
652 If the program does terminal interaction, make it output a short
653notice like this when it starts in an interactive mode:
654
655 <program> Copyright (C) <year> <name of author>
656 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 This is free software, and you are welcome to redistribute it
658 under certain conditions; type `show c' for details.
659
660The hypothetical commands `show w' and `show c' should show the appropriate
661parts of the General Public License. Of course, your program's commands
662might be different; for a GUI interface, you would use an "about box".
663
664 You should also get your employer (if you work as a programmer) or school,
665if any, to sign a "copyright disclaimer" for the program, if necessary.
666For more information on this, and how to apply and follow the GNU GPL, see
667<http://www.gnu.org/licenses/>.
668
669 The GNU General Public License does not permit incorporating your program
670into proprietary programs. If your program is a subroutine library, you
671may consider it more useful to permit linking proprietary applications with
672the library. If this is what you want to do, use the GNU Lesser General
673Public License instead of this License. But first, please read
674<http://www.gnu.org/philosophy/why-not-lgpl.html>.
166675
=== added file 'COPYING.LIB'
--- COPYING.LIB 1970-01-01 00:00:00 +0000
+++ COPYING.LIB 2012-01-14 02:17:23 +0000
@@ -0,0 +1,165 @@
1 GNU LESSER GENERAL PUBLIC LICENSE
2 Version 3, 29 June 2007
3
4 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8
9 This version of the GNU Lesser General Public License incorporates
10the terms and conditions of version 3 of the GNU General Public
11License, supplemented by the additional permissions listed below.
12
13 0. Additional Definitions.
14
15 As used herein, "this License" refers to version 3 of the GNU Lesser
16General Public License, and the "GNU GPL" refers to version 3 of the GNU
17General Public License.
18
19 "The Library" refers to a covered work governed by this License,
20other than an Application or a Combined Work as defined below.
21
22 An "Application" is any work that makes use of an interface provided
23by the Library, but which is not otherwise based on the Library.
24Defining a subclass of a class defined by the Library is deemed a mode
25of using an interface provided by the Library.
26
27 A "Combined Work" is a work produced by combining or linking an
28Application with the Library. The particular version of the Library
29with which the Combined Work was made is also called the "Linked
30Version".
31
32 The "Minimal Corresponding Source" for a Combined Work means the
33Corresponding Source for the Combined Work, excluding any source code
34for portions of the Combined Work that, considered in isolation, are
35based on the Application, and not on the Linked Version.
36
37 The "Corresponding Application Code" for a Combined Work means the
38object code and/or source code for the Application, including any data
39and utility programs needed for reproducing the Combined Work from the
40Application, but excluding the System Libraries of the Combined Work.
41
42 1. Exception to Section 3 of the GNU GPL.
43
44 You may convey a covered work under sections 3 and 4 of this License
45without being bound by section 3 of the GNU GPL.
46
47 2. Conveying Modified Versions.
48
49 If you modify a copy of the Library, and, in your modifications, a
50facility refers to a function or data to be supplied by an Application
51that uses the facility (other than as an argument passed when the
52facility is invoked), then you may convey a copy of the modified
53version:
54
55 a) under this License, provided that you make a good faith effort to
56 ensure that, in the event an Application does not supply the
57 function or data, the facility still operates, and performs
58 whatever part of its purpose remains meaningful, or
59
60 b) under the GNU GPL, with none of the additional permissions of
61 this License applicable to that copy.
62
63 3. Object Code Incorporating Material from Library Header Files.
64
65 The object code form of an Application may incorporate material from
66a header file that is part of the Library. You may convey such object
67code under terms of your choice, provided that, if the incorporated
68material is not limited to numerical parameters, data structure
69layouts and accessors, or small macros, inline functions and templates
70(ten or fewer lines in length), you do both of the following:
71
72 a) Give prominent notice with each copy of the object code that the
73 Library is used in it and that the Library and its use are
74 covered by this License.
75
76 b) Accompany the object code with a copy of the GNU GPL and this license
77 document.
78
79 4. Combined Works.
80
81 You may convey a Combined Work under terms of your choice that,
82taken together, effectively do not restrict modification of the
83portions of the Library contained in the Combined Work and reverse
84engineering for debugging such modifications, if you also do each of
85the following:
86
87 a) Give prominent notice with each copy of the Combined Work that
88 the Library is used in it and that the Library and its use are
89 covered by this License.
90
91 b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 document.
93
94 c) For a Combined Work that displays copyright notices during
95 execution, include the copyright notice for the Library among
96 these notices, as well as a reference directing the user to the
97 copies of the GNU GPL and this license document.
98
99 d) Do one of the following:
100
101 0) Convey the Minimal Corresponding Source under the terms of this
102 License, and the Corresponding Application Code in a form
103 suitable for, and under terms that permit, the user to
104 recombine or relink the Application with a modified version of
105 the Linked Version to produce a modified Combined Work, in the
106 manner specified by section 6 of the GNU GPL for conveying
107 Corresponding Source.
108
109 1) Use a suitable shared library mechanism for linking with the
110 Library. A suitable mechanism is one that (a) uses at run time
111 a copy of the Library already present on the user's computer
112 system, and (b) will operate properly with a modified version
113 of the Library that is interface-compatible with the Linked
114 Version.
115
116 e) Provide Installation Information, but only if you would otherwise
117 be required to provide such information under section 6 of the
118 GNU GPL, and only to the extent that such information is
119 necessary to install and execute a modified version of the
120 Combined Work produced by recombining or relinking the
121 Application with a modified version of the Linked Version. (If
122 you use option 4d0, the Installation Information must accompany
123 the Minimal Corresponding Source and Corresponding Application
124 Code. If you use option 4d1, you must provide the Installation
125 Information in the manner specified by section 6 of the GNU GPL
126 for conveying Corresponding Source.)
127
128 5. Combined Libraries.
129
130 You may place library facilities that are a work based on the
131Library side by side in a single library together with other library
132facilities that are not Applications and are not covered by this
133License, and convey such a combined library under terms of your
134choice, if you do both of the following:
135
136 a) Accompany the combined library with a copy of the same work based
137 on the Library, uncombined with any other library facilities,
138 conveyed under the terms of this License.
139
140 b) Give prominent notice with the combined library that part of it
141 is a work based on the Library, and explaining where to find the
142 accompanying uncombined form of the same work.
143
144 6. Revised Versions of the GNU Lesser General Public License.
145
146 The Free Software Foundation may publish revised and/or new versions
147of the GNU Lesser General Public License from time to time. Such new
148versions will be similar in spirit to the present version, but may
149differ in detail to address new problems or concerns.
150
151 Each version is given a distinguishing version number. If the
152Library as you received it specifies that a certain numbered version
153of the GNU Lesser General Public License "or any later version"
154applies to it, you have the option of following the terms and
155conditions either of that published version or of any later version
156published by the Free Software Foundation. If the Library as you
157received it does not specify a version number of the GNU Lesser
158General Public License, you may choose any version of the GNU Lesser
159General Public License ever published by the Free Software Foundation.
160
161 If the Library as you received it specifies that a proxy can decide
162whether future versions of the GNU Lesser General Public License shall
163apply, that proxy's public statement of acceptance of any version is
164permanent authorization for you to choose that version for the
165Library.
0166
=== modified file 'MANIFEST.in'
--- MANIFEST.in 2010-11-02 15:50:32 +0000
+++ MANIFEST.in 2012-01-14 02:17:23 +0000
@@ -1,5 +1,4 @@
1include COPYING MANIFEST.in README1include COPYING COPYING.LIB MANIFEST.in README
2include run-tests rb.py rhythmdb.py2include run-tests
3recursive-include gst *.py
4recursive-include po *.po POTFILES.in3recursive-include po *.po POTFILES.in
5recursive-include umusicstore *.py *.glade *.mp3 *.rb-plugin.in4recursive-include ubuntuone *.py *.glade *.mp3 *.rb-plugin.in
65
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in 2010-09-13 03:43:27 +0000
+++ po/POTFILES.in 2012-01-14 02:17:23 +0000
@@ -1,5 +1,4 @@
1umusicstore/__init__.py1ubuntuone/ubuntuone.py
2umusicstore/MusicStoreWidget.py2ubuntuone/MusicStoreWidget.py
3umusicstore/U1MSLinks.py3[type: gettext/ini]ubuntuone/ubuntuone.plugin.in
4[type: gettext/ini]umusicstore/umusicstore.rb-plugin.in
54
65
=== removed file 'rb.py'
--- rb.py 2011-04-05 21:31:48 +0000
+++ rb.py 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1"""Fake rb.py for use in testing."""
2
3SOURCE_GROUP_CATEGORY_FIXED = 0
4
5
6class Plugin(object):
7 """Fake Plugin class for testing."""
8
9 def __init__(self, *args, **kwargs):
10 super(Plugin, self).__init__()
11
12 def find_file(self, *args, **kwargs):
13 """Fake find_file method."""
14 pass
15
16
17class Source(object):
18 """Fake Source class for testing."""
19
20 add = __fake_it
21 remove = __fake_it
22 show_all = __fake_it
23 do_impl_activate = __fake_it
24
25 def __fake_it(self, *args, **kwargs):
26 """Fake method."""
27
28
29def rb_source_group_get_by_name(*args, **kwargs):
30 """Fake method."""
31 return
32
33def rb_display_page_group_get_by_id(*args, **kwargs):
34 """Fake method."""
35 return
36
37def rb_source_group_register(*args, **kwargs):
38 """Fake method."""
39 return
400
=== removed file 'rhythmdb.py'
--- rhythmdb.py 2010-11-02 15:50:32 +0000
+++ rhythmdb.py 1970-01-01 00:00:00 +0000
@@ -1,12 +0,0 @@
1"""Fake rhythmdb.py for use in testing."""
2
3PROP_ARTIST = 0
4PROP_TITLE = 1
5PROP_ALBUM = 2
6
7
8class EntryType(object):
9 """Fake EntryType object."""
10
11 def __init__(self, *args, **kwargs):
12 super(EntryType, self).__init__()
130
=== modified file 'run-tests'
--- run-tests 2010-11-02 15:50:32 +0000
+++ run-tests 2012-01-14 02:17:23 +0000
@@ -14,7 +14,7 @@
14#14#
15# You should have received a copy of the GNU General Public License along15# You should have received a copy of the GNU General Public License along
16# with this program. If not, see <http://www.gnu.org/licenses/>.16# with this program. If not, see <http://www.gnu.org/licenses/>.
17export PYTHONPATH=umusicstore17export PYTHONPATH=ubuntuone
18u1lint .18u1lint .
19if [ -x `which pep8` ]; then19if [ -x `which pep8` ]; then
20 pep8 --repeat .20 pep8 --repeat .
2121
=== modified file 'setup.cfg'
--- setup.cfg 2010-04-14 21:37:08 +0000
+++ setup.cfg 2012-01-14 02:17:23 +0000
@@ -1,2 +1,2 @@
1[build_i18n]1[build_i18n]
2desktop_files=[("lib/rhythmbox/plugins/umusicstore", ("umusicstore/umusicstore.rb-plugin.in",))]2desktop_files=[("lib/rhythmbox/plugins/ubuntuone", ("ubuntuone/ubuntuone.plugin.in",))]
33
=== modified file 'setup.py'
--- setup.py 2011-11-14 18:31:48 +0000
+++ setup.py 2012-01-14 02:17:23 +0000
@@ -3,20 +3,19 @@
33
4import DistUtilsExtra.auto4import DistUtilsExtra.auto
55
6
6DistUtilsExtra.auto.setup(7DistUtilsExtra.auto.setup(
7 name='rhythmbox-ubuntuone-music-store',8 name='rhythmbox-ubuntuone',
8 version='3.1',9 version='3.1',
9 license='LGPL v3',10 license='LGPL v3',
10 author='Stuart Langridge',11 author='Ubuntu One Developers',
11 author_email='stuart.langridge@canonical.com',12 author_email='ubuntuone-users@lists.launchpad.net',
12 description='Ubuntu One Music Store Rhythmbox plug-in',13 description='Ubuntu One Music Store Rhythmbox plug-in',
13 long_description=('A plug-in to access the Ubuntu One Music Store '14 long_description=('A plug-in to integrate Ubuntu One in Rhythmbox.'),
14 'in Rhythmbox.'),15 url='https://launchpad.net/rhythmbox-ubuntuone',
15 url='https://launchpad.net/rhythmbox-ubuntuone-music-store',16 data_files=[('/usr/lib/rhythmbox/plugins/ubuntuone',
16 data_files=[('/usr/lib/rhythmbox/plugins/umusicstore',17 ['ubuntuone/__init__.py',
17 ['umusicstore/__init__.py',18 'ubuntuone/MusicStoreWidget.py',
18 'umusicstore/MusicStoreWidget.py',19 'ubuntuone/U1MSLinks.py',
19 'umusicstore/U1MSLinks.py',20 'ubuntuone/u1msurl.glade'])],
20 'umusicstore/u1msurl.glade'])],
21 )21 )
22
2322
=== renamed directory 'umusicstore' => 'ubuntuone'
=== modified file 'ubuntuone/MusicStoreWidget.py'
--- umusicstore/MusicStoreWidget.py 2011-04-05 21:31:48 +0000
+++ ubuntuone/MusicStoreWidget.py 2012-01-14 02:17:23 +0000
@@ -1,5 +1,4 @@
1"""The Ubuntu One Music Store Rhythmbox plugin."""1# Copyright (C) 2009-2012 Canonical, Ltd.
2# Copyright (C) 2009 Canonical, Ltd.
3#2#
4# This library is free software; you can redistribute it and/or modify3# This library is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License4# it under the terms of the GNU Lesser General Public License
@@ -13,35 +12,25 @@
13# You should have received a copy of the GNU Lesser General Public12# You should have received a copy of the GNU Lesser General Public
14# License along with this library. If not, see13# License along with this library. If not, see
15# <http://www.gnu.org/licenses/>.14# <http://www.gnu.org/licenses/>.
16#15"""The Ubuntu One Rhythmbox plugin."""
17# Authored by Stuart Langridge <stuart.langridge@canonical.com>16
18
19# pylint: disable=W0201
20
21# Import these here as gtk/gio import ordering seems to matter
22import gobject
23import gtk
24import gio
25
26import gconf
27import gettext17import gettext
28import os18import os
29# pylint: disable=F0401
30import rb as RB
31import rhythmdb
32# pylint: enable=F0401
33import stat19import stat
34import urllib
35import urlparse20import urlparse
36import xdg.BaseDirectory21
3722# pylint: disable=E0611
23from gi.repository import Gio, GObject, Gtk, RB
24# pylint: enable=E0611
25
26from dirspec import basedir
38from gettext import lgettext as _27from gettext import lgettext as _
39from ubuntuone.gtkwidgets import MusicStore as U1MusicStore28#from ubuntuone.gtkwidgets import MusicStore as U1MusicStore
4029
41gettext.bindtextdomain("rhythmbox-ubuntuone-music-store", "/usr/share/locale")30gettext.bindtextdomain("rhythmbox-ubuntuone-music-store", "/usr/share/locale")
42gettext.textdomain("rhythmbox-ubuntuone-music-store")31gettext.textdomain("rhythmbox-ubuntuone-music-store")
4332
44MUSIC_STORE_WIDGET = U1MusicStore() # keep this around for later33MUSIC_STORE_WIDGET = Gtk.EventBox() # keep this around for later
45U1LIBRARYPATH = MUSIC_STORE_WIDGET.get_library_location()34U1LIBRARYPATH = MUSIC_STORE_WIDGET.get_library_location()
46RB_LIBRARY_LOCATIONS = "/apps/rhythmbox/library_locations"35RB_LIBRARY_LOCATIONS = "/apps/rhythmbox/library_locations"
47PARTNER_LIST = "canonical-partner-maverick.list"36PARTNER_LIST = "canonical-partner-maverick.list"
@@ -49,11 +38,11 @@
49PLUGIN_PACKAGENAME = "gstreamer0.10-fluendo-plugins-mp3-partner"38PLUGIN_PACKAGENAME = "gstreamer0.10-fluendo-plugins-mp3-partner"
5039
5140
52class U1EntryType(rhythmdb.EntryType):41class U1EntryType(RB.RhythmDBEntryType):
53 """Entry type for the Ubuntu One Music Store source."""42 """Entry type for the Ubuntu One Music Store source."""
5443
55 def __init__(self):44 def __init__(self):
56 rhythmdb.EntryType.__init__(self, name='ubuntuone')45 RB.RhythmDBEntryType.__init__(self, name='ubuntuone')
5746
58 def do_can_sync_metadata(self, entry):47 def do_can_sync_metadata(self, entry):
59 """Not a real source, so we can't sync metadata."""48 """Not a real source, so we can't sync metadata."""
@@ -68,6 +57,10 @@
68 """The Ubuntu One Music Store."""57 """The Ubuntu One Music Store."""
69 def __init__(self, plugin):58 def __init__(self, plugin):
70 self.plugin = plugin59 self.plugin = plugin
60 self.db = None
61 self.shell = None
62 self.source = None
63 self.u1_library_symlink = None
71 self.entry_type = U1EntryType()64 self.entry_type = U1EntryType()
7265
73 def activate(self, shell):66 def activate(self, shell):
@@ -75,12 +68,12 @@
75 self.db = shell.get_property("db")68 self.db = shell.get_property("db")
76 group = RB.rb_display_page_group_get_by_id("stores")69 group = RB.rb_display_page_group_get_by_id("stores")
7770
78 icon = gtk.IconTheme().load_icon(71 icon = Gtk.IconTheme.get_default().load_icon(
79 "ubuntuone", gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)[0], 0)72 "ubuntuone", Gtk.IconSize.lookup(Gtk.IconSize.MENU)[0], 0)
8073
81 self.db.register_entry_type(self.entry_type)74 self.db.register_entry_type(self.entry_type)
8275
83 self.source = gobject.new(U1Source,76 self.source = GObject.new(U1Source,
84 shell=shell,77 shell=shell,
85 entry_type=self.entry_type,78 entry_type=self.entry_type,
86 pixbuf=icon,79 pixbuf=icon,
@@ -101,22 +94,6 @@
101 """Plugin shutdown."""94 """Plugin shutdown."""
102 # remove source95 # remove source
103 self.source.delete_thyself()96 self.source.delete_thyself()
104 # remove the library, if it's empty
105 try:
106 filecount = len(os.listdir(self.u1_library_symlink))
107 except OSError:
108 # symlink is dangling
109 # so they never downloaded anything
110 filecount = 0
111 if filecount == 0:
112 client = gconf.client_get_default()
113 libraries = client.get_list(RB_LIBRARY_LOCATIONS,
114 gconf.VALUE_STRING)
115 if self.u1_library_path_url in libraries:
116 client.notify_remove(self.library_adder)
117 libraries.remove(self.u1_library_path_url)
118 client.set_list(RB_LIBRARY_LOCATIONS,
119 gconf.VALUE_STRING, libraries)
120 # delete held references97 # delete held references
121 del self.db98 del self.db
122 del self.source99 del self.source
@@ -145,7 +122,7 @@
145 library_path = os.path.join(self.u1_library_symlink, subpath)122 library_path = os.path.join(self.u1_library_symlink, subpath)
146 # convert path to URI. Don't use urllib for this; Python and123 # convert path to URI. Don't use urllib for this; Python and
147 # glib escape URLs differently. gio does it the glib way.124 # glib escape URLs differently. gio does it the glib way.
148 library_uri = gio.File(library_path).get_uri()125 library_uri = Gio.File(library_path).get_uri()
149 return library_uri126 return library_uri
150127
151 def download_finished(self, source, path):128 def download_finished(self, source, path):
@@ -165,8 +142,10 @@
165 libsrc = self.shell.props.library_source142 libsrc = self.shell.props.library_source
166 artist_view, album_view = libsrc.get_property_views()[0:2]143 artist_view, album_view = libsrc.get_property_views()[0:2]
167 song_view = libsrc.get_entry_view()144 song_view = libsrc.get_entry_view()
168 artist = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ARTIST)145 artist = self.shell.props.db.entry_get(entry,
169 album = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ALBUM)146 RB.RhythmDBPropType.ARTIST)
147 album = self.shell.props.db.entry_get(entry,
148 RB.RhythmDBPropType.ALBUM)
170 self.shell.props.display_page_tree.select(libsrc)149 self.shell.props.display_page_tree.select(libsrc)
171 artist_view.set_selection([artist])150 artist_view.set_selection([artist])
172 album_view.set_selection([album])151 album_view.set_selection([album])
@@ -181,7 +160,7 @@
181 entry = self.shell.props.db.entry_lookup_by_location(url)160 entry = self.shell.props.db.entry_lookup_by_location(url)
182 if entry is None:161 if entry is None:
183 entry = self.shell.props.db.entry_new(self.entry_type, url)162 entry = self.shell.props.db.entry_new(self.entry_type, url)
184 self.shell.props.db.set(entry, rhythmdb.PROP_TITLE, title)163 self.shell.props.db.set(entry, RB.RhythmDBPropType.TITLE, title)
185 player = self.shell.get_player()164 player = self.shell.get_player()
186 player.stop()165 player.stop()
187 player.play_entry(entry, self.source)166 player.play_entry(entry, self.source)
@@ -189,7 +168,7 @@
189168
190 def add_u1_library(self):169 def add_u1_library(self):
191 """Add the U1 library if not listed in RB and re-add if changed."""170 """Add the U1 library if not listed in RB and re-add if changed."""
192 u1_library_path_folder = xdg.BaseDirectory.save_data_path("ubuntuone")171 u1_library_path_folder = basedir.save_data_path("ubuntuone")
193 # Ensure that we can write to the folder, because syncdaemon creates it172 # Ensure that we can write to the folder, because syncdaemon creates it
194 # with no write permissions173 # with no write permissions
195 os.chmod(u1_library_path_folder,174 os.chmod(u1_library_path_folder,
@@ -212,90 +191,35 @@
212 "you know what you're doing. If this is a problem, then "191 "you know what you're doing. If this is a problem, then "
213 "delete or rename %s.") % (u1_library_path, U1LIBRARYPATH,192 "delete or rename %s.") % (u1_library_path, U1LIBRARYPATH,
214 u1_library_path)193 u1_library_path)
215 self.u1_library_path_url = "file://%s" % urllib.quote(u1_library_path)
216 self.u1_library_symlink = u1_library_path194 self.u1_library_symlink = u1_library_path
217 client = gconf.client_get_default()195
218 self._add_u1_library_if_not_present(client)196
219 self._remove_old_u1_library_if_present(client)197class U1Source(RB.Source):
220 # Watch for changes to the gconf key and re-add the library
221 self.library_adder = client.notify_add(
222 RB_LIBRARY_LOCATIONS,
223 self._add_u1_library_if_not_present)
224
225 def _add_u1_library_if_not_present(self, client, *args, **kwargs):
226 """Check for the U1 library and add to libraries list."""
227 libraries = client.get_list(RB_LIBRARY_LOCATIONS, gconf.VALUE_STRING)
228 if self.u1_library_path_url not in libraries:
229 libraries.append(self.u1_library_path_url)
230 client.set_list(RB_LIBRARY_LOCATIONS,
231 gconf.VALUE_STRING, libraries)
232
233 def _remove_old_u1_library_if_present(self, client, *args, **kwargs):
234 """Check for the old U1 library and remove it from libraries list."""
235 libraries = client.get_list(RB_LIBRARY_LOCATIONS, gconf.VALUE_STRING)
236 removed = False
237 # originally, this was the library path. Someone might have this.
238 old_path = "file://%s" % os.path.expanduser("~/.ubuntuone/musicstore")
239 if old_path in libraries:
240 libraries.remove(old_path)
241 removed = True
242 # Then, this was the library path, which we put into gconf unescaped
243 actual_udf_path_unescaped = "file://%s" % U1LIBRARYPATH
244 if actual_udf_path_unescaped in libraries:
245 libraries.remove(actual_udf_path_unescaped)
246 removed = True
247 # In theory, no-one should have the escaped path, but let's check
248 actual_udf_path_escaped = "file://%s" % U1LIBRARYPATH
249 if actual_udf_path_escaped in libraries:
250 libraries.remove(actual_udf_path_escaped)
251 removed = True
252 # Also, remove any library which is in .local/share and *isn't*
253 # the current library. This caters for people who got the library
254 # created under one name (say, English) and then had it created
255 # under another (say, after a translation to Dutch)
256 u1_library_path_folder = xdg.BaseDirectory.save_data_path("ubuntuone")
257 u1_library_path_folder_url = "file://%s" % urllib.quote(
258 u1_library_path_folder)
259 symlink_url = "file://" + urllib.quote(self.u1_library_symlink)
260 for lib in libraries:
261 if lib.startswith(u1_library_path_folder_url) and \
262 lib != symlink_url:
263 libraries.remove(lib)
264 # and delete the symlink itself
265 symlink_to_remove = urllib.unquote(lib[7:])
266 os.unlink(symlink_to_remove)
267 removed = True
268 if removed:
269 client.set_list(RB_LIBRARY_LOCATIONS,
270 gconf.VALUE_STRING, libraries)
271
272
273class U1Source(RB.Source, gobject.GObject):
274 """A Rhythmbox source widget for the U1 Music Store."""198 """A Rhythmbox source widget for the U1 Music Store."""
275 # gproperties required so that rb.Source is instantiable199 # gproperties required so that rb.Source is instantiable
276 __gproperties__ = {200 __gproperties__ = {
277 'plugin': (RB.Plugin, 'plugin', 'plugin',201 'plugin': (RB.Plugin, 'plugin', 'plugin',
278 gobject.PARAM_WRITABLE | gobject.PARAM_CONSTRUCT_ONLY),202 GObject.PARAM_WRITABLE | GObject.PARAM_CONSTRUCT_ONLY),
279 }203 }
280 # we have the preview-mp3 signal; we receive it from the widget, and204 # we have the preview-mp3 signal; we receive it from the widget, and
281 # re-emit it so that the plugin gets it, because the plugin actually205 # re-emit it so that the plugin gets it, because the plugin actually
282 # plays the mp3206 # plays the mp3
283 __gsignals__ = {207 __gsignals__ = {
284 "preview-mp3": (gobject.SIGNAL_RUN_FIRST,208 "preview-mp3": (GObject.SIGNAL_RUN_FIRST,
285 gobject.TYPE_NONE, (str, str)),209 GObject.TYPE_NONE, (str, str)),
286 "play-library": (gobject.SIGNAL_RUN_FIRST,210 "play-library": (GObject.SIGNAL_RUN_FIRST,
287 gobject.TYPE_NONE, (str,)),211 GObject.TYPE_NONE, (str,)),
288 "download-finished": (gobject.SIGNAL_RUN_FIRST,212 "download-finished": (GObject.SIGNAL_RUN_FIRST,
289 gobject.TYPE_NONE, (str,)),213 GObject.TYPE_NONE, (str,)),
290 "url-loaded": (gobject.SIGNAL_RUN_FIRST,214 "url-loaded": (GObject.SIGNAL_RUN_FIRST,
291 gobject.TYPE_NONE, (str,)),215 GObject.TYPE_NONE, (str,)),
292 }216 }
293217
294 def __init__(self):218 def __init__(self):
295 RB.Source.__init__(self, name=_("Ubuntu One"))219 RB.Source.__init__(self, name=_("Ubuntu One"))
296 gobject.GObject.__init__(self)
297 self.browser = MUSIC_STORE_WIDGET220 self.browser = MUSIC_STORE_WIDGET
298 self.__activated = False221 self.__activated = False
222 self.__plugin = None
299 self.add_music_store_widget()223 self.add_music_store_widget()
300224
301 def do_impl_activate(self):225 def do_impl_activate(self):
@@ -317,6 +241,7 @@
317 return False241 return False
318 uri_to_use = uri.replace("u1ms://", "http://")242 uri_to_use = uri.replace("u1ms://", "http://")
319 print "Calling u1musicstore plugin with %s" % uri_to_use243 print "Calling u1musicstore plugin with %s" % uri_to_use
244 # pylint: disable=E1101
320 shell = self.get_property("shell")245 shell = self.get_property("shell")
321 shell.props.display_page_tree.select(self)246 shell.props.display_page_tree.select(self)
322 self.browser.load_store_link(uri_to_use)247 self.browser.load_store_link(uri_to_use)
@@ -324,6 +249,7 @@
324249
325 def add_music_store_widget(self):250 def add_music_store_widget(self):
326 """Display the music store widget in Rhythmbox."""251 """Display the music store widget in Rhythmbox."""
252 # pylint: disable=E1101
327 self.add(self.browser)253 self.add(self.browser)
328 self.browser.show()254 self.browser.show()
329 self.show()255 self.show()
@@ -343,25 +269,28 @@
343 return True # so we can pause, else we segfault269 return True # so we can pause, else we segfault
344270
345 def re_emit_preview(self, widget, url, title):271 def re_emit_preview(self, widget, url, title):
346 """Handle the preview-mp3 signal and re-emit it to rb.Plugin."""272 """Handle the preview-mp3 signal and re-emit it."""
273 # pylint: disable=E1101
347 self.emit("preview-mp3", url, title)274 self.emit("preview-mp3", url, title)
348275
349 def re_emit_playlibrary(self, widget, path):276 def re_emit_playlibrary(self, widget, path):
350 """Handle the play-library signal and re-emit it to rb.Plugin."""277 """Handle the play-library signal and re-emit it."""
278 # pylint: disable=E1101
351 self.emit("play-library", path)279 self.emit("play-library", path)
352280
353 def re_emit_downloadfinished(self, widget, path):281 def re_emit_downloadfinished(self, widget, path):
354 """Handle the download-finished signal and re-emit it to rb.Plugin."""282 """Handle the download-finished signal and re-emit it."""
283 # pylint: disable=E1101
355 self.emit("download-finished", path)284 self.emit("download-finished", path)
356285
357 def re_emit_urlloaded(self, widget, url):286 def re_emit_urlloaded(self, widget, url):
358 """Handle the url-loaded signal and re-emit it to rb.Plugin."""287 """Handle the url-loaded signal and re-emit it."""
359 self.emit("url-loaded", url)288 # pylint: disable=E1101
289 self.signal_emit_by_name("url-loaded", url)
360290
361 def do_set_property(self, prop, value):291 def do_set_property(self, prop, value):
362 """Allow property settings to handle the plugin call."""292 """Allow property settings to handle the plug-in call."""
363 if prop.name == 'plugin':293 if prop.name == 'plugin':
364 self.__plugin = value294 self.__plugin = value
365 else:295 else:
366 raise AttributeError('unknown property %s' % prop.name)296 raise AttributeError('unknown property %s' % prop.name)
367
368297
=== renamed file 'umusicstore/umusicstore.rb-plugin.in' => 'ubuntuone/ubuntuone.plugin.in'
--- umusicstore/umusicstore.rb-plugin.in 2010-03-25 08:13:45 +0000
+++ ubuntuone/ubuntuone.plugin.in 2012-01-14 02:17:23 +0000
@@ -1,10 +1,11 @@
1[RB Plugin]1[Plugin]
2Loader=python2Loader=python
3Module=umusicstore3Module=ubuntuone
4IAge=14IAge=1
5_Name=Ubuntu One Music Store5Depends=rb
6_Description=The Ubuntu One Music Store6Name=Ubuntu One
7Authors=Stuart Langridge <stuart.langridge@canonical.com>, Rodrigo Moya <rodrigo.moya@canonical.com>7_Description=Integration of Ubuntu One for Rhythmbox.
8Copyright=Copyright © 2009 Canonical8Authors=Ubuntu One Developers <ubuntuone-users@lists.launchpad.net>
9Copyright=Copyright © 2009-2012 Canonical
9Website=http://one.ubuntu.com/10Website=http://one.ubuntu.com/
1011
1112
=== renamed file 'umusicstore/__init__.py' => 'ubuntuone/ubuntuone.py'
--- umusicstore/__init__.py 2011-04-05 21:31:48 +0000
+++ ubuntuone/ubuntuone.py 2012-01-14 02:17:23 +0000
@@ -1,5 +1,4 @@
1"""The Ubuntu One Music Store Rhythmbox plugin."""1# Copyright (C) 2009-2012 Canonical, Ltd.
2# Copyright (C) 2009 Canonical, Ltd.
3#2#
4# This library is free software; you can redistribute it and/or modify3# This library is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License4# it under the terms of the GNU Lesser General Public License
@@ -13,46 +12,52 @@
13# You should have received a copy of the GNU Lesser General Public12# You should have received a copy of the GNU Lesser General Public
14# License along with this library. If not, see13# License along with this library. If not, see
15# <http://www.gnu.org/licenses/>.14# <http://www.gnu.org/licenses/>.
16#15"""The Ubuntu One Rhythmbox plugin."""
17# Authored by Stuart Langridge <stuart.langridge@canonical.com>16
1817import os
19import gconf18
20import rb as RB19# pylint: disable=E0611
2120from gi.repository import Gio, GLib, GObject, Peas
22from .MusicStoreWidget import U1MusicStoreWidget21# pylint: enable=E0611
23from .U1MSLinks import U1MSLinkProvider22
2423# We aren't actually providing a music store widget at the moment,
25U1_FIRST_TIME_FLAG_ENTRY = \24# as libu1 needs to be ported to gtk3 first. We may add it back later.
26 "/apps/rhythmbox/plugins/umusicstore/first_time_flag"25#from MusicStoreWidget import U1MusicStoreWidget
2726
2827
29class U1MusicStorePlugin (RB.Plugin):28class UbuntuOnePlugin (GObject.GObject, Peas.Activatable):
30 """The Ubuntu One Music Store."""29 """Ubuntu One integration for Rhythmbox."""
30 __gtype_name__ = 'UbuntuOnePlugin'
31 object = GObject.property(type=GObject.GObject)
3132
32 def __init__(self):33 def __init__(self):
33 RB.Plugin.__init__(self)34 GObject.GObject.__init__(self)
35
36 # The folder where files get stored
37 self.u1_library_path_url = 'file://{0}'.format(
38 os.path.join(GLib.get_home_dir(),
39 '.ubuntuone',
40 'Purchased from Ubuntu One'))
41 # RhythmDB settings so we can handle changes
42 self.rdbconf = Gio.Settings('org.gnome.rhythmbox.rhythmdb')
43 self.rdbconf.connect('changed::locations', self._locations_changed)
3444
35 # The Music Store itself45 # The Music Store itself
36 self.music_store_widget = U1MusicStoreWidget(plugin=self)46 #self.music_store_widget = U1MusicStoreWidget(plugin=self)
3747
38 # The Links button48 def _locations_changed(self, *args, **kwargs):
39 self.music_store_links_provider = U1MSLinkProvider(49 """Handle the locations setting being changed."""
40 find_file=self.find_file)50 libraries = self.rdbconf.get_strv('locations')
4151 if self.u1_library_path_url not in libraries:
42 def activate(self, shell):52 libraries.append(self.u1_library_path_url)
43 """Plugin startup."""53 self.rdbconf.set_strv('locations', libraries)
44 self.music_store_widget.activate(shell)54
45 self.music_store_links_provider.activate(shell)55 def do_activate(self):
4656 """Plug-in startup."""
47 # Select the source if it's the first time57 # Add the Ubuntu One purchased music directory if not already added
48 conf_client = gconf.client_get_default()58 self._locations_changed()
49 if not conf_client.get_bool(U1_FIRST_TIME_FLAG_ENTRY):59 #self.music_store_widget.activate(shell)
50 shell.props.display_page_tree.select(60
51 self.music_store_widget.source)61 def do_deactivate(self):
52 conf_client.set_bool(U1_FIRST_TIME_FLAG_ENTRY, True)62 """Plug-in shutdown."""
5363 #self.music_store_widget.deactivate(shell)
54 def deactivate(self, shell):
55 """Plugin shutdown."""
56 self.music_store_widget.deactivate(shell)
57 self.music_store_links_provider.deactivate(shell)
58
5964
=== removed file 'umusicstore/U1MSLinks.py'
--- umusicstore/U1MSLinks.py 2010-12-22 19:16:06 +0000
+++ umusicstore/U1MSLinks.py 1970-01-01 00:00:00 +0000
@@ -1,380 +0,0 @@
1"""The Ubuntu One Music Store Links plugin."""
2# Copyright (C) 2010 Canonical, Ltd.
3#
4# This library is free software; you can redistribute it and/or modify
5# it under the terms of the GNU Lesser General Public License
6# version 3.0 as published by the Free Software Foundation.
7#
8# This library is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU Lesser General Public License version 3.0 for more details.
12#
13# You should have received a copy of the GNU Lesser General Public
14# License along with this library. If not, see
15# <http://www.gnu.org/licenses/>.
16#
17# Authored by Stuart Langridge <stuart.langridge@canonical.com>
18
19# Import gtk+/gio bits here because order matters for some unknown reason
20import glib
21import gtk
22import gio
23
24import cgi
25import gettext
26import locale
27import operator
28import os
29import re
30import rhythmdb
31import unicodedata
32import urllib
33import xml.parsers
34
35from gettext import lgettext as _
36from xml.dom import minidom
37
38try:
39 import gwibber.lib.gtk.widgets
40 GWIBBER_AVAILABLE = True
41except ImportError:
42 GWIBBER_AVAILABLE = False
43
44gettext.bindtextdomain("rhythmbox-ubuntuone-music-store", "/usr/share/locale")
45gettext.textdomain("rhythmbox-ubuntuone-music-store")
46
47UI_STR = \
48"""<ui>
49 <menubar name="MenuBar">
50 <menu name="ViewMenu" action="View">
51 <placeholder name="ViewMenuModePlaceholder">
52 <menuitem name="ViewMenuGetU1MSLink" action="GetU1MSLink"/>
53 </placeholder>
54 </menu>
55 </menubar>
56 <toolbar name="ToolBar">
57 <placeholder name="ToolBarPluginPlaceholder">
58 <toolitem name="U1MSLink" action="GetU1MSLink"/>
59 </placeholder>
60 </toolbar>
61</ui>"""
62
63ERRORS = {
64 "could-not-detect": _("Unable to automatically detect which "
65 "song is currently playing. Please try searching for "
66 "the song in the Ubuntu One Music Store."),
67 "could-not-find": _("Unable to automatically find the song that is "
68 "currently playing in the Ubuntu One Music Store. "
69 "Please try searching manually."),
70 "could-not-connect": _("Unable to look up the song (couldn't connect "
71 "to Ubuntu One). Please check your internet "
72 "connection, or try again shortly.")}
73
74BASE_URL = os.environ.get("U1MSLINK_BASE_URL", "https://one.ubuntu.com")
75# getpreferredencoding isn't threadsafe, but we should be OK
76PREFERRED_ENCODING = locale.getpreferredencoding()
77SCRUBBING_RE = re.compile(r"[\W\s]+", re.UNICODE)
78CLEANING_RE = re.compile(r"\s+", re.UNICODE)
79
80
81def normalize(string):
82 """Normalize the given string, to increase the chances of a match"""
83 # rule #0 of unicode mangling: first, normalize
84 na = unicodedata.normalize('NFKD', string)
85 # then, strip everything that's not alphanumeric
86 na = re.sub(SCRUBBING_RE, "", na)
87 # \w leaves _s
88 na = na.replace("_", " ")
89 # then, unify spaces
90 na = re.sub(CLEANING_RE, " ", na).strip()
91 # finally, lowercase
92 na = na.lower()
93 # if there's anything left, go with that, otherwise rollback
94 return na if na else string
95
96
97def modified_levenshtein(start, end):
98 """Calculates the Levenshtein distance between start and end,
99 but counts added characters as worth 0 (thus meaning that 'Foo' will match
100 'Foo (Radio Edit)' with a high degree of accuracy.)"""
101 start = normalize(start)
102 end = normalize(end)
103 ls, le = len(start), len(end)
104 if ls > le:
105 # Make sure ls <= le, to use O(min(ls, le)) space
106 start, end = end, start
107 ls, le = le, ls
108
109 current = range(ls + 1)
110 for pose in range(1, le + 1):
111 previous, current = current, [pose] + [0] * ls
112 for poss in range(1, ls + 1):
113 delete = current[poss - 1] + 1
114 change = previous[poss - 1]
115 if start[poss - 1] != end[pose - 1]:
116 change = change + 1
117 # replace add with 10000 to not count adds
118 current[poss] = min(10000, delete, change)
119
120 return current[ls]
121
122
123class U1MSLinkProvider(object):
124 """Get a public link for any playing song to buy it in
125 the Ubuntu One Music Store."""
126
127 def __init__(self, find_file):
128 self.find_file = find_file
129 self.track_fetch = None
130 self.artist_fetch = None
131 self.win = None
132 self.button = None
133 self.action_group = None
134 self.builder = None
135 self.pvb = None
136 self.tweet_button = None
137 self.message = None
138 self.ui_id = None
139 self.image = None
140
141 def activate(self, shell):
142 """Plugin startup."""
143 # Add button and menu item
144 action = gtk.Action("GetU1MSLink", _("Get link to Music Store"),
145 _("Get a link for the current song to the Ubuntu One Music Store"),
146 "view-u1mslink")
147 action.set_icon_name("ubuntuone")
148 action.connect("activate", self.get_link, shell)
149 manager = shell.get_player().get_property("ui-manager")
150 self.action_group = gtk.ActionGroup('U1MSLinkPluginActions')
151 self.action_group.add_action(action)
152 manager.insert_action_group(self.action_group, 0)
153 self.ui_id = manager.add_ui_from_string(UI_STR)
154 manager.ensure_update()
155
156 def deactivate(self, shell):
157 """Plugin shutdown."""
158 manager = shell.get_player().get_property('ui-manager')
159 manager.remove_ui(self.ui_id)
160 manager.remove_action_group(self.action_group)
161 manager.ensure_update()
162
163 def dialog_response_cb(self, dialog, response_id):
164 """Destroy the window."""
165 self.win.destroy()
166 self.win = None
167
168 def get_link(self, action, shell):
169 """Get the details of the currently playing song from RB."""
170 self.builder = gtk.Builder()
171 self.builder.add_from_file(self.find_file("u1msurl.glade"))
172 self.win = self.builder.get_object("winMain")
173 self.win.connect("response", self.dialog_response_cb)
174 self.win.set_transient_for(shell.props.window)
175 self.image = self.builder.get_object("imgMain")
176 self.image.set_from_icon_name("ubuntuone", gtk.ICON_SIZE_DIALOG)
177 self.win.show_all()
178
179 player = shell.get_player()
180 entry = player.get_playing_entry()
181 if not entry:
182 # This shouldn't happen; the button and menu item should
183 # be disabled when nothing is playing
184 self.display_error('could-not-detect')
185 return
186 artist = shell.props.db.entry_get(entry, rhythmdb.PROP_ARTIST)
187 if not artist:
188 # If you're playing something odd, like a radio station, then
189 # there is a playing entry but it doesn't have an artist.
190 self.display_error('could-not-detect')
191 return
192 title = shell.props.db.entry_get(entry, rhythmdb.PROP_TITLE)
193 album = shell.props.db.entry_get(entry, rhythmdb.PROP_ALBUM)
194 # promote them from strings to Unicode
195 artist = artist.decode(PREFERRED_ENCODING, 'replace')
196 title = title.decode(PREFERRED_ENCODING, 'replace')
197 album = album.decode(PREFERRED_ENCODING, 'replace')
198 self.builder.get_object("lblProgress").set_markup(
199 _("Looking up <i>%s</i> by <i>%s</i> from <i>%s</i>") % (
200 cgi.escape(title), cgi.escape(artist), cgi.escape(album)))
201 self.lookup_artist(title, artist, album)
202
203 def display_error(self, messagename):
204 """Display error text and a warning icon."""
205 self.builder.get_object("lblProgress").set_markup(ERRORS[messagename])
206 self.image.set_from_icon_name("dialog-warning",
207 gtk.ICON_SIZE_DIALOG)
208
209 def lookup_artist(self, title, artist, album):
210 """Use the 7digital public API to look up the artist."""
211 base_url = "http://api.7digital.com/1.2/artist/search"
212 params = {"q": artist.encode("utf-8", "replace"),
213 "oauth_consumer_key": "canonical",
214 "country": "GB"}
215 url = "%s?%s" % (base_url, urllib.urlencode(params))
216 self.artist_fetch = gio.File(url)
217 self.artist_fetch.read_async(
218 self.artist_fetched,
219 user_data=(title, artist, album))
220
221 def artist_fetched(self, gdaemonfile, result, user_data):
222 """Artist query is complete"""
223 title, artist, album = user_data
224 try:
225 data = self.artist_fetch.read_finish(result).read()
226 except glib.GError:
227 self.display_error('could-not-connect')
228 return
229 try:
230 dom = minidom.parseString(data)
231 except xml.parsers.expat.ExpatError:
232 self.display_error('could-not-connect')
233 print "Could not parse returned XML:", data
234 return
235 artistnodes = dom.getElementsByTagName("artist")
236 possibles = []
237 for anode in artistnodes:
238 names = anode.getElementsByTagName("name")
239 if not names:
240 continue
241 namenode = names[0]
242 if not namenode.hasChildNodes():
243 continue
244 name = namenode.firstChild.nodeValue
245 possibles.append((
246 anode.getAttribute("id"),
247 modified_levenshtein(name, artist),
248 name))
249 possibles.sort(key=operator.itemgetter(1))
250 if not possibles:
251 self.display_error('could-not-find')
252 print "Couldn't find artist '%s'" % artist
253 return
254 artist_id = possibles[0][0]
255 print "got artist %s" % possibles[0][2]
256 self.lookup_track(title, artist, album, artist_id)
257
258 def lookup_track(self, title, artist, album, artist_id):
259 """Use the 7digital public API to look up the song."""
260 # There is no way of searching the 7digital API and saying
261 # I *know* the artist ID, please only return me tracks by that
262 # artist. So instead we search for the artist name + track name
263 # combined, and then later we'll walk through the results ourselves.
264 base_url = "http://api.7digital.com/1.2/track/search"
265 params = {"q": "%s %s" % (artist.encode("utf-8", "replace"),
266 title.encode("utf-8", "replace")),
267 "oauth_consumer_key": "canonical",
268 "country": "GB", "pagesize": 50}
269 url = "%s?%s" % (base_url, urllib.urlencode(params))
270 self.track_fetch = gio.File(url)
271 self.track_fetch.read_async(self.track_fetched,
272 user_data=(title, artist, album, artist_id))
273
274 def track_fetched(self, gdaemonfile, result, user_data):
275 """Track query is complete"""
276 title, artist, album, artist_id = user_data
277 try:
278 data = self.artist_fetch.read_finish(result).read()
279 except glib.GError:
280 self.display_error('could-not-connect')
281 return
282 try:
283 dom = minidom.parseString(data)
284 except xml.parsers.expat.ExpatError:
285 self.display_error('could-not-connect')
286 print "Could not parse returned XML:", data
287 return
288 print data
289 tracknodes = dom.getElementsByTagName("track")
290 possibles = []
291 for tnode in tracknodes:
292 anodes = tnode.getElementsByTagName("artist")
293 if not anodes:
294 continue
295 aid = anodes[0].getAttribute("id")
296 if aid == artist_id:
297 artist_score = 0
298 artist_name = artist
299 else:
300 atnodes = anodes[0].getElementsByTagName("name")
301 if not atnodes:
302 continue
303 if not atnodes[0].hasChildNodes():
304 continue
305 # a +100 penalty for not being the right artist
306 artist_score = 100 + modified_levenshtein(
307 atnodes[0].firstChild.nodeValue, artist)
308 artist_name = atnodes[0].firstChild.nodeValue
309 nnodes = tnode.getElementsByTagName("title")
310 if not nnodes:
311 continue
312 if not nnodes[0].hasChildNodes():
313 continue
314 rnodes = tnode.getElementsByTagName("release")
315 if not rnodes:
316 continue
317 rtnodes = rnodes[0].getElementsByTagName("title")
318 if not rtnodes:
319 continue
320 if not rtnodes[0].hasChildNodes():
321 continue
322 track_score = modified_levenshtein(
323 nnodes[0].firstChild.nodeValue, title)
324 album_score = modified_levenshtein(
325 rtnodes[0].firstChild.nodeValue, album)
326 total_score = track_score + album_score + artist_score
327 result = {"track": nnodes[0].firstChild.nodeValue,
328 "album": rtnodes[0].firstChild.nodeValue,
329 "artist": artist_name,
330 "track_score": track_score,
331 "album_score": album_score,
332 "artist_score": album_score,
333 "total_score": total_score,
334 "trackid": tnode.getAttribute("id")}
335 if total_score < 150:
336 possibles.append(result)
337 else:
338 print "discarding", result
339 possibles.sort(key=operator.itemgetter('total_score'))
340 if not possibles:
341 print "Didn't find any matches at all"
342 self.display_error('could-not-find')
343 return
344 print possibles
345 match = possibles[0]
346 print "got a match", match
347 dest_url = "%s/music/l/%s/%s" % (
348 BASE_URL, match["trackid"], "0") # this 0 should be userid
349 self.builder.get_object("lblProgress").set_markup(
350 _("Found <i>%s</i> by <i>%s</i> from <i>%s</i>") % (
351 cgi.escape(match["track"]), cgi.escape(match["artist"]),
352 cgi.escape(match["album"])))
353 self.builder.get_object("lblURL").set_markup(
354 "<big><b>%s</b></big>" % dest_url)
355 clipboard = gtk.Clipboard(
356 gtk.gdk.display_manager_get().get_default_display(), "CLIPBOARD")
357 clipboard.set_text(dest_url)
358
359 if GWIBBER_AVAILABLE:
360 self.tweet_button = gtk.Button("Tweet this link")
361 self.tweet_button.connect("clicked", self.gwibber, dest_url,
362 artist, album, title)
363 self.win.get_content_area().pack_end(self.tweet_button)
364 self.tweet_button.show()
365
366 def gwibber(self, button, url, artist, album, title):
367 """Show the Gwibber posting widget."""
368 self.pvb = gwibber.lib.gtk.widgets.GwibberPosterVBox()
369 self.message = "Currently listening to %s by %s %s" % (
370 title, artist, url)
371 self.pvb.input.connect("expose-event", self.gwibber_input_text)
372 self.pvb.button_send.connect("clicked",
373 lambda x: self.builder.get_object("winMain").destroy())
374 self.pvb.show_all()
375 self.builder.get_object("vbMain").pack_end(self.pvb)
376 self.tweet_button.hide()
377
378 def gwibber_input_text(self, *args):
379 """Set the Gwibber text input."""
380 self.pvb.input.set_text(self.message)
3810
=== removed file 'umusicstore/u1msurl.glade'
--- umusicstore/u1msurl.glade 2010-09-20 15:15:15 +0000
+++ umusicstore/u1msurl.glade 1970-01-01 00:00:00 +0000
@@ -1,108 +0,0 @@
1<?xml version="1.0"?>
2<interface>
3 <requires lib="gtk+" version="2.16"/>
4 <!-- interface-naming-policy project-wide -->
5 <object class="GtkDialog" id="winMain">
6 <property name="border_width">5</property>
7 <property name="type_hint">normal</property>
8 <property name="has_separator">False</property>
9 <child internal-child="vbox">
10 <object class="GtkVBox" id="dialog-vbox1">
11 <property name="visible">True</property>
12 <property name="spacing">2</property>
13 <child>
14 <object class="GtkHBox" id="hbox1">
15 <property name="visible">True</property>
16 <child>
17 <object class="GtkImage" id="imgMain">
18 <property name="visible">True</property>
19 <property name="yalign">0</property>
20 <property name="xpad">3</property>
21 <property name="ypad">3</property>
22 <property name="stock">gtk-info</property>
23 <property name="icon-size">6</property>
24 </object>
25 <packing>
26 <property name="expand">False</property>
27 <property name="position">0</property>
28 </packing>
29 </child>
30 <child>
31 <object class="GtkVBox" id="vbMain">
32 <property name="visible">True</property>
33 <property name="spacing">3</property>
34 <child>
35 <object class="GtkLabel" id="lblProgress">
36 <property name="visible">True</property>
37 <property name="xalign">0</property>
38 <property name="yalign">0</property>
39 <property name="wrap">True</property>
40 </object>
41 <packing>
42 <property name="expand">False</property>
43 <property name="fill">False</property>
44 <property name="padding">3</property>
45 <property name="position">0</property>
46 </packing>
47 </child>
48 <child>
49 <object class="GtkLabel" id="lblURL">
50 <property name="visible">True</property>
51 <property name="xalign">0</property>
52 <property name="yalign">0</property>
53 <property name="wrap">True</property>
54 <property name="selectable">True</property>
55 </object>
56 <packing>
57 <property name="expand">False</property>
58 <property name="fill">False</property>
59 <property name="padding">3</property>
60 <property name="position">1</property>
61 </packing>
62 </child>
63 </object>
64 <packing>
65 <property name="position">1</property>
66 </packing>
67 </child>
68 </object>
69 <packing>
70 <property name="padding">3</property>
71 <property name="position">1</property>
72 </packing>
73 </child>
74 <child internal-child="action_area">
75 <object class="GtkHButtonBox" id="dialog-action_area1">
76 <property name="visible">True</property>
77 <property name="layout_style">end</property>
78 <child>
79 <placeholder/>
80 </child>
81 <child>
82 <object class="GtkButton" id="button1">
83 <property name="label">gtk-close</property>
84 <property name="visible">True</property>
85 <property name="can_focus">True</property>
86 <property name="receives_default">True</property>
87 <property name="use_stock">True</property>
88 </object>
89 <packing>
90 <property name="expand">False</property>
91 <property name="fill">False</property>
92 <property name="position">1</property>
93 </packing>
94 </child>
95 </object>
96 <packing>
97 <property name="expand">False</property>
98 <property name="pack_type">end</property>
99 <property name="position">0</property>
100 </packing>
101 </child>
102 </object>
103 </child>
104 <action-widgets>
105 <action-widget response="0">button1</action-widget>
106 </action-widgets>
107 </object>
108</interface>

Subscribers

People subscribed via source and target branches