Changeset 4874 for extensions/digikam_export/piwigoexport
- Timestamp:
- Feb 10, 2010, 10:18:02 PM (14 years ago)
- Location:
- extensions/digikam_export/piwigoexport
- Files:
-
- 4 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/digikam_export/piwigoexport/CMakeLists.txt
r4770 r4874 3 3 SET(kipiplugin_piwigoexport_PART_SRCS 4 4 plugin_piwigoexport.cpp 5 albumdlg.cpp6 5 piwigos.cpp 7 6 piwigoconfig.cpp … … 9 8 piwigotalker.cpp 10 9 ) 11 12 KDE4_ADD_UI_FILES(kipiplugin_piwigoexport_PART_SRCS piwigoalbumwidget.ui)13 10 14 11 KDE4_ADD_PLUGIN(kipiplugin_piwigoexport ${kipiplugin_piwigoexport_PART_SRCS}) -
extensions/digikam_export/piwigoexport/piwigoitem.h
r4770 r4874 35 35 { 36 36 37 class GPhoto38 {39 public:40 41 GPhoto() {42 ref_num = -1;43 }44 45 int ref_num;46 int album_num;47 48 QString name;49 QString caption;50 QString thumbName;51 QString albumURL;52 };53 54 // ------------------------------------------------------------------------55 56 37 class GAlbum 57 38 { … … 70 51 } 71 52 72 // permissions73 53 int ref_num; // album reference number 74 54 int parent_ref_num; // parent's album reference number 75 55 76 QString name; // ? 77 /*QString parentName; // ? 78 QString title; // album title*/ 79 //QString summary; // album summary 56 QString name; // Album name 80 57 QString baseurl; // album partial (gallery) URL 81 58 }; 82 59 83 //category id="3" nb_images="80" total_nb_images="80" date_last="2010-01-03 22:06:29" max_date_last="2010-01-03 22:06:29" nb_categories="0" url="http://fcoiffie.free.fr/piwigo-2.0.7/index.php?/category/3"84 60 } // namespace KIPIPiwigoExportPlugin 85 61 -
extensions/digikam_export/piwigoexport/piwigos.cpp
r4770 r4874 71 71 } 72 72 73 unsigned int Piwigo::galleryId() const74 {75 return mPiwigoId;76 }77 78 73 // ------------------------------------- 79 74 … … 96 91 { 97 92 mPassword = password; 98 }99 100 void Piwigo::setPiwigoId(unsigned int galleryId)101 {102 mPiwigoId = galleryId;103 93 } 104 94 -
extensions/digikam_export/piwigoexport/piwigos.h
r4770 r4874 52 52 QString username() const; 53 53 QString password() const; 54 unsigned int version() const;55 unsigned int galleryId() const;56 54 57 55 void setName(const QString& name); … … 59 57 void setUsername(const QString& username); 60 58 void setPassword(const QString& password); 61 void setPiwigoId(unsigned int galleryId);62 59 63 60 public: … … 70 67 71 68 private: 72 73 unsigned int mPiwigoId;74 69 75 70 QString mName; -
extensions/digikam_export/piwigoexport/piwigotalker.cpp
r4770 r4874 28 28 #include "piwigotalker.moc" 29 29 30 // C++ includes31 32 #include <cstring>33 #include <cstdio>34 35 30 // Qt includes 36 31 … … 72 67 : m_parent(parent), m_job(0), m_loggedIn(false) 73 68 { 74 kDebug() << "BEGIN\n";75 69 } 76 70 … … 143 137 m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" ); 144 138 m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken ); 145 /* m_job->addMetaData("cookies", "manual");146 m_job->addMetaData("setcookies", m_cookie);*/147 139 148 140 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), … … 153 145 154 146 emit signalBusy(true); 155 }156 157 void PiwigoTalker::listPhotos(const QString& albumName)158 {159 m_job = 0;160 m_state = GE_LISTPHOTOS;161 m_talker_buffer.resize(0);162 #if 0163 PiwigoMPForm form;164 form.addPair("cmd", "fetch-album-images");165 form.addPair("protocol_version", "2.11");166 form.addPair("set_albumName", albumName);167 form.finish();168 169 m_job = KIO::http_post(m_url, form.formData(), KIO::HideProgressInfo);170 m_job->addMetaData("content-type", form.contentType());171 m_job->addMetaData("cookies", "manual");172 m_job->addMetaData("setcookies", m_cookie);173 174 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),175 this, SLOT(slotTalkerData(KIO::Job*, const QByteArray&)));176 177 connect(m_job, SIGNAL(result(KJob *)),178 this, SLOT(slotResult(KJob *)));179 180 emit signalBusy(true);181 #endif182 }183 184 void PiwigoTalker::createAlbum(const QString& parentAlbumName,185 const QString& albumName,186 const QString& albumTitle,187 const QString& albumCaption)188 {189 m_job = 0;190 m_state = GE_CREATEALBUM;191 m_talker_buffer.resize(0);192 #if 0193 PiwigoMPForm form;194 form.addPair("cmd", "new-album");195 form.addPair("protocol_version", "2.11");196 form.addPair("set_albumName", parentAlbumName);197 198 if (!albumName.isEmpty())199 form.addPair("newAlbumName", albumName);200 201 if (!albumTitle.isEmpty())202 form.addPair("newAlbumTitle", albumTitle);203 204 if (!albumCaption.isEmpty())205 form.addPair("newAlbumDesc", albumCaption);206 207 form.finish();208 209 m_job = KIO::http_post(m_url, form.formData(), KIO::HideProgressInfo);210 m_job->addMetaData("content-type", form.contentType());211 m_job->addMetaData("cookies", "manual");212 m_job->addMetaData("setcookies", m_cookie);213 214 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)),215 this, SLOT(slotTalkerData(KIO::Job*, const QByteArray&)));216 217 connect(m_job, SIGNAL(result(KJob*)),218 this, SLOT(slotResult(KJob*)));219 220 emit signalBusy(true);221 #endif222 147 } 223 148 … … 269 194 270 195 // Complete name and comment for summary sending 271 m_comment = m_name = KUrl(photoPath).fileName();196 m_comment = m_name = caption; 272 197 m_date = fi.created(); 273 198 … … 301 226 buffer.append(dataParameters.toUtf8()); 302 227 303 //kDebug() << "Request " << m_url << buffer << "\n";304 305 228 m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo); 306 229 m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" ); 307 230 m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken ); 308 /* m_job->addMetaData("cookies", "manual");309 m_job->addMetaData("setcookies", m_cookie);*/310 231 311 232 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), … … 336 257 m_talker_buffer.resize(oldSize + data.size()); 337 258 memcpy(m_talker_buffer.data() + oldSize, data.data(), data.size()); 338 339 kDebug() << data;340 259 } 341 260 … … 349 268 kDebug() << tempjob->errorString(); 350 269 } else { 351 if (m_state == GE_CHECKPHOTOEXIST || m_state == GE_ADDPHOTO ) {270 if (m_state == GE_CHECKPHOTOEXIST || m_state == GE_ADDPHOTO || m_state == GE_ADDTHUMB || m_state == GE_ADDPHOTOSUMMARY) { 352 271 emit signalAddPhotoFailed(tempjob->errorString()); 353 272 } else { … … 366 285 case(GE_LISTALBUMS): 367 286 parseResponseListAlbums(m_talker_buffer); 368 break;369 case(GE_LISTPHOTOS):370 parseResponseListPhotos(m_talker_buffer);371 break;372 case(GE_CREATEALBUM):373 parseResponseCreateAlbum(m_talker_buffer);374 287 break; 375 288 case(GE_CHECKPHOTOEXIST): … … 391 304 392 305 if (m_state == GE_LOGIN && m_loggedIn) { 393 /*394 const QStringList cookielist = (tempjob->queryMetaData("setcookies")).split('\n');395 m_cookie = "Cookie:";396 397 398 if(!cookielist.isEmpty())399 {400 QRegExp rx("^PIWIGOSID=.+");401 QString app;402 foreach(const QString &str, cookielist)403 {404 if(str.contains("Set-Cookie: "))405 {406 const QStringList cl = str.split(' ');407 int n = cl.lastIndexOf(rx);408 if(n!= -1)409 {410 app = cl.at(n);411 }412 }413 }414 m_cookie += app;415 }416 */417 306 listAlbums(); 418 307 } … … 427 316 bool foundResponse = false; 428 317 m_loggedIn = false; 318 319 kDebug() << "parseResponseLogin: " << QString(data); 429 320 430 321 while (!ts.atEnd()) { … … 461 352 GAlbumList::iterator iter = albumList.begin(); 462 353 463 kDebug() << QString(data);354 kDebug() << "parseResponseListAlbums: " << QString(data); 464 355 465 356 while (!ts.atEnd()) { … … 517 408 } 518 409 519 void PiwigoTalker::parseResponseListPhotos(const QByteArray &data)520 {521 QString str = QString::fromUtf8(data);522 QTextStream ts(&str, QIODevice::ReadOnly);523 QString line;524 bool foundResponse = false;525 bool success = false;526 527 typedef QList<GPhoto> GPhotoList;528 GPhotoList photoList;529 GPhotoList::iterator iter = photoList.begin();530 531 QString albumURL;532 533 while (!ts.atEnd()) {534 line = ts.readLine();535 536 if (!foundResponse) {537 foundResponse = line.startsWith(QLatin1String(("#__GR2PROTO__")));538 } else {539 QStringList strlist = line.split('=');540 if (strlist.count() == 2) {541 QString key = strlist[0];542 QString value = strlist[1];543 544 if (key == "status") {545 success = (value == "0");546 } else if (key.startsWith(QLatin1String(("image.name")))) {547 GPhoto photo;548 photo.name = value;549 photo.ref_num = key.section('.', 2, 2).toInt();550 iter = photoList.insert(iter, photo);551 } else if (key.startsWith(QLatin1String(("image.caption")))) {552 (*iter).caption = value;553 } else if (key.startsWith(QLatin1String(("image.thumbName")))) {554 (*iter).thumbName = value;555 } else if (key.startsWith(QLatin1String(("baseurl")))) {556 albumURL = value.replace("\\", ""); // doesn't compile fixing EBN Krazy issue!!557 }558 }559 }560 }561 562 if (!foundResponse) {563 emit signalError(i18n("Invalid response received from remote Piwigo"));564 return;565 }566 567 if (!success) {568 emit signalError(i18n("Failed to list photos"));569 return;570 }571 572 emit signalPhotos(photoList);573 }574 575 void PiwigoTalker::parseResponseCreateAlbum(const QByteArray& data)576 {577 QString str = QString::fromUtf8(data);578 QTextStream ts(&str, QIODevice::ReadOnly);579 QString line;580 bool foundResponse = false;581 bool success = false;582 583 while (!ts.atEnd()) {584 line = ts.readLine();585 586 if (!foundResponse) {587 foundResponse = line.startsWith(QLatin1String(("#__GR2PROTO__")));588 } else {589 QStringList strlist = line.split('=');590 if (strlist.count() == 2) {591 QString key = strlist[0];592 QString value = strlist[1];593 if (key == "status") { // key == "status" NOT FOUND!!!594 success = (value == "0");595 kWarning() << "Create Album. success: " << success ;596 } else if (key.startsWith(QLatin1String(("status_text")))) {597 kDebug() << "STATUS: Create Album: " << value ;598 }599 }600 }601 }602 603 if (!foundResponse) {604 emit signalError(i18n("Invalid response received from remote Piwigo"));605 return;606 }607 608 if (!success) {609 emit signalError(i18n("Failed to create new album"));610 return;611 }612 613 listAlbums();614 }615 616 410 void PiwigoTalker::parseResponseDoesPhotoExist(const QByteArray& data) 617 411 { … … 622 416 bool success = false; 623 417 624 // typedef QList<GAlbum> GAlbumList; 625 // GAlbumList albumList; 626 // GAlbumList::iterator iter = albumList.begin(); 627 628 kDebug() << QString(data); 418 kDebug() << "parseResponseDoesPhotoExist: " << QString(data); 629 419 630 420 while (!ts.atEnd()) { … … 667 457 imagefile.close(); 668 458 669 //kDebug() << "Request " << m_url << buffer << "\n";670 671 459 m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo); 672 460 m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" ); 673 461 m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken ); 674 /* m_job->addMetaData("cookies", "manual");675 m_job->addMetaData("setcookies", m_cookie);*/676 462 677 463 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), … … 680 466 connect(m_job, SIGNAL(result(KJob *)), 681 467 this, SLOT(slotResult(KJob *))); 682 683 #if 0684 QString str = QString::fromUtf8(data);685 QTextStream ts(&str, QIODevice::ReadOnly);686 QString line;687 bool foundResponse = false;688 bool success = false;689 690 while (!ts.atEnd()) {691 line = ts.readLine();692 693 if (!foundResponse) {694 // Piwigo1 sends resizing debug code sometimes so we695 // have to detect things slightly differently696 foundResponse = (line.startsWith(QLatin1String(("#__GR2PROTO__")))697 || (line.startsWith(QLatin1String(("<br>- Resizing")))698 && line.endsWith(QLatin1String(("#__GR2PROTO__")))));699 } else {700 QStringList strlist = line.split('=');701 if (strlist.count() == 2) {702 QString key = strlist[0];703 QString value = strlist[1];704 705 if (key == "status") {706 success = (value == "0");707 kWarning() << "Add photo. success: " << success ;708 } else if (key.startsWith(QLatin1String(("status_text")))) {709 kDebug() << "STATUS: Add Photo: " << value ;710 }711 }712 }713 }714 715 if (!foundResponse) {716 emit signalAddPhotoFailed(i18n("Invalid response received from remote Piwigo"));717 return;718 }719 720 if (!success) {721 emit signalAddPhotoFailed(i18n("Failed to upload photo"));722 } else {723 emit signalAddPhotoSucceeded();724 }725 #endif726 468 } 727 469 … … 735 477 bool success = false; 736 478 737 kDebug() << QString(data);479 kDebug() << "parseResponseAddPhoto: " << QString(data); 738 480 739 481 while (!ts.atEnd()) { … … 776 518 imagefile.close(); 777 519 778 //kDebug() << "Request " << m_url << buffer << "\n";779 780 520 m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo); 781 521 m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" ); 782 522 m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken ); 783 /* m_job->addMetaData("cookies", "manual");784 m_job->addMetaData("setcookies", m_cookie);*/785 523 786 524 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), … … 800 538 bool success = false; 801 539 802 kDebug() << QString(data);540 kDebug() << "parseResponseAddThumbnail: " << QString(data); 803 541 804 542 while (!ts.atEnd()) { … … 826 564 m_state = GE_ADDPHOTOSUMMARY; 827 565 828 //name=img_9738&author=Fr%E9d%E9ric+COIFFIER&categories=12&file_sum=8aa81afb8f15a5dbcf463e210e0cc6f2&thumbnail_sum=8d30dd047bd8d44ea099c461bd87ff7c&original_sum=278d66d52b278fbf531a4c7a74a0dd21&date_creation=2009%3A06%3A16&tag_ids=&comment=&mthod=pwg.images.add829 830 831 566 QFile imagefile(m_thumbpath); 832 567 imagefile.open(QIODevice::ReadOnly); … … 836 571 qsl.append("original_sum=" + m_md5sum.toHex()); 837 572 qsl.append("name=" + m_name.toUtf8().toPercentEncoding()); 838 qsl.append("author="); // TODO 573 qsl.append("author="); // TODO Retrieve author name from EXIF/IPTC tags 839 574 qsl.append("categories=" + QString::number(m_albumId)); 840 575 qsl.append("file_sum=" + computeMD5Sum(m_path).toHex()); 841 576 qsl.append("thumbnail_sum=" + computeMD5Sum(m_thumbpath).toHex()); 842 qsl.append("date_creation=" + m_date.toString("yyyy:MM:dd").toUtf8().toPercentEncoding()); // 2007%3A06%3A23577 qsl.append("date_creation=" + m_date.toString("yyyy:MM:dd").toUtf8().toPercentEncoding()); 843 578 qsl.append("tag_ids="); 844 579 qsl.append("comment=" + m_comment.toUtf8().toPercentEncoding()); … … 849 584 imagefile.close(); 850 585 851 kDebug() << "Request " << m_url << buffer << "\n";852 853 586 m_job = KIO::http_post(m_url, buffer, KIO::HideProgressInfo); 854 587 m_job->addMetaData("content-type", "Content-Type: application/x-www-form-urlencoded" ); 855 588 m_job->addMetaData("customHTTPHeader", "Authorization: " + s_authToken ); 856 /* m_job->addMetaData("cookies", "manual");857 m_job->addMetaData("setcookies", m_cookie);*/858 589 859 590 connect(m_job, SIGNAL(data(KIO::Job*, const QByteArray&)), … … 872 603 bool success = false; 873 604 874 kDebug() << QString(data);605 kDebug() << "parseResponseAddPhotoSummary: " << QString(data); 875 606 876 607 while (!ts.atEnd()) { … … 896 627 } 897 628 898 #if 0899 while (!ts.atEnd()) {900 line = ts.readLine();901 902 if (!foundResponse) {903 // Piwigo1 sends resizing debug code sometimes so we904 // have to detect things slightly differently905 foundResponse = (line.startsWith(QLatin1String(("#__GR2PROTO__")))906 || (line.startsWith(QLatin1String(("<br>- Resizing")))907 && line.endsWith(QLatin1String(("#__GR2PROTO__")))));908 } else {909 QStringList strlist = line.split('=');910 if (strlist.count() == 2) {911 QString key = strlist[0];912 QString value = strlist[1];913 914 if (key == "status") {915 success = (value == "0");916 kWarning() << "Add photo. success: " << success ;917 } else if (key.startsWith(QLatin1String(("status_text")))) {918 kDebug() << "STATUS: Add Photo: " << value ;919 }920 }921 }922 }923 #endif924 629 if (!foundResponse) { 925 630 emit signalAddPhotoFailed(i18n("Invalid response received from remote Piwigo")); 926 631 return; 927 632 } 633 634 if (m_path.size()) 635 QFile(m_path).remove(); 636 if (m_thumbpath.size()) 637 QFile(m_thumbpath).remove(); 638 639 m_path = ""; 640 m_thumbpath = ""; 928 641 929 642 if (!success) { -
extensions/digikam_export/piwigoexport/piwigotalker.h
r4770 r4874 65 65 GE_LOGIN = 0, 66 66 GE_LISTALBUMS, 67 GE_LISTPHOTOS,68 GE_CREATEALBUM,69 67 GE_CHECKPHOTOEXIST, 70 68 GE_ADDPHOTO, … … 97 95 const QString& caption = QString(), 98 96 bool captionIsTitle = true, bool captionIsDescription = false, 99 bool rescale = false, int maxDim = 600, int thumbDim = 12 0);97 bool rescale = false, int maxDim = 600, int thumbDim = 128); 100 98 101 99 void cancel(); … … 107 105 void signalBusy(bool val); 108 106 void signalAlbums(const QList<GAlbum>& albumList); 109 void signalPhotos(const QList<GPhoto>& photoList);110 107 void signalAddPhotoSucceeded(); 111 108 void signalAddPhotoFailed(const QString& msg); … … 115 112 void parseResponseLogin(const QByteArray& data); 116 113 void parseResponseListAlbums(const QByteArray& data); 117 void parseResponseListPhotos(const QByteArray& data);118 void parseResponseCreateAlbum(const QByteArray& data);119 114 void parseResponseDoesPhotoExist(const QByteArray& data); 120 115 void parseResponseAddPhoto(const QByteArray& data); -
extensions/digikam_export/piwigoexport/piwigowindow.cpp
r4770 r4874 39 39 #include <QTreeWidgetItem> 40 40 #include <QPointer> 41 #include <QHBoxLayout> 42 #include <QVBoxLayout> 41 43 42 44 // KDE includes … … 63 65 // Local includes 64 66 65 #include "albumdlg.h"66 67 #include "piwigos.h" 67 68 #include "piwigoconfig.h" … … 84 85 QTreeWidget* albumView; 85 86 86 QPushButton* newAlbumBtn;87 87 QPushButton* addPhotoBtn; 88 88 … … 111 111 logo = new KUrlLabel; 112 112 logo->setText(QString()); 113 logo->setUrl("http://piwigo. menalto.com");113 logo->setUrl("http://piwigo.org"); 114 114 logo->setPixmap(QPixmap(KStandardDirs::locate("data", "kipiplugin_piwigoexport/pics/piwigo_logo.png"))); 115 115 logo->setAlignment(Qt::AlignLeft); … … 119 119 albumView = new QTreeWidget; 120 120 QStringList labels; 121 labels << i18n("Albums"); // << i18n("ID");121 labels << i18n("Albums"); 122 122 albumView->setHeaderLabels(labels); 123 123 … … 126 126 QFrame *optionFrame = new QFrame; 127 127 QVBoxLayout *vlay = new QVBoxLayout(); 128 129 newAlbumBtn = new QPushButton;130 newAlbumBtn->setText(i18n("&New Album"));131 newAlbumBtn->setIcon(KIcon("folder-new"));132 newAlbumBtn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);133 newAlbumBtn->setEnabled(false);134 128 135 129 addPhotoBtn = new QPushButton; … … 163 157 thumbDimensionSpinBox = new QSpinBox; 164 158 thumbDimensionSpinBox->setRange(32,800); 165 thumbDimensionSpinBox->setValue(12 0);159 thumbDimensionSpinBox->setValue(128); 166 160 167 161 captTitleCheckBox->setChecked(true); … … 199 193 // --------------------------------------------------------------------------- 200 194 201 vlay->addWidget(newAlbumBtn);202 195 vlay->addWidget(addPhotoBtn); 203 196 vlay->addWidget(optionsBox); … … 226 219 d(new Private(this)) 227 220 { 228 kDebug() << "BEGIN Window\n";229 230 231 221 setWindowTitle( i18n("Piwigo Export") ); 232 222 setButtons( KDialog::Close | KDialog::User1 | KDialog::Help); … … 310 300 group.writeEntry("Set description", d->captDescrCheckBox->isChecked()); 311 301 group.writeEntry("Maximum Width", d->dimensionSpinBox->value()); 302 group.writeEntry("Thumbnail Width", d->thumbDimensionSpinBox->value()); 312 303 313 304 delete m_talker; … … 324 315 this , SLOT( slotAlbumSelected() ) ); 325 316 326 connect(d->newAlbumBtn, SIGNAL(clicked()),327 this, SLOT(slotNewAlbum()));328 329 317 connect(d->addPhotoBtn, SIGNAL(clicked()), 330 318 this, SLOT(slotAddPhoto())); … … 350 338 connect(m_talker, SIGNAL(signalAlbums(const QList<GAlbum>&)), 351 339 this, SLOT(slotAlbums(const QList<GAlbum>&))); 352 353 connect(m_talker, SIGNAL(signalPhotos(const QList<GPhoto>&)),354 this, SLOT(slotPhotos(const QList<GPhoto>&)));355 340 356 341 connect(m_talker, SIGNAL(signalAddPhotoSucceeded()), … … 391 376 d->captDescrCheckBox->setChecked(false); 392 377 378 379 d->thumbDimensionSpinBox->setValue(group.readEntry("Thumbnail Width", 128)); 393 380 } 394 381 … … 443 430 if (val) { 444 431 setCursor(Qt::WaitCursor); 445 d->newAlbumBtn->setEnabled(false);446 432 d->addPhotoBtn->setEnabled(false); 447 433 } else { 448 434 setCursor(Qt::ArrowCursor); 449 435 bool loggedIn = m_talker->loggedIn(); 450 // TODO Enable the button to implement the feature451 //d->newAlbumBtn->setEnabled(loggedIn);452 436 d->addPhotoBtn->setEnabled(loggedIn && d->albumView->currentItem()); 453 437 } … … 492 476 int i = 0; 493 477 494 kDebug() << "Parent : " << parentRefNum << "\n";495 496 478 while ( !found && i < parentItemList.size() ) { 497 479 parentItem = parentItemList.at(i); 498 499 kDebug() << "User : " << parentItem->data(1, Qt::UserRole).toInt() << "\n";500 480 501 481 if (parentItem && (parentItem->data(1, Qt::UserRole).toInt() == parentRefNum)) { … … 505 485 item->setData(1, Qt::UserRole, album.ref_num ); 506 486 item->setText(2, i18n("Album") ); 507 508 kDebug() << "Child : " << album.name << " " << album.ref_num << "\n";509 487 510 488 parentItem->addChild(item); … … 515 493 i++; 516 494 } 517 518 /*if (!found && i == parentItemList.size() )519 {520 workList.append(album);521 }*/522 495 } 523 496 } 524 497 } 525 498 526 // FIXME: avoid duplications527 void PiwigoWindow::slotPhotos(const QList<GPhoto>& photoList)528 {529 QTreeWidgetItem* parentItem = d->albumView->currentItem();530 531 typedef QList<GPhoto> GPhotoList;532 GPhotoList::const_iterator iterator;533 for (iterator = photoList.begin(); iterator != photoList.end(); ++iterator) {534 QString plain = (*iterator).caption;535 QTreeWidgetItem *item = new QTreeWidgetItem(parentItem);536 item->setText(0, cleanName(plain) );537 item->setIcon(0, KIcon("image-x-generic") );538 item->setText(1, (*iterator).name);539 item->setText(2, i18n("Image") );540 }541 }542 543 499 void PiwigoWindow::slotAlbumSelected() 544 500 { 545 501 QTreeWidgetItem* item = d->albumView->currentItem(); 546 547 kDebug() << "slotAlbumSelected\n";548 502 549 503 // stop loading if user clicked an image 550 504 if ( item->text(2) == i18n("Image") ) 551 505 return; 552 553 kDebug() << "Album\n";554 506 555 507 if (!item) { … … 562 514 if (m_talker->loggedIn() && albumId ) { 563 515 d->addPhotoBtn->setEnabled(true); 564 //m_talker->listPhotos(albumName);565 516 } else { 566 517 d->addPhotoBtn->setEnabled(false); … … 569 520 } 570 521 571 void PiwigoWindow::slot NewAlbum()572 { 573 QPointer<AlbumDlg> dlg = new AlbumDlg(d->widget);574 dlg->titleEdit->setFocus(); 575 if ( dlg->exec() != QDialog::Accepted) {576 delete dlg;522 void PiwigoWindow::slotAddPhoto() 523 { 524 KUrl::List *urls = new KUrl::List(m_interface->currentSelection().images()); 525 526 if (urls == NULL || urls->isEmpty()) { 527 KMessageBox::error(this, i18n("Nothing to upload - please select photos to upload.")); 577 528 return; 578 529 } 579 530 580 QString name = dlg->nameEdit->text(); 581 QString title = dlg->titleEdit->text(); 582 QString caption = dlg->captionEdit->text(); 583 584 delete dlg; 585 586 // check for prohibited chars in the album name 587 // \ / * ? " ' & < > | . + # ( ) or spaces 588 // TODO: Change this to a QRegExp check. 589 QChar ch; 590 bool clean = true; 591 592 for (int i = 0; i < name.length(); ++i) { 593 ch = name[i]; 594 if (ch == '\\') { 595 clean = false; 596 break; 597 } else if (ch == '/') { 598 clean = false; 599 break; 600 } else if (ch == '*') { 601 clean = false; 602 break; 603 } else if (ch == '?') { 604 clean = false; 605 break; 606 } else if (ch == '"') { 607 clean = false; 608 break; 609 } else if (ch == '\'') { 610 clean = false; 611 break; 612 } else if (ch == '&') { 613 clean = false; 614 break; 615 } else if (ch == '<') { 616 clean = false; 617 break; 618 } else if (ch == '>') { 619 clean = false; 620 break; 621 } else if (ch == '|') { 622 clean = false; 623 break; 624 } else if (ch == '.') { 625 clean = false; 626 break; 627 } else if (ch == '+') { 628 clean = false; 629 break; 630 } else if (ch == '#') { 631 clean = false; 632 break; 633 } else if (ch == '(') { 634 clean = false; 635 break; 636 } else if (ch == ')') { 637 clean = false; 638 break; 639 } 640 /* 641 else if (ch == ' ') 642 { 643 clean = false; 644 break; 645 } 646 */ 647 } 648 649 if (!clean) { 650 KMessageBox::error(this, i18n("Sorry, these characters are not allowed in album name: \\ / * ? \" \' & < > | . + # ( ) or spaces")); 651 return; 652 } 653 654 QString parentAlbumName; 655 656 QTreeWidgetItem* item = d->albumView->currentItem(); 657 int column = d->albumView->currentColumn(); 658 if (item) { 659 const GAlbum& album = d->albumDict.value( item->text(column) ); 660 parentAlbumName = album.name; 661 m_talker->createAlbum( parentAlbumName, name, title, caption); 662 } else { 663 m_talker->createAlbum( firstAlbumName, name, title, caption ); 664 } 665 } 666 667 void PiwigoWindow::slotAddPhoto() 668 { 669 #if 0 670 QTreeWidgetItem* item = d->albumView->currentItem(); 671 int column = d->albumView->currentColumn(); 672 if (!item) 673 return; // NO album selected: FIXME: do something 674 675 // albumName 676 QString albumTitle = item->text(column); 677 if (!d->albumDict.contains(albumTitle)) 678 return; // NO album name found: FIXME: do something 679 680 // photoPath 681 KUrl::List urls = KIPIPlugins::ImageDialog::getImageUrls(this, m_interface); 682 if (urls.isEmpty()) 683 return; // NO photo selected: FIXME: do something 684 685 for (KUrl::List::iterator it = urls.begin(); it != urls.end(); ++it) { 531 for (KUrl::List::iterator it = urls->begin(); it != urls->end(); ++it) { 686 532 mpUploadList->append( (*it).path() ); 687 533 } … … 692 538 m_uploadCount = 0; 693 539 slotAddPhotoNext(); 694 #endif695 KUrl::List *urls = new KUrl::List(m_interface->currentSelection().images());696 697 if (urls == NULL || urls->isEmpty()) {698 KMessageBox::error(this, i18n("Nothing to upload - please select photos to upload."));699 return;700 }701 702 for (KUrl::List::iterator it = urls->begin(); it != urls->end(); ++it) {703 mpUploadList->append( (*it).path() );704 }705 706 m_uploadTotal = mpUploadList->count();707 m_progressDlg->reset();708 m_progressDlg->setMaximum(m_uploadTotal);709 m_uploadCount = 0;710 slotAddPhotoNext();711 540 } 712 541 … … 716 545 m_progressDlg->reset(); 717 546 m_progressDlg->hide(); 718 //slotAlbumSelected(); // ?719 547 return; 720 548 } -
extensions/digikam_export/piwigoexport/piwigowindow.h
r4770 r4874 80 80 void slotError(const QString& msg); 81 81 void slotAlbums(const QList<GAlbum>& albumList); 82 void slotPhotos(const QList<GPhoto>& photoList);83 82 void slotAlbumSelected(); 84 // void slotOpenPhoto(const KUrl& url); // DISABLED for NOW!85 void slotNewAlbum();86 83 void slotAddPhoto(); 87 84 void slotAddPhotoNext(); -
extensions/digikam_export/piwigoexport/plugin_piwigoexport.cpp
r4770 r4874 125 125 if (action == m_action) 126 126 return KIPI::ExportPlugin; 127 // if (action == m_action_configure) 128 // return KIPI::ToolsPlugin; 129 // 127 130 128 kWarning() << "Unrecognized action for plugin category identification"; 131 129 return KIPI::ExportPlugin;
Note: See TracChangeset
for help on using the changeset viewer.