1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* aul
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
*
* 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.
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <utilX.h>
#include <glib.h>
#include <poll.h>
#include <bundle.h>
#include "aul.h"
#include "aul_api.h"
#include "menu_db_util.h"
#include "simple_util.h"
#include "app_sock.h"
#include "aul_util.h"
#include "launch.h"
static int (*_aul_key_handler) (bundle *kb, void *data) = NULL;
static void *_aul_key_data = NULL;
extern GSourceFuncs funcs;
int app_key_event(bundle *kb)
{
if (_aul_key_handler)
_aul_key_handler(kb, _aul_key_data);
return 0;
}
int aul_register_key_init_callback(
int (*aul_handler) (bundle *, void *), void *data)
{
/* Save start handler function in static var */
_aul_key_handler = aul_handler;
_aul_key_data = data;
return 0;
}
SLPAPI int aul_key_init(int (*aul_handler) (bundle *, void *), void *data)
{
int fd;
GPollFD *gpollfd;
GSource *src;
int ret;
if (aul_handler != NULL)
aul_register_key_init_callback(aul_handler, data);
fd = aul_initialize();
if (fd < 0)
return fd;
src = g_source_new(&funcs, sizeof(GSource));
gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
gpollfd->events = POLLIN;
gpollfd->fd = fd;
g_source_add_poll(src, gpollfd);
g_source_set_callback(src, (GSourceFunc) __aul_glib_handler,
(gpointer) gpollfd, NULL);
g_source_set_priority(src, G_PRIORITY_LOW);
ret = g_source_attach(src, NULL);
if (ret == 0)
return AUL_R_ERROR;
g_source_unref(src);
return AUL_R_OK;
}
SLPAPI int aul_key_reserve()
{
bundle *kb;
int ret;
kb = bundle_create();
ret = app_send_cmd(AUL_UTIL_PID, APP_KEY_RESERVE, kb);
bundle_free(kb);
return ret;
}
SLPAPI int aul_key_release()
{
bundle *kb;
int ret;
kb = bundle_create();
ret = app_send_cmd(AUL_UTIL_PID, APP_KEY_RELEASE, kb);
bundle_free(kb);
return ret;
}
|