Skip to content

Commit

Permalink
service: Add helper function for detecting a default service index
Browse files Browse the repository at this point in the history
Add a helper function to detect if the index belongs to the default
service.
  • Loading branch information
pfl committed Jan 21, 2014
1 parent 7b415b9 commit 4f04f75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/connman.h
Expand Up @@ -638,6 +638,7 @@ struct connman_service *__connman_service_lookup_from_index(int index);
struct connman_service *__connman_service_lookup_from_ident(const char *identifier);
struct connman_service *__connman_service_create_from_network(struct connman_network *network);
struct connman_service *__connman_service_create_from_provider(struct connman_provider *provider);
bool __connman_service_index_is_default(int index);
struct connman_service *__connman_service_get_default(void);
void __connman_service_update_from_network(struct connman_network *network);
void __connman_service_remove_from_network(struct connman_network *network);
Expand Down
12 changes: 12 additions & 0 deletions src/service.c
Expand Up @@ -1365,6 +1365,18 @@ struct connman_service *__connman_service_get_default(void)
return service;
}

bool __connman_service_index_is_default(int index)
{
struct connman_service *service;

if (index < 0)
return false;

service = __connman_service_get_default();

return __connman_service_get_index(service) == index;
}

static void default_changed(void)
{
struct connman_service *service = __connman_service_get_default();
Expand Down

0 comments on commit 4f04f75

Please sign in to comment.