File: mozilla-cookie.cpp

package info (click to toggle)
galeon 2.0.6-2.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 19,156 kB
  • ctags: 9,680
  • sloc: ansic: 77,798; cpp: 13,928; sh: 9,000; xml: 5,761; makefile: 901
file content (59 lines) | stat: -rw-r--r-- 1,200 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * mozilla-cookie.cpp
 *
 * Copyright (C) 2003 Tommi Komulainen <tommi.komulainen@iki.fi>
 * Available under the terms of the GNU General Public License version 2.
 */ 

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "mozilla-cookie.h"
#include "GulString.h"

#include <nsICookie.h>

#include <ctime>
#include <glib/gi18n.h>

CookieInfo *
mozilla_cookie_to_info (nsICookie *aCookie)
{
	CookieInfo *info = g_new0(CookieInfo, 1);
	GulCString str;
	PRUint64 expires;

	(void)aCookie->GetHost (str);
	info->domain = g_strdup (str.get());

	(void)aCookie->GetName (str);
	info->name = g_strdup (str.get());

	(void)aCookie->GetValue (str);
	info->value = g_strdup (str.get());

	(void)aCookie->GetPath (str);
	info->path = g_strdup (str.get());

	(void)aCookie->GetIsSecure(&info->secure);

	(void)aCookie->GetExpires(&expires);
	if (expires == 0)
	{
		info->expire = g_strdup (_("End of current session"));
	}
	else
	{
		time_t t = (time_t)expires;	// PRTime is PRInt64 is time_t
		struct tm tm;
		char buf[64];

		strftime (buf, sizeof(buf), _("%a, %b %-d %Y at %-I:%M %p"), 
			  localtime_r (&t, &tm));
		info->expire = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
	}

	return info;
}