1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
* vi:set noexpandtab tabstop=8 shiftwidth=8:
*
* Copyright (C) 2012-2016 Richard Hughes <richard@hughsie.com>
* Copyright (C) 2020 Kalev Lember <klember@redhat.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <glib-object.h>
#include <gmodule.h>
#include <gio/gio.h>
#include "gs-app.h"
#include "gs-app-list.h"
#include "gs-app-query.h"
#include "gs-category.h"
#include "gs-plugin-event.h"
#include "gs-plugin-types.h"
G_BEGIN_DECLS
#define GS_TYPE_PLUGIN (gs_plugin_get_type ())
G_DECLARE_DERIVABLE_TYPE (GsPlugin, gs_plugin, GS, PLUGIN, GObject)
/**
* GsPluginClass:
* @adopt_app: (nullable): Called when an app has not been claimed (i.e. a management
* plugin has not been set). (Since: 49)
* @setup_async: (nullable): Setup method for the plugin. This is called after
* the #GsPlugin object is constructed, before it’s used for anything. It
* should do any long-running setup operations which the plugin needs, such as
* file or network access. It may be %NULL if the plugin doesn’t need to be
* explicitly shut down. It is not called if the plugin is disabled during
* construction.
* @setup_finish: (nullable): Finish method for @setup_async. Must be
* implemented if @setup_async is implemented. If this returns an error, the
* plugin will be disabled.
* @shutdown_async: (nullable): Shutdown method for the plugin. This is called
* by the #GsPluginLoader when the process is terminating or the
* #GsPluginLoader is being destroyed. It should be used to cancel or stop any
* ongoing operations or threads in the plugin. It may be %NULL if the plugin
* doesn’t need to be explicitly shut down.
* @shutdown_finish: (nullable): Finish method for @shutdown_async. Must be
* implemented if @shutdown_async is implemented.
* @refine_async: (nullable): Refining looks up and adds data to #GsApps. The
* apps to refine are provided in a list, and the @require_flags specify what data to
* look up and add. Refining certain kinds of data can be very expensive (for
* example, requiring network requests), which is why it’s not all loaded by
* default. By refining multiple apps at once, data requests can be
* batched by the plugin where possible. (Since: 49)
* @refine_finish: (nullable): Finish method for @refine_async. Must be
* implemented if @refine_async is implemented. (Since: 43)
* @list_apps_async: (nullable): List apps matching a given query. (Since: 49)
* @list_apps_finish: (nullable): Finish method for @list_apps_async. Must be
* implemented if @list_apps_async is implemented. (Since: 43)
* @refresh_metadata_async: (nullable): Refresh plugin metadata. (Since: 49)
* @refresh_metadata_finish: (nullable): Finish method for
* @refresh_metadata_async. Must be implemented if @refresh_metadata_async is
* implemented. (Since: 43)
* @list_distro_upgrades_async: (nullable): List available distro upgrades. (Since: 43)
* @list_distro_upgrades_finish: (nullable): Finish method for
* @list_distro_upgrades_async. Must be implemented if
* @list_distro_upgrades_async is implemented. (Since: 43)
* @install_repository_async: (nullable): Install repository. (Since: 49)
* @install_repository_finish: (nullable): Finish method for
* @install_repository_async. Must be implemented if
* @install_repository_async is implemented. (Since: 43)
* @remove_repository_async: (nullable): Remove repository. (Since: 49)
* @remove_repository_finish: (nullable): Finish method for
* @remove_repository_async. Must be implemented if
* @remove_repository_async is implemented. (Since: 43)
* @enable_repository_async: (nullable): Enable repository. (Since: 49)
* @enable_repository_finish: (nullable): Finish method for
* @enable_repository_async. Must be implemented if
* @enable_repository_async is implemented. (Since: 43)
* @disable_repository_async: (nullable): Disable repository. (Since: 49)
* @disable_repository_finish: (nullable): Finish method for
* @disable_repository_async. Must be implemented if
* @disable_repository_async is implemented. (Since: 43)
* @refine_categories_async: (nullable): Refining looks up and adds data to
* #GsCategorys. The categories to refine are provided in a list, and the
* flags specify what data to look up and add. Refining certain kinds of data
* can be very expensive (for example, requiring network requests), which is
* why it’s not all loaded by default. By refining multiple categories at
* once, data requests can be batched by the plugin where possible. (Since: 49)
* @refine_categories_finish: (nullable): Finish method for
* @refine_categories_async. Must be implemented if @refine_categories_async
* is implemented. (Since: 43)
* @update_apps_async: (nullable): Update apps or the OS, or download updates
* ready for installation. (Since: 49)
* @update_apps_finish: (nullable): Finish method for @update_apps_async. Must
* be implemented if @update_apps_async is implemented. (Since: 44)
* @install_apps_async: (nullable): Install apps, or download them ready for
* installation. (Since: 49)
* @install_apps_finish: (nullable): Finish method for @install_apps_async. Must
* be implemented if @install_apps_async is implemented. (Since: 47)
* @uninstall_apps_async: (nullable): Uninstall apps. (Since: 49)
* @uninstall_apps_finish: (nullable): Finish method for @uninstall_apps_async.
* Must be implemented if @uninstall_apps_async is implemented. (Since: 47)
* @cancel_offline_update_async: (nullable): Cancels the pending offline update. (Since: 47)
* @cancel_offline_update_finish: (nullable): Finish method for
* @cancel_offline_update_async. Must be implemented if
* @cancel_offline_update_async is implemented. (Since: 47)
* @download_upgrade_async: (nullable): Start download of a distribution upgrade
* in the background. (Since: 49)
* @download_upgrade_finish: (nullable): Finish method for
* @download_upgrade_async. Must be implemented if
* @download_upgrade_async is implemented. (Since: 47)
* @trigger_upgrade_async: (nullable): Triggers the distribution upgrade to be
* installed on next boot. (Since: 47)
* @trigger_upgrade_finish: (nullable): Finish method for
* @trigger_upgrade_async. Must be implemented if
* @trigger_upgrade_async is implemented. (Since: 47)
* @launch_async: (nullable): Launch the specified app using a plugin-specific method. (Since: 47)
* @launch_finish: (nullable): Finish method for
* @launch_async. Must be implemented if
* @launch_async is implemented. (Since: 47)
* @file_to_app_async: (nullable): Converts a local file to a #GsApp. (Since: 49)
* @file_to_app_finish: (nullable): Finish method for
* @file_to_app_async. Must be implemented if
* @file_to_app_async is implemented. (Since: 47)
* @url_to_app_async: (nullable): Converts a URL to a #GsApp. (Since: 49)
* @url_to_app_finish: (nullable): Finish method for
* @url_to_app_async. Must be implemented if
* @url_to_app_async is implemented. (Since: 47)
*
* The class structure for a #GsPlugin. Virtual methods here should be
* implemented by plugin implementations derived from #GsPlugin to provide their
* plugin-specific behaviour.
*/
struct _GsPluginClass
{
GObjectClass parent_class;
void (*updates_changed) (GsPlugin *plugin);
void (*reload) (GsPlugin *plugin);
void (*report_event) (GsPlugin *plugin,
GsPluginEvent *event);
void (*allow_updates) (GsPlugin *plugin,
gboolean allow_updates);
void (*basic_auth_start) (GsPlugin *plugin,
const gchar *remote,
const gchar *realm,
GCallback callback,
gpointer user_data);
void (*repository_changed) (GsPlugin *plugin,
GsApp *repository);
gboolean (*ask_untrusted) (GsPlugin *plugin,
const gchar *title,
const gchar *msg,
const gchar *details,
const gchar *accept_label);
void (*adopt_app) (GsPlugin *plugin,
GsApp *app);
void (*setup_async) (GsPlugin *plugin,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*setup_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*shutdown_async) (GsPlugin *plugin,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*shutdown_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*refine_async) (GsPlugin *plugin,
GsAppList *list,
GsPluginRefineFlags job_flags,
GsPluginRefineRequireFlags require_flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*refine_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*list_apps_async) (GsPlugin *plugin,
GsAppQuery *query,
GsPluginListAppsFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GsAppList * (*list_apps_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*refresh_metadata_async) (GsPlugin *plugin,
guint64 cache_age_secs,
GsPluginRefreshMetadataFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*refresh_metadata_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*list_distro_upgrades_async) (GsPlugin *plugin,
GsPluginListDistroUpgradesFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GsAppList * (*list_distro_upgrades_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*install_repository_async) (GsPlugin *plugin,
GsApp *repository,
GsPluginManageRepositoryFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*install_repository_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*remove_repository_async) (GsPlugin *plugin,
GsApp *repository,
GsPluginManageRepositoryFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*remove_repository_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*enable_repository_async) (GsPlugin *plugin,
GsApp *repository,
GsPluginManageRepositoryFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*enable_repository_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*disable_repository_async) (GsPlugin *plugin,
GsApp *repository,
GsPluginManageRepositoryFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*disable_repository_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*refine_categories_async) (GsPlugin *plugin,
GPtrArray *list,
GsPluginRefineCategoriesFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*refine_categories_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*update_apps_async) (GsPlugin *plugin,
GsAppList *apps,
GsPluginUpdateAppsFlags flags,
GsPluginProgressCallback progress_callback,
gpointer progress_user_data,
GsPluginEventCallback event_callback,
void *event_user_data,
GsPluginAppNeedsUserActionCallback app_needs_user_action_callback,
gpointer app_needs_user_action_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*update_apps_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*install_apps_async) (GsPlugin *plugin,
GsAppList *apps,
GsPluginInstallAppsFlags flags,
GsPluginProgressCallback progress_callback,
gpointer progress_user_data,
GsPluginEventCallback event_callback,
void *event_user_data,
GsPluginAppNeedsUserActionCallback app_needs_user_action_callback,
gpointer app_needs_user_action_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*install_apps_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*uninstall_apps_async) (GsPlugin *plugin,
GsAppList *apps,
GsPluginUninstallAppsFlags flags,
GsPluginProgressCallback progress_callback,
gpointer progress_user_data,
GsPluginEventCallback event_callback,
void *event_user_data,
GsPluginAppNeedsUserActionCallback app_needs_user_action_callback,
gpointer app_needs_user_action_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*uninstall_apps_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*cancel_offline_update_async) (GsPlugin *plugin,
GsPluginCancelOfflineUpdateFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*cancel_offline_update_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*download_upgrade_async) (GsPlugin *plugin,
GsApp *app,
GsPluginDownloadUpgradeFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*download_upgrade_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*trigger_upgrade_async) (GsPlugin *plugin,
GsApp *app,
GsPluginTriggerUpgradeFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*trigger_upgrade_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*launch_async) (GsPlugin *plugin,
GsApp *app,
GsPluginLaunchFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*launch_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*file_to_app_async) (GsPlugin *plugin,
GFile *file,
GsPluginFileToAppFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GsAppList * (*file_to_app_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void (*url_to_app_async) (GsPlugin *plugin,
const gchar *url,
GsPluginUrlToAppFlags flags,
GsPluginEventCallback event_callback,
void *event_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GsAppList * (*url_to_app_finish) (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
gpointer padding[23];
};
/* helpers */
#define GS_PLUGIN_ERROR gs_plugin_error_quark ()
GQuark gs_plugin_error_quark (void);
/* public getters and setters */
const gchar *gs_plugin_get_name (GsPlugin *plugin);
gboolean gs_plugin_get_enabled (GsPlugin *plugin);
void gs_plugin_set_enabled (GsPlugin *plugin,
gboolean enabled);
guint gs_plugin_get_scale (GsPlugin *plugin);
const gchar *gs_plugin_get_language (GsPlugin *plugin);
void gs_plugin_add_rule (GsPlugin *plugin,
GsPluginRule rule,
const gchar *name);
void gs_plugin_adopt_app (GsPlugin *plugin,
GsApp *app);
/* helpers */
gboolean gs_plugin_check_distro_id (GsPlugin *plugin,
const gchar *distro_id);
GsApp *gs_plugin_cache_lookup (GsPlugin *plugin,
const gchar *key);
void gs_plugin_cache_lookup_by_state (GsPlugin *plugin,
GsAppList *list,
GsAppState state);
void gs_plugin_cache_add (GsPlugin *plugin,
const gchar *key,
GsApp *app);
void gs_plugin_cache_remove (GsPlugin *plugin,
const gchar *key);
void gs_plugin_cache_invalidate (GsPlugin *plugin);
GsAppList *gs_plugin_list_cached (GsPlugin *plugin);
void gs_plugin_app_launch_async (GsPlugin *plugin,
GsApp *app,
GsPluginLaunchFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean gs_plugin_app_launch_finish (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
typedef gboolean (* GsPluginPickDesktopFileCallback) (GsPlugin *plugin,
GsApp *app,
const gchar *filename,
GKeyFile *key_file,
gpointer user_data);
/**
* GsPluginPickDesktopFileCallback:
* @plugin: a #GsPlugin
* @app: a #GsApp
* @filename: a .desktop file name
* @key_file: a #GKeyFile with @filename loaded
* @user_data: callback user data
*
* A callback used by gs_plugin_app_launch_filtered_async() to filter which
* of the candidate .desktop files should be used to launch the @app.
*
* Returns: %TRUE, when the @key_file should be used, %FALSE to continue
* searching.
*
* Since: 43
**/
void gs_plugin_app_launch_filtered_async (GsPlugin *plugin,
GsApp *app,
GsPluginLaunchFlags flags,
GsPluginPickDesktopFileCallback cb,
gpointer cb_user_data,
GCancellable *cancellable,
GAsyncReadyCallback async_callback,
gpointer async_user_data);
gboolean gs_plugin_app_launch_filtered_finish (GsPlugin *plugin,
GAsyncResult *result,
GError **error);
void gs_plugin_updates_changed (GsPlugin *plugin);
void gs_plugin_reload (GsPlugin *plugin);
void gs_plugin_report_event (GsPlugin *plugin,
GsPluginEvent *event);
void gs_plugin_set_allow_updates (GsPlugin *plugin,
gboolean allow_updates);
gboolean gs_plugin_get_network_available (GsPlugin *plugin);
void gs_plugin_basic_auth_start (GsPlugin *plugin,
const gchar *remote,
const gchar *realm,
GCallback callback,
gpointer user_data);
void gs_plugin_repository_changed (GsPlugin *plugin,
GsApp *repository);
void gs_plugin_update_cache_state_for_repository
(GsPlugin *plugin,
GsApp *repository);
gboolean gs_plugin_ask_untrusted (GsPlugin *plugin,
const gchar *title,
const gchar *msg,
const gchar *details,
const gchar *accept_label);
GDBusConnection *gs_plugin_get_session_bus_connection (GsPlugin *self);
GDBusConnection *gs_plugin_get_system_bus_connection (GsPlugin *self);
G_END_DECLS
|