1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GIOMM_DBUSWATCHNAME_H 3 #define _GIOMM_DBUSWATCHNAME_H 4 5 6 #include <glibmm/ustring.h> 7 #include <sigc++/sigc++.h> 8 9 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- 10 11 /* Copyright (C) 2010 The giomm Development Team 12 * 13 * This library is free software; you can redistribute it and/or 14 * modify it under the terms of the GNU Lesser General Public 15 * License as published by the Free Software Foundation; either 16 * version 2.1 of the License, or (at your option) any later version. 17 * 18 * This library is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 * Lesser General Public License for more details. 22 * 23 * You should have received a copy of the GNU Lesser General Public 24 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 25 */ 26 27 #include <giomm/dbusconnection.h> 28 29 30 namespace Gio 31 { 32 33 namespace DBus 34 { 35 36 /** @addtogroup giommEnums giomm Enums and Flags */ 37 38 /** 39 * @var BusNameWatcherFlags BUS_NAME_WATCHER_FLAGS_NONE 40 * No flags set. 41 * 42 * @var BusNameWatcherFlags BUS_NAME_WATCHER_FLAGS_AUTO_START 43 * If no-one owns the name when 44 * beginning to watch the name, ask the bus to launch an owner for the 45 * name. 46 * 47 * @enum BusNameWatcherFlags 48 * 49 * Flags used in g_bus_watch_name(). 50 * 51 * @newin{2,26} 52 * 53 * @ingroup giommEnums 54 * @par Bitwise operators: 55 * <tt>%BusNameWatcherFlags operator|(BusNameWatcherFlags, BusNameWatcherFlags)</tt><br> 56 * <tt>%BusNameWatcherFlags operator&(BusNameWatcherFlags, BusNameWatcherFlags)</tt><br> 57 * <tt>%BusNameWatcherFlags operator^(BusNameWatcherFlags, BusNameWatcherFlags)</tt><br> 58 * <tt>%BusNameWatcherFlags operator~(BusNameWatcherFlags)</tt><br> 59 * <tt>%BusNameWatcherFlags& operator|=(BusNameWatcherFlags&, BusNameWatcherFlags)</tt><br> 60 * <tt>%BusNameWatcherFlags& operator&=(BusNameWatcherFlags&, BusNameWatcherFlags)</tt><br> 61 * <tt>%BusNameWatcherFlags& operator^=(BusNameWatcherFlags&, BusNameWatcherFlags)</tt><br> 62 */ 63 enum BusNameWatcherFlags 64 { 65 BUS_NAME_WATCHER_FLAGS_NONE = 0x0, 66 BUS_NAME_WATCHER_FLAGS_AUTO_START = (1<<0) 67 }; 68 69 /** @ingroup giommEnums */ 70 inline BusNameWatcherFlags operator|(BusNameWatcherFlags lhs, BusNameWatcherFlags rhs) 71 { return static_cast<BusNameWatcherFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); } 72 73 /** @ingroup giommEnums */ 74 inline BusNameWatcherFlags operator&(BusNameWatcherFlags lhs, BusNameWatcherFlags rhs) 75 { return static_cast<BusNameWatcherFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); } 76 77 /** @ingroup giommEnums */ 78 inline BusNameWatcherFlags operator^(BusNameWatcherFlags lhs, BusNameWatcherFlags rhs) 79 { return static_cast<BusNameWatcherFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); } 80 81 /** @ingroup giommEnums */ 82 inline BusNameWatcherFlags operator~(BusNameWatcherFlags flags) 83 { return static_cast<BusNameWatcherFlags>(~static_cast<unsigned>(flags)); } 84 85 /** @ingroup giommEnums */ 86 inline BusNameWatcherFlags& operator|=(BusNameWatcherFlags& lhs, BusNameWatcherFlags rhs) 87 { return (lhs = static_cast<BusNameWatcherFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); } 88 89 /** @ingroup giommEnums */ 90 inline BusNameWatcherFlags& operator&=(BusNameWatcherFlags& lhs, BusNameWatcherFlags rhs) 91 { return (lhs = static_cast<BusNameWatcherFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); } 92 93 /** @ingroup giommEnums */ 94 inline BusNameWatcherFlags& operator^=(BusNameWatcherFlags& lhs, BusNameWatcherFlags rhs) 95 { return (lhs = static_cast<BusNameWatcherFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); } 96 97 98 /** For example, 99 * void on_name_appeared(const Glib::RefPtr<Gio::DBus::Connection>& connection, 100 * const Glib::ustring& name, const Glib::ustring& name_owner); 101 * @ingroup DBus 102 */ 103 using SlotNameAppeared = sigc::slot<void, const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring, const Glib::ustring&>; 104 105 /** For example, 106 * void on_name_vanished(const Glib::RefPtr<Gio::DBus::Connection>& connection, 107 * const Glib::ustring& name); 108 * @ingroup DBus 109 */ 110 using SlotNameVanished = sigc::slot<void, const Glib::RefPtr<Gio::DBus::Connection>&, Glib::ustring>; 111 112 //TODO: Add example from C API in class docs? 113 /** Starts watching @a name on the bus specified by @a bus_type and calls 114 * @a name_appeared_slot and @a name_vanished_slot when the name is 115 * known to have a owner respectively known to lose its owner. Callbacks will 116 * be invoked in the thread-default main loop of the thread you are calling 117 * this function from. 118 * 119 * You are guaranteed that one of the slot will be invoked after calling 120 * this function. When you are done watching the name, just call 121 * unwatch_name() with the watcher id this function returns. 122 * 123 * If the name vanishes or appears (for example the application owning the 124 * name could restart), the slot are also invoked. If the Connection 125 * that is used for watching the name disconnects, then @a 126 * name_vanished_slot is invoked since it is no longer possible to access 127 * the name. 128 * 129 * Another guarantee is that invocations of @a name_appeared_slot and @a 130 * name_vanished_slot are guaranteed to alternate; that is, if 131 * @a name_appeared_slot is invoked then you are guaranteed that the next 132 * time one of the slot is invoked, it will be @a name_vanished_slot. 133 * The reverse is also true. 134 * 135 * This behavior makes it very simple to write applications that wants to take 136 * action when a certain name exists, see the C API's Example 9, “Simple 137 * application watching a name” for more information. Basically, the 138 * application should create object proxies in @a name_appeared_slot and 139 * destroy them again (if any) in @a name_vanished_slot. 140 * 141 * @param bus_type The type of bus to watch a name on. 142 * @param name The name (well-known or unique) to watch. 143 * @param name_appeared_slot Slot to invoke when name is known to exist. 144 * @param name_vanished_slot Slot to invoke when name is known to not 145 * exist. 146 * @param flags Flags from the BusNameWatcherFlags enumeration. 147 * @return An identifier (never 0) that can be used with unwatch_name() to 148 * stop watching the name. 149 * 150 * @newin{2,28} 151 * @ingroup DBus 152 */ 153 GIOMM_API 154 guint watch_name( 155 BusType bus_type, 156 const Glib::ustring& name, 157 const SlotNameAppeared& name_appeared_slot = SlotNameAppeared(), 158 const SlotNameVanished& name_vanished_slot = SlotNameVanished(), 159 BusNameWatcherFlags flags = Gio::DBus::BUS_NAME_WATCHER_FLAGS_NONE 160 ); 161 162 163 /** A watch_name() function that takes a Connection instead of a BusType. 164 * 165 * @param connection A Connection. 166 * @param name The name (well-known or unique) to watch. 167 * @param name_appeared_slot Slot to invoke when name is known to exist. 168 * @param name_vanished_slot Slot to invoke when name is known to not 169 * exist. 170 * @param flags Flags from the BusNameWatcherFlags enumeration. 171 * @return An identifier (never 0) that can be used with unwatch_name() to 172 * stop watching the name. 173 * 174 * @newin{2,28} 175 * @ingroup DBus 176 */ 177 GIOMM_API 178 guint watch_name( 179 const Glib::RefPtr<Connection>& connection, 180 const Glib::ustring& name, 181 const SlotNameAppeared& name_appeared_slot = SlotNameAppeared(), 182 const SlotNameVanished& name_vanished_slot = SlotNameVanished(), 183 BusNameWatcherFlags flags = Gio::DBus::BUS_NAME_WATCHER_FLAGS_NONE 184 ); 185 186 187 /** Stops watching a name. 188 * @param watcher_id An identifier obtained from watch_name(). 189 * @ingroup DBus 190 */ 191 GIOMM_API 192 void unwatch_name(guint watcher_id); 193 194 195 } // namespace DBus 196 197 } // namespace Gio 198 199 200 #endif /* _GIOMM_DBUSWATCHNAME_H */ 201 202