| 71 protocol_id = purple_account_get_protocol_id(account); |
71 protocol_id = purple_account_get_protocol_id(account); |
| 72 |
72 |
| 73 purple_debug_misc("raw", "protocol_id = %s\n", protocol_id); |
73 purple_debug_misc("raw", "protocol_id = %s\n", protocol_id); |
| 74 |
74 |
| 75 if (strcmp(protocol_id, "toc") == 0) { |
75 if (strcmp(protocol_id, "toc") == 0) { |
| 76 int *a = (int *)gc->proto_data; |
76 int *a = (int *)purple_connection_get_protocol_data(gc); |
| 77 unsigned short seqno = htons(a[1]++ & 0xffff); |
77 unsigned short seqno = htons(a[1]++ & 0xffff); |
| 78 unsigned short len = htons(strlen(txt) + 1); |
78 unsigned short len = htons(strlen(txt) + 1); |
| 79 write(*a, "*\002", 2); |
79 write(*a, "*\002", 2); |
| 80 write(*a, &seqno, 2); |
80 write(*a, &seqno, 2); |
| 81 write(*a, &len, 2); |
81 write(*a, &len, 2); |
| 82 write(*a, txt, ntohs(len)); |
82 write(*a, txt, ntohs(len)); |
| 83 purple_debug(PURPLE_DEBUG_MISC, "raw", "TOC C: %s\n", txt); |
83 purple_debug(PURPLE_DEBUG_MISC, "raw", "TOC C: %s\n", txt); |
| 84 |
84 |
| 85 } else if (strcmp(protocol_id, "msn") == 0) { |
85 } else if (strcmp(protocol_id, "msn") == 0) { |
| 86 MsnSession *session = gc->proto_data; |
86 MsnSession *session = purple_connection_get_protocol_data(gc); |
| 87 char buf[strlen(txt) + 3]; |
87 char buf[strlen(txt) + 3]; |
| 88 |
88 |
| 89 g_snprintf(buf, sizeof(buf), "%s\r\n", txt); |
89 g_snprintf(buf, sizeof(buf), "%s\r\n", txt); |
| 90 msn_servconn_write(session->notification->servconn, buf, strlen(buf)); |
90 msn_servconn_write(session->notification->servconn, buf, strlen(buf)); |
| 91 |
91 |
| 92 } else if (strcmp(protocol_id, "irc") == 0) { |
92 } else if (strcmp(protocol_id, "irc") == 0) { |
| 93 write(*(int *)gc->proto_data, txt, strlen(txt)); |
93 write(*(int *)purple_connection_get_protocol_data(gc), txt, strlen(txt)); |
| 94 write(*(int *)gc->proto_data, "\r\n", 2); |
94 write(*(int *)purple_connection_get_protocol_data(gc), "\r\n", 2); |
| 95 purple_debug(PURPLE_DEBUG_MISC, "raw", "IRC C: %s\n", txt); |
95 purple_debug(PURPLE_DEBUG_MISC, "raw", "IRC C: %s\n", txt); |
| 96 |
96 |
| 97 } else if (strcmp(protocol_id, "jabber") == 0) { |
97 } else if (strcmp(protocol_id, "jabber") == 0) { |
| 98 jabber_send_raw((JabberStream *)gc->proto_data, txt, -1); |
98 jabber_send_raw((JabberStream *)purple_connection_get_protocol_data(gc), txt, -1); |
| 99 |
99 |
| 100 } else { |
100 } else { |
| 101 purple_debug_error("raw", "Unknown protocol ID %s\n", protocol_id); |
101 purple_debug_error("raw", "Unknown protocol ID %s\n", protocol_id); |
| 102 } |
102 } |
| 103 |
103 |
| 109 void *user_data) |
109 void *user_data) |
| 110 { |
110 { |
| 111 account = new_account; |
111 account = new_account; |
| 112 } |
112 } |
| 113 |
113 |
| |
114 static PidginPluginInfo * |
| |
115 plugin_query(GError **error) |
| |
116 { |
| |
117 const gchar * const authors[] = { |
| |
118 "Eric Warmenhoven <eric@warmenhoven.org>", |
| |
119 NULL |
| |
120 }; |
| |
121 |
| |
122 return pidgin_plugin_info_new( |
| |
123 "id", RAW_PLUGIN_ID, |
| |
124 "name", N_("Raw"), |
| |
125 "version", DISPLAY_VERSION, |
| |
126 "category", N_("Protocol utility"), |
| |
127 "summary", N_("Lets you send raw input to text-based protocols."), |
| |
128 "description", N_("Lets you send raw input to text-based protocols " |
| |
129 "(XMPP, MSN, IRC, TOC). Hit 'Enter' in the entry " |
| |
130 "box to send. Watch the debug window."), |
| |
131 "authors", authors, |
| |
132 "website", PURPLE_WEBSITE, |
| |
133 "abi-version", PURPLE_ABI_VERSION, |
| |
134 NULL |
| |
135 ); |
| |
136 } |
| |
137 |
| 114 static gboolean |
138 static gboolean |
| 115 plugin_load(PurplePlugin *plugin) |
139 plugin_load(PurplePlugin *plugin, GError **error) |
| 116 { |
140 { |
| 117 GtkWidget *hbox; |
141 GtkWidget *hbox; |
| 118 GtkWidget *entry; |
142 GtkWidget *entry; |
| 119 GtkWidget *dropdown; |
143 GtkWidget *dropdown; |
| |
144 |
| |
145 my_plugin = plugin; |
| 120 |
146 |
| 121 /* Setup the window. */ |
147 /* Setup the window. */ |
| 122 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
148 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 123 gtk_container_set_border_width(GTK_CONTAINER(window), 6); |
149 gtk_container_set_border_width(GTK_CONTAINER(window), 6); |
| 124 |
150 |
| 149 |
175 |
| 150 return TRUE; |
176 return TRUE; |
| 151 } |
177 } |
| 152 |
178 |
| 153 static gboolean |
179 static gboolean |
| 154 plugin_unload(PurplePlugin *plugin) |
180 plugin_unload(PurplePlugin *plugin, GError **error) |
| 155 { |
181 { |
| 156 if (window) |
182 if (window) |
| 157 gtk_widget_destroy(window); |
183 gtk_widget_destroy(window); |
| 158 |
184 |
| 159 window = NULL; |
185 window = NULL; |
| |
186 my_plugin = NULL; |
| 160 |
187 |
| 161 return TRUE; |
188 return TRUE; |
| 162 } |
189 } |
| 163 |
190 |
| 164 static PurplePluginInfo info = |
191 PURPLE_PLUGIN_INIT(raw, plugin_query, plugin_load, plugin_unload); |
| 165 { |
|
| 166 PURPLE_PLUGIN_MAGIC, |
|
| 167 PURPLE_MAJOR_VERSION, |
|
| 168 PURPLE_MINOR_VERSION, |
|
| 169 PURPLE_PLUGIN_STANDARD, |
|
| 170 PIDGIN_PLUGIN_TYPE, |
|
| 171 0, |
|
| 172 NULL, |
|
| 173 PURPLE_PRIORITY_DEFAULT, |
|
| 174 RAW_PLUGIN_ID, |
|
| 175 N_("Raw"), |
|
| 176 DISPLAY_VERSION, |
|
| 177 N_("Lets you send raw input to text-based protocols."), |
|
| 178 N_("Lets you send raw input to text-based protocols (XMPP, MSN, IRC, " |
|
| 179 "TOC). Hit 'Enter' in the entry box to send. Watch the debug window."), |
|
| 180 "Eric Warmenhoven <eric@warmenhoven.org>", |
|
| 181 PURPLE_WEBSITE, |
|
| 182 plugin_load, |
|
| 183 plugin_unload, |
|
| 184 NULL, |
|
| 185 NULL, |
|
| 186 NULL, |
|
| 187 NULL, |
|
| 188 NULL |
|
| 189 }; |
|
| 190 |
|
| 191 static void |
|
| 192 init_plugin(PurplePlugin *plugin) |
|
| 193 { |
|
| 194 my_plugin = plugin; |
|
| 195 } |
|
| 196 |
|
| 197 PURPLE_INIT_PLUGIN(raw, init_plugin, info) |
|