[libgit2-glib] Bind very basic GgitProxyOptions
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Bind very basic GgitProxyOptions
- Date: Sat, 4 Feb 2017 22:53:43 +0000 (UTC)
commit cb156cbfd9044fba668ac59f24647c08fa856ffd
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sat Feb 4 17:13:49 2017 +0100
Bind very basic GgitProxyOptions
This is very basic and it should be extended to
add the properties if somebody needs this api.
libgit2-glib/Makefile.am | 2 +
libgit2-glib/ggit-proxy-options.c | 117 +++++++++++++++++++++++++++++++++++++
libgit2-glib/ggit-proxy-options.h | 48 +++++++++++++++
libgit2-glib/ggit-remote.c | 3 +
libgit2-glib/ggit-remote.h | 2 +
5 files changed, 172 insertions(+), 0 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index 8638cda..04f195d 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -59,6 +59,7 @@ H_FILES = \
ggit-object-factory-base.h \
ggit-oid.h \
ggit-patch.h \
+ ggit-proxy-options.h \
ggit-push-options.h \
ggit-rebase-operation.h \
ggit-rebase-options.h \
@@ -130,6 +131,7 @@ C_FILES = \
ggit-object-factory-base.c \
ggit-oid.c \
ggit-patch.c \
+ ggit-proxy-options.c \
ggit-push-options.c \
ggit-rebase-operation.c \
ggit-rebase-options.c \
diff --git a/libgit2-glib/ggit-proxy-options.c b/libgit2-glib/ggit-proxy-options.c
new file mode 100644
index 0000000..a4b6c8b
--- /dev/null
+++ b/libgit2-glib/ggit-proxy-options.c
@@ -0,0 +1,117 @@
+/*
+ * ggit-proxy-options.c
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2017 - Ignacio Casal Quinteiro
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ggit-proxy-options.h"
+
+/**
+ * GgitProxyOptions:
+ *
+ * Represents a git proxy options.
+ */
+
+typedef struct _GgitProxyOptionsPrivate
+{
+ git_proxy_options options;
+} GgitProxyOptionsPrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (GgitProxyOptions, ggit_proxy_options, G_TYPE_OBJECT)
+
+enum
+{
+ PROP_0,
+};
+
+static void
+ggit_proxy_options_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggit_proxy_options_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+ {
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ggit_proxy_options_class_init (GgitProxyOptionsClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->get_property = ggit_proxy_options_get_property;
+ object_class->set_property = ggit_proxy_options_set_property;
+}
+
+static void
+ggit_proxy_options_init (GgitProxyOptions *options)
+{
+ GgitProxyOptionsPrivate *priv;
+
+ priv = ggit_proxy_options_get_instance_private (options);
+
+ git_proxy_init_options (&priv->options, GIT_PROXY_OPTIONS_VERSION);
+}
+
+/**
+ * ggit_proxy_options_new:
+ *
+ * Create a new proxy options object.
+ *
+ * Returns: a #GgitProxyOptions.
+ *
+ **/
+GgitProxyOptions *
+ggit_proxy_options_new ()
+{
+ return g_object_new (GGIT_TYPE_PROXY_OPTIONS, NULL);
+}
+
+const git_proxy_options *
+_ggit_proxy_options_get_proxy_options (GgitProxyOptions *options)
+{
+ if (options != NULL)
+ {
+ GgitProxyOptionsPrivate *priv;
+
+ priv = ggit_proxy_options_get_instance_private (options);
+
+ return &priv->options;
+ }
+
+ return NULL;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-proxy-options.h b/libgit2-glib/ggit-proxy-options.h
new file mode 100644
index 0000000..04597df
--- /dev/null
+++ b/libgit2-glib/ggit-proxy-options.h
@@ -0,0 +1,48 @@
+/*
+ * ggit-push-options.h
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2017 - Ignacio Casal Quinteiro
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GGIT_PROXY_OPTIONS_H__
+#define __GGIT_PROXY_OPTIONS_H__
+
+#include <glib-object.h>
+#include <git2.h>
+
+#include "ggit-types.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_PROXY_OPTIONS (ggit_proxy_options_get_type ())
+G_DECLARE_DERIVABLE_TYPE (GgitProxyOptions, ggit_proxy_options, GGIT, PROXY_OPTIONS, GObject)
+
+struct _GgitProxyOptionsClass
+{
+ GObjectClass parent_class;
+};
+
+const git_proxy_options *
+ _ggit_proxy_options_get_proxy_options (GgitProxyOptions *options);
+
+GgitProxyOptions *ggit_proxy_options_new (void);
+
+G_END_DECLS
+
+#endif /* __GGIT_PROXY_OPTIONS_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-remote.c b/libgit2-glib/ggit-remote.c
index bc98af9..c14f265 100644
--- a/libgit2-glib/ggit-remote.c
+++ b/libgit2-glib/ggit-remote.c
@@ -294,6 +294,7 @@ ggit_remote_get_url (GgitRemote *remote)
* @remote: a #GgitRemote.
* @direction: whether you want to receive or send data.
* @callbacks: the callbacks to use for this connection.
+ * @proxy_options: (allow-none): the proxy options.
* @custom_headers: (allow-none): extra HTTP headers to use in this connection.
* @error: a #GError for error reporting, or %NULL.
*
@@ -306,6 +307,7 @@ void
ggit_remote_connect (GgitRemote *remote,
GgitDirection direction,
GgitRemoteCallbacks *callbacks,
+ GgitProxyOptions *proxy_options,
const gchar * const *custom_headers,
GError **error)
{
@@ -320,6 +322,7 @@ ggit_remote_connect (GgitRemote *remote,
ret = git_remote_connect (_ggit_native_get (remote),
(git_direction)direction,
_ggit_remote_callbacks_get_native (callbacks),
+ proxy_options != NULL ? _ggit_proxy_options_get_proxy_options
(proxy_options) : NULL,
&headers);
if (ret != GIT_OK)
diff --git a/libgit2-glib/ggit-remote.h b/libgit2-glib/ggit-remote.h
index 96af972..5e47dba 100644
--- a/libgit2-glib/ggit-remote.h
+++ b/libgit2-glib/ggit-remote.h
@@ -27,6 +27,7 @@
#include <libgit2-glib/ggit-types.h>
#include <libgit2-glib/ggit-native.h>
#include <libgit2-glib/ggit-remote-callbacks.h>
+#include <libgit2-glib/ggit-proxy-options.h>
G_BEGIN_DECLS
@@ -74,6 +75,7 @@ const gchar *ggit_remote_get_url (GgitRemote *remot
void ggit_remote_connect (GgitRemote *remote,
GgitDirection direction,
GgitRemoteCallbacks *callbacks,
+ GgitProxyOptions *proxy_options,
const gchar * const *custom_headers,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]