Mercurial > pidgin
annotate plugins/gaim-remote/remote.c @ 6982:083d1e4a9c78
[gaim-migrate @ 7538]
This is Mr. Holland's Opus. And by Mr. Holland I mean Robot101. He
rewrote the coreish IM image support so that the binary data gets
ripped out in the prpl and put in an imgstore instead of just being
passed in the same huge as char string as the actual message. This
is good because it's prpl agnostic, or something. It also means
we don't have a silly length of "-1" with pretty much every send or
receive IM function.
It should be crash free, bug free, and memleak free, but additional
testing is always a good thing.
If you like good stuff then you'll love this patch. But don't take
my word for it--ba dun dunt!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 27 Sep 2003 19:17:21 +0000 |
parents | 8f94cce8faa5 |
children | abdc55ffadba |
rev | line source |
---|---|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6179
diff
changeset
|
1 /** |
5859 | 2 * Remote control plugin for Gaim |
3 * | |
4 * Copyright (C) 2003 Christian Hammond. | |
5 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
6 * | |
7 * This program is free software; you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation; either version 2 of the | |
10 * License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 * 02111-1307, USA. | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
21 * |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
22 * @todo Make this a core plugin! |
5859 | 23 */ |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
24 #include "internal.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6179
diff
changeset
|
25 #include "gtkinternal.h" |
5859 | 26 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
27 #ifndef _WIN32 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
28 # include <sys/un.h> |
5859 | 29 #endif |
30 | |
31 #include <signal.h> | |
32 #include <getopt.h> | |
33 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
34 #include "conversation.h" |
6179
16e384bb7fbf
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6177
diff
changeset
|
35 #include "core.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
36 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
37 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
38 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
39 /* XXX */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
40 #include "gtkconv.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
41 #include "gtkplugin.h" |
5859 | 42 #include "gaim.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
43 #include "ui.h" |
5859 | 44 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
45 #include <gaim-remote/remote.h> |
5859 | 46 |
5873
a18e88c4dace
[gaim-migrate @ 6305]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
47 #define REMOTE_PLUGIN_ID "gtk-remote" |
5859 | 48 |
49 struct UI { | |
50 GIOChannel *channel; | |
51 guint inpa; | |
52 }; | |
53 | |
54 #ifndef _WIN32 | |
55 static gint UI_fd = -1; | |
6107 | 56 static guint watcher = 0; |
5859 | 57 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
58 static int gaim_session = 0; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
59 static GSList *uis = NULL; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
60 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
61 /* AIM URI's ARE FUN :-D */ |
5884
d188b000e892
[gaim-migrate @ 6316]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
62 static const char * |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
63 gaim_remote_handle_uri(const char *uri) |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
64 { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
65 const char *username; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
66 GString *str; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
67 GList *conn; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
68 GaimConnection *gc = NULL; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
69 GaimAccount *account; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
70 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
71 gaim_debug(GAIM_DEBUG_INFO, "gaim_remote_handle_uri", "Handling URI: %s\n", uri); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
72 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
73 /* Well, we'd better check to make sure we have at least one |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
74 AIM account connected. */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
75 for (conn = gaim_connections_get_all(); conn != NULL; conn = conn->next) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
76 gc = conn->data; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
77 account = gaim_connection_get_account(gc); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
78 username = gaim_account_get_username(account); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
79 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
80 if (gaim_account_get_protocol(account) == GAIM_PROTO_OSCAR && |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
81 username != NULL && isalpha(*username)) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
82 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
83 break; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
84 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
85 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
86 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
87 if (gc == NULL) |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
88 return _("Not connected to AIM"); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
89 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
90 /* aim:goim?screenname=screenname&message=message */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
91 if (!g_ascii_strncasecmp(uri, "aim:goim?", strlen("aim:goim?"))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
92 char *who, *what; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
93 GaimConversation *c; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
94 uri = uri + strlen("aim:goim?"); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
95 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
96 if (!(who = strstr(uri, "screenname="))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
97 return _("No screenname given."); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
98 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
99 /* spaces are encoded as +'s */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
100 who = who + strlen("screenname="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
101 str = g_string_new(NULL); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
102 while (*who && (*who != '&')) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
103 g_string_append_c(str, *who == '+' ? ' ' : *who); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
104 who++; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
105 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
106 who = g_strdup(str->str); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
107 g_string_free(str, TRUE); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
108 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
109 what = strstr(uri, "message="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
110 if (what) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
111 what = what + strlen("message="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
112 str = g_string_new(NULL); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
113 while (*what && (*what != '&' || !g_ascii_strncasecmp(what, "&", 5))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
114 g_string_append_c(str, *what == '+' ? ' ' : *what); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
115 what++; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
116 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
117 what = g_strdup(str->str); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
118 g_string_free(str, TRUE); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
119 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
120 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
121 c = gaim_conversation_new(GAIM_CONV_IM, gc->account, who); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
122 g_free(who); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
123 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
124 if (what) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
125 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(c); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
126 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
127 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, what, -1); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
128 g_free(what); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
129 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
130 } else if (!g_ascii_strncasecmp(uri, "aim:addbuddy?", strlen("aim:addbuddy?"))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
131 char *who, *group; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
132 uri = uri + strlen("aim:addbuddy?"); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
133 /* spaces are encoded as +'s */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
134 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
135 if (!(who = strstr(uri, "screenname="))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
136 return _("No screenname given."); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
137 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
138 who = who + strlen("screenname="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
139 str = g_string_new(NULL); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
140 while (*who && (*who != '&')) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
141 g_string_append_c(str, *who == '+' ? ' ' : *who); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
142 who++; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
143 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
144 who = g_strdup(str->str); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
145 g_string_free(str, TRUE); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
146 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
147 group = strstr(uri, "group="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
148 if (group) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
149 group = group + strlen("group="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
150 str = g_string_new(NULL); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
151 while (*group && (*group != '&' || !g_ascii_strncasecmp(group, "&", 5))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
152 g_string_append_c(str, *group == '+' ? ' ' : *group); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
153 group++; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
154 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
155 group = g_strdup(str->str); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
156 g_string_free(str, TRUE); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
157 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
158 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
159 gaim_debug(GAIM_DEBUG_MISC, "gaim_remote_handle_uri", "who: %s\n", who); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
160 show_add_buddy(gc, who, group, NULL); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
161 g_free(who); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
162 if (group) |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
163 g_free(group); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
164 } else if (!g_ascii_strncasecmp(uri, "aim:gochat?", strlen("aim:gochat?"))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
165 char *room; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
166 GHashTable *components; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
167 int exch = 5; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
168 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
169 uri = uri + strlen("aim:gochat?"); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
170 /* spaces are encoded as +'s */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
171 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
172 if (!(room = strstr(uri, "roomname="))) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
173 return _("No roomname given."); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
174 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
175 room = room + strlen("roomname="); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
176 str = g_string_new(NULL); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
177 while (*room && (*room != '&')) { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
178 g_string_append_c(str, *room == '+' ? ' ' : *room); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
179 room++; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
180 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
181 room = g_strdup(str->str); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
182 g_string_free(str, TRUE); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
183 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
184 g_free); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
185 g_hash_table_replace(components, g_strdup("room"), room); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
186 g_hash_table_replace(components, g_strdup("exchange"), |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
187 g_strdup_printf("%d", exch)); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
188 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
189 serv_join_chat(gc, components); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
190 g_hash_table_destroy(components); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
191 } else { |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
192 return _("Invalid AIM URI"); |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
193 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
194 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
195 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
196 return NULL; |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
197 } |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
198 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
199 |
5859 | 200 |
201 #if 0 | |
202 static guchar * | |
203 UI_build(guint32 *len, guchar type, guchar subtype, va_list args) | |
204 { | |
205 guchar *buffer; | |
206 guint32 pos; | |
207 int size; | |
208 void *data; | |
209 | |
210 *len = sizeof(guchar) * 2 + 4; | |
211 buffer = g_malloc(*len); | |
212 pos = 0; | |
213 | |
214 memcpy(buffer + pos, &type, sizeof(type)); pos += sizeof(type); | |
215 memcpy(buffer + pos, &subtype, sizeof(subtype)); pos += sizeof(subtype); | |
216 | |
217 /* we come back and do size last */ | |
218 pos += 4; | |
219 | |
220 size = va_arg(args, int); | |
221 while (size != -1) { | |
222 *len += size; | |
223 buffer = g_realloc(buffer, *len); | |
224 | |
225 data = va_arg(args, void *); | |
226 memcpy(buffer + pos, data, size); | |
227 pos += size; | |
228 | |
229 size = va_arg(args, int); | |
230 } | |
231 | |
232 pos -= sizeof(guchar) * 2 + 4; | |
233 | |
234 /* now we do size */ | |
235 memcpy(buffer + sizeof(guchar) * 2, &pos, 4); | |
236 | |
237 return buffer; | |
238 } | |
239 | |
240 static gint | |
241 UI_write(struct UI *ui, guchar *data, gint len) | |
242 { | |
243 GError *error = NULL; | |
244 gint sent; | |
245 /* we'll let the write silently fail because the read will pick it up as dead */ | |
246 g_io_channel_write_chars(ui->channel, data, len, &sent, &error); | |
247 if (error) | |
248 g_error_free(error); | |
249 return sent; | |
250 } | |
251 | |
252 static void | |
253 UI_build_write(struct UI *ui, guchar type, guchar subtype, ...) | |
254 { | |
255 va_list ap; | |
256 gchar *data; | |
257 guint32 len; | |
258 | |
259 va_start(ap, subtype); | |
260 data = UI_build(&len, type, subtype, ap); | |
261 va_end(ap); | |
262 | |
263 UI_write(ui, data, len); | |
264 | |
265 g_free(data); | |
266 } | |
267 | |
268 static void | |
269 UI_broadcast(guchar *data, gint len) | |
270 { | |
271 GSList *u = uis; | |
272 while (u) { | |
273 struct UI *ui = u->data; | |
274 UI_write(ui, data, len); | |
275 u = u->next; | |
276 } | |
277 } | |
278 | |
279 static void | |
280 UI_build_broadcast(guchar type, guchar subtype, ...) | |
281 { | |
282 va_list ap; | |
283 gchar *data; | |
284 guint32 len; | |
285 | |
286 if (!uis) | |
287 return; | |
288 | |
289 va_start(ap, subtype); | |
290 data = UI_build(&len, type, subtype, ap); | |
291 va_end(ap); | |
292 | |
293 UI_broadcast(data, len); | |
294 | |
295 g_free(data); | |
296 } | |
297 #endif | |
298 | |
299 #ifndef _WIN32 | |
300 static void | |
6063 | 301 meta_handler(struct UI *ui, guchar subtype, gchar *data) |
5859 | 302 { |
303 GaimRemotePacket *p; | |
304 GError *error = NULL; | |
305 switch (subtype) { | |
306 case CUI_META_LIST: | |
307 break; | |
308 case CUI_META_QUIT: | |
309 while (uis) { | |
310 ui = uis->data; | |
311 uis = g_slist_remove(uis, ui); | |
312 g_io_channel_shutdown(ui->channel, TRUE, &error); | |
313 g_source_remove(ui->inpa); | |
314 g_free(ui); | |
315 } | |
6179
16e384bb7fbf
[gaim-migrate @ 6664]
Christian Hammond <chipx86@chipx86.com>
parents:
6177
diff
changeset
|
316 gaim_core_quit(); |
5859 | 317 break; |
318 case CUI_META_DETACH: | |
319 uis = g_slist_remove(uis, ui); | |
320 g_io_channel_shutdown(ui->channel, TRUE, &error); | |
321 g_source_remove(ui->inpa); | |
322 g_free(ui); | |
323 break; | |
324 case CUI_META_PING: | |
325 p = gaim_remote_packet_new(CUI_TYPE_META, CUI_META_ACK); | |
326 gaim_remote_session_send_packet(g_io_channel_unix_get_fd(ui->channel), | |
327 p); | |
328 gaim_remote_packet_free(p); | |
329 break; | |
330 default: | |
331 gaim_debug(GAIM_DEBUG_WARNING, "cui", | |
332 "Unhandled meta subtype %d\n", subtype); | |
333 break; | |
334 } | |
335 | |
336 if(error) | |
337 g_error_free(error); | |
338 } | |
339 | |
340 static void | |
6063 | 341 plugin_handler(struct UI *ui, guchar subtype, gpointer data) |
5859 | 342 { |
343 #ifdef GAIM_PLUGINS | |
344 guint id; | |
345 GaimPlugin *p; | |
346 | |
347 switch (subtype) { | |
348 /* | |
349 case CUI_PLUGIN_LIST: | |
350 break; | |
351 */ | |
352 case CUI_PLUGIN_LOAD: | |
353 gaim_plugin_load(gaim_plugin_probe(data)); | |
354 break; | |
355 case CUI_PLUGIN_UNLOAD: | |
356 memcpy(&id, data, sizeof(id)); | |
357 p = g_list_nth_data(gaim_plugins_get_loaded(), id); | |
358 if (p) { | |
359 gaim_plugin_unload(p); | |
360 } | |
361 break; | |
362 default: | |
363 gaim_debug(GAIM_DEBUG_WARNING, "cui", | |
364 "Unhandled plugin subtype %d\n", subtype); | |
365 break; | |
366 } | |
367 #endif | |
368 } | |
369 | |
370 static void | |
6063 | 371 user_handler(struct UI *ui, guchar subtype, gchar *data) |
5859 | 372 { |
373 guint id; | |
374 GaimAccount *account; | |
375 | |
376 switch (subtype) { | |
377 /* | |
378 case CUI_USER_LIST: | |
379 break; | |
380 case CUI_USER_ADD: | |
381 break; | |
382 case CUI_USER_REMOVE: | |
383 break; | |
384 case CUI_USER_MODIFY: | |
385 break; | |
386 */ | |
387 case CUI_USER_SIGNON: | |
388 if (!data) | |
389 return; | |
390 memcpy(&id, data, sizeof(id)); | |
391 account = g_list_nth_data(gaim_accounts_get_all(), id); | |
392 if (account) | |
6036 | 393 gaim_account_connect(account); |
5859 | 394 /* don't need to do anything here because the UI will get updates from other handlers */ |
395 break; | |
396 default: | |
397 gaim_debug(GAIM_DEBUG_WARNING, "cui", | |
398 "Unhandled user subtype %d\n", subtype); | |
399 break; | |
400 } | |
401 } | |
402 | |
403 static void | |
6063 | 404 message_handler(struct UI *ui, guchar subtype, gchar *data) |
5859 | 405 { |
406 switch (subtype) { | |
407 case CUI_MESSAGE_LIST: | |
408 break; | |
409 case CUI_MESSAGE_SEND: | |
410 if (!data) | |
411 return; | |
412 { | |
413 guint id; | |
414 GaimConnection *gc; | |
415 guint len; | |
416 char *who, *msg; | |
417 gint flags; | |
418 int pos = 0; | |
419 | |
420 memcpy(&id, data + pos, sizeof(id)); | |
421 pos += sizeof(id); | |
422 gc = g_list_nth_data(gaim_connections_get_all(), id); | |
423 if (!gc) | |
424 return; | |
425 | |
426 memcpy(&len, data + pos, sizeof(len)); | |
427 pos += sizeof(len); | |
428 who = g_strndup(data + pos, len + 1); | |
429 pos += len; | |
430 | |
431 memcpy(&len, data + pos, sizeof(len)); | |
432 pos += sizeof(len); | |
433 msg = g_strndup(data + pos, len + 1); | |
434 pos += len; | |
435 | |
436 memcpy(&flags, data + pos, sizeof(flags)); | |
6982 | 437 serv_send_im(gc, who, msg, flags); |
5859 | 438 |
439 g_free(who); | |
440 g_free(msg); | |
441 } | |
442 break; | |
443 case CUI_MESSAGE_RECV: | |
444 break; | |
445 default: | |
446 gaim_debug(GAIM_DEBUG_WARNING, "cui", | |
447 "Unhandled message subtype %d\n", subtype); | |
448 break; | |
449 } | |
450 } | |
451 | |
452 static gint | |
6063 | 453 gaim_recv(GIOChannel *source, gchar *buf, gint len) |
5859 | 454 { |
455 gint total = 0; | |
6063 | 456 guint cur; |
5859 | 457 |
458 GError *error = NULL; | |
459 | |
460 while (total < len) { | |
461 if (g_io_channel_read_chars(source, buf + total, len - total, &cur, &error) != G_IO_STATUS_NORMAL) { | |
462 if (error) | |
463 g_error_free(error); | |
464 return -1; | |
465 } | |
466 if (cur == 0) | |
467 return total; | |
468 total += cur; | |
469 } | |
470 | |
471 return total; | |
472 } | |
473 | |
474 static void | |
6063 | 475 remote_handler(struct UI *ui, guchar subtype, gchar *data, int len) |
5859 | 476 { |
477 const char *resp; | |
478 char *send; | |
479 switch (subtype) { | |
480 case CUI_REMOTE_CONNECTIONS: | |
481 break; | |
482 case CUI_REMOTE_URI: | |
483 send = g_malloc(len + 1); | |
484 memcpy(send, data, len); | |
485 send[len] = 0; | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
486 resp = gaim_remote_handle_uri(send); |
5859 | 487 g_free(send); |
488 /* report error */ | |
489 break; | |
490 default: | |
491 gaim_debug(GAIM_DEBUG_WARNING, "cui", | |
492 "Unhandled remote subtype %d\n", subtype); | |
493 break; | |
494 } | |
495 } | |
496 | |
497 static gboolean | |
498 UI_readable(GIOChannel *source, GIOCondition cond, gpointer data) | |
499 { | |
500 struct UI *ui = data; | |
501 | |
6063 | 502 gchar type; |
503 gchar subtype; | |
5859 | 504 guint32 len; |
505 | |
506 GError *error = NULL; | |
507 | |
6063 | 508 gchar *in; |
5859 | 509 |
510 /* no byte order worries! this'll change if we go to TCP */ | |
511 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { | |
512 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); | |
513 uis = g_slist_remove(uis, ui); | |
514 g_io_channel_shutdown(ui->channel, TRUE, &error); | |
515 if(error) { | |
516 g_error_free(error); | |
517 error = NULL; | |
518 } | |
519 g_source_remove(ui->inpa); | |
520 g_free(ui); | |
521 return FALSE; | |
522 } | |
523 | |
524 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { | |
525 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); | |
526 uis = g_slist_remove(uis, ui); | |
527 g_io_channel_shutdown(ui->channel, TRUE, &error); | |
528 if(error) { | |
529 g_error_free(error); | |
530 error = NULL; | |
531 } | |
532 g_source_remove(ui->inpa); | |
533 g_free(ui); | |
534 return FALSE; | |
535 } | |
536 | |
6063 | 537 if (gaim_recv(source, (gchar *)&len, sizeof(len)) != sizeof(len)) { |
5859 | 538 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); |
539 uis = g_slist_remove(uis, ui); | |
540 g_io_channel_shutdown(ui->channel, TRUE, &error); | |
541 if(error) { | |
542 g_error_free(error); | |
543 error = NULL; | |
544 } | |
545 g_source_remove(ui->inpa); | |
546 g_free(ui); | |
547 return FALSE; | |
548 } | |
549 | |
550 if (len) { | |
6063 | 551 in = g_new0(gchar, len); |
5859 | 552 if (gaim_recv(source, in, len) != len) { |
553 gaim_debug(GAIM_DEBUG_ERROR, "cui", "UI has abandoned us!\n"); | |
554 uis = g_slist_remove(uis, ui); | |
555 g_io_channel_shutdown(ui->channel, TRUE, &error); | |
556 if(error) { | |
557 g_error_free(error); | |
558 error = NULL; | |
559 } | |
560 g_source_remove(ui->inpa); | |
561 g_free(ui); | |
562 return FALSE; | |
563 } | |
564 } else | |
565 in = NULL; | |
566 | |
567 switch (type) { | |
568 case CUI_TYPE_META: | |
569 meta_handler(ui, subtype, in); | |
570 break; | |
571 case CUI_TYPE_PLUGIN: | |
572 plugin_handler(ui, subtype, in); | |
573 break; | |
574 case CUI_TYPE_USER: | |
575 user_handler(ui, subtype, in); | |
576 break; | |
577 /* | |
578 case CUI_TYPE_CONN: | |
579 conn_handler(ui, subtype, in); | |
580 break; | |
581 case CUI_TYPE_BUDDY: | |
582 buddy_handler(ui, subtype, in); | |
583 break; | |
584 */ | |
585 case CUI_TYPE_MESSAGE: | |
586 message_handler(ui, subtype, in); | |
587 break; | |
588 /* | |
589 case CUI_TYPE_CHAT: | |
590 chat_handler(ui, subtype, in); | |
591 break; | |
592 */ | |
593 case CUI_TYPE_REMOTE: | |
594 remote_handler(ui, subtype, in, len); | |
595 break; | |
596 default: | |
597 gaim_debug(GAIM_DEBUG_WARNING, "cui", | |
598 "Unhandled type %d\n", type); | |
599 break; | |
600 } | |
601 | |
602 if (in) | |
603 g_free(in); | |
604 return TRUE; | |
605 } | |
606 | |
607 static gboolean | |
608 socket_readable(GIOChannel *source, GIOCondition cond, gpointer data) | |
609 { | |
610 struct sockaddr_un saddr; | |
6063 | 611 guint len = sizeof(saddr); |
5859 | 612 gint fd; |
613 | |
614 struct UI *ui; | |
615 | |
616 if ((fd = accept(UI_fd, (struct sockaddr *)&saddr, &len)) == -1) | |
617 return FALSE; | |
618 | |
619 ui = g_new0(struct UI, 1); | |
620 uis = g_slist_append(uis, ui); | |
621 | |
622 ui->channel = g_io_channel_unix_new(fd); | |
623 ui->inpa = g_io_add_watch(ui->channel, G_IO_IN | G_IO_HUP | G_IO_ERR, UI_readable, ui); | |
624 g_io_channel_unref(ui->channel); | |
625 | |
626 gaim_debug(GAIM_DEBUG_MISC, "cui", "Got one\n"); | |
627 return TRUE; | |
628 } | |
629 | |
630 static gint | |
631 open_socket() | |
632 { | |
633 struct sockaddr_un saddr; | |
634 gint fd; | |
635 | |
636 while (gaim_remote_session_exists(gaim_session)) | |
637 gaim_session++; | |
638 | |
639 gaim_debug(GAIM_DEBUG_MISC, "cui", "Session: %d\n", gaim_session); | |
640 | |
641 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { | |
642 mode_t m = umask(0177); | |
643 saddr.sun_family = AF_UNIX; | |
644 | |
645 g_snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", | |
646 g_get_tmp_dir(), g_get_user_name(), gaim_session); | |
647 if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) != -1) | |
648 listen(fd, 100); | |
649 else { | |
650 g_log(NULL, G_LOG_LEVEL_CRITICAL, | |
651 "Failed to assign %s to a socket (Error: %s)", | |
652 saddr.sun_path, strerror(errno)); | |
653 return -1; | |
654 } | |
655 umask(m); | |
656 } else | |
657 g_log(NULL, G_LOG_LEVEL_CRITICAL, "Unable to open socket: %s", strerror(errno)); | |
658 return fd; | |
659 } | |
660 #endif /*! _WIN32*/ | |
661 | |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
662 static gboolean |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
663 plugin_load(GaimPlugin *plugin) |
5859 | 664 { |
665 #ifndef _WIN32 | |
666 GIOChannel *channel; | |
667 | |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
668 if ((UI_fd = open_socket()) < 0) |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
669 return FALSE; |
5859 | 670 |
671 channel = g_io_channel_unix_new(UI_fd); | |
6107 | 672 watcher = g_io_add_watch(channel, G_IO_IN, socket_readable, NULL); |
5859 | 673 g_io_channel_unref(channel); |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
674 |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
675 return TRUE; |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
676 #else |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
677 return FALSE; |
5859 | 678 #endif |
679 } | |
680 | |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
681 static gboolean |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
682 plugin_unload(GaimPlugin *plugin) |
5859 | 683 { |
684 /* don't save prefs after plugins are gone... */ | |
685 #ifndef _WIN32 | |
686 char buf[1024]; | |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
687 |
6107 | 688 g_source_remove(watcher); |
5859 | 689 close(UI_fd); |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
690 |
6063 | 691 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", |
5859 | 692 g_get_tmp_dir(), g_get_user_name(), gaim_session); |
693 | |
694 unlink(buf); | |
695 | |
696 gaim_debug(GAIM_DEBUG_MISC, "core", "Removed core\n"); | |
5954 | 697 |
698 return TRUE; | |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
699 #else |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
700 return FALSE; |
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
701 #endif |
5859 | 702 } |
703 | |
704 static GaimPluginInfo info = | |
705 { | |
706 2, /**< api_version */ | |
707 GAIM_PLUGIN_STANDARD, /**< type */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5859
diff
changeset
|
708 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */ |
5859 | 709 0, /**< flags */ |
710 NULL, /**< dependencies */ | |
711 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
712 | |
713 REMOTE_PLUGIN_ID, /**< id */ | |
714 N_("Remote Control"), /**< name */ | |
715 VERSION, /**< version */ | |
716 /** summary */ | |
717 N_("Provides remote control for gaim applications."), | |
718 /** description */ | |
719 N_("Gives Gaim the ability to be remote-controlled through third-party " | |
720 "applications or through the gaim-remote tool."), | |
721 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6179
diff
changeset
|
722 GAIM_WEBSITE, /**< homepage */ |
5859 | 723 |
724 plugin_load, /**< load */ | |
725 plugin_unload, /**< unload */ | |
726 NULL, /**< destroy */ | |
727 | |
728 NULL, /**< ui_info */ | |
729 NULL /**< extra_info */ | |
730 }; | |
731 | |
732 static void | |
733 __init_plugin(GaimPlugin *plugin) | |
734 { | |
735 } | |
736 | |
6177
73f8f5c0e348
[gaim-migrate @ 6662]
Christian Hammond <chipx86@chipx86.com>
parents:
6107
diff
changeset
|
737 /* This may be horribly wrong. Oh the mayhem! */ |
6063 | 738 GAIM_INIT_PLUGIN(remote, __init_plugin, info) |