summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/prompt.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index 24b728f3..b6827ce2 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -52,9 +52,21 @@ static void execute(ToxWindow *self, char *u_cmd)
52 cmd[i - newlines] = u_cmd[i]; 52 cmd[i - newlines] = u_cmd[i];
53 } 53 }
54 54
55 int leading_spc = 0;
56 for (i = 0; i < 256 && isspace(cmd[i]); ++i)
57 leading_spc++;
58 memmove(cmd, cmd + leading_spc, 256 - leading_spc);
59
60 int cmd_end = strlen(cmd);
61 while (cmd_end > 0 && cmd_end--)
62 if (!isspace(cmd[cmd_end]))
63 break;
64 cmd[cmd_end + 1] = '\0';
65
55 if (cmd[0] == '/') { 66 if (cmd[0] == '/') {
67 wprintw(self->window,"Warning: Run your command without the /, this may not work\n");
56 int i; 68 int i;
57 for (i = i; i < strlen(cmd); i++) { //This doesn't work when it doesn't end with a space and another word 69 for (i = 1; i < strlen(cmd); i++) { //This doesn't work when it doesn't end with a space and another word
58 cmd[i - 1] = cmd[i]; //Still working on why 70 cmd[i - 1] = cmd[i]; //Still working on why
59 } 71 }
60 } 72 }
@@ -171,6 +183,54 @@ static void execute(ToxWindow *self, char *u_cmd)
171 } 183 }
172 184
173 else if (!strncmp(cmd, "status ", strlen("status "))) { 185 else if (!strncmp(cmd, "status ", strlen("status "))) {
186 char *status = strchr(cmd, ' ');
187 char *msg;
188 char *status_text;
189 if (status == NULL) {
190 wprintw(self->window, "Invalid syntax.\n");
191 return;
192 }
193 status++;
194 USERSTATUS_KIND status_kind;
195 if (!strncmp(status, "online", strlen("online"))) {
196 status_kind = USERSTATUS_KIND_ONLINE;
197 status_text = "ONLINE";
198 }
199
200 else if (!strncmp(status, "away", strlen("away"))) {
201 status_kind = USERSTATUS_KIND_AWAY;
202 status_text = "AWAY";
203 }
204
205 else if (!strncmp(status, "busy", strlen("busy"))) {
206 status_kind = USERSTATUS_KIND_BUSY;
207 status_text = "BUSY";
208 }
209
210 else if (!strncmp(status, "offline", strlen("offline"))) {
211 status_kind = USERSTATUS_KIND_OFFLINE;
212 status_text = "OFFLINE";
213 }
214
215 else
216 {
217 wprintw(self->window, "Invalid status.\n");
218 return;
219 }
220
221 msg = strchr(status, ' ');
222 if (msg == NULL) {
223 m_set_userstatus_kind(status_kind);
224 wprintw(self->window, "Status set to: %s\n", status_text);
225 }
226 else {
227 msg++;
228 m_set_userstatus(status_kind, (uint8_t*) msg, strlen(msg)+1);
229 wprintw(self->window, "Status set to: %s, %s\n", status_text, msg);
230 }
231 }
232
233 else if (!strncmp(cmd, "statusmsg ", strlen("statumsg "))) {
174 char *msg = strchr(cmd, ' '); 234 char *msg = strchr(cmd, ' ');
175 if (msg == NULL) { 235 if (msg == NULL) {
176 wprintw(self->window, "Invalid syntax.\n"); 236 wprintw(self->window, "Invalid syntax.\n");
@@ -313,7 +373,8 @@ static void print_usage(ToxWindow *self)
313 373
314 wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n"); 374 wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
315 wprintw(self->window, " add <id> <message> : Add friend\n"); 375 wprintw(self->window, " add <id> <message> : Add friend\n");
316 wprintw(self->window, " status <message> : Set your status\n"); 376 wprintw(self->window, " status <type> <message> : Set your status\n");
377 wprintw(self->window, " statusmsg <message> : Set your status\n");
317 wprintw(self->window, " nick <nickname> : Set your nickname\n"); 378 wprintw(self->window, " nick <nickname> : Set your nickname\n");
318 wprintw(self->window, " accept <number> : Accept friend request\n"); 379 wprintw(self->window, " accept <number> : Accept friend request\n");
319 wprintw(self->window, " myid : Print your ID\n"); 380 wprintw(self->window, " myid : Print your ID\n");