My Project
Loading...
Searching...
No Matches
GioMemory.h
1/*
2 * Copyright (C) 2013-2017 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Pete Woods <pete.woods@canonical.com>
17 */
18
19#ifndef UNITY_UTIL_GIOMEMORY_H
20#define UNITY_UTIL_GIOMEMORY_H
21
22#include <gio/gio.h>
23
24#include <unity/util/GObjectMemory.h>
25
26namespace unity
27{
28
29namespace util
30{
31
32namespace internal
33{
34struct GDBusSignalUnsubscriber
35{
36public:
37 void operator()(guint handle) noexcept
38 {
39 if (handle != 0 && G_IS_OBJECT(bus_.get()))
40 {
41 g_dbus_connection_signal_unsubscribe(bus_.get(), handle);
42 }
43 }
44
45 GObjectSPtr<GDBusConnection> bus_;
46};
47
48}
49
50typedef ResourcePtr<guint, internal::GDBusSignalUnsubscriber> GDBusSignalConnection;
51
63inline GDBusSignalConnection gdbus_signal_connection(guint id, GObjectSPtr<GDBusConnection> bus) noexcept
64{
65 return GDBusSignalConnection(id, internal::GDBusSignalUnsubscriber{bus});
66}
67
68} // namespace until
69
70} // namespace unity
71
72#endif
Top-level namespace for all things Unity-related.
Definition: Version.h:38