summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/chat.c44
-rw-r--r--testing/toxic/main.c5
-rw-r--r--testing/toxic/prompt.c12
3 files changed, 42 insertions, 19 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 56dfb050..83765777 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -154,15 +154,47 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd)
154 } 154 }
155 155
156 else if (!strncmp(cmd, "/status ", strlen("/status "))) { 156 else if (!strncmp(cmd, "/status ", strlen("/status "))) {
157 char *status = strchr(cmd, ' ');
157 char *msg; 158 char *msg;
158 msg = strchr(cmd, ' '); 159 char *status_text;
159 if (msg == NULL) { 160 if (status == NULL) {
160 wprintw(ctx->history, "Invalid syntax.\n"); 161 wprintw(ctx->history, "Invalid syntax.\n");
161 return; 162 return;
162 } 163 }
163 msg++; 164 status++;
164 m_set_statusmessage((uint8_t*) msg, strlen(msg)+1); 165 USERSTATUS status_kind;
165 wprintw(ctx->history, "Status set to: %s\n", msg); 166 if (!strncmp(status, "online", strlen("online"))) {
167 status_kind = USERSTATUS_NONE;
168 status_text = "ONLINE";
169 }
170
171 else if (!strncmp(status, "away", strlen("away"))) {
172 status_kind = USERSTATUS_AWAY;
173 status_text = "AWAY";
174 }
175
176 else if (!strncmp(status, "busy", strlen("busy"))) {
177 status_kind = USERSTATUS_BUSY;
178 status_text = "BUSY";
179 }
180
181 else
182 {
183 wprintw(ctx->history, "Invalid status.\n");
184 return;
185 }
186
187 msg = strchr(status, ' ');
188 if (msg == NULL) {
189 m_set_userstatus(status_kind);
190 wprintw(ctx->history, "Status set to: %s\n", status_text);
191 }
192 else {
193 msg++;
194 m_set_userstatus(status_kind);
195 m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
196 wprintw(ctx->history, "Status set to: %s, %s\n", status_text, msg);
197 }
166 } 198 }
167 199
168 else if (!strncmp(cmd, "/nick ", strlen("/nick "))) { 200 else if (!strncmp(cmd, "/nick ", strlen("/nick "))) {
@@ -231,7 +263,7 @@ void print_help(ChatContext *self)
231 wprintw(self->history, "Commands:\n"); 263 wprintw(self->history, "Commands:\n");
232 wattroff(self->history, A_BOLD); 264 wattroff(self->history, A_BOLD);
233 265
234 wprintw(self->history, " /status <message> : Set your status\n"); 266 wprintw(self->history, " /status <type> <message> : Set your status\n");
235 wprintw(self->history, " /nick <nickname> : Set your nickname\n"); 267 wprintw(self->history, " /nick <nickname> : Set your nickname\n");
236 wprintw(self->history, " /myid : Print your ID\n"); 268 wprintw(self->history, " /myid : Print your ID\n");
237 wprintw(self->history, " /clear : Clear the screen\n"); 269 wprintw(self->history, " /clear : Clear the screen\n");
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index d4579571..7fa9e964 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -22,7 +22,10 @@ extern int add_req(uint8_t *public_key); // XXX
22 22
23/* Holds status of chat windows */ 23/* Holds status of chat windows */
24char WINDOW_STATUS[MAX_WINDOW_SLOTS]; 24char WINDOW_STATUS[MAX_WINDOW_SLOTS];
25//#define TOXICVER "0.1.0" //Will be moved to a -D flag later 25
26#ifndef TOXICVER
27#define TOXICVER "NOVER" //Use the -D flag to set this
28#endif
26 29
27static ToxWindow windows[MAX_WINDOW_SLOTS]; 30static ToxWindow windows[MAX_WINDOW_SLOTS];
28static ToxWindow* prompt; 31static ToxWindow* prompt;
diff --git a/testing/toxic/prompt.c b/testing/toxic/prompt.c
index b50792fe..eaa8d7bc 100644
--- a/testing/toxic/prompt.c
+++ b/testing/toxic/prompt.c
@@ -228,17 +228,6 @@ static void execute(ToxWindow *self, char *u_cmd)
228 } 228 }
229 } 229 }
230 230
231 else if (!strncmp(cmd, "statusmsg ", strlen("statumsg "))) {
232 char *msg = strchr(cmd, ' ');
233 if (msg == NULL) {
234 wprintw(self->window, "Invalid syntax.\n");
235 return;
236 }
237 msg++;
238 m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
239 wprintw(self->window, "Status set to: %s\n", msg);
240 }
241
242 else if (!strncmp(cmd, "nick ", strlen("nick "))) { 231 else if (!strncmp(cmd, "nick ", strlen("nick "))) {
243 char *nick = strchr(cmd, ' '); 232 char *nick = strchr(cmd, ' ');
244 if (nick == NULL) { 233 if (nick == NULL) {
@@ -372,7 +361,6 @@ static void print_usage(ToxWindow *self)
372 wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n"); 361 wprintw(self->window, " connect <ip> <port> <key> : Connect to DHT server\n");
373 wprintw(self->window, " add <id> <message> : Add friend\n"); 362 wprintw(self->window, " add <id> <message> : Add friend\n");
374 wprintw(self->window, " status <type> <message> : Set your status\n"); 363 wprintw(self->window, " status <type> <message> : Set your status\n");
375 wprintw(self->window, " statusmsg <message> : Set your status\n");
376 wprintw(self->window, " nick <nickname> : Set your nickname\n"); 364 wprintw(self->window, " nick <nickname> : Set your nickname\n");
377 wprintw(self->window, " accept <number> : Accept friend request\n"); 365 wprintw(self->window, " accept <number> : Accept friend request\n");
378 wprintw(self->window, " myid : Print your ID\n"); 366 wprintw(self->window, " myid : Print your ID\n");