4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
29 #define METHOD_REQUEST_SECURE_MOUNT "RequestSecureMount"
30 #define METHOD_REQUEST_SECURE_UNMOUNT "RequestSecureUnmount"
31 #define METHOD_REQUEST_MOUNT "RequestMount"
32 #define METHOD_REQUEST_UNMOUNT "RequestUnmount"
33 #define METHOD_REQUEST_FORMAT "RequestFormat"
35 #define ODE_MOUNT_STATE 1
37 API int mmc_secure_mount(const char *mount_point)
40 arr[0] = (char *)mount_point;
41 return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_MMC,
42 DEVICED_INTERFACE_MMC, METHOD_REQUEST_SECURE_MOUNT, "s", arr);
45 API int mmc_secure_unmount(const char *mount_point)
48 arr[0] = (char *)mount_point;
49 return dbus_method_sync(DEVICED_BUS_NAME, DEVICED_PATH_MMC,
50 DEVICED_INTERFACE_MMC, METHOD_REQUEST_SECURE_UNMOUNT, "s", arr);
53 static void mount_mmc_cb(void *data, DBusMessage *msg, DBusError *err)
55 struct mmc_contents *mmc_data = (struct mmc_contents*)data;
59 _D("mount_mmc_cb called");
62 _E("no message [%s:%s]", err->name, err->message);
67 dbus_error_init(&r_err);
68 r = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &mmc_ret, DBUS_TYPE_INVALID);
70 _E("no message [%s:%s]", r_err.name, r_err.message);
71 dbus_error_free(&r_err);
76 _I("Mount State : %d", mmc_ret);
78 // if (mmc_ret == ODE_MOUNT_STATE)
82 (mmc_data->mmc_cb)(mmc_ret, mmc_data->user_data);
85 API int deviced_request_mount_mmc(struct mmc_contents *mmc_data)
87 void (*mount_cb)(void*, DBusMessage*, DBusError*) = NULL;
90 if (mmc_data != NULL && mmc_data->mmc_cb != NULL) {
91 mount_cb = mount_mmc_cb;
95 return dbus_method_async_with_reply(DEVICED_BUS_NAME,
97 DEVICED_INTERFACE_MMC,
99 NULL, NULL, mount_cb, -1, data);
102 static void unmount_mmc_cb(void *data, DBusMessage *msg, DBusError *err)
104 struct mmc_contents *mmc_data = (struct mmc_contents*)data;
108 _D("unmount_mmc_cb called");
111 _E("no message [%s:%s]", err->name, err->message);
116 dbus_error_init(&r_err);
117 r = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &mmc_ret, DBUS_TYPE_INVALID);
119 _E("no message [%s:%s]", r_err.name, r_err.message);
120 dbus_error_free(&r_err);
125 _I("Unmount State : %d", mmc_ret);
128 (mmc_data->mmc_cb)(mmc_ret, mmc_data->user_data);
131 API int deviced_request_unmount_mmc(struct mmc_contents *mmc_data, int option)
135 void (*unmount_cb)(void*, DBusMessage*, DBusError*) = NULL;
138 if (option < 0 || option > 1)
141 if (mmc_data != NULL && mmc_data->mmc_cb != NULL) {
142 unmount_cb = unmount_mmc_cb;
146 snprintf(buf_opt, sizeof(buf_opt), "%d", option);
148 return dbus_method_async_with_reply(DEVICED_BUS_NAME,
150 DEVICED_INTERFACE_MMC,
151 METHOD_REQUEST_UNMOUNT,
152 "i", arr, unmount_cb, -1, data);
155 static void format_mmc_cb(void *data, DBusMessage *msg, DBusError *err)
157 struct mmc_contents *mmc_data = (struct mmc_contents*)data;
161 _D("format_mmc_cb called");
164 _E("no message [%s:%s]", err->name, err->message);
169 dbus_error_init(&r_err);
170 r = dbus_message_get_args(msg, &r_err, DBUS_TYPE_INT32, &mmc_ret, DBUS_TYPE_INVALID);
172 _E("no message [%s:%s]", r_err.name, r_err.message);
173 dbus_error_free(&r_err);
178 _I("Format State : %d", mmc_ret);
181 (mmc_data->mmc_cb)(mmc_ret, mmc_data->user_data);
184 API int deviced_request_format_mmc(struct mmc_contents *mmc_data)
186 return deviced_format_mmc(mmc_data, 1);
189 API int deviced_format_mmc(struct mmc_contents *mmc_data, int option)
193 void (*format_cb)(void*, DBusMessage*, DBusError*) = NULL;
196 if (option < 0 || option > 1)
199 if (mmc_data != NULL && mmc_data->mmc_cb != NULL) {
200 format_cb = format_mmc_cb;
204 snprintf(buf_opt, sizeof(buf_opt), "%d", option);
206 return dbus_method_async_with_reply(DEVICED_BUS_NAME,
208 DEVICED_INTERFACE_MMC,
209 METHOD_REQUEST_FORMAT,
210 "i", arr, format_cb, -1, data);