Exemplo n.º 1
0
static void session_activate(struct connman_session *session)
{
    GHashTableIter iter;
    gpointer key, value;

    if (!service_hash)
        return;

    g_hash_table_iter_init(&iter, service_hash);
    while (g_hash_table_iter_next(&iter, &key, &value)) {
        struct connman_service_info *info = value;
        enum connman_service_state state;

        state = __connman_service_get_state(info->service);

        if (is_session_connected(session, state) &&
                session_match_service(session, info->service)) {
            DBG("session %p add service %p", session, info->service);

            info->sessions = g_slist_prepend(info->sessions,
                                             session);
            session->service = info->service;
            update_session_state(session);

            return;
        }
    }

    session_notify(session);
}
Exemplo n.º 2
0
static void handle_service_state_online(struct connman_service *service,
                                        enum connman_service_state state,
                                        struct connman_service_info *info)
{
    GHashTableIter iter;
    gpointer key, value;

    g_hash_table_iter_init(&iter, session_hash);
    while (g_hash_table_iter_next(&iter, &key, &value)) {
        struct connman_session *session = value;
        bool connected;

        connected = is_session_connected(session, state);

        if (session->service == service) {
            if (!connected) {
                DBG("session %p remove service %p", session, service);
                info->sessions = g_slist_remove(info->sessions,
                                                session);
                session->service = NULL;
                update_session_state(session);
            }
        } else if (connected && session_match_service(session, service)) {
            DBG("session %p add service %p", session, service);

            info->sessions = g_slist_prepend(info->sessions,
                                             session);
            session->service = service;
            update_session_state(session);
        }
    }
}
Exemplo n.º 3
0
static void session_activate(struct connman_session *session)
{
	GHashTableIter iter;
	gpointer key, value;

	if (!service_hash)
		return;

	if (policy && policy->get_service_for_session) {
		struct connman_service *service;
		struct connman_service_info *info;
		GSList *service_list = NULL;
		enum connman_service_state state = CONNMAN_SESSION_STATE_DISCONNECTED;

		g_hash_table_iter_init(&iter, service_hash);

		while (g_hash_table_iter_next(&iter, &key, &value)) {
			struct connman_service_info *info = value;
			state = connman_service_get_state(info->service);

			if (is_session_connected(session, state))
				service_list = g_slist_prepend(service_list,
							       info->service);
		}

		service_list = g_slist_reverse(service_list);
		service = policy->get_service_for_session(session, service_list);

		if (service) {
			info = g_hash_table_lookup(service_hash, service);
			DBG("session %p add service %p", session, info->service);

			info->sessions = g_slist_prepend(info->sessions,
							session);
			session->service = info->service;
			update_session_state(session);
		}

		g_slist_free(service_list);
		return;
	}

	g_hash_table_iter_init(&iter, service_hash);
	while (g_hash_table_iter_next(&iter, &key, &value)) {
		struct connman_service_info *info = value;
		enum connman_service_state state;

		state = connman_service_get_state(info->service);

		if (is_session_connected(session, state) &&
				session_match_service(session, info->service)) {
			DBG("session %p add service %p", session, info->service);

			info->sessions = g_slist_prepend(info->sessions,
							session);
			session->service = info->service;
			update_session_state(session);

			return;
		}
	}

	session_notify(session);
}