annotate finch/finch.c @ 16748:da7621e799b7

Enable usage of RC4 in libpurple, now that it is in 2.0.1.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Thu, 31 May 2007 02:17:03 +0000
parents f8f78fa7e774
children afa0a7b053b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
15871
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
2 * finch
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15871
66dff3dfdea6 Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
4 * Finch is the legal property of its developers, whose names are too numerous
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * source distribution.
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 #include "account.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #include "conversation.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "core.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include "debug.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "eventloop.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "ft.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "log.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "notify.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "prefs.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "prpl.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "pounce.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "savedstatuses.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 #include "sound.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #include "status.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include "util.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "whiteboard.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 #include "gntdebug.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 #include "finch.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #include "gntprefs.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 #include "gntui.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 #include "gntidle.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 #define _GNU_SOURCE
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 #include <getopt.h>
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 #include "config.h"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 static void
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 debug_init()
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 finch_debug_init();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 purple_debug_set_ui_ops(finch_debug_get_ui_ops());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 static PurpleCoreUiOps core_ops =
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 finch_prefs_init,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 debug_init,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 gnt_ui_init,
16677
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
62 gnt_ui_uninit,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
63
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
64 /* padding */
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
65 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
66 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
67 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
68 NULL
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 };
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 static PurpleCoreUiOps *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 gnt_core_get_ui_ops()
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 return &core_ops;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 /* Anything IO-related is directly copied from gtkpurple's source tree */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 #define FINCH_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 #define FINCH_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 typedef struct _PurpleGntIOClosure {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 PurpleInputFunction function;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 guint result;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 gpointer data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 } PurpleGntIOClosure;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 static void purple_gnt_io_destroy(gpointer data)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 g_free(data);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 static gboolean purple_gnt_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 PurpleGntIOClosure *closure = data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 PurpleInputCondition purple_cond = 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 if (condition & FINCH_READ_COND)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 purple_cond |= PURPLE_INPUT_READ;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 if (condition & FINCH_WRITE_COND)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 purple_cond |= PURPLE_INPUT_WRITE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 #if 0
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 purple_debug(PURPLE_DEBUG_MISC, "gtk_eventloop",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 "CLOSURE: callback for %d, fd is %d\n",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 closure->result, g_io_channel_unix_get_fd(source));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 #endif
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 #ifdef _WIN32
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 if(! purple_cond) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 #if DEBUG
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 purple_debug_misc("gnt_eventloop",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 "CLOSURE received GIOCondition of 0x%x, which does not"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 " match 0x%x (READ) or 0x%x (WRITE)\n",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 condition, FINCH_READ_COND, FINCH_WRITE_COND);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 #endif /* DEBUG */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 return TRUE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 #endif /* _WIN32 */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 closure->function(closure->data, g_io_channel_unix_get_fd(source),
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 purple_cond);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 return TRUE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 static guint gnt_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 gpointer data)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 PurpleGntIOClosure *closure = g_new0(PurpleGntIOClosure, 1);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 GIOChannel *channel;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 GIOCondition cond = 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 closure->function = function;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 closure->data = data;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 if (condition & PURPLE_INPUT_READ)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 cond |= FINCH_READ_COND;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 if (condition & PURPLE_INPUT_WRITE)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 cond |= FINCH_WRITE_COND;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 channel = g_io_channel_unix_new(fd);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 purple_gnt_io_invoke, closure, purple_gnt_io_destroy);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 g_io_channel_unref(channel);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 return closure->result;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 static PurpleEventLoopUiOps eventloop_ops =
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 g_timeout_add,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 g_source_remove,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 gnt_input_add,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 g_source_remove,
16677
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
158 NULL, /* input_get_error */
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
159
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
160 /* padding */
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
161 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
162 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
163 NULL,
30829e806dae And finch is up to date
Gary Kramlich <grim@reaperworld.com>
parents: 16573
diff changeset
164 NULL
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 };
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 static PurpleEventLoopUiOps *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 gnt_eventloop_get_ui_ops(void)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 return &eventloop_ops;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 /* This is mostly copied from gtkpurple's source tree */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 static void
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 show_usage(const char *name, gboolean terse)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 char *text;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 if (terse) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 text = g_strdup_printf(_("%s. Try `%s -h' for more information.\n"), VERSION, name);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 } else {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 text = g_strdup_printf(_("%s\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 "Usage: %s [OPTION]...\n\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 " -c, --config=DIR use DIR for config files\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 " -d, --debug print debugging messages to stdout\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 " -h, --help display this help and exit\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 " -n, --nologin don't automatically login\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 " -v, --version display the current version and exit\n"), VERSION, name);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 purple_print_utf8_to_console(stdout, text);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 g_free(text);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 static int
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 init_libpurple(int argc, char **argv)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 char *path;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 int opt;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 gboolean opt_help = FALSE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 gboolean opt_nologin = FALSE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 gboolean opt_version = FALSE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 char *opt_config_dir_arg = NULL;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 char *opt_session_arg = NULL;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 gboolean debug_enabled = FALSE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 struct option long_options[] = {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 {"config", required_argument, NULL, 'c'},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 {"debug", no_argument, NULL, 'd'},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 {"help", no_argument, NULL, 'h'},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 {"nologin", no_argument, NULL, 'n'},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 {"session", required_argument, NULL, 's'},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 {"version", no_argument, NULL, 'v'},
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 {0, 0, 0, 0}
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 };
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
16533
2da3e5a69ebc Add the fatal asserts enabling code to Finch. I'm uneasy about putting this in libpurple, because then a fatal-asserts-enabled libpurple would kill any UI that had a glib debug error, which might not even be in libpurple. I'm not sure we want that, though it may not matter since this is for debugging only.
Richard Laager <rlaager@wiktel.com>
parents: 16483
diff changeset
217 #ifdef PURPLE_FATAL_ASSERTS
2da3e5a69ebc Add the fatal asserts enabling code to Finch. I'm uneasy about putting this in libpurple, because then a fatal-asserts-enabled libpurple would kill any UI that had a glib debug error, which might not even be in libpurple. I'm not sure we want that, though it may not matter since this is for debugging only.
Richard Laager <rlaager@wiktel.com>
parents: 16483
diff changeset
218 /* Make g_return_... functions fatal. */
2da3e5a69ebc Add the fatal asserts enabling code to Finch. I'm uneasy about putting this in libpurple, because then a fatal-asserts-enabled libpurple would kill any UI that had a glib debug error, which might not even be in libpurple. I'm not sure we want that, though it may not matter since this is for debugging only.
Richard Laager <rlaager@wiktel.com>
parents: 16483
diff changeset
219 g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
2da3e5a69ebc Add the fatal asserts enabling code to Finch. I'm uneasy about putting this in libpurple, because then a fatal-asserts-enabled libpurple would kill any UI that had a glib debug error, which might not even be in libpurple. I'm not sure we want that, though it may not matter since this is for debugging only.
Richard Laager <rlaager@wiktel.com>
parents: 16483
diff changeset
220 #endif
2da3e5a69ebc Add the fatal asserts enabling code to Finch. I'm uneasy about putting this in libpurple, because then a fatal-asserts-enabled libpurple would kill any UI that had a glib debug error, which might not even be in libpurple. I'm not sure we want that, though it may not matter since this is for debugging only.
Richard Laager <rlaager@wiktel.com>
parents: 16483
diff changeset
221
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 #ifdef ENABLE_NLS
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 bindtextdomain(PACKAGE, LOCALEDIR);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 bind_textdomain_codeset(PACKAGE, "UTF-8");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 textdomain(PACKAGE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 #endif
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 #ifdef HAVE_SETLOCALE
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 setlocale(LC_ALL, "");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 #endif
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 /* scan command-line options */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 opterr = 1;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 while ((opt = getopt_long(argc, argv,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 #ifndef _WIN32
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 "c:dhn::s:v",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 #else
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 "c:dhn::v",
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 #endif
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 long_options, NULL)) != -1) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 switch (opt) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 case 'c': /* config dir */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 g_free(opt_config_dir_arg);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 opt_config_dir_arg = g_strdup(optarg);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 case 'd': /* debug */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 debug_enabled = TRUE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 case 'h': /* help */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 opt_help = TRUE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 case 'n': /* no autologin */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 opt_nologin = TRUE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 case 's': /* use existing session ID */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 g_free(opt_session_arg);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 opt_session_arg = g_strdup(optarg);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 case 'v': /* version */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 opt_version = TRUE;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 case '?': /* show terse help */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 default:
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 show_usage(argv[0], TRUE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 return 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 break;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 /* show help message */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 if (opt_help) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 show_usage(argv[0], FALSE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 return 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 /* show version message */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 if (opt_version) {
16081
306b2f0143f8 This is called Finch
Richard Nelson <wabz@pidgin.im>
parents: 15871
diff changeset
277 printf("Finch %s\n", VERSION);
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 return 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 /* set a user-specified config directory */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 if (opt_config_dir_arg != NULL) {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 purple_util_set_user_dir(opt_config_dir_arg);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 g_free(opt_config_dir_arg);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 /*
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 * We're done piddling around with command line arguments.
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 * Fire up this baby.
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
16380
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
292 /* We don't want debug-messages to show up and corrupt the display */
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 purple_debug_set_enabled(debug_enabled);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294
16380
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
295 /* If we're using a custom configuration directory, we
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
296 * do NOT want to migrate, or weird things will happen. */
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
297 if (opt_config_dir_arg == NULL)
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
298 {
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
299 if (!purple_core_migrate())
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
300 {
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
301 char *old = g_strconcat(purple_home_dir(),
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
302 G_DIR_SEPARATOR_S ".gaim", NULL);
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
303 char *text = g_strdup_printf(_(
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
304 "%s encountered errors migrating your settings "
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
305 "from %s to %s. Please investigate and complete the "
16700
f8f78fa7e774 Solicit bug reports
Sean Egan <seanegan@gmail.com>
parents: 16677
diff changeset
306 "migration by hand. Please report this error at http://developer.pidgin.im"), _("Finch"),
16380
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
307 old, purple_user_dir());
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
308
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
309 g_free(old);
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
310
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
311 purple_print_utf8_to_console(stderr, text);
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
312 g_free(text);
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
313
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
314 return 0;
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
315 }
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
316 }
6c97924af83b Call the migrate code from Finch.
Richard Laager <rlaager@wiktel.com>
parents: 16098
diff changeset
317
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 purple_core_set_ui_ops(gnt_core_get_ui_ops());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 purple_eventloop_set_ui_ops(gnt_eventloop_get_ui_ops());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 purple_idle_set_ui_ops(finch_idle_get_ui_ops());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 path = g_build_filename(purple_user_dir(), "plugins", NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 purple_plugins_add_search_path(path);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 g_free(path);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 purple_plugins_add_search_path(LIBDIR);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 if (!purple_core_init(FINCH_UI))
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 fprintf(stderr,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 "Initialization of the Purple core failed. Dumping core.\n"
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 "Please report this!\n");
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 abort();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 /* TODO: Move blist loading into purple_blist_init() */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 purple_set_blist(purple_blist_new());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 purple_blist_load();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 /* TODO: Move prefs loading into purple_prefs_init() */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 purple_prefs_load();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 purple_prefs_update_old();
16573
ac0d07c7fd90 Pref migration for finch.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 16533
diff changeset
343 finch_prefs_update_old();
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 /* load plugins we had when we quit */
16427
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 16098
diff changeset
346 purple_plugins_load_saved("/finch/plugins/loaded");
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 /* TODO: Move pounces loading into purple_pounces_init() */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 purple_pounces_load();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 if (opt_nologin)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353 /* Set all accounts to "offline" */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 PurpleSavedStatus *saved_status;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 /* If we've used this type+message before, lookup the transient status */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357 saved_status = purple_savedstatus_find_transient_by_type_and_message(
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 PURPLE_STATUS_OFFLINE, NULL);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 /* If this type+message is unique then create a new transient saved status */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 if (saved_status == NULL)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 saved_status = purple_savedstatus_new(NULL, PURPLE_STATUS_OFFLINE);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 /* Set the status for each account */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 purple_savedstatus_activate(saved_status);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 else
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 /* Everything is good to go--sign on already */
16427
4999bbc52881 Works for me! Renames prefs: /core to /purple, /gaim/gtk to /pidgin, /gaim/gnt to /finch
Sean Egan <seanegan@gmail.com>
parents: 16098
diff changeset
370 if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 purple_savedstatus_activate(purple_savedstatus_get_startup());
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372 purple_accounts_restore_current_statuses();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 return 1;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 int main(int argc, char **argv)
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 {
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 signal(SIGPIPE, SIG_IGN);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 /* Initialize the libpurple stuff */
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 if (!init_libpurple(argc, argv))
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384 return 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 purple_blist_show();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387 gnt_main();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
388
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 #ifdef STANDALONE
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 purple_core_quit();
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 #endif
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393 return 0;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 }
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395