[libgit2-glib] More canonical signature for credentials vmethod
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] More canonical signature for credentials vmethod
- Date: Wed, 24 Dec 2014 09:02:00 +0000 (UTC)
commit 3e53b92a28148dce29cd89f10a7d6c09935d4697
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Wed Dec 24 10:01:18 2014 +0100
More canonical signature for credentials vmethod
libgit2-glib/ggit-remote-callbacks.c | 54 +++++++++++++++------------------
libgit2-glib/ggit-remote-callbacks.h | 3 +-
2 files changed, 26 insertions(+), 31 deletions(-)
---
diff --git a/libgit2-glib/ggit-remote-callbacks.c b/libgit2-glib/ggit-remote-callbacks.c
index 9c5f868..a15e999 100644
--- a/libgit2-glib/ggit-remote-callbacks.c
+++ b/libgit2-glib/ggit-remote-callbacks.c
@@ -31,18 +31,6 @@ struct _GgitRemoteCallbacksPrivate
git_remote_callbacks native;
};
-/**
- * GgitRemoteCallbacksClass::credentials:
- * @callbacks:
- * @url:
- * @username_from_url:
- * @allowed_types:
- * @cred: (out):
- * @error:
- *
- * Returns:
- */
-
enum
{
PROGRESS,
@@ -54,6 +42,18 @@ enum
static guint signals[NUM_SIGNALS] = {0,};
+
+/**
+ * GgitRemoteCallbacksClass::credentials:
+ * @callbacks: a #GgitRemoteCallbacks.
+ * @url: the url.
+ * @username_from_url: (allow-none): the username extracted from the url.
+ * @allowed_types: the allowed credential types.
+ * @error: a #GError for error reporting.
+ *
+ * Returns: (transfer full) (nullable): a #GgitCred or %NULL in case of an error.
+ */
+
G_DEFINE_TYPE (GgitRemoteCallbacks, ggit_remote_callbacks, G_TYPE_OBJECT)
static void
@@ -130,28 +130,24 @@ credentials_wrap (git_cred **cred,
void *data)
{
GgitRemoteCallbacks *self = GGIT_REMOTE_CALLBACKS (data);
+ GgitRemoteCallbacksClass *cls = GGIT_REMOTE_CALLBACKS_GET_CLASS (self);
+
+ *cred = NULL;
- if (GGIT_REMOTE_CALLBACKS_GET_CLASS (self)->credentials != NULL)
+ if (cls->credentials != NULL)
{
GgitCred *mcred = NULL;
GError *error = NULL;
- if (GGIT_REMOTE_CALLBACKS_GET_CLASS (self)->credentials (self,
- url,
- username_from_url,
- allowed_types,
- &mcred,
- &error))
- {
- if (mcred != NULL)
- {
- *cred = _ggit_native_release (mcred);
- g_object_unref (mcred);
- }
- else
- {
- *cred = NULL;
- }
+ mcred = cls->credentials (self,
+ url,
+ username_from_url,
+ allowed_types,
+ &error);
+
+ if (mcred != NULL) {
+ *cred = _ggit_native_release (mcred);
+ g_object_unref (mcred);
return GIT_OK;
}
diff --git a/libgit2-glib/ggit-remote-callbacks.h b/libgit2-glib/ggit-remote-callbacks.h
index aa77e24..ff478c3 100644
--- a/libgit2-glib/ggit-remote-callbacks.h
+++ b/libgit2-glib/ggit-remote-callbacks.h
@@ -66,11 +66,10 @@ struct _GgitRemoteCallbacksClass
GgitRemoteCompletionType type);
/* virtual methods */
- gboolean (*credentials) (GgitRemoteCallbacks *callbacks,
+ GgitCred *(*credentials) (GgitRemoteCallbacks *callbacks,
const gchar *url,
const gchar *username_from_url,
GgitCredtype allowed_types,
- GgitCred **cred,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]