e_dbus/connman: remove deprecated properties
[framework/uifw/edbus.git] / src / lib / connman / e_connman_service.c
1 #include "e_connman_private.h"
2
3 E_Connman_Element *
4 e_connman_service_get(const char *path)
5 {
6    E_Connman_Element *service;
7
8    EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
9
10    service = e_connman_element_get(path);
11    if (!service)
12       return NULL;
13
14    if (!e_connman_element_is_service(service))
15      {
16         WRN("path '%s' is not a service!", path);
17         return NULL;
18      }
19
20    return service;
21 }
22
23 /**
24  * Connect this service.
25  *
26  * Connect this service. It will attempt to connect
27  * WiFi, WiMAX or Bluetooth services.
28  *
29  * For Ethernet devices this method can only be used
30  * if it has previously been disconnected. Otherwise
31  * the plugging of a cable will trigger connecting
32  * automatically. If no cable is plugged in this method
33  * will fail.
34  *
35  * @param service path to call method on server.
36  * @param cb function to call when server replies or some error happens.
37  * @param data data to give to cb when it is called.
38  *
39  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
40  */
41 Eina_Bool
42 e_connman_service_connect(E_Connman_Element *service, E_DBus_Method_Return_Cb cb, const void *data)
43 {
44    const char name[] = "Connect";
45
46    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
47    return e_connman_element_call_full
48              (service, name, NULL, &service->_pending.service_connect, cb, data);
49 }
50
51 /**
52  * Disconnect this service.
53  *
54  * Disconnect this service. If the service is not
55  * connected an error message will be generated.
56  *
57  * On Ethernet devices this will disconnect the IP
58  * details from the service. It will not magically
59  * unplug the cable. When no cable is plugged in this
60  * method will fail.
61  *
62  * This method can also be used to abort a previous
63  * connectiong attempt via the Connect method.
64  *
65  * @param service path to call method on server.
66  * @param cb function to call when server replies or some error happens.
67  * @param data data to give to cb when it is called.
68  *
69  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
70  */
71 Eina_Bool
72 e_connman_service_disconnect(E_Connman_Element *service, E_DBus_Method_Return_Cb cb, const void *data)
73 {
74    const char name[] = "Disconnect";
75
76    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
77    return e_connman_element_call_full
78              (service, name, NULL, &service->_pending.service_disconnect, cb, data);
79 }
80
81 /**
82  * Remove this service.
83  *
84  * A successfully connected service with Favorite=true
85  * can be removed this way. If it is connected, it will
86  * be automatically disconnected first.
87  *
88  * If the service requires a passphrase it will be
89  * cleared and forgotten when removing.
90  *
91  * This is similar to setting the Favorite property
92  * to false, but that is currently not supported.
93  *
94  * In the case a connection attempt failed and the
95  * service is in the State=failure, this method can
96  * also be used to reset the service.
97  *
98  * Calling this method on Ethernet devices will cause
99  * an error message. It is not possible to remove these
100  * kind of devices.
101  *
102  * @param service path to call method on server.
103  * @param cb function to call when server replies or some error happens.
104  * @param data data to give to cb when it is called.
105  *
106  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
107  */
108 Eina_Bool
109 e_connman_service_remove(E_Connman_Element *service, E_DBus_Method_Return_Cb cb, const void *data)
110 {
111    const char name[] = "Remove";
112
113    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
114    return e_connman_element_call_full
115              (service, name, NULL, &service->_pending.service_remove, cb, data);
116 }
117
118 /**
119  * Clears the value of the specified property.
120  *
121  *
122  * @param service path to call method on server.
123  * @param property to be cleared.
124  * @param cb function to call when server replies or some error happens.
125  * @param data data to give to cb when it is called.
126  *
127  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
128  */
129 Eina_Bool
130 e_connman_service_clear_property(E_Connman_Element *service, const char *property, E_DBus_Method_Return_Cb cb, const void *data)
131 {
132    const char name[] = "ClearProperty";
133
134    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
135    EINA_SAFETY_ON_NULL_RETURN_VAL(property, EINA_FALSE);
136    return e_connman_element_call_with_string
137              (service, name, property, NULL, &service->_pending.service_clear_property,
138              cb, data);
139 }
140
141 /**
142  * Move service before in favorites list.
143  *
144  * Call method MoveBefore(object service) at the given service on server.
145  *
146  * If a service has been used before, this allows a
147  * reorder of the favorite services.
148  *
149  * The target service object must be part of this
150  * profile. Moving between profiles is not supported.
151  *
152  * @param service path to call method on server.
153  * @param object_path object service.
154  * @param cb function to call when server replies or some error happens.
155  * @param data data to give to cb when it is called.
156  *
157  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
158  */
159 Eina_Bool
160 e_connman_service_move_before(E_Connman_Element *service, const char *object_path, E_DBus_Method_Return_Cb cb, const void *data)
161 {
162    const char name[] = "MoveBefore";
163
164    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
165    EINA_SAFETY_ON_NULL_RETURN_VAL(object_path, EINA_FALSE);
166    return e_connman_element_call_with_path
167              (service, name, object_path, NULL,
168              &service->_pending.service_move_before, cb, data);
169 }
170
171 /**
172  * Move service after in favorites list.
173  *
174  * Call method MoveAfter(object service) at the given service on server.
175  *
176  * If a service has been used before, this allows a
177  * reorder of the favorite services.
178  *
179  * The target service object must be part of this
180  * profile. Moving between profiles is not supported.
181  *
182  * @param service path to call method on server.
183  * @param cb function to call when server replies or some error happens.
184  * @param data data to give to cb when it is called.
185  *
186  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
187  */
188 Eina_Bool
189 e_connman_service_move_after(E_Connman_Element *service, const char *object_path, E_DBus_Method_Return_Cb cb, const void *data)
190 {
191    const char name[] = "MoveAfter";
192
193    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
194    EINA_SAFETY_ON_NULL_RETURN_VAL(object_path, EINA_FALSE);
195    return e_connman_element_call_with_path
196              (service, name, object_path, NULL,
197              &service->_pending.service_move_after, cb, data);
198 }
199
200 /**
201  * Get property "State" value.
202  *
203  * If this property isn't found then @c EINA_FALSE is returned.
204  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
205  * values shall be considered invalid.
206  *
207  * The service state information.
208  *
209  * Valid states are "idle", "failure", "association",
210  * "configuration", "ready", "login" and "online".
211  *
212  * @param service path to get property.
213  * @param state where to store the property value, must be a pointer
214  *        to string (const char **), it will not be allocated or
215  *        copied and references will be valid until element changes,
216  *        so copy it if you want to use it later.
217  *
218  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
219  */
220 Eina_Bool
221 e_connman_service_state_get(const E_Connman_Element *service, const char **state)
222 {
223    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
224    EINA_SAFETY_ON_NULL_RETURN_VAL(state, EINA_FALSE);
225    return e_connman_element_property_get_stringshared
226              (service, e_connman_prop_state, NULL, state);
227 }
228
229 /**
230  * Get property "Error" value.
231  *
232  * If this property isn't found then @c EINA_FALSE is returned.
233  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
234  * values shall be considered invalid.
235  *
236  * The service error status details.
237  *
238  * When error occur during connection or disconnection
239  * the detailed information are represented in this
240  * property to help the user interface to present the
241  * user with alternate options.
242  *
243  * This property is only valid when the service is in
244  * the "failure" state. Otherwise it might be empty or
245  * not present at all.
246  *
247  * Current defined error code is "dhcp-failed".
248  *
249  * @param service path to get property.
250  * @param error where to store the property value, must be a pointer
251  *        to string (const char **), it will not be allocated or
252  *        copied and references will be valid until element changes,
253  *        so copy it if you want to use it later.
254  *
255  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
256  */
257 Eina_Bool
258 e_connman_service_error_get(const E_Connman_Element *service, const char **error)
259 {
260    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
261    EINA_SAFETY_ON_NULL_RETURN_VAL(error, EINA_FALSE);
262    return e_connman_element_property_get_stringshared
263              (service, e_connman_prop_error, NULL, error);
264 }
265
266 /**
267  * Get property "Name" value.
268  *
269  * If this property isn't found then @c EINA_FALSE is returned.
270  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
271  * values shall be considered invalid.
272  *
273  * The service name (for example "Wireless" etc.)
274  *
275  * This name can be used for directly displaying it in
276  * the application. It has pure informational purpose.
277  *
278  * For Ethernet devices and hidden WiFi networks it is
279  * not guaranteed that this property is present.
280  *
281  * @param service path to get property.
282  * @param name where to store the property value, must be a pointer
283  *        to string (const char **), it will not be allocated or
284  *        copied and references will be valid until element changes,
285  *        so copy it if you want to use it later.
286  *
287  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
288  */
289 Eina_Bool
290 e_connman_service_name_get(const E_Connman_Element *service, const char **name)
291 {
292    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
293    EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
294    return e_connman_element_property_get_stringshared
295              (service, e_connman_prop_name, NULL, name);
296 }
297
298 /**
299  * Get property "Type" value.
300  *
301  * If this property isn't found then @c EINA_FALSE is returned.
302  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
303  * values shall be considered invalid.
304  *
305  * The service type (for example "ethernet", "wifi" etc.)
306  *
307  * This information should only be used to determine
308  * advanced properties or showing the correct icon
309  * to the user.
310  *
311  * @param service path to get property.
312  * @param type where to store the property value, must be a pointer
313  *        to string (const char **), it will not be allocated or
314  *        copied and references will be valid until element changes,
315  *        so copy it if you want to use it later.
316  *
317  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
318  */
319 Eina_Bool
320 e_connman_service_type_get(const E_Connman_Element *service, const char **type)
321 {
322    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
323    EINA_SAFETY_ON_NULL_RETURN_VAL(type, EINA_FALSE);
324    return e_connman_element_property_get_stringshared
325              (service, e_connman_prop_type, NULL, type);
326 }
327
328 /**
329  * Get property "Security" value.
330  *
331  * If this property isn't found then @c EINA_FALSE is returned.
332  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
333  * values shall be considered invalid.
334  *
335  * If the service type is WiFi, then this property is
336  * present and contains the list of security method or key
337  * management setting.
338  *
339  * Possible values are "none", "wep", "wpa", "rsn", "psk", "ieee8021x" and "wps"
340  *
341  * This property might be only present for WiFi
342  * services.
343  *
344  * @param service path to get property.
345  * @param security where to store the property value, must be a pointer
346  *        to E_Connman_Array, it will not be allocated or
347  *        copied and references will be valid until element changes,
348  *        so copy it if you want to use it later.
349  *
350  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
351  */
352 Eina_Bool
353 e_connman_service_security_get(const E_Connman_Element *service, const E_Connman_Array **security)
354 {
355    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
356    EINA_SAFETY_ON_NULL_RETURN_VAL(security, EINA_FALSE);
357    return e_connman_element_property_get_stringshared
358              (service, e_connman_prop_security, NULL, security);
359 }
360
361 /**
362  * Get property "Passphrase" value.
363  *
364  * If this property isn't found then @c EINA_FALSE is returned.
365  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
366  * values shall be considered invalid.
367  *
368  * If the service type is WiFi, then this property
369  * can be used to store a passphrase.
370  *
371  * No PropertyChanged signals will be send for this
372  * property. The PassphraseRequired property should
373  * be monitored instead.
374  *
375  * This property might also not always be included
376  * since it is protected by a different security policy.
377  *
378  * @param service path to get property.
379  * @param passphrase where to store the property value, must be a pointer
380  *        to string (const char **), it will not be allocated or
381  *        copied and references will be valid until element changes,
382  *        so copy it if you want to use it later.
383  *
384  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
385  * @see e_connman_service_passphrase_set()
386  */
387 Eina_Bool
388 e_connman_service_passphrase_get(const E_Connman_Element *service, const char **passphrase)
389 {
390    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
391    EINA_SAFETY_ON_NULL_RETURN_VAL(passphrase, EINA_FALSE);
392    return e_connman_element_property_get_stringshared
393              (service, e_connman_prop_passphrase, NULL, passphrase);
394 }
395
396 /**
397  * Set property "Passphrase" value.
398  *
399  * If this property isn't found then @c EINA_FALSE is returned.
400  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
401  * values shall be considered invalid.
402  *
403  * If the service type is WiFi, then this property
404  * can be used to store a passphrase.
405  *
406  * No PropertyChanged signals will be send for this
407  * property. The PassphraseRequired property should
408  * be monitored instead.
409  *
410  * This property might also not always be included
411  * since it is protected by a different security policy.
412  *
413  * @param service path to get property.
414  * @param passphrase value to set.
415  * @param cb function to call when server replies or some error happens.
416  * @param data data to give to cb when it is called.
417  *
418  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
419  * @see e_connman_service_passphrase_get()
420  */
421 Eina_Bool
422 e_connman_service_passphrase_set(E_Connman_Element *service, const char *passphrase, E_DBus_Method_Return_Cb cb, const void *data)
423 {
424    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
425    return e_connman_element_property_set_full
426              (service, e_connman_prop_passphrase, DBUS_TYPE_STRING,
427              passphrase, cb, data);
428 }
429
430 /**
431  * Get property "PassphraseRequired" value.
432  *
433  * If this property isn't found then @c EINA_FALSE is returned.
434  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
435  * values shall be considered invalid.
436  *
437  * If the service type is WiFi, then this property
438  * indicates if a passphrase is required.
439  *
440  * If a passphrase has been set already or if no
441  * passphrase is needed, then this property will
442  * be set to false.
443  *
444  * @param service path to get property.
445  * @param passphrase_required where to store the property value, must be a
446  *        pointer to Eina_Bool (Eina_Bool *).
447  *
448  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
449  */
450 Eina_Bool
451 e_connman_service_passphrase_required_get(const E_Connman_Element *service, Eina_Bool *passphrase_required)
452 {
453    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
454    EINA_SAFETY_ON_NULL_RETURN_VAL(passphrase_required, EINA_FALSE);
455    return e_connman_element_property_get_stringshared
456              (service, e_connman_prop_passphrase_required, NULL, passphrase_required);
457 }
458
459 /**
460  * Get property "LoginRequired" value.
461  *
462  * If this property isn't found then @c EINA_FALSE is returned.
463  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
464  * values shall be considered invalid.
465  *
466  * Indicates that a manual configuration must be done to login the
467  * user, likely access an website using a browser.
468  *
469  * If a login has been set already or if no
470  * login is needed, then this property will
471  * be set to false.
472  *
473  * @param service path to get property.
474  * @param login_required where to store the property value, must be a
475  *        pointer to Eina_Bool (Eina_Bool *).
476  *
477  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
478  *
479  * @since 1.1.0
480  */
481 Eina_Bool
482 e_connman_service_login_required_get(const E_Connman_Element *service, Eina_Bool *login_required)
483 {
484    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
485    EINA_SAFETY_ON_NULL_RETURN_VAL(login_required, EINA_FALSE);
486    return e_connman_element_property_get_stringshared
487              (service, e_connman_prop_login_required, NULL, login_required);
488 }
489
490 /**
491  * Get property "Strength" value.
492  *
493  * If this property isn't found then @c EINA_FALSE is returned.
494  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
495  * values shall be considered invalid.
496  *
497  * Indicates the signal strength of the service. This
498  * is a normalized value between 0 and 100.
499  *
500  * This property will not be present for Ethernet
501  * devices.
502  *
503  * @param service path to get property.
504  * @param strength where to store the property value, must be a pointer
505  *        to byte (unsigned char*).
506  *
507  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
508  */
509 Eina_Bool
510 e_connman_service_strength_get(const E_Connman_Element *service, unsigned char *strength)
511 {
512    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
513    EINA_SAFETY_ON_NULL_RETURN_VAL(strength, EINA_FALSE);
514    return e_connman_element_property_get_stringshared
515              (service, e_connman_prop_strength, NULL, strength);
516 }
517
518 /**
519  * Get property "Favorite" value.
520  *
521  * If this property isn't found then @c EINA_FALSE is returned.
522  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
523  * values shall be considered invalid.
524  *
525  * Will be true if a cable is plugged in or the user
526  * selected and successfully connected to this service.
527  *
528  * This value is automatically changed and to revert
529  * it back to false the Remove() method needs to be
530  * used.
531  *
532  * @param service path to get property.
533  * @param favorite where to store the property value, must be a
534  *        pointer to Eina_Bool (Eina_Bool *).
535  *
536  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
537  */
538 Eina_Bool
539 e_connman_service_favorite_get(const E_Connman_Element *service, Eina_Bool *favorite)
540 {
541    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
542    EINA_SAFETY_ON_NULL_RETURN_VAL(favorite, EINA_FALSE);
543    return e_connman_element_property_get_stringshared
544              (service, e_connman_prop_favorite, NULL, favorite);
545 }
546
547 /**
548  * Get property "Immutable" value.
549  *
550  * This value will be set to true if the service is configured
551  * externally via a configuration file.
552  *
553  * The only valid operation are e_connman_service_connect() and
554  * e_connman_service_disconnect(). The e_connman_service_remove()
555  * method will result in an error.
556
557  * @param service path to get property.
558  * @param immutable where to store the property value, must be a
559  *        pointer to Eina_Bool (Eina_Bool *).
560  *
561  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
562  */
563 Eina_Bool
564 e_connman_service_immutable_get(const E_Connman_Element *service, Eina_Bool *immutable)
565 {
566    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
567    EINA_SAFETY_ON_NULL_RETURN_VAL(immutable, EINA_FALSE);
568    return e_connman_element_property_get_stringshared
569              (service, e_connman_prop_immutable, NULL, immutable);
570 }
571
572 /**
573  * Get property "AutoConnect" value.
574  *
575  * If this property isn't found then @c EINA_FALSE is returned.
576  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
577  * values shall be considered invalid.
578  *
579  * If set to true, this service will auto-connect
580  * when not other connection is available.
581  *
582  * For favorite services it is possible to change
583  * this value to prevent or permit automatic
584  * connection attempts.
585  *
586  * @param service path to get property.
587  * @param auto_connect where to store the property value, must be a
588  *        pointer to Eina_Bool (Eina_Bool *).
589  *
590  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
591  * @see e_connman_service_auto_connect_set()
592  */
593 Eina_Bool
594 e_connman_service_auto_connect_get(const E_Connman_Element *service, Eina_Bool *auto_connect)
595 {
596    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
597    EINA_SAFETY_ON_NULL_RETURN_VAL(auto_connect, EINA_FALSE);
598    return e_connman_element_property_get_stringshared
599              (service, e_connman_prop_auto_connect, NULL, auto_connect);
600 }
601
602 /**
603  * Set property "AutoConnect" value.
604  *
605  * If this property isn't found then @c EINA_FALSE is returned.
606  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
607  * values shall be considered invalid.
608  *
609  * If set to true, this service will auto-connect
610  * when not other connection is available.
611  *
612  * For favorite services it is possible to change
613  * this value to prevent or permit automatic
614  * connection attempts.
615  *
616  * @param service path to get property.
617  * @param service_favorite where to store the property value, must be a
618  *        pointer to Eina_Bool (Eina_Bool *).
619  *
620  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
621  * @see e_connman_service_auto_connect_get()
622  */
623 Eina_Bool
624 e_connman_service_auto_connect_set(E_Connman_Element *service, Eina_Bool auto_connect, E_DBus_Method_Return_Cb cb, const void *data)
625 {
626    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
627    return e_connman_element_property_set_full
628              (service, e_connman_prop_auto_connect, DBUS_TYPE_BOOLEAN, &auto_connect, cb, data);
629 }
630
631 /**
632  * Get property "Roaming" value.
633  *
634  * If this property isn't found then @c EINA_FALSE is returned.
635  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
636  * values shall be considered invalid.
637  *
638  * This property indicates if this service is roaming.
639  *
640  * In the case of Cellular services this normally
641  * indicates connections to a foreign provider when
642  * traveling abroad.
643  *
644  * @param service path to get property.
645  * @param roaming where to store the property value, must be a
646  *        pointer to Eina_Bool (Eina_Bool *).
647  *
648  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
649  */
650 Eina_Bool
651 e_connman_service_roaming_get(const E_Connman_Element *service, Eina_Bool *roaming)
652 {
653    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
654    EINA_SAFETY_ON_NULL_RETURN_VAL(roaming, EINA_FALSE);
655    return e_connman_element_property_get_stringshared
656              (service, e_connman_prop_roaming, NULL, roaming);
657 }
658
659 /**
660  * Get property "IPv4.Method" value.
661  *
662  * If this property isn't found then @c EINA_FALSE is returned.
663  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
664  * values shall be considered invalid.
665  *
666  * The IPv4 method in use. Possible values here are "dhcp" and
667  * "static".
668  *
669  * @param service path to get property.
670  * @param method where to store the property value, must be a pointer
671  *        to string (const char **), it will not be allocated or
672  *        copied and references will be valid until element changes,
673  *        so copy it if you want to use it later.
674  *
675  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
676  */
677 Eina_Bool
678 e_connman_service_ipv4_method_get(const E_Connman_Element *service, const char **method)
679 {
680    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
681    EINA_SAFETY_ON_NULL_RETURN_VAL(method, EINA_FALSE);
682    return e_connman_element_property_dict_get_stringshared
683              (service, e_connman_prop_ipv4, e_connman_prop_method, NULL, method);
684 }
685
686 /**
687  * Get property "IPv4.Address" value.
688  *
689  * If this property isn't found then @c EINA_FALSE is returned.
690  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
691  * values shall be considered invalid.
692  *
693  * The current IPv4 address.
694  *
695  * @param service path to get property.
696  * @param address where to store the property value, must be a pointer
697  *        to string (const char **), it will not be allocated or
698  *        copied and references will be valid until element changes,
699  *        so copy it if you want to use it later.
700  *
701  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
702  */
703 Eina_Bool
704 e_connman_service_ipv4_address_get(const E_Connman_Element *service, const char **address)
705 {
706    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
707    EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINA_FALSE);
708    return e_connman_element_property_dict_get_stringshared
709              (service, e_connman_prop_ipv4, e_connman_prop_address, NULL, address);
710 }
711
712 /**
713  * Get property "IPv4.Gateway" value.
714  *
715  * If this property isn't found then @c EINA_FALSE is returned.
716  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
717  * values shall be considered invalid.
718  *
719  * The current IPv4 gateway.
720  *
721  * @param service path to get property.
722  * @param gateway where to store the property value, must be a pointer
723  *        to string (const char **), it will not be allocated or
724  *        copied and references will be valid until element changes,
725  *        so copy it if you want to use it later.
726  *
727  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
728  */
729 Eina_Bool
730 e_connman_service_ipv4_gateway_get(const E_Connman_Element *service, const char **gateway)
731 {
732    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
733    EINA_SAFETY_ON_NULL_RETURN_VAL(gateway, EINA_FALSE);
734    return e_connman_element_property_dict_get_stringshared
735              (service, e_connman_prop_ipv4, e_connman_prop_gateway, NULL, gateway);
736 }
737
738 /**
739  * Get property "IPv4.Netmask" value.
740  *
741  * If this property isn't found then @c EINA_FALSE is returned.
742  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
743  * values shall be considered invalid.
744  *
745  * The current IPv4 netmask.
746  *
747  * @param service path to get property.
748  * @param netmask where to store the property value, must be a pointer
749  *        to string (const char **), it will not be allocated or
750  *        copied and references will be valid until element changes,
751  *        so copy it if you want to use it later.
752  *
753  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
754  */
755 Eina_Bool
756 e_connman_service_ipv4_netmask_get(const E_Connman_Element *service, const char **netmask)
757 {
758    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
759    EINA_SAFETY_ON_NULL_RETURN_VAL(netmask, EINA_FALSE);
760    return e_connman_element_property_dict_get_stringshared
761              (service, e_connman_prop_ipv4, e_connman_prop_netmask, NULL, netmask);
762 }
763
764 /**
765  * Get property "IPv4.Configuration.Method" value.
766  *
767  * Unlike IPv4.Method, this is the user-set value, rather than the
768  * actual value.
769  *
770  * If this property isn't found then @c EINA_FALSE is returned.
771  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
772  * values shall be considered invalid.
773  *
774  * The IPv4 configured method. Possible values here are "dhcp" and
775  * "static".
776  *
777  * @param service path to get property.
778  * @param method where to store the property value, must be a pointer
779  *        to string (const char **), it will not be allocated or
780  *        copied and references will be valid until element changes,
781  *        so copy it if you want to use it later.
782  *
783  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
784  */
785 Eina_Bool
786 e_connman_service_ipv4_configuration_method_get(const E_Connman_Element *service, const char **method)
787 {
788    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
789    EINA_SAFETY_ON_NULL_RETURN_VAL(method, EINA_FALSE);
790    return e_connman_element_property_dict_get_stringshared
791              (service, e_connman_prop_ipv4_configuration, e_connman_prop_method,
792              NULL, method);
793 }
794
795 /**
796  * Get property "IPv4.Configuration.Address" value.
797  *
798  * Unlike IPv4.Address, this is the user-set value, rather than the
799  * actual value.
800  *
801  * If this property isn't found then @c EINA_FALSE is returned.
802  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
803  * values shall be considered invalid.
804  *
805  * The current configured IPv4 address.
806  *
807  * @param service path to get property.
808  * @param address where to store the property value, must be a pointer
809  *        to string (const char **), it will not be allocated or
810  *        copied and references will be valid until element changes,
811  *        so copy it if you want to use it later.
812  *
813  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
814  */
815 Eina_Bool
816 e_connman_service_ipv4_configuration_address_get(const E_Connman_Element *service, const char **address)
817 {
818    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
819    EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINA_FALSE);
820    return e_connman_element_property_dict_get_stringshared
821              (service, e_connman_prop_ipv4_configuration, e_connman_prop_address,
822              NULL, address);
823 }
824
825 /**
826  * Get property "IPv4.Configuration.Gateway" value.
827  *
828  * Unlike IPv4.Gateway, this is the user-set value, rather than the
829  * actual value.
830  *
831  * If this property isn't found then @c EINA_FALSE is returned.
832  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
833  * values shall be considered invalid.
834  *
835  * The current configured IPv4 gateway.
836  *
837  * @param service path to get property.
838  * @param gateway where to store the property value, must be a pointer
839  *        to string (const char **), it will not be allocated or
840  *        copied and references will be valid until element changes,
841  *        so copy it if you want to use it later.
842  *
843  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
844  */
845 Eina_Bool
846 e_connman_service_ipv4_configuration_gateway_get(const E_Connman_Element *service, const char **gateway)
847 {
848    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
849    EINA_SAFETY_ON_NULL_RETURN_VAL(gateway, EINA_FALSE);
850    return e_connman_element_property_dict_get_stringshared
851              (service, e_connman_prop_ipv4_configuration, e_connman_prop_gateway,
852              NULL, gateway);
853 }
854
855 /**
856  * Get property "IPv4.Configuration.Netmask" value.
857  *
858  * Unlike IPv4.Netmask, this is the user-set value, rather than the
859  * actual value.
860  *
861  * If this property isn't found then @c EINA_FALSE is returned.
862  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
863  * values shall be considered invalid.
864  *
865  * The current configured IPv4 netmask.
866  *
867  * @param service path to get property.
868  * @param netmask where to store the property value, must be a pointer
869  *        to string (const char **), it will not be allocated or
870  *        copied and references will be valid until element changes,
871  *        so copy it if you want to use it later.
872  *
873  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
874  */
875 Eina_Bool
876 e_connman_service_ipv4_configuration_netmask_get(const E_Connman_Element *service, const char **netmask)
877 {
878    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
879    EINA_SAFETY_ON_NULL_RETURN_VAL(netmask, EINA_FALSE);
880    return e_connman_element_property_dict_get_stringshared
881              (service, e_connman_prop_ipv4_configuration, e_connman_prop_netmask,
882              NULL, netmask);
883 }
884
885 /**
886  * Set IPv4 to connect automatically using DHCP.
887  *
888  * @param service path to set.
889  * @param cb function to call when server replies or some error happens.
890  * @param data data to give to cb when it is called.
891  *
892  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
893  */
894 Eina_Bool
895 e_connman_service_ipv4_configure_dhcp(E_Connman_Element *service, E_DBus_Method_Return_Cb cb, const void *data)
896 {
897    const char method[] = "dhcp";
898    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
899    return e_connman_element_property_dict_set_full
900              (service, e_connman_prop_ipv4_configuration, e_connman_prop_method,
901              DBUS_TYPE_STRING, method, cb, data);
902 }
903
904 /**
905  * Set IPv4 to connect using manually set parameters.
906  *
907  * @param service path to set.
908  * @param address IPv4 address.
909  * @param netmask IPv4 netmask, or @c NULL for "/32".
910  * @param gateway IPv4 gateway address.
911  * @param cb function to call when server replies or some error happens.
912  * @param data data to give to cb when it is called.
913  *
914  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
915  */
916 Eina_Bool
917 e_connman_service_ipv4_configure_manual(E_Connman_Element *service, const char *address, const char *netmask, const char *gateway, E_DBus_Method_Return_Cb cb, const void *data)
918 {
919    const char name[] = "SetProperty";
920    const char *method = "manual"; /* not method[] as gcc screws it with dbus */
921    DBusMessage *msg;
922    DBusMessageIter itr, variant, dict, entry;
923
924    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
925    EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINA_FALSE);
926
927    msg = dbus_message_new_method_call
928          (e_connman_system_bus_name_get(), service->path, service->interface, name);
929
930    if (!msg)
931       return 0;
932
933    dbus_message_iter_init_append(msg, &itr);
934    dbus_message_iter_append_basic
935       (&itr, DBUS_TYPE_STRING, &e_connman_prop_ipv4_configuration);
936
937    dbus_message_iter_open_container
938       (&itr, DBUS_TYPE_VARIANT,
939       (DBUS_TYPE_ARRAY_AS_STRING
940        DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
941        DBUS_TYPE_STRING_AS_STRING
942        DBUS_TYPE_STRING_AS_STRING
943        DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
944       &variant);
945    dbus_message_iter_open_container
946       (&variant, DBUS_TYPE_ARRAY,
947       (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
948        DBUS_TYPE_STRING_AS_STRING
949        DBUS_TYPE_STRING_AS_STRING
950        DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
951       &dict);
952
953    dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
954    dbus_message_iter_append_basic
955       (&entry, DBUS_TYPE_STRING, &e_connman_prop_method);
956    dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &method);
957    dbus_message_iter_close_container(&dict, &entry);
958
959    dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
960    dbus_message_iter_append_basic
961       (&entry, DBUS_TYPE_STRING, &e_connman_prop_address);
962    dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &address);
963    dbus_message_iter_close_container(&dict, &entry);
964
965    if (netmask)
966      {
967         dbus_message_iter_open_container
968            (&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
969         dbus_message_iter_append_basic
970            (&entry, DBUS_TYPE_STRING, &e_connman_prop_netmask);
971         dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &netmask);
972         dbus_message_iter_close_container(&dict, &entry);
973      }
974
975    if (gateway)
976      {
977         dbus_message_iter_open_container
978            (&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
979         dbus_message_iter_append_basic
980            (&entry, DBUS_TYPE_STRING, &e_connman_prop_gateway);
981         dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &gateway);
982         dbus_message_iter_close_container(&dict, &entry);
983      }
984
985    dbus_message_iter_close_container(&variant, &dict);
986    dbus_message_iter_close_container(&itr, &variant);
987
988    return e_connman_element_message_send
989              (service, name, NULL, msg, &service->_pending.property_set, cb, data);
990 }
991
992 /**
993  * Get property "Ethernet.Method" value.
994  *
995  * If this property isn't found then @c EINA_FALSE is returned.
996  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
997  * values shall be considered invalid.
998  *
999  * The Ethernet configuration method. Possible values here "auto" and "manual".
1000  *
1001  * @param service path to get property.
1002  * @param method where to store the property value, must be a pointer
1003  *        to string (const char **), it will not be allocated or
1004  *        copied and references will be valid until element changes,
1005  *        so copy it if you want to use it later.
1006  *
1007  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1008  */
1009 Eina_Bool
1010 e_connman_service_ethernet_method_get(const E_Connman_Element *service, const char **method)
1011 {
1012    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
1013    EINA_SAFETY_ON_NULL_RETURN_VAL(method, EINA_FALSE);
1014    return e_connman_element_property_dict_get_stringshared
1015              (service, e_connman_prop_ethernet, e_connman_prop_method, NULL, method);
1016 }
1017
1018 /**
1019  * Get property "Ethernet.Interface" value.
1020  *
1021  * If this property isn't found then @c EINA_FALSE is returned.
1022  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
1023  * values shall be considered invalid.
1024  *
1025  * Interface name (for example eth0).
1026  *
1027  * @param service path to get property.
1028  * @param iface where to store the property value, must be a pointer
1029  *        to string (const char **), it will not be allocated or
1030  *        copied and references will be valid until element changes,
1031  *        so copy it if you want to use it later.
1032  *
1033  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1034  */
1035 Eina_Bool
1036 e_connman_service_ethernet_interface_get(const E_Connman_Element *service, const char **iface)
1037 {
1038    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
1039    EINA_SAFETY_ON_NULL_RETURN_VAL(iface, EINA_FALSE);
1040    return e_connman_element_property_dict_get_stringshared
1041              (service, e_connman_prop_ethernet, e_connman_prop_interface, NULL, iface);
1042 }
1043
1044 /**
1045  * Get property "Ethernet.Speed" value.
1046  *
1047  * If this property isn't found then @c EINA_FALSE is returned.
1048  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
1049  * values shall be considered invalid.
1050  *
1051  * Selected speed of the line. This information might not always be available.
1052  *
1053  * @param service path to get property.
1054  * @param speed where to store the property value.
1055  *
1056  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1057  */
1058 Eina_Bool
1059 e_connman_service_ethernet_speed_get(const E_Connman_Element *service, unsigned short *speed)
1060 {
1061    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
1062    EINA_SAFETY_ON_NULL_RETURN_VAL(speed, EINA_FALSE);
1063    return e_connman_element_property_dict_get_stringshared
1064              (service, e_connman_prop_ethernet, e_connman_prop_speed, NULL, speed);
1065 }
1066
1067 /**
1068  * Get property "Ethernet.Address" value.
1069  *
1070  * If this property isn't found then @c EINA_FALSE is returned.
1071  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
1072  * values shall be considered invalid.
1073  *
1074  * The current configured Ethernet address (mac-address).
1075  *
1076  * @param service path to get property.
1077  * @param address where to store the property value, must be a pointer
1078  *        to string (const char **), it will not be allocated or
1079  *        copied and references will be valid until element changes,
1080  *        so copy it if you want to use it later.
1081  *
1082  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1083  */
1084 Eina_Bool
1085 e_connman_service_ethernet_address_get(const E_Connman_Element *service, const char **address)
1086 {
1087    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
1088    EINA_SAFETY_ON_NULL_RETURN_VAL(address, EINA_FALSE);
1089    return e_connman_element_property_dict_get_stringshared
1090              (service, e_connman_prop_ethernet, e_connman_prop_address, NULL, address);
1091 }
1092
1093 /**
1094  * Get property "Ethernet.Duplex" value.
1095  *
1096  * If this property isn't found then @c EINA_FALSE is returned.
1097  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
1098  * values shall be considered invalid.
1099  *
1100  * Selected duplex settings of the line. Possible values are "half" and "full".
1101  * This information might not always be available.
1102  *
1103  * @param service path to get property.
1104  * @param duplex where to store the property value, must be a pointer
1105  *        to string (const char **), it will not be allocated or
1106  *        copied and references will be valid until element changes,
1107  *        so copy it if you want to use it later.
1108  *
1109  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1110  */
1111 Eina_Bool
1112 e_connman_service_ethernet_duplex_get(const E_Connman_Element *service, const char **duplex)
1113 {
1114    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
1115    EINA_SAFETY_ON_NULL_RETURN_VAL(duplex, EINA_FALSE);
1116    return e_connman_element_property_dict_get_stringshared
1117              (service, e_connman_prop_ethernet, e_connman_prop_duplex, NULL, duplex);
1118 }
1119
1120 /**
1121  * Get property "Ethernet.MTU" value.
1122  *
1123  * If this property isn't found then @c EINA_FALSE is returned.
1124  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
1125  * values shall be considered invalid.
1126  *
1127  * The current configured Ethernet MTU.
1128  *
1129  * @param service path to get property.
1130  * @param gateway where to store the property value, must be a pointer
1131  *        to string (const char **), it will not be allocated or
1132  *        copied and references will be valid until element changes,
1133  *        so copy it if you want to use it later.
1134  *
1135  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1136  */
1137 Eina_Bool
1138 e_connman_service_ethernet_mtu_get(const E_Connman_Element *service, unsigned short *mtu)
1139 {
1140    EINA_SAFETY_ON_NULL_RETURN_VAL(service, EINA_FALSE);
1141    EINA_SAFETY_ON_NULL_RETURN_VAL(mtu, EINA_FALSE);
1142    return e_connman_element_property_dict_get_stringshared
1143              (service, e_connman_prop_ethernet, e_connman_prop_mtu, NULL, mtu);
1144 }