[ease/text] Add Picasa import service
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease/text] Add Picasa import service
- Date: Sun, 6 Feb 2011 21:40:21 +0000 (UTC)
commit 3e44891d3c0718d3ca0d10872fba38418338242b
Author: Nate Stedman <natesm gmail com>
Date: Sun Feb 6 16:33:48 2011 -0500
Add Picasa import service
AUTHORS | 1 +
ease/ease-import-dialog.vala | 6 ++-
ease/ease-import-picasa-media.vala | 4 ++
ease/ease-import-picasa-service.vala | 71 ++++++++++++++++++++++++++++++++++
ease/wscript | 4 +-
5 files changed, 83 insertions(+), 3 deletions(-)
---
diff --git a/AUTHORS b/AUTHORS
index 43f918f..ffdbfbd 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,3 @@
Nate Stedman <natesm gmail com>
Stéphane Maniaci <stephane maniaci gmail com>
+Scott Ringwelski
diff --git a/ease/ease-import-dialog.vala b/ease/ease-import-dialog.vala
index e9e78dc..5024682 100644
--- a/ease/ease-import-dialog.vala
+++ b/ease/ease-import-dialog.vala
@@ -37,8 +37,10 @@ internal class Ease.ImportDialog : Gtk.Window
Plugin.ImportService service = new FlickrService();
var flickr = create_item("Flickr", "gtk-go-down", service);
group.add_item(flickr);
- service = new OCAService();
- group.add_item(create_item("OpenClipArt", "gtk-go-down", service));
+ group.add_item(create_item("OpenClipArt", "gtk-go-down",
+ new OCAService()));
+ group.add_item(create_item("Picasa", "gtk-go-down",
+ new PicasaService()));
add(view);
view.show_all();
diff --git a/ease/ease-import-picasa-media.vala b/ease/ease-import-picasa-media.vala
new file mode 100644
index 0000000..e24a815
--- /dev/null
+++ b/ease/ease-import-picasa-media.vala
@@ -0,0 +1,4 @@
+internal class Ease.PicasaMedia : Plugin.ImportMedia {
+ string client_id;
+
+}
diff --git a/ease/ease-import-picasa-service.vala b/ease/ease-import-picasa-service.vala
new file mode 100644
index 0000000..57faaf2
--- /dev/null
+++ b/ease/ease-import-picasa-service.vala
@@ -0,0 +1,71 @@
+public class Ease.PicasaService : Plugin.ImportService
+{
+ private const string REST_URL = "http://picasaweb.google.com/data/feed/api/all?";
+
+ protected override Rest.Proxy create_proxy()
+ {
+ return new Rest.Proxy(REST_URL, false);
+ }
+
+ protected override Rest.ProxyCall create_call(Rest.Proxy proxy,
+ string search)
+ {
+ var call = proxy.new_call();
+ call.set_function(search);
+ call.add_param("q", search);
+ return call;
+ }
+
+ internal override void parse_data(string data)
+ {
+ Xml.Parser.init();
+
+ Xml.Doc* doc = Xml.Parser.parse_doc(data);
+ if(doc == null) return;
+
+ Xml.Node* root = doc->get_root_element();
+ if(root == null) return;
+
+ // loop through all the nodes
+ for (Xml.Node* iter = root->children; iter != null; iter = iter->next)
+ {
+ if(iter->name == "entry")
+ {
+ OCAMedia image = new OCAMedia();
+
+ for (Xml.Node* tag = iter->children; tag != null;
+ tag = tag->next)
+ {
+ switch (tag->name)
+ {
+ case "title":
+ image.title = tag->children->content;
+ break;
+ case "group":
+ for (Xml.Node* content = tag->children;
+ content != null; content = content->next)
+ {
+ if (content->name == "content")
+ {
+ image.link = content->get_prop("url");
+ image.file_link = image.link;
+ debug("\n%s\n\n", image.link);
+ }
+ }
+ break;
+ case "author":
+ for (Xml.Node* author = tag->children;
+ author != null; author = author->next)
+ {
+ if (author->name == "name")
+ image.creator = author->children->content;
+ }
+ break;
+ }
+ }
+
+ add_media(image);
+ }
+ }
+ }
+}
diff --git a/ease/wscript b/ease/wscript
index 6f9f81d..61bf55f 100644
--- a/ease/wscript
+++ b/ease/wscript
@@ -7,7 +7,9 @@ ease_files = ["ease-about-dialog.vala",
"ease-handle.vala",
"ease-import-dialog.vala",
"ease-import-flickr-media.vala",
- "ease-import-flickr-service.vala",
+ "ease-import-flickr-service.vala",
+ "ease-import-picasa-media.vala",
+ "ease-import-picasa-service.vala",
"ease-import-oca-media.vala",
"ease-import-oca-service.vala",
"ease-import-widget.vala",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]