pidgin/libpidgin.c

Mon, 31 Oct 2022 04:02:09 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 31 Oct 2022 04:02:09 -0500
changeset 41867
5375c1d58c50
parent 41806
b7a1aab4b3be
child 41947
7b3312d0760c
permissions
-rw-r--r--

Create PurpleUi that merges PurpleCoreUiOps and PurpleUiInfo

This created a lot more refactoring that I imagined, but it's mostly just moving stuff around.

I skipped the unit tests for now because we already have a `test_ui.[ch]` in the tests directory which we can/should move to a separate library or something, so it's available outside of the `libpurple/tests/` directory.

Testing Done:
Ran the unit tests, launched pidgin3, and launched finch3 with out issue.

Bugs closed: PIDGIN-17697

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

10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
1 /*
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
2 * pidgin
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
3 *
15931
716b5fac1895 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents: 15884
diff changeset
4 * Pidgin is the legal property of its developers, whose names are too numerous
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
6 * source distribution.
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
7 *
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
12 *
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
17 *
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
19 * 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: 19840
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
21 *
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
22 */
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
23
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
24 #ifdef HAVE_CONFIG_H
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
25 # include <config.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
26 #endif
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
27
40462
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
28 #include <errno.h>
24ed25d87550 Fix some issues on macos that resulted from the internal.h cleanup
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
29
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
30 #include <glib/gi18n-lib.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
31 #include <glib/gstdio.h>
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40360
diff changeset
32
39372
43e3da39daf6 Include 'locale.h' directly in files which use setlocale()
Mike Ruprecht <cmaiku@gmail.com>
parents: 39365
diff changeset
33 #include <locale.h>
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
34
40360
e21f3bbcc2a5 Update all of the pidgin code to include purple.h
Gary Kramlich <grim@reaperworld.com>
parents: 40337
diff changeset
35 #include <purple.h>
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
36
40553
892459990bb7 Create a proper GtkApplication subclass for Pidgin and use it.
Gary Kramlich <grim@reaperworld.com>
parents: 40531
diff changeset
37 #include "pidginapplication.h"
40496
6941fece679b phase2 of pidgin.h: move existing file to pidgincore.h
Gary Kramlich <grim@reaperworld.com>
parents: 40462
diff changeset
38 #include "pidgincore.h"
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
39
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
40 #ifndef _WIN32
38047
312be70f9de6 Remove AC_HEADER_STDC and related C89 tests.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 37998
diff changeset
41 #include <signal.h>
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
42 #endif
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
43
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
44 #ifndef _WIN32
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
45
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
46 /*
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
47 * Lists of signals we wish to catch and those we wish to ignore.
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
48 * Each list terminated with -1
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
49 */
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20791
diff changeset
50 static const int catch_sig_list[] = {
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
51 SIGSEGV,
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
52 SIGINT,
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
53 SIGTERM,
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
54 SIGQUIT,
34293
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
55 SIGCHLD,
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
56 -1
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
57 };
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
58
21091
07fe1a99c47b Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents: 20791
diff changeset
59 static const int ignore_sig_list[] = {
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
60 SIGPIPE,
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
61 -1
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
62 };
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
63 #endif /* !_WIN32 */
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
64
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
65 #ifndef _WIN32
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
66 static char *segfault_message;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
67
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
68 static guint signal_channel_watcher;
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
69
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
70 static int signal_sockets[2];
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
71
14542
7c1dd9601f1d [gaim-migrate @ 17199]
Mark Doliner <markdoliner@pidgin.im>
parents: 14323
diff changeset
72 static void sighandler(int sig);
7c1dd9601f1d [gaim-migrate @ 17199]
Mark Doliner <markdoliner@pidgin.im>
parents: 14323
diff changeset
73
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
74 static void sighandler(int sig)
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
75 {
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
76 ssize_t written;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
77
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
78 /*
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
79 * We won't do any of the heavy lifting for the signal handling here
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
80 * because we have no idea what was interrupted. Previously this signal
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
81 * handler could result in some calls to malloc/free, which can cause
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
82 * deadlock in libc when the signal handler was interrupting a previous
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
83 * malloc or free. So instead we'll do an ugly hack where we write the
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
84 * signal number to one end of a socket pair. The other half of the
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
85 * socket pair is watched by our main loop. When the main loop sees new
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
86 * data on the socket it reads in the signal and performs the appropriate
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
87 * action without fear of interrupting stuff.
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
88 */
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
89 if (sig == SIGSEGV) {
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
90 fprintf(stderr, "%s", segfault_message);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
91 abort();
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
92 return;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
93 }
12556
f4d4e4e3a825 [gaim-migrate @ 14875]
Richard Laager <rlaager@pidgin.im>
parents: 12409
diff changeset
94
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
95 written = write(signal_sockets[0], &sig, sizeof(int));
40133
b86418d6eb94 Remove redundant comparisons in conditions
qarkai <qarkai@gmail.com>
parents: 40094
diff changeset
96 if (written != sizeof(int)) {
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
97 /* This should never happen */
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
98 purple_debug_error("sighandler", "Received signal %d but only "
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
99 "wrote %" G_GSSIZE_FORMAT " bytes out of %"
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
100 G_GSIZE_FORMAT ": %s\n",
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
101 sig, written, sizeof(int), g_strerror(errno));
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
102 exit(1);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
103 }
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
104 }
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
105
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
106 static gboolean
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
107 mainloop_sighandler(GIOChannel *source, GIOCondition cond, gpointer data)
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
108 {
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
109 GIOStatus stat;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
110 int sig;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
111 gsize bytes_read;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
112 GError *error = NULL;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
113
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
114 /* read the signal number off of the io channel */
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
115 stat = g_io_channel_read_chars(source, (gchar *)&sig, sizeof(int),
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
116 &bytes_read, &error);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
117 if (stat != G_IO_STATUS_NORMAL) {
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
118 purple_debug_error("sighandler", "Signal callback failed to read "
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
119 "from signal socket: %s", error->message);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
120 purple_core_quit();
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
121 return FALSE;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
122 }
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
123
34293
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
124 switch (sig) {
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
125 case SIGCHLD:
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
126 /* Restore signal catching */
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
127 signal(SIGCHLD, sighandler);
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
128 break;
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
129 default:
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
130 purple_debug_warning("sighandler", "Caught signal %d\n", sig);
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
131 purple_core_quit();
c1da9082287f Fix a crash in case of Ctrl+C while booting (it's fork related)
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents: 33955
diff changeset
132 }
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
133
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
134 return TRUE;
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
135 }
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
136 #endif /* !_WIN32 */
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
137
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
138 #ifndef _WIN32
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
139 static void
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
140 pidgin_setup_error_handler(void)
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
141 {
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
142 int sig_indx; /* for setting up signal catching */
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
143 sigset_t sigset;
10323
f4a013ac9e7c [gaim-migrate @ 11530]
Mark Doliner <markdoliner@pidgin.im>
parents: 10322
diff changeset
144 char errmsg[BUFSIZ];
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
145 GIOChannel *signal_channel;
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
146 GIOStatus signal_status;
39365
af69ee5abbf2 pidgin: Fix compiling with -Dconsole-logging=true
Mike Ruprecht <cmaiku@gmail.com>
parents: 39335
diff changeset
147 GError *error = NULL;
13215
c3e72e316531 [gaim-migrate @ 15578]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents: 13111
diff changeset
148 char *segfault_message_tmp;
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
149
40531
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
150 /* We translate this here in case the crash breaks gettext. */
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
151 segfault_message_tmp = g_strdup_printf(_(
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
152 "%s %s has segfaulted and attempted to dump a core file.\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
153 "This is a bug in the software and has happened through\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
154 "no fault of your own.\n\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
155 "If you can reproduce the crash, please notify the developers\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
156 "by reporting a bug at:\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
157 "%snewissue\n\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
158 "Please make sure to specify what you were doing at the time\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
159 "and post the backtrace from the core file. If you do not know\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
160 "how to get the backtrace, please read the instructions at\n"
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
161 "https://developer.pidgin.im/wiki/GetABacktrace\n"),
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
162 PIDGIN_NAME, DISPLAY_VERSION, PURPLE_WEBSITE
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
163 );
13587
fb0245a7ccab [gaim-migrate @ 15971]
Daniel Atallah <datallah@pidgin.im>
parents: 13429
diff changeset
164
40531
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
165 /* we have to convert the message (UTF-8 to console
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
166 charset) early because after a segmentation fault
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
167 it's not a good practice to allocate memory */
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
168 segfault_message = g_locale_from_utf8(segfault_message_tmp, -1, NULL, NULL,
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
169 &error);
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
170 if(segfault_message != NULL) {
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
171 g_free(segfault_message_tmp);
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
172 } else {
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
173 /* use 'segfault_message_tmp' (UTF-8) as a fallback */
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
174 g_warning("%s\n", error->message);
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
175 g_clear_error(&error);
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
176 segfault_message = segfault_message_tmp;
ed47469c4311 Fix some broken urls and get rid of the old developer segfault message
Gary Kramlich <grim@reaperworld.com>
parents: 40509
diff changeset
177 }
12556
f4d4e4e3a825 [gaim-migrate @ 14875]
Richard Laager <rlaager@pidgin.im>
parents: 12409
diff changeset
178
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
179 /*
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
180 * Create a socket pair for receiving unix signals from a signal
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
181 * handler.
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
182 */
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
183 if (socketpair(AF_UNIX, SOCK_STREAM, 0, signal_sockets) < 0) {
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
184 perror("Failed to create sockets for GLib signal handling");
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
185 exit(1);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
186 }
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
187 signal_channel = g_io_channel_unix_new(signal_sockets[1]);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
188
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
189 /*
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
190 * Set the channel encoding to raw binary instead of the default of
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
191 * UTF-8, because we'll be sending integers across instead of strings.
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
192 */
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
193 signal_status = g_io_channel_set_encoding(signal_channel, NULL, &error);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
194 if (signal_status != G_IO_STATUS_NORMAL) {
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
195 fprintf(stderr, "Failed to set the signal channel to raw "
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
196 "binary: %s", error->message);
38607
51b50879b5c9 libpidgin: Fix Windows crash by initializing error to NULL
Mike Ruprecht <cmaiku@gmail.com>
parents: 38578
diff changeset
197 g_clear_error(&error);
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
198 exit(1);
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
199 }
29991
37e306c31983 Try to be polite and free stuff associated with our signal watcher pipes
Mark Doliner <markdoliner@pidgin.im>
parents: 29662
diff changeset
200 signal_channel_watcher = g_io_add_watch(signal_channel, G_IO_IN, mainloop_sighandler, NULL);
37e306c31983 Try to be polite and free stuff associated with our signal watcher pipes
Mark Doliner <markdoliner@pidgin.im>
parents: 29662
diff changeset
201 g_io_channel_unref(signal_channel);
28820
58701e24ed40 We really shouldn't be doing a whole lot in our signal handler. The
Mark Doliner <markdoliner@pidgin.im>
parents: 28800
diff changeset
202
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
203 /* Let's not violate any PLA's!!!! */
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
204 /* jseymour: whatever the fsck that means */
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
205 /* Robot101: for some reason things like gdm like to block *
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
206 * useful signals like SIGCHLD, so we unblock all the ones we *
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
207 * declare a handler for. thanks JSeymour and Vann. */
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
208 if (sigemptyset(&sigset)) {
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
209 g_snprintf(errmsg, sizeof(errmsg),
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
210 "Warning: couldn't initialise empty signal set");
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
211 perror(errmsg);
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
212 }
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
213 for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) {
33794
716cbef8d1c6 Fix a number of additional trivial issues - unused variables, etc.
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
214 if(signal(catch_sig_list[sig_indx], sighandler) == SIG_ERR) {
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
215 g_snprintf(errmsg, sizeof(errmsg),
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
216 "Warning: couldn't set signal %d for catching",
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
217 catch_sig_list[sig_indx]);
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
218 perror(errmsg);
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
219 }
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
220 if(sigaddset(&sigset, catch_sig_list[sig_indx])) {
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
221 g_snprintf(errmsg, sizeof(errmsg),
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
222 "Warning: couldn't include signal %d for unblocking",
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
223 catch_sig_list[sig_indx]);
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
224 perror(errmsg);
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
225 }
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
226 }
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
227 for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) {
33794
716cbef8d1c6 Fix a number of additional trivial issues - unused variables, etc.
Daniel Atallah <datallah@pidgin.im>
parents: 33371
diff changeset
228 if(signal(ignore_sig_list[sig_indx], SIG_IGN) == SIG_ERR) {
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
229 g_snprintf(errmsg, sizeof(errmsg),
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
230 "Warning: couldn't set signal %d to ignore",
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
231 ignore_sig_list[sig_indx]);
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
232 perror(errmsg);
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
233 }
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
234 }
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
235
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
236 if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) {
40094
8e6d91e4dd8f Use g_(v)snprintf so we need less wrappers.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39954
diff changeset
237 g_snprintf(errmsg, sizeof(errmsg), "Warning: couldn't unblock signals");
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
238 perror(errmsg);
10307
f3ba80364053 [gaim-migrate @ 11497]
Mark Doliner <markdoliner@pidgin.im>
parents: 10306
diff changeset
239 }
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
240 }
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
241 #endif /* !_WIN32 */
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
242
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
243 int pidgin_start(int argc, char *argv[])
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
244 {
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
245 GApplication *app;
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
246 int ret;
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
247
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
248 bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
249 bind_textdomain_codeset(PACKAGE, "UTF-8");
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
250 textdomain(PACKAGE);
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
251
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
252 /* Locale initialization is not complete here. See gtk_init_check() */
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
253 setlocale(LC_ALL, "");
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
254
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
255 #ifndef _WIN32
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
256 pidgin_setup_error_handler();
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
257 #endif
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
258
40553
892459990bb7 Create a proper GtkApplication subclass for Pidgin and use it.
Gary Kramlich <grim@reaperworld.com>
parents: 40531
diff changeset
259 app = pidgin_application_new();
40600
46d10c72c137 Create a new ContactList that will eventually fully replace PidginBuddyList
Gary Kramlich <grim@reaperworld.com>
parents: 40553
diff changeset
260 g_application_set_default(app);
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
261
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
262 ret = g_application_run(app, argc, argv);
38383
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
263
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
264 /* Make sure purple has quit in case something in GApplication
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
265 * has caused g_application_run() to finish on its own. This can
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
266 * happen, for example, if the desktop session is ending.
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
267 */
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
268 if (purple_get_core() != NULL) {
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
269 purple_core_quit();
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
270 }
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
271
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
272 if (g_application_get_is_registered(app) &&
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
273 g_application_get_is_remote(app)) {
39921
a9c92a82f4c8 Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39857
diff changeset
274 g_printerr("%s\n", _("Exiting because another libpurple client is "
a9c92a82f4c8 Don't pass literals to g_set_error / g_error_new.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39857
diff changeset
275 "already running."));
39256
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
276 }
0245b49e1231 libpidgin: Use GApplication command line argument parsing and uniqueness
Mike Ruprecht <cmaiku@gmail.com>
parents: 39255
diff changeset
277
38383
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
278 /* Now that we're sure purple_core_quit() has been called,
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
279 * this can be freed.
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
280 */
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
281 g_object_unref(app);
10320
f5b0f5cf8562 [gaim-migrate @ 11527]
Mark Doliner <markdoliner@pidgin.im>
parents: 10317
diff changeset
282
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
283 #ifndef _WIN32
12556
f4d4e4e3a825 [gaim-migrate @ 14875]
Richard Laager <rlaager@pidgin.im>
parents: 12409
diff changeset
284 g_free(segfault_message);
29991
37e306c31983 Try to be polite and free stuff associated with our signal watcher pipes
Mark Doliner <markdoliner@pidgin.im>
parents: 29662
diff changeset
285 g_source_remove(signal_channel_watcher);
37e306c31983 Try to be polite and free stuff associated with our signal watcher pipes
Mark Doliner <markdoliner@pidgin.im>
parents: 29662
diff changeset
286 close(signal_sockets[0]);
37e306c31983 Try to be polite and free stuff associated with our signal watcher pipes
Mark Doliner <markdoliner@pidgin.im>
parents: 29662
diff changeset
287 close(signal_sockets[1]);
38064
7cb860a7bb2e libpidgin: Fix Win32 build due to lacking signalpair() and some enums
Mike Ruprecht <cmaiku@gmail.com>
parents: 38048
diff changeset
288 #endif
12556
f4d4e4e3a825 [gaim-migrate @ 14875]
Richard Laager <rlaager@pidgin.im>
parents: 12409
diff changeset
289
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
290 #ifdef _WIN32
15574
18d9d1c05994 Win32 de-gaimification of pidgin
Daniel Atallah <datallah@pidgin.im>
parents: 15567
diff changeset
291 winpidgin_cleanup();
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
292 #endif
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
293
38383
0ceb576f5617 libpidgin: Port to use GtkApplication
Mike Ruprecht <cmaiku@gmail.com>
parents: 38240
diff changeset
294 return ret;
10302
8c73238fb5d4 [gaim-migrate @ 11487]
Mark Doliner <markdoliner@pidgin.im>
parents:
diff changeset
295 }

mercurial