#include <pkgmgr-info.h>
#include <pkgmgr/pkgmgr_parser.h>
#include <tzplatform_config.h>
+#include <drm-tizen-apps.h>
#include "pkgmgr_installer.h"
#include "pkgmgr-server.h"
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
}
+static void __process_generate_license_request(pm_dbus_msg *item)
+{
+ int ret;
+ char *resp_data;
+ char req_data[MAX_PKG_ARGS_LEN];
+ unsigned int req_data_len;
+ char license_url[MAX_PKG_ARGS_LEN];
+ unsigned int license_url_len;
+
+ resp_data = item->args;
+ req_data_len = sizeof(req_data);
+ license_url_len = sizeof(license_url);
+
+ ret = drm_tizen_generate_license_request(resp_data, strlen(resp_data),
+ req_data, &req_data_len, license_url, &license_url_len);
+ if (ret != TADC_SUCCESS) {
+ ERR("drm_tizen_generate_license_request failed: %d", ret);
+ __return_value_to_caller(item->req_id, g_variant_new("(iss)",
+ PKGMGR_R_ESYSTEM, "", ""));
+ return;
+ }
+
+ __return_value_to_caller(item->req_id,
+ g_variant_new("(iss)", PKGMGR_R_OK, req_data,
+ license_url));
+}
+
+static void __process_register_license(pm_dbus_msg *item)
+{
+ int ret;
+ char *resp_data;
+
+ resp_data = item->args;
+
+ ret = drm_tizen_register_license(resp_data, strlen(resp_data));
+ if (ret != TADC_SUCCESS) {
+ ERR("drm_tizen_register_license failed: %d", ret);
+ __return_value_to_caller(item->req_id,
+ g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+ return;
+ }
+
+ __return_value_to_caller(item->req_id,
+ g_variant_new("(i)", PKGMGR_R_OK));
+}
+
+static void __process_decrypt_package(pm_dbus_msg *item)
+{
+ int ret;
+ char *drm_file_path;
+ char *decrypted_file_path;
+
+ drm_file_path = item->pkgid;
+ decrypted_file_path = item->args;
+
+ /* TODO: check ownership of decrypted file */
+ ret = drm_tizen_decrypt_package(drm_file_path, strlen(drm_file_path),
+ decrypted_file_path, strlen(decrypted_file_path));
+ if (ret != TADC_SUCCESS) {
+ ERR("drm_tizen_register_license failed: %d", ret);
+ __return_value_to_caller(item->req_id,
+ g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+ return;
+ }
+
+ __return_value_to_caller(item->req_id,
+ g_variant_new("(i)", PKGMGR_R_OK));
+}
+
gboolean queue_job(void *data)
{
pm_dbus_msg *item = NULL;
case PKGMGR_REQUEST_TYPE_CHECK:
__process_check(item);
break;
+ case PKGMGR_REQUEST_TYPE_GENERATE_LICENSE_REQUEST:
+ __process_generate_license_request(item);
+ break;
+ case PKGMGR_REQUEST_TYPE_REGISTER_LICENSE:
+ __process_register_license(item);
+ break;
+ case PKGMGR_REQUEST_TYPE_DECRYPT_PACKAGE:
+ __process_decrypt_package(item);
+ break;
}
/* exit child */
_save_queue_status(item, "done");
" <arg type='s' name='pkgid' direction='in'/>"
" <arg type='i' name='ret' direction='out'/>"
" </method>"
+ " <method name='generate_license_request'>"
+ " <arg type='s' name='resp_data' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " <arg type='s' name='req_data' direction='out'/>"
+ " <arg type='s' name='license_url' direction='out'/>"
+ " </method>"
+ " <method name='register_license'>"
+ " <arg type='s' name='resp_data' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " </method>"
+ " <method name='decrypt_package'>"
+ " <arg type='s' name='drm_file_path' direction='in'/>"
+ " <arg type='s' name='decrypted_file_path' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " </method>"
" </interface>"
"</node>";
static GDBusNodeInfo *instropection_data;
return 0;
}
+static int __handle_request_generate_license_request(uid_t uid,
+ GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ char *reqkey;
+ char *resp_data = NULL;
+
+ g_variant_get(parameters, "(&s)", &resp_data);
+ if (resp_data == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(iss)", PKGMGR_R_ECOMM, "", ""));
+ return -1;
+ }
+
+ reqkey = __generate_reqkey("drm");
+ if (reqkey == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(iss)", PKGMGR_R_ENOMEM, "",
+ ""));
+ return -1;
+ }
+
+ if (_pm_queue_push(uid, reqkey,
+ PKGMGR_REQUEST_TYPE_GENERATE_LICENSE_REQUEST,
+ "pkg", "", resp_data)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(iss)", PKGMGR_R_ESYSTEM, "",
+ ""));
+ free(reqkey);
+ return -1;
+ }
+
+ if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+ (gpointer)invocation))
+ ERR("reqkey already exists");
+
+ return 0;
+}
+
+static int __handle_request_register_license(uid_t uid,
+ GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ char *reqkey;
+ char *resp_data = NULL;
+
+ g_variant_get(parameters, "(&s)", &resp_data);
+ if (resp_data == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ECOMM));
+ return -1;
+ }
+
+ reqkey = __generate_reqkey("drm");
+ if (reqkey == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ENOMEM));
+ return -1;
+ }
+
+ if (_pm_queue_push(uid, reqkey, PKGMGR_REQUEST_TYPE_REGISTER_LICENSE,
+ "pkg", "", resp_data)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+ free(reqkey);
+ return -1;
+ }
+
+ if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+ (gpointer)invocation))
+ ERR("reqkey already exists");
+
+ return 0;
+}
+
+static int __handle_request_decrypt_package(uid_t uid,
+ GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ char *reqkey;
+ char *drm_file_path = NULL;
+ char *decrypted_file_path = NULL;
+
+ g_variant_get(parameters, "(&s&s)", &drm_file_path,
+ &decrypted_file_path);
+ if (drm_file_path == NULL || decrypted_file_path == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ECOMM));
+ return -1;
+ }
+
+ reqkey = __generate_reqkey("drm");
+ if (reqkey == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ENOMEM));
+ return -1;
+ }
+
+ if (_pm_queue_push(uid, reqkey, PKGMGR_REQUEST_TYPE_DECRYPT_PACKAGE,
+ "pkg", drm_file_path, decrypted_file_path)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+ free(reqkey);
+ return -1;
+ }
+
+ if (!g_hash_table_insert(req_table, (gpointer)reqkey,
+ (gpointer)invocation))
+ ERR("reqkey already exists");
+
+ return 0;
+}
+
static uid_t __get_caller_uid(GDBusConnection *connection, const char *name)
{
GError *err = NULL;
ret = __handle_request_kill(uid, invocation, parameters);
else if (g_strcmp0(method_name, "check") == 0)
ret = __handle_request_check(uid, invocation, parameters);
+ else if (g_strcmp0(method_name, "generate_license_request") == 0)
+ ret = __handle_request_generate_license_request(uid, invocation,
+ parameters);
+ else if (g_strcmp0(method_name, "register_license") == 0)
+ ret = __handle_request_register_license(uid, invocation,
+ parameters);
+ else if (g_strcmp0(method_name, "decrypt_package") == 0)
+ ret = __handle_request_decrypt_package(uid, invocation,
+ parameters);
else
ret = -1;