Mercurial > pidgin
comparison plugins/filectl.c @ 2324:9ab820049ede
[gaim-migrate @ 2334]
Ari Pollak's patch to get this compiling again
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 20 Sep 2001 09:15:31 +0000 |
parents | ece2d1543b20 |
children | dfd9705bc750 |
comparison
equal
deleted
inserted
replaced
2323:bde2481bb4db | 2324:9ab820049ede |
---|---|
33 | 33 |
34 file = fopen(filename, "r+"); | 34 file = fopen(filename, "r+"); |
35 while (fgets(buffer, sizeof buffer, file)) { | 35 while (fgets(buffer, sizeof buffer, file)) { |
36 if (buffer[strlen(buffer) - 1] == '\n') | 36 if (buffer[strlen(buffer) - 1] == '\n') |
37 buffer[strlen(buffer) - 1] = 0; | 37 buffer[strlen(buffer) - 1] = 0; |
38 sprintf(debug_buff, "read: %s\n", buffer); | 38 debug_printf("read: %s\n", buffer); |
39 debug_print(debug_buff); | |
40 command = getarg(buffer, 0, 0); | 39 command = getarg(buffer, 0, 0); |
41 if (!strncasecmp(command, "signon", 6)) { | 40 if (!strncasecmp(command, "signon", 6)) { |
42 if (!blist) { | 41 struct aim_user *u = NULL; |
43 show_login(); | 42 GList *userlist = aim_users; |
44 dologin(NULL, NULL); | 43 arg1 = getarg(buffer, 1, 1); |
44 if(arg1) { | |
45 while(userlist) { | |
46 struct aim_user *current = userlist->data; | |
47 if(!strcmp(current->username, arg1)) { | |
48 u = current; | |
49 break; | |
50 } | |
51 userlist = userlist->next; | |
52 } | |
53 free(arg1); | |
45 } | 54 } |
55 if(u) /* username found */ | |
56 serv_login(u); | |
46 } else if (!strncasecmp(command, "signoff", 7)) { | 57 } else if (!strncasecmp(command, "signoff", 7)) { |
47 struct gaim_connection *gc = NULL; | 58 struct gaim_connection *gc = NULL; |
48 arg1 = getarg(buffer, 1, 1); | 59 arg1 = getarg(buffer, 1, 1); |
49 if (arg1) gc = find_gaim_conn_by_name(arg1); | 60 if (arg1) { |
61 gc = find_gaim_conn_by_name(arg1); | |
62 free(arg1); | |
63 } | |
50 if (gc) signoff(gc); | 64 if (gc) signoff(gc); |
51 else signoff_all(NULL, NULL); | 65 else signoff_all(NULL, NULL); |
52 } else if (!strncasecmp(command, "send", 4)) { | 66 } else if (!strncasecmp(command, "send", 4)) { |
53 struct conversation *c; | 67 struct conversation *c; |
54 arg1 = getarg(buffer, 1, 0); | 68 arg1 = getarg(buffer, 1, 0); |
55 arg2 = getarg(buffer, 2, 1); | 69 arg2 = getarg(buffer, 2, 1); |
56 c = find_conversation(arg1); | 70 c = find_conversation(arg1); |
57 if (!c) c = new_conversation(arg1); | 71 if (!c) c = new_conversation(arg1); |
58 write_to_conv(c, arg2, WFLAG_SEND, NULL); | 72 write_to_conv(c, arg2, WFLAG_SEND, NULL, time(NULL)); |
59 serv_send_im(c->gc, arg1, arg2, 0); | 73 serv_send_im(c->gc, arg1, arg2, 0); |
60 free(arg1); | 74 free(arg1); |
61 free(arg2); | 75 free(arg2); |
62 } else if (!strncasecmp(command, "away", 4)) { | 76 } else if (!strncasecmp(command, "away", 4)) { |
63 struct away_message a; | 77 struct away_message a; |
83 | 97 |
84 char *gaim_plugin_init(GModule *h) { | 98 char *gaim_plugin_init(GModule *h) { |
85 handle = h; | 99 handle = h; |
86 init_file(); | 100 init_file(); |
87 check = gtk_timeout_add(5000, (GtkFunction)check_file, NULL); | 101 check = gtk_timeout_add(5000, (GtkFunction)check_file, NULL); |
102 return NULL; | |
88 } | 103 } |
89 | 104 |
90 void gaim_plugin_remove() { | 105 void gaim_plugin_remove() { |
91 gtk_timeout_remove(check); | 106 gtk_timeout_remove(check); |
92 } | 107 } |
119 | 134 |
120 sprintf(file, "%s/.gaim/control", getenv("HOME")); | 135 sprintf(file, "%s/.gaim/control", getenv("HOME")); |
121 | 136 |
122 if ((stat (file, &finfo) == 0) && (finfo.st_size > 0)) | 137 if ((stat (file, &finfo) == 0) && (finfo.st_size > 0)) |
123 if (mtime != finfo.st_mtime) { | 138 if (mtime != finfo.st_mtime) { |
124 sprintf(debug_buff, "control changed, checking\n"); | 139 debug_printf("control changed, checking\n"); |
125 debug_print(debug_buff); | |
126 run_commands(); | 140 run_commands(); |
127 } | 141 } |
128 } | 142 } |
129 | 143 |
130 char *getarg(char *line, int which, int remain) { | 144 char *getarg(char *line, int which, int remain) { |