2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <tapi_common.h>
25 #include <ITapiModem.h>
26 #include "telephony_common.h"
27 #include "telephony_modem.h"
28 #include "telephony_private.h"
33 #define LOG_TAG "CAPI_TELEPHONY"
35 #define CHECK_INPUT_PARAMETER(arg) \
37 LOGE("INVALID_PARAMETER"); \
38 return TELEPHONY_ERROR_INVALID_PARAMETER; \
41 int telephony_modem_get_imei(telephony_h handle, char **imei)
47 int error = TELEPHONY_ERROR_OPERATION_FAILED;
50 CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE);
51 CHECK_INPUT_PARAMETER(handle);
52 tapi_h = ((telephony_data *)handle)->tapi_h;
53 CHECK_INPUT_PARAMETER(tapi_h);
54 CHECK_INPUT_PARAMETER(imei);
56 gv = g_dbus_connection_call_sync(tapi_h->dbus_connection,
57 DBUS_TELEPHONY_SERVICE, tapi_h->path, DBUS_TELEPHONY_MODEM_INTERFACE,
58 "GetIMEI", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &gerr);
61 g_variant_get(gv, "(is)", &tapi_result, &tapi_imei);
62 if (tapi_result == 0) {
63 if (tapi_imei != NULL && strlen(tapi_imei) != 0) {
64 *imei = g_strdup_printf("%s", tapi_imei);
65 error = TELEPHONY_ERROR_NONE;
69 LOGE("g_dbus_conn failed. error (%s)", gerr->message);
70 if (strstr(gerr->message, "No access rights")) {
71 LOGE("PERMISSION_DENIED");
72 error = TELEPHONY_ERROR_PERMISSION_DENIED;