summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/flickrexport
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-19 18:22:05 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-19 18:22:05 +0000
commit57e10fedbcb8c3e8c6590ff0935dbf017ce5587f (patch)
tree3000a7649ca4e40e43f9e7feed963236a0b0f56b /kipi-plugins/flickrexport
downloadkipi-plugins-57e10fedbcb8c3e8c6590ff0935dbf017ce5587f.tar.gz
kipi-plugins-57e10fedbcb8c3e8c6590ff0935dbf017ce5587f.zip
Import abandoned KDE3 version of kipi plugins
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/libraries/kipi-plugins@1077221 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kipi-plugins/flickrexport')
-rw-r--r--kipi-plugins/flickrexport/Makefile.am23
-rw-r--r--kipi-plugins/flickrexport/TODO5
-rw-r--r--kipi-plugins/flickrexport/flickralbumdialog.ui197
-rw-r--r--kipi-plugins/flickrexport/flickritem.h140
-rw-r--r--kipi-plugins/flickrexport/flickrtalker.cpp1020
-rw-r--r--kipi-plugins/flickrexport/flickrtalker.h151
-rw-r--r--kipi-plugins/flickrexport/flickrviewitem.cpp107
-rw-r--r--kipi-plugins/flickrexport/flickrviewitem.h60
-rw-r--r--kipi-plugins/flickrexport/flickrwidget.cpp218
-rw-r--r--kipi-plugins/flickrexport/flickrwidget.h102
-rw-r--r--kipi-plugins/flickrexport/flickrwindow.cpp588
-rw-r--r--kipi-plugins/flickrexport/flickrwindow.h167
-rw-r--r--kipi-plugins/flickrexport/imageslist.cpp342
-rw-r--r--kipi-plugins/flickrexport/imageslist.h122
-rw-r--r--kipi-plugins/flickrexport/kipiplugin_flickrexport.desktop55
-rw-r--r--kipi-plugins/flickrexport/login.cpp123
-rw-r--r--kipi-plugins/flickrexport/login.h59
-rw-r--r--kipi-plugins/flickrexport/mpform.cpp163
-rw-r--r--kipi-plugins/flickrexport/mpform.h61
-rw-r--r--kipi-plugins/flickrexport/plugin_flickrexport.cpp114
-rw-r--r--kipi-plugins/flickrexport/plugin_flickrexport.h56
21 files changed, 3873 insertions, 0 deletions
diff --git a/kipi-plugins/flickrexport/Makefile.am b/kipi-plugins/flickrexport/Makefile.am
new file mode 100644
index 0000000..90d64f4
--- /dev/null
+++ b/kipi-plugins/flickrexport/Makefile.am
@@ -0,0 +1,23 @@
+METASOURCES = AUTO
+
+INCLUDES = $(LIBKEXIV2_CFLAGS) $(LIBKDCRAW_CFLAGS) $(KIPI_PLUGINS_COMMON_INCLUDE) $(LIBKIPI_CFLAGS) $(all_includes)
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = kipiplugin_flickrexport.la
+
+kipiplugin_flickrexport_la_DEPENDENCIES = $(LIBKIPI_LIBS_DEP) $(LIBKEXIV2_LIBS_DEP) $(LIBKDCRAW_LIBS_DEP)
+
+kipiplugin_flickrexport_la_SOURCES = plugin_flickrexport.cpp imageslist.cpp \
+ flickrwindow.cpp login.cpp flickrtalker.cpp \
+ flickrwidget.cpp mpform.cpp flickralbumdialog.ui \
+ flickrviewitem.cpp
+
+kipiplugin_flickrexport_la_LIBADD = $(LIBKEXIV2_LIBS) $(LIBKDCRAW_LIBS) $(LIBKIPI_LIBS) $(LIB_KIO) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT)
+
+kipiplugin_flickrexport_la_LDFLAGS = $(KIPI_PLUGINS_COMMON_LDFLAGS) -module $(KDE_PLUGIN) $(all_libraries) -lkipiplugins
+
+kde_services_DATA = kipiplugin_flickrexport.desktop
+
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kipiplugin_flickrexport.pot
diff --git a/kipi-plugins/flickrexport/TODO b/kipi-plugins/flickrexport/TODO
new file mode 100644
index 0000000..98d218c
--- /dev/null
+++ b/kipi-plugins/flickrexport/TODO
@@ -0,0 +1,5 @@
+Could add these things to the plugin.
+ Support for viewing your photos stored at server.
+ Querying Space Limit from the server.
+ Allow fetching feature of images just uploaded, like url etc.
+
diff --git a/kipi-plugins/flickrexport/flickralbumdialog.ui b/kipi-plugins/flickrexport/flickralbumdialog.ui
new file mode 100644
index 0000000..63ac730
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickralbumdialog.ui
@@ -0,0 +1,197 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>KIPIFlickrExportPlugin::FlickrAlbumDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>FlickrAlbumDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>342</width>
+ <height>181</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>New PhotoSet</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>false</bool>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>10</number>
+ </property>
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>header</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;h3&gt;Create New PhotoSet &lt;/h3&gt;</string>
+ </property>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>hline1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>titleLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Title (optional):</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>nameLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Name (optional):</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>captionLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Caption (optional):</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>titleEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1">
+ <property name="name">
+ <cstring>nameEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1">
+ <property name="name">
+ <cstring>captionEdit</cstring>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="Line">
+ <property name="name">
+ <cstring>hline2</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>Horizontal Spacing2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="accel">
+ <string></string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>FlickrAlbumDialog</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>FlickrAlbumDialog</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kipi-plugins/flickrexport/flickritem.h b/kipi-plugins/flickrexport/flickritem.h
new file mode 100644
index 0000000..5179ac8
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickritem.h
@@ -0,0 +1,140 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef FLICKRITEM_H
+#define FLICKRITEM_H
+
+// Qt includes.
+
+#include <qstring.h>
+
+namespace KIPIFlickrExportPlugin
+{
+
+class GPhoto
+{
+
+public:
+
+ GPhoto()
+ {
+// ref_num = -1;
+ }
+
+ bool is_public;
+ bool is_private;
+ bool is_family;
+
+ int ref_num;
+// int album_num;
+
+ QStrList tags;
+ QString title;
+ QString description;
+
+// QString caption;
+// QString thumbName;
+// QString albumURL;
+};
+
+// -------------------------------------------------------------
+
+class FPhotoInfo
+{
+
+public:
+
+ FPhotoInfo()
+ {
+ is_public = false;
+ is_family = false;
+ is_friend = false;
+ }
+
+ bool is_public;
+ bool is_friend;
+ bool is_family;
+
+ QString title;
+ QString description;
+ QStringList tags;
+};
+
+// -------------------------------------------------------------
+
+class GAlbum
+{
+
+public:
+
+ GAlbum()
+ {
+ ref_num = -1;
+ parent_ref_num = -1;
+
+ add = false;
+ write = false;
+ del_item = false;
+ del_alb = false;
+ create_sub = false;
+ }
+
+ bool add;
+ bool write;
+ bool del_item;
+ bool del_alb;
+ bool create_sub;
+
+ int ref_num;
+ int parent_ref_num;
+
+ QString name;
+ QString parentName;
+ QString title;
+ QString summary;
+ QString baseurl;
+};
+
+// -------------------------------------------------------------
+
+class FPhotoSet
+{
+
+public:
+
+ FPhotoSet()
+ {
+ id = "-1";
+ }
+
+ QString id;
+ QString primary; //="2483"
+ QString secret; //="abcdef"
+ QString server;
+ QString photos;
+ QString title;
+ QString description;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif /* FLICKRITEM_H */
diff --git a/kipi-plugins/flickrexport/flickrtalker.cpp b/kipi-plugins/flickrexport/flickrtalker.cpp
new file mode 100644
index 0000000..f9926fb
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrtalker.cpp
@@ -0,0 +1,1020 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// C++ includes.
+
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+
+// Qt includes.
+
+#include <qcstring.h>
+#include <qtextstream.h>
+#include <qfile.h>
+#include <qimage.h>
+#include <qstringlist.h>
+#include <qlineedit.h>
+#include <qmessagebox.h>
+#include <qdom.h>
+#include <qmap.h>
+#include <qfileinfo.h>
+#include <qprogressdialog.h>
+
+// KDE includes.
+
+#include <klocale.h>
+#include <kdebug.h>
+#include <kmimetype.h>
+#include <kstandarddirs.h>
+#include <kmdcodec.h>
+#include <kapp.h>
+#include <kmessagebox.h>
+
+// LibKExiv2 includes.
+
+#include <libkexiv2/kexiv2.h>
+
+// LibKDcraw includes.
+
+#include <libkdcraw/version.h>
+#include <libkdcraw/kdcraw.h>
+
+#if KDCRAW_VERSION < 0x000106
+#include <libkdcraw/dcrawbinary.h>
+#endif
+
+// Local includes.
+
+#include "pluginsversion.h"
+#include "mpform.h"
+#include "flickritem.h"
+#include "flickrwindow.h"
+#include "flickrtalker.h"
+#include "flickrtalker.moc"
+
+namespace KIPIFlickrExportPlugin
+{
+
+FlickrTalker::FlickrTalker(QWidget* parent)
+{
+ m_parent = parent;
+ m_job = 0;
+ m_apikey = "49d585bafa0758cb5c58ab67198bf632";
+ m_secret = "34b39925e6273ffd";
+
+ connect(this, SIGNAL(signalAuthenticate()),
+ this, SLOT(slotAuthenticate()));
+}
+
+FlickrTalker::~FlickrTalker()
+{
+ if (m_job)
+ m_job->kill();
+}
+
+/** Compute MD5 signature using url queries keys and values following Flickr notice:
+ http://www.flickr.com/services/api/auth.spec.html
+*/
+QString FlickrTalker::getApiSig(const QString& secret, const KURL& url)
+{
+ QMap<QString, QString> queries = url.queryItems();
+ QString compressed(secret);
+
+ // NOTE: iterator QMap iterator will sort alphabetically items based on key values.
+ for (QMap<QString, QString>::iterator it = queries.begin() ; it != queries.end(); ++it)
+ {
+ compressed.append(it.key());
+ compressed.append(it.data());
+ }
+
+ KMD5 context(compressed.utf8());
+ return context.hexDigest().data();
+}
+
+/**get the Api sig and send it to the server server should return a frob.
+*/
+void FlickrTalker::getFrob()
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ KURL url("http://www.flickr.com/services/rest/");
+ url.addQueryItem("method", "flickr.auth.getFrob");
+ url.addQueryItem("api_key", m_apikey);
+ QString md5 = getApiSig(m_secret, url);
+ url.addQueryItem("api_sig", md5);
+ kdDebug() << "Get frob url: " << url << endl;
+ QByteArray tmp;
+ KIO::TransferJob* job = KIO::http_post(url, tmp, false);
+
+ job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded");
+
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(data(KIO::Job*, const QByteArray&)));
+
+ connect(job, SIGNAL(result(KIO::Job *)),
+ this, SLOT(slotResult(KIO::Job *)));
+
+ m_state = FE_GETFROB;
+ m_authProgressDlg->setLabelText(i18n("Getting the Frob"));
+ m_authProgressDlg->setProgress(1, 4);
+ m_job = job;
+ m_buffer.resize(0);
+ emit signalBusy(true);
+}
+
+void FlickrTalker::checkToken(const QString& token)
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ KURL url("http://www.flickr.com/services/rest/");
+ url.addQueryItem("method", "flickr.auth.checkToken");
+ url.addQueryItem("api_key", m_apikey);
+ url.addQueryItem("auth_token", token);
+ QString md5 = getApiSig(m_secret, url);
+ url.addQueryItem("api_sig", md5);
+ kdDebug() << "Check token url: " << url << endl;
+ QByteArray tmp;
+ KIO::TransferJob* job = KIO::http_post(url, tmp, false);
+
+ job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded");
+
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(data(KIO::Job*, const QByteArray&)));
+
+ connect(job, SIGNAL(result(KIO::Job *)),
+ this, SLOT(slotResult(KIO::Job *)));
+
+ m_state = FE_CHECKTOKEN;
+ m_authProgressDlg->setLabelText(i18n("Checking if previous token is still valid"));
+ m_authProgressDlg->setProgress(1, 4);
+ m_job = job;
+ m_buffer.resize(0);
+ emit signalBusy( true );
+}
+
+void FlickrTalker::slotAuthenticate()
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ KURL url("http://www.flickr.com/services/auth/");
+ url.addQueryItem("api_key", m_apikey);
+ url.addQueryItem("frob", m_frob);
+ url.addQueryItem("perms", "write");
+ QString md5 = getApiSig(m_secret, url);
+ url.addQueryItem("api_sig", md5);
+ kdDebug() << "Authenticate url: " << url << endl;
+
+ KApplication::kApplication()->invokeBrowser(url.url());
+ int valueOk = KMessageBox::questionYesNo(kapp->activeWindow(),
+ i18n("Please Follow through the instructions in the browser window and "
+ "return back to press ok if you are authenticated or press No"),
+ i18n("Flickr Service Web Authorization"));
+
+ if( valueOk == KMessageBox::Yes)
+ {
+ getToken();
+ m_authProgressDlg->setLabelText(i18n("Authenticating the User on web"));
+ m_authProgressDlg->setProgress(2, 4);
+ emit signalBusy(false);
+ }
+ else
+ {
+ kdDebug() << "User didn't proceed with getToken Authorization, cannot proceed further, aborting" << endl;
+ cancel();
+ }
+}
+
+void FlickrTalker::getToken()
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ KURL url("http://www.flickr.com/services/rest/");
+ url.addQueryItem("api_key", m_apikey);
+ url.addQueryItem("method", "flickr.auth.getToken");
+ url.addQueryItem("frob", m_frob);
+ QString md5 = getApiSig(m_secret, url);
+ url.addQueryItem("api_sig", md5);
+ kdDebug() << "Get token url: " << url << endl;
+ QByteArray tmp;
+ KIO::TransferJob* job = KIO::http_post(url, tmp, false);
+ job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded");
+
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(data(KIO::Job*, const QByteArray&)));
+
+ connect(job, SIGNAL(result(KIO::Job *)),
+ this, SLOT(slotResult(KIO::Job *)));
+
+ m_state = FE_GETTOKEN;
+ m_job = job;
+ m_buffer.resize(0);
+ emit signalBusy(true);
+ m_authProgressDlg->setLabelText(i18n("Getting the Token from the server"));
+ m_authProgressDlg->setProgress(3, 4);
+}
+
+void FlickrTalker::listPhotoSets()
+{
+ KURL url("http://www.flickr.com/services/rest/");
+ url.addQueryItem("api_key", m_apikey);
+ url.addQueryItem("method", "flickr.photosets.getList");
+ url.addQueryItem("user_id", m_userId);
+ QString md5 = getApiSig(m_secret, url);
+ url.addQueryItem("api_sig", md5);
+ kdDebug() << "List photo sets url: " << url << endl;
+ QByteArray tmp;
+ KIO::TransferJob* job = KIO::http_post(url, tmp, false);
+ job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
+
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(data(KIO::Job*, const QByteArray&)));
+
+ connect(job, SIGNAL(result(KIO::Job *)),
+ this, SLOT(slotResult(KIO::Job *)));
+
+ m_state = FE_LISTPHOTOSETS;
+ m_job = job;
+ m_buffer.resize(0);
+ emit signalBusy(true);
+}
+
+void FlickrTalker::getPhotoProperty(const QString& method, const QStringList& argList)
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ KURL url("http://www.flickr.com/services/rest/");
+ url.addQueryItem("api_key", m_apikey);
+ url.addQueryItem("method", method);
+ url.addQueryItem("frob", m_frob);
+
+ for (QStringList::const_iterator it = argList.begin(); it != argList.end(); ++it)
+ {
+ QStringList str = QStringList::split("=", (*it));
+ url.addQueryItem(str[0], str[1]);
+ }
+
+ QString md5 = getApiSig(m_secret, url);
+ url.addQueryItem("api_sig", md5);
+ kdDebug() << "Get photo property url: " << url << endl;
+ QByteArray tmp;
+ KIO::TransferJob* job = KIO::http_post(url, tmp, false);
+ job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" );
+
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(data(KIO::Job*, const QByteArray&)));
+
+ connect(job, SIGNAL(result(KIO::Job *)),
+ this, SLOT(slotResult(KIO::Job *)));
+
+ m_state = FE_GETPHOTOPROPERTY;
+ m_job = job;
+ m_buffer.resize(0);
+ emit signalBusy( true );
+
+// m_authProgressDlg->setLabelText("Getting the Token from the server");
+// m_authProgressDlg->setProgress(3,4);
+}
+void FlickrTalker::listPhotos(const QString& /*albumName*/)
+{
+ // TODO
+}
+
+void FlickrTalker::createAlbum(const QString& /*parentAlbumName*/, const QString& /*albumName*/,
+ const QString& /*albumTitle*/, const QString& /*albumCaption*/)
+{
+ //TODO: The equivalent for Album is sets.
+}
+
+bool FlickrTalker::addPhoto(const QString& photoPath, const FPhotoInfo& info,
+ bool rescale, int maxDim, int imageQuality)
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ KURL url("http://www.flickr.com/services/upload/");
+ QString path = photoPath;
+ MPForm form;
+
+ form.addPair("auth_token", m_token);
+ url.addQueryItem("auth_token", m_token);
+
+ form.addPair("api_key", m_apikey);
+ url.addQueryItem("api_key", m_apikey);
+
+ QString ispublic = (info.is_public == 1) ? "1" : "0";
+ form.addPair("is_public", ispublic);
+ url.addQueryItem("is_public", ispublic);
+
+ QString isfamily = (info.is_family == 1) ? "1" : "0";
+ form.addPair("is_family", isfamily);
+ url.addQueryItem("is_family", isfamily);
+
+ QString isfriend = (info.is_friend == 1) ? "1" : "0";
+ form.addPair("is_friend", isfriend);
+ url.addQueryItem("is_friend", isfriend);
+
+ QString tags = info.tags.join(" ");
+ if(tags.length() > 0)
+ {
+ form.addPair("tags", tags);
+ url.addQueryItem("tags", tags);
+ }
+
+ if (!info.title.isEmpty())
+ {
+ form.addPair("title", info.title);
+ url.addQueryItem("title", info.title);
+ }
+
+ if (!info.description.isEmpty())
+ {
+ form.addPair("description", info.description);
+ url.addQueryItem("description", info.description);
+ }
+
+ QString md5 = getApiSig(m_secret, url);
+ form.addPair("api_sig", md5);
+ url.addQueryItem("api_sig", md5);
+ QImage image;
+
+ // Check if RAW file.
+#if KDCRAW_VERSION < 0x000106
+ QString rawFilesExt(KDcrawIface::DcrawBinary::instance()->rawFiles());
+#else
+ QString rawFilesExt(KDcrawIface::KDcraw::rawFiles());
+#endif
+ QFileInfo fileInfo(photoPath);
+ if (rawFilesExt.upper().contains(fileInfo.extension(false).upper()))
+ KDcrawIface::KDcraw::loadDcrawPreview(image, photoPath);
+ else
+ image.load(photoPath);
+
+ kdDebug() << "Add photo query: " << url << endl;
+
+ if (!image.isNull())
+ {
+ path = locateLocal("tmp", QFileInfo(photoPath).baseName().stripWhiteSpace() + ".jpg");
+
+ if (rescale && (image.width() > maxDim || image.height() > maxDim))
+ image = image.smoothScale(maxDim, maxDim, QImage::ScaleMin);
+
+ image.save(path, "JPEG", imageQuality);
+
+ // Restore all metadata.
+
+ KExiv2Iface::KExiv2 exiv2Iface;
+
+ if (exiv2Iface.load(photoPath))
+ {
+ exiv2Iface.setImageDimensions(image.size());
+
+ // NOTE: see B.K.O #153207: Flickr use IPTC keywords to create Tags in web interface
+ // As IPTC do not support UTF-8, we need to remove it.
+ exiv2Iface.removeIptcTag("Iptc.Application2.Keywords", false);
+
+ exiv2Iface.setImageProgramId(QString("Kipi-plugins"), QString(kipiplugins_version));
+ exiv2Iface.save(path);
+ }
+ else
+ {
+ kdWarning(51000) << "(flickrExport::Image doesn't have metdata)" << endl;
+ }
+
+ kdDebug() << "Resizing and saving to temp file: " << path << endl;
+ }
+
+ if (!form.addFile("photo", path))
+ return false;
+
+ form.finish();
+
+ KIO::TransferJob* job = KIO::http_post(url, form.formData(), false);
+ job->addMetaData("content-type", form.contentType());
+
+ connect(job, SIGNAL(data(KIO::Job*, const QByteArray&)),
+ this, SLOT(data(KIO::Job*, const QByteArray&)));
+
+ connect(job, SIGNAL(result(KIO::Job *)),
+ this, SLOT(slotResult(KIO::Job *)));
+
+ m_state = FE_ADDPHOTO;
+ m_job = job;
+ m_buffer.resize(0);
+ emit signalBusy(true);
+ return true;
+}
+
+QString FlickrTalker::getUserName()
+{
+ return m_username;
+}
+
+QString FlickrTalker::getUserId()
+{
+ return m_userId;
+}
+
+void FlickrTalker::cancel()
+{
+ if (m_job)
+ {
+ m_job->kill();
+ m_job = 0;
+ }
+
+ if (m_authProgressDlg && !m_authProgressDlg->isHidden())
+ m_authProgressDlg->hide();
+}
+
+void FlickrTalker::data(KIO::Job*, const QByteArray& data)
+{
+ if (data.isEmpty())
+ return;
+
+ int oldSize = m_buffer.size();
+ m_buffer.resize(m_buffer.size() + data.size());
+ memcpy(m_buffer.data()+oldSize, data.data(), data.size());
+}
+
+void FlickrTalker::slotError(const QString& error)
+{
+ QString transError;
+ int errorNo = atoi(error.latin1());
+
+ switch (errorNo)
+ {
+ case 2:
+ transError = i18n("No photo specified");
+ break;
+ case 3:
+ transError = i18n("General upload failure");
+ break;
+ case 4:
+ transError = i18n("Filesize was zero");
+ break;
+ case 5:
+ transError = i18n("Filetype was not recognised");
+ break;
+ case 6:
+ transError = i18n("User exceeded upload limit");
+ break;
+ case 96:
+ transError = i18n("Invalid signature");
+ break;
+ case 97:
+ transError = i18n("Missing signature");
+ break;
+ case 98:
+ transError = i18n("Login Failed / Invalid auth token");
+ break;
+ case 100:
+ transError = i18n("Invalid API Key");
+ break;
+ case 105:
+ transError = i18n("Service currently unavailable");
+ break;
+ case 108:
+ transError = i18n("Invalid Frob");
+ break;
+ case 111:
+ transError = i18n("Format \"xxx\" not found");
+ break;
+ case 112:
+ transError = i18n("Method \"xxx\" not found");
+ break;
+ case 114:
+ transError = i18n("Invalid SOAP envelope");
+ break;
+ case 115:
+ transError = i18n("Invalid XML-RPC Method Call");
+ break;
+ case 116:
+ transError = i18n("The POST method is now required for all setters");
+ break;
+ default:
+ transError = i18n("Unknown error");
+ break;
+ };
+
+ KMessageBox::error(kapp->activeWindow(),
+ i18n("Error Occured: %1\n We can not proceed further").arg(transError));
+
+// kdDebug() << "Not handling the error now will see it later" << endl;
+}
+
+void FlickrTalker::slotResult(KIO::Job *job)
+{
+ m_job = 0;
+ emit signalBusy(false);
+
+ if (job->error())
+ {
+ if (m_state == FE_ADDPHOTO)
+ emit signalAddPhotoFailed( job->errorString());
+ else
+ job->showErrorDialog(m_parent);
+ return;
+ }
+
+ switch(m_state)
+ {
+ case(FE_LOGIN):
+ //parseResponseLogin(m_buffer);
+ break;
+ case(FE_LISTPHOTOSETS):
+ parseResponseListPhotoSets(m_buffer);
+ break;
+ case(FE_GETFROB):
+ parseResponseGetFrob(m_buffer);
+ break;
+ case(FE_GETTOKEN):
+ parseResponseGetToken(m_buffer);
+ break;
+ case(FE_CHECKTOKEN):
+ parseResponseCheckToken(m_buffer);
+ break;
+ case(FE_GETAUTHORIZED):
+ //parseResponseGetToken(m_buffer);
+ break;
+ case(FE_LISTPHOTOS):
+ parseResponseListPhotos(m_buffer);
+ break;
+ case(FE_GETPHOTOPROPERTY):
+ parseResponsePhotoProperty(m_buffer);
+ break;
+ case(FE_ADDPHOTO):
+ parseResponseAddPhoto(m_buffer);
+ break;
+ }
+ /*
+ if (m_state == FE_LOGIN && m_loggedIn)
+ {
+ // listAlbums();
+ }*/
+}
+
+void FlickrTalker::parseResponseGetFrob(const QByteArray& data)
+{
+ bool success = false;
+ QString errorString;
+ QDomDocument doc("mydocument");
+
+ if (!doc.setContent(data))
+ {
+ return;
+ }
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+
+ while(!node.isNull())
+ {
+ if (node.isElement() && node.nodeName() == "frob")
+ {
+ QDomElement e = node.toElement(); // try to convert the node to an element.
+ kdDebug() << "Frob is" << e.text() << endl;
+ m_frob = e.text(); // this is what is obtained from data.
+ success = true;
+ }
+
+ if (node.isElement() && node.nodeName() == "err")
+ {
+ kdDebug() << "Checking Error in response" << endl;
+ errorString = node.toElement().attribute("code");
+ kdDebug() << "Error code=" << errorString << endl;
+ kdDebug() << "Msg=" << node.toElement().attribute("msg") << endl;
+ }
+ node = node.nextSibling();
+ }
+
+ kdDebug() << "GetFrob finished" << endl;
+ m_authProgressDlg->setProgress(2, 4);
+ m_state = FE_GETAUTHORIZED;
+ if(success)
+ emit signalAuthenticate();
+ else
+ emit signalError(errorString);
+}
+
+void FlickrTalker::parseResponseCheckToken(const QByteArray& data)
+{
+ bool success = false;
+ QString errorString;
+ QString username;
+ QString transReturn;
+ QDomDocument doc("checktoken");
+
+ if (!doc.setContent(data))
+ {
+ return;
+ }
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+ QDomElement e;
+
+ while(!node.isNull())
+ {
+ if (node.isElement() && node.nodeName() == "auth")
+ {
+ e = node.toElement(); // try to convert the node to an element.
+ QDomNode details = e.firstChild();
+
+ while(!details.isNull())
+ {
+ if(details.isElement())
+ {
+ e = details.toElement();
+
+ if(details.nodeName() == "token")
+ {
+ kdDebug() << "Token=" << e.text() << endl;
+ m_token = e.text();//this is what is obtained from data.
+ }
+
+ if(details.nodeName() == "perms")
+ {
+ kdDebug() << "Perms=" << e.text() << endl;
+ QString perms = e.text();//this is what is obtained from data.
+
+ if(perms == "write")
+ transReturn = i18n("As in the persmission to", "write");
+ else if(perms == "read")
+ transReturn = i18n("As in the permission to", "read");
+ else if(perms == "delete")
+ transReturn = i18n("As in the permission to", "delete");
+ }
+
+ if(details.nodeName() == "user")
+ {
+ kdDebug() << "nsid=" << e.attribute("nsid") << endl;
+ m_userId = e.attribute("nsid");
+ username = e.attribute("username");
+ m_username = username;
+ kdDebug() << "username=" << e.attribute("username") << endl;
+ kdDebug() << "fullname=" << e.attribute("fullname") << endl;
+ }
+ }
+
+ details = details.nextSibling();
+ }
+
+ m_authProgressDlg->hide();
+ emit signalTokenObtained(m_token);
+ success = true;
+ }
+
+ if (node.isElement() && node.nodeName() == "err")
+ {
+ kdDebug() << "Checking Error in response" << endl;
+ errorString = node.toElement().attribute("code");
+ kdDebug() << "Error code=" << errorString << endl;
+ kdDebug() << "Msg=" << node.toElement().attribute("msg") << endl;
+
+ int valueOk = KMessageBox::questionYesNo(kapp->activeWindow(),
+ i18n("Your token is invalid. Would you like to "
+ "get a new token to proceed ?\n"));
+ if(valueOk == KMessageBox::Yes)
+ {
+ getFrob();
+ return;
+ }
+ else
+ {
+ m_authProgressDlg->hide(); //will popup the result for the checktoken failure below
+ }
+
+ }
+
+ node = node.nextSibling();
+ }
+
+ if(!success)
+ emit signalError(errorString);
+
+ kdDebug() << "CheckToken finished" << endl;
+}
+
+void FlickrTalker::parseResponseGetToken(const QByteArray& data)
+{
+ bool success = false;
+ QString errorString;
+ QDomDocument doc("gettoken");
+ if (!doc.setContent( data ))
+ return;
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+ QDomElement e;
+
+ while(!node.isNull())
+ {
+ if (node.isElement() && node.nodeName() == "auth")
+ {
+ e = node.toElement(); // try to convert the node to an element.
+ QDomNode details = e.firstChild();
+
+ while(!details.isNull())
+ {
+ if(details.isElement())
+ {
+ e = details.toElement();
+
+ if(details.nodeName() == "token")
+ {
+ kdDebug() << "Token=" << e.text() << endl;
+ m_token = e.text(); //this is what is obtained from data.
+ }
+
+ if(details.nodeName() == "perms")
+ {
+ kdDebug() << "Perms=" << e.text() << endl;
+ }
+
+ if(details.nodeName() == "user")
+ {
+ kdDebug() << "nsid=" << e.attribute("nsid") << endl;
+ kdDebug() << "username=" << e.attribute("username") << endl;
+ kdDebug() << "fullname=" << e.attribute("fullname") << endl;
+ m_username = e.attribute("username");
+ m_userId = e.attribute("nsid");
+ }
+ }
+
+ details = details.nextSibling();
+ }
+
+ success = true;
+ }
+ else if (node.isElement() && node.nodeName() == "err")
+ {
+ kdDebug() << "Checking Error in response" << endl;
+ errorString = node.toElement().attribute("code");
+ kdDebug() << "Error code=" << errorString << endl;
+ kdDebug() << "Msg=" << node.toElement().attribute("msg") << endl;
+ //emit signalError(code);
+ }
+
+ node = node.nextSibling();
+ }
+
+ kdDebug() << "GetToken finished" << endl;
+ //emit signalBusy( false );
+ m_authProgressDlg->hide();
+
+ if(success)
+ emit signalTokenObtained(m_token);
+ else
+ emit signalError(errorString);
+}
+void FlickrTalker::parseResponseListPhotoSets(const QByteArray& data)
+{
+ bool success = false;
+ QDomDocument doc("getListPhotoSets");
+ if (!doc.setContent(data))
+ return;
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+ QDomElement e;
+ QString photoSet_id, photoSet_title, photoSet_description;
+ QValueList <FPhotoSet> photoSetList;
+
+ while(!node.isNull())
+ {
+ if (node.isElement() && node.nodeName() == "photosets")
+ {
+ e = node.toElement();
+ QDomNode details = e.firstChild();
+ FPhotoSet fps;
+ QDomNode detailsNode = details;
+
+ while(!detailsNode.isNull())
+ {
+ if(detailsNode.isElement())
+ {
+ e = detailsNode.toElement();
+ if(detailsNode.nodeName() == "photoset")
+ {
+ kdDebug() << "id=" << e.attribute("id") << endl;
+ photoSet_id = e.attribute("id"); //this is what is obtained from data.
+ fps.id = photoSet_id;
+ QDomNode photoSetDetails = detailsNode.firstChild();
+ QDomElement e_detail;
+
+ while(!photoSetDetails.isNull())
+ {
+ e_detail = photoSetDetails.toElement();
+
+ if(photoSetDetails.nodeName() == "title")
+ {
+ kdDebug() << "Title=" << e_detail.text() << endl;
+ photoSet_title = e_detail.text();
+ fps.title = photoSet_title;
+ }
+ else if(photoSetDetails.nodeName() == "description")
+ {
+ kdDebug() << "Description =" << e_detail.text() << endl;
+ photoSet_description = e_detail.text();
+ fps.description = photoSet_description;
+ }
+
+ photoSetDetails = photoSetDetails.nextSibling();
+ }
+ }
+ }
+
+ detailsNode = detailsNode.nextSibling();
+ }
+
+ photoSetList.append(fps);
+ details = details.nextSibling();
+ success = true;
+ }
+
+ if (node.isElement() && node.nodeName() == "err")
+ {
+ kdDebug() << "Checking Error in response" << endl;
+ QString code = node.toElement().attribute("code");
+ kdDebug() << "Error code=" << code << endl;
+ kdDebug() << "Msg=" << node.toElement().attribute("msg") << endl;
+ emit signalError(code);
+ }
+
+ node = node.nextSibling();
+ }
+
+ kdDebug() << "GetPhotoList finished" << endl;
+
+ if (!success)
+ {
+ emit signalListPhotoSetsFailed(i18n("Failed to fetch photoSets List"));
+ }
+ else
+ {
+ emit signalListPhotoSetsSucceeded(photoSetList);
+ }
+}
+
+void FlickrTalker::parseResponseListPhotos(const QByteArray& data)
+{
+ QDomDocument doc("getPhotosList");
+ if (!doc.setContent( data))
+ return;
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+ //QDomElement e;
+ //TODO
+}
+
+void FlickrTalker::parseResponseCreateAlbum(const QByteArray& data)
+{
+ QDomDocument doc("getCreateAlbum");
+ if (!doc.setContent(data))
+ return;
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+
+ //TODO
+}
+
+void FlickrTalker::parseResponseAddPhoto(const QByteArray& data)
+{
+ bool success = false;
+ QString line;
+ QDomDocument doc("AddPhoto Response");
+ if (!doc.setContent(data))
+ return;
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+ QDomElement e;
+
+ while(!node.isNull())
+ {
+ if (node.isElement() && node.nodeName() == "photoid")
+ {
+ e = node.toElement(); // try to convert the node to an element.
+ QDomNode details = e.firstChild();
+ kdDebug() << "Photoid= " << e.text() << endl;
+ success = true;
+ }
+
+ if (node.isElement() && node.nodeName() == "err")
+ {
+ kdDebug() << "Checking Error in response" << endl;
+ QString code = node.toElement().attribute("code");
+ kdDebug() << "Error code=" << code << endl;
+ kdDebug() << "Msg=" << node.toElement().attribute("msg") << endl;
+ emit signalError(code);
+ }
+
+ node = node.nextSibling();
+ }
+
+ kdDebug() << "GetToken finished" << endl;
+
+ if (!success)
+ {
+ emit signalAddPhotoFailed(i18n("Failed to upload photo"));
+ }
+ else
+ {
+ emit signalAddPhotoSucceeded();
+ }
+
+}
+void FlickrTalker::parseResponsePhotoProperty(const QByteArray& data)
+{
+ bool success = false;
+ QString line;
+ QDomDocument doc("Photos Properties");
+ if (!doc.setContent(data))
+ return;
+
+ QDomElement docElem = doc.documentElement();
+ QDomNode node = docElem.firstChild();
+ QDomElement e;
+
+ while(!node.isNull())
+ {
+ if (node.isElement() && node.nodeName() == "photoid")
+ {
+ e = node.toElement(); // try to convert the node to an element.
+ QDomNode details = e.firstChild();
+ kdDebug() << "Photoid=" << e.text() << endl;
+ success = true;
+ }
+
+ if (node.isElement() && node.nodeName() == "err")
+ {
+ kdDebug() << "Checking Error in response" << endl;
+ QString code = node.toElement().attribute("code");
+ kdDebug() << "Error code=" << code << endl;
+ kdDebug() << "Msg=" << node.toElement().attribute("msg") << endl;
+ emit signalError(code);
+ }
+
+ node = node.nextSibling();
+ }
+
+ kdDebug() << "GetToken finished" << endl;
+
+ if (!success)
+ {
+ emit signalAddPhotoFailed(i18n("Failed to query photo information"));
+ }
+ else
+ {
+ emit signalAddPhotoSucceeded();
+ }
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/flickrtalker.h b/kipi-plugins/flickrexport/flickrtalker.h
new file mode 100644
index 0000000..9b98209
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrtalker.h
@@ -0,0 +1,151 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef FLICKRTALKER_H
+#define FLICKRTALKER_H
+
+// Qt includes.
+
+#include <qstring.h>
+#include <qvaluelist.h>
+#include <qobject.h>
+#include <qprogressdialog.h>
+
+// KDE includes.
+
+#include <kurl.h>
+#include <kio/job.h>
+
+class QProgressDialog;
+
+namespace KIPIFlickrExportPlugin
+{
+
+class GAlbum;
+class GPhoto;
+class FPhotoInfo;
+class FPhotoSet;
+
+class FlickrTalker : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ enum State
+ {
+ FE_LOGIN = 0,
+ FE_LISTPHOTOSETS,
+ FE_LISTPHOTOS,
+ FE_GETPHOTOPROPERTY,
+ FE_ADDPHOTO,
+ FE_GETFROB,
+ FE_CHECKTOKEN,
+ FE_GETTOKEN,
+ FE_GETAUTHORIZED
+ };
+
+public:
+
+ FlickrTalker(QWidget* parent);
+ ~FlickrTalker();
+
+ QString getUserName();
+ QString getUserId();
+ void getFrob();
+ void getToken();
+ void checkToken(const QString& token);
+ void getPhotoProperty(const QString& method, const QStringList& argList);
+ void cancel();
+
+ void listPhotoSets();
+ void listPhotos(const QString& albumName);
+ void createAlbum(const QString& parentAlbumName,
+ const QString& albumName,
+ const QString& albumTitle,
+ const QString& albumCaption);
+
+ bool addPhoto(const QString& photoPath, const FPhotoInfo& info,
+ bool rescale=false, int maxDim=600, int imageQuality=85);
+
+public:
+
+ QProgressDialog *m_authProgressDlg;
+
+signals:
+
+ void signalError(const QString& msg);
+// void signalLoginFailed( const QString& msg );
+ void signalBusy(bool val);
+ void signalAlbums(const QValueList<GAlbum>& albumList);
+ void signalPhotos(const QValueList<GPhoto>& photoList);
+ void signalAddPhotoSucceeded();
+ void signalListPhotoSetsSucceeded(const QValueList <FPhotoSet>& photoSetList);
+ void signalAddPhotoFailed(const QString& msg);
+ void signalListPhotoSetsFailed(const QString& msg);
+ void signalAuthenticate();
+ void signalTokenObtained(const QString& token);
+
+private:
+
+// void parseResponseLogin(const QByteArray& data);
+ void parseResponseListPhotoSets(const QByteArray& data);
+ void parseResponseListPhotos(const QByteArray& data);
+ void parseResponseCreateAlbum(const QByteArray& data);
+ void parseResponseAddPhoto(const QByteArray& data);
+ void parseResponseGetFrob(const QByteArray& data);
+ void parseResponseGetToken(const QByteArray& data);
+ void parseResponseCheckToken(const QByteArray& data);
+ void parseResponsePhotoProperty(const QByteArray& data);
+
+ QString getApiSig(const QString& secret, const KURL& url);
+
+private slots:
+
+ void slotError(const QString& msg);
+ void slotAuthenticate();
+ void data(KIO::Job *job, const QByteArray& data);
+ void slotResult(KIO::Job *job);
+
+private:
+
+ QWidget* m_parent;
+
+// QString m_cookie;
+ QByteArray m_buffer;
+
+ QString m_apikey;
+ QString m_secret;
+ QString m_frob;
+ QString m_token;
+ QString m_username;
+ QString m_userId;
+
+ KIO::Job* m_job;
+
+ State m_state;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif /* FLICKRTALKER_H */
diff --git a/kipi-plugins/flickrexport/flickrviewitem.cpp b/kipi-plugins/flickrexport/flickrviewitem.cpp
new file mode 100644
index 0000000..50d955a
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrviewitem.cpp
@@ -0,0 +1,107 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2004-12-01
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2004 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// Qt includes.
+
+#include <qpainter.h>
+#include <qpixmap.h>
+
+// Local includes.
+
+#include "flickrviewitem.h"
+
+namespace KIPIFlickrExportPlugin
+{
+
+GAlbumViewItem::GAlbumViewItem(QListView* parent, const QString& name, const GAlbum& album)
+ : QListViewItem(parent, name)
+{
+ m_album = album;
+}
+
+GAlbumViewItem::GAlbumViewItem(QListViewItem* parent, const QString& name, const GAlbum& album)
+ : QListViewItem(parent, name)
+{
+ m_album = album;
+}
+
+GAlbumViewItem::~GAlbumViewItem()
+{
+}
+
+void GAlbumViewItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int)
+{
+ if (!p)
+ return;
+
+ QListView *lv = listView();
+ if (!lv)
+ return;
+
+ QFontMetrics fm(p->fontMetrics());
+
+ if (isSelected())
+ p->fillRect(0, 0, width, height(), cg.highlight());
+ else
+ p->fillRect(0, 0, width, height(), cg.base());
+
+ const QPixmap* icon = pixmap(column);
+
+ int iconWidth = 0;
+ if (icon)
+ {
+ iconWidth = icon->width() + lv->itemMargin();
+ int xo = lv->itemMargin();
+ int yo = (height() - icon->height())/2;
+ p->drawPixmap( xo, yo, *icon );
+ }
+
+ if (isSelected())
+ p->setPen( cg.highlightedText() );
+ else
+ p->setPen( cg.text() );
+
+ int r = lv->itemMargin() + iconWidth;
+ int h = lv->fontMetrics().height() + 2;
+ p->drawText(r, 0, width-r, h, Qt::AlignVCenter, m_album.title);
+
+ QFont fn(lv->font());
+ fn.setPointSize(fn.pointSize()-2);
+ fn.setItalic(true);
+ p->setFont(fn);
+ p->setPen(isSelected() ? cg.highlightedText() : Qt::gray);
+ p->drawText(r, h, width-r, h, Qt::AlignVCenter, m_album.name);
+}
+
+void GAlbumViewItem::setup()
+{
+ int h = listView()->fontMetrics().height();
+ int margin = 4;
+ setHeight( QMAX(2*h + margin, 32) );
+}
+
+void GAlbumViewItem::paintFocus(QPainter*, const QColorGroup&, const QRect&)
+{
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/flickrviewitem.h b/kipi-plugins/flickrexport/flickrviewitem.h
new file mode 100644
index 0000000..9bd5a21
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrviewitem.h
@@ -0,0 +1,60 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2004-12-01
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2004 by Renchi Raju <renchi@pooh.tam.uiuc.edu>
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef FLICKRVIEWITEM_H
+#define FLICKRVIEWITEM_H
+
+// Qt includes.
+
+#include <qlistview.h>
+
+// Local includes.
+
+#include "flickritem.h"
+
+namespace KIPIFlickrExportPlugin
+{
+
+class GAlbumViewItem : public QListViewItem
+{
+
+public:
+
+ GAlbumViewItem(QListView* parent, const QString& name, const GAlbum& album);
+ GAlbumViewItem(QListViewItem* parent, const QString& name, const GAlbum& album);
+ ~GAlbumViewItem();
+
+protected:
+
+ void paintCell(QPainter *p, const QColorGroup& cg, int column, int width, int);
+ void paintFocus(QPainter*, const QColorGroup&, const QRect&);
+ void setup();
+
+private:
+
+ GAlbum m_album;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif /* FLICKRVIEWITEM_H */
diff --git a/kipi-plugins/flickrexport/flickrwidget.cpp b/kipi-plugins/flickrexport/flickrwidget.cpp
new file mode 100644
index 0000000..45e5afb
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrwidget.cpp
@@ -0,0 +1,218 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// Qt includes.
+
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qframe.h>
+#include <qheader.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qgroupbox.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+// KDE includes.
+
+#include <ktabwidget.h>
+#include <klineedit.h>
+#include <kdialog.h>
+#include <kactivelabel.h>
+#include <klocale.h>
+#include <khtml_part.h>
+#include <khtmlview.h>
+#include <kseparator.h>
+#include <kiconloader.h>
+#include <kapplication.h>
+
+// Libkipi includes.
+
+#include <libkipi/interface.h>
+
+// Local includes.
+
+#include "imageslist.h"
+#include "flickrwidget.h"
+#include "flickrwidget.moc"
+
+namespace KIPIFlickrExportPlugin
+{
+
+FlickrWidget::FlickrWidget(QWidget* parent, KIPI::Interface *iface)
+ : QWidget(parent)
+{
+ setName("FlickrWidget");
+
+ QVBoxLayout* flickrWidgetLayout = new QVBoxLayout(this, 5, 5);
+
+ m_photoView = 0; //new KHTMLPart(splitter);
+ KSeparator *line = new KSeparator(Horizontal, this);
+ m_tab = new KTabWidget(this);
+ KActiveLabel *headerLabel = new KActiveLabel(this);
+ headerLabel->setFocusPolicy(NoFocus);
+ headerLabel->setLinkUnderline(false);
+ headerLabel->setText(i18n("<qt><b><h2><a href='http://www.flickr.com'>"
+ "<font color=\"#0065DE\">flick</font>"
+ "<font color=\"#FF0084\">r</font></a>"
+ " Export"
+ "</h2></b></qt>"));
+
+ // -------------------------------------------------------------------
+
+ m_imglst = new ImagesList(m_tab, iface);
+ QWidget* settingsBox = new QWidget(m_tab);
+ QVBoxLayout* settingsBoxLayout = new QVBoxLayout(settingsBox);
+
+ //m_newAlbumBtn = new QPushButton(settingsBox, "m_newAlbumBtn");
+ //m_newAlbumBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ //m_newAlbumBtn->setText(i18n("&New Album"));
+
+ QGridLayout* tagsLayout = new QGridLayout(1, 1);
+ QLabel* tagsLabel = new QLabel(i18n("Added Tags: "), settingsBox);
+ m_tagsLineEdit = new KLineEdit(settingsBox);
+ m_exportHostTagsCheckBox = new QCheckBox(settingsBox);
+ m_exportHostTagsCheckBox->setText(i18n("Use Host Application Tags"));
+ m_stripSpaceTagsCheckBox = new QCheckBox(settingsBox);
+ m_stripSpaceTagsCheckBox->setText(i18n("Strip Space From Host Application Tags"));
+ QToolTip::add(m_tagsLineEdit, i18n("Enter here new tags separated by space."));
+
+ tagsLayout->addWidget(tagsLabel, 0, 0);
+ tagsLayout->addWidget(m_tagsLineEdit, 0, 1);
+ tagsLayout->addWidget(m_exportHostTagsCheckBox, 1, 1);
+ tagsLayout->addWidget(m_stripSpaceTagsCheckBox, 2, 1);
+
+ // ------------------------------------------------------------------------
+
+ QGroupBox* optionsBox = new QGroupBox(i18n("Override Default Options"), settingsBox);
+ optionsBox->setColumnLayout(0, Qt::Vertical);
+ optionsBox->layout()->setSpacing(KDialog::spacingHint());
+ optionsBox->layout()->setMargin(KDialog::spacingHint());
+ QGridLayout* optionsBoxLayout = new QGridLayout(optionsBox->layout(), 5, 3);
+
+ m_publicCheckBox = new QCheckBox(optionsBox);
+ m_publicCheckBox->setText(i18n("As in accessible for people", "Public (anyone can see them)"));
+
+ m_familyCheckBox = new QCheckBox(optionsBox);
+ m_familyCheckBox->setText(i18n("Visible to Family"));
+
+ m_friendsCheckBox = new QCheckBox(optionsBox);
+ m_friendsCheckBox->setText(i18n("Visible to Friends"));
+
+ m_resizeCheckBox = new QCheckBox(optionsBox);
+ m_resizeCheckBox->setText(i18n("Resize photos before uploading"));
+ m_resizeCheckBox->setChecked(false);
+
+ m_dimensionSpinBox = new QSpinBox(0, 5000, 10, optionsBox);
+ m_dimensionSpinBox->setValue(600);
+ m_dimensionSpinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_dimensionSpinBox->setEnabled(false);
+
+ QLabel* resizeLabel = new QLabel(i18n("Maximum dimension (pixels):"), optionsBox);
+
+ m_imageQualitySpinBox = new QSpinBox(0, 100, 1, optionsBox);
+ m_imageQualitySpinBox->setValue(85);
+ m_imageQualitySpinBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ // NOTE: The term Compression factor may be to technical to write in the label
+ QLabel* imageQualityLabel = new QLabel(i18n("JPEG Image Quality (higher is better):"), optionsBox);
+
+ optionsBoxLayout->addMultiCellWidget(m_publicCheckBox, 0, 0, 0, 3);
+ optionsBoxLayout->addMultiCellWidget(m_familyCheckBox, 1, 1, 0, 3);
+ optionsBoxLayout->addMultiCellWidget(m_friendsCheckBox, 2, 2, 0, 3);
+ optionsBoxLayout->addMultiCellWidget(imageQualityLabel, 3, 3, 0, 2);
+ optionsBoxLayout->addMultiCellWidget(m_imageQualitySpinBox, 3, 3, 3, 3);
+ optionsBoxLayout->addMultiCellWidget(m_resizeCheckBox, 4, 4, 0, 3);
+ optionsBoxLayout->addMultiCellWidget(resizeLabel, 5, 5, 1, 2);
+ optionsBoxLayout->addMultiCellWidget(m_dimensionSpinBox, 5, 5, 3, 3);
+ optionsBoxLayout->setColSpacing(0, KDialog::spacingHint());
+ optionsBoxLayout->setColStretch(1, 10);
+ optionsBoxLayout->setSpacing(KDialog::spacingHint());
+ optionsBoxLayout->setMargin(0);
+
+ // ------------------------------------------------------------------------
+
+ QGroupBox* accountBox = new QGroupBox(i18n("Account"), settingsBox);
+ accountBox->setColumnLayout(0, Qt::Vertical);
+ accountBox->layout()->setSpacing(KDialog::spacingHint());
+ accountBox->layout()->setMargin(KDialog::spacingHint());
+ QGridLayout* accountBoxLayout = new QGridLayout(accountBox->layout(), 1, 3);
+
+ QLabel *userNameLabel = new QLabel(i18n("User Name: "), accountBox);
+ m_userNameDisplayLabel = new QLabel(accountBox);
+ m_changeUserButton = new QPushButton(accountBox);
+ m_changeUserButton->setText(i18n("Use a different account"));
+ m_changeUserButton->setIconSet(SmallIcon("switchuser"));
+
+ accountBoxLayout->addMultiCellWidget(userNameLabel, 0, 0, 0, 0);
+ accountBoxLayout->addMultiCellWidget(m_userNameDisplayLabel, 0, 0, 1, 1);
+ accountBoxLayout->addMultiCellWidget(m_changeUserButton, 0, 0, 3, 3);
+ accountBoxLayout->setColStretch(2, 10);
+ accountBoxLayout->setSpacing(KDialog::spacingHint());
+ accountBoxLayout->setMargin(0);
+
+ settingsBoxLayout->addLayout(tagsLayout);
+ settingsBoxLayout->addWidget(optionsBox);
+ settingsBoxLayout->addWidget(accountBox);
+ settingsBoxLayout->addStretch(10);
+ settingsBoxLayout->setSpacing(KDialog::spacingHint());
+ settingsBoxLayout->setMargin(KDialog::spacingHint());
+
+ // ------------------------------------------------------------------------
+
+ flickrWidgetLayout->addWidget(headerLabel);
+ flickrWidgetLayout->addWidget(line);
+ flickrWidgetLayout->addWidget(m_tab, 5);
+ flickrWidgetLayout->setSpacing(KDialog::spacingHint());
+ flickrWidgetLayout->setMargin(0);
+
+ m_tab->insertTab(m_imglst, i18n("Files List"), FILELIST);
+ m_tab->insertTab(settingsBox, i18n("Upload Options"), UPLOAD);
+
+ // ------------------------------------------------------------------------
+
+ connect(m_resizeCheckBox, SIGNAL(clicked()),
+ this, SLOT(slotResizeChecked()));
+
+ connect(m_exportHostTagsCheckBox, SIGNAL(clicked()),
+ this, SLOT(slotExportHostTagsChecked()));
+}
+
+FlickrWidget::~FlickrWidget()
+{
+}
+
+void FlickrWidget::slotResizeChecked()
+{
+ m_dimensionSpinBox->setEnabled(m_resizeCheckBox->isChecked());
+}
+
+void FlickrWidget::slotExportHostTagsChecked()
+{
+ m_stripSpaceTagsCheckBox->setEnabled(m_exportHostTagsCheckBox->isChecked());
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/flickrwidget.h b/kipi-plugins/flickrexport/flickrwidget.h
new file mode 100644
index 0000000..e451a8a
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrwidget.h
@@ -0,0 +1,102 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef FLICKRWIDGET_H
+#define FLICKRWIDGET_H
+
+// Qt includes.
+
+#include <qwidget.h>
+
+class QPushButton;
+class QSpinBox;
+class QCheckBox;
+class QRadioButton;
+
+class KTabWidget;
+class KLineEdit;
+class KHTMLPart;
+
+namespace KIPI
+{
+ class Interface;
+}
+
+namespace KIPIFlickrExportPlugin
+{
+
+class ImagesList;
+
+class FlickrWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ enum SettingsTab
+ {
+ FILELIST=0,
+ UPLOAD
+ };
+
+public:
+
+ FlickrWidget(QWidget* parent, KIPI::Interface *iface);
+ ~FlickrWidget();
+
+private slots:
+
+ void slotResizeChecked();
+ void slotExportHostTagsChecked();
+
+private:
+
+// QPushButton* m_newAlbumBtn;
+ QPushButton* m_changeUserButton;
+
+ QCheckBox* m_resizeCheckBox;
+ QCheckBox* m_familyCheckBox;
+ QCheckBox* m_friendsCheckBox;
+ QCheckBox* m_publicCheckBox;
+ QCheckBox* m_exportHostTagsCheckBox;
+ QCheckBox* m_stripSpaceTagsCheckBox;
+
+ QSpinBox* m_dimensionSpinBox;
+ QSpinBox* m_imageQualitySpinBox;
+
+ QLabel* m_userNameDisplayLabel;
+
+ KLineEdit* m_tagsLineEdit;
+
+ KTabWidget* m_tab;
+
+ KHTMLPart* m_photoView;
+
+ ImagesList* m_imglst;
+
+ friend class FlickrWindow;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif // FLICKRWIDGET_H
diff --git a/kipi-plugins/flickrexport/flickrwindow.cpp b/kipi-plugins/flickrexport/flickrwindow.cpp
new file mode 100644
index 0000000..5f6a345
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrwindow.cpp
@@ -0,0 +1,588 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-17-06
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// Qt includes.
+
+#include <qpushbutton.h>
+#include <qtimer.h>
+#include <qpixmap.h>
+#include <qcursor.h>
+#include <qprogressdialog.h>
+#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qstringlist.h>
+#include <qradiobutton.h>
+
+// KDE includes.
+
+#include <klineedit.h>
+#include <khelpmenu.h>
+#include <kpopupmenu.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+#include <kiconloader.h>
+#include <khtml_part.h>
+#include <khtmlview.h>
+#include <ktabwidget.h>
+#include <krun.h>
+#include <kdebug.h>
+#include <kconfig.h>
+#include <kdeversion.h>
+#if KDE_IS_VERSION(3,2,0)
+#include <kwallet.h>
+#endif
+
+// Libkipi includes.
+
+#include <libkipi/interface.h>
+#include <libkipi/imagedialog.h>
+
+// Local includes.
+
+#include "kpaboutdata.h"
+#include "pluginsversion.h"
+#include "login.h"
+#include "imageslist.h"
+#include "flickrtalker.h"
+#include "flickritem.h"
+#include "flickrviewitem.h"
+#include "flickrwidget.h"
+#include "flickralbumdialog.h"
+#include "flickrwindow.h"
+#include "flickrwindow.moc"
+
+namespace KIPIFlickrExportPlugin
+{
+
+FlickrWindow::FlickrWindow(KIPI::Interface* interface, const QString &tmpFolder, QWidget *parent)
+ : KDialogBase(parent, 0, false, i18n("Export to Flickr Web Service"),
+ Help|User1|Close, Close, false)
+{
+ m_tmp = tmpFolder;
+ m_interface = interface;
+ m_uploadCount = 0;
+ m_uploadTotal = 0;
+// m_wallet = 0;
+ m_widget = new FlickrWidget(this, interface);
+ m_photoView = m_widget->m_photoView;
+// m_newAlbumBtn = m_widget->m_newAlbumBtn;
+ m_resizeCheckBox = m_widget->m_resizeCheckBox;
+ m_publicCheckBox = m_widget->m_publicCheckBox;
+ m_familyCheckBox = m_widget->m_familyCheckBox;
+ m_friendsCheckBox = m_widget->m_friendsCheckBox;
+ m_dimensionSpinBox = m_widget->m_dimensionSpinBox;
+ m_imageQualitySpinBox = m_widget->m_imageQualitySpinBox;
+ m_tagsLineEdit = m_widget->m_tagsLineEdit;
+ m_exportHostTagsCheckBox = m_widget->m_exportHostTagsCheckBox;
+ m_stripSpaceTagsCheckBox = m_widget->m_stripSpaceTagsCheckBox;
+ m_changeUserButton = m_widget->m_changeUserButton;
+ m_userNameDisplayLabel = m_widget->m_userNameDisplayLabel;
+ m_imglst = m_widget->m_imglst;
+
+ setButtonGuiItem(User1, KGuiItem(i18n("Start Uploading"), SmallIcon("network")));
+ setMainWidget(m_widget);
+ m_widget->setMinimumSize(600, 400);
+
+ connect(m_imglst, SIGNAL(signalImageListChanged(bool)),
+ this, SLOT(slotImageListChanged(bool)));
+
+ //m_startUploadButton->setEnabled(false);
+ //m_albumView->setRootIsDecorated(true);
+ //m_newAlbumBtn->setEnabled(false);
+
+ // --------------------------------------------------------------------------
+ // About data and help button.
+
+ m_about = new KIPIPlugins::KPAboutData(I18N_NOOP("Flickr Export"),
+ 0,
+ KAboutData::License_GPL,
+ I18N_NOOP("A Kipi plugin to export image collection to "
+ "Flickr web service."),
+ "(c) 2005-2008, Vardhman Jain\n"
+ "(c) 2008, Gilles Caulier");
+
+ m_about->addAuthor("Vardhman Jain", I18N_NOOP("Author and maintainer"),
+ "Vardhman at gmail dot com");
+
+ m_about->addAuthor("Gilles Caulier", I18N_NOOP("Developer"),
+ "caulier dot gilles at gmail dot com");
+
+ KHelpMenu* helpMenu = new KHelpMenu(this, m_about, false);
+ helpMenu->menu()->removeItemAt(0);
+ helpMenu->menu()->insertItem(i18n("Plugin Handbook"), this, SLOT(slotHelp()), 0, -1, 0);
+ actionButton(Help)->setPopup(helpMenu->menu());
+
+ // --------------------------------------------------------------------------
+
+ m_talker = new FlickrTalker(this);
+
+ connect(m_talker, SIGNAL( signalError( const QString& ) ),
+ m_talker, SLOT( slotError( const QString& ) ));
+
+ connect(m_talker, SIGNAL( signalBusy( bool ) ),
+ this, SLOT( slotBusy( bool ) ));
+
+ connect(m_talker, SIGNAL( signalAddPhotoSucceeded() ),
+ this, SLOT( slotAddPhotoSucceeded() ));
+
+ connect(m_talker, SIGNAL( signalAddPhotoFailed( const QString& ) ),
+ this, SLOT( slotAddPhotoFailed( const QString& ) ));
+
+ connect(m_talker, SIGNAL( signalListPhotoSetsSucceeded( const QValueList<FPhotoSet>& ) ),
+ this, SLOT( slotListPhotoSetsResponse( const QValueList<FPhotoSet>& ) ));
+
+ //connect( m_talker, SIGNAL( signalAlbums( const QValueList<GAlbum>& ) ),
+ // SLOT( slotAlbums( const QValueList<GAlbum>& ) ) );
+
+ //connect( m_talker, SIGNAL( signalPhotos( const QValueList<GPhoto>& ) ),
+ // SLOT( slotPhotos( const QValueList<GPhoto>& ) ) );
+
+ // --------------------------------------------------------------------------
+
+ m_progressDlg = new QProgressDialog(this, 0, true);
+ m_progressDlg->setAutoReset(true);
+ m_progressDlg->setAutoClose(true);
+
+ connect(m_progressDlg, SIGNAL( canceled() ),
+ this, SLOT( slotAddPhotoCancel() ));
+
+ connect(m_changeUserButton, SIGNAL( clicked() ),
+ this, SLOT( slotUserChangeRequest() ));
+
+ connect(m_talker, SIGNAL( signalTokenObtained(const QString&) ),
+ this, SLOT( slotTokenObtained(const QString&) ));
+
+ //connect( m_tagView, SIGNAL( selectionChanged() ),
+ // SLOT( slotTagSelected() ) );
+
+ //connect( m_photoView->browserExtension(), SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
+ // SLOT( slotOpenPhoto( const KURL& ) ) );
+
+ //connect( m_newAlbumBtn, SIGNAL( clicked() ),
+ // SLOT( slotNewAlbum() ) );
+
+ // --------------------------------------------------------------------------
+
+ readSettings();
+
+ m_authProgressDlg = new QProgressDialog(this, 0, true);
+ m_authProgressDlg->setAutoReset(true);
+ m_authProgressDlg->setAutoClose(true);
+
+ connect(m_authProgressDlg, SIGNAL( canceled() ),
+ this, SLOT( slotAuthCancel() ));
+
+ m_talker->m_authProgressDlg = m_authProgressDlg;
+ m_widget->setEnabled(false);
+
+ kdDebug() << "Calling auth methods" << endl;
+
+ if(m_token.length()< 1)
+ m_talker->getFrob();
+ else
+ m_talker->checkToken(m_token);
+}
+
+FlickrWindow::~FlickrWindow()
+{
+#if KDE_IS_VERSION(3,2,0)
+// if (m_wallet)
+// delete m_wallet;
+#endif
+
+ delete m_progressDlg;
+ delete m_authProgressDlg;
+ delete m_talker;
+ delete m_widget;
+ delete m_about;
+}
+
+void FlickrWindow::readSettings()
+{
+ KConfig config("kipirc");
+ config.setGroup("FlickrExport Settings");
+ m_token = config.readEntry("token");
+
+ if (config.readBoolEntry("Resize", false))
+ {
+ m_resizeCheckBox->setChecked(true);
+ m_dimensionSpinBox->setEnabled(true);
+ }
+ else
+ {
+ m_resizeCheckBox->setChecked(false);
+ m_dimensionSpinBox->setEnabled(false);
+ }
+
+ m_dimensionSpinBox->setValue(config.readNumEntry("Maximum Width", 1600));
+ m_imageQualitySpinBox->setValue(config.readNumEntry("Image Quality", 85));
+ m_exportHostTagsCheckBox->setChecked(config.readBoolEntry("Export Host Tags", false));
+ m_stripSpaceTagsCheckBox->setChecked(config.readBoolEntry("Strip Space Host Tags", false));
+ m_stripSpaceTagsCheckBox->setEnabled(m_exportHostTagsCheckBox->isChecked());
+
+ if(!m_interface->hasFeature(KIPI::HostSupportsTags))
+ {
+ m_exportHostTagsCheckBox->setEnabled(false);
+ m_stripSpaceTagsCheckBox->setEnabled(false);
+ }
+
+ m_publicCheckBox->setChecked(config.readBoolEntry("Public Sharing", false));
+ m_familyCheckBox->setChecked(config.readBoolEntry("Family Sharing", false));
+ m_friendsCheckBox->setChecked(config.readBoolEntry("Friends Sharing", false));
+
+ resize(configDialogSize(config, QString("FlickrExport Dialog")));
+}
+
+void FlickrWindow::writeSettings()
+{
+ KConfig config("kipirc");
+ config.setGroup("FlickrExport Settings");
+ config.writeEntry("token", m_token);
+ config.writeEntry("Resize", m_resizeCheckBox->isChecked());
+ config.writeEntry("Maximum Width", m_dimensionSpinBox->value());
+ config.writeEntry("Image Quality", m_imageQualitySpinBox->value());
+ config.writeEntry("Export Host Tags", m_exportHostTagsCheckBox->isChecked());
+ config.writeEntry("Strip Space Host Tags", m_stripSpaceTagsCheckBox->isChecked());
+ config.writeEntry("Public Sharing", m_publicCheckBox->isChecked());
+ config.writeEntry("Family Sharing", m_familyCheckBox->isChecked());
+ config.writeEntry("Friends Sharing", m_friendsCheckBox->isChecked());
+ saveDialogSize(config, QString("FlickrExport Dialog"));
+ config.sync();
+}
+
+void FlickrWindow::slotHelp()
+{
+ KApplication::kApplication()->invokeHelp("flickrexport", "kipi-plugins");
+}
+
+void FlickrWindow::slotDoLogin()
+{
+}
+
+void FlickrWindow::slotClose()
+{
+ writeSettings();
+ done(Close);
+}
+
+void FlickrWindow::slotTokenObtained(const QString& token)
+{
+ m_token = token;
+ m_username = m_talker->getUserName();
+ m_userId = m_talker->getUserId();
+ kdDebug() << "SlotTokenObtained invoked setting user Display name to " << m_username << endl;
+ m_userNameDisplayLabel->setText(QString("<qt><b>%1</b></qt>").arg(m_username));
+ m_widget->setEnabled(true);
+}
+
+void FlickrWindow::slotBusy(bool val)
+{
+ if (val)
+ {
+ setCursor(QCursor::WaitCursor);
+// m_newAlbumBtn->setEnabled( false );
+// m_addPhotoButton->setEnabled( false );
+ }
+ else
+ {
+ setCursor(QCursor::ArrowCursor);
+// m_newAlbumBtn->setEnabled( loggedIn );
+// m_addPhotoButton->setEnabled( loggedIn && m_albumView->selectedItem() );
+ }
+}
+
+void FlickrWindow::slotError(const QString& msg)
+{
+ //m_talker->slotError(msg);
+ KMessageBox::error( this, msg );
+}
+
+void FlickrWindow::slotUserChangeRequest()
+{
+ kdDebug() << "Slot Change User Request " << endl;
+ m_talker->getFrob();
+// m_addPhotoButton->setEnabled(m_selectImagesButton->isChecked());
+}
+
+/*
+void FlickrWindow::slotAlbums( const QValueList<GAlbum>& albumList )
+{
+ m_albumDict.clear();
+ m_tagView->clear();
+ //m_photoView->begin();
+ //m_photoView->write( "<html></html>" );
+ //m_photoView->end();
+
+ KIconLoader* iconLoader = KApplication::kApplication()->iconLoader();
+ QPixmap pix = iconLoader->loadIcon( "folder", KIcon::NoGroup, 32 );
+
+ typedef QValueList<GAlbum> GAlbumList;
+ GAlbumList::const_iterator iter;
+ for ( iter = albumList.begin(); iter != albumList.end(); ++iter )
+ {
+ const GAlbum& album = *iter;
+
+ if ( album.parent_ref_num == 0 )
+ {
+ GAlbumViewItem* item = new GAlbumViewItem( m_tagView, album.name,
+ album );
+ item->setPixmap( 0, pix );
+ m_albumDict.insert( album.ref_num, item );
+ }
+ else
+ {
+ QListViewItem* parent = m_albumDict.find( album.parent_ref_num );
+ if ( parent )
+ {
+ GAlbumViewItem* item = new GAlbumViewItem( parent, album.name,
+ album);
+ item->setPixmap( 0, pix );
+ m_albumDict.insert( album.ref_num, item );
+ }
+ else
+ {
+ kdWarning() << "Failed to find parent for album "
+ << album.name
+ << "with id " << album.ref_num;
+ }
+ }
+ }
+
+
+ // find and select the last selected album
+ int lastSelectedID = 0;
+ for ( iter = albumList.begin(); iter != albumList.end(); ++iter )
+ {
+ if ((*iter).name == m_lastSelectedAlbum)
+ {
+ lastSelectedID = (*iter).ref_num;
+ break;
+ }
+ }
+
+ if (lastSelectedID > 0)
+ {
+ GAlbumViewItem* lastSelectedItem = m_albumDict.find( lastSelectedID );
+ if (lastSelectedItem)
+ {
+ m_tagView->setSelected( lastSelectedItem, true );
+ m_tagView->ensureItemVisible( lastSelectedItem );
+ }
+ }
+}
+*/
+
+void FlickrWindow::slotAuthCancel()
+{
+ m_talker->cancel();
+ m_authProgressDlg->hide();
+}
+
+/*
+void FlickrWindow::slotPhotos( const QValueList<GPhoto>& photoList)
+{
+ // TODO
+}
+
+void FlickrWindow::slotTagSelected()
+{
+ // TODO
+}
+void FlickrWindow::slotOpenPhoto( const KURL& url )
+{
+ new KRun(url);
+}
+*/
+
+void FlickrWindow::slotListPhotoSetsResponse(const QValueList <FPhotoSet>& /*photoSetList*/)
+{
+ kdDebug() << "SlotListPhotoSetsResponse invoked" << endl;
+ // TODO
+}
+
+void FlickrWindow::slotNewPhotoSet()
+{
+ // TODO
+}
+
+/** This slot is call when 'Start Uploading' button is pressed.
+*/
+void FlickrWindow::slotUser1()
+{
+ kdDebug() << "SlotUploadImages invoked" << endl;
+
+ m_widget->m_tab->setCurrentPage(FlickrWidget::FILELIST);
+ KURL::List urls = m_imglst->imageUrls();
+
+ if (urls.isEmpty())
+ return;
+
+ typedef QPair<KURL, FPhotoInfo> Pair;
+
+ m_uploadQueue.clear();
+
+ for (KURL::List::iterator it = urls.begin(); it != urls.end(); ++it)
+ {
+ KIPI::ImageInfo info = m_interface->info(*it);
+ kdDebug() << "Adding images to the list" << endl;
+ FPhotoInfo temp;
+
+ temp.title = info.title();
+ temp.description = info.description();
+ temp.is_public = m_publicCheckBox->isChecked();
+ temp.is_family = m_familyCheckBox->isChecked();
+ temp.is_friend = m_friendsCheckBox->isChecked();
+ QStringList tagsFromDialog = QStringList::split(" ", m_tagsLineEdit->text(), false);
+
+ QStringList allTags;
+ QStringList::Iterator itTags;
+
+ // Tags from the dialog
+ itTags = tagsFromDialog.begin();
+ while(itTags != tagsFromDialog.end())
+ {
+ allTags.append(*itTags);
+ ++itTags;
+ }
+
+ // Tags from the database
+ QMap <QString, QVariant> attribs = info.attributes();
+ QStringList tagsFromDatabase;
+
+ if(m_exportHostTagsCheckBox->isChecked())
+ {
+ tagsFromDatabase = attribs["tags"].asStringList();
+ if (m_stripSpaceTagsCheckBox->isChecked())
+ {
+ for (QStringList::iterator it = tagsFromDatabase.begin(); it != tagsFromDatabase.end() ; ++it)
+ *it = (*it).stripWhiteSpace().remove(" ");
+ }
+ }
+
+ itTags = tagsFromDatabase.begin();
+
+ while(itTags != tagsFromDatabase.end())
+ {
+ allTags.append(*itTags);
+ ++itTags;
+ }
+
+ itTags = allTags.begin();
+
+ while(itTags != allTags.end())
+ {
+ kdDebug() << "Tags list: " << (*itTags) << endl;
+ ++itTags;
+ }
+
+ temp.tags = allTags;
+ m_uploadQueue.append(Pair(*it, temp));
+ }
+
+ m_uploadTotal = m_uploadQueue.count();
+ m_uploadCount = 0;
+ m_progressDlg->reset();
+ slotAddPhotoNext();
+ kdDebug() << "SlotUploadImages done" << endl;
+}
+
+void FlickrWindow::slotAddPhotoNext()
+{
+ if (m_uploadQueue.isEmpty())
+ {
+ m_progressDlg->reset();
+ m_progressDlg->hide();
+ //slotAlbumSelected();
+ return;
+ }
+
+ typedef QPair<KURL, FPhotoInfo> Pair;
+ Pair pathComments = m_uploadQueue.first();
+ FPhotoInfo info = pathComments.second;
+ bool res = m_talker->addPhoto(pathComments.first.path(), //the file path
+ info,
+ m_resizeCheckBox->isChecked(),
+ m_dimensionSpinBox->value(),
+ m_imageQualitySpinBox->value());
+ if (!res)
+ {
+ slotAddPhotoFailed("");
+ return;
+ }
+
+ m_progressDlg->setLabelText(i18n("Uploading file %1").arg(pathComments.first.filename()));
+
+ if (m_progressDlg->isHidden())
+ m_progressDlg->show();
+}
+
+void FlickrWindow::slotAddPhotoSucceeded()
+{
+ // Remove photo uploaded from the list
+ m_imglst->removeItemByUrl(m_uploadQueue.first().first);
+ m_uploadQueue.pop_front();
+ m_uploadCount++;
+ m_progressDlg->setProgress(m_uploadCount, m_uploadTotal);
+ slotAddPhotoNext();
+}
+
+void FlickrWindow::slotAddPhotoFailed(const QString& msg)
+{
+ if (KMessageBox::warningContinueCancel(this,
+ i18n("Failed to upload photo into Flickr. %1\nDo you want to continue?").arg(msg))
+ != KMessageBox::Continue)
+ {
+ m_uploadQueue.clear();
+ m_progressDlg->reset();
+ m_progressDlg->hide();
+ // refresh the thumbnails
+ //slotTagSelected();
+ }
+ else
+ {
+ m_uploadQueue.pop_front();
+ m_uploadTotal--;
+ m_progressDlg->setProgress(m_uploadCount, m_uploadTotal);
+ slotAddPhotoNext();
+ }
+}
+
+void FlickrWindow::slotAddPhotoCancel()
+{
+ m_uploadQueue.clear();
+ m_progressDlg->reset();
+ m_progressDlg->hide();
+
+ m_talker->cancel();
+
+ // refresh the thumbnails
+ //slotTagSelected();
+}
+
+void FlickrWindow::slotImageListChanged(bool state)
+{
+ enableButton(User1, !state);
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/flickrwindow.h b/kipi-plugins/flickrexport/flickrwindow.h
new file mode 100644
index 0000000..a87e9ee
--- /dev/null
+++ b/kipi-plugins/flickrexport/flickrwindow.h
@@ -0,0 +1,167 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-17-06
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef FLICKRWINDOW_H
+#define FLICKRWINDOW_H
+
+// Qt includes.
+
+#include <qvaluelist.h>
+#include <qpair.h>
+#include <qintdict.h>
+
+// KDE includes.
+
+#include <kdialogbase.h>
+
+// Libkipi includes.
+
+#include <libkipi/interface.h>
+#include <libkipi/imagedialog.h>
+
+// Local includes
+
+#include "kpaboutdata.h"
+
+class QPushButton;
+class QSpinBox;
+class QCheckBox;
+class QProgressDialog;
+
+class KLineEdit;
+class KHTMLPart;
+class KURL;
+
+namespace KIPI
+{
+class Interface;
+}
+
+namespace KWallet
+{
+class Wallet;
+}
+
+namespace KIPIFlickrExportPlugin
+{
+
+class FlickrWidget;
+class FlickrTalker;
+class FPhotoInfo;
+class FPhotoSet;
+class GPhoto;
+class GAlbum;
+class GAlbumViewItem;
+class ImagesList;
+
+class FlickrWindow : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+
+ FlickrWindow(KIPI::Interface *interface, const QString &tmpFolder, QWidget *parent);
+ ~FlickrWindow();
+
+private slots:
+
+ void slotTokenObtained(const QString& token);
+ void slotDoLogin();
+ void slotBusy(bool val);
+ void slotError(const QString& msg);
+
+// void slotLoginFailed( const QString& msg );
+// void slotAlbums( const QValueList<GAlbum>& albumList );
+// void slotPhotos( const QValueList<GPhoto>& photoList );
+// void slotTagSelected();
+// void slotOpenPhoto( const KURL& url );
+
+ void slotNewPhotoSet();
+ void slotUserChangeRequest();
+ void slotListPhotoSetsResponse(const QValueList <FPhotoSet>& photoSetList);
+ void slotAddPhotoNext();
+ void slotAddPhotoSucceeded();
+ void slotAddPhotoFailed(const QString& msg);
+ void slotAddPhotoCancel();
+ void slotAuthCancel();
+ void slotHelp();
+ void slotClose();
+ void slotUser1();
+ void slotImageListChanged(bool);
+
+private:
+
+ void readSettings();
+ void writeSettings();
+
+private:
+
+ unsigned int m_uploadCount;
+ unsigned int m_uploadTotal;
+
+// QPushButton *m_newAlbumBtn;
+ QPushButton *m_changeUserButton;
+
+ QCheckBox *m_resizeCheckBox;
+ QCheckBox *m_publicCheckBox;
+ QCheckBox *m_familyCheckBox;
+ QCheckBox *m_friendsCheckBox;
+ QCheckBox *m_exportHostTagsCheckBox;
+ QCheckBox *m_stripSpaceTagsCheckBox;
+
+ QSpinBox *m_dimensionSpinBox;
+ QSpinBox *m_imageQualitySpinBox;
+
+ QIntDict<GAlbumViewItem> m_albumDict;
+
+ QString m_token;
+ QString m_username;
+ QString m_userId;
+ QString m_lastSelectedAlbum;
+ QString m_tmp;
+
+ QLabel *m_userNameDisplayLabel;
+
+ QProgressDialog *m_progressDlg;
+ QProgressDialog *m_authProgressDlg;
+
+ QValueList< QPair<KURL, FPhotoInfo> > m_uploadQueue;
+
+// KWallet::Wallet *m_wallet;
+ KHTMLPart *m_photoView;
+
+ KLineEdit *m_tagsLineEdit;
+
+ FlickrWidget *m_widget;
+ FlickrTalker *m_talker;
+
+ ImagesList *m_imglst;
+
+ KIPI::Interface *m_interface;
+
+ KIPIPlugins::KPAboutData *m_about;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif /* FLICKRWINDOW_H */
diff --git a/kipi-plugins/flickrexport/imageslist.cpp b/kipi-plugins/flickrexport/imageslist.cpp
new file mode 100644
index 0000000..1127b40
--- /dev/null
+++ b/kipi-plugins/flickrexport/imageslist.cpp
@@ -0,0 +1,342 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2008-05-21
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#define ICONSIZE 64
+
+// QT includes.
+
+#include <qpushbutton.h>
+#include <qpainter.h>
+#include <qfileinfo.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+#include <qdragobject.h>
+#include <qimage.h>
+
+// KDE includes.
+
+#include <klocale.h>
+#include <kdialog.h>
+#include <knuminput.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+#include <kio/previewjob.h>
+
+// Libkipi includes.
+
+#include <libkipi/interface.h>
+#include <libkipi/imagedialog.h>
+#include <libkipi/imagecollection.h>
+
+// Local includes.
+
+#include "imageslist.h"
+#include "imageslist.moc"
+
+namespace KIPIFlickrExportPlugin
+{
+
+ImagesListViewItem::ImagesListViewItem(QListView *view, const KURL& url)
+ : QListViewItem(view)
+{
+ setThumb(SmallIcon("file_broken", ICONSIZE, KIcon::DisabledState));
+ setUrl(url);
+}
+
+ImagesListViewItem::~ImagesListViewItem()
+{
+}
+
+void ImagesListViewItem::setUrl(const KURL& url)
+{
+ m_url = url;
+ setText(1, m_url.fileName());
+}
+
+KURL ImagesListViewItem::url() const
+{
+ return m_url;
+}
+
+void ImagesListViewItem::setThumb(const QPixmap& pix)
+{
+ QPixmap pixmap(ICONSIZE+2, ICONSIZE+2);
+ pixmap.fill(Qt::color0);
+ QPainter p(&pixmap);
+ p.drawPixmap((pixmap.width()/2) - (pix.width()/2), (pixmap.height()/2) - (pix.height()/2), pix);
+ setPixmap(0, pixmap);
+}
+
+// ---------------------------------------------------------------------------
+
+ImagesListView::ImagesListView(QWidget *parent)
+ : QListView(parent)
+{
+ addColumn(i18n("Thumbnail"));
+ addColumn(i18n("File Name"));
+ QWhatsThis::add(this, i18n("<p>This is the list of images to upload on your Flickr account."));
+ setAcceptDrops(true);
+ setResizeMode(QListView::AllColumns);
+ setAllColumnsShowFocus(true);
+ setSorting(-1);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ setSelectionMode(QListView::Extended);
+}
+
+ImagesListView::~ImagesListView()
+{
+}
+
+void ImagesListView::dragEnterEvent(QDragEnterEvent *e)
+{
+ e->accept(QUriDrag::canDecode(e));
+}
+
+void ImagesListView::dropEvent(QDropEvent *e)
+{
+ QStrList strList;
+ KURL::List urls;
+
+ if (!QUriDrag::decode(e, strList))
+ return;
+
+ QStrList stringList;
+ QStrListIterator it(strList);
+ char *str;
+
+ while ((str = it.current()) != 0)
+ {
+ QString filePath = QUriDrag::uriToLocalFile(str);
+ QFileInfo fileInfo(filePath);
+
+ if (fileInfo.isFile() && fileInfo.exists())
+ urls.append(fileInfo.filePath());
+
+ ++it;
+ }
+
+ if (!urls.isEmpty())
+ emit signalDropedItems(urls);
+}
+
+// ---------------------------------------------------------------------------
+
+class ImagesPagePriv
+{
+public:
+
+ ImagesPagePriv()
+ {
+ listView = 0;
+ addButton = 0;
+ removeButton = 0;
+ iface = 0;
+ }
+
+ QPushButton *addButton;
+ QPushButton *removeButton;
+
+ ImagesListView *listView;
+
+ KIPI::Interface *iface;
+};
+
+ImagesList::ImagesList(QWidget* parent, KIPI::Interface *iface)
+ : QWidget(parent)
+{
+ d = new ImagesPagePriv;
+ d->iface = iface;
+
+ // --------------------------------------------------------
+
+ QGridLayout* grid = new QGridLayout(this, 2, 3);
+ d->listView = new ImagesListView(this);
+
+ // --------------------------------------------------------
+
+ d->addButton = new QPushButton(this);
+ d->removeButton = new QPushButton(this);
+ d->addButton->setText(i18n("&Add"));
+ d->addButton->setIconSet(SmallIcon("add"));
+ d->removeButton->setText(i18n("&Remove"));
+ d->removeButton->setIconSet(SmallIcon("remove"));
+
+ // --------------------------------------------------------
+
+ grid->addMultiCellWidget(d->listView, 0, 2, 0, 2);
+ grid->addMultiCellWidget(d->addButton, 0, 0, 3, 3);
+ grid->addMultiCellWidget(d->removeButton, 1, 1, 3, 3);
+ grid->setColStretch(0, 10);
+ grid->setRowStretch(2, 10);
+ grid->setMargin(KDialog::spacingHint());
+ grid->setSpacing(KDialog::spacingHint());
+
+ // --------------------------------------------------------
+
+ connect(d->addButton, SIGNAL(clicked()),
+ this, SLOT(slotAddItems()));
+
+ connect(d->removeButton, SIGNAL(clicked()),
+ this, SLOT(slotRemoveItems()));
+
+ connect(d->listView, SIGNAL(signalDropedItems(const KURL::List&)),
+ this, SLOT(slotAddImages(const KURL::List&)));
+
+ // --------------------------------------------------------
+
+ KIPI::ImageCollection images = d->iface->currentSelection();
+
+ if (images.isValid())
+ slotAddImages(images.images());
+}
+
+ImagesList::~ImagesList()
+{
+ delete d;
+}
+
+void ImagesList::slotAddImages(const KURL::List& list)
+{
+ if (list.count() == 0) return;
+
+ KURL::List urls;
+
+ for(KURL::List::const_iterator it = list.begin(); it != list.end(); ++it)
+ {
+ KURL imageUrl = *it;
+
+ // Check if the new item already exist in the list.
+
+ bool find = false;
+
+ QListViewItemIterator it(d->listView);
+ while (it.current())
+ {
+ ImagesListViewItem* item = dynamic_cast<ImagesListViewItem*>(*it);
+
+ if (item->url() == imageUrl)
+ find = true;
+
+ ++it;
+ }
+
+ if (!find)
+ {
+ new ImagesListViewItem(d->listView, imageUrl);
+ urls.append(imageUrl);
+ }
+ }
+
+ emit signalImageListChanged(imageUrls().isEmpty());
+
+ KIO::PreviewJob *thumbnailJob = KIO::filePreview(urls, ICONSIZE);
+
+ connect(thumbnailJob, SIGNAL(gotPreview(const KFileItem*, const QPixmap&)),
+ this, SLOT(slotGotThumbnail(const KFileItem*, const QPixmap&)));
+}
+
+void ImagesList::slotGotThumbnail(const KFileItem *item, const QPixmap& pix)
+{
+ QListViewItemIterator it(d->listView);
+
+ while (it.current())
+ {
+ ImagesListViewItem *selItem = dynamic_cast<ImagesListViewItem*>(*it);
+ if (selItem->url() == item->url())
+ {
+ selItem->setPixmap(0, pix);
+ }
+ ++it;
+ }
+}
+
+void ImagesList::slotAddItems()
+{
+ KURL::List urls = KIPI::ImageDialog::getImageURLs(this, d->iface);
+ if (!urls.isEmpty())
+ slotAddImages(urls);
+
+ emit signalImageListChanged(imageUrls().isEmpty());
+}
+
+void ImagesList::slotRemoveItems()
+{
+ bool find;
+ do
+ {
+ find = false;
+ QListViewItemIterator it(d->listView);
+ while (it.current())
+ {
+ ImagesListViewItem* item = dynamic_cast<ImagesListViewItem*>(*it);
+ if (item->isSelected())
+ {
+ delete item;
+ find = true;
+ break;
+ }
+ ++it;
+ }
+ }
+ while(find);
+
+ emit signalImageListChanged(imageUrls().isEmpty());
+}
+
+void ImagesList::removeItemByUrl(const KURL& url)
+{
+ bool find;
+ do
+ {
+ find = false;
+ QListViewItemIterator it(d->listView);
+ while (it.current())
+ {
+ ImagesListViewItem* item = dynamic_cast<ImagesListViewItem*>(*it);
+ if (item->url() == url)
+ {
+ delete item;
+ find = true;
+ break;
+ }
+ ++it;
+ }
+ }
+ while(find);
+
+ emit signalImageListChanged(imageUrls().isEmpty());
+}
+
+KURL::List ImagesList::imageUrls() const
+{
+ KURL::List list;
+ QListViewItemIterator it(d->listView);
+ while (it.current())
+ {
+ ImagesListViewItem* item = dynamic_cast<ImagesListViewItem*>(*it);
+ list.append(item->url());
+ ++it;
+ }
+ return list;
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/imageslist.h b/kipi-plugins/flickrexport/imageslist.h
new file mode 100644
index 0000000..66363e8
--- /dev/null
+++ b/kipi-plugins/flickrexport/imageslist.h
@@ -0,0 +1,122 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2008-05-21
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef IMAGES_LIST_H
+#define IMAGES_LIST_H
+
+// Qt includes.
+
+#include <qlistview.h>
+#include <qwidget.h>
+#include <qpixmap.h>
+
+// KDE includes.
+
+#include <kurl.h>
+
+class KFileItem;
+
+namespace KIPI
+{
+ class Interface;
+}
+
+namespace KIPIFlickrExportPlugin
+{
+
+class ImagesPagePriv;
+
+class ImagesListViewItem : public QListViewItem
+{
+
+public:
+
+ ImagesListViewItem(QListView *view, const KURL& url);
+ ~ImagesListViewItem();
+
+ void setUrl(const KURL& url);
+ KURL url() const;
+
+ void setThumb(const QPixmap& pix);
+
+private:
+
+ KURL m_url;
+};
+
+// ---------------------------------------------------------
+
+class ImagesListView : public QListView
+{
+ Q_OBJECT
+
+public:
+
+ ImagesListView(QWidget *parent);
+ ~ImagesListView();
+
+signals:
+
+ void signalDropedItems(const KURL::List&);
+
+private:
+
+ void dragEnterEvent(QDragEnterEvent *e);
+ void dropEvent(QDropEvent *e);
+};
+
+// ---------------------------------------------------------
+
+class ImagesList : public QWidget
+{
+ Q_OBJECT
+
+public:
+
+ ImagesList(QWidget* parent, KIPI::Interface *iface);
+ ~ImagesList();
+
+ KURL::List imageUrls() const;
+ void removeItemByUrl(const KURL& url);
+
+signals:
+
+ void signalImageListChanged(bool);
+
+public slots:
+
+ void slotAddImages(const KURL::List& list);
+
+private slots:
+
+ void slotAddItems();
+ void slotRemoveItems();
+ void slotGotThumbnail(const KFileItem *item, const QPixmap& pix);
+
+private:
+
+ ImagesPagePriv *d;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif // IMAGES_LIST_H
diff --git a/kipi-plugins/flickrexport/kipiplugin_flickrexport.desktop b/kipi-plugins/flickrexport/kipiplugin_flickrexport.desktop
new file mode 100644
index 0000000..f76ba1a
--- /dev/null
+++ b/kipi-plugins/flickrexport/kipiplugin_flickrexport.desktop
@@ -0,0 +1,55 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=Flickr Exporter
+Name[br]=Ezporzher Flickr
+Name[ca]=Exportador a Flickr
+Name[cs]=Export do Flickru
+Name[de]=Flickr-Export
+Name[el]=Εξαγωγέας Flickr
+Name[es]=Exportador Flickr
+Name[et]=Flickri eksport
+Name[fi]=Flicr-vienti
+Name[ga]=Easpórtálaí Flickr
+Name[gl]=Exportazón a Flickr
+Name[is]=Flickr Útflutningur
+Name[it]=Esportazione a Flickr
+Name[nds]=Flickr-Exporteren
+Name[pa]=ਫਲਿਕਰ ਨਿਰਯਾਤਕ
+Name[pl]=Eksporter Flickr
+Name[pt]=Exportação para o Flickr
+Name[sr]=Flickr извозник
+Name[sr@Latn]=Flickr izvoznik
+Name[sv]=Export till Flickr
+Name[tg]=Воридкунандаи ларзиши акс
+Name[xx]=xxFlickr Exporterxx
+Name[zh_CN]=Flickr 导出器
+Comment=KIPI Remote Flickr Export Plugin
+Comment[ca]=Connector del KIPI per exportar remotament al Flickr
+Comment[cs]=KIPI modul exportu do Flickru
+Comment[da]=KIPI Eksternt Flickr eksport plugin
+Comment[de]=Ein KIPI-Modul zum Exportieren von Bildern zu Flickr
+Comment[el]=Πρόσθετο απομακρυσμένης εξαγωγής Flickr του KIPI
+Comment[es]=Complemento de KIPI para exportación Flickr remota
+Comment[et]=KIPI Flickri ekspordiplugin
+Comment[fi]=Kipi-liitännäinen Flicr-vientiä varten
+Comment[fr]=Module externe KIPI pour exporter des images vers le site Flickr
+Comment[gl]=Plugin de KIPI para Exportar a un Flickr Remoto
+Comment[is]=KIPI íforrit til útflutnings á fjarlæga Flickr þjóna
+Comment[it]=Plugin per l'esportazione remota a Flickr di KIPI
+Comment[ja]=Kipi Flickr エクスポートプラグイン
+Comment[nds]=KIPI-Moduul för't Exporteren na Flickr
+Comment[nl]=KIPI-plugin voor het exporteren naar Flickr-galerij
+Comment[pa]=KIPI ਰਿਮੋਟ ਫਲਿਕਰ ਨਿਰਯਾਤ ਪਲੱਗਇਨ
+Comment[pl]=Wtyczka KIPI - Eksport do usługi sieciowej Flickr
+Comment[pt]='Plugin' do KIPI de Exportação para o Flickr Remoto
+Comment[pt_BR]=Plugin de Exportação Remota para o Flickr do KIPI
+Comment[sr]=KIPI прикључак за извоз у удаљени Flickr
+Comment[sr@Latn]=KIPI priključak za izvoz u udaljeni Flickr
+Comment[sv]=KIPI-insticksprogram för fjärrexport till Flickr
+Comment[tg]=Модули воридкунандаи ларзиши акси дурдастаи KIPI
+Comment[xx]=xxKIPI Remote Flickr Export Pluginxx
+Comment[zh_CN]=KIPI 远程 Flickr 导出插件
+Type=Service
+ServiceTypes=KIPI/Plugin
+X-KDE-Library=kipiplugin_flickrexport
+author=Vardhman Jain, vardhman@gmail.com
diff --git a/kipi-plugins/flickrexport/login.cpp b/kipi-plugins/flickrexport/login.cpp
new file mode 100644
index 0000000..3f58188
--- /dev/null
+++ b/kipi-plugins/flickrexport/login.cpp
@@ -0,0 +1,123 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// Qt includes.
+
+#include <qlabel.h>
+#include <qframe.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+
+// KDE includes.
+
+#include <klocale.h>
+
+// Local includes.
+
+#include "login.h"
+#include "login.moc"
+
+namespace KIPIFlickrExportPlugin
+{
+
+FlickrLogin::FlickrLogin(QWidget* parent, const QString& header,
+ const QString& _name, const QString& _passwd)
+ : QDialog(parent)
+{
+ setSizeGripEnabled(false);
+
+ QVBoxLayout* vbox = new QVBoxLayout(this, 5, 5, "vbox");
+ m_headerLabel = new QLabel(this);
+ m_headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ m_headerLabel->setText(header);
+
+ QFrame* hline = new QFrame(this, "hline");
+ hline->setFrameShape(QFrame::HLine);
+ hline->setFrameShadow(QFrame::Sunken);
+
+ QGridLayout* centerLayout = new QGridLayout(0, 1, 1, 5, 5);
+
+ m_nameEdit = new QLineEdit(this);
+ m_passwdEdit = new QLineEdit(this);
+ m_passwdEdit->setEchoMode(QLineEdit::Password);
+
+ QLabel* nameLabel = new QLabel(this);
+ nameLabel->setText(i18n("Username:"));
+
+ QLabel* passwdLabel = new QLabel(this);
+ passwdLabel->setText(i18n("Password:"));
+
+ centerLayout->addWidget(m_nameEdit, 0, 1);
+ centerLayout->addWidget(m_passwdEdit, 1, 1);
+ centerLayout->addWidget(nameLabel, 0, 0);
+ centerLayout->addWidget(passwdLabel, 1, 0);
+
+ QHBoxLayout* btnLayout = new QHBoxLayout(0, 0, 5);
+ btnLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
+
+ QPushButton *okBtn = new QPushButton(this);
+ okBtn->setAutoDefault(true);
+ okBtn->setDefault(true);
+ okBtn->setText(i18n("&OK"));
+
+ QPushButton *cancelBtn = new QPushButton(this);
+ cancelBtn->setText(i18n("&Cancel"));
+
+ btnLayout->addWidget( okBtn );
+ btnLayout->addWidget( cancelBtn );
+
+ vbox->addWidget(m_headerLabel);
+ vbox->addWidget(hline);
+ vbox->addLayout(centerLayout);
+ vbox->addLayout(btnLayout);
+
+ resize( QSize(300, 150).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ m_nameEdit->setText(_name);
+ m_passwdEdit->setText(_passwd);
+
+ // ---------------------------------------------------------------
+
+ connect(okBtn, SIGNAL( clicked() ),
+ this, SLOT( accept() ));
+
+ connect(cancelBtn, SIGNAL( clicked() ),
+ this, SLOT( reject() ));
+}
+
+FlickrLogin::~FlickrLogin()
+{
+}
+
+QString FlickrLogin::name() const
+{
+ return m_nameEdit->text();
+}
+
+QString FlickrLogin::password() const
+{
+ return m_passwdEdit->text();
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/login.h b/kipi-plugins/flickrexport/login.h
new file mode 100644
index 0000000..84dbaad
--- /dev/null
+++ b/kipi-plugins/flickrexport/login.h
@@ -0,0 +1,59 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef FLICKRLOGIN_H
+#define FLICKRLOGIN_H
+
+// Qt includes.
+
+#include <qdialog.h>
+
+class QLabel;
+class QLineEdit;
+
+namespace KIPIFlickrExportPlugin
+{
+
+class FlickrLogin : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ FlickrLogin(QWidget* parent, const QString& header,
+ const QString& _name=QString(),
+ const QString& _passwd=QString());
+ ~FlickrLogin();
+
+ QString name() const;
+ QString password() const;
+
+private:
+
+ QLabel *m_headerLabel;
+ QLineEdit *m_nameEdit;
+ QLineEdit *m_passwdEdit;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif // FLICKRLOGIN_H
diff --git a/kipi-plugins/flickrexport/mpform.cpp b/kipi-plugins/flickrexport/mpform.cpp
new file mode 100644
index 0000000..462b0e4
--- /dev/null
+++ b/kipi-plugins/flickrexport/mpform.cpp
@@ -0,0 +1,163 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// C++ includes.
+
+#include <cstring>
+#include <cstdio>
+
+// Qt includes.
+
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qtextstream.h>
+
+// KDE includes.
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <kmimetype.h>
+#include <kurl.h>
+
+// Local includes.
+
+#include "mpform.h"
+
+namespace KIPIFlickrExportPlugin
+{
+
+MPForm::MPForm()
+{
+ m_boundary = "----------";
+ m_boundary += KApplication::randomString(42 + 13).ascii();
+}
+
+MPForm::~MPForm()
+{
+}
+
+void MPForm::reset()
+{
+ m_buffer.resize(0);
+}
+
+void MPForm::finish()
+{
+ QCString str;
+ str += "--";
+ str += m_boundary;
+ str += "--";
+
+ QTextStream ts(m_buffer, IO_Append|IO_WriteOnly);
+ ts.setEncoding(QTextStream::UnicodeUTF8);
+ ts << str;
+}
+
+bool MPForm::addPair(const QString& name, const QString& value)
+{
+ QCString str;
+
+ str += "--";
+ str += m_boundary;
+ str += "\r\n";
+ str += "Content-Disposition: form-data; name=\"";
+ str += name.ascii();
+ str += "\"";
+ str += "\r\n\r\n";
+ str += value.utf8();
+ str += "\r\n";
+
+ //uint oldSize = m_buffer.size();
+ //m_buffer.resize(oldSize + str.size());
+ //memcpy(m_buffer.data() + oldSize, str.data(), str.size());
+
+ QTextStream ts(m_buffer, IO_Append|IO_WriteOnly);
+ ts.setEncoding(QTextStream::UnicodeUTF8);
+ ts << QString::fromUtf8(str);
+
+ return true;
+}
+
+bool MPForm::addFile(const QString& name,const QString& path)
+{
+ KMimeType::Ptr ptr = KMimeType::findByURL(path);
+ QString mime = ptr->name();
+ if (mime.isEmpty())
+ {
+ // if we ourselves can't determine the mime of the local file,
+ // very unlikely the remote site will be able to identify it
+ return false;
+ }
+
+ QFile imageFile(path);
+ if (!imageFile.open(IO_ReadOnly))
+ return false;
+
+ QByteArray imageData = imageFile.readAll();
+ imageFile.close();
+
+ QCString str;
+
+ str += "--";
+ str += m_boundary;
+ str += "\r\n";
+ str += "Content-Disposition: form-data; name=\"";
+ str += name.ascii();
+ str += "\"; ";
+ str += "filename=\"";
+ str += QFile::encodeName(KURL(path).filename());
+ str += "\"";
+ str += "\r\n";
+ str += "Content-Type: ";
+ str += mime.ascii();
+ str += "\r\n\r\n";
+
+ QTextStream ts(m_buffer, IO_Append|IO_WriteOnly);
+ ts.setEncoding(QTextStream::UnicodeUTF8);
+ ts << str;
+
+ int oldSize = m_buffer.size();
+ m_buffer.resize(oldSize + imageData.size() + 2);
+ memcpy(m_buffer.data() + oldSize, imageData.data(), imageData.size());
+ m_buffer[m_buffer.size()-2] = '\r';
+ m_buffer[m_buffer.size()-1] = '\n';
+
+ return true;
+}
+
+QString MPForm::contentType() const
+{
+ return QString("Content-Type: multipart/form-data; boundary=" + m_boundary);
+}
+
+QString MPForm::boundary() const
+{
+ return m_boundary;
+}
+
+QByteArray MPForm::formData() const
+{
+ return m_buffer;
+}
+
+} // namespace KIPIFlickrExportPlugin
diff --git a/kipi-plugins/flickrexport/mpform.h b/kipi-plugins/flickrexport/mpform.h
new file mode 100644
index 0000000..89d958d
--- /dev/null
+++ b/kipi-plugins/flickrexport/mpform.h
@@ -0,0 +1,61 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-07-07
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ * Copyright (C) 2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef MPFORM_H
+#define MPFORM_H
+
+// Qt includes.
+
+#include <qcstring.h>
+#include <qstring.h>
+
+namespace KIPIFlickrExportPlugin
+{
+
+class MPForm
+{
+
+public:
+
+ MPForm();
+ ~MPForm();
+
+ void finish();
+ void reset();
+
+ bool addPair(const QString& name, const QString& value);
+ bool addFile(const QString& name, const QString& path);
+
+ QString contentType() const;
+ QByteArray formData() const;
+ QString boundary() const;
+
+private:
+
+ QByteArray m_buffer;
+ QCString m_boundary;
+};
+
+} // namespace KIPIFlickrExportPlugin
+
+#endif /* MPFORM_H */
diff --git a/kipi-plugins/flickrexport/plugin_flickrexport.cpp b/kipi-plugins/flickrexport/plugin_flickrexport.cpp
new file mode 100644
index 0000000..101aaae
--- /dev/null
+++ b/kipi-plugins/flickrexport/plugin_flickrexport.cpp
@@ -0,0 +1,114 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-17-06
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// C ansi includes.
+
+extern "C"
+{
+#include <unistd.h>
+}
+
+// KDE includes.
+
+#include <klocale.h>
+#include <kaction.h>
+#include <kgenericfactory.h>
+#include <klibloader.h>
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kapplication.h>
+#include <kstandarddirs.h>
+
+// libkipi includes.
+
+#include <libkipi/interface.h>
+
+// Local includes.
+
+#include "flickrwindow.h"
+#include "plugin_flickrexport.h"
+#include "plugin_flickrexport.moc"
+
+typedef KGenericFactory<Plugin_FlickrExport> Factory;
+
+K_EXPORT_COMPONENT_FACTORY(kipiplugin_flickrexport, Factory("kipiplugin_flickrexport"))
+
+Plugin_FlickrExport::Plugin_FlickrExport(QObject *parent, const char*, const QStringList&)
+ : KIPI::Plugin(Factory::instance(), parent, "FlickrExport")
+{
+ kdDebug(51001) << "Plugin_FlickrExport plugin loaded" << endl;
+}
+
+void Plugin_FlickrExport::setup(QWidget* widget)
+{
+ KIPI::Plugin::setup(widget);
+
+ m_action = new KAction(i18n("Export to Flickr..."),
+ "www",
+ 0,
+ this,
+ SLOT(slotActivate()),
+ actionCollection(),
+ "flickrexport");
+
+ KIPI::Interface* interface = dynamic_cast<KIPI::Interface*>(parent());
+
+ if (!interface)
+ {
+ kdError( 51000 ) << "Kipi interface is null!" << endl;
+ m_action->setEnabled(false);
+ return;
+ }
+
+ m_action->setEnabled(true);
+ addAction(m_action);
+}
+
+Plugin_FlickrExport::~Plugin_FlickrExport()
+{
+}
+
+void Plugin_FlickrExport::slotActivate()
+{
+ KIPI::Interface* interface = dynamic_cast<KIPI::Interface*>(parent());
+ if (!interface)
+ {
+ kdError( 51000 ) << "Kipi interface is null!" << endl;
+ return;
+ }
+
+ KStandardDirs dir;
+ QString Tmp = dir.saveLocation("tmp", "kipi-flickrexportplugin-" + QString::number(getpid()) + "/");
+
+ // We clean it up in the close button
+ m_dlg = new KIPIFlickrExportPlugin::FlickrWindow(interface, Tmp, kapp->activeWindow());
+ m_dlg->show();
+}
+
+KIPI::Category Plugin_FlickrExport::category( KAction* action ) const
+{
+ if (action == m_action)
+ return KIPI::EXPORTPLUGIN;
+
+ kdWarning(51000) << "Unrecognized action for plugin category identification" << endl;
+ return KIPI::EXPORTPLUGIN;
+}
diff --git a/kipi-plugins/flickrexport/plugin_flickrexport.h b/kipi-plugins/flickrexport/plugin_flickrexport.h
new file mode 100644
index 0000000..282686d
--- /dev/null
+++ b/kipi-plugins/flickrexport/plugin_flickrexport.h
@@ -0,0 +1,56 @@
+/* ============================================================
+ *
+ * This file is a part of kipi-plugins project
+ * http://www.kipi-plugins.org
+ *
+ * Date : 2005-17-06
+ * Description : a kipi plugin to export images to Flickr web service
+ *
+ * Copyright (C) 2005-2008 by Vardhman Jain <vardhman at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#ifndef PLUGIN_FLICKREXPORT_H
+#define PLUGIN_FLICKREXPORT_H
+
+// libKIPI includes.
+
+#include <libkipi/plugin.h>
+
+class KAction;
+
+using namespace KIPIFlickrExportPlugin;
+
+class Plugin_FlickrExport : public KIPI::Plugin
+{
+ Q_OBJECT
+
+public:
+
+ Plugin_FlickrExport(QObject *parent, const char* name, const QStringList &args);
+ ~Plugin_FlickrExport();
+
+ virtual KIPI::Category category(KAction* action) const;
+ virtual void setup(QWidget*);
+
+public slots:
+
+ void slotActivate();
+
+private:
+
+ KAction *m_action;
+ FlickrWindow *m_dlg;
+};
+
+#endif // PLUGIN_FLICKREXPORT_H