mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
New friend list function for nTox client.
This commit is contained in:
parent
d503941f6c
commit
09a71f37ec
@ -20,10 +20,11 @@
|
|||||||
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
|
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include "../core/DHT.c"
|
||||||
#include "nTox.h"
|
#include "nTox.h"
|
||||||
#include "misc_tools.h"
|
#include "misc_tools.h"
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -50,6 +51,25 @@ void new_lines(char *line)
|
|||||||
do_refresh();
|
do_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_friendlist()
|
||||||
|
{
|
||||||
|
char name[MAX_NAME_LENGTH];
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
new_lines("[i] Friend List:");
|
||||||
|
for (i=0; i <= num_requests; i++) {
|
||||||
|
char fstring[128];
|
||||||
|
|
||||||
|
getname(i, (uint8_t*)name);
|
||||||
|
if (strlen(name) <= 0) {
|
||||||
|
sprintf(fstring, "[i] Friend: NULL\n\tid: %i", i);
|
||||||
|
} else {
|
||||||
|
sprintf(fstring, "[i] Friend: %s\n\tid: %i", (uint8_t*)name, i);
|
||||||
|
}
|
||||||
|
new_lines(fstring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
||||||
{
|
{
|
||||||
if (line[0] == '/') {
|
if (line[0] == '/') {
|
||||||
@ -104,6 +124,9 @@ void line_eval(char lines[HISTORY][STRING_LENGTH], char *line)
|
|||||||
sprintf(numstring, "[i] changed nick to %s", (char*)name);
|
sprintf(numstring, "[i] changed nick to %s", (char*)name);
|
||||||
new_lines(numstring);
|
new_lines(numstring);
|
||||||
}
|
}
|
||||||
|
else if (line[1] == 'l') {
|
||||||
|
print_friendlist();
|
||||||
|
}
|
||||||
else if (line[1] == 's') {
|
else if (line[1] == 's') {
|
||||||
uint8_t status[MAX_USERSTATUS_LENGTH];
|
uint8_t status[MAX_USERSTATUS_LENGTH];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -313,7 +336,8 @@ int main(int argc, char *argv[])
|
|||||||
raw();
|
raw();
|
||||||
getmaxyx(stdscr,y,x);
|
getmaxyx(stdscr,y,x);
|
||||||
new_lines(idstring0);
|
new_lines(idstring0);
|
||||||
new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status), /n nick (to change nickname), /q (to quit)");
|
new_lines("[i] commands: /f ID (to add friend), /m friendnumber message (to send message), /s status (to change status)");
|
||||||
|
new_lines("[i] /l list (list friends), /n nick (to change nickname), /q (to quit)");
|
||||||
strcpy(line, "");
|
strcpy(line, "");
|
||||||
IP_Port bootstrap_ip_port;
|
IP_Port bootstrap_ip_port;
|
||||||
bootstrap_ip_port.port = htons(atoi(argv[2]));
|
bootstrap_ip_port.port = htons(atoi(argv[2]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user