Bug 142259 - Export fails
Summary: Export fails
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-WebService-Piwigo (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-27 11:03 UTC by Martin Kaufmann
Modified: 2023-02-25 08:23 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.1.0


Attachments
Patch for authToken bug in Gallery Remote application (1.95 KB, patch)
2007-03-01 03:05 UTC, Martin Kaufmann
Details
wireshark (aka ethereal) pdump file (10.37 KB, application/octet-stream)
2007-04-17 00:38 UTC, Malte Cornils
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Kaufmann 2007-02-27 11:03:36 UTC
Version:           0.1.4 (using KDE KDE 3.5.5)
Installed from:    Compiled From Sources
OS:                Linux

Hi!

Initially, I've used digikam 0.8 with kipi 0.1.2 (the packages that came with Kubuntu Edgy) to upload  photos to Gallery 2.1 which worked fine. After updating to G2.2-RC-1, the export stopped working. I can still log in to the gallery but when I try to create a new album or add photos, I always get the error message "Invalid response received from remote Gallery". I since updated digikam and kipi to 0.9.1-rc1 and 0.1.4 respectively but I still get the same error message. Is there a way of accessing more information about this error? 

Could this problem be related to the bug described in report 137582 (http://bugs.kde.org/show_bug.cgi?id=137582)?

Cheers,

Martin
Comment 1 Colin Guthrie 2007-02-27 12:08:15 UTC
Chances are it is related to bug 137582 as I implemented it blind as I had no time to actually get a gallery installed and test it and I wanted it in final.

If you are a good coder please feel free to fiddle and post a patch, but if not I'll look at this as soon as I can. I'm off on holiday for a week soon tho', so if you are desperate, then I'd suggest you have a poke yourself. I'll try to get something to you if I find time before I go tho'.

Col
Comment 2 Martin Kaufmann 2007-02-28 21:58:30 UTC
I've actually managed to fix the bug (it was more a bug in the Gallery Remote implementation -- see http://sourceforge.net/mailarchive/message.php?msg_id=38073975). The authToken doesn't get sent the first time (right after the login process) but only the second time (after the directory listing). 

I've never submitted a patch before, so I might need some help there.

Martin
Comment 3 Colin Guthrie 2007-02-28 22:09:15 UTC
Wow, what great timing! I've just turned on my comp to take a look at this and here is your message :)

If you have made changes from an svn checkout, just run svn diff > patch.diff and post the file patch.diff.

If you made changes from the source tarball, then do the following:

1) Assuming you have the folder "kipi-plugins-0.1.x"; rename this folder to "b"
2) Extract a fresh copy of the kipi-plugins from the tarball and rename that folder to "a".
3) Run the command diff -ru a b >patch.diff and post the file patch.diff.

Hope that helps :) That said, it's probably more correct to fix the Gallery Remote implementation and give them the patch... :) Seeing as they've not gone to final yet and seeing as their implementation is wrong, it's maybe better to leave the kipi code as it is? WDYT?
Comment 4 Colin Guthrie 2007-02-28 22:42:01 UTC
If you are debugging, I'd imagine the bit of code you want to analyse at the PHP end is probably around line 202 of this file: http://gallery.svn.sourceforge.net/viewvc/gallery/trunk/gallery2/modules/remote/GalleryRemote.inc?revision=15513&view=markup

For whatever reason, perhaps $session->isPersistent() does not return true on first login connection to the server.

A few debug statements should confirm/disprove this.

