Remove debian files
[platform/core/telephony/tel-plugin-dbus_tapi.git] / src / network.c
index 7998819..3bfb24f 100644 (file)
 #include "generated-code.h"
 #include "common.h"
 
+static inline GVariant *network_build_empty_array()
+{
+       GVariantBuilder b;
+
+       g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
+
+       return g_variant_builder_end(&b);
+}
 
 static char *_get_network_name_by_plmn(CoreObject *o, const char *plmn)
 {
@@ -223,44 +231,22 @@ on_network_search (TelephonyNetwork *network,
                GDBusMethodInvocation *invocation,
                gpointer user_data)
 {
-#if 1
        struct custom_data *ctx = user_data;
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "x") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_SEARCH);
        ret = tcore_communicator_dispatch_request(ctx->comm, ur);
        if (ret != TCORE_RETURN_SUCCESS) {
-               telephony_network_complete_search(network, invocation, NULL, ret);
+               GVariant *network_response = network_build_empty_array();
+               telephony_network_complete_search(network, invocation, network_response, ret);
                tcore_user_request_unref(ur);
        }
-#else
-       /* Dummy return */
-       GVariant *result = NULL;
-       GVariantBuilder b;
-       int i;
-       char *buf;
-
-       g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
-
-       for (i = 0; i < 3; i++) {
-               g_variant_builder_open(&b, G_VARIANT_TYPE("a{sv}"));
-
-               g_variant_builder_add(&b, "{sv}", "plmn", g_variant_new_string("45001"));
-               g_variant_builder_add(&b, "{sv}", "act", g_variant_new_int32(4));
-               g_variant_builder_add(&b, "{sv}", "type", g_variant_new_int32(2));
-               g_variant_builder_add(&b, "{sv}", "name", g_variant_new_string("Samsung"));
-
-               g_variant_builder_close(&b);
-       }
-
-       result = g_variant_builder_end(&b);
-
-       telephony_network_complete_search(network, invocation, result, 0);
-       g_variant_unref(result);
-#endif
 
        return TRUE;
 }
@@ -274,6 +260,9 @@ on_network_search_cancel (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "x") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_SET_CANCEL_MANUAL_SEARCH);
@@ -295,6 +284,9 @@ on_network_get_selection_mode (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_PLMN_SELECTION_MODE);
@@ -320,6 +312,9 @@ on_network_set_selection_mode (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "w") == FALSE)
+               return FALSE;
+
        memset(&req, 0, sizeof(struct treq_network_set_plmn_selection_mode));
 
        if (mode == 0) {
@@ -367,6 +362,9 @@ on_network_set_service_domain (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "w") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
 
        req.domain = domain;
@@ -391,6 +389,9 @@ on_network_get_service_domain (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_SERVICE_DOMAIN);
@@ -415,6 +416,9 @@ on_network_set_band (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "w") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
 
        req.mode = mode;
@@ -440,6 +444,9 @@ on_network_get_band (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_BAND);
@@ -463,6 +470,9 @@ on_network_set_mode (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "w") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
 
        req.mode = mode;
@@ -487,6 +497,9 @@ on_network_get_mode (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_MODE);
@@ -503,7 +516,7 @@ static gboolean
 on_network_set_preferred_plmn (TelephonyNetwork *network,
                GDBusMethodInvocation *invocation,
                gint mode,
-               gint ef_index,
+               gint index,
                gint act,
                const gchar *plmn,
                gpointer user_data)
@@ -513,10 +526,13 @@ on_network_set_preferred_plmn (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "w") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
 
        req.operation = mode;
-       req.ef_index = ef_index;
+       req.index = index;
        req.act = act;
 
        memcpy(req.plmn, plmn, 6);
@@ -545,12 +561,16 @@ on_network_get_preferred_plmn (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_PREFERRED_PLMN);
        ret = tcore_communicator_dispatch_request(ctx->comm, ur);
        if (ret != TCORE_RETURN_SUCCESS) {
-               telephony_network_complete_get_preferred_plmn(network, invocation, NULL, ret);
+               GVariant *network_response = network_build_empty_array();
+               telephony_network_complete_get_preferred_plmn(network, invocation, network_response, ret);
                tcore_user_request_unref(ur);
        }
 
@@ -566,6 +586,9 @@ on_network_get_serving_network (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_SERVING_NETWORK);
@@ -587,12 +610,16 @@ on_network_get_neighboring_cell_info (TelephonyNetwork *network,
        UserRequest *ur = NULL;
        TReturn ret;
 
+       if (check_access_control(invocation, AC_NETWORK, "r") == FALSE)
+               return FALSE;
+
        ur = MAKE_UR(ctx, network, invocation);
        tcore_user_request_set_data(ur, 0, NULL);
        tcore_user_request_set_command(ur, TREQ_NETWORK_GET_NEIGHBORING_CELL_INFO);
        ret = tcore_communicator_dispatch_request(ctx->comm, ur);
        if (ret != TCORE_RETURN_SUCCESS) {
-               telephony_network_complete_get_ngbr_cell_info(network, invocation, NULL, ret);
+               GVariant *network_response = network_build_empty_array();
+               telephony_network_complete_get_ngbr_cell_info(network, invocation, network_response, ret);
                tcore_user_request_unref(ur);
        }
 
@@ -607,6 +634,8 @@ gboolean dbus_plugin_setup_network_interface(TelephonyObjectSkeleton *object, st
        telephony_object_skeleton_set_network(object, network);
        g_object_unref(network);
 
+       dbg("network = %p", network);
+
        g_signal_connect (network,
                        "handle-search",
                        G_CALLBACK (on_network_search),
@@ -881,7 +910,7 @@ gboolean dbus_plugin_network_response(struct custom_data *ctx, UserRequest *ur,
                                                        g_variant_new_string(resp_get_preferred_plmn->list[i].plmn));
                                        g_variant_builder_add(&b, "{sv}", "act", g_variant_new_int32(resp_get_preferred_plmn->list[i].act));
                                        g_variant_builder_add(&b, "{sv}", "index",
-                                                       g_variant_new_int32(resp_get_preferred_plmn->list[i].ef_index));
+                                                       g_variant_new_int32(resp_get_preferred_plmn->list[i].index));
 
                                        buf = _get_network_name_by_plmn(co_network, resp_get_preferred_plmn->list[i].plmn);
                                        if (buf)