annotate src/core.c @ 2584:34812d648f72

[gaim-migrate @ 2597] heh. this was pointless. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 23 Oct 2001 08:06:09 +0000
parents 271011bbe14e
children 35c23df11d16
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * (at your option) any later version.
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 *
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * GNU General Public License for more details.
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 */
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 #ifdef HAVE_CONFIG_H
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include "config.h"
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 #endif
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include <glib.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include <stdio.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #include <stdlib.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <sys/types.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <sys/socket.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <sys/stat.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include <sys/un.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include <unistd.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <errno.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <signal.h>
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include <getopt.h>
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
37 #include <stdarg.h>
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 #include "gaim.h"
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 static gint UI_fd = -1;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 GSList *uis = NULL;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
2544
271011bbe14e [gaim-migrate @ 2557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
44 static guchar *UI_build(guint32 *len, guchar type, guchar subtype, va_list args)
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
45 {
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
46 guchar *buffer;
2462
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
47 guint32 pos;
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
48 int size;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
49 void *data;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
50
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
51 *len = sizeof(guchar) * 2 + 4;
2462
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
52 buffer = g_malloc(*len);
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
53 pos = 0;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
54
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
55 memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
56 memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
57
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
58 /* we come back and do size last */
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
59 pos += 4;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
60
2544
271011bbe14e [gaim-migrate @ 2557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
61 size = va_arg(args, int);
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
62 while (size != -1) {
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
63 *len += size;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
64 buffer = g_realloc(buffer, *len);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
65
2544
271011bbe14e [gaim-migrate @ 2557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
66 data = va_arg(args, void *);
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
67 memcpy(buffer + pos, data, size);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
68 pos += size;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
69
2544
271011bbe14e [gaim-migrate @ 2557]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2541
diff changeset
70 size = va_arg(args, int);
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
71 }
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
72
2482
7e4757801725 [gaim-migrate @ 2495]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2462
diff changeset
73 pos -= sizeof(guchar) * 2 + 4;
7e4757801725 [gaim-migrate @ 2495]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2462
diff changeset
74
2462
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
75 /* now we do size */
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
76 memcpy(buffer + sizeof(guchar) * 2, &pos, 4);
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
77
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
78 return buffer;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
79 }
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
80
2435
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
81 gint UI_write(struct UI *ui, guchar *data, gint len)
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
82 {
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
83 gint sent;
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
84 /* we'll let the write silently fail because the read will pick it up as dead */
2482
7e4757801725 [gaim-migrate @ 2495]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2462
diff changeset
85 g_io_channel_write(ui->channel, data, len, &sent);
2435
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
86 return sent;
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
87 }
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
88
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
89 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...)
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
90 {
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
91 va_list ap;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
92 gchar *data;
2462
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
93 guint32 len;
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
94
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
95 va_start(ap, subtype);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
96 data = UI_build(&len, type, subtype, ap);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
97 va_end(ap);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
98
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
99 UI_write(ui, data, len);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
100
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
101 g_free(data);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
102 }
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
103
2435
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
104 void UI_broadcast(guchar *data, gint len)
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
105 {
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
106 GSList *u = uis;
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
107 while (u) {
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
108 struct UI *ui = u->data;
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
109 UI_write(ui, data, len);
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
110 u = u->next;
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
111 }
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
112 }
b4f2a53c0ee5 [gaim-migrate @ 2448]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2430
diff changeset
113
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
114 void UI_build_broadcast(guchar type, guchar subtype, ...)
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
115 {
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
116 va_list ap;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
117 gchar *data;
2462
cf2f2450f7cc [gaim-migrate @ 2475]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2447
diff changeset
118 guint32 len;
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
119
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
120 if (!uis)
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
121 return;
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
122
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
123 va_start(ap, subtype);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
124 data = UI_build(&len, type, subtype, ap);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
125 va_end(ap);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
126
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
127 UI_broadcast(data, len);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
128
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
129 g_free(data);
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
130 }
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
131
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
132 static void meta_handler(struct UI *ui, guchar subtype, guchar *data)
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
133 {
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
134 switch (subtype) {
2440
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
135 case CUI_META_LIST:
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
136 break;
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
137 case CUI_META_QUIT:
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
138 while (uis) {
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
139 ui = uis->data;
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
140 uis = g_slist_remove(uis, ui);
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
141 g_io_channel_close(ui->channel);
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
142 g_source_remove(ui->inpa);
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
143 g_free(ui);
2440
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
144 }
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
145 do_quit();
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
146 break;
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
147 case CUI_META_DETACH:
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
148 uis = g_slist_remove(uis, ui);
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
149 g_io_channel_close(ui->channel);
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
150 g_source_remove(ui->inpa);
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
151 g_free(ui);
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
152 break;
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
153 default:
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
154 debug_printf("unhandled meta subtype %d\n", subtype);
8306c042bac7 [gaim-migrate @ 2453]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2439
diff changeset
155 break;
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
156 }
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
157 }
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
158
2443
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
159 static void plugin_handler(struct UI *ui, guchar subtype, guchar *data)
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
160 {
2446
f9cad82d321b [gaim-migrate @ 2459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2443
diff changeset
161 #ifdef GAIM_PLUGINS
2443
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
162 guint id;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
163 struct gaim_plugin *p;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
164
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
165 switch (subtype) {
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
166 /*
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
167 case CUI_PLUGIN_LIST:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
168 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
169 */
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
170 case CUI_PLUGIN_LOAD:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
171 p = load_plugin(data);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
172 /* XXX need to broadcast to UIs that plugin has been loaded */
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
173 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
174 case CUI_PLUGIN_UNLOAD:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
175 memcpy(&id, data, sizeof(id));
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
176 p = g_list_nth_data(plugins, id);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
177 if (p) {
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
178 unload_plugin(p);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
179 /* XXX need to broadcast to UIs that plugin has been unloaded */
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
180 }
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
181 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
182 case CUI_PLUGIN_RELOAD:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
183 memcpy(&id, data, sizeof(id));
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
184 p = g_list_nth_data(plugins, id);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
185 if (p) {
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
186 p = reload_plugin(p);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
187 /* XXX need to broadcast to UIs that plugin has been reloaded */
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
188 }
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
189 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
190 default:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
191 debug_printf("unhandled plugin subtype %d\n", subtype);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
192 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
193 }
2446
f9cad82d321b [gaim-migrate @ 2459]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2443
diff changeset
194 #endif
2443
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
195 }
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
196
2441
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
197 static void user_handler(struct UI *ui, guchar subtype, guchar *data)
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
198 {
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
199 guint id;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
200 struct aim_user *u;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
201
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
202 switch (subtype) {
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
203 /*
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
204 case CUI_USER_LIST:
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
205 break;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
206 case CUI_USER_ADD:
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
207 break;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
208 case CUI_USER_REMOVE:
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
209 break;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
210 case CUI_USER_MODIFY:
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
211 break;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
212 */
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
213 case CUI_USER_SIGNON:
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
214 if (!data)
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
215 return;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
216 memcpy(&id, data, sizeof(id));
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
217 u = g_slist_nth_data(aim_users, id);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
218 if (u)
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
219 serv_login(u);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
220 /* don't need to do anything here because the UI will get updates from other handlers */
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
221 break;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
222 default:
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
223 debug_printf("unhandled user subtype %d\n", subtype);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
224 break;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
225 }
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
226 }
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
227
2443
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
228 static void message_handler(struct UI *ui, guchar subtype, guchar *data)
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
229 {
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
230 switch (subtype) {
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
231 case CUI_MESSAGE_LIST:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
232 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
233 case CUI_MESSAGE_SEND:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
234 if (!data)
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
235 return;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
236 {
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
237 guint id;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
238 struct gaim_connection *gc;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
239 guint len;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
240 char *who, *msg;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
241 gint flags;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
242 int pos = 0;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
243
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
244 memcpy(&id, data + pos, sizeof(id));
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
245 pos += sizeof(id);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
246 gc = g_slist_nth_data(connections, id);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
247 if (!gc)
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
248 return;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
249
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
250 memcpy(&len, data + pos, sizeof(len));
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
251 pos += sizeof(len);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
252 who = g_strndup(data + pos, len + 1);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
253 pos += len;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
254
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
255 memcpy(&len, data + pos, sizeof(len));
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
256 pos += sizeof(len);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
257 msg = g_strndup(data + pos, len + 1);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
258 pos += len;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
259
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
260 memcpy(&flags, data + pos, sizeof(flags));
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
261 serv_send_im(gc, who, msg, flags);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
262
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
263 g_free(who);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
264 g_free(msg);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
265 }
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
266 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
267 case CUI_MESSAGE_RECV:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
268 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
269 default:
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
270 debug_printf("unhandled message subtype %d\n", subtype);
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
271 break;
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
272 }
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
273 }
7f2432a87376 [gaim-migrate @ 2456]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2441
diff changeset
274
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2503
diff changeset
275 static gint gaim_recv(GIOChannel *source, guchar *buf, gint len)
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 gint total = 0;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 gint cur;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 while (total < len) {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 if (g_io_channel_read(source, buf + total, len - total, &cur) != G_IO_ERROR_NONE)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 return -1;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 if (cur == 0)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 return total;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 total += cur;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 return total;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 static gboolean UI_readable(GIOChannel *source, GIOCondition cond, gpointer data)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 struct UI *ui = data;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294
2438
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
295 guchar type;
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
296 guchar subtype;
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 guint32 len;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 guchar *in;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 /* no byte order worries! this'll change if we go to TCP */
2438
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
302 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) {
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 debug_printf("UI has abandoned us!\n");
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 uis = g_slist_remove(uis, ui);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 g_io_channel_close(ui->channel);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 g_source_remove(ui->inpa);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 g_free(ui);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 return FALSE;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310
2438
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
311 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) {
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
312 debug_printf("UI has abandoned us!\n");
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
313 uis = g_slist_remove(uis, ui);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
314 g_io_channel_close(ui->channel);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
315 g_source_remove(ui->inpa);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
316 g_free(ui);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
317 return FALSE;
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
318 }
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319
2541
8229710b343b [gaim-migrate @ 2554]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2503
diff changeset
320 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) {
2438
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
321 debug_printf("UI has abandoned us!\n");
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
322 uis = g_slist_remove(uis, ui);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
323 g_io_channel_close(ui->channel);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
324 g_source_remove(ui->inpa);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
325 g_free(ui);
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
326 return FALSE;
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
327 }
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
328
2441
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
329 if (len) {
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
330 in = g_new0(guchar, len);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
331 if (gaim_recv(source, in, len) != len) {
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
332 debug_printf("UI has abandoned us!\n");
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
333 uis = g_slist_remove(uis, ui);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
334 g_io_channel_close(ui->channel);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
335 g_source_remove(ui->inpa);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
336 g_free(ui);
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
337 return FALSE;
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
338 }
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
339 } else
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
340 in = NULL;
2438
5cbe86a444d9 [gaim-migrate @ 2451]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2435
diff changeset
341
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 switch (type) {
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
343 case CUI_TYPE_META:
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
344 meta_handler(ui, subtype, in);
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
345 break;
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 case CUI_TYPE_PLUGIN:
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
347 plugin_handler(ui, subtype, in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 break;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 case CUI_TYPE_USER:
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
350 user_handler(ui, subtype, in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 break;
2441
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
352 /*
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 case CUI_TYPE_CONN:
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
354 conn_handler(ui, subtype, in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 break;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 case CUI_TYPE_BUDDY:
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
357 buddy_handler(ui, subtype, in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 break;
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
359 */
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 case CUI_TYPE_MESSAGE:
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
361 message_handler(ui, subtype, in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 break;
2447
6bdeb91abe4e [gaim-migrate @ 2460]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2446
diff changeset
363 /*
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 case CUI_TYPE_CHAT:
2439
932adc1ac9ed [gaim-migrate @ 2452]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2438
diff changeset
365 chat_handler(ui, subtype, in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 break;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 */
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 default:
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 debug_printf("unhandled type %d\n", type);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 break;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372
2441
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
373 if (in)
2c2c1f717616 [gaim-migrate @ 2454]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2440
diff changeset
374 g_free(in);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 return TRUE;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 static gboolean socket_readable(GIOChannel *source, GIOCondition cond, gpointer data)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 struct sockaddr_un saddr;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 gint len;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 gint fd;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 struct UI *ui;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 if ((fd = accept(UI_fd, (struct sockaddr *)&saddr, &len)) == -1)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 return FALSE;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 ui = g_new0(struct UI, 1);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 uis = g_slist_append(uis, ui);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 ui->channel = g_io_channel_unix_new(fd);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 ui->inpa = g_io_add_watch(ui->channel, G_IO_IN | G_IO_HUP | G_IO_ERR, UI_readable, ui);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 g_io_channel_unref(ui->channel);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 debug_printf("got one\n");
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 return TRUE;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 static gint open_socket()
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 struct sockaddr_un saddr;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 gint fd;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) {
2503
b4ac3b5f484b [gaim-migrate @ 2516]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2482
diff changeset
406 mode_t m = umask(0177);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 saddr.sun_family = AF_UNIX;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 g_snprintf(saddr.sun_path, 108, "%s/gaim_%s.%d",
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 g_get_tmp_dir(), g_get_user_name(), getpid());
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 listen(fd, 100);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 else
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 g_log(NULL, G_LOG_LEVEL_CRITICAL,
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 "Failed to assign %s to a socket (Error: %s)",
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 saddr.sun_path, strerror(errno));
2503
b4ac3b5f484b [gaim-migrate @ 2516]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2482
diff changeset
416 umask(m);
2416
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 } else
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 g_log(NULL, G_LOG_LEVEL_CRITICAL, "Unable to open socket: %s", strerror(errno));
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 return fd;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 int core_main()
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 /*
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 GMainLoop *loop;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 */
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 GIOChannel *channel;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 UI_fd = open_socket();
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 if (UI_fd < 0)
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 return 1;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 channel = g_io_channel_unix_new(UI_fd);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 g_io_add_watch(channel, G_IO_IN, socket_readable, NULL);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 g_io_channel_unref(channel);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 /*
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 loop = g_main_new(TRUE);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 g_main_run(loop);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 */
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 return 0;
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 }
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 void core_quit()
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 {
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 char buf[1024];
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 close(UI_fd);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 sprintf(buf, "%s/gaim_%s.%d", g_get_tmp_dir(), g_get_user_name(), getpid());
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 unlink(buf);
61b816a7b467 [gaim-migrate @ 2429]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 }