[libsoup] Add get methods for SoupCookie, SoupDate, and SoupURI fields
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] Add get methods for SoupCookie, SoupDate, and SoupURI fields
- Date: Thu, 29 Apr 2010 00:50:43 +0000 (UTC)
commit e4b50bfc892ba2e65ecff05425ed4ef10af38e3c
Author: Dan Winship <danw gnome org>
Date: Wed Jul 8 16:33:16 2009 -0400
Add get methods for SoupCookie, SoupDate, and SoupURI fields
for added introspectability
libsoup/soup-cookie.c | 113 +++++++++++++++++++++++++++++++++++++++++
libsoup/soup-cookie.h | 7 +++
libsoup/soup-date.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++
libsoup/soup-date.h | 9 +++
libsoup/soup-uri.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++-
libsoup/soup-uri.h | 106 +++++++++++++++++++++------------------
6 files changed, 447 insertions(+), 52 deletions(-)
---
diff --git a/libsoup/soup-cookie.c b/libsoup/soup-cookie.c
index e31bdd9..06a873b 100644
--- a/libsoup/soup-cookie.c
+++ b/libsoup/soup-cookie.c
@@ -429,6 +429,22 @@ soup_cookie_parse (const char *cookie, SoupURI *origin)
}
/**
+ * soup_cookie_get_name:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's name
+ *
+ * Return value: @cookie's name
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_cookie_get_name (SoupCookie *cookie)
+{
+ return cookie->name;
+}
+
+/**
* soup_cookie_set_name:
* @cookie: a #SoupCookie
* @name: the new name
@@ -445,6 +461,22 @@ soup_cookie_set_name (SoupCookie *cookie, const char *name)
}
/**
+ * soup_cookie_get_value:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's value
+ *
+ * Return value: @cookie's value
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_cookie_get_value (SoupCookie *cookie)
+{
+ return cookie->value;
+}
+
+/**
* soup_cookie_set_value:
* @cookie: a #SoupCookie
* @value: the new value
@@ -461,6 +493,22 @@ soup_cookie_set_value (SoupCookie *cookie, const char *value)
}
/**
+ * soup_cookie_get_domain:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's domain
+ *
+ * Return value: @cookie's domain
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_cookie_get_domain (SoupCookie *cookie)
+{
+ return cookie->domain;
+}
+
+/**
* soup_cookie_set_domain:
* @cookie: a #SoupCookie
* @domain: the new domain
@@ -477,6 +525,22 @@ soup_cookie_set_domain (SoupCookie *cookie, const char *domain)
}
/**
+ * soup_cookie_get_path:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's path
+ *
+ * Return value: @cookie's path
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_cookie_get_path (SoupCookie *cookie)
+{
+ return cookie->path;
+}
+
+/**
* soup_cookie_set_path:
* @cookie: a #SoupCookie
* @path: the new path
@@ -561,6 +625,23 @@ soup_cookie_set_max_age (SoupCookie *cookie, int max_age)
**/
/**
+ * soup_cookie_get_expires:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's expiration time
+ *
+ * Return value: @cookie's expiration time, which is owned
+ * by @cookie and should not be modified or freed.
+ *
+ * Since: 2.32
+ **/
+SoupDate *
+soup_cookie_get_expires (SoupCookie *cookie)
+{
+ return cookie->expires;
+}
+
+/**
* soup_cookie_set_expires:
* @cookie: a #SoupCookie
* @expires: the new expiration time, or %NULL
@@ -586,6 +667,22 @@ soup_cookie_set_expires (SoupCookie *cookie, SoupDate *expires)
}
/**
+ * soup_cookie_get_secure:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's secure attribute
+ *
+ * Return value: @cookie's secure attribute
+ *
+ * Since: 2.32
+ **/
+gboolean
+soup_cookie_get_secure (SoupCookie *cookie)
+{
+ return cookie->secure;
+}
+
+/**
* soup_cookie_set_secure:
* @cookie: a #SoupCookie
* @secure: the new value for the secure attribute
@@ -603,6 +700,22 @@ soup_cookie_set_secure (SoupCookie *cookie, gboolean secure)
}
/**
+ * soup_cookie_get_http_only:
+ * @cookie: a #SoupCookie
+ *
+ * Gets @cookie's HttpOnly attribute
+ *
+ * Return value: @cookie's HttpOnly attribute
+ *
+ * Since: 2.32
+ **/
+gboolean
+soup_cookie_get_http_only (SoupCookie *cookie)
+{
+ return cookie->http_only;
+}
+
+/**
* soup_cookie_set_http_only:
* @cookie: a #SoupCookie
* @http_only: the new value for the HttpOnly attribute
diff --git a/libsoup/soup-cookie.h b/libsoup/soup-cookie.h
index 8bccd90..3a3c388 100644
--- a/libsoup/soup-cookie.h
+++ b/libsoup/soup-cookie.h
@@ -37,20 +37,27 @@ SoupCookie *soup_cookie_parse (const char *header,
SoupURI *origin);
SoupCookie *soup_cookie_copy (SoupCookie *cookie);
+const char *soup_cookie_get_name (SoupCookie *cookie);
void soup_cookie_set_name (SoupCookie *cookie,
const char *name);
+const char *soup_cookie_get_value (SoupCookie *cookie);
void soup_cookie_set_value (SoupCookie *cookie,
const char *value);
+const char *soup_cookie_get_domain (SoupCookie *cookie);
void soup_cookie_set_domain (SoupCookie *cookie,
const char *domain);
+const char *soup_cookie_get_path (SoupCookie *cookie);
void soup_cookie_set_path (SoupCookie *cookie,
const char *path);
void soup_cookie_set_max_age (SoupCookie *cookie,
int max_age);
+SoupDate *soup_cookie_get_expires (SoupCookie *cookie);
void soup_cookie_set_expires (SoupCookie *cookie,
SoupDate *expires);
+gboolean soup_cookie_get_secure (SoupCookie *cookie);
void soup_cookie_set_secure (SoupCookie *cookie,
gboolean secure);
+gboolean soup_cookie_get_http_only (SoupCookie *cookie);
void soup_cookie_set_http_only (SoupCookie *cookie,
gboolean http_only);
diff --git a/libsoup/soup-date.c b/libsoup/soup-date.c
index 5509af8..ce99ec5 100644
--- a/libsoup/soup-date.c
+++ b/libsoup/soup-date.c
@@ -764,6 +764,136 @@ soup_date_is_past (SoupDate *date)
}
/**
+ * soup_date_get_year:
+ * @date: a #SoupDate
+ *
+ * Gets @date's year.
+ *
+ * Return value: @date's year
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_year (SoupDate *date)
+{
+ return date->year;
+}
+
+/**
+ * soup_date_get_month:
+ * @date: a #SoupDate
+ *
+ * Gets @date's month.
+ *
+ * Return value: @date's month
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_month (SoupDate *date)
+{
+ return date->month;
+}
+
+/**
+ * soup_date_get_day:
+ * @date: a #SoupDate
+ *
+ * Gets @date's day.
+ *
+ * Return value: @date's day
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_day (SoupDate *date)
+{
+ return date->day;
+}
+
+/**
+ * soup_date_get_hour:
+ * @date: a #SoupDate
+ *
+ * Gets @date's hour.
+ *
+ * Return value: @date's hour
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_hour (SoupDate *date)
+{
+ return date->hour;
+}
+
+/**
+ * soup_date_get_minute:
+ * @date: a #SoupDate
+ *
+ * Gets @date's minute.
+ *
+ * Return value: @date's minute
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_minute (SoupDate *date)
+{
+ return date->minute;
+}
+
+/**
+ * soup_date_get_second:
+ * @date: a #SoupDate
+ *
+ * Gets @date's second.
+ *
+ * Return value: @date's second
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_second (SoupDate *date)
+{
+ return date->second;
+}
+
+/**
+ * soup_date_get_utc:
+ * @date: a #SoupDate
+ *
+ * Gets @date's UTC flag
+ *
+ * Return value: %TRUE if @date is UTC.
+ *
+ * Since: 2.32
+ **/
+gboolean
+soup_date_get_utc (SoupDate *date)
+{
+ return date->utc;
+}
+
+/**
+ * soup_date_get_offset:
+ * @date: a #SoupDate
+ *
+ * Gets @date's offset from UTC.
+ *
+ * Return value: @date's offset from UTC. If soup_date_get_utc()
+ * returns %FALSE but soup_date_get_offset() returns 0, that means the
+ * date is a "floating" time with no associated offset information.
+ *
+ * Since: 2.32
+ **/
+int
+soup_date_get_offset (SoupDate *date)
+{
+ return date->offset;
+}
+
+/**
* soup_date_copy:
* @date: a #SoupDate
*
diff --git a/libsoup/soup-date.h b/libsoup/soup-date.h
index 41f5db0..0924607 100644
--- a/libsoup/soup-date.h
+++ b/libsoup/soup-date.h
@@ -56,6 +56,15 @@ void soup_date_to_timeval (SoupDate *date,
gboolean soup_date_is_past (SoupDate *date);
+int soup_date_get_year (SoupDate *date);
+int soup_date_get_month (SoupDate *date);
+int soup_date_get_day (SoupDate *date);
+int soup_date_get_hour (SoupDate *date);
+int soup_date_get_minute (SoupDate *date);
+int soup_date_get_second (SoupDate *date);
+int soup_date_get_utc (SoupDate *date);
+int soup_date_get_offset (SoupDate *date);
+
SoupDate *soup_date_copy (SoupDate *date);
void soup_date_free (SoupDate *date);
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index 792c6dc..c5c8c3e 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -100,7 +100,7 @@ gpointer _SOUP_URI_SCHEME_FTP;
gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA;
static inline const char *
-soup_uri_get_scheme (const char *scheme, int len)
+soup_uri_parse_scheme (const char *scheme, int len)
{
if (len == 4 && !g_ascii_strncasecmp (scheme, "http", len)) {
return SOUP_URI_SCHEME_HTTP;
@@ -191,7 +191,7 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
p++;
if (p > uri_string && *p == ':') {
- uri->scheme = soup_uri_get_scheme (uri_string, p - uri_string);
+ uri->scheme = soup_uri_parse_scheme (uri_string, p - uri_string);
uri_string = p + 1;
}
@@ -762,6 +762,22 @@ soup_uri_uses_default_port (SoupURI *uri)
**/
/**
+ * soup_uri_get_scheme:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's scheme.
+ *
+ * Return value: @uri's scheme.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_scheme (SoupURI *uri)
+{
+ return uri->scheme;
+}
+
+/**
* soup_uri_set_scheme:
* @uri: a #SoupURI
* @scheme: the URI scheme
@@ -772,11 +788,27 @@ soup_uri_uses_default_port (SoupURI *uri)
void
soup_uri_set_scheme (SoupURI *uri, const char *scheme)
{
- uri->scheme = soup_uri_get_scheme (scheme, strlen (scheme));
+ uri->scheme = soup_uri_parse_scheme (scheme, strlen (scheme));
uri->port = soup_scheme_default_port (uri->scheme);
}
/**
+ * soup_uri_get_user:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's user.
+ *
+ * Return value: @uri's user.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_user (SoupURI *uri)
+{
+ return uri->user;
+}
+
+/**
* soup_uri_set_user:
* @uri: a #SoupURI
* @user: the username, or %NULL
@@ -791,6 +823,22 @@ soup_uri_set_user (SoupURI *uri, const char *user)
}
/**
+ * soup_uri_get_password:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's password.
+ *
+ * Return value: @uri's password.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_password (SoupURI *uri)
+{
+ return uri->password;
+}
+
+/**
* soup_uri_set_password:
* @uri: a #SoupURI
* @password: the password, or %NULL
@@ -805,6 +853,22 @@ soup_uri_set_password (SoupURI *uri, const char *password)
}
/**
+ * soup_uri_get_host:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's host.
+ *
+ * Return value: @uri's host.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_host (SoupURI *uri)
+{
+ return uri->host;
+}
+
+/**
* soup_uri_set_host:
* @uri: a #SoupURI
* @host: the hostname or IP address, or %NULL
@@ -823,6 +887,22 @@ soup_uri_set_host (SoupURI *uri, const char *host)
}
/**
+ * soup_uri_get_port:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's port.
+ *
+ * Return value: @uri's port.
+ *
+ * Since: 2.32
+ **/
+guint
+soup_uri_get_port (SoupURI *uri)
+{
+ return uri->port;
+}
+
+/**
* soup_uri_set_port:
* @uri: a #SoupURI
* @port: the port, or 0
@@ -837,6 +917,22 @@ soup_uri_set_port (SoupURI *uri, guint port)
}
/**
+ * soup_uri_get_path:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's path.
+ *
+ * Return value: @uri's path.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_path (SoupURI *uri)
+{
+ return uri->path;
+}
+
+/**
* soup_uri_set_path:
* @uri: a #SoupURI
* @path: the path
@@ -851,6 +947,22 @@ soup_uri_set_path (SoupURI *uri, const char *path)
}
/**
+ * soup_uri_get_query:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's query.
+ *
+ * Return value: @uri's query.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_query (SoupURI *uri)
+{
+ return uri->query;
+}
+
+/**
* soup_uri_set_query:
* @uri: a #SoupURI
* @query: the query
@@ -904,6 +1016,22 @@ soup_uri_set_query_from_fields (SoupURI *uri,
}
/**
+ * soup_uri_get_fragment:
+ * @uri: a #SoupURI
+ *
+ * Gets @uri's fragment.
+ *
+ * Return value: @uri's fragment.
+ *
+ * Since: 2.32
+ **/
+const char *
+soup_uri_get_fragment (SoupURI *uri)
+{
+ return uri->fragment;
+}
+
+/**
* soup_uri_set_fragment:
* @uri: a #SoupURI
* @fragment: the fragment
diff --git a/libsoup/soup-uri.h b/libsoup/soup-uri.h
index f574b7c..a5c54a6 100644
--- a/libsoup/soup-uri.h
+++ b/libsoup/soup-uri.h
@@ -28,7 +28,7 @@ struct _SoupURI {
char *fragment;
};
-GType soup_uri_get_type (void);
+GType soup_uri_get_type (void);
#define SOUP_TYPE_URI (soup_uri_get_type ())
#define SOUP_URI_SCHEME_HTTP _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "http")
@@ -40,54 +40,62 @@ extern gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
extern gpointer _SOUP_URI_SCHEME_FTP;
extern gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA;
-SoupURI *soup_uri_new_with_base (SoupURI *base,
- const char *uri_string);
-SoupURI *soup_uri_new (const char *uri_string);
-
-char *soup_uri_to_string (SoupURI *uri,
- gboolean just_path_and_query);
-
-SoupURI *soup_uri_copy (SoupURI *uri);
-
-gboolean soup_uri_equal (SoupURI *uri1,
- SoupURI *uri2);
-
-void soup_uri_free (SoupURI *uri);
-
-char *soup_uri_encode (const char *part,
- const char *escape_extra);
-char *soup_uri_decode (const char *part);
-char *soup_uri_normalize (const char *part,
- const char *unescape_extra);
-
-gboolean soup_uri_uses_default_port (SoupURI *uri);
-
-void soup_uri_set_scheme (SoupURI *uri,
- const char *scheme);
-void soup_uri_set_user (SoupURI *uri,
- const char *user);
-void soup_uri_set_password (SoupURI *uri,
- const char *password);
-void soup_uri_set_host (SoupURI *uri,
- const char *host);
-void soup_uri_set_port (SoupURI *uri,
- guint port);
-void soup_uri_set_path (SoupURI *uri,
- const char *path);
-void soup_uri_set_query (SoupURI *uri,
- const char *query);
-void soup_uri_set_query_from_form (SoupURI *uri,
- GHashTable *form);
-void soup_uri_set_query_from_fields (SoupURI *uri,
- const char *first_field,
- ...) G_GNUC_NULL_TERMINATED;
-void soup_uri_set_fragment (SoupURI *uri,
- const char *fragment);
-
-SoupURI *soup_uri_copy_host (SoupURI *uri);
-guint soup_uri_host_hash (gconstpointer key);
-gboolean soup_uri_host_equal (gconstpointer v1,
- gconstpointer v2);
+SoupURI *soup_uri_new_with_base (SoupURI *base,
+ const char *uri_string);
+SoupURI *soup_uri_new (const char *uri_string);
+
+char *soup_uri_to_string (SoupURI *uri,
+ gboolean just_path_and_query);
+
+SoupURI *soup_uri_copy (SoupURI *uri);
+
+gboolean soup_uri_equal (SoupURI *uri1,
+ SoupURI *uri2);
+
+void soup_uri_free (SoupURI *uri);
+
+char *soup_uri_encode (const char *part,
+ const char *escape_extra);
+char *soup_uri_decode (const char *part);
+char *soup_uri_normalize (const char *part,
+ const char *unescape_extra);
+
+gboolean soup_uri_uses_default_port (SoupURI *uri);
+
+const char *soup_uri_get_scheme (SoupURI *uri);
+void soup_uri_set_scheme (SoupURI *uri,
+ const char *scheme);
+const char *soup_uri_get_user (SoupURI *uri);
+void soup_uri_set_user (SoupURI *uri,
+ const char *user);
+const char *soup_uri_get_password (SoupURI *uri);
+void soup_uri_set_password (SoupURI *uri,
+ const char *password);
+const char *soup_uri_get_host (SoupURI *uri);
+void soup_uri_set_host (SoupURI *uri,
+ const char *host);
+guint soup_uri_get_port (SoupURI *uri);
+void soup_uri_set_port (SoupURI *uri,
+ guint port);
+const char *soup_uri_get_path (SoupURI *uri);
+void soup_uri_set_path (SoupURI *uri,
+ const char *path);
+const char *soup_uri_get_query (SoupURI *uri);
+void soup_uri_set_query (SoupURI *uri,
+ const char *query);
+void soup_uri_set_query_from_form (SoupURI *uri,
+ GHashTable *form);
+void soup_uri_set_query_from_fields (SoupURI *uri,
+ const char *first_field,
+ ...) G_GNUC_NULL_TERMINATED;
+const char *soup_uri_get_fragment (SoupURI *uri);
+void soup_uri_set_fragment (SoupURI *uri,
+ const char *fragment);
+
+SoupURI *soup_uri_copy_host (SoupURI *uri);
+guint soup_uri_host_hash (gconstpointer key);
+gboolean soup_uri_host_equal (gconstpointer v1,
+ gconstpointer v2);
#define SOUP_URI_VALID_FOR_HTTP(uri) ((uri) && ((uri)->scheme == SOUP_URI_SCHEME_HTTP || (uri)->scheme == SOUP_URI_SCHEME_HTTPS) && (uri)->host && (uri)->path)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]