return cb_info;
}
+static struct cb_info *__create_upgrade_event_cb_info(
+ struct pkgmgr_client_t *client,
+ pkgmgr_pkg_upgrade_handler upgrade_event_cb,
+ void *data, const char *req_key)
+{
+ struct cb_info *cb_info;
+
+ cb_info = calloc(1, sizeof(struct cb_info));
+ if (cb_info == NULL) {
+ ERR("out of memory");
+ return NULL;
+ }
+
+ cb_info->client = client;
+ cb_info->upgrade_event_cb = upgrade_event_cb;
+ cb_info->data = data;
+ cb_info->req_id = _get_internal_request_id();
+ if (req_key == NULL)
+ return cb_info;
+
+ cb_info->req_key = strdup(req_key);
+ if (cb_info->req_key == NULL) {
+ ERR("out of memory");
+ free(cb_info);
+ return NULL;
+ }
+
+ return cb_info;
+}
+
static struct cb_info *__create_size_info_cb_info(
struct pkgmgr_client_t *client,
pkgmgr_pkg_size_info_receive_cb size_info_cb,
return cb_info->req_id;
}
+API int pkgmgr_client_listen_pkg_upgrade_status(pkgmgr_client *pc,
+ pkgmgr_pkg_upgrade_handler event_cb, void *data)
+{
+ int ret;
+ struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+ struct cb_info *cb_info;
+
+ if (pc == NULL || event_cb == NULL) {
+ ERR("invalid parameter");
+ return PKGMGR_R_EINVAL;
+ }
+
+ if (client->pc_type != PC_LISTENING) {
+ ERR("client->pc_type is not PC_LISTENING");
+ return PKGMGR_R_EINVAL;
+ }
+
+ cb_info = __create_upgrade_event_cb_info(client, event_cb, data, NULL);
+ if (cb_info == NULL)
+ return PKGMGR_R_ENOMEM;
+ cb_info->status_type = client->status_type;
+ ret = pkgmgr_client_connection_set_callback(client, cb_info);
+ if (ret != PKGMGR_R_OK) {
+ __free_cb_info(cb_info);
+ return ret;
+ }
+ client->cb_info_list = g_list_append(client->cb_info_list, cb_info);
+
+ return cb_info->req_id;
+}
+
API int pkgmgr_client_remove_listen_status(pkgmgr_client *pc)
{
struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;