1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
1 |
/**
|
2 |
* @file eventloop.c Purple Event Loop API
|
|
3 |
* @ingroup core
|
|
1.1.5
by Sebastien Bacher
Import upstream version 2.2.1 |
4 |
*/
|
5 |
||
6 |
/* purple
|
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
7 |
*
|
8 |
* Purple is the legal property of its developers, whose names are too numerous
|
|
9 |
* to list here. Please refer to the COPYRIGHT file distributed with this
|
|
10 |
* source distribution.
|
|
11 |
*
|
|
12 |
* This program is free software; you can redistribute it and/or modify
|
|
13 |
* it under the terms of the GNU General Public License as published by
|
|
14 |
* the Free Software Foundation; either version 2 of the License, or
|
|
15 |
* (at your option) any later version.
|
|
16 |
*
|
|
17 |
* This program is distributed in the hope that it will be useful,
|
|
18 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 |
* GNU General Public License for more details.
|
|
21 |
*
|
|
22 |
* You should have received a copy of the GNU General Public License
|
|
23 |
* along with this program; if not, write to the Free Software
|
|
1.1.4
by Sebastien Bacher
Import upstream version 2.2.0 |
24 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
|
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
25 |
*/
|
26 |
#include "eventloop.h" |
|
27 |
#include "internal.h" |
|
28 |
||
29 |
static PurpleEventLoopUiOps *eventloop_ui_ops = NULL; |
|
30 |
||
31 |
guint
|
|
32 |
purple_timeout_add(guint interval, GSourceFunc function, gpointer data) |
|
33 |
{
|
|
34 |
PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
35 |
||
36 |
return ops->timeout_add(interval, function, data); |
|
37 |
}
|
|
38 |
||
1.1.2
by Sebastien Bacher
Import upstream version 2.1.0 |
39 |
guint
|
40 |
purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) |
|
41 |
{
|
|
42 |
PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
43 |
||
44 |
if (ops->timeout_add_seconds) |
|
45 |
return ops->timeout_add_seconds(interval, function, data); |
|
46 |
else
|
|
47 |
return ops->timeout_add(1000 * interval, function, data); |
|
48 |
}
|
|
49 |
||
1
by Ari Pollak
Import upstream version 2.0.0+dfsg.1 |
50 |
gboolean
|
51 |
purple_timeout_remove(guint tag) |
|
52 |
{
|
|
53 |
PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
54 |
||
55 |
return ops->timeout_remove(tag); |
|
56 |
}
|
|
57 |
||
58 |
guint
|
|
59 |
purple_input_add(int source, PurpleInputCondition condition, PurpleInputFunction func, gpointer user_data) |
|
60 |
{
|
|
61 |
PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
62 |
||
63 |
return ops->input_add(source, condition, func, user_data); |
|
64 |
}
|
|
65 |
||
66 |
gboolean
|
|
67 |
purple_input_remove(guint tag) |
|
68 |
{
|
|
69 |
PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
70 |
||
71 |
return ops->input_remove(tag); |
|
72 |
}
|
|
73 |
||
74 |
int
|
|
75 |
purple_input_get_error(int fd, int *error) |
|
76 |
{
|
|
77 |
PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
78 |
||
79 |
if (ops->input_get_error) |
|
80 |
{
|
|
81 |
int ret = ops->input_get_error(fd, error); |
|
82 |
errno = *error; |
|
83 |
return ret; |
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
socklen_t len; |
|
88 |
len = sizeof(*error); |
|
89 |
||
90 |
return getsockopt(fd, SOL_SOCKET, SO_ERROR, error, &len); |
|
91 |
}
|
|
92 |
}
|
|
93 |
||
94 |
void
|
|
95 |
purple_eventloop_set_ui_ops(PurpleEventLoopUiOps *ops) |
|
96 |
{
|
|
97 |
eventloop_ui_ops = ops; |
|
98 |
}
|
|
99 |
||
100 |
PurpleEventLoopUiOps * |
|
101 |
purple_eventloop_get_ui_ops(void) |
|
102 |
{
|
|
103 |
g_return_val_if_fail(eventloop_ui_ops != NULL, NULL); |
|
104 |
||
105 |
return eventloop_ui_ops; |
|
106 |
}
|