[librest/gwagner/deprecated: 6/10] flickr: modernized




commit fab6794864c0e90c7b64901acbb3b24511a0d9ec
Author: Günther Wagner <info gunibert de>
Date:   Wed Dec 22 23:14:51 2021 +0100

    flickr: modernized

 rest-extras/flickr-proxy-call.c    |  73 +++++++++-------
 rest-extras/flickr-proxy-call.h    |  39 ++-------
 rest-extras/flickr-proxy-private.h |  33 -------
 rest-extras/flickr-proxy.c         | 172 ++++++++++++++++++++++---------------
 rest-extras/flickr-proxy.h         |  93 +++++++-------------
 5 files changed, 180 insertions(+), 230 deletions(-)
---
diff --git a/rest-extras/flickr-proxy-call.c b/rest-extras/flickr-proxy-call.c
index e7dfa07..fc38ca0 100644
--- a/rest-extras/flickr-proxy-call.c
+++ b/rest-extras/flickr-proxy-call.c
@@ -4,6 +4,7 @@
  *
  * Authors: Rob Bradford <rob linux intel com>
  *          Ross Burton <ross linux intel com>
+ *          Günther Wagner <info gunibert de>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU Lesser General Public License,
@@ -24,50 +25,57 @@
 #include <libsoup/soup.h>
 #include <rest/rest-proxy-call.h>
 #include "flickr-proxy-call.h"
-#include "flickr-proxy-private.h"
+#include "flickr-proxy.h"
 #include "rest/sha1.h"
 
-G_DEFINE_TYPE (FlickrProxyCall, flickr_proxy_call, REST_TYPE_PROXY_CALL)
-
-#define GET_PRIVATE(o) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((o), FLICKR_TYPE_PROXY_CALL, FlickrProxyCallPrivate))
-
 typedef struct {
   gboolean upload;
 } FlickrProxyCallPrivate;
 
+G_DEFINE_TYPE_WITH_PRIVATE (FlickrProxyCall, flickr_proxy_call, REST_TYPE_PROXY_CALL)
+
 enum {
   PROP_0,
-  PROP_UPLOAD
+  PROP_UPLOAD,
+  N_PROPS
 };
 
+static GParamSpec *properties [N_PROPS];
+
 static void
 flickr_proxy_call_set_property (GObject      *object,
                                 guint         property_id,
                                 const GValue *value,
                                 GParamSpec   *pspec)
 {
-   switch (property_id) {
-   case PROP_UPLOAD:
-     GET_PRIVATE (object)->upload = g_value_get_boolean (value);
-     break;
+  FlickrProxyCall *self = FLICKR_PROXY_CALL (object);
+  FlickrProxyCallPrivate *priv = flickr_proxy_call_get_instance_private (self);
+
+  switch (property_id)
+    {
+    case PROP_UPLOAD:
+      priv->upload = g_value_get_boolean (value);
+      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-   }
+    }
 }
 
 static gboolean
