Commit 7fed04f1 authored by Richard Hughes's avatar Richard Hughes

Add GsPluginRequest to all the plugin loader methods

This allows us to add common parameters to each request without changing the
API every time. It also allows all the different plugin loader actions to share
one thread func, putting all the filter and post-resolve code in one place.

Use this new functionality to add support for max-results and sort_func to
every plugin loader method, which allows us to speed up loading the overview.
parent 6abb6a9a
......@@ -296,13 +296,15 @@ main (int argc, char **argv)
/* do action */
if (argc == 2 && g_strcmp0 (argv[1], "installed") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_installed (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_INSTALLED,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job,
NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
......@@ -310,40 +312,40 @@ main (int argc, char **argv)
}
} else if (argc == 3 && g_strcmp0 (argv[1], "search") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_search (plugin_loader,
argv[2], max_results,
NULL, NULL,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
"search", argv[2],
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
}
}
} else if (argc == 3 && g_strcmp0 (argv[1], "action-upgrade-download") == 0) {
g_autoptr(GsPluginJob) plugin_job = NULL;
app = gs_app_new (argv[2]);
gs_app_set_kind (app, AS_APP_KIND_OS_UPGRADE);
ret = gs_plugin_loader_app_action (plugin_loader,
app,
GS_PLUGIN_ACTION_UPGRADE_DOWNLOAD,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_UPGRADE_DOWNLOAD,
"app", app,
NULL);
ret = gs_plugin_loader_job_action (plugin_loader, plugin_job,
NULL, &error);
if (ret)
gs_app_list_add (list, app);
} else if (argc == 3 && g_strcmp0 (argv[1], "refine") == 0) {
app = gs_app_new (argv[2]);
for (i = 0; i < repeat; i++) {
ret = gs_plugin_loader_app_refine (plugin_loader,
app,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
g_autoptr(GsPluginJob) plugin_job = NULL;
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
"app", app,
NULL);
ret = gs_plugin_loader_job_action (plugin_loader, plugin_job,
NULL, &error);
if (!ret)
break;
}
......@@ -352,23 +354,24 @@ main (int argc, char **argv)
} else if (argc == 3 && g_strcmp0 (argv[1], "launch") == 0) {
app = gs_app_new (argv[2]);
for (i = 0; i < repeat; i++) {
ret = gs_plugin_loader_app_action (plugin_loader,
app,
GS_PLUGIN_ACTION_LAUNCH,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
g_autoptr(GsPluginJob) plugin_job = NULL;
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_LAUNCH,
"app", app,
NULL);
ret = gs_plugin_loader_job_action (plugin_loader, plugin_job,
NULL, &error);
if (!ret)
break;
}
} else if (argc == 3 && g_strcmp0 (argv[1], "filename-to-app") == 0) {
g_autoptr(GsPluginJob) plugin_job = NULL;
file = g_file_new_for_path (argv[2]);
app = gs_plugin_loader_file_to_app (plugin_loader,
file,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_FILE_TO_APP,
"file", file,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
app = gs_plugin_loader_job_process_app (plugin_loader, plugin_job, NULL, &error);
if (app == NULL) {
ret = FALSE;
} else {
......@@ -376,12 +379,14 @@ main (int argc, char **argv)
gs_app_list_add (list, app);
}
} else if (argc == 3 && g_strcmp0 (argv[1], "url-to-app") == 0) {
app = gs_plugin_loader_url_to_app (plugin_loader,
argv[2],
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
g_autoptr(GsPluginJob) plugin_job = NULL;
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_URL_TO_APP,
"search", argv[2],
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
app = gs_plugin_loader_job_process_app (plugin_loader, plugin_job,
NULL, &error);
if (app == NULL) {
ret = FALSE;
} else {
......@@ -390,13 +395,15 @@ main (int argc, char **argv)
}
} else if (argc == 2 && g_strcmp0 (argv[1], "updates") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_updates (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_UPDATES,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job,
NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
......@@ -404,35 +411,43 @@ main (int argc, char **argv)
}
} else if (argc == 2 && g_strcmp0 (argv[1], "upgrades") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_distro_upgrades (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_DISTRO_UPDATES,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job,
NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
}
}
} else if (argc == 2 && g_strcmp0 (argv[1], "sources") == 0) {
list = gs_plugin_loader_get_sources (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
g_autoptr(GsPluginJob) plugin_job = NULL;
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_SOURCES,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader,
plugin_job,
NULL,
&error);
if (list == NULL)
ret = FALSE;
} else if (argc == 2 && g_strcmp0 (argv[1], "popular") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_popular (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_POPULAR,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job,
NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
......@@ -440,13 +455,15 @@ main (int argc, char **argv)
}
} else if (argc == 2 && g_strcmp0 (argv[1], "featured") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_featured (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_FEATURED,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job,
NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
......@@ -454,14 +471,16 @@ main (int argc, char **argv)
}
} else if (argc == 2 && g_strcmp0 (argv[1], "recent") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_recent (plugin_loader,
60 * 60 * 24 * 60,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_RECENT,
"age", 60 * 60 * 24 * 60,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job,
NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
......@@ -469,13 +488,16 @@ main (int argc, char **argv)
}
} else if (argc == 2 && g_strcmp0 (argv[1], "get-categories") == 0) {
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (categories != NULL)
g_ptr_array_unref (categories);
categories = gs_plugin_loader_get_categories (plugin_loader,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_CATEGORIES,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
categories = gs_plugin_loader_job_get_categories (plugin_loader,
plugin_job,
NULL, &error);
if (categories == NULL) {
ret = FALSE;
break;
......@@ -494,14 +516,15 @@ main (int argc, char **argv)
gs_category_add_child (parent, category);
}
for (i = 0; i < repeat; i++) {
g_autoptr(GsPluginJob) plugin_job = NULL;
if (list != NULL)
g_object_unref (list);
list = gs_plugin_loader_get_category_apps (plugin_loader,
category,
refine_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL,
&error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_CATEGORY_APPS,
"category", category,
"refine-flags", refine_flags,
"max-results", max_results,
NULL);
list = gs_plugin_loader_job_process (plugin_loader, plugin_job, NULL, &error);
if (list == NULL) {
ret = FALSE;
break;
......@@ -509,11 +532,14 @@ main (int argc, char **argv)
}
} else if (argc >= 2 && g_strcmp0 (argv[1], "refresh") == 0) {
GsPluginRefreshFlags refresh_flags;
g_autoptr(GsPluginJob) plugin_job = NULL;
refresh_flags = gs_cmd_refresh_flag_from_string (argv[2]);
ret = gs_plugin_loader_refresh (plugin_loader, cache_age,
refresh_flags,
GS_PLUGIN_FAILURE_FLAGS_FATAL_ANY,
NULL, &error);
plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFRESH,
"age", cache_age,
"refresh-flags", refresh_flags,
NULL);
ret = gs_plugin_loader_job_action (plugin_loader, plugin_job,
NULL, &error);
} else {
ret = FALSE;
g_set_error_literal (&error,
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __GS_PLUGIN_JOB_PRIVATE
#define __GS_PLUGIN_JOB_PRIVATE
#include <glib-object.h>
#include "gs-plugin-job.h"
G_BEGIN_DECLS
GsPluginAction gs_plugin_job_get_action (GsPluginJob *self);
GsPluginRefreshFlags gs_plugin_job_get_refresh_flags (GsPluginJob *self);
GsPluginRefineFlags gs_plugin_job_get_refine_flags (GsPluginJob *self);
gboolean gs_plugin_job_has_refine_flags (GsPluginJob *self,
GsPluginRefineFlags refine_flags);
void gs_plugin_job_add_refine_flags (GsPluginJob *self,
GsPluginRefineFlags refine_flags);
void gs_plugin_job_remove_refine_flags (GsPluginJob *self,
GsPluginRefineFlags refine_flags);
GsPluginFailureFlags gs_plugin_job_get_failure_flags (GsPluginJob *self);
guint gs_plugin_job_get_max_results (GsPluginJob *self);
guint64 gs_plugin_job_get_age (GsPluginJob *self);
GsAppListSortFunc gs_plugin_job_get_sort_func (GsPluginJob *self);
gpointer gs_plugin_job_get_sort_func_data (GsPluginJob *self);
const gchar *gs_plugin_job_get_search (GsPluginJob *self);
GsAuth *gs_plugin_job_get_auth (GsPluginJob *self);
GsApp *gs_plugin_job_get_app (GsPluginJob *self);
GsAppList *gs_plugin_job_get_list (GsPluginJob *self);
GFile *gs_plugin_job_get_file (GsPluginJob *self);
GsCategory *gs_plugin_job_get_category (GsPluginJob *self);
AsReview *gs_plugin_job_get_review (GsPluginJob *self);
gchar *gs_plugin_job_to_string (GsPluginJob *self);
void gs_plugin_job_set_action (GsPluginJob *self,
GsPluginAction action);
G_END_DECLS
#endif /* __GS_PLUGIN_JOB_PRIVATE */
/* vim: set noexpandtab: */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include <glib.h>
#include "gs-plugin-private.h"
#include "gs-plugin-job-private.h"
struct _GsPluginJob
{
GObject parent_instance;
GsPluginRefineFlags refine_flags;
GsPluginRefreshFlags refresh_flags;
GsPluginFailureFlags failure_flags;
guint max_results;
guint64 age;
GsPluginAction action;
GsAppListSortFunc sort_func;
gpointer sort_func_data;
gchar *search;
GsAuth *auth;
GsApp *app;
GsAppList *list;
GFile *file;
GsCategory *category;
AsReview *review;
};
enum {
PROP_0,
PROP_ACTION,
PROP_AGE,
PROP_SEARCH,
PROP_REFINE_FLAGS,
PROP_REFRESH_FLAGS,
PROP_FAILURE_FLAGS,
PROP_AUTH,
PROP_APP,
PROP_LIST,
PROP_FILE,
PROP_CATEGORY,
PROP_REVIEW,
PROP_MAX_RESULTS,
PROP_LAST
};
G_DEFINE_TYPE (GsPluginJob, gs_plugin_job, G_TYPE_OBJECT)
gchar *
gs_plugin_job_to_string (GsPluginJob *self)
{
GString *str = g_string_new (NULL);
g_string_append_printf (str, "running %s",
gs_plugin_action_to_string (self->action));
if (self->refine_flags > 0) {
g_autofree gchar *tmp = gs_plugin_refine_flags_to_string (self->refine_flags);
g_string_append_printf (str, " with refine-flags=%s", tmp);
}
if (self->failure_flags > 0) {
g_autofree gchar *tmp = gs_plugin_failure_flags_to_string (self->failure_flags);
g_string_append_printf (str, " with failure-flags=%s", tmp);
}
if (self->age != 0) {
if (self->age == G_MAXUINT) {
g_string_append (str, " with cache age=any");
} else {
g_string_append_printf (str, " with cache age=%" G_GUINT64_FORMAT,
self->age);
}
}
if (self->search != NULL) {
g_string_append_printf (str, " with search=%s",
self->search);
}
if (self->category != NULL) {
GsCategory *parent = gs_category_get_parent (self->category);
if (parent != NULL) {
g_string_append_printf (str, " with category=%s/%s",
gs_category_get_id (parent),
gs_category_get_id (self->category));
} else {
g_string_append_printf (str, " with category=%s",
gs_category_get_id (self->category));
}
}
if (self->review != NULL) {
g_string_append_printf (str, " with review=%s",
as_review_get_id (self->review));
}
if (self->review != NULL) {
g_string_append_printf (str, " with review=%s",
as_review_get_id (self->review));
}
if (self->auth != NULL) {
g_string_append_printf (str, " with auth=%s",
gs_auth_get_provider_id (self->auth));
}
if (self->file != NULL) {
g_autofree gchar *path = g_file_get_path (self->file);
g_string_append_printf (str, " with file=%s", path);
}
if (self->list != NULL && gs_app_list_length (self->list) > 0) {
g_autofree const gchar **unique_ids = NULL;
g_autofree gchar *unique_ids_str = NULL;
unique_ids = g_new0 (const gchar *, gs_app_list_length (self->list) + 1);
for (guint i = 0; i < gs_app_list_length (self->list); i++) {
GsApp *app = gs_app_list_index (self->list, i);
unique_ids[i] = gs_app_get_unique_id (app);
}
unique_ids_str = g_strjoinv (",", (gchar**) unique_ids);
g_string_append_printf (str, " on apps %s", unique_ids_str);
}
return g_string_free (str, FALSE);
}
void
gs_plugin_job_set_refine_flags (GsPluginJob *self, GsPluginRefineFlags refine_flags)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->refine_flags = refine_flags;
}
GsPluginRefineFlags
gs_plugin_job_get_refine_flags (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->refine_flags;
}
void
gs_plugin_job_set_refresh_flags (GsPluginJob *self, GsPluginRefreshFlags refresh_flags)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->refresh_flags = refresh_flags;
}
GsPluginRefreshFlags
gs_plugin_job_get_refresh_flags (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->refresh_flags;
}
gboolean
gs_plugin_job_has_refine_flags (GsPluginJob *self, GsPluginRefineFlags refine_flags)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), FALSE);
return (self->refine_flags & refine_flags) > 0;
}
void
gs_plugin_job_add_refine_flags (GsPluginJob *self, GsPluginRefineFlags refine_flags)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->refine_flags |= refine_flags;
}
void
gs_plugin_job_remove_refine_flags (GsPluginJob *self, GsPluginRefineFlags refine_flags)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->refine_flags &= ~refine_flags;
}
void
gs_plugin_job_set_failure_flags (GsPluginJob *self, GsPluginFailureFlags failure_flags)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->failure_flags = failure_flags;
}
GsPluginFailureFlags
gs_plugin_job_get_failure_flags (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->failure_flags;
}
void
gs_plugin_job_set_max_results (GsPluginJob *self, guint max_results)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->max_results = max_results;
}
guint
gs_plugin_job_get_max_results (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->max_results;
}
void
gs_plugin_job_set_age (GsPluginJob *self, guint64 age)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->age = age;
}
guint64
gs_plugin_job_get_age (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->age;
}
void
gs_plugin_job_set_action (GsPluginJob *self, GsPluginAction action)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->action = action;
}
GsPluginAction
gs_plugin_job_get_action (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->action;
}
void
gs_plugin_job_set_sort_func (GsPluginJob *self, GsAppListSortFunc sort_func)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->sort_func = sort_func;
}
GsAppListSortFunc
gs_plugin_job_get_sort_func (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), 0);
return self->sort_func;
}
void
gs_plugin_job_set_sort_func_data (GsPluginJob *self, gpointer sort_func_data)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
self->sort_func_data = sort_func_data;
}
gpointer
gs_plugin_job_get_sort_func_data (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL);
return self->sort_func_data;
}
void
gs_plugin_job_set_search (GsPluginJob *self, const gchar *search)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
g_free (self->search);
self->search = g_strdup (search);
}
const gchar *
gs_plugin_job_get_search (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL);
return self->search;
}
void
gs_plugin_job_set_auth (GsPluginJob *self, GsAuth *auth)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
g_set_object (&self->auth, auth);
}
GsAuth *
gs_plugin_job_get_auth (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL);
return self->auth;
}
void
gs_plugin_job_set_app (GsPluginJob *self, GsApp *app)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
g_set_object (&self->app, app);
/* ensure we can always operate on a list object */
if (self->list != NULL && app != NULL && gs_app_list_length (self->list) == 0)
gs_app_list_add (self->list, self->app);
}
GsApp *
gs_plugin_job_get_app (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL);
return self->app;
}
void
gs_plugin_job_set_list (GsPluginJob *self, GsAppList *list)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
if (list == NULL)
g_warning ("trying to set list to NULL, not a god idea");
g_set_object (&self->list, list);
}
GsAppList *
gs_plugin_job_get_list (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL);
return self->list;
}
void
gs_plugin_job_set_file (GsPluginJob *self, GFile *file)
{
g_return_if_fail (GS_IS_PLUGIN_JOB (self));
g_set_object (&self->file, file);
}
GFile *
gs_plugin_job_get_file (GsPluginJob *self)
{
g_return_val_if_fail (GS_IS_PLUGIN_JOB (self), NULL);
return self->file;
}