e_connman0_7x: phase-2 - remove the old library and create the new one.
[framework/uifw/edbus.git] / src / lib / connman0_7x / e_connman_profile.c
1 #include "e_connman_private.h"
2
3 E_Connman_Element *
4 e_connman_profile_get(const char *path)
5 {
6    E_Connman_Element *profile;
7
8    EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
9
10    profile = e_connman_element_get(path);
11    if (!profile)
12       return NULL;
13
14    if (!e_connman_element_is_profile(profile))
15      {
16         WRN("path '%s' is not a profile!", path);
17         return NULL;
18      }
19
20    return profile;
21 }
22
23 /**
24  * Get property "Name" value.
25  *
26  * If this property isn't found then @c EINA_FALSE is returned.
27  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
28  * values shall be considered invalid.
29  *
30  * The profile name, if set with e_connman_profile_name_set()
31  *
32  * @param profile path to get property.
33  * @param name where to store the property value, must be a pointer
34  *        to string (const char **), it will not be allocated or
35  *        copied and references will be valid until element changes,
36  *        so copy it if you want to use it later.
37  *
38  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
39  * @see e_connman_profile_name_set()
40  */
41 Eina_Bool
42 e_connman_profile_name_get(const E_Connman_Element *profile, const char **name)
43 {
44    EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
45    EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
46    return e_connman_element_property_get_stringshared
47              (profile, e_connman_prop_name, NULL, name);
48 }
49
50 /**
51  * Call method SetProperty("Name", name) at the given element on server.
52  *
53  * This is a server call, not local, so it may fail and in that case
54  * no property is updated locally. If the value was set the event
55  * E_CONNMAN_EVENT_ELEMENT_UPDATED will be added to main loop.
56  *
57  * @param name value to set.
58  * @param cb function to call when server replies or some error happens.
59  * @param data data to give to cb when it is called.
60  *
61  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
62  * @see e_connman_profile_name_get()
63  */
64 Eina_Bool
65 e_connman_profile_name_set(E_Connman_Element *profile, const char *name, E_DBus_Method_Return_Cb cb, const void *data)
66 {
67    EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
68    return e_connman_element_property_set_full
69              (profile, e_connman_prop_name, DBUS_TYPE_STRING, name, cb, data);
70 }
71
72 /**
73  * Get property "OfflineMode" value.
74  *
75  * If this property isn't found then @c EINA_FALSE is returned.
76  * If @c EINA_FALSE is returned, then this call failed and parameter-returned
77  * values shall be considered invalid.
78  *
79  * The offline mode indicates the global setting for switching all radios on or
80  * off. Changing offline mode to true results in powering down all devices that
81  * use radio technology.
82  *
83  * @param offline where to store the property value, must be a pointer
84  *        to Eina_Bool (Eina_Bool *).
85  *
86  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
87  * @see e_connman_profile_offline_mode_set()
88  */
89 Eina_Bool
90 e_connman_profile_offline_mode_get(const E_Connman_Element *profile, Eina_Bool *offline)
91 {
92    EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
93    EINA_SAFETY_ON_NULL_RETURN_VAL(offline, EINA_FALSE);
94    return e_connman_element_property_get_stringshared
95              (profile, e_connman_prop_offline_mode, NULL, offline);
96 }
97
98 /**
99  * Call method SetProperty("OfflineMode", offline) at the given element on server.
100  *
101  * This is a server call, not local, so it may fail and in that case
102  * no property is updated locally. If the value was set the event
103  * E_CONNMAN_EVENT_ELEMENT_UPDATED will be added to main loop.
104  *
105  * The offline mode indicates the global setting for switching all radios on or
106  * off. Changing offline mode to true results in powering down all devices that
107  * use radio technology.
108  *
109  * @param offline value to set.
110  * @param cb function to call when server replies or some error happens.
111  * @param data data to give to cb when it is called.
112  *
113  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
114  * @see e_connman_profile_offline_mode_get()
115  */
116 Eina_Bool
117 e_connman_profile_offline_mode_set(E_Connman_Element *profile, Eina_Bool offline, E_DBus_Method_Return_Cb cb, const void *data)
118 {
119    EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
120    return e_connman_element_property_set_full
121              (profile, e_connman_prop_offline_mode, DBUS_TYPE_BOOLEAN,
122              &offline, cb, data);
123 }
124
125 /**
126  * Get array of service elements.
127  *
128  * @param count return the number of elements in array.
129  * @param p_elements array with all elements, these are not referenced
130  *        and in no particular order, just set if return is @c EINA_TRUE.
131  *
132  * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
133  */
134 Eina_Bool
135 e_connman_profile_services_get(const E_Connman_Element *profile, unsigned int *count, E_Connman_Element ***p_elements)
136 {
137    EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
138    EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
139    EINA_SAFETY_ON_NULL_RETURN_VAL(p_elements, EINA_FALSE);
140    return e_connman_element_objects_array_get_stringshared
141              (profile, e_connman_prop_services, count, p_elements);
142 }
143