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,};
41 DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
43 _LOGE("DBUS Connection Error");
47 rv = lstat(mnt_path[0], &link_buf);
49 rv = unlink(mnt_path[0]);
51 _LOGE("Unable to remove link file [%s]", mnt_path[0]);
54 msg = dbus_message_new_method_call(TZIP_BUS_NAME, TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_MOUNT_METHOD);
56 _LOGE("dbus_message_new_method_call(%s:%s-%s)", TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_MOUNT_METHOD);
60 if (!dbus_message_append_args(msg,
61 DBUS_TYPE_STRING, &mnt_path[0],
62 DBUS_TYPE_STRING, &mnt_path[1],
63 DBUS_TYPE_STRING, &pkgid,
66 _LOGE("Ran out of memory while constructing args\n");
71 if(dbus_connection_send(conn, msg, NULL) == FALSE) {
72 _LOGE("dbus_connection_send error");
77 dbus_message_unref(msg);
78 _LOGE("__tpk_mount finished");
83 int _coretpk_dbus_unmount_file(char *mnt_path)
85 _LOGD("__tpk_unmount called [%s]", mnt_path);
87 DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
89 _LOGE("DBUS Connection Error");
93 DBusMessage *msg = NULL;
94 msg = dbus_message_new_method_call(TZIP_BUS_NAME, TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_UNMOUNT_METHOD);
96 _LOGE("dbus_message_new_method_call(%s:%s-%s)", TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_UNMOUNT_METHOD);
100 if (!dbus_message_append_args(msg,
101 DBUS_TYPE_STRING, &mnt_path,
104 _LOGE("Ran out of memory while constructing args\n");
105 dbus_message_unref(msg);
109 if(dbus_connection_send(conn, msg, NULL) == FALSE)
111 _LOGE("dbus send error");
112 dbus_message_unref(msg);
115 dbus_message_unref(msg);
116 _LOGE("__tpk_unmount finished");
121 int _coretpk_dbus_is_mount_done(const char *mnt_path)
123 _LOGD("_coretpk_dbus_is_mount_done called [%s]", mnt_path);
130 DBusConnection *conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
132 _LOGE("DBUS Connection Error");
136 msg = dbus_message_new_method_call(TZIP_BUS_NAME, TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_IS_MOUNTED_METHOD);
138 _LOGE("dbus_message_new_method_call(%s:%s-%s)", TZIP_OBJECT_PATH, TZIP_INTERFACE_NAME, TZIP_IS_MOUNTED_METHOD);
142 if (!dbus_message_append_args(msg,
143 DBUS_TYPE_STRING, &mnt_path,
144 DBUS_TYPE_INVALID)) {
145 _LOGE("Ran out of memory while constructing args\n");
146 dbus_message_unref(msg);
150 dbus_error_init(&err);
151 reply = dbus_connection_send_with_reply_and_block(conn, msg, 500, &err);
153 _LOGE("dbus_connection_send error(%s:%s)", err.name, err.message);
157 r = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
159 _LOGE("no message : [%s:%s]", err.name, err.message);
164 dbus_message_unref(msg);
165 dbus_error_free(&err);
169 int _coretpk_dbus_wait_for_tep_mount(const char *mnt_path)
171 _LOGD("_coretpk_dbus_wait_for_tep_mount called [%s]", mnt_path);
175 while(cnt < TZIP_MOUNT_MAXIMUM_RETRY_CNT) {
176 rv = _coretpk_dbus_is_mount_done(mnt_path);
183 /* incase after trying 15 sec, not getting mounted then quit */
185 _LOGE("Not able to mount within 15 sec");