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"
33 static gboolean __aul_glib_check(GSource *src);
34 static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
36 static gboolean __aul_glib_prepare(GSource *src, gint *timeout);
37 static gboolean __app_start_internal(gpointer data);
39 static gboolean __aul_glib_check(GSource *src)
44 fd_list = src->poll_fds;
46 tmp = (GPollFD *) fd_list->data;
47 if ((tmp->revents & (POLLIN | POLLPRI)))
49 fd_list = fd_list->next;
55 static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
62 static gboolean __aul_glib_prepare(GSource *src, gint *timeout)
67 GSourceFuncs funcs = {
68 .prepare = __aul_glib_prepare,
69 .check = __aul_glib_check,
70 .dispatch = __aul_glib_dispatch,
74 gboolean __aul_glib_handler(gpointer data)
76 GPollFD *gpollfd = (GPollFD *) data;
77 aul_sock_handler(gpollfd->fd);
81 static gboolean __app_start_internal(gpointer data)
92 SLPAPI int aul_launch_init(
93 int (*aul_handler) (aul_type type, bundle *, void *), void *data)
99 if (aul_handler != NULL)
100 aul_register_init_callback(aul_handler, data);
102 fd = aul_initialize();
106 src = g_source_new(&funcs, sizeof(GSource));
108 gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
109 gpollfd->events = POLLIN;
112 g_source_add_poll(src, gpollfd);
113 g_source_set_callback(src, (GSourceFunc) __aul_glib_handler,
114 (gpointer) gpollfd, NULL);
115 g_source_set_priority(src, G_PRIORITY_DEFAULT);
117 ret = g_source_attach(src, NULL);
126 SLPAPI int aul_launch_fini()
128 g_source_destroy(src);
131 SLPAPI int aul_launch_argv_handler(int argc, char **argv)
135 if (!aul_is_initialized())
136 return AUL_R_ENOINIT;
138 b = bundle_import_from_argv(argc, argv);
140 _E("bundle for APP_START is NULL");
142 if (g_idle_add(__app_start_internal, b) > 0)
148 SLPAPI int aul_launch_local(bundle *b)
150 if (!aul_is_initialized())
151 return AUL_R_ENOINIT;
154 _E("bundle for APP_START is NULL");
156 if (g_idle_add(__app_start_internal, b) > 0)