Add new APIs for complication 13/173013/2
authorjusung son <jusung07.son@samsung.com>
Mon, 19 Mar 2018 07:48:50 +0000 (16:48 +0900)
committerjusung son <jusung07.son@samsung.com>
Mon, 19 Mar 2018 07:53:27 +0000 (16:53 +0900)
Change-Id: If913893cd7607424845e85570f08c1b9a0a78bd3
Signed-off-by: jusung son <jusung07.son@samsung.com>
CMakeLists.txt [changed mode: 0644->0755]
include/aul_cmd.h [changed mode: 0644->0755]
include/aul_complication.h [new file with mode: 0755]
src/aul_complication.c [new file with mode: 0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8e5ec1b..1cbf8ed
@@ -62,6 +62,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_window.h DESTINATION inclu
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_widget.h DESTINATION include/aul)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_job_scheduler.h DESTINATION include/aul)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_rpc_port.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_complication.h DESTINATION include/aul)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION ${SHARE_INSTALL_PREFIX}/aul )
 INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION ${SHARE_INSTALL_PREFIX}/aul )
old mode 100644 (file)
new mode 100755 (executable)
index 82849bc..7a944fa
@@ -132,6 +132,7 @@ enum app_cmd {
 
        RPC_PORT_CREATE_SOCKET_PAIR = 101,
        RPC_PORT_NOTIFY_RPC_FINISHED = 102,
+       COMPLICATION_UPDATE_REQUEST = 103,
 
        APP_CMD_MAX
 };
diff --git a/include/aul_complication.h b/include/aul_complication.h
new file mode 100755 (executable)
index 0000000..ac072fe
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AUL_COMPLICATION_H__
+#define __AUL_COMPLICATION_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int aul_complication_update_request(const char *appid, const char *provider_appid, uid_t uid);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUL_COMPLICATION_H__ */
diff --git a/src/aul_complication.c b/src/aul_complication.c
new file mode 100755 (executable)
index 0000000..53ca32d
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <bundle_internal.h>
+
+#include "aul_api.h"
+#include "aul_util.h"
+#include "aul_sock.h"
+#include "aul_complication.h"
+#include "aul.h"
+
+#define MAX_UID_STR_BUFSZ 20
+
+API int aul_complication_update_request(const char *appid, const char *provider_appid, uid_t uid)
+{
+       bundle *b;
+       int r;
+       char buf[MAX_UID_STR_BUFSZ];
+
+       if (!appid || !provider_appid) {
+               _E("Invalid parameter");
+               return AUL_R_EINVAL;
+       }
+
+       b = bundle_create();
+       if (!b) {
+               _E("Out of memory");
+               return AUL_R_ERROR;
+       }
+
+       r = bundle_add(b, AUL_K_CALLER_APPID, appid);
+       if (r != BUNDLE_ERROR_NONE) {
+               _E("Failed to add appid(%s)", appid);
+               bundle_free(b);
+               return AUL_R_ERROR;
+       }
+
+       r = bundle_add(b, AUL_K_APPID, provider_appid);
+       if (r != BUNDLE_ERROR_NONE) {
+               _E("Failed to add provider_appid(%s)", provider_appid);
+               bundle_free(b);
+               return AUL_R_ERROR;
+       }
+
+       snprintf(buf, sizeof(buf), "%d", uid);
+       r = bundle_add(b, AUL_K_TARGET_UID, buf);
+       if (r != BUNDLE_ERROR_NONE) {
+               _E("Failed to add uid(%d)", uid);
+               bundle_free(b);
+               return AUL_R_ERROR;
+       }
+
+       r = aul_sock_send_bundle(AUL_UTIL_PID, getuid(),
+               COMPLICATION_UPDATE_REQUEST, b, AUL_SOCK_QUEUE);
+       if (r < 0) {
+               _E("Failed to send request(%d:%s)",
+                               COMPLICATION_UPDATE_REQUEST, appid);
+               bundle_free(b);
+               return r;
+       }
+       bundle_free(b);
+
+       return AUL_R_OK;
+}