// ----------------------------------------------- //
		
		// FIXME: Ok, this is a real hack, it has half-support for buying multiple songs
		// but doenst really allow it yet. Will overwrite the song with the last one downloaded.
		protected virtual void ThreadWorker()
		{
			user_event = new ActiveUserEvent (String.Format (Catalog.GetString ("Purchasing {0} - {1}"), track.Artist, track.Title));
			
			user_event.CanCancel = false;
			user_event.Icon = IconThemeUtils.LoadIcon("document-save", 22); // FIXME: Get a nice icon
			
			user_event.Header = Catalog.GetString ("Purchasing");
			user_event.Message = String.Format ("{0} - {1}", track.Artist, track.Title);

			ArrayList songs = new ArrayList ();
			try {
				songs = plugin.Store.Buy (track.Data);
			} catch (Exception ex) {
				// FIXME: Error handling correct?
				user_event.Dispose ();
				HigMessageDialog.RunHigMessageDialog (null,
								      0,
								      MessageType.Error,
								      ButtonsType.Ok,
								      "Purchase Error",
								      String.Format ("There was an error while performing the purchase: {0}", ex.Message)); 				
				return;
			}

			Hashtable song, meta;

			for (int i = 0; i < songs.Count; i++) {
				song = (Hashtable) songs[i];
				meta = song[ "metaData" ] != null ? (Hashtable)song ["metaData"] : song;
				
				user_event.Header = String.Format (Catalog.GetString ("Downloading {0} of {1}"), i+1, songs.Count);
				user_event.Message = String.Format (Catalog.GetString ("{0} - {1}"), track.Artist, track.Title);

				try {
					byte [] buffer = plugin.Store.DownloadSong (song, new FairStore.Progress (ProgressUpdate));
					
					FileStream fs = new FileStream (MusicStorePlugin.GetLibraryPathForTrack (track), FileMode.CreateNew);
	                    		BinaryWriter bw = new BinaryWriter (fs);
                    			bw.Write (buffer);
                    			bw.Close ();
                    			fs.Close ();
				} catch (Exception ex) {
					// FIXME: Error handling correct?
					user_event.Dispose ();
					HigMessageDialog.RunHigMessageDialog (null,
									      0,
									      MessageType.Error,
									      ButtonsType.Ok,
									      "Download Error",
									      String.Format ("There was an error while performing the download: {0}", ex.Message)); 
					return;
				}
			}
			user_event.Dispose ();
		}
        public MusicStoreView(MusicStorePlugin plugin)
        {
            this.plugin = plugin;

            Model         = new ListStore(typeof(MusicStoreTrackInfo));
            RowActivated += new RowActivatedHandler(OnRowActivated);

            CellRendererText renderer_text = new CellRendererText();

            TreeViewColumn type_column = new TreeViewColumn();

            type_column.Title = Catalog.GetString("Artist");
            type_column.PackStart(renderer_text, false);
            type_column.SetCellDataFunc(renderer_text, new TreeCellDataFunc(ArtistCellDataFunc));
            AppendColumn(type_column);

            TreeViewColumn name_column = new TreeViewColumn();

            name_column.Title = Catalog.GetString("Title");
            name_column.PackStart(renderer_text, false);
            name_column.SetCellDataFunc(renderer_text, new TreeCellDataFunc(TitleCellDataFunc));
            AppendColumn(name_column);

            TreeViewColumn album_column = new TreeViewColumn();

            album_column.Title = Catalog.GetString("Album");
            album_column.PackStart(renderer_text, false);
            album_column.SetCellDataFunc(renderer_text, new TreeCellDataFunc(AlbumCellDataFunc));
            AppendColumn(album_column);

            TreeViewColumn time_column = new TreeViewColumn();

            time_column.Title = Catalog.GetString("Time");
            time_column.PackStart(renderer_text, false);
            time_column.SetCellDataFunc(renderer_text, new TreeCellDataFunc(TimeCellDataFunc));
            AppendColumn(time_column);

            TreeViewColumn price_column = new TreeViewColumn();

            price_column.Title = Catalog.GetString("Price");
            price_column.PackStart(renderer_text, false);
            price_column.SetCellDataFunc(renderer_text, new TreeCellDataFunc(PriceCellDataFunc));
            AppendColumn(price_column);
        }
        public MusicStoreView(MusicStorePlugin plugin)
        {
            this.plugin = plugin;

            Model = new ListStore (typeof(MusicStoreTrackInfo));
            RowActivated += new RowActivatedHandler (OnRowActivated);

            CellRendererText renderer_text = new CellRendererText ();

            TreeViewColumn type_column = new TreeViewColumn ();
            type_column.Title = Catalog.GetString ("Artist");
            type_column.PackStart (renderer_text, false);
            type_column.SetCellDataFunc (renderer_text, new TreeCellDataFunc (ArtistCellDataFunc));
            AppendColumn (type_column);

            TreeViewColumn name_column = new TreeViewColumn ();
            name_column.Title = Catalog.GetString ("Title");
            name_column.PackStart (renderer_text, false);
            name_column.SetCellDataFunc (renderer_text, new TreeCellDataFunc (TitleCellDataFunc));
            AppendColumn (name_column);

            TreeViewColumn album_column = new TreeViewColumn ();
            album_column.Title = Catalog.GetString ("Album");
            album_column.PackStart (renderer_text, false);
            album_column.SetCellDataFunc (renderer_text, new TreeCellDataFunc (AlbumCellDataFunc));
            AppendColumn (album_column);

            TreeViewColumn time_column = new TreeViewColumn ();
            time_column.Title = Catalog.GetString ("Time");
            time_column.PackStart (renderer_text, false);
            time_column.SetCellDataFunc (renderer_text, new TreeCellDataFunc (TimeCellDataFunc));
            AppendColumn (time_column);

            TreeViewColumn price_column = new TreeViewColumn ();
            price_column.Title = Catalog.GetString ("Price");
            price_column.PackStart (renderer_text, false);
            price_column.SetCellDataFunc (renderer_text, new TreeCellDataFunc (PriceCellDataFunc));
            AppendColumn (price_column);
        }
 public MusicStoreConfigPage(MusicStorePlugin plugin)
     : base()
 {
     this.plugin = plugin;
     BuildWidget();
 }
		public MusicStorePurchaseTransaction (MusicStorePlugin plugin, MusicStoreTrackInfo track)
		{
			this.plugin = plugin;
			this.track = track;
		}
		public MusicStoreSource (MusicStorePlugin plugin) : base("Music Store", 150)
		{
			this.plugin = plugin;
		}
 public MusicStorePurchaseTransaction(MusicStorePlugin plugin, MusicStoreTrackInfo track)
 {
     this.plugin = plugin;
     this.track = track;
 }
Ejemplo n.º 8
0
 public MusicStoreSource(MusicStorePlugin plugin) : base("Music Store", 150)
 {
     this.plugin = plugin;
 }
 public MusicStoreConfigPage(MusicStorePlugin plugin) :  base()
 {
     this.plugin = plugin;
     BuildWidget();
 }