From 2b19f56e637c22061e9edc683a58971bdc8bf934 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Sun, 1 Feb 2015 21:09:48 +0100 Subject: [PATCH] Update for toxcore API break --- src/friendlist.c | 12 ++++++------ src/friendlist.h | 4 ++-- src/global_commands.c | 4 ++-- src/prompt.c | 2 +- src/prompt.h | 2 +- src/toxic.c | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/friendlist.c b/src/friendlist.c index 6ce0cc9..21f8a93 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -150,7 +150,7 @@ static int save_blocklist(char *path) memset(&tmp, 0, sizeof(BlockedFriend)); tmp.namelength = htons(Blocked.list[i].namelength); memcpy(tmp.name, Blocked.list[i].name, Blocked.list[i].namelength + 1); - memcpy(tmp.pub_key, Blocked.list[i].pub_key, TOX_CLIENT_ID_SIZE); + memcpy(tmp.pub_key, Blocked.list[i].pub_key, TOX_PUBLIC_KEY_SIZE); uint8_t lastonline[sizeof(uint64_t)]; memcpy(lastonline, &Blocked.list[i].last_on, sizeof(uint64_t)); @@ -232,7 +232,7 @@ int load_blocklist(char *path) Blocked.list[i].num = i; Blocked.list[i].namelength = ntohs(tmp.namelength); memcpy(Blocked.list[i].name, tmp.name, Blocked.list[i].namelength + 1); - memcpy(Blocked.list[i].pub_key, tmp.pub_key, TOX_CLIENT_ID_SIZE); + memcpy(Blocked.list[i].pub_key, tmp.pub_key, TOX_PUBLIC_KEY_SIZE); uint8_t lastonline[sizeof(uint64_t)]; memcpy(lastonline, &tmp.last_on, sizeof(uint64_t)); @@ -448,7 +448,7 @@ static void friendlist_add_blocked(Tox *m, int32_t fnum, int32_t bnum) Friends.list[i].namelength = Blocked.list[bnum].namelength; update_friend_last_online(i, Blocked.list[bnum].last_on); memcpy(Friends.list[i].name, Blocked.list[bnum].name, Friends.list[i].namelength + 1); - memcpy(Friends.list[i].pub_key, Blocked.list[bnum].pub_key, TOX_CLIENT_ID_SIZE); + memcpy(Friends.list[i].pub_key, Blocked.list[bnum].pub_key, TOX_PUBLIC_KEY_SIZE); if (i == Friends.max_idx) ++Friends.max_idx; @@ -644,7 +644,7 @@ void block_friend(Tox *m, int32_t fnum) Blocked.list[i].num = i; Blocked.list[i].namelength = Friends.list[fnum].namelength; Blocked.list[i].last_on = Friends.list[fnum].last_online.last_on; - memcpy(Blocked.list[i].pub_key, Friends.list[fnum].pub_key, TOX_CLIENT_ID_SIZE); + memcpy(Blocked.list[i].pub_key, Friends.list[fnum].pub_key, TOX_PUBLIC_KEY_SIZE); memcpy(Blocked.list[i].name, Friends.list[fnum].name, Friends.list[fnum].namelength + 1); ++Blocked.num_blocked; @@ -823,7 +823,7 @@ static void blocklist_onDraw(ToxWindow *self, Tox *m, int y2, int x2) int i; - for (i = 0; i < TOX_CLIENT_ID_SIZE; ++i) + for (i = 0; i < TOX_PUBLIC_KEY_SIZE; ++i) wprintw(self->window, "%02X", Blocked.list[selected_num].pub_key[i] & 0xff); } @@ -1012,7 +1012,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m) int i; - for (i = 0; i < TOX_CLIENT_ID_SIZE; ++i) + for (i = 0; i < TOX_PUBLIC_KEY_SIZE; ++i) wprintw(self->window, "%02X", Friends.list[selected_num].pub_key[i] & 0xff); } diff --git a/src/friendlist.h b/src/friendlist.h index 3beb633..d031751 100644 --- a/src/friendlist.h +++ b/src/friendlist.h @@ -60,7 +60,7 @@ typedef struct { int namelength; char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH + 1]; uint16_t statusmsg_len; - char pub_key[TOX_CLIENT_ID_SIZE]; + char pub_key[TOX_PUBLIC_KEY_SIZE]; int32_t num; int chatwin; bool active; @@ -77,7 +77,7 @@ typedef struct { typedef struct { char name[TOXIC_MAX_NAME_LENGTH + 1]; int namelength; - char pub_key[TOX_CLIENT_ID_SIZE]; + char pub_key[TOX_PUBLIC_KEY_SIZE]; int32_t num; bool active; uint64_t last_on; diff --git a/src/global_commands.c b/src/global_commands.c index b2321b9..93837b5 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -507,9 +507,9 @@ void cmd_requests(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv if (!FrndRequests.request[i].active) continue; - char id[TOX_CLIENT_ID_SIZE * 2 + 1] = {0}; + char id[TOX_PUBLIC_KEY_SIZE * 2 + 1] = {0}; - for (j = 0; j < TOX_CLIENT_ID_SIZE; ++j) { + for (j = 0; j < TOX_PUBLIC_KEY_SIZE; ++j) { char d[3]; snprintf(d, sizeof(d), "%02X", FrndRequests.request[i].key[j] & 0xff); strcat(id, d); diff --git a/src/prompt.c b/src/prompt.c index 99c2a4a..a580c1f 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -145,7 +145,7 @@ static int add_friend_request(const char *public_key, const char *data) for (i = 0; i <= FrndRequests.max_idx; ++i) { if (!FrndRequests.request[i].active) { FrndRequests.request[i].active = true; - memcpy(FrndRequests.request[i].key, public_key, TOX_CLIENT_ID_SIZE); + memcpy(FrndRequests.request[i].key, public_key, TOX_PUBLIC_KEY_SIZE); snprintf(FrndRequests.request[i].msg, sizeof(FrndRequests.request[i].msg), "%s", data); if (i == FrndRequests.max_idx) diff --git a/src/prompt.h b/src/prompt.h index e184b8d..e6eb0cc 100644 --- a/src/prompt.h +++ b/src/prompt.h @@ -31,7 +31,7 @@ struct friend_request { bool active; char msg[MAX_STR_SIZE]; - uint8_t key[TOX_CLIENT_ID_SIZE]; + uint8_t key[TOX_PUBLIC_KEY_SIZE]; }; typedef struct { diff --git a/src/toxic.c b/src/toxic.c index 23046b8..dc5b862 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -324,13 +324,13 @@ static Tox *init_tox(void) #define MIN_NODE_LINE 50 /* IP: 7 + port: 5 + key: 38 + spaces: 2 = 70. ! (& e.g. tox.im = 6) */ #define MAX_NODE_LINE 256 /* Approx max number of chars in a sever line (name + port + key) */ #define MAXNODES 50 -#define NODELEN (MAX_NODE_LINE - TOX_CLIENT_ID_SIZE - 7) +#define NODELEN (MAX_NODE_LINE - TOX_PUBLIC_KEY_SIZE - 7) static struct toxNodes { int lines; char nodes[MAXNODES][NODELEN]; uint16_t ports[MAXNODES]; - char keys[MAXNODES][TOX_CLIENT_ID_SIZE]; + char keys[MAXNODES][TOX_PUBLIC_KEY_SIZE]; } toxNodes; static int load_nodelist(const char *filename) @@ -360,7 +360,7 @@ static int load_nodelist(const char *filename) toxNodes.ports[toxNodes.lines] = atoi(port); char *key_binary = hex_string_to_bin(key_ascii); - memcpy(toxNodes.keys[toxNodes.lines], key_binary, TOX_CLIENT_ID_SIZE); + memcpy(toxNodes.keys[toxNodes.lines], key_binary, TOX_PUBLIC_KEY_SIZE); free(key_binary); toxNodes.lines++;