| 43 char filename[256]; |
43 char filename[256]; |
| 44 char buffer[1024]; |
44 char buffer[1024]; |
| 45 char *command, *arg1, *arg2; |
45 char *command, *arg1, *arg2; |
| 46 FILE *file; |
46 FILE *file; |
| 47 |
47 |
| 48 sprintf(filename, "%s" G_DIR_SEPARATOR_S "control", gaim_user_dir()); |
48 sprintf(filename, "%s" G_DIR_SEPARATOR_S "control", purple_user_dir()); |
| 49 |
49 |
| 50 file = g_fopen(filename, "r+"); |
50 file = g_fopen(filename, "r+"); |
| 51 while (fgets(buffer, sizeof(buffer), file)) { |
51 while (fgets(buffer, sizeof(buffer), file)) { |
| 52 |
52 |
| 53 /* Read the next command */ |
53 /* Read the next command */ |
| 54 if (buffer[strlen(buffer) - 1] == '\n') |
54 if (buffer[strlen(buffer) - 1] == '\n') |
| 55 buffer[strlen(buffer) - 1] = 0; |
55 buffer[strlen(buffer) - 1] = 0; |
| 56 gaim_debug_misc("filectl", "read: %s\n", buffer); |
56 purple_debug_misc("filectl", "read: %s\n", buffer); |
| 57 command = getarg(buffer, 0, 0); |
57 command = getarg(buffer, 0, 0); |
| 58 |
58 |
| 59 if (!strncasecmp(command, "login", 6)) { |
59 if (!strncasecmp(command, "login", 6)) { |
| 60 GaimAccount *account; |
60 PurpleAccount *account; |
| 61 |
61 |
| 62 arg1 = getarg(buffer, 1, 0); |
62 arg1 = getarg(buffer, 1, 0); |
| 63 arg2 = getarg(buffer, 2, 1); |
63 arg2 = getarg(buffer, 2, 1); |
| 64 |
64 |
| 65 account = gaim_accounts_find(arg1, arg2); |
65 account = purple_accounts_find(arg1, arg2); |
| 66 if (account != NULL) /* username found */ |
66 if (account != NULL) /* username found */ |
| 67 gaim_account_connect(account); |
67 purple_account_connect(account); |
| 68 |
68 |
| 69 free(arg1); |
69 free(arg1); |
| 70 free(arg2); |
70 free(arg2); |
| 71 |
71 |
| 72 } else if (!strncasecmp(command, "logout", 7)) { |
72 } else if (!strncasecmp(command, "logout", 7)) { |
| 73 GaimAccount *account; |
73 PurpleAccount *account; |
| 74 |
74 |
| 75 arg1 = getarg(buffer, 1, 1); |
75 arg1 = getarg(buffer, 1, 1); |
| 76 arg2 = getarg(buffer, 2, 1); |
76 arg2 = getarg(buffer, 2, 1); |
| 77 |
77 |
| 78 account = gaim_accounts_find(arg1, arg2); |
78 account = purple_accounts_find(arg1, arg2); |
| 79 if (account != NULL) |
79 if (account != NULL) |
| 80 { |
80 { |
| 81 gaim_account_disconnect(account); |
81 purple_account_disconnect(account); |
| 82 } |
82 } |
| 83 else if (arg1 == NULL) |
83 else if (arg1 == NULL) |
| 84 gaim_connections_disconnect_all(); |
84 purple_connections_disconnect_all(); |
| 85 |
85 |
| 86 free(arg1); |
86 free(arg1); |
| 87 free(arg2); |
87 free(arg2); |
| 88 |
88 |
| 89 /* gaim_find_conversation() is gone in 2.0.0. */ |
89 /* purple_find_conversation() is gone in 2.0.0. */ |
| 90 #if 0 |
90 #if 0 |
| 91 } else if (!strncasecmp(command, "send", 4)) { |
91 } else if (!strncasecmp(command, "send", 4)) { |
| 92 GaimConversation *conv; |
92 PurpleConversation *conv; |
| 93 |
93 |
| 94 arg1 = getarg(buffer, 1, 0); |
94 arg1 = getarg(buffer, 1, 0); |
| 95 arg2 = getarg(buffer, 2, 1); |
95 arg2 = getarg(buffer, 2, 1); |
| 96 |
96 |
| 97 conv = gaim_find_conversation(GAIM_CONV_TYPE_ANY, arg1); |
97 conv = purple_find_conversation(PURPLE_CONV_TYPE_ANY, arg1); |
| 98 if (conv != NULL) |
98 if (conv != NULL) |
| 99 { |
99 { |
| 100 /* |
100 /* |
| 101 gaim_conversation_write(conv, arg2, WFLAG_SEND, NULL, time(NULL), -1); |
101 purple_conversation_write(conv, arg2, WFLAG_SEND, NULL, time(NULL), -1); |
| 102 serv_send_im(conv->gc, arg1, arg2, 0); |
102 serv_send_im(conv->gc, arg1, arg2, 0); |
| 103 */ |
103 */ |
| 104 } |
104 } |
| 105 |
105 |
| 106 free(arg1); |
106 free(arg1); |
| 111 arg1 = getarg(buffer, 1, 1); |
111 arg1 = getarg(buffer, 1, 1); |
| 112 /* serv_set_away_all(arg1); */ |
112 /* serv_set_away_all(arg1); */ |
| 113 free(arg1); |
113 free(arg1); |
| 114 |
114 |
| 115 } else if (!strncasecmp(command, "hide", 4)) { |
115 } else if (!strncasecmp(command, "hide", 4)) { |
| 116 gaim_blist_set_visible(FALSE); |
116 purple_blist_set_visible(FALSE); |
| 117 |
117 |
| 118 } else if (!strncasecmp(command, "unhide", 6)) { |
118 } else if (!strncasecmp(command, "unhide", 6)) { |
| 119 gaim_blist_set_visible(TRUE); |
119 purple_blist_set_visible(TRUE); |
| 120 |
120 |
| 121 } else if (!strncasecmp(command, "back", 4)) { |
121 } else if (!strncasecmp(command, "back", 4)) { |
| 122 /* do_im_back(); */ |
122 /* do_im_back(); */ |
| 123 |
123 |
| 124 } else if (!strncasecmp(command, "quit", 4)) { |
124 } else if (!strncasecmp(command, "quit", 4)) { |
| 125 gaim_core_quit(); |
125 purple_core_quit(); |
| 126 |
126 |
| 127 } |
127 } |
| 128 |
128 |
| 129 free(command); |
129 free(command); |
| 130 } |
130 } |
| 215 /* |
215 /* |
| 216 * EXPORTED FUNCTIONS |
216 * EXPORTED FUNCTIONS |
| 217 */ |
217 */ |
| 218 |
218 |
| 219 static gboolean |
219 static gboolean |
| 220 plugin_load(GaimPlugin *plugin) |
220 plugin_load(PurplePlugin *plugin) |
| 221 { |
221 { |
| 222 init_file(); |
222 init_file(); |
| 223 check = gaim_timeout_add(5000, (GSourceFunc)check_file, NULL); |
223 check = purple_timeout_add(5000, (GSourceFunc)check_file, NULL); |
| 224 |
224 |
| 225 return TRUE; |
225 return TRUE; |
| 226 } |
226 } |
| 227 |
227 |
| 228 static gboolean |
228 static gboolean |
| 229 plugin_unload(GaimPlugin *plugin) |
229 plugin_unload(PurplePlugin *plugin) |
| 230 { |
230 { |
| 231 gaim_timeout_remove(check); |
231 purple_timeout_remove(check); |
| 232 |
232 |
| 233 return TRUE; |
233 return TRUE; |
| 234 } |
234 } |
| 235 |
235 |
| 236 static GaimPluginInfo info = |
236 static PurplePluginInfo info = |
| 237 { |
237 { |
| 238 GAIM_PLUGIN_MAGIC, |
238 PURPLE_PLUGIN_MAGIC, |
| 239 GAIM_MAJOR_VERSION, |
239 PURPLE_MAJOR_VERSION, |
| 240 GAIM_MINOR_VERSION, |
240 PURPLE_MINOR_VERSION, |
| 241 GAIM_PLUGIN_STANDARD, /**< type */ |
241 PURPLE_PLUGIN_STANDARD, /**< type */ |
| 242 NULL, /**< ui_requirement */ |
242 NULL, /**< ui_requirement */ |
| 243 0, /**< flags */ |
243 0, /**< flags */ |
| 244 NULL, /**< dependencies */ |
244 NULL, /**< dependencies */ |
| 245 GAIM_PRIORITY_DEFAULT, /**< priority */ |
245 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 246 |
246 |
| 247 FILECTL_PLUGIN_ID, /**< id */ |
247 FILECTL_PLUGIN_ID, /**< id */ |
| 248 N_("File Control"), /**< name */ |
248 N_("File Control"), /**< name */ |
| 249 VERSION, /**< version */ |
249 VERSION, /**< version */ |
| 250 /** summary */ |
250 /** summary */ |
| 251 N_("Allows control by entering commands in a file."), |
251 N_("Allows control by entering commands in a file."), |
| 252 /** description */ |
252 /** description */ |
| 253 N_("Allows control by entering commands in a file."), |
253 N_("Allows control by entering commands in a file."), |
| 254 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ |
254 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ |
| 255 GAIM_WEBSITE, /**< homepage */ |
255 PURPLE_WEBSITE, /**< homepage */ |
| 256 |
256 |
| 257 plugin_load, /**< load */ |
257 plugin_load, /**< load */ |
| 258 plugin_unload, /**< unload */ |
258 plugin_unload, /**< unload */ |
| 259 NULL, /**< destroy */ |
259 NULL, /**< destroy */ |
| 260 |
260 |
| 261 NULL, /**< ui_info */ |
261 NULL, /**< ui_info */ |
| 262 NULL /**< extra_info */ |
262 NULL /**< extra_info */ |
| 263 }; |
263 }; |
| 264 |
264 |
| 265 static void |
265 static void |
| 266 init_plugin(GaimPlugin *plugin) |
266 init_plugin(PurplePlugin *plugin) |
| 267 { |
267 { |
| 268 } |
268 } |
| 269 |
269 |
| 270 GAIM_INIT_PLUGIN(filectl, init_plugin, info) |
270 PURPLE_INIT_PLUGIN(filectl, init_plugin, info) |