summaryrefslogtreecommitdiff
path: root/testing/toxic
diff options
context:
space:
mode:
authorSean Qureshi <stqism@risingstormgames.com>2013-08-02 16:44:32 -0700
committerSean Qureshi <stqism@risingstormgames.com>2013-08-02 16:44:32 -0700
commit10feea4474e53c12b74e4334042b13a5d5cfe94f (patch)
tree7f192223c8a8de0c889e0b41e2fd90198c795110 /testing/toxic
parentf8f24ba48a31f6405f5faa8cf770df6fb924acb9 (diff)
Adds timestamp to toxic, fixes issue #217
Diffstat (limited to 'testing/toxic')
-rw-r--r--testing/toxic/chat.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/testing/toxic/chat.c b/testing/toxic/chat.c
index 854d3817..10837aa7 100644
--- a/testing/toxic/chat.c
+++ b/testing/toxic/chat.c
@@ -7,6 +7,7 @@
7#include <string.h> 7#include <string.h>
8#include <stdint.h> 8#include <stdint.h>
9#include <ctype.h> 9#include <ctype.h>
10#include <time.h>
10 11
11#include "../../core/Messenger.h" 12#include "../../core/Messenger.h"
12#include "../../core/network.h" 13#include "../../core/network.h"
@@ -26,11 +27,15 @@ typedef struct {
26 27
27extern void fix_name(uint8_t* name); 28extern void fix_name(uint8_t* name);
28 29
29
30static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) { 30static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len) {
31 ChatContext* ctx = (ChatContext*) self->x; 31 ChatContext* ctx = (ChatContext*) self->x;
32 uint8_t nick[MAX_NAME_LENGTH] = {0}; 32 uint8_t nick[MAX_NAME_LENGTH] = {0};
33 33
34 time_t now;
35 time(&now);
36 struct tm * timeinfo;
37 timeinfo = localtime(&now);
38
34 if(ctx->friendnum != num) 39 if(ctx->friendnum != num)
35 return; 40 return;
36 41
@@ -42,10 +47,21 @@ static void chat_onMessage(ToxWindow* self, int num, uint8_t* msg, uint16_t len)
42 fix_name(msg); 47 fix_name(msg);
43 fix_name(nick); 48 fix_name(nick);
44 49
50 int inthour = timeinfo->tm_hour;
51 int intmin = timeinfo->tm_min;
52 char min[2];
53 char hour[2];
54 sprintf(hour,"%d",inthour);
55 sprintf(min,"%d",intmin);
56
57 wattron(ctx->history, COLOR_PAIR(2));
58 wprintw(ctx->history,"%s",hour);
59 wprintw(ctx->history,":%s ",min);
60 wattron(ctx->history, COLOR_PAIR(4));
61 wprintw(ctx->history, "%s: ", now);
45 wattron(ctx->history, COLOR_PAIR(4)); 62 wattron(ctx->history, COLOR_PAIR(4));
46 wprintw(ctx->history, "%s: ", nick); 63 wprintw(ctx->history, "%s: ", nick);
47 wattroff(ctx->history, COLOR_PAIR(4)); 64 wattroff(ctx->history, COLOR_PAIR(4));
48
49 wprintw(ctx->history, "%s\n", msg); 65 wprintw(ctx->history, "%s\n", msg);
50 66
51 self->blink = true; 67 self->blink = true;
@@ -74,6 +90,11 @@ static void chat_onStatusChange(ToxWindow* self, int num, uint8_t* status, uint1
74static void chat_onKey(ToxWindow* self, int key) { 90static void chat_onKey(ToxWindow* self, int key) {
75 ChatContext* ctx = (ChatContext*) self->x; 91 ChatContext* ctx = (ChatContext*) self->x;
76 92
93 time_t now;
94 time(&now);
95 struct tm * timeinfo;
96 timeinfo = localtime(&now);
97
77 if(isprint(key)) { 98 if(isprint(key)) {
78 99
79 if(ctx->pos != sizeof(ctx->line)-1) { 100 if(ctx->pos != sizeof(ctx->line)-1) {
@@ -82,6 +103,17 @@ static void chat_onKey(ToxWindow* self, int key) {
82 } 103 }
83 } 104 }
84 else if(key == '\n') { 105 else if(key == '\n') {
106
107 int inthour = timeinfo->tm_hour; //Pretty bad, but it gets the job done
108 int intmin = timeinfo->tm_min;
109 char min[2];
110 char hour[2];
111 sprintf(hour,"%d",inthour);
112 sprintf(min,"%d",intmin);
113
114 wattron(ctx->history, COLOR_PAIR(2));
115 wprintw(ctx->history,"%s",hour);
116 wprintw(ctx->history,":%s ",min);
85 wattron(ctx->history, COLOR_PAIR(1)); 117 wattron(ctx->history, COLOR_PAIR(1));
86 wprintw(ctx->history, "you: ", ctx->line); 118 wprintw(ctx->history, "you: ", ctx->line);
87 wattroff(ctx->history, COLOR_PAIR(1)); 119 wattroff(ctx->history, COLOR_PAIR(1));