Skip to content

Commit

Permalink
Rename m -> tox
Browse files Browse the repository at this point in the history
  • Loading branch information
JFreegman committed Jan 9, 2024
1 parent b527eed commit f574fb3
Show file tree
Hide file tree
Showing 48 changed files with 918 additions and 915 deletions.
2 changes: 1 addition & 1 deletion src/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void draw_handler_help(WINDOW *win)
python_draw_handler_help(win);
}

void cmd_run(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_run(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
FILE *fp;
const char *error_str;
Expand Down
2 changes: 1 addition & 1 deletion src/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ int num_registered_handlers(void);
int help_max_width(void);
void draw_handler_help(WINDOW *win);
void invoke_autoruns(WINDOW *w, ToxWindow *self);
void cmd_run(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]);
void cmd_run(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE]);

#endif /* API_H */
46 changes: 23 additions & 23 deletions src/audio_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void on_call_state(ToxAV *av, uint32_t friend_number, uint32_t state, void *user
void on_audio_receive_frame(ToxAV *av, uint32_t friend_number, int16_t const *pcm, size_t sample_count,
uint8_t channels, uint32_t sampling_rate, void *user_data);

void callback_recv_invite(Tox *m, uint32_t friend_number);
void callback_recv_invite(Tox *tox, uint32_t friend_number);
void callback_recv_ringing(uint32_t friend_number);
void callback_recv_starting(uint32_t friend_number);
void callback_recv_ending(uint32_t friend_number);
Expand Down Expand Up @@ -300,7 +300,7 @@ void on_call(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_e
{
UNUSED_VAR(av);

Tox *m = (Tox *) user_data;
Tox *tox = (Tox *) user_data;

Call *call = &CallControl.calls[friend_number];
init_call(call);
Expand All @@ -315,7 +315,7 @@ void on_call(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_e
call->state |= TOXAV_FRIEND_CALL_STATE_SENDING_V;
}

callback_recv_invite(m, friend_number);
callback_recv_invite(tox, friend_number);
}

void on_call_state(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data)
Expand Down Expand Up @@ -394,7 +394,7 @@ void audio_bit_rate_callback(ToxAV *av, uint32_t friend_number, uint32_t audio_b
toxav_audio_set_bit_rate(av, friend_number, audio_bit_rate, NULL);
}

void callback_recv_invite(Tox *m, uint32_t friend_number)
void callback_recv_invite(Tox *tox, uint32_t friend_number)
{
if (friend_number >= Friends.max_idx) {
return;
Expand All @@ -405,7 +405,7 @@ void callback_recv_invite(Tox *m, uint32_t friend_number)
return;
}

Friends.list[friend_number].chatwin = add_window(m, new_chat(m, Friends.list[friend_number].num));
Friends.list[friend_number].chatwin = add_window(tox, new_chat(tox, Friends.list[friend_number].num));
}

const Call *call = &CallControl.calls[friend_number];
Expand Down Expand Up @@ -499,10 +499,10 @@ void callback_call_ended(uint32_t friend_number)
/*
* Commands from chat_commands.h
*/
void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_call(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);
UNUSED_VAR(argv);

if (argc != 0) {
Expand Down Expand Up @@ -532,10 +532,10 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
place_call(self);
}

void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_answer(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);
UNUSED_VAR(argv);

Toxav_Err_Answer error;
Expand Down Expand Up @@ -579,10 +579,10 @@ void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
callback_recv_starting(self->num);
}

void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_reject(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);
UNUSED_VAR(argv);

if (argc != 0) {
Expand Down Expand Up @@ -610,10 +610,10 @@ void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
callback_call_rejected(self->num);
}

void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);
UNUSED_VAR(argv);

if (!CallControl.av) {
Expand All @@ -636,10 +636,10 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
stop_current_call(self);
}

void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);

