summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno da Silva Belo <brunodasilvabelo@gmail.com>2019-10-16 10:50:10 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-16 10:55:34 -0300
commite6bffe1e2b65eb4625a16c32fee0d37b2c2aafc8 (patch)
treeb01f9f0552d930e73da6221d97dfce9fddfa3321
parentee33f93743b41c82543f8857e72e38e60a5cd67f (diff)
csharp: updating eldbus_connection docs.
Summary: ref T8361 Reviewers: lauromoura, felipealmeida, segfaultxavi, woohyun Reviewed By: lauromoura Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8361 Differential Revision: https://phab.enlightenment.org/D10418
-rw-r--r--src/bindings/mono/eldbus_mono/eldbus_connection.cs151
1 files changed, 147 insertions, 4 deletions
diff --git a/src/bindings/mono/eldbus_mono/eldbus_connection.cs b/src/bindings/mono/eldbus_mono/eldbus_connection.cs
index 18ec10f..6a75bb9 100644
--- a/src/bindings/mono/eldbus_mono/eldbus_connection.cs
+++ b/src/bindings/mono/eldbus_mono/eldbus_connection.cs
@@ -2,12 +2,14 @@
2 2
3using System; 3using System;
4using System.Runtime.InteropServices; 4using System.Runtime.InteropServices;
5using System.ComponentModel;
5 6
6using static eldbus.EldbusConnectionNativeFunctions; 7using static eldbus.EldbusConnectionNativeFunctions;
7 8
8namespace eldbus 9namespace eldbus
9{ 10{
10 11
12[EditorBrowsable(EditorBrowsableState.Never)]
11public static class EldbusConnectionNativeFunctions 13public static class EldbusConnectionNativeFunctions
12{ 14{
13 [DllImport(efl.Libs.Eldbus)] public static extern IntPtr 15 [DllImport(efl.Libs.Eldbus)] public static extern IntPtr
@@ -89,22 +91,55 @@ public static class EldbusConnectionNativeFunctions
89} 91}
90 92
91/// <summary>Represents a DBus connection. 93/// <summary>Represents a DBus connection.
92/// 94/// <para>Since EFL 1.23.</para>
93/// Since EFL 1.23.
94/// </summary> 95/// </summary>
95public class Connection : IDisposable 96public class Connection : IDisposable
96{ 97{
98 /// <summary>
99 /// The type of the Connection.
100 /// <para>Since EFL 1.23.</para>
101 /// </summary>
97 public enum Type 102 public enum Type
98 { 103 {
104 /// <summary>
105 /// Unknown type.
106 /// <para>It's a sentinel.</para>
107 /// <para>Since EFL 1.23.</para>
108 /// </summary>
99 Unknown = 0, // sentinel, not a real type 109 Unknown = 0, // sentinel, not a real type
110 /// <summary>
111 /// Session type.
112 /// <para>Since EFL 1.23.</para>
113 /// </summary>
100 Session, 114 Session,
115 /// <summary>
116 /// System type.
117 /// <para>Since EFL 1.23.</para>
118 /// </summary>
101 System, 119 System,
120 /// <summary>
121 /// Starter type.
122 /// <para>Since EFL 1.23.</para>
123 /// </summary>
102 Starter, 124 Starter,
125 /// <summary>
126 /// Address type.
127 /// <para>Since EFL 1.23.</para>
128 /// </summary>
103 Address, 129 Address,
130 /// <summary>
131 /// Last type.
132 /// <para>It's a sentinel.</para>
133 /// <para>Since EFL 1.23.</para>
134 /// </summary>
104 Last // sentinel, not a real type 135 Last // sentinel, not a real type
105 }; 136 };
106 137
138 [EditorBrowsable(EditorBrowsableState.Never)]
107 public IntPtr Handle {get;set;} = IntPtr.Zero; 139 public IntPtr Handle {get;set;} = IntPtr.Zero;
140 /// <summary>Whether this wrapper owns the native handle.
141 /// <para>Since EFL 1.23.</para>
142 /// </summary>
108 public bool Own {get;set;} = true; 143 public bool Own {get;set;} = true;
109 144
110 private void InitNew(IntPtr handle, bool own) 145 private void InitNew(IntPtr handle, bool own)
@@ -122,38 +157,67 @@ public class Connection : IDisposable
122 } 157 }
123 } 158 }
124 159
160 [EditorBrowsable(EditorBrowsableState.Never)]
125 public Connection(IntPtr handle, bool own) 161 public Connection(IntPtr handle, bool own)
126 { 162 {
127 InitNew(handle, own); 163 InitNew(handle, own);
128 } 164 }
129 165
130 166 /// <summary>
167 /// Constructor.
168 /// <para>Since EFL 1.23.</para>
169 /// </summary>
170 /// <param name="type">The type of the connection.</param>
131 public Connection(eldbus.Connection.Type type) 171 public Connection(eldbus.Connection.Type type)
132 { 172 {
133 InitNew(eldbus_connection_get(type), true); 173 InitNew(eldbus_connection_get(type), true);
134 } 174 }
135 175
176 /// <summary>
177 /// Constructor.
178 /// <para>Since EFL 1.23.</para>
179 /// </summary>
180 /// <param name="address">The address of the connection.</param>
136 public Connection(string address) 181 public Connection(string address)
137 { 182 {
138 InitNew(eldbus_address_connection_get(address), true); 183 InitNew(eldbus_address_connection_get(address), true);
139 } 184 }
140 185
186 /// <summary>
187 /// Gets a Connection with a type.
188 /// <para>Since EFL 1.23.</para>
189 /// </summary>
190 /// <param name="type"></param>
191 /// <returns>A Connection with the type.</returns>
141 public static eldbus.Connection GetPrivate(eldbus.Connection.Type type) 192 public static eldbus.Connection GetPrivate(eldbus.Connection.Type type)
142 { 193 {
143 return new eldbus.Connection(eldbus_private_connection_get(type), true); 194 return new eldbus.Connection(eldbus_private_connection_get(type), true);
144 } 195 }
145 196
197 /// <summary>
198 /// Gets a Connection with a address.
199 /// <para>Since EFL 1.23.</para>
200 /// </summary>
201 /// <param name="address">The address of the connection.</param>
146 public static eldbus.Connection GetPrivate(string address) 202 public static eldbus.Connection GetPrivate(string address)
147 { 203 {
148 return new eldbus.Connection(eldbus_private_address_connection_get(address), true); 204 return new eldbus.Connection(eldbus_private_address_connection_get(address), true);
149 } 205 }
150 206
151 207 /// <summary>
208 /// Finalizer to be called from the Garbage Collector.
209 /// <para>Since EFL 1.23.</para>
210 /// </summary>
152 ~Connection() 211 ~Connection()
153 { 212 {
154 Dispose(false); 213 Dispose(false);
155 } 214 }
156 215
216 /// <summary>Disposes of this wrapper, releasing the native array if owned.
217 /// <para>Since EFL 1.23.</para>
218 /// </summary>
219 /// <param name="disposing">True if this was called from <see cref="Dispose()"/> public method. False if
220 /// called from the C# finalizer.</param>
157 protected virtual void Dispose(bool disposing) 221 protected virtual void Dispose(bool disposing)
158 { 222 {
159 IntPtr h = Handle; 223 IntPtr h = Handle;
@@ -176,17 +240,28 @@ public class Connection : IDisposable
176 } 240 }
177 } 241 }
178 242
243 /// <summary>Releases the native resources held by this instance.
244 /// <para>Since EFL 1.23.</para>
245 /// </summary>
179 public void Dispose() 246 public void Dispose()
180 { 247 {
181 Dispose(true); 248 Dispose(true);
182 GC.SuppressFinalize(this); 249 GC.SuppressFinalize(this);
183 } 250 }
184 251
252 /// <summary>Releases the native resources held by this instance.
253 /// <para>Since EFL 1.23.</para>
254 /// </summary>
185 public void Free() 255 public void Free()
186 { 256 {
187 Dispose(); 257 Dispose();
188 } 258 }
189 259
260 /// <summary>
261 /// Releases the native handler.
262 /// <para>Since EFL 1.23.</para>
263 /// </summary>
264 /// <returns>The native handler.</returns>
190 public IntPtr Release() 265 public IntPtr Release()
191 { 266 {
192 IntPtr h = Handle; 267 IntPtr h = Handle;
@@ -194,6 +269,14 @@ public class Connection : IDisposable
194 return h; 269 return h;
195 } 270 }
196 271
272 /// <summary>
273 /// Send a message.
274 /// <para>Since EFL 1.23.</para>
275 /// </summary>
276 /// <param name="msg">The message that will be sent.</param>
277 /// <param name="dlgt">The function that is executed when a response arrives..</param>
278 /// <param name="timeout">The timeout of the message.</param>
279 /// <returns>A <see cref="eldbus.Pending" /></returns>
197 public eldbus.Pending Send(eldbus.Message msg, eldbus.MessageDelegate dlgt = null, double timeout = -1) 280 public eldbus.Pending Send(eldbus.Message msg, eldbus.MessageDelegate dlgt = null, double timeout = -1)
198 { 281 {
199 CheckHandle(); 282 CheckHandle();
@@ -218,6 +301,11 @@ public class Connection : IDisposable
218 return new eldbus.Pending(pending_hdl, false); 301 return new eldbus.Pending(pending_hdl, false);
219 } 302 }
220 303
304 /// <summary>
305 /// Gets a unique name assigned by the message bus.
306 /// <para>Since EFL 1.23.</para>
307 /// </summary>
308 /// <returns>The unique name string.</returns>
221 public string GetUniqueName() 309 public string GetUniqueName()
222 { 310 {
223 CheckHandle(); 311 CheckHandle();
@@ -230,6 +318,14 @@ public class Connection : IDisposable
230 return Eina.StringConversion.NativeUtf8ToManagedString(ptr); 318 return Eina.StringConversion.NativeUtf8ToManagedString(ptr);
231 } 319 }
232 320
321 /// <summary>
322 /// Send a RequestName method.
323 /// <para>Since EFL 1.23.</para>
324 /// </summary>
325 /// <param name="bus">The name of the bus.</param>
326 /// <param name="flags">Parameter of the RequestName method.</param>
327 /// <param name="dlgt">The function to call when receiving answer.</param>
328 /// <returns>A <see cref="eldbus.Pending" /></returns>
233 public eldbus.Pending NameRequest(string bus, uint flags, eldbus.MessageDelegate dlgt = null) 329 public eldbus.Pending NameRequest(string bus, uint flags, eldbus.MessageDelegate dlgt = null)
234 { 330 {
235 CheckHandle(); 331 CheckHandle();
@@ -252,6 +348,13 @@ public class Connection : IDisposable
252 return new eldbus.Pending(pending_hdl, false); 348 return new eldbus.Pending(pending_hdl, false);
253 } 349 }
254 350
351 /// <summary>
352 /// Send a ReleaseName method.
353 /// <para>Since EFL 1.23.</para>
354 /// </summary>
355 /// <param name="bus">The name of the bus.</param>
356 /// <param name="dlgt">The function to call when receiving answer.</param>
357 /// <returns>A <see cref="eldbus.Pending" /></returns>
255 public eldbus.Pending NameRelease(string bus, eldbus.MessageDelegate dlgt = null) 358 public eldbus.Pending NameRelease(string bus, eldbus.MessageDelegate dlgt = null)
256 { 359 {
257 CheckHandle(); 360 CheckHandle();
@@ -274,6 +377,13 @@ public class Connection : IDisposable
274 return new eldbus.Pending(pending_hdl, false); 377 return new eldbus.Pending(pending_hdl, false);
275 } 378 }
276 379
380 /// <summary>
381 /// Send a GetNameOwner method.
382 /// <para>Since EFL 1.23.</para>
383 /// </summary>
384 /// <param name="bus">The name of the bus.</param>
385 /// <param name="dlgt">The function to call when receiving answer.</param>
386 /// <returns>A <see cref="eldbus.Pending" /></returns>
277 public eldbus.Pending GetNameOwner(string bus, eldbus.MessageDelegate dlgt = null) 387 public eldbus.Pending GetNameOwner(string bus, eldbus.MessageDelegate dlgt = null)
278 { 388 {
279 CheckHandle(); 389 CheckHandle();
@@ -296,6 +406,13 @@ public class Connection : IDisposable
296 return new eldbus.Pending(pending_hdl, false); 406 return new eldbus.Pending(pending_hdl, false);
297 } 407 }
298 408
409 /// <summary>
410 /// Send NameHasOwner method.
411 /// <para>Since EFL 1.23.</para>
412 /// </summary>
413 /// <param name="bus">The name of the bus.</param>
414 /// <param name="dlgt">The function to call when receiving the answer.</param>
415 /// <returns>A <see cref="eldbus.Pending" /></returns>
299 public eldbus.Pending HasNameOwner(string bus, eldbus.MessageDelegate dlgt = null) 416 public eldbus.Pending HasNameOwner(string bus, eldbus.MessageDelegate dlgt = null)
300 { 417 {
301 CheckHandle(); 418 CheckHandle();
@@ -318,6 +435,12 @@ public class Connection : IDisposable
318 return new eldbus.Pending(pending_hdl, false); 435 return new eldbus.Pending(pending_hdl, false);
319 } 436 }
320 437
438 /// <summary>
439 /// Send ListNames method.
440 /// <para>Since EFL 1.23.</para>
441 /// </summary>
442 /// <param name="dlgt">The function to call when receiving answer.</param>
443 /// <returns>A <see cref="eldbus.Pending" /></returns>
321 public eldbus.Pending NameList(eldbus.MessageDelegate dlgt = null) 444 public eldbus.Pending NameList(eldbus.MessageDelegate dlgt = null)
322 { 445 {
323 CheckHandle(); 446 CheckHandle();
@@ -335,6 +458,12 @@ public class Connection : IDisposable
335 return new eldbus.Pending(pending_hdl, false); 458 return new eldbus.Pending(pending_hdl, false);
336 } 459 }
337 460
461 /// <summary>
462 /// Send ListActivatableNames method.
463 /// <para>Since EFL 1.23.</para>
464 /// </summary>
465 /// <param name="dlgt">The function to call when receiving a method.</param>
466 /// <returns>A <see cref="eldbus.Pending" /></returns>
338 public eldbus.Pending ActivatableList(eldbus.MessageDelegate dlgt = null) 467 public eldbus.Pending ActivatableList(eldbus.MessageDelegate dlgt = null)
339 { 468 {
340 CheckHandle(); 469 CheckHandle();
@@ -352,6 +481,12 @@ public class Connection : IDisposable
352 return new eldbus.Pending(pending_hdl, false); 481 return new eldbus.Pending(pending_hdl, false);
353 } 482 }
354 483
484 /// <summary>
485 /// Send Hello method.
486 /// <para>Since EFL 1.23.</para>
487 /// </summary>
488 /// <param name="dlgt">The function to call when receiving answer.</param>
489 /// <returns>A <see cref="eldbus.Pending" /></returns>
355 public eldbus.Pending Hello(eldbus.MessageDelegate dlgt = null) 490 public eldbus.Pending Hello(eldbus.MessageDelegate dlgt = null)
356 { 491 {
357 CheckHandle(); 492 CheckHandle();
@@ -369,6 +504,14 @@ public class Connection : IDisposable
369 return new eldbus.Pending(pending_hdl, false); 504 return new eldbus.Pending(pending_hdl, false);
370 } 505 }
371 506
507 /// <summary>
508 /// Send StartServiceByName method.
509 /// <para>Since EFL 1.23.</para>
510 /// </summary>
511 /// <param name="bus">The name of the bus.</param>
512 /// <param name="flags">Parameter of the StartServiceByName.</param>
513 /// <param name="dlgt">The function to call when receiving answer.</param>
514 /// <returns>A <see cref="eldbus.Pending" /></returns>
372 public eldbus.Pending NameStart(string bus, uint flags, eldbus.MessageDelegate dlgt = null) 515 public eldbus.Pending NameStart(string bus, uint flags, eldbus.MessageDelegate dlgt = null)
373 { 516 {
374 CheckHandle(); 517 CheckHandle();