tizen beta release
[framework/web/webkit-efl.git] / debian / libwebkit-engine-dev / usr / include / ewebkit-0 / ewk_cookies.h
1 /*
2     Copyright (C) 2010 ProFUSION embedded systems
3     Copyright (C) 2010 Samsung Electronics
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 /**
22  * @file    ewk_cookies.h
23  * @brief   The Ewk cookies API.
24  */
25
26 #ifndef ewk_cookies_h
27 #define ewk_cookies_h
28
29 #include <Eina.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * \struct  _Ewk_Cookie
37  *
38  * @brief   Describes properties of an HTTP cookie.
39  */
40 struct _Ewk_Cookie {
41     /// the cookie name
42     char *name;
43     /// the cookie value
44     char *value;
45     /// the "domain" attribute, or else the hostname that the cookie came from
46     char *domain;
47     /// the "path" attribute, or @c 0
48     char *path;
49     /// the cookie expiration time, or @c 0 for a session cookie
50     time_t expires;
51     /// @c EINA_TRUE if the cookie should only be tranferred over SSL
52     Eina_Bool secure;
53     /// @c EINA_TRUE if the cookie should not be exposed to scripts
54     Eina_Bool http_only;    
55 };
56 /// Creates a type name for the _Ewk_Cookie.
57 typedef struct _Ewk_Cookie Ewk_Cookie;
58
59 /**
60  * \enum    _Ewk_Cookie_Policy
61  *
62  * @brief   Contains a policy for the cookies.
63  */
64 enum _Ewk_Cookie_Policy {
65     /// Rejects all cookies.
66     EWK_COOKIE_JAR_ACCEPT_NEVER,
67     /// Accepts every cookie sent from any page.
68     EWK_COOKIE_JAR_ACCEPT_ALWAYS,
69     /// Accepts cookies only from the main page.
70     EWK_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
71 };
72 /// Creates a type name for the _Ewk_Cookie_Policy.
73 typedef enum _Ewk_Cookie_Policy Ewk_Cookie_Policy;
74
75 /************************** Exported functions ***********************/
76
77 /**
78  * Sets the path where the cookies are going to be stored. 
79  *
80  * @param filename path to the cookies.txt file, use @c 0 for keep
81  *        cookies just in memory.
82  *
83  * @return @c EINA_FALSE if it wasn't possible to create the cookie jar,
84  *          @c EINA_TRUE otherwise.
85  */
86 EAPI Eina_Bool          ewk_cookies_file_set(const char *filename);
87
88 /**
89  * Clears all the cookies from the cookie jar.
90  */
91 EAPI void               ewk_cookies_clear(void);
92 EAPI void               ewk_cookies_clear_by_filename(const char *filename);
93
94 /**
95  * Returns a list of cookies in the cookie jar.
96  *
97  * @return an @c Eina_List with all the cookies in the cookie jar
98  */
99 EAPI Eina_List*         ewk_cookies_get_all(void);
100
101 /**
102  * Deletes a cookie from the cookie jar.
103  *
104  * Note that the fields name, value, domain and path are used to match this
105  * cookie in the cookie jar.
106  *
107  * @param cookie an @c Ewk_Cookie that has the info relative to that cookie
108  */
109 EAPI void               ewk_cookies_cookie_del(Ewk_Cookie *cookie);
110
111 /**
112  * Frees the memory used by a cookie.
113  *
114  * @param cookie the Ewk_Cookie struct that will be freed
115  */
116 EAPI void               ewk_cookies_cookie_free(Ewk_Cookie *cookie);
117
118 /**
119  * Sets accept policy for the cookies.
120  *
121  * @param p the acceptance policy
122  *
123  * @see Ewk_Cookie_Policy
124  */
125 EAPI void               ewk_cookies_policy_set(Ewk_Cookie_Policy p);
126
127 /**
128  * Gets the acceptance policy used in the current cookie jar.
129  *
130  * @return the current acceptance policy
131  * @see Ewk_Cookie_Policy
132  */
133 EAPI Ewk_Cookie_Policy  ewk_cookies_policy_get(void);
134
135 #ifdef __cplusplus
136 }
137 #endif
138 #endif // ewk_cookies_h