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