2014-02-25 08:28:24 +01:00
|
|
|
/* friendlist.h
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This file is part of Toxic.
|
|
|
|
*
|
|
|
|
* Toxic is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Toxic is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#ifndef FRIENDLIST_H
|
|
|
|
#define FRIENDLIST_H
|
2013-08-13 00:50:43 +02:00
|
|
|
|
2014-03-15 22:18:23 +01:00
|
|
|
#include <time.h>
|
2014-06-12 00:06:55 +02:00
|
|
|
|
|
|
|
#include "toxic.h"
|
|
|
|
#include "windows.h"
|
|
|
|
#include "file_senders.h"
|
2013-08-13 02:32:09 +02:00
|
|
|
|
2014-06-12 00:06:55 +02:00
|
|
|
struct FileReceiver {
|
2014-08-05 23:38:33 +02:00
|
|
|
char filename[MAX_STR_SIZE];
|
|
|
|
int filenum;
|
|
|
|
FILE *file;
|
|
|
|
bool pending;
|
|
|
|
bool active;
|
|
|
|
uint64_t size;
|
2014-08-16 23:20:53 +02:00
|
|
|
uint64_t bytes_recv;
|
2014-08-05 23:38:33 +02:00
|
|
|
double bps;
|
2014-08-16 23:20:53 +02:00
|
|
|
uint64_t last_progress; /* unix-time when we last updated progress */
|
2014-08-05 23:38:33 +02:00
|
|
|
uint32_t line_id;
|
2014-06-12 00:06:55 +02:00
|
|
|
};
|
|
|
|
|
2014-03-15 22:18:23 +01:00
|
|
|
struct LastOnline {
|
|
|
|
uint64_t last_on;
|
|
|
|
struct tm tm;
|
2014-07-07 04:15:35 +02:00
|
|
|
char hour_min_str[TIME_STR_SIZE]; /* holds 12/24-hour time string e.g. "10:43 PM" */
|
2014-03-15 22:18:23 +01:00
|
|
|
};
|
|
|
|
|
2015-01-23 06:52:09 +01:00
|
|
|
struct GroupInvite {
|
|
|
|
uint8_t data[TOX_GROUP_INVITE_DATA_SIZE];
|
|
|
|
uint16_t length;
|
|
|
|
};
|
|
|
|
|
2013-11-30 00:52:21 +01:00
|
|
|
typedef struct {
|
2014-10-03 23:53:50 +02:00
|
|
|
char name[TOXIC_MAX_NAME_LENGTH + 1];
|
2014-07-07 04:31:11 +02:00
|
|
|
int namelength;
|
2014-10-03 23:53:50 +02:00
|
|
|
char statusmsg[TOX_MAX_STATUSMESSAGE_LENGTH + 1];
|
2013-11-30 00:52:21 +01:00
|
|
|
uint16_t statusmsg_len;
|
2014-07-07 04:15:35 +02:00
|
|
|
char pub_key[TOX_CLIENT_ID_SIZE];
|
2014-03-19 02:48:26 +01:00
|
|
|
int32_t num;
|
2013-11-30 00:52:21 +01:00
|
|
|
int chatwin;
|
|
|
|
bool active;
|
|
|
|
bool online;
|
2014-03-21 01:50:48 +01:00
|
|
|
uint8_t is_typing;
|
2014-08-07 19:05:42 +02:00
|
|
|
bool logging_on; /* saves preference for friend irrespective of global settings */
|
2014-03-19 02:48:26 +01:00
|
|
|
uint8_t status;
|
2015-01-23 06:52:09 +01:00
|
|
|
struct GroupInvite group_invite;
|
2014-03-15 22:18:23 +01:00
|
|
|
struct LastOnline last_online;
|
2014-08-05 23:38:33 +02:00
|
|
|
struct FileReceiver file_receiver[MAX_FILES];
|
2014-08-16 23:20:53 +02:00
|
|
|
uint8_t active_file_receivers;
|
2013-11-30 00:52:21 +01:00
|
|
|
} ToxicFriend;
|
|
|
|
|
2014-07-31 18:48:49 +02:00
|
|
|
typedef struct {
|
2014-10-03 23:53:50 +02:00
|
|
|
char name[TOXIC_MAX_NAME_LENGTH + 1];
|
2014-07-31 18:48:49 +02:00
|
|
|
int namelength;
|
|
|
|
char pub_key[TOX_CLIENT_ID_SIZE];
|
|
|
|
int32_t num;
|
|
|
|
bool active;
|
2014-07-31 20:53:02 +02:00
|
|
|
uint64_t last_on;
|
2014-07-31 18:48:49 +02:00
|
|
|
} BlockedFriend;
|
|
|
|
|
2014-08-07 19:05:42 +02:00
|
|
|
typedef struct {
|
|
|
|
int num_selected;
|
2014-08-08 01:24:56 +02:00
|
|
|
int max_idx; /* 1 + the index of the last friend in list */
|
2014-08-07 19:05:42 +02:00
|
|
|
int num_friends;
|
|
|
|
int *index;
|
|
|
|
ToxicFriend *list;
|
2014-09-28 23:49:48 +02:00
|
|
|
} FriendsList;
|
2014-08-07 19:05:42 +02:00
|
|
|
|
2013-11-19 21:32:35 +01:00
|
|
|
ToxWindow new_friendlist(void);
|
2014-03-19 08:14:08 +01:00
|
|
|
void disable_chatwin(int32_t f_num);
|
2013-09-18 01:11:23 +02:00
|
|
|
int get_friendnum(uint8_t *name);
|
2014-07-31 18:48:49 +02:00
|
|
|
int load_blocklist(char *data);
|
2014-08-07 19:05:42 +02:00
|
|
|
void kill_friendlist(void);
|
2014-03-19 08:14:08 +01:00
|
|
|
void friendlist_onFriendAdded(ToxWindow *self, Tox *m, int32_t num, bool sort);
|
2014-03-05 14:01:12 +01:00
|
|
|
|
2013-11-25 00:22:48 +01:00
|
|
|
/* sorts friendlist_index first by connection status then alphabetically */
|
2014-03-14 04:30:44 +01:00
|
|
|
void sort_friendlist_index(void);
|
2013-08-13 00:50:43 +02:00
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#endif /* end of include guard: FRIENDLIST_H */
|