libpurple/eventloop.c

Thu, 25 Aug 2022 23:25:12 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 25 Aug 2022 23:25:12 -0500
branch
gtk4
changeset 41598
2b34cd990c16
parent 39556
622bf98df0ac
child 41685
ca22b00972d4
permissions
-rw-r--r--

Replace the style-updated signal with GtkIconTheme:changed

Testing Done:
Ran and make sure the `GWarning` went away.

Reviewed at https://reviews.imfreedom.org/r/1653/

20147
66f05a854eee applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents: 19859
diff changeset
1 /* purple
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
2 *
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15754
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
5 * source distribution.
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
6 *
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
10 * (at your option) any later version.
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
11 *
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
15 * GNU General Public License for more details.
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
16 *
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
18 * 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
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
20 */
28981
4e3922ab4844 Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <darkrain42@pidgin.im>
parents: 20147
diff changeset
21 #include "internal.h"
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
22 #include "eventloop.h"
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
23
38418
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
24 #define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
25 #define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
26
39556
622bf98df0ac Remove unnecessary struct tags.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 38434
diff changeset
27 typedef struct {
38418
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
28 PurpleInputFunction function;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
29 guint result;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
30 gpointer data;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
31 } PurpleIOClosure;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
32
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
33 static gboolean
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
34 purple_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
35 {
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
36 PurpleIOClosure *closure = data;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
37 PurpleInputCondition purple_cond = 0;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
38
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
39 if (condition & PURPLE_GLIB_READ_COND)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
40 purple_cond |= PURPLE_INPUT_READ;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
41 if (condition & PURPLE_GLIB_WRITE_COND)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
42 purple_cond |= PURPLE_INPUT_WRITE;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
43
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
44 #ifdef _WIN32
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
45 if(!purple_cond) {
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
46 return TRUE;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
47 }
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
48 #endif /* _WIN32 */
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
49
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
50 closure->function(closure->data, g_io_channel_unix_get_fd(source),
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
51 purple_cond);
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
52
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
53 return TRUE;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
54 }
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
55
8280
f448633d3f3a [gaim-migrate @ 9004]
Scott Lamb
parents: 8273
diff changeset
56 guint
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15754
diff changeset
57 purple_input_add(int source, PurpleInputCondition condition, PurpleInputFunction func, gpointer user_data)
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
58 {
38418
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
59 PurpleIOClosure *closure = g_new0(PurpleIOClosure, 1);
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
60 GIOChannel *channel;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
61 GIOCondition cond = 0;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
62
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
63 closure->function = func;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
64 closure->data = user_data;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
65
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
66 if (condition & PURPLE_INPUT_READ)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
67 cond |= PURPLE_GLIB_READ_COND;
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
68 if (condition & PURPLE_INPUT_WRITE)
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
69 cond |= PURPLE_GLIB_WRITE_COND;
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
70
38418
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
71 #ifdef _WIN32
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
72 channel = g_io_channel_win32_new_socket(source);
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
73 #else
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
74 channel = g_io_channel_unix_new(source);
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
75 #endif
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
76
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
77 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT,
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
78 cond, purple_io_invoke, closure, g_free);
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
79
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
80 g_io_channel_unref(channel);
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
81 return closure->result;
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
82 }
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
83
15729
6932ac4e5b3d Change out source_remove and input_remove eventloop functions to return
Mark Doliner <markdoliner@pidgin.im>
parents: 15435
diff changeset
84 gboolean
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15754
diff changeset
85 purple_input_remove(guint tag)
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
86 {
38418
9d86663a7437 eventloop: Replace eventloop input functions with Pidgin versions
Mike Ruprecht <cmaiku@gmail.com>
parents: 38417
diff changeset
87 return g_source_remove(tag);
8273
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
88 }
7882af5843e9 [gaim-migrate @ 8997]
Scott Lamb
parents:
diff changeset
89
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
90 int
33291
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
91 purple_input_pipe(int pipefd[2])
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
92 {
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
93 #ifdef _WIN32
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
94 return wpurple_input_pipe(pipefd);
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
95 #else
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
96 return pipe(pipefd);
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
97 #endif
b70ab10887a7 New custom resolver, that uses libpurple for DNS queries. Get rid of old win32 resolver. Refs#343. Fixes #6263
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 28981
diff changeset
98 }

mercurial