[libgit2-glib] remote: remove the callbacks and all the logic related to it.



commit 79efbd987b3fc4162abf95317d4473b99f11da1d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Jul 1 00:19:42 2015 +0200

    remote: remove the callbacks and all the logic related to it.
    
    The remote no longer stores this configuration.

 libgit2-glib/ggit-remote.c |  266 --------------------------------------------
 libgit2-glib/ggit-remote.h |   12 --
 2 files changed, 0 insertions(+), 278 deletions(-)
---
diff --git a/libgit2-glib/ggit-remote.c b/libgit2-glib/ggit-remote.c
index b7765dc..2899162 100644
--- a/libgit2-glib/ggit-remote.c
+++ b/libgit2-glib/ggit-remote.c
@@ -25,7 +25,6 @@
 #include "ggit-oid.h"
 #include "ggit-ref-spec.h"
 #include "ggit-repository.h"
-#include "ggit-remote-callbacks.h"
 #include "ggit-utils.h"
 #include "ggit-signature.h"
 #include "ggit-transfer-progress.h"
@@ -43,30 +42,8 @@ struct _GgitRemoteHead
 
 struct _GgitRemotePrivate
 {
-       GgitRemoteCallbacks *callbacks;
-       gdouble transfer_progress;
-
-       guint reset_transfer_progress_timeout;
-
-       gulong update_tips_id;
-       gulong transfer_progress_id;
-};
-
-enum
-{
-       PROP_0,
-       PROP_CALLBACKS,
-       PROP_TRANSFER_PROGRESS
-};
-
-enum
-{
-       TIP_UPDATED,
-       NUM_SIGNALS
 };
 
-static guint signals[NUM_SIGNALS] = {0,};
-
 G_DEFINE_TYPE_WITH_PRIVATE (GgitRemote, ggit_remote, GGIT_TYPE_NATIVE)
 G_DEFINE_BOXED_TYPE (GgitRemoteHead, ggit_remote_head, ggit_remote_head_ref, ggit_remote_head_unref)
 
@@ -177,128 +154,17 @@ _ggit_remote_wrap (git_remote *remote)
 }
 
 static void
-clear_callbacks (GgitRemote *remote)
-{
-       if (remote->priv->callbacks)
-       {
-               g_signal_handler_disconnect (remote->priv->callbacks,
-                                            remote->priv->update_tips_id);
-
-               g_signal_handler_disconnect (remote->priv->callbacks,
-                                            remote->priv->transfer_progress_id);
-
-               g_clear_object (&remote->priv->callbacks);
-       }
-}
-
-static void
 ggit_remote_dispose (GObject *object)
 {
-       GgitRemote *remote = GGIT_REMOTE (object);
-       git_remote *native;
-
-       clear_callbacks (remote);
-
-       native = _ggit_native_get (remote);
-
-       if (native)
-       {
-               git_remote_callbacks cb = GIT_REMOTE_CALLBACKS_INIT;
-               git_remote_set_callbacks (native, &cb);
-       }
-
-       if (remote->priv->reset_transfer_progress_timeout != 0)
-       {
-               g_source_remove (remote->priv->reset_transfer_progress_timeout);
-               remote->priv->reset_transfer_progress_timeout = 0;
-       }
-
        G_OBJECT_CLASS (ggit_remote_parent_class)->dispose (object);
 }
 
 static void
