prefs: Convert Status/Idle page to glade.
[pidgin-git.git] / libpurple / eventloop.h
blob30ecd1518f327dc7462141ff40c87a23833e9105
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_EVENTLOOP_H_
23 #define _PURPLE_EVENTLOOP_H_
24 /**
25 * SECTION:eventloop
26 * @section_id: libpurple-eventloop
27 * @short_description: <filename>eventloop.h</filename>
28 * @title: Event Loop API
31 #include <glib.h>
32 #include <glib-object.h>
34 /**
35 * PurpleInputCondition:
36 * @PURPLE_INPUT_READ: A read condition.
37 * @PURPLE_INPUT_WRITE: A write condition.
39 * An input condition.
41 typedef enum
43 PURPLE_INPUT_READ = 1 << 0,
44 PURPLE_INPUT_WRITE = 1 << 1
46 } PurpleInputCondition;
48 /**
49 * PurpleInputFunction:
51 * The type of callbacks to handle events on file descriptors, as passed to
52 * purple_input_add(). The callback will receive the @user_data passed to
53 * purple_input_add(), the file descriptor on which the event occurred, and the
54 * condition that was satisfied to cause the callback to be invoked.
56 typedef void (*PurpleInputFunction)(gpointer data, gint fd, PurpleInputCondition cond);
58 G_BEGIN_DECLS
60 /**************************************************************************/
61 /* Event Loop API */
62 /**************************************************************************/
64 /**
65 * purple_input_add:
66 * @fd: The input file descriptor.
67 * @cond: The condition type.
68 * @func: (scope call): The callback function for data.
69 * @user_data: User-specified data.
71 * Adds an input handler.
73 * See g_io_add_watch_full().
75 * Returns: The resulting handle (will be greater than 0).
77 guint purple_input_add(int fd, PurpleInputCondition cond,
78 PurpleInputFunction func, gpointer user_data);
80 /**
81 * purple_input_remove:
82 * @handle: The handle of the input handler. Note that this is the return
83 * value from purple_input_add(), <emphasis>not</emphasis> the
84 * file descriptor.
86 * Removes an input handler.
88 gboolean purple_input_remove(guint handle);
90 /**
91 * purple_input_pipe:
92 * @pipefd: Array used to return file descriptors for both ends of pipe.
94 * Creates a pipe - an unidirectional data channel that can be used for
95 * interprocess communication.
97 * File descriptors for both ends of pipe will be written into provided array.
98 * The first one (pipefd[0]) can be used for reading, the second one (pipefd[1])
99 * for writing.
101 * On Windows it's simulated by creating a pair of connected sockets, on other
102 * systems pipe() is used.
104 * Returns: 0 on success, -1 on error.
107 purple_input_pipe(int pipefd[2]);
109 G_END_DECLS
111 #endif /* _PURPLE_EVENTLOOP_H_ */