return h;
}
-API int aul_app_com_create(const char *endpoint, aul_app_com_permission_h permission, app_com_cb callback, void *user_data, aul_app_com_connection_h *connection)
+API int aul_app_com_create(const char *endpoint,
+ aul_app_com_permission_h permission, app_com_cb callback,
+ void *user_data, aul_app_com_connection_h *connection)
{
- bundle *b = NULL;
- int ret = 0;
+ bundle *b;
+ int ret;
- if (endpoint == NULL || callback == NULL || connection == NULL)
- return -1;
+ if (endpoint == NULL || callback == NULL || connection == NULL) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
- b = bundle_create();
+ if (!aul_is_initialized()) {
+ if (aul_launch_init(NULL, NULL) < 0)
+ return AUL_R_ENOINIT;
+ }
+ b = bundle_create();
if (!b) {
_E("out of memory");
- return -1;
+ return AUL_R_ENOMEM;
}
bundle_add_str(b, AUL_K_COM_ENDPOINT, endpoint);
if (permission) {
- if (permission->propagation)
+ if (permission->propagation) {
bundle_add_byte(b, AUL_K_COM_PROPAGATE,
- (void *)(GUINT_TO_POINTER(permission->propagation)), sizeof(unsigned int));
+ (GUINT_TO_POINTER(permission->propagation)),
+ sizeof(unsigned int));
+ }
- if (permission->privilege)
- bundle_add_str(b, AUL_K_COM_PRIVILEGE, permission->privilege);
+ if (permission->privilege) {
+ bundle_add_str(b, AUL_K_COM_PRIVILEGE,
+ permission->privilege);
+ }
}
ret = app_send_cmd(AUL_UTIL_PID, APP_COM_CREATE, b);
return ret;
}
-API int aul_app_com_join(const char *endpoint, const char *filter, app_com_cb callback, void *user_data, aul_app_com_connection_h *connection)
+API int aul_app_com_join(const char *endpoint, const char *filter,
+ app_com_cb callback, void *user_data,
+ aul_app_com_connection_h *connection)
{
- bundle *b = NULL;
- int ret = 0;
+ bundle *b;
+ int ret;
- if (endpoint == NULL || callback == NULL || connection == NULL)
- return -1;
+ if (endpoint == NULL || callback == NULL || connection == NULL) {
+ _E("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
- b = bundle_create();
+ if (!aul_is_initialized()) {
+ if (aul_launch_init(NULL, NULL) < 0)
+ return AUL_R_ENOINIT;
+ }
+ b = bundle_create();
if (!b) {
_E("out of memory");
- return -1;
+ return AUL_R_ENOMEM;
}
bundle_add_str(b, AUL_K_COM_ENDPOINT, endpoint);