4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Vineet Mimrot <v.mimrot@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #ifdef _APPFW_FEATURE_MOUNT_INSTALL
23 #include <dbus/dbus.h>
24 #include <dbus/dbus-glib-lowlevel.h>
28 #include "coretpk-installer-internal.h"
29 #include "installer-type.h"
32 int _coretpk_dbus_mount_file(char *mnt_path[], const char *pkgid)
35 _LOGD("_coretpk_dbus_mount_file called");
39 struct stat link_buf = {0,};
42 DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
44 _LOGE("DBUS Connection Error");
48 rv = lstat(mnt_path[0], &link_buf);
50 rv = unlink(mnt_path[0]);
52 _LOGE("Unable to remove link file [%s]", mnt_path[0]);
55 msg = dbus_message_new_method_call(TZIP_BUS_NAME, TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_MOUNT_METHOD);
57 _LOGE("dbus_message_new_method_call(%s:%s-%s)", TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_MOUNT_METHOD);
61 if (!dbus_message_append_args(msg,
62 DBUS_TYPE_STRING, &mnt_path[0],
63 DBUS_TYPE_STRING, &mnt_path[1],
64 DBUS_TYPE_STRING, &pkgid,
67 _LOGE("Ran out of memory while constructing args\n");
72 if(dbus_connection_send(conn, msg, NULL) == FALSE) {
73 _LOGE("dbus_connection_send error");
78 dbus_message_unref(msg);
79 _LOGE("__tpk_mount finished");
84 int _coretpk_dbus_unmount_file(char *mnt_path)
87 _LOGD("__tpk_unmount called [%s]", mnt_path);
89 DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
91 _LOGE("DBUS Connection Error");
95 DBusMessage *msg = NULL;
96 msg = dbus_message_new_method_call(TZIP_BUS_NAME, TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_UNMOUNT_METHOD);
98 _LOGE("dbus_message_new_method_call(%s:%s-%s)", TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_UNMOUNT_METHOD);
102 if (!dbus_message_append_args(msg,
103 DBUS_TYPE_STRING, &mnt_path,
106 _LOGE("Ran out of memory while constructing args\n");
107 dbus_message_unref(msg);
111 if(dbus_connection_send(conn, msg, NULL) == FALSE)
113 _LOGE("dbus send error");
114 dbus_message_unref(msg);
117 dbus_message_unref(msg);
118 _LOGE("__tpk_unmount finished");
123 int _coretpk_dbus_is_mount_done(const char *mnt_path)
125 _LOGD("_coretpk_dbus_is_mount_done called [%s]", mnt_path);
132 DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
134 _LOGE("DBUS Connection Error");
138 msg = dbus_message_new_method_call(TZIP_BUS_NAME, TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_IS_MOUNTED_METHOD);
140 _LOGE("dbus_message_new_method_call(%s:%s-%s)", TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_IS_MOUNTED_METHOD);
144 if (!dbus_message_append_args(msg,
145 DBUS_TYPE_STRING, &mnt_path,
146 DBUS_TYPE_INVALID)) {
147 _LOGE("Ran out of memory while constructing args\n");
148 dbus_message_unref(msg);
152 dbus_error_init(&err);
153 reply = dbus_connection_send_with_reply_and_block(conn, msg, 500, &err);
155 _LOGE("dbus_connection_send error(%s:%s)", err.name, err.message);
159 r = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
161 _LOGE("no message : [%s:%s]", err.name, err.message);
166 dbus_message_unref(msg);
167 dbus_error_free(&err);
171 int _coretpk_dbus_wait_for_tep_mount(const char *mnt_path)
173 _LOGD("_coretpk_dbus_wait_for_tep_mount called [%s]", mnt_path);
177 while(cnt < TZIP_MOUNT_MAXIMUM_RETRY_CNT) {
178 rv = _coretpk_dbus_is_mount_done(mnt_path);
185 /* incase after trying 15 sec, not getting mounted then quit */
187 _LOGE("Not able to mount within 15 sec");