1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY!
2 
3 
4 #include <glibmm.h>
5 
6 #include <giomm/dbuswatchname.h>
7 #include <giomm/private/dbuswatchname_p.h>
8 
9 
10 /* Copyright (C) 2010 The giomm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #include <glibmm/exceptionhandler.h>
27 #include <gio/gio.h>
28 
29 namespace
30 {
31 
32 // Structure to hold the slots registred with watch_name().
33 struct WatchSlots
34 {
35   Gio::DBus::SlotNameAppeared* name_appeared_slot;
36   Gio::DBus::SlotNameVanished* name_vanished_slot;
37 };
38 
39 extern "C" {
40 
41 static void
Bus_Name_Appeared_giomm_callback(GDBusConnection * connection,const gchar * name,const char * name_owner,gpointer data)42 Bus_Name_Appeared_giomm_callback(
43   GDBusConnection* connection, const gchar* name, const char* name_owner, gpointer data)
44 {
45   auto slots = static_cast<WatchSlots*>(data);
46   auto the_slot = slots->name_appeared_slot;
47 
48   try
49   {
50     (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name),
51       Glib::convert_const_gchar_ptr_to_ustring(name_owner));
52   }
53   catch (...)
54   {
55     Glib::exception_handlers_invoke();
56   }
57 }
58 
59 static void
Bus_Name_Vanished_giomm_callback(GDBusConnection * connection,const gchar * name,gpointer data)60 Bus_Name_Vanished_giomm_callback(GDBusConnection* connection, const gchar* name, gpointer data)
61 {
62   auto slots = static_cast<WatchSlots*>(data);
63   auto the_slot = slots->name_vanished_slot;
64 
65   try
66   {
67     (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name));
68   }
69   catch (...)
70   {
71     Glib::exception_handlers_invoke();
72   }
73 }
74 
75 static void
Bus_Watch_Name_giomm_callback_destroy(void * data)76 Bus_Watch_Name_giomm_callback_destroy(void* data)
77 {
78   auto slots = static_cast<WatchSlots*>(data);
79 
80   if (slots->name_appeared_slot)
81     delete slots->name_appeared_slot;
82 
83   if (slots->name_vanished_slot)
84     delete slots->name_vanished_slot;
85 
86   delete slots;
87 }
88 
89 } // extern "C"
90 
91 } // anonymous namespace
92 
93 namespace Gio
94 {
95 
96 namespace DBus
97 {
98 
99 guint
watch_name(BusType bus_type,const Glib::ustring & name,const SlotNameAppeared & name_appeared_slot,const SlotNameVanished & name_vanished_slot,BusNameWatcherFlags flags)100 watch_name(BusType bus_type, const Glib::ustring& name, const SlotNameAppeared& name_appeared_slot,
101   const SlotNameVanished& name_vanished_slot, BusNameWatcherFlags flags)
102 {
103   auto slots = new WatchSlots;
104 
105   // Make copies of the slots which will be deleted on destroy notification.
106   slots->name_appeared_slot = new SlotNameAppeared(name_appeared_slot);
107   slots->name_vanished_slot = new SlotNameVanished(name_vanished_slot);
108 
109   return g_bus_watch_name(static_cast<GBusType>(bus_type), name.c_str(),
110     static_cast<GBusNameWatcherFlags>(flags), &Bus_Name_Appeared_giomm_callback,
111     &Bus_Name_Vanished_giomm_callback, slots, &Bus_Watch_Name_giomm_callback_destroy);
112 }
113 
114 guint
watch_name(const Glib::RefPtr<Connection> & connection,const Glib::ustring & name,const SlotNameAppeared & name_appeared_slot,const SlotNameVanished & name_vanished_slot,BusNameWatcherFlags flags)115 watch_name(const Glib::RefPtr<Connection>& connection, const Glib::ustring& name,
116   const SlotNameAppeared& name_appeared_slot, const SlotNameVanished& name_vanished_slot,
117   BusNameWatcherFlags flags)
118 {
119   auto slots = new WatchSlots;
120 
121   // Make copies of the slots which will be deleted on destroy notification.
122   slots->name_appeared_slot = new SlotNameAppeared(name_appeared_slot);
123   slots->name_vanished_slot = new SlotNameVanished(name_vanished_slot);
124 
125   return g_bus_watch_name_on_connection(Glib::unwrap(connection), name.c_str(),
126     static_cast<GBusNameWatcherFlags>(flags), &Bus_Name_Appeared_giomm_callback,
127     &Bus_Name_Vanished_giomm_callback, slots, &Bus_Watch_Name_giomm_callback_destroy);
128 }
129 
130 void
unwatch_name(guint watcher_id)131 unwatch_name(guint watcher_id)
132 {
133   g_bus_unwatch_name(watcher_id);
134 }
135 
136 } // namespace DBus
137 
138 } // namespace Gio
139 
140 namespace
141 {
142 } // anonymous namespace
143 
144 
145