2 * Copyright (c) 2015 - 2021 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 AUL_APP_COM_PUBLIC = 0x0, /* allowed for all */
28 AUL_APP_COM_PRIVILEGED = 0x1, /* allowed for given privileged app */
29 } aul_app_com_propagate_option_e;
32 AUL_APP_COM_R_ERROR_OK = 0,
33 AUL_APP_COM_R_ERROR_UNKNOWN_ENDPOINT = -1,
34 AUL_APP_COM_R_ERROR_ENDPOINT_ALREADY_EXISTS = -2,
35 AUL_APP_COM_R_ERROR_ILLEGAL_ACCESS = -3,
36 AUL_APP_COM_R_ERROR_CLIENT_REMAINING = -4,
37 AUL_APP_COM_R_ERROR_OUT_OF_MEMORY = -5,
38 AUL_APP_COM_R_ERROR_FATAL_ERROR = -6,
39 } aul_app_com_error_e;
43 AUL_APP_COM_R_ILLEGAL_ACCESS = -1,
44 } aul_app_com_result_e;
46 typedef void *aul_app_com_permission_h;
47 typedef void *aul_app_com_connection_h;
49 typedef int (*app_com_cb)(const char *endpoint, aul_app_com_result_e result, bundle *envelope, void *user_data);
52 * aul_app_com provides publish-subscribe style message for internal AUL use.
53 * e.g) widget status propagation, sharing callee app status to caller app
56 static int __handler(const char *endpoint, aul_app_com_result_e result, bundle *envelope, void *user_data)
58 _D("endpoint: %s", endpoint);
59 _D("result: %d", result);
65 aul_app_com_permission_h permission = aul_app_com_permission_create();
66 aul_app_com_permission_set_propagation(permission, AUL_APP_COM_PRIVILEGED);
67 aul_app_com_permission_set_privilege(permission, "http://tizen.org/privilege/widget.viewer");
68 aul_app_com_connection_h connection = NULL;
69 aul_app_com_create("widget.status", permission, __handler, NULL, &connection);
73 bundle *b = bundle_create();
74 bundle_add_str(b, "WIDGET_ID", "org.example.widget");
75 bundle_add_str(b, "STATUS", "RUNNING");
76 aul_app_com_send("widget.status", b);
81 static int __handler(const char *endpoint, aul_app_com_result_e result, bundle *envelope, void *user_data)
83 const char *widget_id = bundle_get_val(envelope, "WIDGET_ID");
84 const char *status = bundle_get_val(envelope, "STATUS");
86 _D("%s is %s", widget_id, status);
91 aul_app_com_connection_h connection = NULL;
92 aul_app_com_join("widget.status", NULL, __handler, NULL, &connection);
96 aul_app_com_permission_h aul_app_com_permission_create();
97 void aul_app_com_permission_destroy(aul_app_com_permission_h permission);
98 int aul_app_com_permission_set_propagation(aul_app_com_permission_h permission, aul_app_com_propagate_option_e option);
99 int aul_app_com_permission_set_privilege(aul_app_com_permission_h permission, const char *privilege);
101 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);
102 int aul_app_com_join(const char *endpoint, const char *filter, app_com_cb callback, void *user_data, aul_app_com_connection_h *connection);
103 int aul_app_com_leave(aul_app_com_connection_h connection);
104 int aul_app_com_send(const char *endpoint, bundle *envelope);
106 int aul_app_com_create_async(const char *endpoint,
107 aul_app_com_permission_h permission,
110 aul_app_com_connection_h *connection);