aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/fetch-file.vala65
-rw-r--r--src/metadata-menu-item.vala2
-rw-r--r--src/metadata-widget.c1
-rw-r--r--src/player-item.vala56
-rw-r--r--src/sound-service.c4
6 files changed, 126 insertions, 10 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a4e937..e85ed93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -67,7 +67,9 @@ music_bridge_VALASOURCES = \
player-controller.vala \
mpris2-controller.vala \
player-item.vala \
- familiar-players-db.vala
+ familiar-players-db.vala \
+ fetch-file.vala
+
music_bridge_VALAFLAGS = \
--ccode \
@@ -81,7 +83,9 @@ music_bridge_VALAFLAGS = \
--pkg Dbusmenu-Glib-0.2 \
--pkg common-defs \
--pkg dbus-glib-1 \
- --pkg gio-unix-2.0
+ --pkg gio-unix-2.0 \
+ --pkg gdk-pixbuf-2.0
+
$(MAINTAINER_VALAFLAGS)
diff --git a/src/fetch-file.vala b/src/fetch-file.vala
new file mode 100644
index 0000000..55bfdc3
--- /dev/null
+++ b/src/fetch-file.vala
@@ -0,0 +1,65 @@
+public class FetchFile : Object
+{
+ /* public variables */
+ public string uri {get; construct;}
+
+ /* private variables */
+ private DataInputStream stream;
+ private File? file;
+ private ByteArray data;
+
+ /* public signals */
+ public signal void failed ();
+ public signal void completed (ByteArray data);
+
+ public FetchFile (string uri)
+ {
+ Object (uri: uri);
+ }
+
+ construct
+ {
+ this.file = File.new_for_uri(this.uri);
+ this.data = new ByteArray ();
+ }
+
+ public async void fetch_data ()
+ {
+ //grab our data from our uri
+ try {
+ this.stream = new DataInputStream(this.file.read(null));
+ this.stream.set_byte_order (DataStreamByteOrder.LITTLE_ENDIAN);
+ } catch (GLib.Error e) {
+ this.failed ();
+ }
+ this.read_something_async ();
+ }
+
+ private async void read_something_async ()
+ {
+ ssize_t size = 1024;
+ uint8[] buffer = new uint8[size];
+
+ ssize_t bufsize = 1;
+ do {
+ try {
+ bufsize = yield this.stream.read_async (buffer, size, GLib.Priority.DEFAULT, null);
+ if (bufsize < 1) { break;}
+
+ if (bufsize != size)
+ {
+ uint8[] cpybuf = new uint8[bufsize];
+ Memory.copy (cpybuf, buffer, bufsize);
+ this.data.append (cpybuf);
+ }
+ else
+ {
+ this.data.append (buffer);
+ }
+ } catch (Error e) {
+ this.failed ();
+ }
+ } while (bufsize > 0);
+ this.completed (this.data);
+ }
+}
diff --git a/src/metadata-menu-item.vala b/src/metadata-menu-item.vala
index 0bb4a85..090952b 100644
--- a/src/metadata-menu-item.vala
+++ b/src/metadata-menu-item.vala
@@ -17,9 +17,9 @@ You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-using Dbusmenu;
using Gee;
using DbusmenuMetadata;
+using Gdk;
public class MetadataMenuitem : PlayerItem
{
diff --git a/src/metadata-widget.c b/src/metadata-widget.c
index f600238..5e75b29 100644
--- a/src/metadata-widget.c
+++ b/src/metadata-widget.c
@@ -190,6 +190,7 @@ metadata_image_expose (GtkWidget *metadata, GdkEventExpose *event, gpointer user
if(priv->image_path->len > 0){
if(g_string_equal(priv->image_path, priv->old_image_path) == FALSE){
+
GdkPixbuf* pixbuf;
pixbuf = gdk_pixbuf_new_from_file(priv->image_path->str, NULL);
g_debug("metadata_widget_expose, album art update -> pixbuf from %s",
diff --git a/src/player-item.vala b/src/player-item.vala
index fbfacbd..82b9f07 100644
--- a/src/player-item.vala
+++ b/src/player-item.vala
@@ -61,14 +61,20 @@ public class PlayerItem : Dbusmenu.Menuitem
debug("with value : %s", update);
// Special case for the arturl URI's.
if(property.contains("mpris:artUrl")){
- try{
- update = Filename.from_uri(update.strip());
+ if(update.has_prefix("http://")){
}
- catch(ConvertError e){
- warning("Problem converting URI %s to file path", update);
+ else{
+ // The file is local, just parse the string
+ try{
+ update = Filename.from_uri(update.strip());
+ }
+ catch(ConvertError e){
+ warning("Problem converting URI %s to file path",
+ update);
+ }
}
}
- this.property_set(property, update);
+ this.property_set(property, update);
}
else if (v.holds (typeof (int))){
debug("with value : %i", v.get_int());
@@ -101,5 +107,45 @@ public class PlayerItem : Dbusmenu.Menuitem
}
return false;
}
+
+ public fetch_remote_art(uri)
+ {
+ this.fetcher = new FetchFile (uri);
+ this.fetcher.failed.connect (() => { this.on_fetcher_failed ();});
+ this.fetcher.completed.connect (this.on_fetcher_completed);
+ this.fetcher.fetch_data ();
+ }
+
+ public string parse_art_url(string update)
+ {
+ if(update == null)
+ return null;
+ string temp_path = "/home/ronoc/Desktop/tempy.jpg";
+ string local_path = "";
+ string temp_name = "";
+
+ debug("MetadataMenuitem: parse art url - result %s", local_path);
+ return local_path;
+ }
+
+ public extract_downloaded_file()
+ {
+ try{
+ PixbufLoader loader = new PixbufLoader ();
+ bool write_result = loader.write (update.data, update.len());
+ loader.close ();
+ unowned PixbufFormat format = loader.get_format();
+ debug("the bloody format name is %s", format.get_name());
+ debug("is the format null %s", (format == null).to_string());
+ Pixbuf icon = loader.get_pixbuf ();
+ temp_name = loader.get_format().get_name();
+ icon.save (temp_path, "jpeg");
+ local_path = temp_path;
+ }
+ catch(GLib.Error e){
+ warning("Problem taking file from the interweb - error: %s and name: %s",
+ e.message,
+ temp_name);
+ }
}
diff --git a/src/sound-service.c b/src/sound-service.c
index 12f067e..42ce116 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -41,8 +41,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown !");
// TODO: uncomment for release !!
- close_pulse_activites();
- g_main_loop_quit(mainloop);
+ //close_pulse_activites();
+ //g_main_loop_quit(mainloop);
}
return;
}