gnome-control-center/shell/cc-object-storage.h
Georges Basile Stavracas Neto 083e7bdae6 object-storage: Introduce CcObjectStorage
CcObjectStorage is a cache for GObjects. It is meant to
store objects that are too expensive to be often created,
such as NMClient, GoaClient or D-Bus proxies.

CcObjectStorage has a very strict usage pattern. It is a
programming error to add an object that is already stored,
and so it is to retrieve an object that was not stored.
Stored objects are meant to be kept alive during the whole
lifetime of GNOME Settings, and CcObjectStorage takes a
reference on every stored object to achieve that.

If objects are destroyed while they are cached, it means
we have a reference mismanagement somewhere. In this sense,
CcObjectStorage will act Sam Sheepdog taking care of sneaky
wolves trying to steal their sheep-references.

Next patches will make various panels and objects around
GNOME Settings adopt this new API, and make sure they always
disconnect when destroyed.
2018-04-06 22:23:38 -03:00

65 lines
2.8 KiB
C

/* cc-object-storage.h
*
* Copyright 2018 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
/* Default storage keys */
#define CC_OBJECT_NMCLIENT "CcObjectStorage::nm-client"
#define CC_TYPE_OBJECT_STORAGE (cc_object_storage_get_type())
G_DECLARE_FINAL_TYPE (CcObjectStorage, cc_object_storage, CC, OBJECT_STORAGE, GObject)
gboolean cc_object_storage_has_object (const gchar *key);
void cc_object_storage_add_object (const gchar *key,
gpointer object);
gpointer cc_object_storage_get_object (const gchar *key);
gpointer cc_object_storage_create_dbus_proxy_sync (GBusType bus_type,
GDBusProxyFlags flags,
const gchar *name,
const gchar *path,
const gchar *interface,
GCancellable *cancellable,
GError **error);
void cc_object_storage_create_dbus_proxy (GBusType bus_type,
GDBusProxyFlags flags,
const gchar *name,
const gchar *path,
const gchar *interface,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gpointer cc_object_storage_create_dbus_proxy_finish (GAsyncResult *result,
GError **error);
void cc_object_storage_initialize (void);
void cc_object_storage_destroy (void);
G_END_DECLS