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 glib.ConstructionException;
32 private import glib.Str;
33 private import gobject.ObjectG;
34 private import gtkc.gio;
35 public  import gtkc.giotypes;
36 
37 
38 /**
39  * #GDBusObjectManagerServer is used to export #GDBusObject instances using
40  * the standardized
41  * [org.freedesktop.DBus.ObjectManager](http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager)
42  * interface. For example, remote D-Bus clients can get all objects
43  * and properties in a single call. Additionally, any change in the
44  * object hierarchy is broadcast using signals. This means that D-Bus
45  * clients can keep caches up to date by only listening to D-Bus
46  * signals.
47  * 
48  * See #GDBusObjectManagerClient for the client-side code that is
49  * intended to be used with #GDBusObjectManagerServer or any D-Bus
50  * object implementing the org.freedesktop.DBus.ObjectManager
51  * interface.
52  *
53  * Since: 2.30
54  */
55 public class DBusObjectManagerServer : ObjectG, DBusObjectManagerIF
56 {
57 	/** the main Gtk struct */
58 	protected GDBusObjectManagerServer* gDBusObjectManagerServer;
59 
60 	/** Get the main Gtk struct */
61 	public GDBusObjectManagerServer* getDBusObjectManagerServerStruct()
62 	{
63 		return gDBusObjectManagerServer;
64 	}
65 
66 	/** the main Gtk struct as a void* */
67 	protected override void* getStruct()
68 	{
69 		return cast(void*)gDBusObjectManagerServer;
70 	}
71 
72 	protected override void setStruct(GObject* obj)
73 	{
74 		gDBusObjectManagerServer = cast(GDBusObjectManagerServer*)obj;
75 		super.setStruct(obj);
76 	}
77 
78 	/**
79 	 * Sets our main struct and passes it to the parent class.
80 	 */
81 	public this (GDBusObjectManagerServer* gDBusObjectManagerServer, bool ownedRef = false)
82 	{
83 		this.gDBusObjectManagerServer = gDBusObjectManagerServer;
84 		super(cast(GObject*)gDBusObjectManagerServer, ownedRef);
85 	}
86 
87 	// add the DBusObjectManager capabilities
88 	mixin DBusObjectManagerT!(GDBusObjectManagerServer);
89 
90 
91 	/** */
92 	public static GType getType()
93 	{
94 		return g_dbus_object_manager_server_get_type();
95 	}
96 
97 	/**
98 	 * Creates a new #GDBusObjectManagerServer object.
99 	 *
100 	 * The returned server isn't yet exported on any connection. To do so,
101 	 * use g_dbus_object_manager_server_set_connection(). Normally you
102 	 * want to export all of your objects before doing so to avoid <ulink
103 	 * url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager">InterfacesAdded</ulink>
104 	 * signals being emitted.
105 	 *
106 	 * Params:
107 	 *     objectPath = The object path to export the manager object at.
108 	 *
109 	 * Return: A #GDBusObjectManagerServer object. Free with g_object_unref().
110 	 *
111 	 * Since: 2.30
112 	 *
113 	 * Throws: ConstructionException GTK+ fails to create the object.
114 	 */
115 	public this(string objectPath)
116 	{
117 		auto p = g_dbus_object_manager_server_new(Str.toStringz(objectPath));
118 		
119 		if(p is null)
120 		{
121 			throw new ConstructionException("null returned by new");
122 		}
123 		
124 		this(cast(GDBusObjectManagerServer*) p, true);
125 	}
126 
127 	/**
128 	 * Exports @object on @manager.
129 	 *
130 	 * If there is already a #GDBusObject exported at the object path,
131 	 * then the old object is removed.
132 	 *
133 	 * The object path for @object must be in the hierarchy rooted by the
134 	 * object path for @manager.
135 	 *
136 	 * Note that @manager will take a reference on @object for as long as
137 	 * it is exported.
138 	 *
139 	 * Params:
140 	 *     object = A #GDBusObjectSkeleton.
141 	 *
142 	 * Since: 2.30
143 	 */
144 	public void expor(DBusObjectSkeleton object)
145 	{
146 		g_dbus_object_manager_server_export(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct());
147 	}
148 
149 	/**
150 	 * Like g_dbus_object_manager_server_export() but appends a string of
151 	 * the form _N (with N being a natural number) to @object's object path
152 	 * if an object with the given path already exists. As such, the
153 	 * #GDBusObjectProxy:g-object-path property of @object may be modified.
154 	 *
155 	 * Params:
156 	 *     object = An object.
157 	 *
158 	 * Since: 2.30
159 	 */
160 	public void exportUniquely(DBusObjectSkeleton object)
161 	{
162 		g_dbus_object_manager_server_export_uniquely(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct());
163 	}
164 
165 	/**
166 	 * Gets the #GDBusConnection used by @manager.
167 	 *
168 	 * Return: A #GDBusConnection object or %NULL if
169 	 *     @manager isn't exported on a connection. The returned object should
170 	 *     be freed with g_object_unref().
171 	 *
172 	 * Since: 2.30
173 	 */
174 	public DBusConnection getConnection()
175 	{
176 		auto p = g_dbus_object_manager_server_get_connection(gDBusObjectManagerServer);
177 		
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 		
183 		return ObjectG.getDObject!(DBusConnection)(cast(GDBusConnection*) p, true);
184 	}
185 
186 	/**
187 	 * Returns whether @object is currently exported on @manager.
188 	 *
189 	 * Params:
190 	 *     object = An object.
191 	 *
192 	 * Return: %TRUE if @object is exported
193 	 *
194 	 * Since: 2.34
195 	 */
196 	public bool isExported(DBusObjectSkeleton object)
197 	{
198 		return g_dbus_object_manager_server_is_exported(gDBusObjectManagerServer, (object is null) ? null : object.getDBusObjectSkeletonStruct()) != 0;
199 	}
200 
201 	/**
202 	 * Exports all objects managed by @manager on @connection. If
203 	 * @connection is %NULL, stops exporting objects.
204 	 *
205 	 * Params:
206 	 *     connection = A #GDBusConnection or %NULL.
207 	 */
208 	public void setConnection(DBusConnection connection)
209 	{
210 		g_dbus_object_manager_server_set_connection(gDBusObjectManagerServer, (connection is null) ? null : connection.getDBusConnectionStruct());
211 	}
212 
213 	/**
214 	 * If @manager has an object at @path, removes the object. Otherwise
215 	 * does nothing.
216 	 *
217 	 * Note that @object_path must be in the hierarchy rooted by the
218 	 * object path for @manager.
219 	 *
220 	 * Params:
221 	 *     objectPath = An object path.
222 	 *
223 	 * Return: %TRUE if object at @object_path was removed, %FALSE otherwise.
224 	 *
225 	 * Since: 2.30
226 	 */
227 	public bool unexport(string objectPath)
228 	{
229 		return g_dbus_object_manager_server_unexport(gDBusObjectManagerServer, Str.toStringz(objectPath)) != 0;
230 	}
231 }