static void cockpit_stream_set_property (GObject *obj, guint prop_id, const GValue *value, GParamSpec *pspec) { CockpitStream *self = COCKPIT_STREAM (obj); switch (prop_id) { case PROP_NAME: self->priv->name = g_value_dup_string (value); break; case PROP_IO_STREAM: self->priv->io = g_value_dup_object (value); break; case PROP_PROBLEM: self->priv->problem = g_value_dup_string (value); if (self->priv->problem) cockpit_close_later (self); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; } }
static void on_connect_stream (GObject *object, GAsyncResult *result, gpointer user_data) { CockpitStream *self = COCKPIT_STREAM (user_data); GError *error = NULL; GIOStream *io; io = cockpit_connect_stream_finish (result, &error); if (error) { set_problem_from_error (self, "couldn't connect", error); close_immediately (self, NULL); g_error_free (error); } else if (!self->priv->closed) { self->priv->io = g_object_ref (io); initialize_io (self); } g_clear_object (&io); g_object_unref (self); }
static void cockpit_stream_constructed (GObject *object) { CockpitStream *self = COCKPIT_STREAM (object); G_OBJECT_CLASS (cockpit_stream_parent_class)->constructed (object); if (self->priv->io) initialize_io (self); }
static void cockpit_stream_dispose (GObject *object) { CockpitStream *self = COCKPIT_STREAM (object); if (!self->priv->closed) close_immediately (self, "terminated"); while (self->priv->out_queue->head) g_bytes_unref (g_queue_pop_head (self->priv->out_queue)); G_OBJECT_CLASS (cockpit_stream_parent_class)->dispose (object); }
static void on_output_closed (GObject *object, GAsyncResult *result, gpointer user_data) { CockpitStream *self = COCKPIT_STREAM (user_data); GError *error = NULL; g_output_stream_close_finish (G_OUTPUT_STREAM (object), result, &error); if (error) { g_warning ("%s: couldn't close output stream: %s", self->priv->name, error->message); close_immediately (self, "internal-error"); } close_maybe (self); g_object_unref (self); }
static void cockpit_stream_finalize (GObject *object) { CockpitStream *self = COCKPIT_STREAM (object); g_assert (self->priv->closed); g_assert (!self->priv->in_source); g_assert (!self->priv->out_source); g_byte_array_unref (self->priv->in_buffer); g_queue_free (self->priv->out_queue); g_free (self->priv->problem); g_free (self->priv->name); if (self->priv->context) g_main_context_unref (self->priv->context); G_OBJECT_CLASS (cockpit_stream_parent_class)->finalize (object); }
static void cockpit_stream_get_property (GObject *obj, guint prop_id, GValue *value, GParamSpec *pspec) { CockpitStream *self = COCKPIT_STREAM (obj); switch (prop_id) { case PROP_NAME: g_value_set_string (value, self->priv->name); break; case PROP_IO_STREAM: g_value_set_object (value, self->priv->io); break; case PROP_PROBLEM: g_value_set_string (value, self->priv->problem); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec); break; } }