Bug 123141 - Manage several cookies
Summary: Manage several cookies
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-WebService-Piwigo (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-06 00:21 UTC by Boris Kavod
Modified: 2023-02-25 08:22 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.1.0


Attachments
Patch in order to kipi plugin manage several authentification cookies (1.58 KB, patch)
2006-03-06 00:22 UTC, Boris Kavod
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Kavod 2006-03-06 00:21:31 UTC
Version:           0.1.0-rc1 (using KDE KDE 3.5.1)
Installed from:    Compiled From Sources
Compiler:          gcc (GCC) 3.4.5 (Gentoo 3.4.5-r1, ssp-3.4.5-1.0, pie-8.7.9) -O3 -march=pentium4 -pipe
OS:                Linux

I have develop a website based on PHPBB (including user/session management).
In the website, I have develop a kind of gallery.

I would create a interface for the kipi plugin copying the Gallery2 interface in order to use digikam to upload my photos.
Unfortunatly, the Gallery authentification is based only on 1 cookie but PhpBB on 2 ones (phpbb_sid, phpbb_data). So the export does not work cause authentification.

I think that a multiple cookie compatibility in kipiplugin should be interresting in order to increase the gallery systems compatibility with kipiplugins.

So I have developed a correction to manage that (patch in the next comment).

NOTE: as I said, I have based my work on the Gallery **2** interface. So the use of the patch (I developed) joined on the 96352 bug is needed.

Hoping it can interest someone...
Comment 1 Boris Kavod 2006-03-06 00:22:45 UTC
Created attachment 14976 [details]
Patch in order to kipi plugin manage several authentification cookies

Here, the correction patch
Comment 2 Boris Kavod 2006-03-06 00:23:26 UTC
above patch should resolv change request.
Comment 3 Tom Albers 2006-03-06 00:35:32 UTC
keep it open untill applied to svn/rejected ;-)
Comment 4 Boris Kavod 2006-03-06 01:16:39 UTC
Sorry, I am newbee in the bug following projects :o)

I know that this functionnality has not a lot of interest for the first goal (ie. interation with Gallery) but I think it was a great thing if, in the future, the integration can expend to another gallery systems.

Waiting your point of view. 

At your disposition.
Comment 5 William Entriken 2006-03-19 04:34:30 UTC
I am currently developing a competitor to Gallery and a KIPI pluggin for it. My recommendation would be to either implement the Gallery API exactly, or to fork the Pluggin and make a couple changes.

In your case, I would imagine the simplest would be to create a proxy to handle this one cookie and trade in for two, essentially making a compatible system.
Comment 6 William Entriken 2006-03-19 04:35:28 UTC
OTOH, considering this patch as an enhancement, would there be any backwards compatibility issues?
Comment 7 Boris Kavod 2006-03-19 12:26:38 UTC
No backward compatibility (at least, considering what I saw). I am currently using the kipi plugins with this patch with both of Gallery and my PhpBB script. So it manages in the same way one or two (and normaly more) cookie(s).
Comment 8 Angelo Naselli 2006-06-03 16:09:18 UTC
Please Col can you check this and the patch they provide?
Comment 9 Colin Guthrie 2006-06-04 12:45:48 UTC
SVN commit 547984 by cguthrie:

Add support for multiple cookies by commiting a slightly modified patch. Tested on G1/G2 for a single cookie environment. Please reopen if my variation on the patch in some way doesn't work for you.
BUG: 123141


 M  +9 -7      gallerytalker.cpp  


--- trunk/extragear/libs/kipi-plugins/galleryexport/gallerytalker.cpp #547983:547984
@@ -23,6 +23,7 @@
 #include <qtextstream.h>
 #include <qfile.h>
 #include <qimage.h>
+#include <qregexp.h>
 
 #include <klocale.h>
 #include <kio/job.h>
@@ -299,13 +300,14 @@
 
     if (m_state == GE_LOGIN && m_loggedIn)
     {
-        // get and parse the cookie
-        m_cookie = job->queryMetaData("setcookies");
-        // rfc2109: http://www.faqs.org/rfcs/rfc2109.html
-        m_cookie.remove("Set-Cookie:");
-        m_cookie = m_cookie.section(";", 0, 0);
-        m_cookie = "Cookie:" + m_cookie;
-
+        QStringList cookielist = QStringList::split("\n", job->queryMetaData("setcookies"));
+        m_cookie = "Cookie:";
+        for (QStringList::Iterator it = cookielist.begin(); it != cookielist.end(); ++it)
+        {
+            QRegExp rx("^Set-Cookie: ([^;]+)");
+            if (rx.search(*it) > -1)
+                m_cookie += " " + rx.cap(1) + ";";
+        }
         listAlbums();
     }
 }
Comment 10 Boris Kavod 2006-06-04 17:15:26 UTC
It works perfectly for me. Thanks you very much!