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