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
|
|
|
|
2020-04-18 02:00:00 +02:00
|
|
|
#include "file_transfers.h"
|
2014-06-12 00:06:55 +02:00
|
|
|
#include "toxic.h"
|
|
|
|
#include "windows.h"
|
|
|
|
|
2021-01-19 04:37:14 +01:00
|
|
|
#ifdef GAMES
|
|
|
|
#include "game_base.h"
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-11-08 16:08:24 +01:00
|
|
|
struct ConferenceInvite {
|
2014-09-28 04:50:20 +02:00
|
|
|
char *key;
|
|
|
|
uint16_t length;
|
2014-11-12 02:49:05 +01:00
|
|
|
uint8_t type;
|
2014-09-28 04:50:20 +02:00
|
|
|
bool pending;
|
|
|
|
};
|
|
|
|
|
2020-11-13 03:30:48 +01:00
|
|
|
struct GroupInvite {
|
|
|
|
uint8_t *data;
|
|
|
|
uint16_t length;
|
|
|
|
};
|
|
|
|
|
2021-01-19 04:37:14 +01:00
|
|
|
#ifdef GAMES
|
|
|
|
|
2021-01-17 19:29:13 +01:00
|
|
|
struct GameInvite {
|
|
|
|
uint8_t *data;
|
|
|
|
size_t data_length;
|
|
|
|
GameType type;
|
|
|
|
uint32_t id;
|
|
|
|
bool pending;
|
|
|
|
};
|
|
|
|
|
2021-01-19 04:37:14 +01:00
|
|
|
#endif // GAMES
|
|
|
|
|
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];
|
2017-08-29 01:37:19 +02:00
|
|
|
uint16_t namelength;
|
2015-03-26 03:56:45 +01:00
|
|
|
char statusmsg[TOX_MAX_STATUS_MESSAGE_LENGTH + 1];
|
2015-03-28 07:56:54 +01:00
|
|
|
size_t statusmsg_len;
|
2015-02-01 21:09:48 +01:00
|
|
|
char pub_key[TOX_PUBLIC_KEY_SIZE];
|
2015-03-26 03:56:45 +01:00
|
|
|
uint32_t num;
|
2013-11-30 00:52:21 +01:00
|
|
|
int chatwin;
|
|
|
|
bool active;
|
2018-10-10 05:06:57 +02:00
|
|
|
Tox_Connection connection_status;
|
2015-03-26 03:56:45 +01:00
|
|
|
bool is_typing;
|
2014-08-07 19:05:42 +02:00
|
|
|
bool logging_on; /* saves preference for friend irrespective of global settings */
|
2018-10-10 05:06:57 +02:00
|
|
|
Tox_User_Status status;
|
2015-03-28 07:56:54 +01:00
|
|
|
|
2014-03-15 22:18:23 +01:00
|
|
|
struct LastOnline last_online;
|
2021-01-19 04:37:14 +01:00
|
|
|
|
|
|
|
#ifdef GAMES
|
2021-01-17 19:29:13 +01:00
|
|
|
struct GameInvite game_invite;
|
2021-01-19 04:37:14 +01:00
|
|
|
#endif
|
2015-03-28 07:56:54 +01:00
|
|
|
|
2020-11-13 03:30:48 +01:00
|
|
|
struct ConferenceInvite conference_invite;
|
|
|
|
struct GroupInvite group_invite;
|
|
|
|
|
|
|
|
struct FileTransfer file_receiver[MAX_FILES];
|
|
|
|
struct FileTransfer file_sender[MAX_FILES];
|
2021-12-22 20:26:07 +01:00
|
|
|
PendingFileTransfer file_send_queue[MAX_FILES];
|
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];
|
2017-08-29 01:37:19 +02:00
|
|
|
uint16_t namelength;
|
2015-02-01 21:09:48 +01:00
|
|
|
char pub_key[TOX_PUBLIC_KEY_SIZE];
|
2015-03-26 03:56:45 +01:00
|
|
|
uint32_t num;
|
2014-07-31 18:48:49 +02:00
|
|
|
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;
|
2015-03-26 03:56:45 +01:00
|
|
|
size_t num_friends;
|
|
|
|
size_t num_online;
|
|
|
|
size_t max_idx; /* 1 + the index of the last friend in list */
|
|
|
|
uint32_t *index;
|
2014-08-07 19:05:42 +02:00
|
|
|
ToxicFriend *list;
|
2014-09-28 23:49:48 +02:00
|
|
|
} FriendsList;
|
2014-08-07 19:05:42 +02:00
|
|
|
|
2021-12-11 23:35:51 +01:00
|
|
|
extern FriendsList Friends;
|
|
|
|
|
2018-10-10 00:59:25 +02:00
|
|
|
ToxWindow *new_friendlist(void);
|
2020-11-30 05:26:51 +01:00
|
|
|
void friendlist_onInit(ToxWindow *self, Tox *m);
|
2015-03-26 03:56:45 +01:00
|
|
|
void disable_chatwin(uint32_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);
|
2018-10-09 20:21:33 +02:00
|
|
|
void kill_friendlist(ToxWindow *self);
|
2015-03-26 03:56:45 +01:00
|
|
|
void friendlist_onFriendAdded(ToxWindow *self, Tox *m, uint32_t num, bool sort);
|
2018-10-10 05:06:57 +02:00
|
|
|
Tox_User_Status get_friend_status(uint32_t friendnumber);
|
|
|
|
Tox_Connection get_friend_connection_status(uint32_t friendnumber);
|
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
|
|
|
|
2019-11-16 07:55:47 +01:00
|
|
|
/*
|
|
|
|
* Returns true if friend associated with `public_key` is in the block list.
|
|
|
|
*
|
|
|
|
* `public_key` must be at least TOX_PUBLIC_KEY_SIZE bytes.
|
|
|
|
*/
|
|
|
|
bool friend_is_blocked(const char *public_key);
|
|
|
|
|
2014-09-23 03:24:45 +02:00
|
|
|
#endif /* end of include guard: FRIENDLIST_H */
|