-ggit_remote_set_property (GObject      *object,
-                          guint         prop_id,
-                          const GValue *value,
-                          GParamSpec   *pspec)
-{
-       GgitRemote *self = GGIT_REMOTE (object);
-
-       switch (prop_id)
-       {
-               case PROP_CALLBACKS:
-                       ggit_remote_set_callbacks (self, g_value_get_object (value));
-                       break;
-               default:
-                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-                       break;
-       }
-}
-
-static void
-ggit_remote_get_property (GObject    *object,
-                          guint       prop_id,
-                          GValue     *value,
-                          GParamSpec *pspec)
-{
-       GgitRemote *self = GGIT_REMOTE (object);
-
-       switch (prop_id)
-       {
-               case PROP_CALLBACKS:
-                       g_value_set_object (value, self->priv->callbacks);
-                       break;
-               case PROP_TRANSFER_PROGRESS:
-                       g_value_set_double (value, self->priv->transfer_progress);
-                       break;
-               default:
-                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-                       break;
-       }
-}
-
-static void
 ggit_remote_class_init (GgitRemoteClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
        object_class->dispose = ggit_remote_dispose;
-
-       object_class->get_property = ggit_remote_get_property;
-       object_class->set_property = ggit_remote_set_property;
-
-       g_object_class_install_property (object_class,
-                                        PROP_CALLBACKS,
-                                        g_param_spec_object ("callbacks",
-                                                             "Callbacks",
-                                                             "Callbacks",
-                                                             GGIT_TYPE_REMOTE_CALLBACKS,
-                                                             G_PARAM_READWRITE |
-                                                             G_PARAM_STATIC_STRINGS |
-                                                             G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_TRANSFER_PROGRESS,
-                                        g_param_spec_double ("transfer-progress",
-                                                             "Transfer Progress",
-                                                             "Transfer Progress",
-                                                             0,
-                                                             1,
-                                                             0,
-                                                             G_PARAM_READABLE |
-                                                             G_PARAM_STATIC_STRINGS));
-       signals[TIP_UPDATED] =
-               g_signal_new ("tip-updated",
-                             G_TYPE_FROM_CLASS (object_class),
-                             G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GgitRemoteClass, tip_updated),
-                             NULL, NULL,
-                             NULL,
-                             G_TYPE_NONE,
-                             3,
-                             G_TYPE_STRING,
-                             GGIT_TYPE_OID,
-                             GGIT_TYPE_OID);
 }
 
 static void
@@ -307,65 +173,6 @@ ggit_remote_init (GgitRemote *self)
        self->priv = ggit_remote_get_instance_private (self);
 }
 
