#include "aul_rpc_port.h"
#include "aul_sock.h"
#include "aul_util.h"
+#include "aul_svc.h"
static bundle *__create_bundle(const char *appid, const char *port_name)
{
return AUL_R_OK;
}
+API int aul_rpc_port_set_private_sharing(
+ const char *appid, const char *paths[], unsigned int size)
+{
+ char buf[12];
+ bundle *b;
+ int r;
+
+ if (!appid || !paths) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ b = bundle_create();
+ if (!b) {
+ _E("Out of memory");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", getpid());
+ r = bundle_add(b, AUL_K_PID, buf);
+ if (r != BUNDLE_ERROR_NONE) {
+ _E("Failed to add pid(%d). err = %d", getpid(), r);
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ r = bundle_add(b, AUL_K_CALLEE_APPID, appid);
+ if (r != BUNDLE_ERROR_NONE) {
+ _E("Failed to add callee appid(%s). err = %d", appid, r);
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ r = bundle_add_str_array(b, AUL_SVC_DATA_PATH, paths, size);
+ if (r != BUNDLE_ERROR_NONE) {
+ _E("Failed to add paths(%d). err = %d", size, r);
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+ SET_PRIVATE_SHARING, b, AUL_SOCK_NOREPLY);
+ if (r != 0) {
+ _E("Failed to set private sharing(%d). err = %d", getpid(), r);
+ bundle_free(b);
+ return aul_error_convert(r);
+ }
+ bundle_free(b);
+
+ return AUL_R_OK;
+}
+
+API int aul_rpc_port_unset_private_sharing(const char *appid)
+{
+ char buf[12];
+ bundle *b;
+ int r;
+
+ if (!appid) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ b = bundle_create();
+ if (!b) {
+ _E("Out of memory");
+ return AUL_R_ERROR;
+ }
+
+ snprintf(buf, sizeof(buf), "%d", getpid());
+ r = bundle_add(b, AUL_K_PID, buf);
+ if (r != BUNDLE_ERROR_NONE) {
+ _E("Failed to add pid(%d). err = %d", getpid(), r);
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ r = bundle_add(b, AUL_K_CALLEE_APPID, appid);
+ if (r != BUNDLE_ERROR_NONE) {
+ _E("Failed to add callee appid(%s). err = %d", appid, r);
+ bundle_free(b);
+ return AUL_R_ERROR;
+ }
+
+ r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+ UNSET_PRIVATE_SHARING, b, AUL_SOCK_NOREPLY);
+ if (r != 0) {
+ _E("Failed to unset private sharing(%d). err = %d", getpid(), r);
+ bundle_free(b);
+ return aul_error_convert(r);
+ }
+ bundle_free(b);
+
+ return AUL_R_OK;
+}
\ No newline at end of file