1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.DBusObjectManagerServer;
26 
27 private import gio.DBusConnection;
28 private import gio.DBusObjectManagerIF;
29 private import gio.DBusObjectManagerT;
30 private import gio.DBusObjectSkeleton;
31 private import gio.c.functions;
32 public  import gio.c.types;
33 private import glib.ConstructionException;
34 private import glib.Str;
35 private import gobject.ObjectG;
36 public  import gtkc.giotypes;
37 
38 
39 /**
40  * #GDBusObjectManagerServer is used to export #GDBusObject instances using
41  * the standardized
42  * [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
43  * interface. For example, remote D-Bus clients can get all objects
44  * and properties in a single call. Additionally, any change in the
45  * object hierarchy is broadcast using signals. This means that D-Bus
46  * clients can keep caches up to date by only listening to D-Bus
47  * signals.
48  * 
49  * The recommended path to export an object manager at is the path form of the
50  * well-known name of a D-Bus service, or below. For example, if a D-Bus service
51  * is available at the well-known name `net.example.ExampleService1`, the object
52  * manager should typically be exported at `/net/example/ExampleService1`, or
53  * below (to allow for multiple object managers in a service).
54  * 
55  * It is supported, but not recommended, to export an object manager at the root
56  * path, `/`.
57  * 
58  * See #GDBusObjectManagerClient for the client-side code that is
59  * intended to be used with #GDBusObjectManagerServer or any D-Bus
60  * object implementing the org.freedesktop.DBus.ObjectManager
61  * interface.
62  *
63  * Since: 2.30
64  */
65 public class DBusObjectManagerServer : ObjectG, DBusObjectManagerIF
66 {
67 	/** the main Gtk struct */
68 	protected GDBusObjectManagerServer* gDBusObjectManagerServer;
69 
70 	/** Get the main Gtk struct */
71 	public GDBusObjectManagerServer* getDBusObjectManagerServerStruct(bool transferOwnership = false)
72 	{
73 		if (transferOwnership)
74 			ownedRef = false;
75 		return gDBusObjectManagerServer;
76 	}
77 
78 	/** the main Gtk struct as a void* */
79 	protected override void* getStruct()
80 	{
81 		return cast(void*)gDBusObjectManagerServer;
82 	}
83 
84 	/**
85 	 * Sets our main struct and passes it to the parent class.
86 	 */
87 	public this (GDBusObjectManagerServer* gDBusObjectManagerServer, bool ownedRef = false)
88 	{
89 		this.gDBusObjectManagerServer = gDBusObjectManagerServer;
90 		super(cast(GObject*)gDBusObjectManagerServer, ownedRef);
91 	}
92 
93 	// add the DBusObjectManager capabilities
94 	mixin DBusObjectManagerT!(GDBusObjectManagerServer);
95 
96 
97 	/** */
98 	public static GType getType()
99 	{
100 		return g_dbus_object_manager_server_get_type();
101 	}
102 
103 	/**
104 	 * Creates a new #GDBusObjectManagerServer object.
105 	 *
106 	 * The returned server isn't yet exported on any connection. To do so,
107 	 * use g_dbus_object_manager_server_set_connection(). Normally you
108 	 * want to export all of your objects before doing so to avoid
109 	 * [InterfacesAdded](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
110 	 * signals being emitted.
111 	 *
112 	 * Params:
113 	 *     objectPath = The object path to export the manager object at.
114 	 *
115 	 * Returns: A #GDBusObjectManagerServer object. Free with g_object_unref().
116 	 *
117 	 * Since: 2.30
118 	 *
119 	 * Throws: ConstructionException GTK+ fails to create the object.
120 	 */
121 	public this(string objectPath)
122 	{
123 		auto __p = g_dbus_object_manager_server_new(Str.toStringz(objectPath));
124 
125 		if(__p is null)
126 		{
127 			throw new ConstructionException("null returned by new");
128 		}
129 
130 		this(cast(GDBusObjectManagerServer*) __p, true);
131 	}
132 
133 	alias expor = export_;
134 	/**
135 	 * Exports @object on @manager.
136 	 *
137 	 * If there is already a #GDBusObject exported at the object path,
138 	 * then the old object is removed.
139 	 *
140 	 * The object path for @object must be in the hierarchy rooted by the
141 	 * object path for @manager.
142 	 *
143 	 * Note that @manager will take a reference on @object for as long as
144 	 * it is exported.
145 	 *
146 	 * Params:
147 	 *     object = A #GDBusObjectSkeleton.
148 	 *
149 	 * Since: 2.30
150 	 */
151 	public void export_(DBusObjectSkeleton object)
152 	{
153 		g_dbus_object_manager_server_export(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct());
154 	}
155 
156 	/**
157 	 * Like g_dbus_object_manager_server_export() but appends a string of
158 	 * the form _N (with N being a natural number) to @object's object path
159 	 * if an object with the given path already exists. As such, the
160 	 * #GDBusObjectProxy:g-object-path property of @object may be modified.
161 	 *
162 	 * Params:
163 	 *     object = An object.
164 	 *
165 	 * Since: 2.30
166 	 */
167 	public void exportUniquely(DBusObjectSkeleton object)
168 	{
169 		g_dbus_object_manager_server_export_uniquely(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct());
170 	}
171 
172 	/**
173 	 * Gets the #GDBusConnection used by @manager.
174 	 *
175 	 * Returns: A #GDBusConnection object or %NULL if
176 	 *     @manager isn't exported on a connection. The returned object should
177 	 *     be freed with g_object_unref().
178 	 *
179 	 * Since: 2.30
180 	 */
181 	public DBusConnection getConnection()
182 	{
183 		auto __p = g_dbus_object_manager_server_get_connection(gDBusObjectManagerServer);
184 
185 		if(__p is null)
186 		{
187 			return null;
188 		}
189 
190 		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) __p, true);
191 	}
192 
193 	/**
194 	 * Returns whether @object is currently exported on @manager.
195 	 *
196 	 * Params:
197 	 *     object = An object.
198 	 *
199 	 * Returns: %TRUE if @object is exported
200 	 *
201 	 * Since: 2.34
202 	 */
203 	public bool isExported(DBusObjectSkeleton object)
204 	{
205 		return g_dbus_object_manager_server_is_exported(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct()) != 0;
206 	}
207 
208 	/**
209 	 * Exports all objects managed by @manager on @connection. If
210 	 * @connection is %NULL, stops exporting objects.
211 	 *
212 	 * Params:
213 	 *     connection = A #GDBusConnection or %NULL.
214 	 */
215 	public void setConnection(DBusConnection connection)
216 	{
217 		g_dbus_object_manager_server_set_connection(gDBusObjectManagerServer, (connection is null) ? null : connection.getDBusConnectionStruct());
218 	}
219 
220 	/**
221 	 * If @manager has an object at @path, removes the object. Otherwise
222 	 * does nothing.
223 	 *
224 	 * Note that @object_path must be in the hierarchy rooted by the
225 	 * object path for @manager.
226 	 *
227 	 * Params:
228 	 *     objectPath = An object path.
229 	 *
230 	 * Returns: %TRUE if object at @object_path was removed, %FALSE otherwise.
231 	 *
232 	 * Since: 2.30
233 	 */
234 	public bool unexport(string objectPath)
235 	{
236 		return g_dbus_object_manager_server_unexport(gDBusObjectManagerServer, Str.toStringz(objectPath)) != 0;
237 	}
238 }