-static gboolean
-reset_transfer_progress_impl (GgitRemote *remote)
-{
-       remote->priv->reset_transfer_progress_timeout = 0;
-
-       remote->priv->transfer_progress = 0;
-       g_object_notify (G_OBJECT (remote), "transfer_progress");
-
-       return FALSE;
-}
-
-static void
-reset_transfer_progress (GgitRemote *remote,
-                         gboolean    with_delay)
-{
-       if (remote->priv->transfer_progress == 0)
-       {
-               return;
-       }
-
-       if (with_delay)
-       {
-               remote->priv->reset_transfer_progress_timeout =
-                       g_timeout_add (500,
-                                      (GSourceFunc)reset_transfer_progress_impl,
-                                      remote);
-       }
-       else if (remote->priv->reset_transfer_progress_timeout == 0)
-       {
-               reset_transfer_progress_impl (remote);
-       }
-}
-
-static void
-callbacks_update_tips (GgitRemote    *remote,
-                       const gchar   *refname,
-                       const GgitOId *a,
-                       const GgitOId *b)
-{
-       g_signal_emit (remote, signals[TIP_UPDATED], 0, refname, a, b);
-}
-
-static void
-callbacks_transfer_progress (GgitRemote           *remote,
-                             GgitTransferProgress *progress)
-{
-       guint total = ggit_transfer_progress_get_total_objects (progress);
-       guint received = ggit_transfer_progress_get_received_objects (progress);
-       guint indexed = ggit_transfer_progress_get_indexed_objects (progress);
-
-       remote->priv->transfer_progress = (gdouble)(received + indexed) / (gdouble)(total + total);
-       g_object_notify (G_OBJECT (remote), "transfer-progress");
-
-       if (received == total && indexed == total)
-       {
-               reset_transfer_progress (remote, TRUE);
-       }
-}
-
 /**
  * ggit_remote_new:
  * @repository: a #GgitRepository.
@@ -508,11 +315,6 @@ ggit_remote_connect (GgitRemote     *remote,
        g_return_if_fail (GGIT_IS_REMOTE (remote));
        g_return_if_fail (error == NULL || *error == NULL);
 
-       if (!ggit_remote_get_connected (remote))
-       {
-               reset_transfer_progress (remote, FALSE);
-       }
-
        ret = git_remote_connect (_ggit_native_get (remote), direction);
 
        if (ret != GIT_OK)
@@ -550,8 +352,6 @@ ggit_remote_disconnect (GgitRemote *remote)
        g_return_if_fail (GGIT_IS_REMOTE (remote));
 
        git_remote_disconnect (_ggit_native_get (remote));
-
-       reset_transfer_progress (remote, TRUE);
 }
 
 /**
@@ -579,15 +379,11 @@ ggit_remote_download (GgitRemote           *remote,
        g_return_val_if_fail (GGIT_IS_REMOTE (remote), FALSE);
        g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-       reset_transfer_progress (remote, FALSE);
-
        ggit_utils_get_git_strarray_from_str_array (specs, &gspecs);
 
        ret = git_remote_download (_ggit_native_get (remote), &gspecs,
                                   _ggit_fetch_options_get_fetch_options (fetch_options));
 
-       reset_transfer_progress (remote, TRUE);
-
        if (ret != GIT_OK)
        {
                _ggit_error_set (error, ret);
@@ -833,66 +629,4 @@ ggit_remote_list (GgitRemote              *remote,
        return retval;
 }
 
-/**
- * ggit_remote_get_callbacks:
- * @remote: a #GgitRemote.
- *
- * Returns: (transfer none): the remote callbacks.
- */
-GgitRemoteCallbacks *
-ggit_remote_get_callbacks (GgitRemote *remote)
-{
-       g_return_val_if_fail (GGIT_IS_REMOTE (remote), NULL);
-
-       return remote->priv->callbacks;
-}
-
-/**
- * ggit_remote_set_callbacks:
- * @remote: a #GgitRemote.
- * @callbacks: (allow-none): a #GgitRemoteCallbacks, or %NULL.
- *
- * Set the remote callbacks.
- */
-void
-ggit_remote_set_callbacks (GgitRemote          *remote,
-                           GgitRemoteCallbacks *callbacks)
-{
-       g_return_if_fail (GGIT_IS_REMOTE (remote));
-       g_return_if_fail (callbacks == NULL || GGIT_IS_REMOTE_CALLBACKS (callbacks));
-
-       if (callbacks != NULL && callbacks == remote->priv->callbacks)
-       {
-               return;
-       }
-
-       clear_callbacks (remote);
-
-       if (!callbacks)
-       {
-               /* Always create a dummy callbacks anyway, since:
-                * 1. libgit2 assumes there always is one
-                * 2. We want to proxy update-tips
-                */
-               callbacks = g_object_new (GGIT_TYPE_REMOTE_CALLBACKS, NULL);
-       }
-
-       remote->priv->callbacks = g_object_ref (callbacks);
-
-       git_remote_set_callbacks (_ggit_native_get (remote),
-                                 _ggit_remote_callbacks_get_native (callbacks));
-
-       remote->priv->update_tips_id = g_signal_connect_swapped (callbacks,
-                                                                "update-tips",
-                                                                G_CALLBACK (callbacks_update_tips),
-                                                                remote);
-
-       remote->priv->transfer_progress_id = g_signal_connect_swapped (callbacks,
-                                                                      "transfer-progress",
-                                                                      G_CALLBACK 
(callbacks_transfer_progress),
-                                                                      remote);
-
-       g_object_notify (G_OBJECT (remote), "callbacks");
-}
-
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-remote.h b/libgit2-glib/ggit-remote.h
index 0647b29..bb02285 100644
--- a/libgit2-glib/ggit-remote.h
+++ b/libgit2-glib/ggit-remote.h
@@ -53,12 +53,6 @@ struct _GgitRemoteClass
 {
        /*< private >*/
        GgitNativeClass parent_class;
-
-       /* < signals > */
-       void (*tip_updated) (GgitRemote    *remote,
-                            const gchar   *refname,
-                            const GgitOId *a,
-                            const GgitOId *b);
 };
 
 #define GGIT_TYPE_REMOTE_HEAD   (ggit_remote_head_get_type ())
@@ -131,12 +125,6 @@ gboolean           ggit_remote_set_push_specs           (GgitRemote           *r
 GgitRemoteHead   **ggit_remote_list                     (GgitRemote       *remote,
                                                          GError          **error);
 
-GgitRemoteCallbacks *
-                   ggit_remote_get_callbacks            (GgitRemote       *remote);
-
-void               ggit_remote_set_callbacks            (GgitRemote       *remote,
-                                                         GgitRemoteCallbacks *callbacks);
-
 G_END_DECLS
 
 #endif /* __GGIT_REMOTE_H__ */


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