[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/graphics/kipi-plugins/fbexport
From: Luka Renko <lure () kubuntu ! org>
Date: 2008-12-30 18:06:37
Message-ID: 1230660397.095534.26470.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 903509 by lure:
Added support for photo caption: Facebook does not read Exif/XMP/IPTC,
so we extract it and send it via API
M +0 -2 TODO
M +5 -1 fbtalker.cpp
M +2 -1 fbtalker.h
M +53 -4 fbwindow.cpp
M +6 -1 fbwindow.h
--- trunk/extragear/graphics/kipi-plugins/fbexport/TODO #903508:903509
@@ -1,8 +1,6 @@
Facebook export plugin
----------------------------------------------------------------------------
Short term:
-- add support for caption
-- retain sessionKey until it expires (no need to relogin for multiple runs)
- add extended permission support (at least as button to link to following URL):
http://www.facebook.com/authorize.php?api_key=bf430ad869b88aba5c0c17ea6707022b&v=1.0&ext_perm=photo_upload
--- trunk/extragear/graphics/kipi-plugins/fbexport/fbtalker.cpp #903508:903509
@@ -430,7 +430,9 @@
m_buffer.resize(0);
}
-bool FbTalker::addPhoto(const QString& imgPath, long long albumID)
+bool FbTalker::addPhoto(const QString& imgPath,
+ long long albumID,
+ const QString& caption)
{
if (m_job)
{
@@ -448,6 +450,8 @@
args["name"] = KUrl(imgPath).fileName();
if (albumID != -1)
args["aid"] = QString::number(albumID);
+ if (!caption.isEmpty())
+ args["caption"] = caption;
args["sig"] = getApiSig(args);
MPForm form;
--- trunk/extragear/graphics/kipi-plugins/fbexport/fbtalker.h #903508:903509
@@ -63,7 +63,8 @@
void createAlbum(const FbAlbum& album);
- bool addPhoto(const QString& imgPath, long long albumID);
+ bool addPhoto(const QString& imgPath, long long albumID,
+ const QString& caption);
public:
QProgressDialog *m_authProgressDlg; // TODO: move to method?
--- trunk/extragear/graphics/kipi-plugins/fbexport/fbwindow.cpp #903508:903509
@@ -374,8 +374,47 @@
kDebug(51000) << "slotStartUpload done";
}
-bool FbWindow::prepareImageForUpload(const QString& imgPath, bool isRAW)
+QString FbWindow::getImageCaption(const KExiv2Iface::KExiv2& ev)
{
+ QString caption = ev.getCommentsDecoded();
+ if (!caption.isEmpty())
+ return caption;
+
+ if (ev.hasExif())
+ {
+ caption = ev.getExifComment();
+ if (!caption.isEmpty())
+ return caption;
+ }
+
+ if (ev.hasXmp())
+ {
+ caption = ev.getXmpTagStringLangAlt("Xmp.dc.description", QString(), false);
+ if (!caption.isEmpty())
+ return caption;
+
+ caption = ev.getXmpTagStringLangAlt("Xmp.exif.UserComment", QString(), \
false); + if (!caption.isEmpty())
+ return caption;
+
+ caption = ev.getXmpTagStringLangAlt("Xmp.tiff.ImageDescription", QString(), \
false); + if (!caption.isEmpty())
+ return caption;
+}
+
+ if (ev.hasIptc())
+ {
+ caption = ev.getIptcTagString("Iptc.Application2.Caption", false);
+ if (!caption.isEmpty() && !caption.trimmed().isEmpty())
+ return caption;
+ }
+
+ return caption;
+}
+
+bool FbWindow::prepareImageForUpload(const QString& imgPath, bool isRAW,
+ QString &caption)
+{
QImage image;
if (isRAW)
{
@@ -407,10 +446,14 @@
KExiv2Iface::KExiv2 exiv2Iface;
if (exiv2Iface.load(imgPath))
{
+ caption = getImageCaption(exiv2Iface);
exiv2Iface.setImageDimensions(image.size());
exiv2Iface.setImageProgramId("Kipi-plugins", kipiplugins_version);
exiv2Iface.save(m_tmpPath);
}
+ else
+ caption.clear();
+
return true;
}
@@ -431,21 +474,27 @@
QString rawFilesExt(KDcrawIface::KDcraw::rawFiles());
#endif
QFileInfo fileInfo(imgPath);
+ QString caption;
bool isRAW = rawFilesExt.toUpper().contains(fileInfo.suffix().toUpper());
bool res;
if (isRAW || m_widget->m_resizeChB->isChecked())
{
- if (!prepareImageForUpload(imgPath, isRAW))
+ if (!prepareImageForUpload(imgPath, isRAW, caption))
{
slotAddPhotoDone(666, i18n("Cannot open file"));
return;
}
- res = m_talker->addPhoto(m_tmpPath, m_currentAlbumID);
+ res = m_talker->addPhoto(m_tmpPath, m_currentAlbumID, caption);
}
else
{
+ KExiv2Iface::KExiv2 exiv2Iface;
+ if (exiv2Iface.load(imgPath))
+ caption = getImageCaption(exiv2Iface);
+ else
+ caption.clear();
m_tmpPath.clear();
- res = m_talker->addPhoto(imgPath, m_currentAlbumID);
+ res = m_talker->addPhoto(imgPath, m_currentAlbumID, caption);
}
if (!res)
{
--- trunk/extragear/graphics/kipi-plugins/fbexport/fbwindow.h #903508:903509
@@ -34,6 +34,9 @@
// LibKIPI includes.
#include <libkipi/interface.h>
+// LibKExiv2 includes.
+#include <libkexiv2/kexiv2.h>
+
class QProgressDialog;
class KUrl;
@@ -86,7 +89,9 @@
void slotImageListChanged(bool);
private:
- bool prepareImageForUpload(const QString& imgPath, bool isRAW);
+ QString getImageCaption(const KExiv2Iface::KExiv2& ev);
+ bool prepareImageForUpload(const QString& imgPath, bool isRAW,
+ QString& caption);
void uploadNextPhoto();
void readSettings();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic