1 #include "e_connman_private.h"
4 * Get the element manager.
6 * @return element pointer if found, NULL otherwise.
9 e_connman_manager_get(void)
11 return e_connman_element_get(manager_path);
15 * Register new agent for handling user requests.
17 * Call method RegisterAgent(object) on server in order to
18 * register new agent for handling user requests.
20 * @param object_path object to be registered.
21 * @param cb function to call when server replies or some error happens.
22 * @param data data to give to cb when it is called.
24 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
27 e_connman_manager_agent_register(const char *object_path, E_DBus_Method_Return_Cb cb, const void *data)
29 const char name[] = "RegisterAgent";
30 E_Connman_Element *element;
32 EINA_SAFETY_ON_NULL_RETURN_VAL(object_path, EINA_FALSE);
34 element = e_connman_manager_get();
38 return e_connman_element_call_with_path
39 (element, name, object_path, NULL,
40 &element->_pending.agent_register, cb, data);
44 * Unregister an existing agent.
46 * Call method UnregisterAgent(object) on server in order to
47 * unregister an existing agent.
49 * @param object_path agent to be unregistered.
50 * @param cb function to call when server replies or some error happens.
51 * @param data data to give to cb when it is called.
53 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
56 e_connman_manager_agent_unregister(const char *object_path, E_DBus_Method_Return_Cb cb, const void *data)
58 const char name[] = "UnregisterAgent";
59 E_Connman_Element *element;
61 EINA_SAFETY_ON_NULL_RETURN_VAL(object_path, EINA_FALSE);
63 element = e_connman_manager_get();
67 return e_connman_element_call_with_path
68 (element, name, object_path, NULL,
69 &element->_pending.agent_unregister, cb, data);
73 * Get property "State" value.
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.
79 * The global connection state of a system. Possible
80 * values are "online" if at least one connection exists
81 * and "offline" if no service is connected.
83 * In certain situations the state might change to
84 * the value "connected". This can only be seen if
85 * previously no connection was present.
87 * @param state where to store the property value, must be a pointer
88 * to string (const char **), it will not be allocated or
89 * copied and references will be valid until element changes,
90 * so copy it if you want to use it later.
92 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
95 e_connman_manager_state_get(const char **state)
97 E_Connman_Element *element;
99 EINA_SAFETY_ON_NULL_RETURN_VAL(state, EINA_FALSE);
101 element = e_connman_manager_get();
105 return e_connman_element_property_get_stringshared
106 (element, e_connman_prop_state, NULL, state);
110 * Get property "OfflineMode" value.
112 * If this property isn't found then @c EINA_FALSE is returned.
113 * If @c EINA_FALSE is returned, then this call failed and parameter-returned
114 * values shall be considered invalid.
116 * The offline mode indicates the global setting for switching all radios on or
117 * off. Changing offline mode to true results in powering down all devices that
118 * use radio technology. When leaving offline mode the individual policy of each
119 * technology decides to switch the radio back on or not.
121 * During offline mode, it is still possible to switch certain technologies
122 * manually back on. For example the limited usage of WiFi or Bluetooth
123 * technologies might be allowed in some situations.
125 * @param offline where to store the property value, must be a pointer
126 * to Eina_Bool (Eina_Bool *).
128 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
129 * @see e_connman_manager_offline_mode_set()
132 e_connman_manager_offline_mode_get(Eina_Bool *offline)
134 E_Connman_Element *element;
136 EINA_SAFETY_ON_NULL_RETURN_VAL(offline, EINA_FALSE);
138 element = e_connman_manager_get();
142 return e_connman_element_property_get_stringshared
143 (element, e_connman_prop_offline_mode, NULL, offline);
147 * Call method SetProperty("OfflineMode", offline) at the given element on server.
149 * This is a server call, not local, so it may fail and in that case
150 * no property is updated locally. If the value was set the event
151 * E_CONNMAN_EVENT_ELEMENT_UPDATED will be added to main loop.
153 * The offline mode indicates the global setting for switching all radios on or
154 * off. Changing offline mode to true results in powering down all devices that
155 * use radio technology. When leaving offline mode the individual policy of each
156 * technology decides to switch the radio back on or not.
158 * During offline mode, it is still possible to switch certain technologies
159 * manually back on. For example the limited usage of WiFi or Bluetooth
160 * technologies might be allowed in some situations.
162 * @param offline value to set.
163 * @param cb function to call when server replies or some error happens.
164 * @param data data to give to cb when it is called.
166 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
167 * @see e_connman_manager_offline_mode_get()
170 e_connman_manager_offline_mode_set(Eina_Bool offline, E_DBus_Method_Return_Cb cb, const void *data)
172 E_Connman_Element *element = e_connman_manager_get();
176 return e_connman_element_property_set_full
177 (element, e_connman_prop_offline_mode, DBUS_TYPE_BOOLEAN,
182 * Get array of profile elements.
184 * @param count return the number of elements in array.
185 * @param p_elements array with all elements, these are not referenced
186 * and in no particular order, just set if return is @c EINA_TRUE. The
187 * array itself is allocated using malloc() and should be freed
188 * after usage is done.
190 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
193 e_connman_manager_profiles_get(unsigned int *count, E_Connman_Element ***p_elements)
195 E_Connman_Element *element;
197 EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
198 EINA_SAFETY_ON_NULL_RETURN_VAL(p_elements, EINA_FALSE);
200 element = e_connman_manager_get();
204 return e_connman_element_objects_array_get_stringshared
205 (element, e_connman_prop_profiles, count, p_elements);
209 * Get array of services elements.
211 * List of service object paths. The list is sorted
212 * internally to have the service with the default
213 * route always first and then the favorite services
214 * followed by scan results.
216 * This list represents the available services for the
217 * current selected profile. If the profile gets changed
218 * then this list will be updated.
220 * The same list is available via the profile object
221 * itself. It is just provided here for convenience of
222 * applications only dealing with the current active
225 * @param count return the number of elements in array.
226 * @param p_elements array with all elements, these are not referenced
227 * and in no particular order, just set if return is @c EINA_TRUE. The
228 * array itself is allocated using malloc() and should be freed
229 * after usage is done.
231 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
234 e_connman_manager_services_get(unsigned int *count, E_Connman_Element ***p_elements)
236 E_Connman_Element *element;
238 EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
239 EINA_SAFETY_ON_NULL_RETURN_VAL(p_elements, EINA_FALSE);
241 element = e_connman_manager_get();
245 return e_connman_element_objects_array_get_stringshared
246 (element, e_connman_prop_services, count, p_elements);
250 * Get array of technology elements.
252 * @param count return the number of elements in array.
253 * @param p_elements array with all elements, these are not referenced
254 * and in no particular order, just set if return is @c EINA_TRUE. The
255 * array itself is allocated using malloc() and should be freed
256 * after usage is done.
258 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
261 e_connman_manager_technologies_get(unsigned int *count, E_Connman_Element ***p_elements)
263 E_Connman_Element *element;
265 EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
266 EINA_SAFETY_ON_NULL_RETURN_VAL(p_elements, EINA_FALSE);
268 element = e_connman_manager_get();
272 return e_connman_element_objects_array_get_stringshared
273 (element, e_connman_prop_technologies, count, p_elements);
277 * Request to trigger a scan for given technology.
279 * Call method RequestScan(type) on server in order to find new services for
280 * such technology type.
282 * The empty string for type means all technolgies.
284 * @param type technology type to scan. Empty or NULL for all technologies.
285 * @param cb function to call when server replies or some error happens.
286 * @param data data to give to cb when it is called.
288 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
291 e_connman_manager_request_scan(const char *type, E_DBus_Method_Return_Cb cb, const void *data)
293 const char name[] = "RequestScan";
294 E_Connman_Element *element;
299 element = e_connman_manager_get();
303 return e_connman_element_call_with_string
304 (element, name, type, NULL,
305 &element->_pending.request_scan, cb, data);
309 * Enable specified type of technology.
311 * Call method EnableTechnology(type) on server.
313 * @param type technology type to enable.
314 * @param cb function to call when server replies or some error happens.
315 * @param data data to give to cb when it is called.
317 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
320 e_connman_manager_technology_enable(const char *type, E_DBus_Method_Return_Cb cb, const void *data)
322 const char name[] = "EnableTechnology";
323 E_Connman_Element *element;
325 EINA_SAFETY_ON_NULL_RETURN_VAL(type, EINA_FALSE);
327 element = e_connman_manager_get();
331 return e_connman_element_call_with_string
332 (element, name, type, NULL,
333 &element->_pending.technology_enable, cb, data);
337 * Disable specified type of technology.
339 * Call method DisableTechnology(type) on server.
341 * @param type technology type to disable.
342 * @param cb function to call when server replies or some error happens.
343 * @param data data to give to cb when it is called.
345 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
348 e_connman_manager_technology_disable(const char *type, E_DBus_Method_Return_Cb cb, const void *data)
350 const char name[] = "DisableTechnology";
351 E_Connman_Element *element;
353 EINA_SAFETY_ON_NULL_RETURN_VAL(type, EINA_FALSE);
355 element = e_connman_manager_get();
359 return e_connman_element_call_with_string
360 (element, name, type, NULL,
361 &element->_pending.technology_disable, cb, data);
365 * Get property "DefaultTechnology" value.
367 * If this property isn't found then @c EINA_FALSE is returned.
368 * If @c EINA_FALSE is returned, then this call failed and parameter-returned
369 * values shall be considered invalid.
371 * The current connected technology which holds the default route.
373 * @param type where to store the property value, must be a pointer
374 * to string (const char **), it will not be allocated or
375 * copied and references will be valid until element changes,
376 * so copy it if you want to use it later.
378 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
381 e_connman_manager_technology_default_get(const char **type)
383 E_Connman_Element *element;
385 EINA_SAFETY_ON_NULL_RETURN_VAL(type, EINA_FALSE);
387 element = e_connman_manager_get();
391 return e_connman_element_property_get_stringshared
392 (element, e_connman_prop_technology_default, NULL, type);
396 * Remove specified profile.
398 * Call method RemoveProfile(profile) on server.
400 * It is not possible to remove the current active profile. To remove
401 * the active profile a different one must be selected via
402 * ActiveProfile property first.
404 * At minimum one profile must be available all the time.
406 * @param profile element to remove, must be of type profile.
407 * @param cb function to call when server replies or some error happens.
408 * @param data data to give to cb when it is called.
410 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
413 e_connman_manager_profile_remove(const E_Connman_Element *profile, E_DBus_Method_Return_Cb cb, const void *data)
415 E_Connman_Element *element;
416 const char name[] = "RemoveProfile";
418 EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
419 EINA_SAFETY_ON_NULL_RETURN_VAL(profile->path, EINA_FALSE);
421 if (!e_connman_element_is_profile(profile))
424 element = e_connman_manager_get();
428 return e_connman_element_call_with_path
429 (element, name, profile->path, NULL,
430 &element->_pending.profile_remove, cb, data);
434 * Get property "ActiveProfile" value.
436 * If this property isn't found then @c EINA_FALSE is returned.
437 * If @c EINA_FALSE is returned, then this call failed and parameter-returned
438 * values shall be considered invalid.
440 * @param element where to store the element, just changed if return is @c EINA_TRUE
442 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
444 * @see e_connman_manager_profile_active_set()
447 e_connman_manager_profile_active_get(E_Connman_Element **profile)
449 E_Connman_Element *element;
452 EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
454 element = e_connman_manager_get();
458 if (!e_connman_element_property_get_stringshared
459 (element, e_connman_prop_profile_active, NULL, &profile_path))
462 *profile = e_connman_element_get(profile_path);
467 * Call method SetProperty("ActiveProfile", profile) at the given
470 * This is a server call, not local, so it may fail and in that case
471 * no property is updated locally. If the value was set the event
472 * E_CONNMAN_EVENT_ELEMENT_UPDATED will be added to main loop.
474 * @param profile object to set.
475 * @param cb function to call when server replies or some error happens.
476 * @param data data to give to cb when it is called.
478 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
479 * @see e_connman_manager_profile_active_get()
482 e_connman_manager_profile_active_set(const E_Connman_Element *profile, E_DBus_Method_Return_Cb cb, const void *data)
484 E_Connman_Element *element;
486 EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
487 EINA_SAFETY_ON_NULL_RETURN_VAL(profile->path, EINA_FALSE);
489 if (!e_connman_element_is_profile(profile))
492 element = e_connman_manager_get();
496 return e_connman_element_property_set_full
497 (element, e_connman_prop_profile_active, DBUS_TYPE_OBJECT_PATH,
498 profile->path, cb, data);
502 * Get array of strings representing the available technologies.
504 * @param count return the number of elements in array.
505 * @param p_strings array with pointers to internal strings. These
506 * strings are not copied in any way, and they are granted to
507 * be eina_stringshare instances, so one can use
508 * eina_stringshare_ref() if he wants to save memory and cpu to
509 * get an extra reference. The array itself is allocated using
510 * malloc() and should be freed after usage is done. This
511 * pointer is just set if return is @c EINA_TRUE.
513 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
516 e_connman_manager_technologies_available_get(unsigned int *count, const char ***p_strings)
518 E_Connman_Element *element;
520 EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
521 EINA_SAFETY_ON_NULL_RETURN_VAL(p_strings, EINA_FALSE);
523 element = e_connman_manager_get();
527 return e_connman_element_strings_array_get_stringshared
528 (element, e_connman_prop_technologies_available, count, p_strings);
532 * Get array of strings representing the enabled technologies.
534 * @param count return the number of elements in array.
535 * @param p_strings array with pointers to internal strings. These
536 * strings are not copied in any way, and they are granted to
537 * be eina_stringshare instances, so one can use
538 * eina_stringshare_ref() if he wants to save memory and cpu to
539 * get an extra reference. The array itself is allocated using
540 * malloc() and should be freed after usage is done. This
541 * pointer is just set if return is @c EINA_TRUE.
543 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
546 e_connman_manager_technologies_enabled_get(unsigned int *count, const char ***p_strings)
548 E_Connman_Element *element;
550 EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
551 EINA_SAFETY_ON_NULL_RETURN_VAL(p_strings, EINA_FALSE);
553 element = e_connman_manager_get();
557 return e_connman_element_strings_array_get_stringshared
558 (element, e_connman_prop_technologies_enabled, count, p_strings);
562 * Get array of strings representing the connected technologies.
564 * @param count return the number of elements in array.
565 * @param p_strings array with pointers to internal strings. These
566 * strings are not copied in any way, and they are granted to
567 * be eina_stringshare instances, so one can use
568 * eina_stringshare_ref() if he wants to save memory and cpu to
569 * get an extra reference. The array itself is allocated using
570 * malloc() and should be freed after usage is done. This
571 * pointer is just set if return is @c EINA_TRUE.
573 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
576 e_connman_manager_technologies_connected_get(unsigned int *count, const char ***p_strings)
578 E_Connman_Element *element;
580 EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
581 EINA_SAFETY_ON_NULL_RETURN_VAL(p_strings, EINA_FALSE);
583 element = e_connman_manager_get();
587 return e_connman_element_strings_array_get_stringshared
588 (element, e_connman_prop_technologies_connected, count, p_strings);