-_prepare (RestProxyCall *call, GError **error)
+_prepare (RestProxyCall  *call,
+          GError        **error)
 {
+  FlickrProxyCall *self = (FlickrProxyCall *)call;
+  FlickrProxyCallPrivate *priv = flickr_proxy_call_get_instance_private (self);
+
   FlickrProxy *proxy = NULL;
-  FlickrProxyPrivate *priv;
+  const gchar *token = NULL;
   GHashTable *params;
   char *s;
 
-  g_object_get (call, "proxy", &proxy, NULL);
-  priv = FLICKR_PROXY_GET_PRIVATE (proxy);
+  g_object_get (self, "proxy", &proxy, NULL);
 
-  if (GET_PRIVATE (call)->upload) {
+  if (priv->upload) {
     rest_proxy_bind (REST_PROXY(proxy), "up", "upload");
     rest_proxy_call_set_function (call, NULL);
   } else {
@@ -79,10 +87,11 @@ _prepare (RestProxyCall *call, GError **error)
     rest_proxy_call_set_function (call, NULL);
   }
 
-  rest_proxy_call_add_param (call, "api_key", priv->api_key);
+  rest_proxy_call_add_param (call, "api_key", flickr_proxy_get_api_key (proxy));
+  token = flickr_proxy_get_token (proxy);
 
-  if (priv->token)
-    rest_proxy_call_add_param (call, "auth_token", priv->token);
+  if (token)
+    rest_proxy_call_add_param (call, "auth_token", token);
 
   /* Get the string params as a hash for signing */
   params = rest_params_as_string_hash_table (rest_proxy_call_get_params (call));
@@ -100,14 +109,11 @@ _prepare (RestProxyCall *call, GError **error)
 static void
 flickr_proxy_call_class_init (FlickrProxyCallClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   RestProxyCallClass *call_class = REST_PROXY_CALL_CLASS (klass);
-  GObjectClass *obj_class = G_OBJECT_CLASS (klass);
-  GParamSpec *pspec;
-
-  g_type_class_add_private (klass, sizeof (FlickrProxyCallPrivate));
 
   call_class->prepare = _prepare;
-  obj_class->set_property = flickr_proxy_call_set_property;
+  object_class->set_property = flickr_proxy_call_set_property;
 
   /**
    * FlickrProxyCall:upload:
@@ -115,16 +121,19 @@ flickr_proxy_call_class_init (FlickrProxyCallClass *klass)
    * Set if the call should be sent to the photo upload endpoint and not the
    * general-purpose endpoint.
    */
-  pspec = g_param_spec_boolean ("upload", "upload", "upload",
-                                FALSE, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (obj_class, PROP_UPLOAD, pspec);
+  properties [PROP_UPLOAD] =
+    g_param_spec_boolean ("upload",
+                          "upload",
+                          "upload",
+                          FALSE,
+                          (G_PARAM_WRITABLE |
+                           G_PARAM_CONSTRUCT_ONLY |
+                           G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
 }
 
 static void
 flickr_proxy_call_init (FlickrProxyCall *self)
 {
 }
-
-#if BUILD_TESTS
-#warning TODO flickr signature test cases
-#endif
diff --git a/rest-extras/flickr-proxy-call.h b/rest-extras/flickr-proxy-call.h
index 195886e..3903631 100644
--- a/rest-extras/flickr-proxy-call.h
+++ b/rest-extras/flickr-proxy-call.h
@@ -20,49 +20,22 @@
  *
  */
 
-#ifndef _FLICKR_PROXY_CALL
-#define _FLICKR_PROXY_CALL
+#pragma once
 
 #include <rest/rest-proxy-call.h>
 
 G_BEGIN_DECLS
 
-#define FLICKR_TYPE_PROXY_CALL flickr_proxy_call_get_type()
+#define FLICKR_TYPE_PROXY_CALL (flickr_proxy_call_get_type())
 
-#define FLICKR_PROXY_CALL(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLICKR_TYPE_PROXY_CALL, FlickrProxyCall))
+G_DECLARE_DERIVABLE_TYPE (FlickrProxyCall, flickr_proxy_call, FLICKR, PROXY_CALL, RestProxyCall)
 
-#define FLICKR_PROXY_CALL_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), FLICKR_TYPE_PROXY_CALL, FlickrProxyCallClass))
-
-#define FLICKR_IS_PROXY_CALL(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FLICKR_TYPE_PROXY_CALL))
-
-#define FLICKR_IS_PROXY_CALL_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), FLICKR_TYPE_PROXY_CALL))
-
-#define FLICKR_PROXY_CALL_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), FLICKR_TYPE_PROXY_CALL, FlickrProxyCallClass))
-
-/**
- * FlickrProxyCall:
- *
- * #FlickrProxyCall has no publicly available members.
- */
-typedef struct {
-  RestProxyCall parent;
-} FlickrProxyCall;
-
-typedef struct {
+struct _FlickrProxyCallClass {
   RestProxyCallClass parent_class;
+
   /*< private >*/
   /* padding for future expansion */
   gpointer _padding_dummy[8];
-} FlickrProxyCallClass;
-
-GType flickr_proxy_call_get_type (void);
+};
 
 G_END_DECLS
-
-#endif /* _FLICKR_PROXY_CALL */
-
diff --git a/rest-extras/flickr-proxy.c b/rest-extras/flickr-proxy.c
index 7726359..5f8a43c 100644
--- a/rest-extras/flickr-proxy.c
+++ b/rest-extras/flickr-proxy.c
@@ -33,18 +33,26 @@
 #include <rest/rest-proxy.h>
 #include <libsoup/soup.h>
 #include "flickr-proxy.h"
-#include "flickr-proxy-private.h"
 #include "flickr-proxy-call.h"
 
-G_DEFINE_TYPE (FlickrProxy, flickr_proxy, REST_TYPE_PROXY)
+typedef struct {
+  char *api_key;
+  char *shared_secret;
+  char *token;
+} FlickrProxyPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (FlickrProxy, flickr_proxy, REST_TYPE_PROXY)
 
 enum {
   PROP_0,
   PROP_API_KEY,
   PROP_SHARED_SECRET,
   PROP_TOKEN,
+  N_PROPS
 };
 
+static GParamSpec *properties [N_PROPS];
+
 GQuark
 flickr_proxy_error_quark (void)
 {
@@ -52,22 +60,25 @@ flickr_proxy_error_quark (void)
 }
 
 static RestProxyCall *
-_new_call (RestProxy *proxy)
+_new_call (RestProxy *self)
 {
   RestProxyCall *call;
 
   call = g_object_new (FLICKR_TYPE_PROXY_CALL,
-                       "proxy", proxy,
+                       "proxy", self,
                        NULL);
 
   return call;
 }
 
 static void
-flickr_proxy_get_property (GObject *object, guint property_id,
-                              GValue *value, GParamSpec *pspec)
+flickr_proxy_get_property (GObject    *object,
+                           guint       property_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
 {
-  FlickrProxyPrivate *priv = FLICKR_PROXY_GET_PRIVATE (object);
+  FlickrProxy *self = FLICKR_PROXY (object);
+  FlickrProxyPrivate *priv = flickr_proxy_get_instance_private (self);
 
   switch (property_id) {
   case PROP_API_KEY:
@@ -85,10 +96,13 @@ flickr_proxy_get_property (GObject *object, guint property_id,
 }
 
 static void
-flickr_proxy_set_property (GObject *object, guint property_id,
-                              const GValue *value, GParamSpec *pspec)
+flickr_proxy_set_property (GObject      *object,
+                           guint         property_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
 {
-  FlickrProxyPrivate *priv = FLICKR_PROXY_GET_PRIVATE (object);
+  FlickrProxy *self = FLICKR_PROXY (object);
+  FlickrProxyPrivate *priv = flickr_proxy_get_instance_private (self);
 
   switch (property_id) {
   case PROP_API_KEY:
@@ -114,27 +128,21 @@ flickr_proxy_set_property (GObject *object, guint property_id,
 static void
 flickr_proxy_finalize (GObject *object)
 {
-  FlickrProxyPrivate *priv = FLICKR_PROXY_GET_PRIVATE (object);
+  FlickrProxy *self = FLICKR_PROXY (object);
+  FlickrProxyPrivate *priv = flickr_proxy_get_instance_private (self);
 
-  g_free (priv->api_key);
-  g_free (priv->shared_secret);
-  g_free (priv->token);
+  g_clear_pointer (&priv->api_key, g_free);
+  g_clear_pointer (&priv->shared_secret, g_free);
+  g_clear_pointer (&priv->token, g_free);
 
   G_OBJECT_CLASS (flickr_proxy_parent_class)->finalize (object);
 }
 
-#ifndef G_PARAM_STATIC_STRINGS
-#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
-#endif
-
 static void
 flickr_proxy_class_init (FlickrProxyClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   RestProxyClass *proxy_class = REST_PROXY_CLASS (klass);
-  GParamSpec *pspec;
-
-  g_type_class_add_private (klass, sizeof (FlickrProxyPrivate));
 
   object_class->get_property = flickr_proxy_get_property;
   object_class->set_property = flickr_proxy_set_property;
@@ -142,37 +150,43 @@ flickr_proxy_class_init (FlickrProxyClass *klass)
 
   proxy_class->new_call = _new_call;
 
-  pspec = g_param_spec_string ("api-key",  "api-key",
-                               "The API key", NULL,
-                               G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY|G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (object_class,
-                                   PROP_API_KEY,
-                                   pspec);
-
-  pspec = g_param_spec_string ("shared-secret",  "shared-secret",
-                               "The shared secret", NULL,
-                               G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY|G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (object_class,
-                                   PROP_SHARED_SECRET,
-                                   pspec);
-
-  pspec = g_param_spec_string ("token",  "token",
-                               "The request or access token", NULL,
-                               G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS);
-  g_object_class_install_property (object_class,
-                                   PROP_TOKEN,
-                                   pspec);
+  properties [PROP_API_KEY] =
+    g_param_spec_string ("api-key",
+                         "api-key",
+                         "The API key",
+                         NULL,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT_ONLY |
+                          G_PARAM_STATIC_STRINGS));
+
+  properties [PROP_SHARED_SECRET] =
+    g_param_spec_string ("shared-secret",
+                         "shared-secret",
+                         "The shared secret",
+                         NULL,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT_ONLY |
+                          G_PARAM_STATIC_STRINGS));
+
+  properties [PROP_TOKEN] =
+    g_param_spec_string ("token",
+                         "token",
+                         "The request or access token",
+                         NULL,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_STATIC_STRINGS));
+
+  g_object_class_install_properties (object_class, N_PROPS, properties);
 }
 
 static void
 flickr_proxy_init (FlickrProxy *self)
 {
-  self->priv = FLICKR_PROXY_GET_PRIVATE (self);
 }
 
 RestProxy *
 flickr_proxy_new (const char *api_key,
-                 const char *shared_secret)
+                  const char *shared_secret)
 {
   return flickr_proxy_new_with_token (api_key,
                                       shared_secret,
@@ -203,9 +217,12 @@ flickr_proxy_new_with_token (const char *api_key,
  * freed.
  */
 const char *
-flickr_proxy_get_api_key (FlickrProxy *proxy)
+flickr_proxy_get_api_key (FlickrProxy *self)
 {
-  FlickrProxyPrivate *priv = FLICKR_PROXY_GET_PRIVATE (proxy);
+  FlickrProxyPrivate *priv = flickr_proxy_get_instance_private (self);
+
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
+
   return priv->api_key;
 }
 
@@ -219,9 +236,12 @@ flickr_proxy_get_api_key (FlickrProxy *proxy)
  * freed.
  */
 const char *
-flickr_proxy_get_shared_secret (FlickrProxy *proxy)
+flickr_proxy_get_shared_secret (FlickrProxy *self)
 {
-  FlickrProxyPrivate *priv = FLICKR_PROXY_GET_PRIVATE (proxy);
+  FlickrProxyPrivate *priv = flickr_proxy_get_instance_private (self);
+
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
+
   return priv->shared_secret;
 }
 
@@ -235,9 +255,12 @@ flickr_proxy_get_shared_secret (FlickrProxy *proxy)
  * by #FlickrProxy and should not be freed.
  */
 const char *
-flickr_proxy_get_token (FlickrProxy *proxy)
+flickr_proxy_get_token (FlickrProxy *self)
 {
-  FlickrProxyPrivate *priv = FLICKR_PROXY_GET_PRIVATE (proxy);
+  FlickrProxyPrivate *priv = flickr_proxy_get_instance_private (self);
+
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
+
   return priv->token;
 }
 
@@ -249,31 +272,36 @@ flickr_proxy_get_token (FlickrProxy *proxy)
  * Set the token.
  */
 void
-flickr_proxy_set_token (FlickrProxy *proxy, const char *token)
+flickr_proxy_set_token (FlickrProxy *self,
+                        const char  *token)
 {
   FlickrProxyPrivate *priv;
 
-  g_return_if_fail (FLICKR_IS_PROXY (proxy));
-  priv = FLICKR_PROXY_GET_PRIVATE (proxy);
+  g_return_if_fail (FLICKR_IS_PROXY (self));
 
-  if (priv->token)
-    g_free (priv->token);
+  priv = flickr_proxy_get_instance_private (self);
 
-  priv->token = g_strdup (token);
+  if (g_strcmp0 (priv->token, token) != 0)
+    {
+      g_clear_pointer (&priv->token, g_free);
+      priv->token = g_strdup (token);
+      g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TOKEN]);
+    }
 }
 
 char *
-flickr_proxy_sign (FlickrProxy *proxy, GHashTable *params)
+flickr_proxy_sign (FlickrProxy *self,
+                   GHashTable  *params)
 {
   FlickrProxyPrivate *priv;
   GList *keys;
   char *md5;
   GChecksum *checksum;
 
-  g_return_val_if_fail (FLICKR_IS_PROXY (proxy), NULL);
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
   g_return_val_if_fail (params, NULL);
 
-  priv = FLICKR_PROXY_GET_PRIVATE (proxy);
+  priv = flickr_proxy_get_instance_private (self);
 
   checksum = g_checksum_new (G_CHECKSUM_MD5);
   g_checksum_update (checksum, (guchar *)priv->shared_secret, -1);
@@ -300,26 +328,29 @@ flickr_proxy_sign (FlickrProxy *proxy, GHashTable *params)
 }
 
 char *
-flickr_proxy_build_login_url (FlickrProxy *proxy,
+flickr_proxy_build_login_url (FlickrProxy *self,
                               const char  *frob,
                               const char  *perms)
 {
+  FlickrProxyPrivate *priv;
   GUri *uri;
   GHashTable *params;
   char *sig, *s;
   char *query;
 
-  g_return_val_if_fail (FLICKR_IS_PROXY (proxy), NULL);
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
+
+  priv = flickr_proxy_get_instance_private (self);
 
   params = g_hash_table_new (g_str_hash, g_str_equal);
 
-  g_hash_table_insert (params, "api_key", proxy->priv->api_key);
+  g_hash_table_insert (params, "api_key", priv->api_key);
   g_hash_table_insert (params, "perms", (gpointer)perms);
 
   if (frob)
     g_hash_table_insert (params, "frob", (gpointer)frob);
 
-  sig = flickr_proxy_sign (proxy, params);
+  sig = flickr_proxy_sign (self, params);
   g_hash_table_insert (params, "api_sig", sig);
   query = soup_form_encode_hash (params);
 
@@ -353,7 +384,8 @@ flickr_proxy_build_login_url (FlickrProxy *proxy,
  * Returns: %TRUE if this response is successful, %FALSE otherwise.
  */
 gboolean
-flickr_proxy_is_successful (RestXmlNode *root, GError **error)
+flickr_proxy_is_successful (RestXmlNode  *root,
+                            GError      **error)
 {
   RestXmlNode *node;
 
@@ -389,12 +421,12 @@ flickr_proxy_is_successful (RestXmlNode *root, GError **error)
  * Returns: (type FlickrProxyCall) (transfer full): a new #FlickrProxyCall
  */
 RestProxyCall *
-flickr_proxy_new_upload (FlickrProxy *proxy)
+flickr_proxy_new_upload (FlickrProxy *self)
 {
-  g_return_val_if_fail (FLICKR_IS_PROXY (proxy), NULL);
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
 
   return g_object_new (FLICKR_TYPE_PROXY_CALL,
-                       "proxy", proxy,
+                       "proxy", self,
                        "upload", TRUE,
                        NULL);
 }
@@ -417,7 +449,9 @@ flickr_proxy_new_upload (FlickrProxy *proxy)
  * Returns: (type FlickrProxyCall) (transfer full): a new #FlickrProxyCall
  */
 RestProxyCall *
-flickr_proxy_new_upload_for_file (FlickrProxy *proxy, const char *filename, GError **error)
+flickr_proxy_new_upload_for_file (FlickrProxy  *self,
+                                  const char   *filename,
+                                  GError      **error)
 {
   GMappedFile *map;
   GError *err = NULL;
@@ -425,7 +459,7 @@ flickr_proxy_new_upload_for_file (FlickrProxy *proxy, const char *filename, GErr
   RestParam *param;
   RestProxyCall *call = NULL;
 
-  g_return_val_if_fail (FLICKR_IS_PROXY (proxy), NULL);
+  g_return_val_if_fail (FLICKR_IS_PROXY (self), NULL);
   g_return_val_if_fail (filename, NULL);
 
   /* Open the file */
@@ -443,7 +477,7 @@ flickr_proxy_new_upload_for_file (FlickrProxy *proxy, const char *filename, GErr
                                        NULL);
 
   /* Make the call */
-  call = flickr_proxy_new_upload (proxy);
+  call = flickr_proxy_new_upload (self);
   param = rest_param_new_with_owner ("photo",
                                      g_mapped_file_get_contents (map),
                                      g_mapped_file_get_length (map),
diff --git a/rest-extras/flickr-proxy.h b/rest-extras/flickr-proxy.h
index 5cff622..bc13149 100644
--- a/rest-extras/flickr-proxy.h
+++ b/rest-extras/flickr-proxy.h
@@ -4,6 +4,7 @@
  *
  * Authors: Rob Bradford <rob linux intel com>
  *          Ross Burton <ross linux intel com>
+ *          Günther Wagner <info gunibert de>
  * 
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU Lesser General Public License,
@@ -20,81 +21,47 @@
  *
  */
 
-#ifndef _FLICKR_PROXY
-#define _FLICKR_PROXY
+#pragma once
 
 #include <rest/rest-proxy.h>
 #include <rest/rest-xml-parser.h>
 
 G_BEGIN_DECLS
 
+#define FLICKR_PROXY_ERROR flickr_proxy_error_quark()
 #define FLICKR_TYPE_PROXY flickr_proxy_get_type()
 
-#define FLICKR_PROXY(obj) \
-  (G_TYPE_CHECK_INSTANCE_CAST ((obj), FLICKR_TYPE_PROXY, FlickrProxy))
-
-#define FLICKR_PROXY_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_CAST ((klass), FLICKR_TYPE_PROXY, FlickrProxyClass))
-
-#define FLICKR_IS_PROXY(obj) \
-  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FLICKR_TYPE_PROXY))
-
-#define FLICKR_IS_PROXY_CLASS(klass) \
-  (G_TYPE_CHECK_CLASS_TYPE ((klass), FLICKR_TYPE_PROXY))
+G_DECLARE_DERIVABLE_TYPE (FlickrProxy, flickr_proxy, FLICKR, PROXY, RestProxy)
 
-#define FLICKR_PROXY_GET_CLASS(obj) \
-  (G_TYPE_INSTANCE_GET_CLASS ((obj), FLICKR_TYPE_PROXY, FlickrProxyClass))
-
-typedef struct _FlickrProxyPrivate FlickrProxyPrivate;
-
-/**
- * FlickrProxy:
- *
- * #FlickrProxy has no publicly available members.
- */
-typedef struct {
-  RestProxy parent;
-  FlickrProxyPrivate *priv;
-} FlickrProxy;
-
-typedef struct {
+struct _FlickrProxyClass {
   RestProxyClass parent_class;
+
   /*< private >*/
   /* padding for future expansion */
   gpointer _padding_dummy[8];
-} FlickrProxyClass;
-
-#define FLICKR_PROXY_ERROR flickr_proxy_error_quark()
-
-GType flickr_proxy_get_type (void);
-
-RestProxy* flickr_proxy_new (const char *api_key,
-                             const char *shared_secret);
-
-RestProxy* flickr_proxy_new_with_token (const char *api_key,
-                                        const char *shared_secret,
-                                        const char *token);
-
-const char * flickr_proxy_get_api_key (FlickrProxy *proxy);
-
-const char * flickr_proxy_get_shared_secret (FlickrProxy *proxy);
-
-const char * flickr_proxy_get_token (FlickrProxy *proxy);
-
-void flickr_proxy_set_token (FlickrProxy *proxy, const char *token);
-
-char * flickr_proxy_sign (FlickrProxy *proxy, GHashTable *params);
-
-char * flickr_proxy_build_login_url (FlickrProxy *proxy,
-                                     const char  *frob,
-                                     const char  *perms);
-
-gboolean flickr_proxy_is_successful (RestXmlNode *root, GError **error);
-
-RestProxyCall * flickr_proxy_new_upload (FlickrProxy *proxy);
-
-RestProxyCall * flickr_proxy_new_upload_for_file (FlickrProxy *proxy, const char *filename, GError **error);
+};
+
+
+RestProxy     *flickr_proxy_new                 (const char   *api_key,
+                                                 const char   *shared_secret);
+RestProxy     *flickr_proxy_new_with_token      (const char   *api_key,
+                                                 const char   *shared_secret,
+                                                 const char   *token);
+const char    *flickr_proxy_get_api_key         (FlickrProxy  *proxy);
+const char    *flickr_proxy_get_shared_secret   (FlickrProxy  *proxy);
+const char    *flickr_proxy_get_token           (FlickrProxy  *proxy);
+void           flickr_proxy_set_token           (FlickrProxy  *proxy,
+                                                 const char   *token);
+char          *flickr_proxy_sign                (FlickrProxy  *proxy,
+                                                 GHashTable   *params);
+char          *flickr_proxy_build_login_url     (FlickrProxy  *proxy,
+                                                 const char   *frob,
+                                                 const char   *perms);
+gboolean       flickr_proxy_is_successful       (RestXmlNode  *root,
+                                                 GError      **error);
+RestProxyCall *flickr_proxy_new_upload          (FlickrProxy  *proxy);
+RestProxyCall *flickr_proxy_new_upload_for_file (FlickrProxy  *proxy,
+                                                 const char   *filename,
+                                                 GError      **error);
 
 G_END_DECLS
-
-#endif /* _FLICKR_PROXY */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]