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.DBusObjectT;
26 
27 public  import gio.DBusInterface;
28 public  import gio.DBusInterfaceIF;
29 public  import glib.ListG;
30 public  import glib.Str;
31 public  import gobject.ObjectG;
32 public  import gobject.Signals;
33 public  import gtkc.gdktypes;
34 public  import gtkc.gio;
35 public  import gtkc.giotypes;
36 
37 
38 /**
39  * The #GDBusObject type is the base type for D-Bus objects on both
40  * the service side (see #GDBusObjectSkeleton) and the client side
41  * (see #GDBusObjectProxy). It is essentially just a container of
42  * interfaces.
43  */
44 public template DBusObjectT(TStruct)
45 {
46 	/** Get the main Gtk struct */
47 	public GDBusObject* getDBusObjectStruct()
48 	{
49 		return cast(GDBusObject*)getStruct();
50 	}
51 
52 
53 	/**
54 	 * Gets the D-Bus interface with name @interface_name associated with
55 	 * @object, if any.
56 	 *
57 	 * Params:
58 	 *     interfaceName = A D-Bus interface name.
59 	 *
60 	 * Return: %NULL if not found, otherwise a
61 	 *     #GDBusInterface that must be freed with g_object_unref().
62 	 *
63 	 * Since: 2.30
64 	 */
65 	public DBusInterfaceIF getInterface(string interfaceName)
66 	{
67 		auto p = g_dbus_object_get_interface(getDBusObjectStruct(), Str.toStringz(interfaceName));
68 		
69 		if(p is null)
70 		{
71 			return null;
72 		}
73 		
74 		return ObjectG.getDObject!(DBusInterface, DBusInterfaceIF)(cast(GDBusInterface*) p);
75 	}
76 
77 	/**
78 	 * Gets the D-Bus interfaces associated with @object.
79 	 *
80 	 * Return: A list of #GDBusInterface instances.
81 	 *     The returned list must be freed by g_list_free() after each element has been freed
82 	 *     with g_object_unref().
83 	 *
84 	 * Since: 2.30
85 	 */
86 	public ListG getInterfaces()
87 	{
88 		auto p = g_dbus_object_get_interfaces(getDBusObjectStruct());
89 		
90 		if(p is null)
91 		{
92 			return null;
93 		}
94 		
95 		return new ListG(cast(GList*) p);
96 	}
97 
98 	/**
99 	 * Gets the object path for @object.
100 	 *
101 	 * Return: A string owned by @object. Do not free.
102 	 *
103 	 * Since: 2.30
104 	 */
105 	public string getObjectPath()
106 	{
107 		return Str.toString(g_dbus_object_get_object_path(getDBusObjectStruct()));
108 	}
109 
110 	int[string] connectedSignals;
111 
112 	void delegate(DBusInterfaceIF, DBusObjectIF)[] _onInterfaceAddedListeners;
113 	@property void delegate(DBusInterfaceIF, DBusObjectIF)[] onInterfaceAddedListeners()
114 	{
115 		return _onInterfaceAddedListeners;
116 	}
117 	/**
118 	 * Emitted when @interface is added to @object.
119 	 *
120 	 * Params:
121 	 *     iface = The #GDBusInterface that was added.
122 	 *
123 	 * Since: 2.30
124 	 */
125 	void addOnInterfaceAdded(void delegate(DBusInterfaceIF, DBusObjectIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
126 	{
127 		if ( "interface-added" !in connectedSignals )
128 		{
129 			Signals.connectData(
130 				this,
131 				"interface-added",
132 				cast(GCallback)&callBackInterfaceAdded,
133 				cast(void*)cast(DBusObjectIF)this,
134 				null,
135 				connectFlags);
136 			connectedSignals["interface-added"] = 1;
137 		}
138 		_onInterfaceAddedListeners ~= dlg;
139 	}
140 	extern(C) static void callBackInterfaceAdded(GDBusObject* dbusobjectStruct, GDBusInterface* iface, DBusObjectIF _dbusobject)
141 	{
142 		foreach ( void delegate(DBusInterfaceIF, DBusObjectIF) dlg; _dbusobject.onInterfaceAddedListeners )
143 		{
144 			dlg(ObjectG.getDObject!(DBusInterface, DBusInterfaceIF)(iface), _dbusobject);
145 		}
146 	}
147 
148 	void delegate(DBusInterfaceIF, DBusObjectIF)[] _onInterfaceRemovedListeners;
149 	@property void delegate(DBusInterfaceIF, DBusObjectIF)[] onInterfaceRemovedListeners()
150 	{
151 		return _onInterfaceRemovedListeners;
152 	}
153 	/**
154 	 * Emitted when @interface is removed from @object.
155 	 *
156 	 * Params:
157 	 *     iface = The #GDBusInterface that was removed.
158 	 *
159 	 * Since: 2.30
160 	 */
161 	void addOnInterfaceRemoved(void delegate(DBusInterfaceIF, DBusObjectIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
162 	{
163 		if ( "interface-removed" !in connectedSignals )
164 		{
165 			Signals.connectData(
166 				this,
167 				"interface-removed",
168 				cast(GCallback)&callBackInterfaceRemoved,
169 				cast(void*)cast(DBusObjectIF)this,
170 				null,
171 				connectFlags);
172 			connectedSignals["interface-removed"] = 1;
173 		}
174 		_onInterfaceRemovedListeners ~= dlg;
175 	}
176 	extern(C) static void callBackInterfaceRemoved(GDBusObject* dbusobjectStruct, GDBusInterface* iface, DBusObjectIF _dbusobject)
177 	{
178 		foreach ( void delegate(DBusInterfaceIF, DBusObjectIF) dlg; _dbusobject.onInterfaceRemovedListeners )
179 		{
180 			dlg(ObjectG.getDObject!(DBusInterface, DBusInterfaceIF)(iface), _dbusobject);
181 		}
182 	}
183 }