Comment 5 Martin Kaufmann 2007-03-01 03:04:13 UTC
I guess you're right, it would be better to fix the bug in the Gallery Remote code. The problem is that I haven't got time right now (I'm off on holiday too...).

For the time being, I just attach the patch file here. In this patch file, I also changed the version number of the Gallery Remote protocol. Ideally, I think it would be better if this version number would actually be extracted from the server response.

Martin
Comment 6 Martin Kaufmann 2007-03-01 03:05:37 UTC
Created attachment 19853 [details]
Patch for authToken bug in Gallery Remote application
Comment 7 Colin Guthrie 2007-03-01 10:30:09 UTC
Thanks for that.

I'm not 100% sure about the protocol_version as I'll have to check the docs as to what that implies. If we just say we accept whatever protocol the server says it supports it could try throwing data at us that we can't actually handle.... I'll look into the various versions and see if we can accept the 2.11 tho'. :)

Thanks again.
Comment 8 Martin Kaufmann 2007-03-01 17:41:21 UTC
You're right about the version numbers. But as long as they don't break the backward compatibility of the Gallery Remote API, nothing much should happen. However, if we don't at least use version 2.10, we won't get the authToken at all.

Martin
Comment 9 kc 2007-03-21 00:04:56 UTC
Hi,

I am using Gallery 2.2, digikam 0.9.1 on KDE 3.5.6 with Kipi library 0.1.5 and my problem is, that I cannot create albums.

To be reproduced like this:
Menu: Album -> Export -> Remote Gallery Sync...
Choose an existing connection -> after the connection to Gallery has been established choose
"New ALbum" -> some (optional ???) parameters -> OK

the message "Failed to create new album" comes up.

I did not find another thread, this problem would fit, so I really hope someone may use this information to fix that bug.

Best regards kc
Comment 10 Colin Guthrie 2007-03-21 00:12:01 UTC
Yeah it's OK to post here as I'm the one who's gonna fix it anyway :)

I'll be upgrading to G2.2 v. soon, so hopefully a fix will be available soon. It will still require your distro to update their package with a patch tho' as I don't believe a kipi-plugins release is planned for some time... 
Comment 11 Martin Kaufmann 2007-03-21 08:53:08 UTC
Just to let you know: I installed G2.2 last week - and the kipi-plugin stopped working (my previously patched version). I haven't been able to fix this bug but all I know so far is the following: The login procedure is successful (as user admin) but afterwards - I think due to a problem with the cookies - the session is continued as user guest. I then get an error message about no being allowed to access the server.

I hope that helps locating the exact cause.

Cheers,

Martin
Comment 12 Colin Guthrie 2007-03-21 10:14:45 UTC
I upgraded my own Gallery last night too so I can now test this properly. Not sure when but I'll get a fix released sometime fairly soon (read within a week or two).

Cheers for your help guys.
Comment 13 Malte Cornils 2007-04-17 00:36:59 UTC
I have the same problem. I will attach a wireshark sniff log for the authentication process... so you can find out for yourself (all real except for the password, which I changed manually to garbage)
Comment 14 Malte Cornils 2007-04-17 00:38:38 UTC
Created attachment 20293 [details]
wireshark (aka ethereal) pdump file
Comment 15 Colin Guthrie 2007-04-18 02:50:13 UTC
SVN commit 655231 by cguthrie:

Fix login to Gallery 2.2.

This was a very annoying bug to track down but it essentially relates
to a bug in the generation of Cookies in Gallery 2.2.

Gallery actually generates 3 Set-Cookie headers in it's response which
seems excessive. The first one is a GALLERYSID=<blank> and the other
two set it to the correct value. The routine that parses cookies is
somewhat dumb and just passes any cookies it receives back to the
server on the next request. By passing the blank GALLERYSID, Gallery
ensured that it did not connect to your logged in session.

The cookie parsing code should be make more intellegent, but in the
mean time I've put in a very simple fix.

Testing and feedback appreciated.

This also applies the patch by Martin Kaufmann - thanks.
BUG: 142259

 M  +1 -1      gallerympform.cpp  
 M  +10 -6     gallerytalker.cpp  


--- trunk/extragear/libs/kipi-plugins/galleryexport/gallerympform.cpp #655230:655231
@@ -70,7 +70,7 @@
 
     QTextStream ts(m_buffer, IO_Append|IO_WriteOnly);
     ts.setEncoding(QTextStream::UnicodeUTF8);
-    ts << str;
+    ts << str << '\0';
 }
 
 bool GalleryMPForm::addPair(const QString& name, const QString& value)
--- trunk/extragear/libs/kipi-plugins/galleryexport/gallerytalker.cpp #655230:655231
@@ -72,7 +72,7 @@
     GalleryMPForm form;
 
     form.addPair("cmd",              "login");
-    form.addPair("protocol_version", "2.3");
+    form.addPair("protocol_version", "2.11");
     form.addPair("uname",            name);
     form.addPair("password",         passwd);
     form.finish();
@@ -100,7 +100,7 @@
       task = "fetch-albums-prune";
 
     form.addPair("cmd",              task);
-    form.addPair("protocol_version", "2.3");
+    form.addPair("protocol_version", "2.11");
     form.finish();
 
     KIO::TransferJob* job = KIO::http_post(m_url, form.formData(), false);
@@ -129,7 +129,7 @@
     GalleryMPForm form;
 
     form.addPair("cmd",              "fetch-album-images");
-    form.addPair("protocol_version", "2.3");
+    form.addPair("protocol_version", "2.11");
     form.addPair("set_albumName",    albumName);
     form.finish();
 
