1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 18:13:26 +01:00

rm unused argument for sort func

This commit is contained in:
Jfreegman 2014-03-13 23:30:44 -04:00
parent ac82961bea
commit d8d198c81c
5 changed files with 24 additions and 17 deletions

View File

@ -62,7 +62,7 @@ static int index_name_cmp(const void *n1, const void *n2)
} }
/* sorts friendlist_index first by connection status then alphabetically */ /* sorts friendlist_index first by connection status then alphabetically */
void sort_friendlist_index(Tox *m) void sort_friendlist_index(void)
{ {
int i; int i;
int n = 0; int n = 0;
@ -105,7 +105,7 @@ static void friendlist_onConnectionChange(ToxWindow *self, Tox *m, int num, uint
return; return;
friends[num].online = status == 1 ? true : false; friends[num].online = status == 1 ? true : false;
sort_friendlist_index(m); sort_friendlist_index();
} }
static void friendlist_onNickChange(ToxWindow *self, Tox *m, int num, uint8_t *str, uint16_t len) static void friendlist_onNickChange(ToxWindow *self, Tox *m, int num, uint8_t *str, uint16_t len)
@ -117,7 +117,7 @@ static void friendlist_onNickChange(ToxWindow *self, Tox *m, int num, uint8_t *s
len = strlen(str) + 1; len = strlen(str) + 1;
memcpy(friends[num].name, str, len); memcpy(friends[num].name, str, len);
friends[num].namelength = len; friends[num].namelength = len;
sort_friendlist_index(m); sort_friendlist_index();
} }
static void friendlist_onStatusChange(ToxWindow *self, Tox *m, int num, TOX_USERSTATUS status) static void friendlist_onStatusChange(ToxWindow *self, Tox *m, int num, TOX_USERSTATUS status)
@ -168,7 +168,7 @@ void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num, bool sort)
++max_friends_index; ++max_friends_index;
if (sort) if (sort)
sort_friendlist_index(m); sort_friendlist_index();
return; return;
} }
@ -253,7 +253,7 @@ static void delete_friend(Tox *m, int f_num)
if (num_friends && num_selected == num_friends) if (num_friends && num_selected == num_friends)
--num_selected; --num_selected;
sort_friendlist_index(m); sort_friendlist_index();
store_data(m, DATA_FILE); store_data(m, DATA_FILE);
} }
@ -425,10 +425,12 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
/* Reset friends[f].statusmsg on window resize */ /* Reset friends[f].statusmsg on window resize */
if (fix_statuses) { if (fix_statuses) {
uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'}; uint8_t statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH] = {'\0'};
pthread_mutex_lock(&Winthread.lock); pthread_mutex_lock(&Winthread.lock);
tox_get_status_message(m, friends[f].num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH); tox_get_status_message(m, friends[f].num, statusmsg, TOX_MAX_STATUSMESSAGE_LENGTH);
friends[f].statusmsg_len = tox_get_status_message_size(m, f); friends[f].statusmsg_len = tox_get_status_message_size(m, f);
pthread_mutex_unlock(&Winthread.lock); pthread_mutex_unlock(&Winthread.lock);
snprintf(friends[f].statusmsg, sizeof(friends[f].statusmsg), "%s", statusmsg); snprintf(friends[f].statusmsg, sizeof(friends[f].statusmsg), "%s", statusmsg);
} }
@ -456,6 +458,11 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
if (f_selected) if (f_selected)
wattroff(self->window, A_BOLD); wattroff(self->window, A_BOLD);
// wprintw(self->window, "Last seen ");
// uint64_t last_seen = friends[f].last_online;
} }
} }
} }

View File

@ -38,6 +38,7 @@ typedef struct {
bool online; bool online;
bool is_typing; bool is_typing;
bool logging_on; /* saves preference for friend irrespective of chat windows */ bool logging_on; /* saves preference for friend irrespective of chat windows */
uint64_t last_online;
TOX_USERSTATUS status; TOX_USERSTATUS status;
struct FileReceiver file_receiver; struct FileReceiver file_receiver;
} ToxicFriend; } ToxicFriend;
@ -54,6 +55,6 @@ int get_friendnum(uint8_t *name);
void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num, bool sort); void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int num, bool sort);
/* sorts friendlist_index first by connection status then alphabetically */ /* sorts friendlist_index first by connection status then alphabetically */
void sort_friendlist_index(Tox *m); void sort_friendlist_index(void);
#endif /* end of include guard: FRIENDLIST_H_53I41IM */ #endif /* end of include guard: FRIENDLIST_H_53I41IM */

View File

@ -99,7 +99,7 @@ void write_to_log(uint8_t *msg, uint8_t *name, struct chatlog *log, bool event)
strftime(s, MAX_STR_SIZE, "%Y/%m/%d [%H:%M:%S]", get_time()); strftime(s, MAX_STR_SIZE, "%Y/%m/%d [%H:%M:%S]", get_time());
fprintf(log->file,"%s %s %s\n", s, name_frmt, msg); fprintf(log->file,"%s %s %s\n", s, name_frmt, msg);
uint64_t curtime = (uint64_t) time(NULL); uint64_t curtime = get_unix_time();
if (timed_out(log->lastwrite, curtime, LOG_FLUSH_LIMIT)) { if (timed_out(log->lastwrite, curtime, LOG_FLUSH_LIMIT)) {
fflush(log->file); fflush(log->file);

View File

@ -501,8 +501,7 @@ int main(int argc, char *argv[])
prompt = init_windows(m); prompt = init_windows(m);
/* create new thread for ncurses stuff */ /* create new thread for ncurses stuff */
if (pthread_mutex_init(&Winthread.lock, NULL) != 0) if (pthread_mutex_init(&Winthread.lock, NULL) != 0) {
{
endwin(); endwin();
fprintf(stderr, "Mutex init failed. Aborting...\n"); fprintf(stderr, "Mutex init failed. Aborting...\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -547,7 +546,7 @@ int main(int argc, char *argv[])
attroff(COLOR_PAIR(RED) | A_BOLD); attroff(COLOR_PAIR(RED) | A_BOLD);
} }
sort_friendlist_index(m); sort_friendlist_index();
prompt_init_statusbar(prompt, m); prompt_init_statusbar(prompt, m);
while (true) { while (true) {

View File

@ -477,7 +477,7 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m)
snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick); snprintf(statusbar->nick, sizeof(statusbar->nick), "%s", nick);
/* temporary until statusmessage saving works */ /* load prev status message or show toxic version if it has never been set */
uint8_t ver[strlen(TOXICVER) + 1]; uint8_t ver[strlen(TOXICVER) + 1];
strcpy(ver, TOXICVER); strcpy(ver, TOXICVER);
uint8_t *toxic_ver = strtok(ver, "_"); uint8_t *toxic_ver = strtok(ver, "_");