mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Modified clients to properly work with the changes
This commit is contained in:
parent
9801eceaa4
commit
b1a2af23e5
@ -220,7 +220,7 @@ void line_eval(char *line)
|
|||||||
print_friendlist();
|
print_friendlist();
|
||||||
}
|
}
|
||||||
else if (inpt_command == 's') {
|
else if (inpt_command == 's') {
|
||||||
uint8_t status[MAX_USERSTATUS_LENGTH];
|
uint8_t status[MAX_STATUSMESSAGE_LENGTH];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
size_t len = strlen(line);
|
size_t len = strlen(line);
|
||||||
for (i = 3; i < len; i++) {
|
for (i = 3; i < len; i++) {
|
||||||
@ -228,7 +228,7 @@ void line_eval(char *line)
|
|||||||
status[i-3] = line[i];
|
status[i-3] = line[i];
|
||||||
}
|
}
|
||||||
status[i-3] = 0;
|
status[i-3] = 0;
|
||||||
m_set_userstatus(USERSTATUS_KIND_ONLINE, status, strlen((char*)status) + 1);
|
m_set_statusmessage(status, strlen((char*)status) + 1);
|
||||||
char numstring[100];
|
char numstring[100];
|
||||||
sprintf(numstring, "[i] changed status to %s", (char*)status);
|
sprintf(numstring, "[i] changed status to %s", (char*)status);
|
||||||
new_lines(numstring);
|
new_lines(numstring);
|
||||||
@ -364,7 +364,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_statuschange(int friendnumber, USERSTATUS_KIND kind, uint8_t *string, uint16_t length)
|
void print_statuschange(int friendnumber, uint8_t *string, uint16_t length)
|
||||||
{
|
{
|
||||||
char name[MAX_NAME_LENGTH];
|
char name[MAX_NAME_LENGTH];
|
||||||
if(getname(friendnumber, (uint8_t*)name) != -1) {
|
if(getname(friendnumber, (uint8_t*)name) != -1) {
|
||||||
@ -464,7 +464,7 @@ int main(int argc, char *argv[])
|
|||||||
m_callback_friendrequest(print_request);
|
m_callback_friendrequest(print_request);
|
||||||
m_callback_friendmessage(print_message);
|
m_callback_friendmessage(print_message);
|
||||||
m_callback_namechange(print_nickchange);
|
m_callback_namechange(print_nickchange);
|
||||||
m_callback_userstatus(print_statuschange);
|
m_callback_statusmessage(print_statuschange);
|
||||||
|
|
||||||
initscr();
|
initscr();
|
||||||
noecho();
|
noecho();
|
||||||
|
@ -86,7 +86,7 @@ void print_nickchange(int friendnumber, uint8_t *string, uint16_t length)
|
|||||||
printf(msg);
|
printf(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_statuschange(int friendnumber,USERSTATUS_KIND kind, uint8_t *string, uint16_t length)
|
void print_statuschange(int friendnumber, uint8_t *string, uint16_t length)
|
||||||
{
|
{
|
||||||
char name[MAX_NAME_LENGTH];
|
char name[MAX_NAME_LENGTH];
|
||||||
getname(friendnumber, (uint8_t*)name);
|
getname(friendnumber, (uint8_t*)name);
|
||||||
@ -263,7 +263,7 @@ void change_nickname()
|
|||||||
|
|
||||||
void change_status(int savetofile)
|
void change_status(int savetofile)
|
||||||
{
|
{
|
||||||
uint8_t status[MAX_USERSTATUS_LENGTH];
|
uint8_t status[MAX_STATUSMESSAGE_LENGTH];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
size_t len = strlen(line);
|
size_t len = strlen(line);
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ void change_status(int savetofile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
status[i-3] = 0;
|
status[i-3] = 0;
|
||||||
m_set_userstatus(USERSTATUS_KIND_RETAIN, status, strlen((char*)status));
|
m_set_statusmessage(status, strlen((char*)status));
|
||||||
char numstring[100];
|
char numstring[100];
|
||||||
sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status);
|
sprintf(numstring, "\n[i] changed status to %s\n\n", (char*)status);
|
||||||
printf(numstring);
|
printf(numstring);
|
||||||
@ -403,11 +403,11 @@ int main(int argc, char *argv[])
|
|||||||
FILE* status_file = NULL;
|
FILE* status_file = NULL;
|
||||||
status_file = fopen("statusfile.txt", "r");
|
status_file = fopen("statusfile.txt", "r");
|
||||||
if(status_file) {
|
if(status_file) {
|
||||||
uint8_t status[MAX_USERSTATUS_LENGTH];
|
uint8_t status[MAX_STATUSMESSAGE_LENGTH];
|
||||||
while (fgets(line, MAX_USERSTATUS_LENGTH, status_file) != NULL) {
|
while (fgets(line, MAX_STATUSMESSAGE_LENGTH, status_file) != NULL) {
|
||||||
sscanf(line, "%s", (char*)status);
|
sscanf(line, "%s", (char*)status);
|
||||||
}
|
}
|
||||||
m_set_userstatus(USERSTATUS_KIND_RETAIN, status, strlen((char*)status)+1);
|
m_set_statusmessage(status, strlen((char*)status)+1);
|
||||||
statusloaded = 1;
|
statusloaded = 1;
|
||||||
printf("%s\n", status);
|
printf("%s\n", status);
|
||||||
fclose(status_file);
|
fclose(status_file);
|
||||||
@ -416,7 +416,7 @@ int main(int argc, char *argv[])
|
|||||||
m_callback_friendrequest(print_request);
|
m_callback_friendrequest(print_request);
|
||||||
m_callback_friendmessage(print_message);
|
m_callback_friendmessage(print_message);
|
||||||
m_callback_namechange(print_nickchange);
|
m_callback_namechange(print_nickchange);
|
||||||
m_callback_userstatus(print_statuschange);
|
m_callback_statusmessae(print_statuschange);
|
||||||
char idstring1[PUB_KEY_BYTES][5];
|
char idstring1[PUB_KEY_BYTES][5];
|
||||||
char idstring2[PUB_KEY_BYTES][5];
|
char idstring2[PUB_KEY_BYTES][5];
|
||||||
int i;
|
int i;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
void do_header();
|
void do_header();
|
||||||
void print_message(int friendnumber, uint8_t * string, uint16_t length);
|
void print_message(int friendnumber, uint8_t * string, uint16_t length);
|
||||||
void print_nickchange(int friendnumber, uint8_t *string, uint16_t length);
|
void print_nickchange(int friendnumber, uint8_t *string, uint16_t length);
|
||||||
void print_statuschange(int friendnumber,USERSTATUS_KIND kind, uint8_t *string, uint16_t length);
|
void print_statuschange(int friendnumber, uint8_t *string, uint16_t length);
|
||||||
void load_key();
|
void load_key();
|
||||||
void add_friend();
|
void add_friend();
|
||||||
void list_friends();
|
void list_friends();
|
||||||
|
@ -162,7 +162,7 @@ void execute(ToxWindow *self, ChatContext *ctx, char *cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msg++;
|
msg++;
|
||||||
m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1);
|
m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
|
||||||
wprintw(ctx->history, "Status set to: %s\n", msg);
|
wprintw(ctx->history, "Status set to: %s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ extern int active_window;
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t name[MAX_NAME_LENGTH];
|
uint8_t name[MAX_NAME_LENGTH];
|
||||||
uint8_t status[MAX_USERSTATUS_LENGTH];
|
uint8_t status[MAX_STATUSMESSAGE_LENGTH];
|
||||||
int num;
|
int num;
|
||||||
int chatwin;
|
int chatwin;
|
||||||
} friend_t;
|
} friend_t;
|
||||||
@ -74,7 +74,7 @@ void friendlist_onNickChange(ToxWindow *self, int num, uint8_t *str, uint16_t le
|
|||||||
|
|
||||||
void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
void friendlist_onStatusChange(ToxWindow *self, int num, uint8_t *str, uint16_t len)
|
||||||
{
|
{
|
||||||
if (len >= MAX_USERSTATUS_LENGTH || num >= num_friends)
|
if (len >= MAX_STATUSMESSAGE_LENGTH || num >= num_friends)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memcpy((char*) &friends[num].status, (char*) str, len);
|
memcpy((char*) &friends[num].status, (char*) str, len);
|
||||||
|
@ -68,7 +68,7 @@ void on_nickchange(int friendnumber, uint8_t *string, uint16_t length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_statuschange(int friendnumber, USERSTATUS_KIND kind, uint8_t *string, uint16_t length)
|
void on_statuschange(int friendnumber, uint8_t *string, uint16_t length)
|
||||||
{
|
{
|
||||||
wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string);
|
wprintw(prompt->window, "\n(statuschange) %d: %s\n", friendnumber, string);
|
||||||
int i;
|
int i;
|
||||||
@ -112,7 +112,7 @@ static void init_tox()
|
|||||||
m_callback_friendrequest(on_request);
|
m_callback_friendrequest(on_request);
|
||||||
m_callback_friendmessage(on_message);
|
m_callback_friendmessage(on_message);
|
||||||
m_callback_namechange(on_nickchange);
|
m_callback_namechange(on_nickchange);
|
||||||
m_callback_userstatus(on_statuschange);
|
m_callback_statusmessage(on_statuschange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_window_status()
|
void init_window_status()
|
||||||
|
@ -183,27 +183,22 @@ static void execute(ToxWindow *self, char *u_cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
status++;
|
status++;
|
||||||
USERSTATUS_KIND status_kind;
|
USERSTATUS status_kind;
|
||||||
if (!strncmp(status, "online", strlen("online"))) {
|
if (!strncmp(status, "online", strlen("online"))) {
|
||||||
status_kind = USERSTATUS_KIND_ONLINE;
|
status_kind = USERSTATUS_NONE;
|
||||||
status_text = "ONLINE";
|
status_text = "ONLINE";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "away", strlen("away"))) {
|
else if (!strncmp(status, "away", strlen("away"))) {
|
||||||
status_kind = USERSTATUS_KIND_AWAY;
|
status_kind = USERSTATUS_AWAY;
|
||||||
status_text = "AWAY";
|
status_text = "AWAY";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "busy", strlen("busy"))) {
|
else if (!strncmp(status, "busy", strlen("busy"))) {
|
||||||
status_kind = USERSTATUS_KIND_BUSY;
|
status_kind = USERSTATUS_BUSY;
|
||||||
status_text = "BUSY";
|
status_text = "BUSY";
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strncmp(status, "offline", strlen("offline"))) {
|
|
||||||
status_kind = USERSTATUS_KIND_OFFLINE;
|
|
||||||
status_text = "OFFLINE";
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wprintw(self->window, "Invalid status.\n");
|
wprintw(self->window, "Invalid status.\n");
|
||||||
@ -212,12 +207,13 @@ static void execute(ToxWindow *self, char *u_cmd)
|
|||||||
|
|
||||||
msg = strchr(status, ' ');
|
msg = strchr(status, ' ');
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
m_set_userstatus_kind(status_kind);
|
m_set_userstatus(status_kind);
|
||||||
wprintw(self->window, "Status set to: %s\n", status_text);
|
wprintw(self->window, "Status set to: %s\n", status_text);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg++;
|
msg++;
|
||||||
m_set_userstatus(status_kind, (uint8_t*) msg, strlen(msg)+1);
|
m_set_userstatus(status_kind);
|
||||||
|
m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
|
||||||
wprintw(self->window, "Status set to: %s, %s\n", status_text, msg);
|
wprintw(self->window, "Status set to: %s, %s\n", status_text, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +225,7 @@ static void execute(ToxWindow *self, char *u_cmd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
msg++;
|
msg++;
|
||||||
m_set_userstatus(USERSTATUS_KIND_RETAIN, (uint8_t*) msg, strlen(msg)+1);
|
m_set_statusmessage((uint8_t*) msg, strlen(msg)+1);
|
||||||
wprintw(self->window, "Status set to: %s\n", msg);
|
wprintw(self->window, "Status set to: %s\n", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user