@@ -162,7 +162,7 @@
     GalleryMPForm form;
 
     form.addPair("cmd", "new-album");
-    form.addPair("protocol_version", "2.3");
+    form.addPair("protocol_version", "2.11");
     form.addPair("set_albumName", parentAlbumName);
     if (!albumName.isEmpty())
         form.addPair("newAlbumName", albumName);
@@ -204,7 +204,7 @@
     GalleryMPForm form;
 
     form.addPair("cmd", "add-item");
-    form.addPair("protocol_version", "2.3");
+    form.addPair("protocol_version", "2.11");
     form.addPair("set_albumName", albumName);
 
     if (!caption.isEmpty())
@@ -318,7 +318,7 @@
         m_cookie = "Cookie:";
         for (QStringList::Iterator it = cookielist.begin(); it != cookielist.end(); ++it)
         {
-            QRegExp rx("^Set-Cookie: ([^;]+)");
+            QRegExp rx("^Set-Cookie: ([^;]+=[^;]+)");
             if (rx.search(*it) > -1)
                 m_cookie += " " + rx.cap(1) + ";";
         }
@@ -453,6 +453,10 @@
                     if (iter != albumList.end())
                         (*iter).create_sub = (value == "true");
                 }
+                else if (key == "auth_token")
+                {
+                  s_authToken = value;
+                }
             }
         }
     }
Comment 16 Gerhard Kulzer 2007-04-18 16:30:20 UTC
Am Wednesday 18 April 2007 schrieb Colin Guthrie:
> Fix login to Gallery 2.2.
>
> This was a very annoying bug to track down but it essentially relates
> to a bug in the generation of Cookies in Gallery 2.2.
>
> Gallery actually generates 3 Set-Cookie headers in it's response which
> seems excessive. The first one is a GALLERYSID=<blank> and the other
> two set it to the correct value. The routine that parses cookies is
> somewhat dumb and just passes any cookies it receives back to the
> server on the next request. By passing the blank GALLERYSID, Gallery
> ensured that it did not connect to your logged in session.
>
> The cookie parsing code should be make more intellegent, but in the
> mean time I've put in a very simple fix.
>
> Testing and feedback appreciated.
>
> This also applies the patch by Martin Kaufmann - thanks.
> BUG: 142259
>
> 
Comment 17 Colin Guthrie 2007-04-18 17:32:41 UTC
> Thanks very much Colin, it works again and faster than before.

Nice :)

> Question: I often use webdav to update gallery2.2 but it doesn't work
> consistantly. Do you have any plans of integrating an update function into
> the kipis? 

Not really sure what you mean here, but perhaps bug #143978 would solve it (the general concept seems to "solve" a lot of bugs/wishes.... just need to pull my finger out and get on with it!)
Comment 18 Gerhard Kulzer 2007-04-18 20:06:51 UTC
Am Wednesday 18 April 2007 schrieb Colin Guthrie:
> Not really sure what you mean here, but perhaps bug #143978 would solve it
> (the general concept seems to "solve" a lot of bugs/wishes.... just need to
> pull my finger out and get on with it!)


Yes, that covers it, I wrote a note to BKO

Gerhard
Comment 19 Ray Hendricks 2007-05-01 20:25:01 UTC
I'm running kipi-plugins-0.1.3+svn655000-3.1 on SUSE 10.2 but I can't get the gallery export to work (failed to create album).  I see the patch above but I don't know how to use it.  Is there an RPM?  Can someone tell me how to apply the fax if not?
Comment 20 Gerhard Kulzer 2007-05-02 08:27:52 UTC
Am Tuesday 01 May 2007 schrieb Ray Hendricks:
[bugs.kde.org quoted mail]

Don't know what you mean by 'fax', I guess it's supposed to mean 'patch'.
A patch is applied to sources which have to be compiled. You can skip patching 
and download the latest svn sources from here : 
http://www.kipi-plugins.org/drupal/?q=node/4, the installation instructions 
are on node/3

Hope that helps
Gerhard
Comment 21 johanneswilm 2007-05-05 22:31:34 UTC
Hi, I do not get the patch to work with Gallery 2.2.1 . Should the bug be reopened?
Comment 22 Colin Guthrie 2007-05-06 01:14:17 UTC
I tested it on 2.2.1 and it works for me....
Comment 23 Colin Guthrie 2007-05-22 00:29:45 UTC
*** Bug 145767 has been marked as a duplicate of this bug. ***