From c35cf0b46dca492dd8d6ad6b8c2d188268dc2bac Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh@fedoraproject.org>
Date: Wed, 20 May 2009 18:15:17 +0530
Subject: [PATCH]  Added libnm_glib, flickcurl and libxml as dependecies and some
  missing changes from initial import for importer and exporter.

---
 configure.ac                    |    3 ++
 src/application/Makefile.am     |    6 +++
 src/application/application.cpp |    5 +++
 src/attribute/Makefile.am       |    3 ++
 src/common/Makefile.am          |   12 ++++++-
 src/common/flickrconf.cpp       |    4 +-
 src/database/Makefile.am        |    3 ++
 src/exporter/Makefile.am        |    3 ++
 src/importer/Makefile.am        |   11 ++++++-
 src/importer/flickr-source.cpp  |   68 +++++++++++++++++++++++++++++++++++++--
 src/importer/flickr-source.h    |   14 +++++++-
 src/renderer/Makefile.am        |    3 ++
 src/storage/Makefile.am         |    3 ++
 13 files changed, 130 insertions(+), 8 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6a3208f..8de538c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,16 +27,19 @@ AM_PROG_LIBTOOL
 
 PKG_CHECK_MODULES(CAIROMM, [cairomm-1.0])
 PKG_CHECK_MODULES(EXIV2, [exiv2])
+PKG_CHECK_MODULES(FLICKCURL, [flickcurl])
 PKG_CHECK_MODULES(GDAMM, [libgdamm-3.0])
 PKG_CHECK_MODULES(GDL, [gdl-1.0])
 PKG_CHECK_MODULES(GIOMM, [giomm-2.4])
 PKG_CHECK_MODULES(GLIBMM, [glibmm-2.4])
 PKG_CHECK_MODULES(GPHOTO2, [libgphoto2])
 PKG_CHECK_MODULES(GTKMM, [gtkmm-2.4 >= 2.8])
+PKG_CHECK_MODULES(NM_GLIB, [libnm_glib])
 
 PKG_CHECK_MODULES(IMAGEMAGICK, [GraphicsMagick++],,
     [PKG_CHECK_MODULES(IMAGEMAGICK, [ImageMagick++])])
 
+PKG_CHECK_MODULES(LIBXML, [libxml-2.0])
 PKG_CHECK_MODULES(SIGC, [sigc++-2.0])
 
 
diff --git a/src/application/Makefile.am b/src/application/Makefile.am
index e5ee6bc..4cd0fb6 100644
--- a/src/application/Makefile.am
+++ b/src/application/Makefile.am
@@ -19,6 +19,7 @@ solang_LDADD = \
 	$(top_builddir)/src/attribute/libattribute.la \
 	$(top_builddir)/src/common/libcommon.la \
 	$(EXIV2_LIBS) \
+	$(FLICKCURL_LIBS) \
 	$(GPHOTO2_LIBS) \
 	$(GTKMM_LIBS) \
 	$(CAIROMM_LIBS) \
@@ -26,7 +27,9 @@ solang_LDADD = \
 	$(GIOMM_LIBS) \
 	$(GLIBMM_LIBS) \
 	$(GDL_LIBS) \
+	$(NM_GLIB_LIBS) \
 	$(IMAGEMAGICK_LIBS) \
+	$(LIBXML_LIBS) \
 	$(SIGC_LIBS)
 
 AM_CPPFLAGS = \
