47
47
// In the sources TreeView, sets the order value for this source, small on top
48
48
const int sort_order = 190;
49
49
CustomView custom_view;
50
string cached_startup_uri;
51
52
public UbuntuOneMusicStoreSource () : base (
52
53
Catalog.GetString ("Ubuntu One Music Store"),
62
63
// So we can handle u1ms:// URIs
63
64
ServiceManager.Get<DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
65
custom_view.store.UrlLoaded += OnDefaultStoreUrlLoaded;
67
// make sure that the u1ms uri gets handled on banshee startup
68
foreach (string uri in ApplicationContext.CommandLine.Files) {
69
if (IsU1msUri (uri)) {
70
cached_startup_uri = uri;
66
76
~UbuntuOneMusicStoreSource ()
68
78
ServiceManager.Get<DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
81
// A count of 0 will be hidden in the source TreeView
82
public override int Count {
86
private void OnDefaultStoreUrlLoaded (object o, UbuntuOne.UrlLoadedArgs args)
88
if (args.Url.StartsWith( "http://stores.7digital.com/default")) {
89
// we just do this the first time we load the default store view
90
// so that we can switch to the passed u1ms uri and not have it switch out on us.
91
custom_view.store.UrlLoaded -= OnDefaultStoreUrlLoaded;
92
if (!string.IsNullOrEmpty (cached_startup_uri))
93
LoadU1msUri (cached_startup_uri);
71
97
private void OnCommandLineArgument (string uri, object value, bool isFile)
73
99
if (!isFile || String.IsNullOrEmpty (uri)) {
106
private void LoadU1msUri (string uri)
77
108
Log.Debug ("U1MS: URI requested: ", uri);
78
109
// Handle u1ms:// URIs
79
if (uri.StartsWith ("u1ms://")) {
110
if (IsU1msUri (uri)) {
80
111
string http_url = uri.Replace ("u1ms://", "http://");
81
112
custom_view.Store.LoadStoreLink (http_url);
82
113
ServiceManager.SourceManager.SetActiveSource (this);
86
// A count of 0 will be hidden in the source TreeView
87
public override int Count {
117
private bool IsU1msUri (string uri)
119
return uri.StartsWith ("u1ms://");
91
122
public class StoreWrapper: UbuntuOne.U1MusicStore, IDisableKeybindings
141
172
private class CustomView : ISourceContents
143
StoreWrapper store = new StoreWrapper ();
174
internal StoreWrapper store = new StoreWrapper ();
145
176
public bool SetSource (ISource source) { return true; }
146
177
public void ResetSource () { }