gs-plugin.h 4.82 KB
Newer Older
1 2
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
3
 * Copyright (C) 2012-2016 Richard Hughes <richard@hughsie.com>
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * 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_H
#define __GS_PLUGIN_H

25
#include <appstream-glib.h>
26 27 28
#include <glib-object.h>
#include <gmodule.h>
#include <gio/gio.h>
29
#include <libsoup/soup.h>
30 31

#include "gs-app.h"
32
#include "gs-app-list.h"
33
#include "gs-auth.h"
34
#include "gs-category.h"
35 36
#include "gs-plugin-event.h"
#include "gs-plugin-types.h"
37 38 39

G_BEGIN_DECLS

40 41 42 43 44 45 46 47 48 49 50
#define GS_TYPE_PLUGIN (gs_plugin_get_type ())

G_DECLARE_DERIVABLE_TYPE (GsPlugin, gs_plugin, GS, PLUGIN, GObject)

struct _GsPluginClass
{
	GObjectClass		 parent_class;
	void			(*updates_changed)	(GsPlugin	*plugin);
	void			(*status_changed)	(GsPlugin	*plugin,
							 GsApp		*app,
							 guint		 status);
51
	void			(*reload)		(GsPlugin	*plugin);
52 53
	void			(*report_event)		(GsPlugin	*plugin,
							 GsPluginEvent	*event);
54 55 56
	void			(*allow_updates)	(GsPlugin	*plugin,
							 gboolean	 allow_updates);
	gpointer		 padding[26];
57 58
};

59
typedef struct	GsPluginData	GsPluginData;
60 61

/* helpers */
62 63 64
#define	GS_PLUGIN_ERROR					gs_plugin_error_quark ()

GQuark		 gs_plugin_error_quark			(void);
65

66 67 68 69
/* public getters and setters */
GsPluginData	*gs_plugin_alloc_data			(GsPlugin	*plugin,
							 gsize		 sz);
GsPluginData	*gs_plugin_get_data			(GsPlugin	*plugin);
70
const gchar	*gs_plugin_get_name			(GsPlugin	*plugin);
71 72 73
const gchar	*gs_plugin_get_appstream_id		(GsPlugin	*plugin);
void		 gs_plugin_set_appstream_id		(GsPlugin	*plugin,
							 const gchar	*appstream_id);
74
gboolean	 gs_plugin_get_enabled			(GsPlugin	*plugin);
75 76
void		 gs_plugin_set_enabled			(GsPlugin	*plugin,
							 gboolean	 enabled);
77 78
gboolean	 gs_plugin_has_flags			(GsPlugin	*plugin,
							 GsPluginFlags	 flags);
79 80 81 82
void		 gs_plugin_add_flags			(GsPlugin	*plugin,
							 GsPluginFlags	 flags);
void		 gs_plugin_remove_flags			(GsPlugin	*plugin,
							 GsPluginFlags	 flags);
83 84
guint		 gs_plugin_get_scale			(GsPlugin	*plugin);
const gchar	*gs_plugin_get_locale			(GsPlugin	*plugin);
85
const gchar	*gs_plugin_get_language			(GsPlugin	*plugin);
86 87
AsProfile	*gs_plugin_get_profile			(GsPlugin	*plugin);
SoupSession	*gs_plugin_get_soup_session		(GsPlugin	*plugin);
88 89
void		 gs_plugin_set_soup_session		(GsPlugin	*plugin,
							 SoupSession	*soup_session);
90 91
void		 gs_plugin_add_auth			(GsPlugin	*plugin,
							 GsAuth		*auth);
92 93
GsAuth		*gs_plugin_get_auth_by_id		(GsPlugin	*plugin,
							 const gchar	*provider_id);
94 95 96
void		 gs_plugin_add_rule			(GsPlugin	*plugin,
							 GsPluginRule	 rule,
							 const gchar	*name);
97 98

/* helpers */
99 100 101 102 103 104 105 106 107 108 109
GBytes		*gs_plugin_download_data		(GsPlugin	*plugin,
							 GsApp		*app,
							 const gchar	*uri,
							 GCancellable	*cancellable,
							 GError		**error);
gboolean	 gs_plugin_download_file		(GsPlugin	*plugin,
							 GsApp		*app,
							 const gchar	*uri,
							 const gchar	*filename,
							 GCancellable	*cancellable,
							 GError		**error);
110
gchar		*gs_plugin_download_rewrite_resource	(GsPlugin	*plugin,
111
							 GsApp		*app,
112 113 114 115
							 const gchar	*resource,
							 GCancellable	*cancellable,
							 GError		**error);

116 117
gboolean	 gs_plugin_check_distro_id		(GsPlugin	*plugin,
							 const gchar	*distro_id);
118 119 120 121 122
GsApp		*gs_plugin_cache_lookup			(GsPlugin	*plugin,
							 const gchar	*key);
void		 gs_plugin_cache_add			(GsPlugin	*plugin,
							 const gchar	*key,
							 GsApp		*app);
123 124
void		 gs_plugin_cache_remove			(GsPlugin	*plugin,
							 const gchar	*key);
125
void		 gs_plugin_cache_invalidate		(GsPlugin	*plugin);
126 127 128
void		 gs_plugin_status_update		(GsPlugin	*plugin,
							 GsApp		*app,
							 GsPluginStatus	 status);
129 130 131
gboolean	 gs_plugin_app_launch			(GsPlugin	*plugin,
							 GsApp		*app,
							 GError		**error);
132
void		 gs_plugin_updates_changed		(GsPlugin	*plugin);
133
void		 gs_plugin_reload			(GsPlugin	*plugin);
134
const gchar	*gs_plugin_status_to_string		(GsPluginStatus	 status);
135 136
void		 gs_plugin_report_event			(GsPlugin	*plugin,
							 GsPluginEvent	*event);
137 138
void		 gs_plugin_set_allow_updates		(GsPlugin	*plugin,
							 gboolean	 allow_updates);
139
gboolean	 gs_plugin_get_network_available	(GsPlugin	*plugin);
140

141 142 143
G_END_DECLS

#endif /* __GS_PLUGIN_H */
144 145

/* vim: set noexpandtab: */