@@ -44,13 +47,16 @@ AM_CPPFLAGS = \
 	$(SOLANG_CFLAGS) \
 	$(CAIROMM_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GPHOTO2_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_LIBS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/application/application.cpp b/src/application/application.cpp
index 2d2a8b3..152b3a6 100644
--- a/src/application/application.cpp
+++ b/src/application/application.cpp
@@ -36,6 +36,7 @@
 #include "i-photo-source.h"
 #include "i-plugin.h"
 #include "importer.h"
+#include "picasaweb-source.h"
 #include "photo.h"
 #include "progress-observer.h"
 #include "property-manager.h"
@@ -226,6 +227,10 @@ Application::init() throw()
     IPluginPtr flickr_importer(new Importer(flickr_source, false));
     plugins_.insert(std::make_pair("flickr-importer", flickr_importer));
 
+    IPhotoSourcePtr picasaweb_source(new PicasawebSource());
+    IPluginPtr picasaweb_importer(new Importer(picasaweb_source, false));
+    plugins_.insert(std::make_pair("picasaweb-importer", picasaweb_importer));
+
     std::for_each(plugins_.begin(), plugins_.end(),
                   Initializer<IPluginPtr>(this));
 
diff --git a/src/attribute/Makefile.am b/src/attribute/Makefile.am
index 3d4fc98..f98a2f5 100644
--- a/src/attribute/Makefile.am
+++ b/src/attribute/Makefile.am
@@ -46,13 +46,16 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/storage \
 	$(SOLANG_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
 	$(LIBXML_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 037e168..bbfd0d5 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -3,6 +3,10 @@ noinst_LTLIBRARIES =	libcommon.la
 libcommon_la_SOURCES = \
 	error.cpp \
 	error.h \
+	flickr.cpp \
+	flickr.h \
+	flickrconf.cpp \
+	flickrconf.h \
 	i-photo-destination.cpp \
 	i-photo-destination.h \
 	i-photo-source.cpp \
@@ -25,7 +29,10 @@ libcommon_la_SOURCES = \
 	progress-dialog.h \
 	progress-observer.cpp \
 	progress-observer.h \
-	types.h
+	types.h \
+	utils.cpp \
+	utils.h
+
 
 AM_CPPFLAGS = \
        	-DPACKAGE_LOCALE_DIR=\"${SOLANG_LOCALE_DIR}\" \
@@ -41,12 +48,15 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/storage \
 	$(SOLANG_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/common/flickrconf.cpp b/src/common/flickrconf.cpp
index 9f4d932..caa3030 100644
--- a/src/common/flickrconf.cpp
+++ b/src/common/flickrconf.cpp
@@ -22,13 +22,13 @@ namespace flickrconf {
 
 	std::string getSharedKey() {
 		// Confirm keys from [rakesh]
-		std::string shared_key = "ece1d65e052be919";
+		std::string shared_key = "abcdefghijk";
 		return shared_key;
 	}
 
 	std::string getApiKey() {
 		// Confirm keys from [rakesh]
-		std::string api_key = "bc071df116992b4a0abc8db01135eb4b";
+		std::string api_key = "abcdefghijk123";
 		return api_key;
 	}
 
diff --git a/src/database/Makefile.am b/src/database/Makefile.am
index dd9a060..c4f1a02 100644
--- a/src/database/Makefile.am
+++ b/src/database/Makefile.am
@@ -36,12 +36,15 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/storage \
 	$(SOLANG_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/exporter/Makefile.am b/src/exporter/Makefile.am
index 86edb1c..f2875de 100644
--- a/src/exporter/Makefile.am
+++ b/src/exporter/Makefile.am
@@ -21,12 +21,15 @@ AM_CPPFLAGS = \
 	$(SOLANG_CFLAGS) \
 	$(CAIROMM_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/importer/Makefile.am b/src/importer/Makefile.am
index ec90ec1..6c8df2b 100644
--- a/src/importer/Makefile.am
+++ b/src/importer/Makefile.am
@@ -7,16 +7,22 @@ libimporter_la_SOURCES = \
 	camera-source.h \
 	directory-source.cpp \
 	directory-source.h \
+	flickr-import-window.cpp \
+	flickr-import-window.h \
 	flickr-source.cpp \
 	flickr-source.h \
 	gp-context.cpp \
 	gp-context.h \
+	import-tree-model.cpp \
+	import-tree-model.h \
 	importer.cpp \
 	importer-dialog.cpp \
 	importer-dialog.h \
 	importer.h \
 	photo-source.cpp \
-	photo-source.h
+	photo-source.h \
+	picasaweb-source.cpp \
+	picasaweb-source.h
 
 AM_CPPFLAGS = \
        	-DPACKAGE_LOCALE_DIR=\"${SOLANG_LOCALE_DIR}\" \
@@ -33,13 +39,16 @@ AM_CPPFLAGS = \
 	$(SOLANG_CFLAGS) \
 	$(CAIROMM_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GPHOTO2_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/importer/flickr-source.cpp b/src/importer/flickr-source.cpp
index f798545..977411c 100644
--- a/src/importer/flickr-source.cpp
+++ b/src/importer/flickr-source.cpp
@@ -17,18 +17,24 @@
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <iostream>
 #include "config.h"
 
 #include "flickr-source.h"
+#include "flickr-import-window.h"
 #include "progress-observer.h"
 
 namespace Solang
 {
 
 FlickrSource::FlickrSource() throw() :
-    PhotoSource(),
-    comboBoxEntry_()
+    PhotoSource()
 {
+	button_.set_label("Confirm on flickr!");
+	button_.signal_clicked().connect( sigc::mem_fun(*this,
+		&FlickrSource::on_button_confirm_flickr) );
+
+	set_authurl_confirmed(false);
 }
 
 FlickrSource::~FlickrSource() throw()
@@ -66,10 +72,66 @@ FlickrSource::import(const IStoragePtr & storage, const TagList &tags,
     return import(files, storage, tags, db, observer);
 }
 
+void
+FlickrSource::on_button_confirm_flickr() throw()
+{
+	flickcurl_photos_list* list = NULL;
+	FlickrImportWindow flickr_window;
+	flickr::dictionary uri_dic;
+	flickr::dictionary title_dic;
+	std::vector<std::string> id_list;
+
+	if (!is_authurl_confirmed()) {
+		std::string url;
+
+		std::string browser = "xdg-open ";
+		//std::string browser = "firefox ";
+
+		url = flickr_web_gallery.get_auth_url("read");
+		if (url.empty()) {
+			// Prompt some message to user.
+			return;
+		}
+
+		std::cout << url << std::endl;
+		std::string cmd = browser + "'" + url + "'"; 
+
+		system(cmd.c_str());
+		button_.set_label("Click after confirmation!");
+		set_authurl_confirmed(true);
+
+		return;
+	}
+
+	// Adding pictures without any set
+	flickr_web_gallery.get_auth_token();
+	list = flickr_web_gallery.get_photo_list_not_in_any_set();
+	flickr_web_gallery.return_photo_list(list);
+	uri_dic = flickr_web_gallery.get_thumbnail_uri_from_photo_list(list);
+	title_dic = flickr_web_gallery.get_title_from_photo_list(list);
+	id_list = flickr_web_gallery.get_id_from_photo_list(list);
+	flickr_window.make_imported_tree_per_set(id_list, title_dic, "No Set");
+
+	// Adding all sets
+	flickcurl_photoset** photo_set = flickr_web_gallery.get_photosets_list();
+	for(int i=0; photo_set[i]; i++) {
+		list = flickr_web_gallery.get_photo_list_in_set(photo_set[i]->id);
+		flickr_web_gallery.return_photo_list(list);
+		uri_dic = flickr_web_gallery.get_thumbnail_uri_from_photo_list(list);
+		title_dic = flickr_web_gallery.get_title_from_photo_list(list);
+		id_list = flickr_web_gallery.get_id_from_photo_list(list);
+		flickr_window.make_imported_tree_per_set(id_list, title_dic, std::string(photo_set[i]->title));
+	}
+
+	flickr_window.run();
+
+	return;
+}
+
 Gtk::Widget &
 FlickrSource::get_browser() throw()
 {
-    return comboBoxEntry_;
+    return button_;
 }
 
 Glib::ustring
diff --git a/src/importer/flickr-source.h b/src/importer/flickr-source.h
index d3a8c67..cacc74b 100644
--- a/src/importer/flickr-source.h
+++ b/src/importer/flickr-source.h
@@ -23,6 +23,7 @@
 #include <glibmm.h>
 #include <gtkmm.h>
 
+#include "flickr.h"
 #include "photo-source.h"
 
 namespace Solang
@@ -63,10 +64,21 @@ public:
     virtual Gtk::StockID
     get_stock_id() const throw();
 
+	bool
+		is_authurl_confirmed() const throw() {return url_confirmed;}
+
 protected:
-    Gtk::ComboBoxEntry comboBoxEntry_;
+    Gtk::Button button_;
+	flickr::flickr flickr_web_gallery;
 
 private:
+	virtual void
+		on_button_confirm_flickr() throw();
+
+	void
+		set_authurl_confirmed(bool value) throw() {url_confirmed = value;}
+
+	bool url_confirmed;
 };
 
 } // namespace Solang
diff --git a/src/renderer/Makefile.am b/src/renderer/Makefile.am
index 397c67a..43b319f 100644
--- a/src/renderer/Makefile.am
+++ b/src/renderer/Makefile.am
@@ -31,12 +31,15 @@ AM_CPPFLAGS = \
 	$(SOLANG_CFLAGS) \
 	$(CAIROMM_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
diff --git a/src/storage/Makefile.am b/src/storage/Makefile.am
index d2b219e..0ca6ad7 100644
--- a/src/storage/Makefile.am
+++ b/src/storage/Makefile.am
@@ -22,12 +22,15 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/src/storage \
 	$(SOLANG_CFLAGS) \
 	$(EXIV2_CFLAGS) \
+	$(FLICKCURL_CFLAGS) \
 	$(GTKMM_CFLAGS) \
 	$(GDAMM_CFLAGS) \
 	$(GIOMM_CFLAGS) \
 	$(GLIBMM_CFLAGS) \
 	$(GDL_CFLAGS) \
+	$(NM_GLIB_CFLAGS) \
 	$(IMAGEMAGICK_CFLAGS) \
+	$(LIBXML_CFLAGS) \
 	$(SIGC_CFLAGS)
 
 AM_CXXFLAGS = \
-- 
1.6.0.6

