SET(SRCS src/pkgmgr-internal.c src/pkgmgr.c)
pkg_check_modules(CLIENT_DEPS REQUIRED
- dbus-glib-1
dlog
pkgmgr-parser
pkgmgr-info
SET_TARGET_PROPERTIES(${PKGMGR_CLIENT} PROPERTIES VERSION ${VERSION})
TARGET_LINK_LIBRARIES(${PKGMGR_CLIENT}
pkgmgr_installer_client
- pkgmgr_installer_status_broadcast_server pkgmgr-info
+ pkgmgr-info
${CLIENT_DEPS_LDFLAGS})
CONFIGURE_FILE(pkgmgr.pc.in pkgmgr.pc @ONLY)
Name: package manager
Description: SLP Package Manager Package
Version: @VERSION@
-Requires: dlog pkgmgr-types pkgmgr-installer-client pkgmgr-installer-status-broadcast-server
+Requires: dlog pkgmgr-types pkgmgr-installer-client
Libs: -L${libdir} -L${libdir}/pkgmgr -lpkgmgr-client
Cflags: -I${includedir}
#include <sys/wait.h>
#include <sys/time.h>
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
#include <pkgmgr-info.h>
#include <iniparser.h>
/* For multi-user support */
#include "pkgmgr-debug.h"
#include "pkgmgr-api.h"
#include "comm_client.h"
-#include "comm_status_broadcast_server.h"
#define PKG_TMP_PATH tzplatform_mkpath(TZ_USER_APP, "tmp")
comm_client *cc;
listen_cb_info *lhead;
} listening;
- struct _broadcast {
- DBusConnection *bc;
- } broadcast;
} info;
void *new_event_cb;
} pkgmgr_client_t;
ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.listening.cc, __status_callback, pc);
trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
} else if (pc->ctype == PC_BROADCAST) {
- pc->info.broadcast.bc = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
- trym_if(pc->info.broadcast.bc == NULL, "client creation failed");
+ /* client cannot broadcast signal */
+ return NULL;
}
return (pkgmgr_client *) pc;
ret = comm_client_free(mpc->info.listening.cc);
tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
} else if (mpc->ctype == PC_BROADCAST) {
- comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
ret = 0;
} else {
ERR("Invalid client type\n");
const char *pkgid, const char *key,
const char *val)
{
- /* Check for NULL value of pc */
- if (pc == NULL) {
- DBG("package manager client handle is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- /* Check for valid arguments. NULL parameter causes DBUS to abort */
- if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
- DBG("Argument supplied is NULL\n");
- return PKGMGR_R_EINVAL;
- }
- pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
-
- /* 0. check the pc type */
- if (mpc->ctype != PC_BROADCAST)
- return PKGMGR_R_EINVAL;
-
- comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, mpc->info.broadcast.bc,
- getuid(), PKG_STATUS,
- pkg_type, pkgid, key, val);
-
+ /* client cannot broadcast signal */
return PKGMGR_R_OK;
}
### Get required CFLAGS, LDFLAGS from pkg-config
include(FindPkgConfig)
-pkg_check_modules(installer_client_pkgs REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog)
+pkg_check_modules(installer_client_pkgs REQUIRED glib-2.0 gio-2.0 dlog)
foreach(flag ${installer_client_pkgs_CFLAGS})
set(installer_client_pkgs_CFLAGS_str "${installer_client_pkgs_CFLAGS_str} ${flag}")
endforeach()
-pkg_check_modules(comm_pkgs REQUIRED glib-2.0 dbus-glib-1 dlog cynara-client cynara-creds-dbus cynara-session)
-foreach(flag ${comm_pkgs_CFLAGS})
- set(comm_pkgs_CFLAGS_str "${comm_pkgs_CFLAGS_str} ${flag}")
-endforeach()
-
-pkg_check_modules(broadcast_server_pkgs REQUIRED dbus-1 dlog)
-foreach(flag ${broadcast_server_pkgs_CFLAGS})
- set(broadcast_server_pkgs_CFLAGS_str "${broadcast_server_pkgs_CFLAGS_str} ${flag}")
-endforeach()
-
-pkg_check_modules(installer_pkgs REQUIRED glib-2.0 dbus-1 dlog pkgmgr-info)
+pkg_check_modules(installer_pkgs REQUIRED glib-2.0 gio-2.0 dlog pkgmgr-info)
foreach(flag ${installer_pkgs_CFLAGS})
set(installer_pkgs_CFLAGS_str "${installer_pkgs_CFLAGS_str} ${flag}")
endforeach()
-### Set current binary dir to be included (for generated *.h files)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
-
-### Create dbus-glib bindings headers (client/server) from xml by dbus-binding-tool
-
-# comm_pkg_mgr : package manger interface (client - package manager process)
-add_custom_target(comm_pkg_mgr_server_dbus_bindings.h
- COMMAND dbus-binding-tool --prefix=pkgmgr --mode=glib-server
- ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
- --output=${CMAKE_CURRENT_BINARY_DIR}/comm_pkg_mgr_server_dbus_bindings.h
- )
-
-#GDBUS specific code
-add_custom_command(OUTPUT comm_pkg_mgr_client_gdbus_generated.c comm_pkg_mgr_client_gdbus_generated.h
- COMMAND gdbus-codegen --generate-c-code comm_pkg_mgr_client_gdbus_generated
- --interface-prefix pkgmgr ${CMAKE_CURRENT_SOURCE_DIR}/comm_pkg_mgr.xml
- )
-
-add_custom_target(comm_status_broadcast_server_dbus_bindings.h
- COMMAND dbus-binding-tool --prefix=status_broadcast --mode=glib-server
- ${CMAKE_CURRENT_SOURCE_DIR}/comm_status_broadcast.xml
- --output=${CMAKE_CURRENT_BINARY_DIR}/comm_status_broadcast_server_dbus_bindings.h
- )
-
-
### Build modules
## client for apps
# Send request, get status signal
add_library(pkgmgr_installer_client SHARED
comm_client_gdbus.c
- comm_pkg_mgr_client_gdbus_generated.c
)
set_target_properties(pkgmgr_installer_client PROPERTIES SOVERSION ${VERSION_MAJOR})
set_target_properties(pkgmgr_installer_client PROPERTIES VERSION ${VERSION})
set_target_properties(pkgmgr_installer_client PROPERTIES COMPILE_FLAGS "${installer_client_pkgs_CFLAGS_str}")
target_link_libraries(pkgmgr_installer_client ${installer_client_pkgs_LDFLAGS})
-add_dependencies(pkgmgr_installer_client comm_pkg_mgr_client_gdbus_generated.h comm_pkg_mgr_client_gdbus_generated.c)
-
-## pkg-mgr server for PMS
-# Get request
-add_library(pkgmgr_installer_pkg_mgr_server STATIC
- comm_pkg_mgr_server.c)
-set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES SOVERSION ${VERSION_MAJOR})
-set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES VERSION ${VERSION})
-set_target_properties(pkgmgr_installer_pkg_mgr_server PROPERTIES COMPILE_FLAGS "${comm_pkgs_CFLAGS_str}")
-target_link_libraries(pkgmgr_installer_pkg_mgr_server ${comm_pkgs_LDFLAGS})
-add_dependencies(pkgmgr_installer_pkg_mgr_server comm_pkg_mgr_server_dbus_bindings.h)
-
-## status-broadcast server for backend/downloader
-# Send signal
-add_library(pkgmgr_installer_status_broadcast_server SHARED
- comm_status_broadcast_server_dbus.c
- )
-set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES SOVERSION ${VERSION_MAJOR})
-set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES VERSION ${VERSION})
-set_target_properties(pkgmgr_installer_status_broadcast_server PROPERTIES COMPILE_FLAGS "${broadcast_server_pkgs_CFLAGS_str}")
-target_link_libraries(pkgmgr_installer_status_broadcast_server ${broadcast_server_pkgs_LDFLAGS})
-add_dependencies(pkgmgr_installer_status_broadcast_server comm_status_broadcast_server_dbus_bindings.h)
-
## pkgmgr_installer object (by youmin.ha)
# This library is for installer backend
set_target_properties(pkgmgr_installer PROPERTIES SOVERSION ${VERSION_MAJOR})
set_target_properties(pkgmgr_installer PROPERTIES VERSION ${VERSION})
set_target_properties(pkgmgr_installer PROPERTIES COMPILE_FLAGS "${installer_pkgs_CFLAGS_str}")
-target_link_libraries(pkgmgr_installer pkgmgr_installer_status_broadcast_server ${installer_pkgs_LDFLAGS})
+target_link_libraries(pkgmgr_installer ${installer_pkgs_LDFLAGS})
### Create pc file
configure_file(pkgmgr-installer-client.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc @ONLY)
-configure_file(pkgmgr-installer-status-broadcast-server.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc @ONLY)
configure_file(pkgmgr-installer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc @ONLY)
## Install
INSTALL(TARGETS
pkgmgr_installer_client
- pkgmgr_installer_status_broadcast_server
pkgmgr_installer
DESTINATION ${LIB_INSTALL_DIR}
COMPONENT RuntimeLibraries)
INSTALL(FILES
comm_client.h
- comm_status_broadcast_server.h
comm_config.h
pkgmgr_installer.h
DESTINATION include/pkgmgr)
INSTALL(FILES
${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-client.pc
- ${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer-status-broadcast-server.pc
${CMAKE_CURRENT_BINARY_DIR}/pkgmgr-installer.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
#include "comm_config.h"
#include "comm_client.h"
-#include "comm_pkg_mgr_client_gdbus_generated.h"
#include "comm_debug.h"
/*******************
/* Storing status_cb */
struct signal_callback_data {
+ int type;
status_cb cb;
void *cb_data;
};
struct signal_callback_data *sig_cb_data;
};
-#define COMM_CLIENT_RETRY_MAX 5
-
-static int __retry_request(comm_client *cc,
- const gchar *req_id,
- gint req_type,
- const gchar *pkg_type,
- const gchar *pkgid,
- const gchar *args,
- uid_t uid,
- gint *ret)
-{
- OrgTizenSlpPkgmgr *proxy;
- GError *error = NULL;
- int rc = 0;
-
- proxy = org_tizen_slp_pkgmgr_proxy_new_sync(cc->conn,
- G_DBUS_PROXY_FLAGS_NONE, COMM_PKG_MGR_DBUS_SERVICE,
- COMM_PKG_MGR_DBUS_PATH,
- NULL, &error);
- if (proxy == NULL) {
- ERR("Unable to create proxy[rc=%d, err=%s]\n", rc, error->message);
- return FALSE;
- }
-
- rc = org_tizen_slp_pkgmgr_call_request_sync(proxy,
- req_id, req_type, pkg_type, pkgid, args, uid, ret, NULL, &error);
- if (!rc) {
- ERR("Failed to send request[rc=%d, err=%s]\n", rc, error->message);
- return FALSE;
- }
- return TRUE;
-}
-
-static const gchar *__get_interface(int status_type)
+static int __get_signal_type(const char *name)
{
- char *ifc = NULL;
-
- switch (status_type) {
- case COMM_STATUS_BROADCAST_ALL:
- ifc = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL:
- ifc = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_UNINSTALL:
- ifc = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_MOVE:
- ifc = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
- ifc = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_UPGRADE:
- ifc = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_GET_SIZE:
- ifc = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
- break;
+ if (name == NULL)
+ return -1;
- default:
- break;
- }
- return ifc;
+ if (strcmp(name, COMM_STATUS_BROADCAST_SIGNAL_STATUS) == 0)
+ return COMM_STATUS_BROADCAST_ALL;
+ else if (strcmp(name, COMM_STATUS_BROADCAST_EVENT_INSTALL) == 0)
+ return COMM_STATUS_BROADCAST_INSTALL;
+ else if (strcmp(name, COMM_STATUS_BROADCAST_EVENT_UNINSTALL) == 0)
+ return COMM_STATUS_BROADCAST_UNINSTALL;
+ else if (strcmp(name, COMM_STATUS_BROADCAST_EVENT_MOVE) == 0)
+ return COMM_STATUS_BROADCAST_MOVE;
+ else if (strcmp(name, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS) == 0)
+ return COMM_STATUS_BROADCAST_INSTALL_PROGRESS;
+ else if (strcmp(name, COMM_STATUS_BROADCAST_EVENT_UPGRADE) == 0)
+ return COMM_STATUS_BROADCAST_UPGRADE;
+ else if (strcmp(name, COMM_STATUS_BROADCAST_EVENT_GET_SIZE) == 0)
+ return COMM_STATUS_BROADCAST_GET_SIZE;
+ else
+ return -1;
}
/**
GVariant *parameters,
gpointer user_data)
{
- if (interface_name && strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INTERFACE) &&
- strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE) &&
- strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE) &&
- strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE) &&
- strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE) &&
- strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE) &&
- strcmp(interface_name, COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE)) {
+ if (interface_name && strcmp(interface_name, "org.tizen.pkgmgr.signal")) {
DBG("Interface name did not match. Drop the message");
return;
}
- if (signal_name && strcmp(signal_name, COMM_STATUS_BROADCAST_SIGNAL_STATUS) &&
- strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL) &&
- strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UNINSTALL) &&
- strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_UPGRADE) &&
- strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_MOVE) &&
- strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS) &&
- strcmp(signal_name, COMM_STATUS_BROADCAST_EVENT_GET_SIZE)) {
- DBG("Signal name did not match. Drop the message");
- return;
- }
+
+ int status_type;
/* Values to be received by signal */
uid_t target_uid;
char *req_id = NULL;
else
return;
+ status_type = __get_signal_type(signal_name);
+ if (status_type < 0 || !(status_type & sig_cb_data->type))
+ return;
+
g_variant_get(parameters, "(u&s&s&s&s&s)",
&target_uid, &req_id, &pkg_type, &pkgid, &key, &val);
* Request a message
*/
int
-comm_client_request(
- comm_client *cc,
- const char *req_id,
- const int req_type,
- const char *pkg_type,
- const char *pkgid,
- const char *args,
- uid_t uid,
- int is_block)
+comm_client_request(comm_client *cc, const char *req_id, const int req_type,
+ const char *pkg_type, const char *pkgid, const char *args,
+ uid_t uid, int is_block)
{
GError *error = NULL;
- int rc = 0;
- int ret = 0;
- int retry_cnt = 0;
+ gint rc = -1;
+ GDBusProxy *proxy;
+ GVariant *result;
- OrgTizenSlpPkgmgr *proxy;
- if (!cc){
- ERR("Invalid gdbus input");
- return COMM_RET_ERROR;
- }
- proxy = org_tizen_slp_pkgmgr_proxy_new_sync(cc->conn,
- G_DBUS_PROXY_FLAGS_NONE, COMM_PKG_MGR_DBUS_SERVICE,
- COMM_PKG_MGR_DBUS_PATH,
- NULL, &error);
+ proxy = g_dbus_proxy_new_sync(cc->conn, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ COMM_PKGMGR_DBUS_SERVICE, COMM_PKGMGR_DBUS_OBJECT_PATH,
+ COMM_PKGMGR_DBUS_INTERFACE, NULL, &error);
if (proxy == NULL) {
- ERR("Unable to create proxy[rc=%d, err=%s]\n", rc, error->message);
- return COMM_RET_ERROR;
+ ERR("failed to get proxy object: %s", error->message);
+ g_error_free(error);
+ return -1;
}
/* Assign default values if NULL (NULL is not allowed) */
if (args == NULL)
args = "";
- rc = org_tizen_slp_pkgmgr_call_request_sync(proxy,
- req_id, req_type, pkg_type, pkgid, args, uid, &ret, NULL, &error);
-
- while ((rc == FALSE) && (retry_cnt < COMM_CLIENT_RETRY_MAX)) {
- ERR("Failed to send request, sleep and retry[rc=%d, err=%s]\n", rc, error->message);
- sleep(1);
+ result = g_dbus_proxy_call_sync(proxy, "Request", g_variant_new("(sisssi)", req_id, req_type, pkg_type, pkgid, args, uid),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (result == NULL) {
+ ERR("failed to call %s", error->message);
+ g_error_free(error);
+ g_object_unref(proxy);
+ return -1;
+ }
- retry_cnt++;
+ g_variant_get(result, "(i)", &rc);
- rc = __retry_request(cc, req_id, req_type, pkg_type, pkgid, args, uid, &ret);
- if(rc == TRUE) {
- ERR("__retry_request is success[retry_cnt=%d]\n", retry_cnt);
- }
- }
-
- return rc == TRUE ? COMM_RET_OK : COMM_RET_ERROR;
+ return rc == 0 ? COMM_RET_OK : COMM_RET_ERROR;
}
/**
comm_client_set_status_callback(int comm_status_type, comm_client *cc, status_cb cb, void *cb_data)
{
int r = COMM_RET_ERROR;
- const char *ifc = NULL;
if (NULL == cc)
return COMM_RET_ERROR;
- ifc = __get_interface(comm_status_type);
- if (ifc == NULL) {
- ERR("Invalid interface name\n");
- return COMM_RET_ERROR;
- }
-
/* Create new sig_cb_data */
cc->sig_cb_data = calloc(1, sizeof(struct signal_callback_data));
if ( cc->sig_cb_data ) {
+ (cc->sig_cb_data)->type = comm_status_type;
(cc->sig_cb_data)->cb = cb;
(cc->sig_cb_data)->cb_data = cb_data;
} else {
goto ERROR_CLEANUP;
}
/* Add a filter for signal */
- cc->subscription_id = g_dbus_connection_signal_subscribe(cc->conn, NULL, ifc,
+ cc->subscription_id = g_dbus_connection_signal_subscribe(cc->conn, NULL, "org.tizen.pkgmgr.signal",
NULL, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
_on_signal_handle_filter, (gpointer)cc->sig_cb_data, _free_sig_cb_data);
if (!cc->subscription_id) {
/* from comm_pkg_mgr.xml
*/
-#define COMM_PKG_MGR_DBUS_SERVICE "org.tizen.slp.pkgmgr"
-#define COMM_PKG_MGR_DBUS_PATH "/org/tizen/slp/pkgmgr"
-#define COMM_PKG_MGR_DBUS_INTERFACE "org.tizen.slp.pkgmgr"
-#define COMM_PKG_MGR_METHOD_REQUEST "Request"
-#define COMM_PKG_MGR_METHOD_ECHO_STRING "EchoString"
+#define COMM_PKGMGR_DBUS_SERVICE "org.tizen.pkgmgr"
+#define COMM_PKGMGR_DBUS_OBJECT_PATH "/org/tizen/pkgmgr"
+#define COMM_PKGMGR_DBUS_INTERFACE "org.tizen.pkgmgr"
/* from comm_status_broadcast
*/
-#define COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX \
- "org.tizen.slp.pkgmgr_status"
-#define COMM_STATUS_BROADCAST_DBUS_PATH \
- "/org/tizen/slp/pkgmgr_status"
-#define COMM_STATUS_BROADCAST_DBUS_INTERFACE \
- "org.tizen.slp.pkgmgr_status"
+#define COMM_STATUS_BROADCAST_INTERFACE "org.tizen.pkgmgr.signal"
+#define COMM_STATUS_BROADCAST_OBJECT_PATH "/org/tizen/pkgmgr/signal"
#define COMM_STATUS_BROADCAST_SIGNAL_STATUS "status"
-
-#define COMM_STATUS_BROADCAST_DBUS_INSTALL_SERVICE_PREFIX "org.tizen.slp.pkgmgr.install"
-#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH "/org/tizen/slp/pkgmgr/install"
-#define COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE "org.tizen.slp.pkgmgr.install"
#define COMM_STATUS_BROADCAST_EVENT_INSTALL "install"
-
-#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_SERVICE_PREFIX "org.tizen.slp.pkgmgr.uninstall"
-#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH "/org/tizen/slp/pkgmgr/uninstall"
-#define COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE "org.tizen.slp.pkgmgr.uninstall"
#define COMM_STATUS_BROADCAST_EVENT_UNINSTALL "uninstall"
-
-#define COMM_STATUS_BROADCAST_DBUS_MOVE_SERVICE_PREFIX "org.tizen.slp.pkgmgr.move"
-#define COMM_STATUS_BROADCAST_DBUS_MOVE_PATH "/org/tizen/slp/pkgmgr/move"
-#define COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE "org.tizen.slp.pkgmgr.move"
#define COMM_STATUS_BROADCAST_EVENT_MOVE "move"
-
-#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_SERVICE_PREFIX "org.tizen.slp.pkgmgr.install.progress"
-#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_PATH "/org/tizen/slp/pkgmgr/install/progress"
-#define COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE "org.tizen.slp.pkgmgr.install.progress"
#define COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS "install_progress"
-
-#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_SERVICE_PREFIX "org.tizen.slp.pkgmgr.upgrade"
-#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH "/org/tizen/slp/pkgmgr/upgrade"
-#define COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE "org.tizen.slp.pkgmgr.upgrade"
#define COMM_STATUS_BROADCAST_EVENT_UPGRADE "upgrade"
-
-#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_SERVICE_PREFIX "org.tizen.pkgmgr.get.size"
-#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH "/org/tizen/pkgmgr/get/size"
-#define COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE "org.tizen.pkgmgr.get.size"
#define COMM_STATUS_BROADCAST_EVENT_GET_SIZE "get_size"
/********
/* broadcast type */
enum {
- COMM_STATUS_BROADCAST_ALL = 1,
- COMM_STATUS_BROADCAST_INSTALL,
- COMM_STATUS_BROADCAST_UNINSTALL,
- COMM_STATUS_BROADCAST_MOVE,
- COMM_STATUS_BROADCAST_INSTALL_PROGRESS,
- COMM_STATUS_BROADCAST_UPGRADE,
- COMM_STATUS_BROADCAST_GET_SIZE,
- COMM_STATUS_BROADCAST_MAX
+ COMM_STATUS_BROADCAST_ALL = 0x3F,
+ COMM_STATUS_BROADCAST_INSTALL = 0x01,
+ COMM_STATUS_BROADCAST_UNINSTALL = 0x02,
+ COMM_STATUS_BROADCAST_MOVE = 0x04,
+ COMM_STATUS_BROADCAST_INSTALL_PROGRESS = 0x08,
+ COMM_STATUS_BROADCAST_UPGRADE = 0x10,
+ COMM_STATUS_BROADCAST_GET_SIZE = 0x20,
};
#endif /* __COMM_CONFIG_H__ */
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-
-<node name="/org/tizen/slp/pkgmgr">
- <interface name="org.tizen.slp.pkgmgr">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="pkgmgr" />
- <method name="Request">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="yes" />
- <arg type="s" name="req_id" direction="in" />
- <arg type="i" name="req_type" direction="in" />
- <arg type="s" name="pkg_type" direction="in" />
- <arg type="s" name="pkgid" direction="in" />
- <arg type="s" name="args" direction="in" />
- <arg type="i" name="uid" direction="in" />
- <arg type="i" name="ret" direction="out" />
- </method>
- </interface>
-</node>
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#include "comm_config.h"
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <cynara-client.h>
-#include <cynara-creds-dbus.h>
-#include <cynara-session.h>
-
-#include "comm_pkg_mgr_server.h"
-#include "comm_debug.h"
-
-#define BUFMAX 128
-
-/* object class def: do nothing on this */
-struct PkgMgrObjectClass {
- GObjectClass parent_class;
-};
-
-/* object def: has connection */
-struct PkgMgrObject {
- GObject parent;
-
- DBusGConnection *bus;
-
- request_callback req_cb;
- void *req_cb_data;
-};
-
-#define PKG_MGR_OBJECT(object) \
-(G_TYPE_CHECK_INSTANCE_CAST((object), \
- PKG_MGR_TYPE_OBJECT, PkgMgrObject))
-#define PKG_MGR_OBJECT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), \
- PKG_MGR_TYPE_OBJECT, PkgMgrObjectClass))
-#define PKG_MGR_IS_OBJECT(object) \
- (G_TYPE_CHECK_INSTANCE_TYPE((object), \
- PKG_MGR_TYPE_OBJECT))
-#define PKG_MGR_IS_OBJECT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), \
- PKG_MGR_TYPE_OBJECT))
-#define PKG_MGR_OBJECT_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS((obj), \
- PKG_MGR_TYPE_OBJECT, PkgMgrObjectClass))
-
-/* Macro that creates follwoing functions automatically;
- * - pkgmgr_object_get_type()
- * - pkgmgr_object_parent_class
- */
-G_DEFINE_TYPE(PkgMgrObject, pkg_mgr_object, G_TYPE_OBJECT);
-
-/* Method declarations
- * Used for binding stub.
- */
-static gboolean pkgmgr_request(PkgMgrObject *obj, const gchar *req_id,
- const gint req_type, const gchar *pkg_type,
- const gchar *pkgid, const gchar *args,
- uid_t uid, DBusGMethodInvocation *invocation);
-
-/* Include stub header */
-#include "comm_pkg_mgr_server_dbus_bindings.h"
-
-static void pkg_mgr_object_finalize(GObject *self);
-static void pkg_mgr_object_init(PkgMgrObject *obj);
-static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass);
-static void pkg_mgr_object_init(PkgMgrObject *obj)
-{
- DBG("called");
- g_assert(NULL != obj);
-
- GError *err = NULL;
-
- /* Establish dbus session */
- obj->bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err);
- if (NULL == obj->bus) {
- DBG("Failed to open connection to dbus: %s", err->message);
- return;
- }
-
- /* Create a proxy to resgister, connecting dbus daemon */
- DBusGProxy *proxy = NULL;
- proxy = dbus_g_proxy_new_for_name(obj->bus,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- if (NULL == proxy) {
- DBG("Failed to get a proxy");
- return;
- }
- /* Register service name
- * NOTE: refer to
- http://dbus.freedesktop.org/doc/dbus-specification.html
- */
- guint result;
- if (!dbus_g_proxy_call(proxy, "RequestName", &err,
- /* input vars */
- G_TYPE_STRING, COMM_PKG_MGR_DBUS_SERVICE,
- /* service name */
- G_TYPE_UINT, 0, /* default flag */
- G_TYPE_INVALID,
- /* output vars */
- G_TYPE_UINT, &result, G_TYPE_INVALID)) {
- g_printerr("dbus RequestName RPC failed %s %d", err->message, TRUE);
- return;
- }
- DBG("RequestName returns: %d", result);
-
- dbus_g_connection_register_g_object(obj->bus,
- COMM_PKG_MGR_DBUS_PATH,
- G_OBJECT(obj));
- DBG("Ready to serve requests");
-
- g_object_unref(proxy);
-
- DBG("done");
-}
-
-static void pkg_mgr_object_class_init(PkgMgrObjectClass *klass)
-{
- DBG("called");
-
- g_assert(NULL != klass);
-
- dbus_g_object_type_install_info(PKG_MGR_TYPE_OBJECT,
- &dbus_glib_pkgmgr_object_info);
-
- DBG("done");
-}
-
-static void pkg_mgr_object_finalize(GObject *self)
-{
- /* PkgMgrObjectClass *klass = (PkgMgrObjectClass *) G_OBJECT_CLASS(self); */
-
- /* Call parent's finalize function
- * 'server_object_parent_class' comes from G_DEFINE_TYPE() macro.
- */
- G_OBJECT_CLASS(pkg_mgr_object_parent_class)->finalize(self);
-}
-
-/* dbus-glib methods */
-
-static gboolean
-pkgmgr_request(PkgMgrObject *obj,
- const gchar *req_id,
- const gint req_type,
- const gchar *pkg_type,
- const gchar *pkgid,
- const gchar *args,
- uid_t uid,
- DBusGMethodInvocation *invocation)
-{
- DBusConnection *con;
- gchar *sender = NULL;
- char *client = NULL;
- char *session = NULL;
- char *user = NULL;
- pid_t pid;
- int ret;
- char buf[BUFMAX] = {0, };
- int r;
-
- DBG("Called");
- ret = COMM_RET_OK; /* TODO: fix this! */
-
- /* TODO: Add business logic
- * - add to queue, or remove from queue
- * */
- do {
- con = dbus_g_connection_get_connection(obj->bus);
- sender = dbus_g_method_get_sender(invocation);
- if (sender == NULL) {
- ERR("get sender failed");
- ret = COMM_RET_ERROR;
- break;
- }
-
- r = cynara_creds_dbus_get_client(con, sender,
- CLIENT_METHOD_DEFAULT, &client);
- if (r != CYNARA_API_SUCCESS) {
- cynara_strerror(r, buf, BUFMAX);
- ERR("cynara_creds_dbus_get_client failed: %s", buf);
- ret = COMM_RET_ERROR;
- break;
- }
-
- r = cynara_creds_dbus_get_user(con, sender,
- USER_METHOD_DEFAULT, &user);
- if (r != CYNARA_API_SUCCESS) {
- cynara_strerror(r, buf, BUFMAX);
- ERR("cynara_creds_dbus_get_user failed: %s", buf);
- ret = COMM_RET_ERROR;
- break;
- }
-
- r = cynara_creds_dbus_get_pid(con, sender, &pid);
- if (r != CYNARA_API_SUCCESS) {
- cynara_strerror(r, buf, BUFMAX);
- ERR("cynara_creds_dbus_get_pid failed: %s", buf);
- ret = COMM_RET_ERROR;
- break;
- }
-
- session = cynara_session_from_pid(pid);
- if (session == NULL) {
- ERR("cynara_session_from_pid failed");
- ret = COMM_RET_ERROR;
- break;
- }
- } while (0);
-
- if (obj->req_cb && ret != COMM_RET_ERROR) {
- DBG("Call request callback(obj, %lu, %s, %d, %s, %s, %s)",
- uid, req_id, req_type, pkg_type, pkgid, args);
- obj->req_cb(obj->req_cb_data, uid, req_id, req_type, pkg_type,
- pkgid, args, client, session, user, &ret);
- } else {
- DBG("Attempt to call request callback,"
- " but request callback is not set. Do nothing.\n"
- "Use pkg_mgr_set_request_callback()"
- " to register your callback.");
- }
-
- if (sender)
- g_free(sender);
- if (client)
- free(client);
- if (session)
- free(session);
- if (user)
- free(user);
-
- dbus_g_method_return(invocation, ret);
-
- return TRUE;
-}
-
-/* Other APIs
- */
-
-/**
- * Set request callback function
- */
-void pkg_mgr_set_request_callback(PkgMgrObject *obj, request_callback req_cb,
- void *cb_data)
-{
- obj->req_cb = req_cb;
- obj->req_cb_data = cb_data;
-}
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#ifndef __COMM_PKG_MGR_SERVER_H__
-#define __COMM_PKG_MGR_SERVER_H__
-
-#include "comm_config.h"
-#include <glib-object.h>
-
-typedef struct PkgMgrObjectClass PkgMgrObjectClass;
-typedef struct PkgMgrObject PkgMgrObject;
-
-/* For returning server object's GType.
- * I don't use this. Just forward declaration for G_DEFINE_TYPE() macro. */
-API GType pkg_mgr_object_get_type(void);
-#define PKG_MGR_TYPE_OBJECT (pkg_mgr_object_get_type())
-
-typedef void (*request_callback) (void *cb_data, uid_t uid, const char *req_id,
- const int req_type, const char *pkg_type,
- const char *pkgid, const char *args,
- const char *client, const char *session,
- const char *user, int *ret);
-
-API void pkg_mgr_set_request_callback(PkgMgrObject *obj,
- request_callback req_cb, void *cb_data);
-
-#endif /* __COMM_PKG_MGR_SERVER_H__ */
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-
-<node name="/org/tizen/slp/pkgmgr_status">
- <interface name="org.tizen.slp.pkgmgr_status">
- <signal name="status">
- <arg type="i" name="target_uid" direction="out" />
- <arg type="s" name="req_id" direction="out" />
- <arg type="s" name="pkgtype" direction="out" />
- <arg type="s" name="pkgid" direction="out" />
- <arg type="s" name="key" direction="out" />
- <arg type="s" name="val" direction="out" />
- </signal>
- </interface>
-</node>
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#ifndef __COMM_STATUS_BROADCAST_SERVER_H__
-#define __COMM_STATUS_BROADCAST_SERVER_H__
-
-#include <sys/types.h>
-#include "comm_config.h"
-#include <dbus/dbus.h>
-
-/* pure dbus api */
-API DBusConnection *comm_status_broadcast_server_connect(int comm_status_type);
-API void comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *conn,
- uid_t target_uid,
- const char *req_id,
- const char *pkg_type,
- const char *pkgid,
- const char *key,
- const char *val);
-API void comm_status_broadcast_server_disconnect(DBusConnection *conn);
-#endif /* __COMM_STATUS_BROADCAST_SERVER_H__ */
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#include "comm_config.h"
-#include "comm_status_broadcast_server.h"
-#include "comm_debug.h"
-#include <dbus/dbus.h>
-
-/********************************************
- * pure dbus signal service for internal use
- ********************************************/
-static char *__get_prifix(int status_type)
-{
- char *prifix = NULL;
-
- switch (status_type) {
- case COMM_STATUS_BROADCAST_ALL:
- prifix = COMM_STATUS_BROADCAST_DBUS_SERVICE_PREFIX;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL:
- prifix = COMM_STATUS_BROADCAST_DBUS_INSTALL_SERVICE_PREFIX;
- break;
-
- case COMM_STATUS_BROADCAST_UNINSTALL:
- prifix = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_SERVICE_PREFIX;
- break;
-
- case COMM_STATUS_BROADCAST_MOVE:
- prifix = COMM_STATUS_BROADCAST_DBUS_MOVE_SERVICE_PREFIX;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
- prifix = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_SERVICE_PREFIX;
- break;
-
- case COMM_STATUS_BROADCAST_UPGRADE:
- prifix = COMM_STATUS_BROADCAST_DBUS_UPGRADE_SERVICE_PREFIX;
- break;
-
- case COMM_STATUS_BROADCAST_GET_SIZE:
- prifix = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_SERVICE_PREFIX;
- break;
-
- default:
- prifix = NULL;
- }
- return prifix;
-}
-
-static char *__get_path(int status_type)
-{
- char *path = NULL;
-
- switch (status_type) {
- case COMM_STATUS_BROADCAST_ALL:
- path = COMM_STATUS_BROADCAST_DBUS_PATH;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL:
- path = COMM_STATUS_BROADCAST_DBUS_INSTALL_PATH;
- break;
-
- case COMM_STATUS_BROADCAST_UNINSTALL:
- path = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_PATH;
- break;
-
- case COMM_STATUS_BROADCAST_MOVE:
- path = COMM_STATUS_BROADCAST_DBUS_MOVE_PATH;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
- path = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_PATH;
- break;
-
- case COMM_STATUS_BROADCAST_UPGRADE:
- path = COMM_STATUS_BROADCAST_DBUS_UPGRADE_PATH;
- break;
-
- case COMM_STATUS_BROADCAST_GET_SIZE:
- path = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_PATH;
- break;
-
- default:
- path = NULL;
- }
- return path;
-}
-
-static char *__get_interface(int status_type)
-{
- char *interface = NULL;
-
- switch (status_type) {
- case COMM_STATUS_BROADCAST_ALL:
- interface = COMM_STATUS_BROADCAST_DBUS_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL:
- interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_UNINSTALL:
- interface = COMM_STATUS_BROADCAST_DBUS_UNINSTALL_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_MOVE:
- interface = COMM_STATUS_BROADCAST_DBUS_MOVE_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
- interface = COMM_STATUS_BROADCAST_DBUS_INSTALL_PROGRESS_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_UPGRADE:
- interface = COMM_STATUS_BROADCAST_DBUS_UPGRADE_INTERFACE;
- break;
-
- case COMM_STATUS_BROADCAST_GET_SIZE:
- interface = COMM_STATUS_BROADCAST_DBUS_GET_SIZE_INTERFACE;
- break;
-
- default:
- interface = NULL;
- }
- return interface;
-}
-
-static char *__get_name(int status_type)
-{
- char *name = NULL;
-
- switch (status_type) {
- case COMM_STATUS_BROADCAST_ALL:
- name = COMM_STATUS_BROADCAST_SIGNAL_STATUS;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL:
- name = COMM_STATUS_BROADCAST_EVENT_INSTALL;
- break;
-
- case COMM_STATUS_BROADCAST_UNINSTALL:
- name = COMM_STATUS_BROADCAST_EVENT_UNINSTALL;
- break;
-
- case COMM_STATUS_BROADCAST_MOVE:
- name = COMM_STATUS_BROADCAST_EVENT_MOVE;
- break;
-
- case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
- name = COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS;
- break;
-
- case COMM_STATUS_BROADCAST_UPGRADE:
- name = COMM_STATUS_BROADCAST_EVENT_UPGRADE;
- break;
-
- case COMM_STATUS_BROADCAST_GET_SIZE:
- name = COMM_STATUS_BROADCAST_EVENT_GET_SIZE;
- break;
-
- default:
- name = NULL;
- }
- return name;
-}
-
-API DBusConnection *comm_status_broadcast_server_connect(int status_type)
-{
- DBusError err;
- DBusConnection *conn;
-
- dbus_error_init(&err);
-
- conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err);
- if (dbus_error_is_set(&err)) {
- DBG("Connection error: %s", err.message);
- dbus_error_free(&err);
- }
- dbus_error_free(&err);
- if (NULL == conn) {
- DBG("conn is NULL");
- return NULL;
- }
-
- dbus_bus_request_name(conn, __get_prifix(status_type), DBUS_NAME_FLAG_ALLOW_REPLACEMENT, &err);
- if (dbus_error_is_set(&err)) {
- DBG("Failed to request name: %s", err.message);
- dbus_error_free(&err);
- return NULL;
- }
-
- return conn;
-}
-
-API void
-comm_status_broadcast_server_send_signal(int comm_status_type, DBusConnection *conn,
- uid_t target_uid,
- const char *req_id,
- const char *pkg_type,
- const char *pkgid, const char *key,
- const char *val)
-{
- dbus_uint32_t serial = 0;
- DBusMessage *msg;
- DBusMessageIter args;
-
- const char *values[] = {
- req_id,
- pkg_type,
- pkgid,
- key,
- val
- };
- int i;
-
- if (conn == NULL) {
- DBG("dbus conn is NULL");
- return;
- }
-
- msg = dbus_message_new_signal(__get_path(comm_status_type), __get_interface(comm_status_type), __get_name(comm_status_type));
- if (NULL == msg) {
- DBG("msg NULL");
- return;
- }
-
- dbus_message_iter_init_append(msg, &args);
-
- if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_UINT32,
- &target_uid)) {
- DBG("dbus_message_iter_append_basic failed: Out of memory");
- return;
- }
-
- for (i = 0; i < 5; i++) {
- if (!dbus_message_iter_append_basic
- (&args, DBUS_TYPE_STRING, &(values[i]))) {
- DBG("dbus_message_iter_append_basic failed:"
- " Out of memory");
- return;
- }
- }
- if (!dbus_connection_send(conn, msg, &serial)) {
- DBG("dbus_connection_send failed: Out of memory");
- return;
- }
- dbus_connection_flush(conn);
- dbus_message_unref(msg);
-}
-
-API void comm_status_broadcast_server_disconnect(DBusConnection *conn)
-{
- if (!conn)
- return;
- dbus_connection_unref(conn);
-}
+++ /dev/null
-/*
- * slp-pkgmgr
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-
-
-#ifndef __ERROR_REPORT_H__
-#define __ERROR_REPORT_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Error reporting: kernel style */
-#include <errno.h>
-#define MAX_ERRNO 4095
-#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
-static inline void *ERR_PTR(long error)
-{
- return (void *)error;
-}
-#ifdef __cplusplus
-}
-#endif
-#endif /* __ERROR_REPORT_H__ */
Name: package manager installer
Description: SLP package manager's installer library
Version: @VERSION@
-Requires: dbus-1 dbus-glib-1
+Requires:
Libs: -L${libdir} -lpkgmgr_installer_client
Cflags: -I${includedir}/pkgmgr
+++ /dev/null
-#
-# Copyright (c) 2008 ~ 2010 Samsung Electronics Co., Ltd.
-# All rights reserved.
-#
-
-prefix=@PREFIX@
-exec_prefix=@EXEC_PREFIX@
-libdir=@LIBDIR@
-includedir=@INCLUDEDIR@
-
-Name: package manager installer
-Description: SLP package manager's installer library
-Version: @VERSION@
-Requires: dbus-1 dbus-glib-1
-Libs: -L${libdir} -lpkgmgr_installer_status_broadcast_server
-Cflags: -I${includedir}/pkgmgr
Name: package manager installer library
Description: SLP package manager's installer lib for each backends
Version: @VERSION@
-Requires: pkgmgr-installer-status-broadcast-server
+Requires:
Libs: -L${libdir} -lpkgmgr_installer
Cflags: -I${includedir}/pkgmgr
#include <string.h>
#include <getopt.h>
+#include <gio/gio.h>
+
#include "pkgmgr_installer.h"
#include "pkgmgr_installer_config.h"
#include "comm_config.h"
-#include "comm_status_broadcast_server.h"
#include "comm_debug.h"
-#include "error_report.h"
#include <pkgmgr-info.h>
#define CHK_PI_RET(r) \
do { if (NULL == pi) return (r); } while (0)
-/* ADT */
struct pkgmgr_installer {
int request_type;
int move_type;
char *caller_pkgid;
uid_t target_uid;
- DBusConnection *conn;
+ GDBusConnection *conn;
};
-/* API */
+static const char *__get_signal_name(int status_type)
+{
+ switch (status_type) {
+ case COMM_STATUS_BROADCAST_ALL:
+ return COMM_STATUS_BROADCAST_SIGNAL_STATUS;
+ case COMM_STATUS_BROADCAST_INSTALL:
+ return COMM_STATUS_BROADCAST_EVENT_INSTALL;
+ case COMM_STATUS_BROADCAST_UNINSTALL:
+ return COMM_STATUS_BROADCAST_EVENT_UNINSTALL;
+ case COMM_STATUS_BROADCAST_MOVE:
+ return COMM_STATUS_BROADCAST_EVENT_MOVE;
+ case COMM_STATUS_BROADCAST_INSTALL_PROGRESS:
+ return COMM_STATUS_BROADCAST_EVENT_INSTALL_PROGRESS;
+ case COMM_STATUS_BROADCAST_UPGRADE:
+ return COMM_STATUS_BROADCAST_EVENT_UPGRADE;
+ case COMM_STATUS_BROADCAST_GET_SIZE:
+ return COMM_STATUS_BROADCAST_EVENT_GET_SIZE;
+ default:
+ return NULL;
+ }
+}
static int __send_signal_for_event(int comm_status_type, pkgmgr_installer *pi,
const char *pkg_type,
const char *pkgid,
const char *key, const char *val)
{
- if (!pi)
- return -1;
+ char *sid;
+ const char *name;
+ GError *err = NULL;
- if (!pi->conn)
- pi->conn = comm_status_broadcast_server_connect(comm_status_type);
+ if (!pi || pi->conn == NULL)
+ return -1;
- char *sid = pi->session_id;
+ sid = pi->session_id;
if (!sid)
sid = "";
- comm_status_broadcast_server_send_signal(comm_status_type, pi->conn, pi->target_uid, sid, pkg_type, pkgid, key, val);
+
+ name = __get_signal_name(comm_status_type);
+ if (name == NULL) {
+ ERR("unknown signal type");
+ return -1;
+ }
+
+ if (g_dbus_connection_emit_signal(pi->conn, NULL,
+ COMM_STATUS_BROADCAST_OBJECT_PATH,
+ COMM_STATUS_BROADCAST_INTERFACE, name,
+ g_variant_new("(usssss)", getuid(), sid,
+ pkg_type, pkgid, key, val), &err)
+ != TRUE) {
+ ERR("failed to send dbus signal: %s", err->message);
+ g_error_free(err);
+ return -1;
+ }
return 0;
}
API pkgmgr_installer *pkgmgr_installer_new(void)
{
- pkgmgr_installer *pi = NULL;
+ pkgmgr_installer *pi;
+ GError *err = NULL;
+
pi = calloc(1, sizeof(struct pkgmgr_installer));
- if (NULL == pi)
- return ERR_PTR(-ENOMEM);
+ if (pi == NULL)
+ return NULL;
+
+ pi->conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (pi->conn == NULL) {
+ ERR("failed to get bus: %s", err->message);
+ g_error_free(err);
+ free(pi);
+ return NULL;
+ }
pi->request_type = PKGMGR_REQ_INVALID;
free(pi->caller_pkgid);
if (pi->conn)
- comm_status_broadcast_server_disconnect(pi->conn);
+ g_dbus_connection_close_sync(pi->conn, NULL, NULL);
free(pi);
const char *key, const char *val)
{
int r = 0;
+ char *sid;
+
+ if (!pi->conn) {
+ ERR("connection is NULL");
+ return -1;
+ }
if (strcmp(pkg_type,PKGMGR_INSTALLER_GET_SIZE_KEY_STR) == 0) {
r = __send_signal_for_event(COMM_STATUS_BROADCAST_GET_SIZE, pi, pkg_type, pkgid, key, val);
return r;
}
- if (!pi->conn)
- pi->conn = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
-
- char *sid = pi->session_id;
+ sid = pi->session_id;
if (!sid)
sid = "";
- comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, pi->conn, pi->target_uid, sid, pkg_type,
- pkgid, key, val);
- __send_event(pi, pkg_type, pkgid, key, val);
+ r = __send_event(pi, pkg_type, pkgid, key, val);
return r;
}
BuildRequires: unzip
BuildRequires: gettext-tools
BuildRequires: pkgconfig(cynara-client)
-BuildRequires: pkgconfig(cynara-creds-dbus)
+BuildRequires: pkgconfig(cynara-creds-gdbus)
BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-2.0)
-BuildRequires: pkgconfig(gio-unix-2.0)
-BuildRequires: pkgconfig(dbus-1)
-BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(bundle)
BuildRequires: pkgconfig(pkgmgr-info)
%{_datadir}/mime/packages/mime.tpk.xml
%exclude %{_includedir}/pkgmgr/comm_client.h
%exclude %{_includedir}/pkgmgr/comm_config.h
-%exclude %{_includedir}/pkgmgr/comm_status_broadcast_server.h
%exclude %{_sysconfdir}/package-manager/server/queue_status
%files client
%files server
%manifest %{name}-server.manifest
%defattr(-,root,root,-)
-%{_datadir}/dbus-1/system-services/org.tizen.slp.pkgmgr.service
-%config %{_sysconfdir}/dbus-1/system.d/org.tizen.slp.pkgmgr.conf
+%{_datadir}/dbus-1/system-services/org.tizen.pkgmgr.service
+%config %{_sysconfdir}/dbus-1/system.d/org.tizen.pkgmgr.conf
%{_bindir}/pkgmgr-server
%{_sysconfdir}/package-manager/server
%manifest %{name}-installer.manifest
%defattr(-,root,root,-)
%{_libdir}/libpkgmgr_installer.so.*
-%{_libdir}/libpkgmgr_installer_status_broadcast_server.so.*
%{_libdir}/libpkgmgr_installer_client.so.*
%files installer-devel
%defattr(-,root,root,-)
%dir %{_includedir}/pkgmgr
%{_includedir}/pkgmgr/pkgmgr_installer.h
-%{_libdir}/pkgconfig/pkgmgr-installer-status-broadcast-server.pc
%{_libdir}/pkgconfig/pkgmgr-installer.pc
%{_libdir}/pkgconfig/pkgmgr-installer-client.pc
%{_libdir}/libpkgmgr_installer.so
%{_libdir}/libpkgmgr_installer_client.so
-%{_libdir}/libpkgmgr_installer_status_broadcast_server.so
%files types-devel
%manifest %{name}-types-devel.manifest
SET(SRCS src/pkgmgr-server.c src/pm-queue.c)
pkg_check_modules(SERVER_DEPS REQUIRED
+ gio-2.0
cynara-client
+ cynara-creds-gdbus
+ cynara-session
dlog
pkgmgr-parser
pkgmgr-info
INCLUDE_DIRECTORIES(include)
ADD_EXECUTABLE(${PKGMGR_SERVER} ${SRCS})
-TARGET_LINK_LIBRARIES(${PKGMGR_SERVER} pkgmgr_installer pkgmgr_installer_pkg_mgr_server)
+TARGET_LINK_LIBRARIES(${PKGMGR_SERVER} pkgmgr_installer)
TARGET_LINK_LIBRARIES(${PKGMGR_SERVER} ${SERVER_DEPS_LDFLAGS})
-CONFIGURE_FILE(org.tizen.slp.pkgmgr.service.in org.tizen.slp.pkgmgr.service @ONLY)
-CONFIGURE_FILE(org.tizen.slp.pkgmgr.conf.in org.tizen.slp.pkgmgr.conf @ONLY)
+CONFIGURE_FILE(org.tizen.pkgmgr.service.in org.tizen.pkgmgr.service @ONLY)
+CONFIGURE_FILE(org.tizen.pkgmgr.conf.in org.tizen.pkgmgr.conf @ONLY)
INSTALL(TARGETS ${PKGMGR_SERVER} DESTINATION bin)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/queue_status DESTINATION ${SYSCONFDIR}/package-manager/server/)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.slp.pkgmgr.service DESTINATION ${PREFIX}/share/dbus-1/system-services/)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.slp.pkgmgr.conf DESTINATION ${SYSCONFDIR}/dbus-1/system.d/)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.pkgmgr.service DESTINATION ${PREFIX}/share/dbus-1/system-services/)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.pkgmgr.conf DESTINATION ${SYSCONFDIR}/dbus-1/system.d/)
--- /dev/null
+<?xml version="1.0"?>
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+ <policy user="root">
+ <allow own="org.tizen.pkgmgr"/>
+ </policy>
+ <policy context="default">
+ <allow receive_sender="org.tizen.pkgmgr"/>
+ <allow send_destination="org.tizen.pkgmgr"/>
+ </policy>
+</busconfig>
--- /dev/null
+[D-BUS Service]
+User=root
+Name=org.tizen.pkgmgr
+Exec=@PREFIX@/bin/pkgmgr-server
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="root">
- <allow own="org.tizen.slp.pkgmgr"/>
- </policy>
- <policy context="default">
- <allow own="org.tizen.pkgmgr.get.size"/>
- <allow own="org.tizen.slp.pkgmgr_status"/>
- <allow receive_sender="org.tizen.slp.pkgmgr"/>
- <allow send_destination="org.tizen.slp.pkgmgr"/>
- </policy>
-</busconfig>
+++ /dev/null
-[D-BUS Service]
-User=root
-Name=org.tizen.slp.pkgmgr
-Exec=@PREFIX@/bin/pkgmgr-server
#include <signal.h>
#include <glib.h>
+#include <gio/gio.h>
#include <pkgmgr-info.h>
#include <pkgmgr/pkgmgr_parser.h>
#include <cynara-client.h>
+#include <cynara-creds-gdbus.h>
+#include <cynara-session.h>
#include <tzplatform_config.h>
#include "pkgmgr_installer.h"
-#include "comm_pkg_mgr_server.h"
#include "pkgmgr-server.h"
#include "pm-queue.h"
#include "comm_config.h"
OPERATION_MAX
} OPERATION_TYPE;
-typedef enum {
- PMSVC_ALL_APP = 0,
- PMSVC_UI_APP,
- PMSVC_SVC_APP
-}pkgmgr_svc_app_component;
-
static int __check_backend_status_for_exit(void);
static int __check_queue_status_for_exit(void);
static int __is_backend_busy(int position);
static void __unset_backend_mode(int position);
static void sighandler(int signo);
static int __get_position_from_pkg_type(char *pkgtype);
-static int __is_efl_tpk_app(char *pkgpath);
-static int __xsystem(const char *argv[]);
gboolean queue_job(void *data);
gboolean exit_server(void *data);
return -1;
}
-static int __xsystem(const char *argv[])
-{
- int err = 0;
- int status = 0;
- pid_t pid;
-
- pid = fork();
-
- switch (pid) {
- case -1:
- DBG("fork() failed");
- return -1;
- case 0:
- if (execvp(argv[0], (char *const *)argv) == -1) {
- DBG("execvp() failed");
- }
- _exit(100);
- default:
- /* parent */
- do {
- err = waitpid(pid, &status, WUNTRACED | WCONTINUED);
- if (err == -1) {
- DBG("waitpid failed\n");
- return -1;
- }
- } while (!WIFEXITED(status) && !WIFSIGNALED(status));
- break;
- }
- if (WIFEXITED(status))
- return WEXITSTATUS(status);
- else
- return -1;
-}
-
-static int __is_efl_tpk_app(char *pkgid)
-{
- int ret = 0;
- char *type = NULL;
- const char *unzip_argv[] = { "/usr/bin/unzip", "-j", pkgid, "usr/share/packages/*", "-d", "/tmp/efltpk-unzip", NULL };
- const char *unzip_opt_argv[] = { "/usr/bin/unzip", "-j", pkgid, "opt/share/packages/*", "-d", "/tmp/efltpk-unzip", NULL };
- const char *delete_argv[] = { "/bin/rm", "-rf", "/tmp/efltpk-unzip", NULL };
- pkgmgrinfo_pkginfo_h handle;
- /*Check for uninstall case. If we fail to get handle then request is for installation*/
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
- if (ret == PMINFO_R_OK) {
- ret = pkgmgrinfo_pkginfo_get_type(handle, &type);
- if (ret != PMINFO_R_OK) {
- DBG("Failed to get package type\n");
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return -1;
- }
- if (strcmp(type, "efltpk") == 0) {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return 1;
- } else {
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return 0;
- }
- }
- /*Install request*/
- if (strstr(pkgid, ".tpk") == NULL) {
- DBG("TPK package");
- return 0;
- }
- __xsystem(delete_argv);
- ret = mkdir("/tmp/efltpk-unzip", 0755);
- if (ret != 0) {
- DBG("Failed to create temporary directory to unzip tpk package\n");
- return -1;
- }
- /*In case of installation request, pkgid contains the pkgpath*/
- ret = __xsystem(unzip_argv);
- if (ret) {
- ret = __xsystem(unzip_opt_argv);
- if (ret) {
- DBG("Unzip of tpk package failed. error:%d\n", ret);
- if (ret == NO_MATCHING_FILE) /*no matching file found*/
- ret = 0;
- else
- ret = -1;
- goto err;
- } else
- ret = 1;
- } else
- ret = 1;
-err:
- __xsystem(delete_argv);
- return ret;
-}
-
static void send_fail_signal(char *pname, char *ptype, char *args)
{
DBG("send_fail_signal start\n");
if (backend_cmd == NULL)
break;
- if (strcmp(item->pkg_type, "tpk") == 0) {
- ret = __is_efl_tpk_app(item->pkgid);
- if (ret == 1) {
- if (backend_cmd)
- free(backend_cmd);
- backend_cmd = _get_backend_cmd("efltpk");
- }
- }
-
DBG("Try to exec [%s][%s]", item->pkg_type, backend_cmd);
fprintf(stdout, "Try to exec [%s][%s]\n", item->pkg_type, backend_cmd);
}
if (item->req_type == COMM_REQ_KILL_APP) {
- ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMSVC_ALL_APP, __pkgcmd_app_cb, "kill", item->uid);
+ ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, __pkgcmd_app_cb, "kill", item->uid);
if (ret < 0) {
DBG("pkgmgrinfo_appinfo_get_list() failed\n");
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
exit(1);
}
} else if (item->req_type == COMM_REQ_CHECK_APP) {
- ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMSVC_ALL_APP, __pkgcmd_app_cb, "check", item->uid);
+ ret = pkgmgrinfo_appinfo_get_usr_list(handle, PMINFO_ALL_APP, __pkgcmd_app_cb, "check", item->uid);
if (ret < 0) {
DBG("pkgmgrinfo_appinfo_get_list() failed\n");
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
return NULL; /* cannot find proper command */
}
+static int __get_caller_info(GDBusConnection *connection,
+ GDBusMethodInvocation *invocation,
+ char **client, char **user, char **session)
+{
+ const gchar *sender = NULL;
+ pid_t pid;
+ int ret = 0;
+ int r;
+ char buf[BUFMAX] = {0, };
+
+ do {
+ sender = g_dbus_method_invocation_get_sender(invocation);
+ if (sender == NULL) {
+ ERR("get sender failed");
+ ret = COMM_RET_ERROR;
+ break;
+ }
+
+ r = cynara_creds_gdbus_get_client(connection, sender,
+ CLIENT_METHOD_DEFAULT, client);
+ if (r != CYNARA_API_SUCCESS) {
+ cynara_strerror(r, buf, BUFMAX);
+ ERR("cynara_creds_dbus_get_client failed: %s", buf);
+ ret = COMM_RET_ERROR;
+ break;
+ }
+
+ r = cynara_creds_gdbus_get_user(connection, sender,
+ USER_METHOD_DEFAULT, user);
+ if (r != CYNARA_API_SUCCESS) {
+ cynara_strerror(r, buf, BUFMAX);
+ ERR("cynara_creds_dbus_get_user failed: %s", buf);
+ ret = COMM_RET_ERROR;
+ break;
+ }
+
+ r = cynara_creds_gdbus_get_pid(connection, sender, &pid);
+ if (r != CYNARA_API_SUCCESS) {
+ cynara_strerror(r, buf, BUFMAX);
+ ERR("cynara_creds_dbus_get_pid failed: %s", buf);
+ ret = COMM_RET_ERROR;
+ break;
+ }
+
+ *session = cynara_session_from_pid(pid);
+ if (*session == NULL) {
+ ERR("cynara_session_from_pid failed");
+ ret = COMM_RET_ERROR;
+ break;
+ }
+ DBG("session: %s", session);
+ } while (0);
+
+ return ret;
+}
+
+static void __handle_method_call(GDBusConnection *connection,
+ const gchar *sender, const gchar *object_path,
+ const gchar *interface_name, const gchar *method_name,
+ GVariant *parameters, GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ gchar *req_id = NULL;
+ gint req_type = -1;
+ gchar *pkg_type = NULL;
+ gchar *pkgid = NULL;
+ gchar *args = NULL;
+ gint uid = -1;
+ gint ret = -1;
+ char *client;
+ char *user;
+ char *session;
+
+ if (g_strcmp0(method_name, "Request") != 0) {
+ ERR("unknown method call");
+ return;
+ }
+
+ if (__get_caller_info(connection, invocation, &client, &user,
+ &session)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", ret));
+ return;
+ }
+
+ g_variant_get(parameters, "(&si&s&s&si)", &req_id, &req_type, &pkg_type,
+ &pkgid, &args, &uid);
+ if (req_id == NULL || req_type == -1 || pkg_type == NULL ||
+ pkgid == NULL || args == NULL || uid == -1) {
+ ERR("failed to get parameters");
+ free(client);
+ free(user);
+ free(session);
+ return;
+ }
+
+ req_cb(NULL, uid, req_id, req_type, pkg_type, pkgid, args,
+ client, user, session, &ret);
+
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", ret));
+
+ free(client);
+ free(user);
+ free(session);
+}
+
+static const char instropection_xml[] =
+ "<node>"
+ " <interface name='org.tizen.pkgmgr'>"
+ " <method name='Request'>"
+ " <arg type='s' name='req_id' direction='in'/>"
+ " <arg type='i' name='req_type' direction='in'/>"
+ " <arg type='s' name='pkg_type' direction='in'/>"
+ " <arg type='s' name='pkg_id' direction='in'/>"
+ " <arg type='s' name='args' direction='in'/>"
+ " <arg type='i' name='uid' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " </method>"
+ " </interface>"
+ "</node>";
+static const GDBusInterfaceVTable interface_vtable =
+{
+ __handle_method_call,
+ NULL,
+ NULL,
+};
+static GDBusNodeInfo *instropection_data;
+static guint reg_id;
+static guint owner_id;
+
+static void __on_bus_acquired(GDBusConnection *connection, const gchar *name,
+ gpointer user_data)
+{
+
+ DBG("on bus acquired");
+
+ reg_id = g_dbus_connection_register_object(connection,
+ COMM_PKGMGR_DBUS_OBJECT_PATH,
+ instropection_data->interfaces[0],
+ &interface_vtable, NULL, NULL, NULL);
+
+ if (reg_id < 0)
+ ERR("failed to register object");
+}
+
+static void __on_name_acquired(GDBusConnection *connection, const gchar *name,
+ gpointer user_data)
+{
+ DBG("on name acquired: %s", name);
+}
+
+static void __on_name_lost(GDBusConnection *connection, const gchar *name,
+ gpointer user_data)
+{
+ DBG("on name lost: %s", name);
+}
+
+static int __init_dbus(void)
+{
+ instropection_data = g_dbus_node_info_new_for_xml(instropection_xml, NULL);
+
+ owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, COMM_PKGMGR_DBUS_SERVICE,
+ G_BUS_NAME_OWNER_FLAGS_NONE, __on_bus_acquired,
+ __on_name_acquired, __on_name_lost, NULL, NULL);
+
+ return 0;
+}
+
+static void __fini_dbus(void)
+{
+ g_bus_unown_name(owner_id);
+ g_dbus_node_info_unref(instropection_data);
+}
+
int main(int argc, char *argv[])
{
FILE *fp_status = NULL;
return -1;
}
+ r = __init_dbus();
+ if (r) {
+ ERR("dbus init failed");
+ return -1;
+ }
+
#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
#endif
DBG("Main loop is created.");
- PkgMgrObject *pkg_mgr;
- pkg_mgr = g_object_new(PKG_MGR_TYPE_OBJECT, NULL);
- pkg_mgr_set_request_callback(pkg_mgr, req_cb, NULL);
- DBG("pkg_mgr object is created, and request callback is registered.");
-
g_main_loop_run(mainloop);
DBG("Quit main loop.");
- _pm_queue_final();
- __fini_backend_info();
+ __fini_dbus();
cynara_finish(p_cynara);
+ __fini_backend_info();
+ _pm_queue_final();
DBG("package manager server terminated.");
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs_initdb REQUIRED libsmack dbus-1 libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config)
+pkg_check_modules(pkgs_initdb REQUIRED libsmack libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config)
FOREACH(flag ${pkgs_initdb_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-pkg_check_modules(pkgs_test REQUIRED dlog dbus-1 libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config security-manager)
+pkg_check_modules(pkgs_test REQUIRED dlog libxml-2.0 bundle pkgmgr-parser pkgmgr-info libtzplatform-config security-manager)
FOREACH(flag ${pkgs_test_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
if (ret != 0) {
__error_no_to_string(data.result, &errstr);
printf("processing result : %s [%d] failed\n", errstr, data.result);
- } else {
- if (data.request == INSTALL_REQ)
- sleep(2);
}
-
gettimeofday(&tv, NULL);
endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
printf("spend time for pkgcmd is [%d]ms\n", (int)(endtime - starttime));
#include <sys/types.h>
#include <fcntl.h>
-#include <dbus/dbus.h>
/* For multi-user support */
#include <tzplatform_config.h>