Ejemplo n.º 1
0
static void
ppg_restart_task_channel_stopped (GObject      *object,
                                  GAsyncResult *result,
                                  gpointer      user_data)
{
	PpgRestartTaskPrivate *priv;
	PkConnection *conn = (PkConnection *)object;
	PpgRestartTask *restart = (PpgRestartTask *)user_data;
	PpgTask *task = (PpgTask *)user_data;
	GError *error = NULL;
	gint channel;

	g_return_if_fail(PK_IS_CONNECTION(conn));
	g_return_if_fail(PPG_IS_RESTART_TASK(restart));
	g_return_if_fail(PPG_IS_TASK(task));

	priv = restart->priv;

	if (!pk_connection_channel_stop_finish(conn, result, &error)) {
		ppg_task_fail(task, error);
		g_error_free(error);
		return;
	}

	g_object_get(priv->session,
	             "channel", &channel,
	             NULL);

	pk_connection_channel_start_async(conn, channel, NULL,
	                                  ppg_restart_task_channel_started,
	                                  task);
}
Ejemplo n.º 2
0
static void
pkg_channels_page_add_channel_cb (PkConnection    *connection,
                                  GAsyncResult    *result,
                                  PkgChannelsPage *page)
{
	PkgChannelsPagePrivate *priv;
	GError *error = NULL;
	gint channel;

	g_return_if_fail(PK_IS_CONNECTION(connection));
	g_return_if_fail(G_IS_ASYNC_RESULT(result));
	g_return_if_fail(PKG_IS_CHANNELS_PAGE(page));

	ENTRY;
	priv = page->priv;
	if (!pk_connection_manager_add_channel_finish(priv->connection, result,
	                                              &channel, &error)) {
		WARNING(Channels, "Failed to add new channel: %s", error->message);
		pkg_util_dialog_warning(gtk_widget_get_toplevel(GTK_WIDGET(page)),
		                        "",
		                        _("There was an error adding the channel."),
		                        error->message,
		                        TRUE);
		g_error_free(error);
		GOTO(fail);
	}
	DEBUG(Channels, "Added channel %d to system.", channel);
  fail:
	EXIT;
}
Ejemplo n.º 3
0
static void
pkg_window_remove_subscription (PkgWindow    *window,       /* IN */
                                PkConnection *connection,   /* IN */
                                gint          subscription) /* IN */
{
	PkgWindowPrivate *priv;
	GtkTreeIter iter;
	GtkTreeIter child;
	gint id = 0;

	g_return_if_fail(PKG_IS_WINDOW(window));
	g_return_if_fail(PK_IS_CONNECTION(connection));

	ENTRY;
	priv = window->priv;
	if (!pkg_window_get_subscriptions_iter(window, connection, &iter)) {
		EXIT;
	}
	if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(priv->model),
	                                  &child, &iter)) {
		EXIT;
	}
	do {
		gtk_tree_model_get(GTK_TREE_MODEL(priv->model), &child, COLUMN_ID, &id, -1);
		g_debug("%d == %d", id, subscription);
		if (id == subscription) {
			gtk_tree_store_remove(priv->model, &child);
			break;
		}
	} while (gtk_tree_model_iter_next(GTK_TREE_MODEL(priv->model), &child));
	EXIT;
}
Ejemplo n.º 4
0
static gboolean
pkg_window_get_child_iter_with_id (PkgWindow    *window,     /* IN */
                                   PkConnection *connection, /* IN */
                                   GtkTreeIter  *iter,       /* IN */
                                   GtkTreeIter  *child,      /* OUT */
                                   gint          id)         /* IN */
{
	PkgWindowPrivate *priv;
	GtkTreeModel *model;
	gint row_id;

	g_return_val_if_fail(PKG_IS_WINDOW(window), FALSE);
	g_return_val_if_fail(PK_IS_CONNECTION(connection), FALSE);
	g_return_val_if_fail(iter != NULL, FALSE);
	g_return_val_if_fail(child != NULL, FALSE);

	ENTRY;
	priv = window->priv;
	model = GTK_TREE_MODEL(priv->model);
	if (!gtk_tree_model_iter_children(model, child, iter)) {
		RETURN(FALSE);
	}
	do {
		gtk_tree_model_get(model, child, COLUMN_ID, &row_id, -1);
		if (id == row_id) {
			RETURN(TRUE);
		}
	} while (gtk_tree_model_iter_next(model, child));
	RETURN(FALSE);
}
Ejemplo n.º 5
0
void
pkg_window_show_channels (PkgWindow    *window,     /* IN */
                          PkConnection *connection) /* IN */
{
	GtkWidget *page;

	g_return_if_fail(PKG_IS_WINDOW(window));
	g_return_if_fail(PK_IS_CONNECTION(connection));

	ENTRY;
	page = pkg_channels_page_new(connection);
	pkg_window_set_page(window, PKG_PAGE(page));
	EXIT;
}
Ejemplo n.º 6
0
void
pkg_window_show_source (PkgWindow    *window,     /* IN */
                        PkConnection *connection, /* IN */
                        gint          source)     /* IN */
{
	GtkWidget *page;

	g_return_if_fail(PKG_IS_WINDOW(window));
	g_return_if_fail(PK_IS_CONNECTION(connection));

	ENTRY;
	pkg_window_clear_page(window);
	page = pkg_source_page_new(connection, source);
	pkg_window_set_page(window, PKG_PAGE(page));
	EXIT;
}
Ejemplo n.º 7
0
void
pkg_window_show_sources (PkgWindow    *window,     /* IN */
                         PkConnection *connection) /* IN */
{
	GtkWidget *page;

	g_return_if_fail(PKG_IS_WINDOW(window));
	g_return_if_fail(PK_IS_CONNECTION(connection));

	ENTRY;
	page = g_object_new(PKG_TYPE_SOURCES_PAGE,
	                    "connection", connection,
	                    NULL);
	pkg_window_set_page(window, PKG_PAGE(page));
	EXIT;
}
Ejemplo n.º 8
0
/**
 * ppg_memory_instrument_set_handlers_cb:
 * @object: (in): A #PkConnection.
 * @result: (in): A #GAsyncResult.
 * @user_data: (in): User data for closure.
 *
 * Handles an asynchronous request to set the delivery closures for incoming
 * manifests and samples.
 *
 * Returns: None.
 * Side effects: None.
 */
