Sat, 08 Sep 2007 03:09:35 +0000
The FSF changed its address a while ago; our files were out of date.
This is a quick update done with a for loop, find, and sed.
| 8273 | 1 | /** |
| 15884 | 2 | * @file eventloop.c Purple Event Loop API |
| 8273 | 3 | * @ingroup core |
| 4 | * | |
| 15884 | 5 | * purple |
| 8273 | 6 | * |
| 15884 | 7 | * Purple is the legal property of its developers, whose names are too numerous |
| 8273 | 8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 9 | * source distribution. | |
| 10 | * | |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19733
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8273 | 24 | */ |
| 25 | #include "eventloop.h" | |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
26 | #include "internal.h" |
| 8273 | 27 | |
| 15884 | 28 | static PurpleEventLoopUiOps *eventloop_ui_ops = NULL; |
| 8273 | 29 | |
| 30 | guint | |
| 15884 | 31 | purple_timeout_add(guint interval, GSourceFunc function, gpointer data) |
| 8273 | 32 | { |
| 15884 | 33 | PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
| 8273 | 34 | |
| 35 | return ops->timeout_add(interval, function, data); | |
| 36 | } | |
| 37 | ||
|
8387
381fc8b4f8f7
[gaim-migrate @ 9115]
Christian Hammond <chipx86@chipx86.com>
parents:
8287
diff
changeset
|
38 | guint |
|
18070
79c7fe0d8e4b
Wire everything up and document it.
Richard Laager <rlaager@pidgin.im>
parents:
18068
diff
changeset
|
39 | purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) |
|
18067
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
40 | { |
|
18070
79c7fe0d8e4b
Wire everything up and document it.
Richard Laager <rlaager@pidgin.im>
parents:
18068
diff
changeset
|
41 | PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
18067
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
42 | |
|
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
43 | if (ops->timeout_add_seconds) |
|
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
44 | return ops->timeout_add_seconds(interval, function, data); |
|
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
45 | else |
|
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
46 | return ops->timeout_add(1000 * interval, function, data); |
|
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
47 | } |
|
ce02548a6b6a
The second_add_timeout patch from Arjan.
Richard Laager <rlaager@pidgin.im>
parents:
14254
diff
changeset
|
48 | |
|
15729
6932ac4e5b3d
Change out source_remove and input_remove eventloop functions to return
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
49 | gboolean |
| 15884 | 50 | purple_timeout_remove(guint tag) |
| 8287 | 51 | { |
| 15884 | 52 | PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
| 8287 | 53 | |
| 54 | return ops->timeout_remove(tag); | |
| 55 | } | |
| 56 | ||
| 8280 | 57 | guint |
| 15884 | 58 | purple_input_add(int source, PurpleInputCondition condition, PurpleInputFunction func, gpointer user_data) |
| 8273 | 59 | { |
| 15884 | 60 | PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
| 8273 | 61 | |
| 62 | return ops->input_add(source, condition, func, user_data); | |
| 63 | } | |
| 64 | ||
|
15729
6932ac4e5b3d
Change out source_remove and input_remove eventloop functions to return
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
65 | gboolean |
| 15884 | 66 | purple_input_remove(guint tag) |
| 8273 | 67 | { |
| 15884 | 68 | PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
| 8273 | 69 | |
| 70 | return ops->input_remove(tag); | |
| 71 | } | |
| 72 | ||
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
73 | int |
| 15884 | 74 | purple_input_get_error(int fd, int *error) |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
75 | { |
| 15884 | 76 | PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); |
|
15746
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
77 | |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
78 | if (ops->input_get_error) |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
79 | { |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
80 | int ret = ops->input_get_error(fd, error); |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
81 | errno = *error; |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
82 | return ret; |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
83 | } |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
84 | else |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
85 | { |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
86 | socklen_t len; |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
87 | len = sizeof(*error); |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
88 | |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
89 | return getsockopt(fd, SOL_SOCKET, SO_ERROR, error, &len); |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
90 | } |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
91 | } |
|
017e33725857
Added a new GaimEventLoopUiOps item, input_get_error(). This function allows the UI to return the current error status on a socket/input. If the UI does not implement it (as Pidgin and gntgaim do not, since glib's handling of sockets is sane), it is just a wrapper around getsockopt(). Implemented or not, its return values should match those of getsockopt() with a level of SOL_SOCKET and an option of SO_ERROR. For curious souls, Adium will be using this to provide a working version of getsockopt(); the CoreFoundation CFSocket class which is used for socket read/write calls getsockopt() with SO_ERROR itself, thereby clearing the error flag [as documented in getsockopt()'s behavior], so depending upon it for determining if an error occurred leads to significant misbehavior.
Evan Schoenberg <evands@pidgin.im>
parents:
15729
diff
changeset
|
92 | |
| 8273 | 93 | void |
| 15884 | 94 | purple_eventloop_set_ui_ops(PurpleEventLoopUiOps *ops) |
| 8273 | 95 | { |
| 96 | eventloop_ui_ops = ops; | |
| 97 | } | |
| 98 | ||
| 15884 | 99 | PurpleEventLoopUiOps * |
| 100 | purple_eventloop_get_ui_ops(void) | |
| 8273 | 101 | { |
|
11291
5441d2419942
[gaim-migrate @ 13491]
Mark Doliner <markdoliner@pidgin.im>
parents:
10566
diff
changeset
|
102 | g_return_val_if_fail(eventloop_ui_ops != NULL, NULL); |
| 8273 | 103 | |
| 104 | return eventloop_ui_ops; | |
| 105 | } |