if (argc != 1) {
if (argc < 1) {
Expand Down Expand Up @@ -673,10 +673,10 @@ void cmd_list_devices(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*
}

/* This changes primary device only */
void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);

if (argc != 2) {
if (argc < 1) {
Expand Down Expand Up @@ -720,10 +720,10 @@ void cmd_change_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (
}
}

void cmd_mute(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_mute(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);

if (argc != 1) {
print_err(self, "Specify type: \"/mute in\" or \"/mute out\".");
Expand Down Expand Up @@ -762,10 +762,10 @@ void cmd_mute(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
return;
}

void cmd_sense(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_sense(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);

if (argc != 1) {
if (argc < 1) {
Expand Down Expand Up @@ -796,10 +796,10 @@ void cmd_sense(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
return;
}

void cmd_bitrate(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
void cmd_bitrate(WINDOW *window, ToxWindow *self, Tox *tox, int argc, char (*argv)[MAX_STR_SIZE])
{
UNUSED_VAR(window);
UNUSED_VAR(m);
UNUSED_VAR(tox);

Call *call = &CallControl.calls[self->num];

Expand Down
10 changes: 5 additions & 5 deletions src/autocomplete.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
#include "toxic.h"
#include "windows.h"

static void print_ac_matches(ToxWindow *self, Tox *m, char **list, size_t n_matches)
static void print_ac_matches(ToxWindow *self, Tox *tox, char **list, size_t n_matches)
{
if (m) {
execute(self->chatwin->history, self, m, "/clear", GLOBAL_COMMAND_MODE);
if (tox != NULL) {
execute(self->chatwin->history, self, tox, "/clear", GLOBAL_COMMAND_MODE);
}

for (size_t i = 0; i < n_matches; ++i) {
Expand Down Expand Up @@ -317,7 +317,7 @@ static bool is_partial_match(const char *s, const char *p, size_t p_len)
* Returns -1 if no matches or more than one match.
*/
#define MAX_DIRS 75
int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)
int dir_match(ToxWindow *self, Tox *tox, const wchar_t *line, const wchar_t *cmd)
{
char b_path[MAX_STR_SIZE + 1];
char b_name[MAX_STR_SIZE + 1];
Expand Down Expand Up @@ -382,7 +382,7 @@ int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd)

if (dircount > 1) {
qsort(dirnames, dircount, sizeof(char *), qsort_ptr_char_array_helper);
print_ac_matches(self, m, dirnames, dircount);
print_ac_matches(self, tox, dirnames, dircount);
}

int ret = complete_path(self, (const char *const *) dirnames, dircount);
Expand Down
2 changes: 1 addition & 1 deletion src/autocomplete.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ int complete_line(ToxWindow *self, const char **list, size_t n_items);
* Returns the diff between old len and new len of ctx->line on success.
* Returns -1 if no matches or more than one match.
*/
int dir_match(ToxWindow *self, Tox *m, const wchar_t *line, const wchar_t *cmd);
int dir_match(ToxWindow *self, Tox *tox, const wchar_t *line, const wchar_t *cmd);

#endif /* AUTOCOMPLETE_H */
38 changes: 19 additions & 19 deletions src/avatars.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ static void avatar_clear(void)
* Returns 0 on success.
* Returns -1 on failure.
*/
int avatar_send(Tox *m, uint32_t friendnumber)
int avatar_send(Tox *tox, uint32_t friendnumber)
{
Tox_Err_File_Send err;
uint32_t filenumber = tox_file_send(m, friendnumber, TOX_FILE_KIND_AVATAR, (size_t) Avatar.size,
uint32_t filenumber = tox_file_send(tox, friendnumber, TOX_FILE_KIND_AVATAR, (size_t) Avatar.size,
NULL, (uint8_t *) Avatar.name, Avatar.name_len, &err);

if (Avatar.size == 0) {
Expand Down Expand Up @@ -117,11 +117,11 @@ int avatar_send(Tox *m, uint32_t friendnumber)
}

/* Sends avatar to all friends */
static void avatar_send_all(Tox *m)
static void avatar_send_all(Tox *tox)
{
for (size_t i = 0; i < Friends.max_idx; ++i) {
if (Friends.list[i].connection_status != TOX_CONNECTION_NONE) {
avatar_send(m, Friends.list[i].num);
avatar_send(tox, Friends.list[i].num);
}
}
}
Expand All @@ -131,7 +131,7 @@ static void avatar_send_all(Tox *m)
* Returns 0 on success.
* Returns -1 on failure.
*/
int avatar_set(Tox *m, const char *path, size_t path_len)
int avatar_set(Tox *tox, const char *path, size_t path_len)
{
if (path_len == 0 || path_len >= sizeof(Avatar.path)) {
return -1;
Expand Down Expand Up @@ -164,7 +164,7 @@ int avatar_set(Tox *m, const char *path, size_t path_len)
Avatar.path_len = path_len;
Avatar.size = size;

avatar_send_all(m);
avatar_send_all(tox);

return 0;
}
Expand All @@ -174,20 +174,20 @@ int avatar_set(Tox *m, const char *path, size_t path_len)
* Returns 0 on success.
* Returns -1 on failure.
*/
void avatar_unset(Tox *m)
void avatar_unset(Tox *tox)
{
avatar_clear();
avatar_send_all(m);
avatar_send_all(tox);
}

void on_avatar_friend_connection_status(Tox *m, uint32_t friendnumber, Tox_Connection connection_status)
void on_avatar_friend_connection_status(Tox *tox, uint32_t friendnumber, Tox_Connection connection_status)
{
if (connection_status == TOX_CONNECTION_NONE) {
kill_avatar_file_transfers_friend(m, friendnumber);
kill_avatar_file_transfers_friend(tox, friendnumber);
}
}

void on_avatar_file_control(Tox *m, struct FileTransfer *ft, Tox_File_Control control)
void on_avatar_file_control(Tox *tox, struct FileTransfer *ft, Tox_File_Control control)
{
switch (control) {
case TOX_FILE_CONTROL_RESUME:
Expand All @@ -204,30 +204,30 @@ void on_avatar_file_control(Tox *m, struct FileTransfer *ft, Tox_File_Control co
break;

case TOX_FILE_CONTROL_CANCEL:
close_file_transfer(NULL, m, ft, -1, NULL, silent);
close_file_transfer(NULL, tox, ft, -1, NULL, silent);
break;
}
}

void on_avatar_chunk_request(Tox *m, struct FileTransfer *ft, uint64_t position, size_t length)
void on_avatar_chunk_request(Tox *tox, struct FileTransfer *ft, uint64_t position, size_t length)
{
if (ft->state != FILE_TRANSFER_STARTED) {
return;
}

if (length == 0) {
close_file_transfer(NULL, m, ft, -1, NULL, silent);
close_file_transfer(NULL, tox, ft, -1, NULL, silent);
return;
}

if (ft->file == NULL) {
close_file_transfer(NULL, m, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
close_file_transfer(NULL, tox, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
return;
}

if (ft->position != position) {
if (fseek(ft->file, position, SEEK_SET) == -1) {
close_file_transfer(NULL, m, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
close_file_transfer(NULL, tox, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
return;
}

Expand All @@ -237,20 +237,20 @@ void on_avatar_chunk_request(Tox *m, struct FileTransfer *ft, uint64_t position,
uint8_t *send_data = malloc(length);

if (send_data == NULL) {
close_file_transfer(NULL, m, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
close_file_transfer(NULL, tox, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
return;
}

size_t send_length = fread(send_data, 1, length, ft->file);

if (send_length != length) {
close_file_transfer(NULL, m, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
close_file_transfer(NULL, tox, ft, TOX_FILE_CONTROL_CANCEL, NULL, silent);
free(send_data);
return;
}

Tox_Err_File_Send_Chunk err;
tox_file_send_chunk(m, ft->friendnumber, ft->filenumber, position, send_data, send_length, &err);
tox_file_send_chunk(tox, ft->friendnumber, ft->filenumber, position, send_data, send_length, &err);

free(send_data);

Expand Down
12 changes: 6 additions & 6 deletions src/avatars.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,24 @@
* Returns 0 on success.
* Returns -1 on failure.
*/
int avatar_send(Tox *m, uint32_t friendnum);
int avatar_send(Tox *tox, uint32_t friendnum);

/* Sets avatar to path and sends it to all online contacts.
*
* Returns 0 on success.
* Returns -1 on failure.
*/
int avatar_set(Tox *m, const char *path, size_t length);
int avatar_set(Tox *tox, const char *path, size_t length);

/* Unsets avatar and sends to all online contacts.
*
* Returns 0 on success.
* Returns -1 on failure.
*/
void avatar_unset(Tox *m);
void avatar_unset(Tox *tox);

void on_avatar_chunk_request(Tox *m, struct FileTransfer *ft, uint64_t position, size_t length);
void on_avatar_file_control(Tox *m, struct FileTransfer *ft, Tox_File_Control control);
void on_avatar_friend_connection_status(Tox *m, uint32_t friendnumber, Tox_Connection connection_status);
void on_avatar_chunk_request(Tox *tox, struct FileTransfer *ft, uint64_t position, size_t length);
void on_avatar_file_control(Tox *tox, struct FileTransfer *ft, Tox_File_Control control);
void on_avatar_friend_connection_status(Tox *tox, uint32_t friendnumber, Tox_Connection connection_status);

#endif /* AVATARS_H */
Loading

0 comments on commit f574fb3

Please sign in to comment.