From d49e911fe410e190091108befbe09fe5f616d182 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Wed, 19 Mar 2014 03:14:08 -0400 Subject: [PATCH] type fixes --- src/chat.c | 6 +++--- src/chat.h | 2 +- src/friendlist.c | 8 ++------ src/friendlist.h | 4 ++-- src/global_commands.c | 4 ++-- src/groupchat.c | 2 +- src/log.c | 2 +- src/log.h | 2 +- src/prompt.c | 8 ++++---- src/windows.c | 4 +++- 10 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/chat.c b/src/chat.c index a21f26b..06ac087 100644 --- a/src/chat.c +++ b/src/chat.c @@ -271,7 +271,7 @@ static void chat_onFileControl(ToxWindow *self, Tox *m, int32_t num, uint8_t rec return; ChatContext *ctx = self->chatwin; - uint8_t *filename; + const uint8_t *filename; if (receive_send == 0) filename = friends[num].file_receiver.filenames[filenum]; @@ -714,7 +714,7 @@ static void chat_onDraw(ToxWindow *self, Tox *m) /* Draw name, status and note in statusbar */ if (statusbar->is_online) { - const char *status_text = "Unknown"; + const uint8_t *status_text = "Unknown"; int colour = WHITE; uint8_t status = statusbar->status; @@ -837,7 +837,7 @@ static void chat_onInit(ToxWindow *self, Tox *m) wmove(self->window, y2 - CURS_Y_OFFSET, 0); } -ToxWindow new_chat(Tox *m, int friendnum) +ToxWindow new_chat(Tox *m, int32_t friendnum) { ToxWindow ret; memset(&ret, 0, sizeof(ret)); diff --git a/src/chat.h b/src/chat.h index fac132a..d3aeb3e 100644 --- a/src/chat.h +++ b/src/chat.h @@ -26,6 +26,6 @@ #include "toxic_windows.h" void kill_chat_window(ToxWindow *self); -ToxWindow new_chat(Tox *m, int friendnum); +ToxWindow new_chat(Tox *m, int32_t friendnum); #endif /* end of include guard: CHAT_H_6489PZ13 */ diff --git a/src/friendlist.c b/src/friendlist.c index b5913c7..538f803 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -86,6 +86,8 @@ static void update_friend_last_online(int32_t num, uint64_t timestamp) { friends[num].last_online.last_on = timestamp; friends[num].last_online.tm = *localtime(×tamp); + + /* if the format changes make sure TIME_STR_SIZE is the correct size */ strftime(friends[num].last_online.hour_min_str, TIME_STR_SIZE, "%I:%M %p", &friends[num].last_online.tm); } @@ -519,11 +521,6 @@ void disable_chatwin(int32_t f_num) friends[f_num].chatwin = -1; } -static void friendlist_onInit(ToxWindow *self, Tox *m) -{ - -} - #ifdef _SUPPORT_AUDIO static void friendlist_onAv(ToxWindow *self, ToxAv *av) { @@ -563,7 +560,6 @@ ToxWindow new_friendlist(void) ret.onKey = &friendlist_onKey; ret.onDraw = &friendlist_onDraw; - ret.onInit = &friendlist_onInit; ret.onFriendAdded = &friendlist_onFriendAdded; ret.onMessage = &friendlist_onMessage; ret.onConnectionChange = &friendlist_onConnectionChange; diff --git a/src/friendlist.h b/src/friendlist.h index a632817..d140689 100644 --- a/src/friendlist.h +++ b/src/friendlist.h @@ -53,10 +53,10 @@ typedef struct { } ToxicFriend; ToxWindow new_friendlist(void); -void disable_chatwin(int f_num); +void disable_chatwin(int32_t f_num); int get_friendnum(uint8_t *name); -void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num, bool sort); +void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort); /* sorts friendlist_index first by connection status then alphabetically */ void sort_friendlist_index(void); diff --git a/src/global_commands.c b/src/global_commands.c index 113dc4f..3e1b749 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -60,7 +60,7 @@ void cmd_accept(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ return; } - int friendnum = tox_add_friend_norequest(m, pending_frnd_requests[req]); + int32_t friendnum = tox_add_friend_norequest(m, pending_frnd_requests[req]); if (friendnum == -1) wprintw(window, "Failed to add friend.\n"); @@ -134,7 +134,7 @@ void cmd_add(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX id[i] = toupper(id[i]); } - int f_num = tox_add_friend(m, id_bin, msg, strlen(msg) + 1); + int32_t f_num = tox_add_friend(m, id_bin, msg, strlen(msg) + 1); switch (f_num) { case TOX_FAERR_TOOLONG: diff --git a/src/groupchat.c b/src/groupchat.c index f1ad6d8..09faaf2 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -272,7 +272,7 @@ static void groupchat_onGroupNamelistChange(ToxWindow *self, Tox *m, int groupnu ChatContext *ctx = self->chatwin; print_time(ctx->history); - uint8_t *event; + const uint8_t *event; switch (change) { case TOX_CHAT_CHANGE_PEER_ADD: diff --git a/src/log.c b/src/log.c index ae21a1c..be2ef28 100644 --- a/src/log.c +++ b/src/log.c @@ -78,7 +78,7 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log) free(user_config_dir); } -void write_to_log(uint8_t *msg, uint8_t *name, struct chatlog *log, bool event) +void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool event) { if (!log->log_on) return; diff --git a/src/log.h b/src/log.h index 71c9748..510a429 100644 --- a/src/log.h +++ b/src/log.h @@ -24,7 +24,7 @@ void init_logging_session(uint8_t *name, uint8_t *key, struct chatlog *log); /* formats/writes line to log file */ -void write_to_log(uint8_t *msg, uint8_t *name, struct chatlog *log, bool event); +void write_to_log(const uint8_t *msg, uint8_t *name, struct chatlog *log, bool event); /* enables logging for specified log and creates/fetches file if necessary */ void log_enable(uint8_t *name, uint8_t *key, struct chatlog *log); diff --git a/src/prompt.c b/src/prompt.c index f02e644..561ee2b 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -325,7 +325,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m) if (statusbar->is_online) { int colour = WHITE; - const char *status_text = "Unknown"; + const uint8_t *status_text = "Unknown"; switch (statusbar->status) { case TOX_USERSTATUS_NONE: @@ -408,7 +408,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, int32_t friendnum wprintw(self->window, "\n"); print_time(self->window); - uint8_t *msg; + const uint8_t *msg; if (status == 1) { msg = "has come online"; @@ -452,7 +452,7 @@ static void prompt_onFriendRequest(ToxWindow *self, Tox *m, uint8_t *key, uint8_ int n = add_friend_request(key); if (n == -1) { - uint8_t *errmsg = "Friend request queue is full. Discarding request.\n"; + const uint8_t *errmsg = "Friend request queue is full. Discarding request.\n"; wprintw(self->window, "%s", errmsg); write_to_log(errmsg, "", prt->log, true); return; @@ -486,7 +486,7 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m) /* load prev status message or show toxic version if it has never been set */ uint8_t ver[strlen(TOXICVER) + 1]; strcpy(ver, TOXICVER); - uint8_t *toxic_ver = strtok(ver, "_"); + const uint8_t *toxic_ver = strtok(ver, "_"); if ( (!strcmp("Online", statusmsg) || !strncmp("Toxing on Toxic", statusmsg, 15)) && toxic_ver != NULL) snprintf(statusmsg, MAX_STR_SIZE, "Toxing on Toxic v.%s", toxic_ver); diff --git a/src/windows.c b/src/windows.c index e47348d..51fd319 100644 --- a/src/windows.c +++ b/src/windows.c @@ -241,7 +241,9 @@ int add_window(Tox *m, ToxWindow w) wbkgd(w.window, COLOR_PAIR(6)); #endif windows[i] = w; - w.onInit(&w, m); + + if (w.onInit) + w.onInit(&w, m); ++num_active_windows;