Maybe you will find this patch to enable webkit cookie support (the
cookie jar) useful.

Regards
--
Carlos

On Tue, Oct 16, 2012 at 5:37 AM, Daniel Bainton <d...@driftaway.org> wrote:
> Hi,
>
> I bumped into a bug in surf.
>
> I try to use Googles multiple sign-in so I can view my work and my
> personal mail in the same browser, but somehow the cookies start
> fighting and all sorts of buggy behaviour shows in Google Mail.
>
> 1. Most of the time I can only open one of the inboxes at a time, the
> second will be stuck on the loading screen.
> 2. The chat is able to login very rarely.
> 3. Marking as read / archiving / deleting won't stick, they "seem" to
> work at first but if I reload the page, they're still there like they
> originally were.
>
> I believe it has something to do with the cookies google stores, but I
> haven't debugged it further.
>
> I made out a workaround that I'm currently using, so I'm in no hurry
> to get this fixed. Just mailing this so there's some log about it
> available and others may find it too.
>
>
> --
> Daniel
>
> Ps.
> The workaround: just compiled another version of the surf binary with
> a different cookie file for work mail, not using multiple sign-in.
>

Attachment: surf-r246-cookiejar.diff
Description: Binary data

#define SURF_TYPE_COOKIE_JAR           (surf_cookie_jar_get_type ())
#define SURF_COOKIE_JAR(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), SURF_TYPE_COOKIE_JAR, SurfCookieJar))

typedef struct {
  SoupCookieJarText parent_instance;
  int lock;
} SurfCookieJar;

typedef struct {
  SoupCookieJarTextClass parent_class;
} SurfCookieJarClass;

G_DEFINE_TYPE(SurfCookieJar, surf_cookie_jar, SOUP_TYPE_COOKIE_JAR_TEXT)

static void
surf_cookie_jar_init(SurfCookieJar *self) {
  self->lock = open(cookiefile, 0);
}

static void
surf_cookie_jar_changed(SoupCookieJar *self, SoupCookie *old_cookie, SoupCookie *new_cookie) {
	flock(SURF_COOKIE_JAR(self)->lock, LOCK_EX);
	if(new_cookie && !new_cookie->expires && sessiontime)
		soup_cookie_set_expires(new_cookie, soup_date_new_from_now(sessiontime));
  SOUP_COOKIE_JAR_CLASS(surf_cookie_jar_parent_class)->changed(self, old_cookie, new_cookie);
	flock(SURF_COOKIE_JAR(self)->lock, LOCK_UN);
}

static void
surf_cookie_jar_set_property(GObject *self, guint prop_id, const GValue *value, GParamSpec *pspec) {
	flock(SURF_COOKIE_JAR(self)->lock, LOCK_SH);
  // parent class loads entire file into hash table at once
  G_OBJECT_CLASS(surf_cookie_jar_parent_class)->set_property(self, prop_id, value, pspec);
	flock(SURF_COOKIE_JAR(self)->lock, LOCK_UN);
}

static void
surf_cookie_jar_finalize(GObject *self) {
  close(SURF_COOKIE_JAR(self)->lock);
  G_OBJECT_CLASS(surf_cookie_jar_parent_class)->finalize(self);
}

static void
surf_cookie_jar_class_init(SurfCookieJarClass *klass) {
  SOUP_COOKIE_JAR_CLASS(klass)->changed = surf_cookie_jar_changed;
  G_OBJECT_CLASS(klass)->get_property = G_OBJECT_CLASS(surf_cookie_jar_parent_class)->get_property;
  G_OBJECT_CLASS(klass)->set_property = surf_cookie_jar_set_property;
  G_OBJECT_CLASS(klass)->finalize = surf_cookie_jar_finalize;
  g_object_class_override_property(G_OBJECT_CLASS(klass), 1, "filename");
}

static SoupCookieJar *
surf_cookie_jar_new(const char *filename, gboolean read_only) {
  return g_object_new(SURF_TYPE_COOKIE_JAR,
                      SOUP_COOKIE_JAR_TEXT_FILENAME, filename,
                      SOUP_COOKIE_JAR_READ_ONLY, read_only, NULL);
} 

Reply via email to