Remove debian files
[platform/core/telephony/tel-plugin-dbus_tapi.git] / src / network.c
index 75cb6f5..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)
 {
@@ -227,12 +235,16 @@ on_network_search (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_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);
        }
 
@@ -248,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);
@@ -269,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);
@@ -294,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) {
@@ -341,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;
@@ -365,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);
@@ -389,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;
@@ -414,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);
@@ -437,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;
@@ -461,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);
@@ -477,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)
@@ -487,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);
@@ -519,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);
        }
 
@@ -540,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);
@@ -561,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);
        }
 
@@ -857,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)