return result;
}
+static inline int validate_request(const char *pkgname, const char *id, struct inst_info **out_inst, const struct pkg_info **out_pkg)
+{
+ struct inst_info *inst;
+ const struct pkg_info *pkg;
+
+ inst = package_find_instance_by_id(pkgname, id);
+ if (!inst) {
+ ErrPrint("Instance is not exists\n");
+ return LB_STATUS_ERROR_NOT_EXIST;
+ }
+
+ pkg = instance_package(inst);
+ if (!pkg) {
+ ErrPrint("System error - instance has no package?\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (package_is_fault(pkg)) {
+ ErrPrint("Faulted package: %s\n", pkgname);
+ return LB_STATUS_ERROR_FAULT;
+ }
+
+ if (instance_state(inst) == INST_DESTROYED) {
+ ErrPrint("Package[%s] instance is already destroyed\n", pkgname);
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (out_inst)
+ *out_inst = inst;
+
+ if (out_pkg)
+ *out_pkg = pkg;
+
+ return LB_STATUS_SUCCESS;
+}
+
/*!< pid, pkgname, filename, event, timestamp, x, y, ret */
static struct packet *client_clicked(pid_t pid, int handle, const struct packet *packet)
{
goto out;
}
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
-
/*!
* \NOTE:
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ErrPrint("Instance is not exists\n");
- else if (package_is_fault(instance_package(inst)))
- ErrPrint("Fault package\n");
- else
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
(void)instance_clicked(inst, event, timestamp, x, y);
out:
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance is not exists\n");
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(instance_package(inst))) {
- ErrPrint("Fault package\n");
- ret = LB_STATUS_ERROR_FAULT;
- } else {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
/*!
* \note
* Send change update mode request to a slave
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ret = LB_STATUS_ERROR_NOT_EXIST;
- else if (package_is_fault(instance_package(inst)))
- ret = LB_STATUS_ERROR_FAULT;
- else
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
ret = instance_text_signal_emit(inst, emission, source, sx, sy, ex, ey);
out:
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(instance_package(inst))) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (instance_client(inst) != client) {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (instance_client(inst) != client) {
if (instance_has_client(inst, client)) {
struct deleted_item *item;
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(instance_package(inst))) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (instance_client(inst) != client) {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (instance_client(inst) != client)
ret = LB_STATUS_ERROR_PERMISSION;
- } else {
+ else
ret = instance_resize(inst, w, h);
- }
out:
result = packet_create_reply(packet, "i", ret);
goto out;
}
- DbgPrint("pid[%d] pkgname[%s] state[%d]\n", pid, pkgname, state);
-
/*!
* \NOTE:
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(instance_package(inst))) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (instance_client(inst) != client) {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (instance_client(inst) != client)
ret = LB_STATUS_ERROR_PERMISSION;
- } else {
+ else
ret = instance_set_visible_state(inst, state);
- }
out:
/*! \note No reply packet */
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(instance_package(inst))) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (instance_client(inst) != client) {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (instance_client(inst) != client)
ret = LB_STATUS_ERROR_PERMISSION;
- } else {
+ else
ret = instance_set_period(inst, period);
- }
out:
result = packet_create_reply(packet, "i", ret);
* Trust the package name which are sent by the client.
* The package has to be a livebox package name.
*/
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ret = LB_STATUS_ERROR_NOT_EXIST;
- } else if (package_is_fault(instance_package(inst))) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (instance_client(inst) != client) {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (instance_client(inst) != client)
ret = LB_STATUS_ERROR_PERMISSION;
- } else {
+ else
ret = instance_change_group(inst, cluster, category);
- }
out:
result = packet_create_reply(packet, "i", ret);
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
if (event_is_activated()) {
if (event_deactivate() == 0)
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
int y;
struct inst_info *inst;
const struct pkg_info *pkg;
+
client = client_find_by_pid(pid);
if (!client) {
ErrPrint("Client %d is not exists\n", pid);
ret = LB_STATUS_ERROR_NOT_EXIST;
goto out;
}
+
ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
if (ret != 5) {
ErrPrint("Parameter is not matched\n");
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = event_deactivate();
if (ret == 0)
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
if (event_is_activated()) {
if (event_deactivate() == 0)
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
ret = event_deactivate();
if (ret == 0)
instance_event_callback_del(inst, INSTANCE_EVENT_DESTROY, inst_del_cb);
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
-
- if (package_is_fault(pkg)) {
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
const struct pkg_info *pkg;
client = client_find_by_pid(pid);
- if (!client) {
- ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
- ErrPrint("Invalid parameter\n");
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
-
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
ret = LB_STATUS_ERROR_NOT_EXIST;
goto out;
}
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Invalid parameter\n");
+ ret = LB_STATUS_ERROR_INVALID;
goto out;
}
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- DbgPrint("%s %s %lf %d %d\n", pkgname, id, timestamp, x, y);
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not found\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
const struct pkg_info *pkg;
client = client_find_by_pid(pid);
- if (!client) {
- ErrPrint("Client %d is not exists\n", pid);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
- if (ret != 5) {
- ErrPrint("Parameter is not matched\n");
- ret = LB_STATUS_ERROR_INVALID;
- goto out;
- }
-
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
+ if (!client) {
+ ErrPrint("Client %d is not exists\n", pid);
ret = LB_STATUS_ERROR_NOT_EXIST;
goto out;
}
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
+ ret = packet_get(packet, "ssdii", &pkgname, &id, ×tamp, &x, &y);
+ if (ret != 5) {
+ ErrPrint("Parameter is not matched\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Package[%s] info is not exists\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- if (package_is_fault(pkg)) {
- /*!
- * \note
- * If the package is registered as fault module,
- * slave has not load it, so we don't need to do anything at here!
- */
- DbgPrint("Package[%s] is faulted\n", pkgname);
- ret = LB_STATUS_ERROR_FAULT;
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
struct buffer_info *buffer;
struct slave_node *slave;
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
buffer = instance_lb_buffer(inst);
if (!buffer) {
ErrPrint("Unable to get LB buffer: %s\n", id);
ErrPrint("Parameter is not matched\n");
goto out;
}
- DbgPrint("pid[%d] pkgname[%s] Pixmap[0x%X]\n", pid, pkgname, pixmap);
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
buf_ptr = buffer_handler_pixmap_find(pixmap);
if (!buf_ptr) {
goto out;
}
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
buffer = instance_pd_buffer(inst);
if (!buffer) {
ErrPrint("Unable to get PD buffer (%s)\n", id);
const char *pkgname;
const char *id;
struct client_node *client;
- struct inst_info *inst;
int pixmap;
void *buf_ptr;
int ret;
ErrPrint("Parameter is not matched\n");
goto out;
}
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Failed to find an instance (%s - %s)\n", pkgname, id);
+ ret = validate_request(pkgname, id, NULL, NULL);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
buf_ptr = buffer_handler_pixmap_find(pixmap);
if (!buf_ptr) {
goto out;
}
- DbgPrint("pid[%d] pkgname[%s] pinup[%d]\n", pid, pkgname, pinup);
-
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ret = LB_STATUS_ERROR_NOT_EXIST;
- else if (package_is_fault(instance_package(inst)))
- ret = LB_STATUS_ERROR_FAULT;
- else
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
ret = instance_set_pinup(inst, pinup);
out:
{
struct client_node *client;
struct inst_info *inst;
+ const struct pkg_info *pkg;
const char *pkgname;
const char *id;
double x = 0.0f;
goto out;
}
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ret = LB_STATUS_ERROR_NOT_EXIST;
- else if (package_is_fault(instance_package(inst)))
- ret = LB_STATUS_ERROR_FAULT;
- else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
instance_slave_set_pd_pos(inst, x, y);
- ret = instance_signal_emit(inst,
- "pd,move", util_uri_to_path(instance_id(inst)),
- 0.0, 0.0, 0.0, 0.0, x, y, 0);
- } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
+ ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
+ } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
int ix;
int iy;
ix = x * instance_pd_width(inst);
iy = y * instance_pd_height(inst);
script_handler_update_pointer(instance_pd_script(inst), ix, iy, 0);
- ret = instance_signal_emit(inst,
- "pd,move", util_uri_to_path(instance_id(inst)),
- 0.0, 0.0, 0.0, 0.0, x, y, 0);
+ ret = instance_signal_emit(inst, "pd,move", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
} else {
ErrPrint("Invalid PD type\n");
ret = LB_STATUS_ERROR_INVALID;
goto out;
}
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ret = LB_STATUS_ERROR_NOT_EXIST;
- else if (package_is_fault(instance_package(inst)))
- ret = LB_STATUS_ERROR_FAULT;
- else if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
+ if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE)
ret = LB_STATUS_ERROR_NO_SPACE;
else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
instance_slave_set_pd_pos(inst, x, y);
*/
ret = instance_slave_open_pd(inst, client);
if (ret == LB_STATUS_SUCCESS) {
- ret = instance_signal_emit(inst,
- "pd,show", util_uri_to_path(instance_id(inst)),
- 0.0, 0.0, 0.0, 0.0, x, y, 0);
+ ret = instance_signal_emit(inst, "pd,show", instance_id(inst), 0.0, 0.0, 0.0, 0.0, x, y, 0);
if (ret != LB_STATUS_SUCCESS) {
int tmp_ret;
const char *id;
int ret;
struct inst_info *inst;
+ const struct pkg_info *pkg;
client = client_find_by_pid(pid);
if (!client) {
goto out;
}
- DbgPrint("pid[%d] pkgname[%s]\n", pid, pkgname);
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
- /*!
- * \NOTE:
- * Trust the package name which are sent by the client.
- * The package has to be a livebox package name.
- */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ret = LB_STATUS_ERROR_NOT_EXIST;
- else if (package_is_fault(instance_package(inst)))
- ret = LB_STATUS_ERROR_FAULT;
- else if (package_pd_type(instance_package(inst)) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
Ecore_Timer *pd_monitor;
pd_monitor = instance_del_data(inst, "pd,open,monitor");
goto out;
}
- ret = instance_signal_emit(inst,
- "pd,hide", util_uri_to_path(instance_id(inst)),
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
+ ret = instance_signal_emit(inst, "pd,hide", instance_id(inst), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
if (ret < 0)
ErrPrint("PD close signal emit failed: %d\n", ret);
*
* instance_client_pd_destroyed(inst);
*/
- } else if (package_pd_type(instance_package(inst)) == PD_TYPE_SCRIPT) {
+ } else if (package_pd_type(pkg) == PD_TYPE_SCRIPT) {
ret = script_handler_unload(instance_pd_script(inst), 1);
if (ret < 0)
ErrPrint("Unable to unload the script: %s, %d\n", pkgname, ret);
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- } else if (package_is_fault(instance_package(inst))) {
- } else if (instance_client(inst) != client) {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ if (instance_client(inst) != client) {
+ /* PERMISSIONS */
+ ErrPrint("Insufficient permissions [%s] - %d\n", pkgname, pid);
} else {
slave_rpc_request_update(pkgname, id, instance_cluster(inst), instance_category(inst));
}
{
struct slave_node *slave;
struct inst_info *inst;
- struct pkg_info *pkg;
+ const struct pkg_info *pkg;
const char *pkgname;
const char *id;
double priority;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance(%s) is not exists\n", id);
- goto out;
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance(%s) is already destroyed\n", id);
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Invalid instance\n");
- } else if (package_is_fault(pkg)) {
- ErrPrint("Faulted instance %s.\n", id);
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = instance_lb_update_begin(inst, priority, content, title);
if (ret == LB_STATUS_SUCCESS)
slave_freeze_ttl(slave);
{
struct slave_node *slave;
struct inst_info *inst;
- struct pkg_info *pkg;
+ const struct pkg_info *pkg;
const char *pkgname;
const char *id;
int ret;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- goto out;
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance[%s] is already destroyed\n", id);
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Invalid instance\n");
- } else if (package_is_fault(pkg)) {
- ErrPrint("Faulted instance %s\n", id);
- } else if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
+ if (package_lb_type(pkg) == LB_TYPE_BUFFER) {
ret = instance_lb_update_end(inst);
if (ret == LB_STATUS_SUCCESS)
slave_thaw_ttl(slave);
static struct packet *slave_pd_update_begin(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
- struct pkg_info *pkg;
+ const struct pkg_info *pkg;
struct inst_info *inst;
const char *pkgname;
const char *id;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Invalid package\n");
- } else if (package_is_fault(pkg)) {
- ErrPrint("Faulted instance %s\n", id);
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance[%s] is already destroyed\n", id);
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
(void)instance_pd_update_begin(inst);
} else {
ErrPrint("Invalid request[%s]\n", id);
static struct packet *slave_access_status(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
- struct pkg_info *pkg;
struct inst_info *inst;
const char *pkgname;
const char *id;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Invalid package\n");
- } else if (package_is_fault(pkg)) {
- ErrPrint("Faulted instance %s\n", id);
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance[%s] is already destroyed\n", id);
- } else {
- /*!
- * \note
- * Forward packet to client
- */
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
(void)instance_forward_packet(inst, packet_ref((struct packet *)packet));
- }
out:
return NULL;
static struct packet *slave_pd_update_end(pid_t pid, int handle, const struct packet *packet)
{
struct slave_node *slave;
- struct pkg_info *pkg;
+ const struct pkg_info *pkg;
struct inst_info *inst;
const char *pkgname;
const char *id;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance[%s] is not exists\n", id);
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
- pkg = instance_package(inst);
- if (!pkg) {
- ErrPrint("Invalid package\n");
- } else if (package_is_fault(pkg)) {
- ErrPrint("Faulted instance %s\n", id);
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance[%s] is already destroyed\n", id);
- } else if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
+ if (package_pd_type(pkg) == PD_TYPE_BUFFER) {
(void)instance_pd_update_end(inst);
} else {
ErrPrint("Invalid request[%s]\n", id);
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- } else if (package_is_fault(instance_package(inst))) {
- ErrPrint("Faulted instance cannot make any event.\n");
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance is already destroyed\n");
- } else {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS) {
char *filename;
instance_set_lb_info(inst, priority, content_info, title);
script_handler_resize(instance_lb_script(inst), w, h);
filename = util_get_file_kept_in_safe(id);
if (filename) {
- (void)script_handler_parse_desc(pkgname, id,
- filename, 0);
+ (void)script_handler_parse_desc(pkgname, id, filename, 0);
DbgFree(filename);
} else {
- (void)script_handler_parse_desc(pkgname, id,
- util_uri_to_path(id), 0);
+ (void)script_handler_parse_desc(pkgname, id, util_uri_to_path(id), 0);
}
break;
case LB_TYPE_BUFFER:
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("No such instance(%s)\n", id);
- } else if (package_is_fault(instance_package(inst))) {
- ErrPrint("Faulted instance cannot seize the screen\n");
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance(%s) is already destroyed\n", id);
- } else {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
(void)instance_hold_scroll(inst, seize);
- }
out:
return NULL;
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- } else if (package_is_fault(instance_package(inst))) {
- ErrPrint("Faulted package cannot make event\n");
- } else if (instance_state(inst) == INST_DESTROYED) {
- ErrPrint("Instance is already destroyed\n");
- } else {
- switch (package_pd_type(instance_package(inst))) {
- case PD_TYPE_SCRIPT:
- if (script_handler_is_loaded(instance_pd_script(inst))) {
- (void)script_handler_parse_desc(pkgname, id,
- descfile, 1);
- }
- break;
- case PD_TYPE_TEXT:
- instance_set_pd_size(inst, 0, 0);
- case PD_TYPE_BUFFER:
- instance_pd_updated(pkgname, id, descfile);
- break;
- default:
- DbgPrint("Ignore updated DESC(%s)\n", pkgname);
- break;
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret != LB_STATUS_SUCCESS)
+ goto out;
+
+ switch (package_pd_type(instance_package(inst))) {
+ case PD_TYPE_SCRIPT:
+ if (script_handler_is_loaded(instance_pd_script(inst))) {
+ (void)script_handler_parse_desc(pkgname, id, descfile, 1);
}
+ break;
+ case PD_TYPE_TEXT:
+ instance_set_pd_size(inst, 0, 0);
+ case PD_TYPE_BUFFER:
+ instance_pd_updated(pkgname, id, descfile);
+ break;
+ default:
+ DbgPrint("Ignore updated DESC(%s)\n", pkgname);
+ break;
}
out:
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- } else if (package_is_fault(instance_package(inst))) {
- } else {
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
ret = instance_destroyed(inst);
- }
out:
return NULL;
goto out;
}
- /* TODO: */
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- DbgPrint("Package[%s] instance is not found\n", pkgname);
- ret = LB_STATUS_ERROR_INVALID;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS) {
id = "";
goto out;
}
- pkg = instance_package(inst);
id = "";
ret = LB_STATUS_ERROR_INVALID;
if (target == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
goto out;
}
- if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
- ErrPrint("Not enough space\n");
- ret = LB_STATUS_ERROR_NO_SPACE;
- id = "";
- goto out;
- }
-
ret = packet_get(packet, "issii", &type, &pkgname, &id, &w, &h);
if (ret != 5) {
ErrPrint("Invalid argument\n");
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- DbgPrint("Instance is not found[%s]\n", pkgname);
- ret = LB_STATUS_ERROR_NOT_EXIST;
+ if (util_free_space(IMAGE_PATH) < MINIMUM_SPACE) {
+ ErrPrint("Not enough space\n");
+ ret = LB_STATUS_ERROR_NO_SPACE;
id = "";
goto out;
}
- pkg = instance_package(inst);
- if (!pkg) {
- /*!
- * \note
- * THIS statement should not be entered.
- */
- ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS) {
id = "";
goto out;
}
goto out;
}
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst) {
- ErrPrint("Instance is not found [%s - %s]\n", pkgname, id);
- ret = LB_STATUS_ERROR_NOT_EXIST;
- goto out;
- }
-
- pkg = instance_package(inst);
- if (!pkg) {
- /*!
- * \note
- * THIS statement should not be entered.
- */
- ErrPrint("PACKAGE INFORMATION IS NOT VALID\n");
- ret = LB_STATUS_ERROR_FAULT;
+ ret = validate_request(pkgname, id, &inst, &pkg);
+ if (ret != LB_STATUS_SUCCESS)
goto out;
- }
ret = LB_STATUS_ERROR_INVALID;
if (type == TYPE_LB && package_lb_type(pkg) == LB_TYPE_BUFFER) {
}
}
} else {
- inst = package_find_instance_by_id(pkgname, id);
- if (!inst)
- ret = LB_STATUS_ERROR_NOT_EXIST;
- else if (package_is_fault(instance_package(inst)))
- ret = LB_STATUS_ERROR_FAULT;
- else
+ ret = validate_request(pkgname, id, &inst, NULL);
+ if (ret == LB_STATUS_SUCCESS)
ret = instance_set_period(inst, period);
}