Ejemplo n.º 1
0
static void
pkg_channel_page_get_working_dir_cb (GObject      *object,    /* IN */
                                     GAsyncResult *result,    /* IN */
                                     gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgChannelPagePrivate *priv;
	gchar *working_dir = NULL;
	gchar *markup;
	GError *error = NULL;

	ENTRY;
	priv = PKG_CHANNEL_PAGE(user_data)->priv;
	if (!pk_connection_channel_get_working_dir_finish(connection, result,
	                                                  &working_dir, &error)) {
		DEBUG(Channel, "Error retrieving channel working-dir: %s",
		      error->message);
		g_error_free(error);
		EXIT;
	}
	if (!IS_NULL_OR_EMPTY(working_dir)) {
		markup = g_markup_printf_escaped("<span size=\"smaller\">%s</span>",
										 working_dir);
		gtk_label_set_markup(GTK_LABEL(priv->working_dir), markup);
		g_free(markup);
	}
	g_free(working_dir);
	EXIT;
}
Ejemplo n.º 2
0
static void
pkg_channel_page_get_env_cb (GObject      *object,    /* IN */
                             GAsyncResult *result,    /* IN */
                             gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgChannelPagePrivate *priv;
	gchar **env;
	gchar *markup;
	gchar *str;

	ENTRY;
	priv = PKG_CHANNEL_PAGE(user_data)->priv;
	if (!pk_connection_channel_get_env_finish(connection, result,
	                                          &env, NULL)) {
		gtk_label_set_text(GTK_LABEL(priv->env), "-");
		EXIT;
	}
	if (g_strv_length(env)) {
		str = g_strjoinv("\n", env);
		markup = g_markup_printf_escaped("<span size=\"smaller\">%s</span>", str);
		gtk_label_set_markup(GTK_LABEL(priv->env), markup);
		g_free(markup);
		g_free(str);
	}
	g_strfreev(env);
	EXIT;
}
Ejemplo n.º 3
0
static void
pkg_channel_page_get_pid_cb (GObject      *object,    /* IN */
                             GAsyncResult *result,    /* IN */
                             gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgChannelPagePrivate *priv;
	GError *error = NULL;
	gchar *str;
	gint pid;

	ENTRY;
	priv = PKG_CHANNEL_PAGE(user_data)->priv;
	if (!pk_connection_channel_get_pid_finish(connection, result,
	                                          &pid, &error)) {
		DEBUG(Channel, "Error retrieving channel pid: %s",
		      error->message);
		g_error_free(error);
		EXIT;
	}
	str = g_markup_printf_escaped("<span size=\"smaller\">%d</span>", pid);
	gtk_label_set_markup(GTK_LABEL(priv->pid), str);
	g_free(str);
	EXIT;
}
Ejemplo n.º 4
0
/**
 * pkg_window_connection_manager_get_hostname_cb:
 * @object: A #PkConnection.
 *
 * Callback which is fired upon receiving the hostname on which an agent runs
 * upon.  Updates the GtkTreeStore containing information about the agent.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
pkg_window_connection_manager_get_hostname_cb (GObject      *object,    /* IN */
                                               GAsyncResult *result,    /* IN */
                                               gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgWindowPrivate *priv;
	gchar *hostname = NULL;
	GError *error = NULL;
	GtkTreeIter iter;

	g_return_if_fail(PKG_IS_WINDOW(user_data));

	ENTRY;
	priv = PKG_WINDOW(user_data)->priv;
	if (!pk_connection_manager_get_hostname_finish(connection, result,
	                                               &hostname, &error)) {
	    WARNING(Connection, "Error retrieving hostname: %s", error->message);
	    g_error_free(error);
	    EXIT;
	}
	if (pkg_window_get_connection_iter(user_data, connection, &iter)) {
		gtk_tree_store_set(priv->model, &iter,
		                   1, hostname,
		                   2, NULL,
		                   -1);
	}
	g_free(hostname);
	EXIT;
}
Ejemplo n.º 5
0
static void
pkg_window_connection_manager_get_sources_cb (GObject      *object,    /* IN */
                                              GAsyncResult *result,    /* IN */
                                              gpointer      user_data) /* IN */
{
	PkConnection *connection;
	PkgWindowPrivate *priv;
	gint *sources;
	gsize sources_len;
	GError *error = NULL;
	gint i;

	g_return_if_fail(PKG_IS_WINDOW(user_data));

	ENTRY;
	priv = PKG_WINDOW(user_data)->priv;
	connection = PK_CONNECTION(object);
	if (!pk_connection_manager_get_sources_finish(connection, result,
	                                              &sources, &sources_len,
	                                              &error)) {
		WARNING(Connection, "Error retrieving sources list: %s",
		        error->message);
		g_error_free(error);
		EXIT;
	}
	for (i = 0; i < sources_len; i++) {
		pkg_window_add_source(user_data, connection, sources[i]);
	}
	g_free(sources);
	EXIT;
}
Ejemplo n.º 6
0
static void
pkg_window_connection_manager_get_plugins_cb (GObject      *object,    /* IN */
                                              GAsyncResult *result,    /* IN */
                                              gpointer      user_data) /* IN */
{
	PkConnection *connection;
	PkgWindowPrivate *priv;
	gchar **plugins = NULL;
	gchar *subtitle = NULL;
	GError *error = NULL;
	GtkTreeIter iter;
	GtkTreeIter child;
	gint len;
	gint i;

	g_return_if_fail(PKG_IS_WINDOW(user_data));

	ENTRY;
	priv = PKG_WINDOW(user_data)->priv;
	connection = PK_CONNECTION(object);
	if (!pk_connection_manager_get_plugins_finish(connection, result,
	                                              &plugins, &error)) {
		WARNING(Connection, "Error retrieving plugin list: %s",
		        error->message);
		g_error_free(error);
		EXIT;
	}
	if (!pkg_window_get_plugins_iter(user_data, connection, &iter)) {
		GOTO(iter_not_found);
	}
	len = g_strv_length(plugins);
	subtitle = g_strdup_printf(P_("%d plugin", "%d plugins", len), len);
	gtk_tree_store_set(priv->model, &iter, COLUMN_SUBTITLE, subtitle, -1);
	for (i = 0; plugins[i]; i++) {
		gchar *desc;
		gtk_tree_store_append(priv->model, &child, &iter);
		gtk_tree_store_set(priv->model, &child,
		                   COLUMN_CONNECTION, connection,
		                   COLUMN_TYPE, TYPE_PLUGIN,
		                   COLUMN_ID, 0,
		                   COLUMN_TITLE, plugins[i],
		                   COLUMN_SUBTITLE, "Show plugin description here",
		                   -1);
		pkg_window_expand_to_iter(user_data, &child);
		if (pk_connection_plugin_get_description(connection, plugins[i], &desc, NULL)) {
			gtk_tree_store_set(priv->model, &child, COLUMN_SUBTITLE, desc, -1);
			g_free(desc);
		}
	}
  iter_not_found:
  	g_free(subtitle);
	g_strfreev(plugins);
	EXIT;
}
Ejemplo n.º 7
0
static void
pkg_channel_page_get_kill_pid_cb (GObject      *object,    /* IN */
                                  GAsyncResult *result,    /* IN */
                                  gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgChannelPagePrivate *priv;
	gboolean kill_pid;

	ENTRY;
	priv = PKG_CHANNEL_PAGE(user_data)->priv;
	if (!pk_connection_channel_get_kill_pid_finish(connection, result,
	                                               &kill_pid, NULL)) {
		EXIT;
	}
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(priv->kill_pid), kill_pid);
	EXIT;
}
Ejemplo n.º 8
0
static void
pkg_window_connection_subscription_get_created_at_cb (GObject      *object,    /* IN */
                                                      GAsyncResult *result,    /* IN */
                                                      gpointer      user_data) /* IN */
{
	PkgWindowSubscriptionCall *call = user_data;
	PkConnection *connection;
	PkgWindowPrivate *priv;
	gchar *subtitle = NULL;
	GError *error = NULL;
	GtkTreeIter iter;
	GtkTreeIter child;
	GDateTime *dt;
	GTimeVal tv;

	g_return_if_fail(user_data != NULL);

	ENTRY;
	priv = call->window->priv;
	connection = PK_CONNECTION(object);
	if (!pk_connection_subscription_get_created_at_finish(connection, result,
	                                                      &tv, &error)) {
		WARNING(Connection, "Error retrieving subscription created-at: %s",
		        error->message);
		g_error_free(error);
		EXIT;
	}
	if (!pkg_window_get_subscriptions_iter(call->window, connection, &iter)) {
		GOTO(iter_not_found);
	}
	if (!pkg_window_get_child_iter_with_id(call->window, connection,
	                                       &iter, &child,
	                                       call->subscription)) {
		GOTO(iter_not_found);
	}
	dt = g_date_time_new_from_timeval_local(&tv);
	subtitle = g_date_time_format(dt, _("Created on %x at %X"));
	g_date_time_unref(dt);
	gtk_tree_store_set(priv->model, &child, COLUMN_SUBTITLE, subtitle, -1);
  iter_not_found:
	pkg_window_subscription_call_free(call);
	g_free(subtitle);
	EXIT;
}
Ejemplo n.º 9
0
static void
pkg_channel_page_get_sources_cb (GObject      *object,    /* IN */
                                 GAsyncResult *result,    /* IN */
                                 gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgChannelPagePrivate *priv;
	gint *sources;
	gsize sources_len = 0;
	gchar *idstr;
	GError *error = NULL;
	GtkTreeIter iter;
	gint i;

	g_return_if_fail(PKG_IS_CHANNEL_PAGE(user_data));

	ENTRY;
	priv = PKG_CHANNEL_PAGE(user_data)->priv;
	if (!pk_connection_channel_get_sources_finish(connection, result,
	                                              &sources, &sources_len,
	                                              &error)) {
	    WARNING(Channel, "Error retrieving channel sources: %s",
	            error->message);
		g_error_free(error);
		EXIT;
	}
	gtk_list_store_clear(priv->model);
	for (i = 0; i < sources_len; i++) {
		idstr = g_strdup_printf("%d", sources[i]);
		gtk_list_store_append(priv->model, &iter);
		gtk_list_store_set(priv->model, &iter,
		                   COLUMN_ID, sources[i],
		                   COLUMN_IDSTR, idstr,
		                   -1);
		g_free(idstr);
		pk_connection_source_get_plugin_async(
				priv->connection, sources[i], NULL,
				pkg_channel_page_source_get_plugin_cb,
				source_call_new(user_data, sources[i]));
	}
	g_free(sources);
	EXIT;
}
Ejemplo n.º 10
0
static void
pkg_window_connection_source_get_plugin_cb (GObject      *object,    /* IN */
                                            GAsyncResult *result,    /* IN */
                                            gpointer      user_data) /* IN */
{
	PkgWindowSourceCall *call = user_data;
	PkConnection *connection;
	PkgWindowPrivate *priv;
	gchar *plugin = NULL;
	GError *error = NULL;
	GtkTreeIter iter;
	GtkTreeIter child;

	g_return_if_fail(user_data != NULL);

	ENTRY;
	priv = call->window->priv;
	connection = PK_CONNECTION(object);
	if (!pk_connection_source_get_plugin_finish(connection, result,
	                                            &plugin, &error)) {
		WARNING(Connection, "Error retrieving subscription created-at: %s",
		        error->message);
		g_error_free(error);
		EXIT;
	}
	if (!pkg_window_get_sources_iter(call->window, connection, &iter)) {
		GOTO(iter_not_found);
	}
	if (!pkg_window_get_child_iter_with_id(call->window, connection,
	                                       &iter, &child, call->source)) {
		GOTO(iter_not_found);
	}
	gtk_tree_store_set(priv->model, &child, COLUMN_SUBTITLE, plugin, -1);
  iter_not_found:
	pkg_window_source_call_free(call);
	g_free(plugin);
	EXIT;
}
Ejemplo n.º 11
0
static void
pkg_channel_page_get_exit_status_cb (GObject      *object,    /* IN */
                                     GAsyncResult *result,    /* IN */
                                     gpointer      user_data) /* IN */
{
	PkConnection *connection = PK_CONNECTION(object);
	PkgChannelPagePrivate *priv;
	gint exit_status;
	gchar *str;

	ENTRY;
	priv = PKG_CHANNEL_PAGE(user_data)->priv;
	if (!pk_connection_channel_get_exit_status_finish(connection, result,
	                                                  &exit_status, NULL)) {
		gtk_label_set_text(GTK_LABEL(priv->exit_status), "-");
		EXIT;
	}
	str = g_markup_printf_escaped("<span size=\"smaller\">%d</span>",
	                              exit_status);
	gtk_label_set_markup(GTK_LABEL(priv->exit_status), str);
	g_free(str);
	EXIT;
}
Ejemplo n.º 12
0
static void
pkg_window_connection_manager_get_channels_cb (GObject      *object,    /* IN */
                                               GAsyncResult *result,    /* IN */
                                               gpointer      user_data) /* IN */
{
	PkgWindowPrivate *priv;
	PkConnection *connection;
	GtkTreeIter iter;
	gint *channels = NULL;
	gsize channels_len = 0;
	GError *error = NULL;
	gint i;

	g_return_if_fail(PKG_IS_WINDOW(user_data));

	ENTRY;
	priv = PKG_WINDOW(user_data)->priv;
	connection = PK_CONNECTION(object);
	if (!pk_connection_manager_get_channels_finish(connection, result,
	                                               &channels, &channels_len,
	                                               &error)) {
		WARNING(Connection, "Error retrieving channel list: %s",
		        error->message);
		g_error_free(error);
		EXIT;
	}
	if (!pkg_window_get_channels_iter(user_data, connection, &iter)) {
		GOTO(failed);
	}
	gtk_tree_store_set(priv->model, &iter, COLUMN_ID, 0, -1);
	for (i = 0; i < channels_len; i++) {
		pkg_window_add_channel(user_data, connection, channels[i]);
	}
  failed:
	g_free(channels);
	EXIT;
}
Ejemplo n.º 13
0
static void
pkg_window_connection_connect_cb (GObject      *object,
                                  GAsyncResult *result,
                                  gpointer      user_data)
{
	PkgWindowPrivate *priv;
	PkConnection *connection;
	GError *error = NULL;
	GtkTreeIter iter;
	GtkTreeIter child;

	g_return_if_fail(PKG_IS_WINDOW(user_data));

	ENTRY;
	priv = PKG_WINDOW(user_data)->priv;
	connection = PK_CONNECTION(object);
	if (!pk_connection_connect_finish(connection, result, &error)) {
		WARNING(Connection, "Error connecting to agent: %s", error->message);
		g_error_free(error);
		EXIT;
	}
	INFO(Connection, "Established connection to agent at: %s.",
	     pk_connection_get_uri(connection));
	if (!pkg_window_get_connection_iter(user_data, connection, &iter)) {
		EXIT;
	}
	gtk_tree_store_append(priv->model, &child, &iter);
	gtk_tree_store_set(priv->model, &child,
		               COLUMN_CONNECTION, connection,
	                   COLUMN_TYPE, TYPE_PLUGINS,
	                   COLUMN_ID, 0,
	                   COLUMN_TITLE, _("Plugins"),
		               COLUMN_SUBTITLE, _("Loading ..."),
	                   -1);
	pkg_window_expand_to_iter(user_data, &child);
	gtk_tree_store_append(priv->model, &child, &iter);
	gtk_tree_store_set(priv->model, &child,
		               COLUMN_CONNECTION, connection,
	                   COLUMN_TYPE, TYPE_CHANNELS,
	                   COLUMN_ID, 0,
	                   COLUMN_TITLE, _("Channels"),
		               COLUMN_SUBTITLE, _("0 channels"),
	                   -1);
	pkg_window_expand_to_iter(user_data, &child);
	gtk_tree_store_append(priv->model, &child, &iter);
	gtk_tree_store_set(priv->model, &child,
		               COLUMN_CONNECTION, connection,
	                   COLUMN_TYPE, TYPE_SOURCES,
	                   COLUMN_ID, 0,
	                   COLUMN_TITLE, _("Sources"),
		               COLUMN_SUBTITLE, _("0 sources"),
	                   -1);
	pkg_window_expand_to_iter(user_data, &child);
	gtk_tree_store_append(priv->model, &child, &iter);
	gtk_tree_store_set(priv->model, &child,
		               COLUMN_CONNECTION, connection,
	                   COLUMN_TYPE, TYPE_SUBSCRIPTIONS,
	                   COLUMN_ID, 0,
	                   COLUMN_TITLE, _("Subscriptions"),
		               COLUMN_SUBTITLE, _("0 subscriptions"),
	                   -1);
	pkg_window_expand_to_iter(user_data, &child);
	pkg_window_refresh_with_iter(user_data,
	                             GTK_TREE_MODEL(priv->model),
	                             &iter);
	/*
	 * TODO: Remove signals on finalize.
	 */
	g_signal_connect(connection, "channel-added",
	                 G_CALLBACK(pkg_window_channel_added_cb),
	                 user_data);
	g_signal_connect(connection, "source-added",
	                 G_CALLBACK(pkg_window_source_added_cb),
	                 user_data);
	g_signal_connect(connection, "source-removed",
	                 G_CALLBACK(pkg_window_source_removed_cb),
	                 user_data);
	g_signal_connect(connection, "subscription-added",
	                 G_CALLBACK(pkg_window_subscription_added_cb),
	                 user_data);
	g_signal_connect(connection, "subscription-removed",
	                 G_CALLBACK(pkg_window_subscription_removed_cb),
	                 user_data);
	EXIT;
}