static void
ppg_memory_instrument_set_handlers_cb (GObject *object,
                                       GAsyncResult *result,
                                       gpointer user_data)
{
	PpgMemoryInstrument *instrument = (PpgMemoryInstrument *)user_data;
	PpgMemoryInstrumentPrivate *priv;
	PkConnection *conn = (PkConnection *)object;
	GError *error = NULL;

	g_return_if_fail(PPG_IS_MEMORY_INSTRUMENT(instrument));
	g_return_if_fail(PK_IS_CONNECTION(object));

	priv = instrument->priv;

	if (!pk_connection_subscription_set_handlers_finish(conn, result, &error)) {
		g_critical("Failed to subscribe to subscription: %d", priv->sub);
	}
}
Ejemplo n.º 9
0
/**
 * pk_connection_valid:
 * @connection: a valid #PkConnection instance
 *
 * Return value: %TRUE if packagekitd is running
 **/
gboolean
pk_connection_valid (PkConnection *connection)
{
	DBusError error;
	DBusConnection *conn;
	gboolean ret;
	g_return_val_if_fail (PK_IS_CONNECTION (connection), FALSE);

	/* get raw connection */
	conn = dbus_g_connection_get_connection (connection->priv->connection);
	dbus_error_init (&error);
	ret = dbus_bus_name_has_owner (conn, PK_DBUS_SERVICE, &error);
	if (dbus_error_is_set (&error)) {
		egg_debug ("error: %s", error.message);
		dbus_error_free (&error);
	}

	return ret;
}
Ejemplo n.º 10
0
static void
ppg_restart_task_channel_started (GObject      *object,
                                  GAsyncResult *result,
                                  gpointer      user_data)
{
	PkConnection *conn = (PkConnection *)object;
	PpgTask *task = (PpgTask *)user_data;
	GError *error = NULL;

	g_return_if_fail(PK_IS_CONNECTION(conn));
	g_return_if_fail(PPG_IS_TASK(task));

	if (!pk_connection_channel_start_finish(conn, result, &error)) {
		ppg_task_finish_with_error(task, error);
		g_error_free(error);
		return;
	}

	ppg_task_finish(task);
}
Ejemplo n.º 11
0
static void
pkg_channels_page_get_channels_cb (PkConnection    *connection, /* IN */
                                   GAsyncResult    *result,     /* IN */
                                   PkgChannelsPage *page)       /* IN */
{
	PkgChannelsPagePrivate *priv;
	GtkTreeIter iter;
	GError *error = NULL;
	gint *channels;
	gsize channels_len;
	gchar *idstr;
	gint i;

	g_return_if_fail(PK_IS_CONNECTION(connection));
	g_return_if_fail(G_IS_ASYNC_RESULT(result));
	g_return_if_fail(PKG_IS_CHANNELS_PAGE(page));

	ENTRY;
	priv = page->priv;
	if (!pk_connection_manager_get_channels_finish(connection, result,
	                                               &channels, &channels_len,
	                                               &error)) {
		WARNING(Channels, "Failed to retrieve channels: %s",
		        error->message);
		g_error_free(error);
		EXIT;
	}
	for (i = 0; i < channels_len; i++) {
		idstr = g_strdup_printf("%d", channels[i]);
		gtk_list_store_append(GTK_LIST_STORE(priv->model), &iter);
		gtk_list_store_set(GTK_LIST_STORE(priv->model), &iter,
		                   COLUMN_ID, channels[i],
		                   COLUMN_IDSTR, idstr,
		                   -1);
		g_free(idstr);
	}
	g_free(channels);
	EXIT;
}
Ejemplo n.º 12
0
static void
ppg_restart_task_channel_started (GObject      *object,
                                  GAsyncResult *result,
                                  gpointer      user_data)
{
	PkConnection *conn = (PkConnection *)object;
	PpgTask *task = (PpgTask *)user_data;
	GError *error = NULL;
	GTimeVal tv = { 0 };

	g_return_if_fail(PK_IS_CONNECTION(conn));
	g_return_if_fail(PPG_IS_TASK(task));

	if (!pk_connection_channel_start_finish(conn, result, &tv, &error)) {
		/*
		 * TODO: Notify session of new start time?
		 */
		ppg_task_fail(task, error);
		g_error_free(error);
		return;
	}

	ppg_task_finish(task);
}
Ejemplo n.º 13
0
static void
pkg_window_add_subscription (PkgWindow    *window,       /* IN */
                             PkConnection *connection,   /* IN */
                             gint          subscription) /* IN */
{
	PkgWindowPrivate *priv;
	GtkTreeIter iter;
	GtkTreeIter child;
	gchar *title;

	g_return_if_fail(PKG_IS_WINDOW(window));
	g_return_if_fail(PK_IS_CONNECTION(connection));

	ENTRY;
	priv = window->priv;
	if (!pkg_window_get_subscriptions_iter(window, connection, &iter)) {
		EXIT;
	}
	title = g_strdup_printf(_("Subscription %d"), subscription);
	gtk_tree_store_append(priv->model, &child, &iter);
	gtk_tree_store_set(priv->model, &child,
	                   COLUMN_CONNECTION, connection,
	                   COLUMN_TYPE, TYPE_SUBSCRIPTION,
	                   COLUMN_ID, subscription,
	                   COLUMN_TITLE, title,
	                   COLUMN_SUBTITLE, _("Loading ..."),
	                   -1);
	pk_connection_subscription_get_created_at_async(
			connection, subscription, NULL,
			pkg_window_connection_subscription_get_created_at_cb,
			pkg_window_subscription_call_new(
				window, connection, subscription));
	pkg_window_expand_to_iter(window, &child);
	g_free(title);
	EXIT;
}