2 * Copyright (c) 2016 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.
20 #include <glib-object.h>
22 #include <sys/types.h>
26 #include <bundle_internal.h>
28 #include <aul_app_com.h>
31 #include "widget_app.h"
32 #include "widget-log.h"
33 #include "widget-private.h"
34 #include "widget_app_internal.h"
35 #include "widget-private.h"
41 #define LOG_TAG "CAPI_WIDGET_APPLICATION"
43 static char *viewer_endpoint = NULL;
44 static GList *contexts = NULL;
46 EXPORT_API int widget_app_restart()
49 int status = AUL_WIDGET_INSTANCE_EVENT_APP_RESTART_REQUEST;
54 if (contexts == NULL) {
56 return WIDGET_ERROR_IO_ERROR;
58 wc = (widget_context_s *)contexts->data;
59 classid = wc->provider->classid;
60 _D("restart widget classid : %s", classid);
63 bundle_add_str(kb, AUL_K_WIDGET_ID, classid);
64 bundle_add_byte(kb, AUL_K_WIDGET_STATUS, &status, sizeof(int));
65 ret = aul_app_com_send(viewer_endpoint, kb);
67 if (ret != AUL_R_OK) {
68 _E("failed to kill app");
69 return WIDGET_ERROR_IO_ERROR;
71 return WIDGET_ERROR_NONE;
74 GList *_widget_app_get_contexts()
79 int _widget_app_add_context(widget_context_s *wc)
81 contexts = g_list_append(contexts, wc);
82 return WIDGET_ERROR_NONE;
85 int _widget_app_remove_context(widget_context_s *wc)
87 contexts = g_list_remove(contexts, wc);
88 return WIDGET_ERROR_NONE;
91 int _widget_app_set_viewer_endpoint(char *endpoint)
94 return WIDGET_ERROR_INVALID_PARAMETER;
96 viewer_endpoint = strdup(endpoint);
97 if (viewer_endpoint == NULL)
98 return WIDGET_ERROR_OUT_OF_MEMORY;
100 return WIDGET_ERROR_NONE;
103 char *_widget_app_get_viewer_endpoint()
105 return viewer_endpoint;
108 int _widget_app_free_viewer_endpoint()
111 free(viewer_endpoint);
113 return WIDGET_ERROR_NONE;