4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 #include "simple_util.h"
34 static gboolean __aul_glib_check(GSource *src);
35 static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
37 static gboolean __aul_glib_prepare(GSource *src, gint *timeout);
38 static gboolean __app_start_internal(gpointer data);
40 static void __aul_glib_finalize(GSource *src)
45 fd_list = src->poll_fds;
47 tmp = (GPollFD *) fd_list->data;
50 fd_list = fd_list->next;
56 static gboolean __aul_glib_check(GSource *src)
61 fd_list = src->poll_fds;
63 tmp = (GPollFD *) fd_list->data;
64 if ((tmp->revents & (POLLIN | POLLPRI)))
66 fd_list = fd_list->next;
72 static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
79 static gboolean __aul_glib_prepare(GSource *src, gint *timeout)
84 GSourceFuncs funcs = {
85 .prepare = __aul_glib_prepare,
86 .check = __aul_glib_check,
87 .dispatch = __aul_glib_dispatch,
88 .finalize = __aul_glib_finalize
91 gboolean __aul_glib_handler(gpointer data)
93 GPollFD *gpollfd = (GPollFD *) data;
94 aul_sock_handler(gpollfd->fd);
98 static gboolean __app_start_internal(gpointer data)
102 kb = (bundle *) data;
109 SLPAPI int aul_launch_init(
110 int (*aul_handler) (aul_type type, bundle *, void *), void *data)
116 if (aul_handler != NULL)
117 aul_register_init_callback(aul_handler, data);
119 fd = aul_initialize();
123 src = g_source_new(&funcs, sizeof(GSource));
125 gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
126 if (gpollfd == NULL) {
133 gpollfd->events = POLLIN;
136 g_source_add_poll(src, gpollfd);
137 g_source_set_callback(src, (GSourceFunc) __aul_glib_handler,
138 (gpointer) gpollfd, NULL);
139 g_source_set_priority(src, G_PRIORITY_DEFAULT);
141 ret = g_source_attach(src, NULL);
150 SLPAPI int aul_launch_fini()
152 g_source_destroy(src);
156 SLPAPI int aul_launch_argv_handler(int argc, char **argv)
160 if (!aul_is_initialized())
161 return AUL_R_ENOINIT;
163 b = bundle_import_from_argv(argc, argv);
165 _E("bundle for APP_START is NULL");
167 if (g_idle_add(__app_start_internal, b) > 0)
173 SLPAPI int aul_launch_argv_handler_for_efl(int argc, char **argv)
177 Ecore_Idler *idler = NULL;
179 if (!aul_is_initialized())
180 return AUL_R_ENOINIT;
182 b = bundle_import_from_argv(argc, argv);
184 _E("bundle for APP_START is NULL");
187 idler = ecore_idler_add(__app_start_internal, b);
194 SLPAPI int aul_launch_local(bundle *b)
196 if (!aul_is_initialized())
197 return AUL_R_ENOINIT;
200 _E("bundle for APP_START is NULL");
202 if (g_idle_add(__app_start_internal, b) > 0)