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