Updated Bengali translation, a month and a half after it was submitted. Fixes #12141.
[pidgin-git.git] / libpurple / eventloop.c
blob35467a4e9b3882f3f8fa076ccf6c1b582ceb1ac7
1 /**
2 * @file eventloop.c Purple Event Loop API
3 * @ingroup core
4 */
6 /* purple
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.
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.
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.
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
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #include "internal.h"
27 #include "eventloop.h"
29 static PurpleEventLoopUiOps *eventloop_ui_ops = NULL;
31 guint
32 purple_timeout_add(guint interval, GSourceFunc function, gpointer data)
34 PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
36 return ops->timeout_add(interval, function, data);
39 guint
40 purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
42 PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
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);
50 gboolean
51 purple_timeout_remove(guint tag)
53 PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
55 return ops->timeout_remove(tag);
58 guint
59 purple_input_add(int source, PurpleInputCondition condition, PurpleInputFunction func, gpointer user_data)
61 PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
63 return ops->input_add(source, condition, func, user_data);
66 gboolean
67 purple_input_remove(guint tag)
69 PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
71 return ops->input_remove(tag);
74 int
75 purple_input_get_error(int fd, int *error)
77 PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
79 if (ops->input_get_error)
81 int ret = ops->input_get_error(fd, error);
82 errno = *error;
83 return ret;
85 else
87 socklen_t len;
88 len = sizeof(*error);
90 return getsockopt(fd, SOL_SOCKET, SO_ERROR, error, &len);
94 void
95 purple_eventloop_set_ui_ops(PurpleEventLoopUiOps *ops)
97 eventloop_ui_ops = ops;
100 PurpleEventLoopUiOps *
101 purple_eventloop_get_ui_ops(void)
103 g_return_val_if_fail(eventloop_ui_ops != NULL, NULL);
105 return eventloop_ui_ops;