mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 14:36:22 +00:00
Refactor _cmd_close
This commit is contained in:
@@ -3035,21 +3035,12 @@ _cmd_close(gchar **args, struct cmd_help_t help)
|
|||||||
{
|
{
|
||||||
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int curr = 0;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
if (args[0] == NULL) {
|
if (args[0] == NULL) {
|
||||||
index = ui_current_win_index();
|
index = ui_current_win_index();
|
||||||
} else if (strcmp(args[0], "all") == 0) {
|
} else if (strcmp(args[0], "all") == 0) {
|
||||||
for (curr = 1; curr <= 9; curr++) {
|
count = ui_close_all_wins();
|
||||||
if (ui_win_exists(curr)) {
|
|
||||||
if (conn_status == JABBER_CONNECTED) {
|
|
||||||
ui_close_connected_win(curr);
|
|
||||||
}
|
|
||||||
ui_close_win(curr);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
cons_show("No windows to close.");
|
cons_show("No windows to close.");
|
||||||
} else if (count == 1) {
|
} else if (count == 1) {
|
||||||
@@ -3059,15 +3050,7 @@ _cmd_close(gchar **args, struct cmd_help_t help)
|
|||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (strcmp(args[0], "read") == 0) {
|
} else if (strcmp(args[0], "read") == 0) {
|
||||||
for (curr = 1; curr <= 9; curr++) {
|
count = ui_close_read_wins();
|
||||||
if (ui_win_exists(curr) && (ui_win_unread(curr) == 0)) {
|
|
||||||
if (conn_status == JABBER_CONNECTED) {
|
|
||||||
ui_close_connected_win(curr);
|
|
||||||
}
|
|
||||||
ui_close_win(curr);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
cons_show("No windows to close.");
|
cons_show("No windows to close.");
|
||||||
} else if (count == 1) {
|
} else if (count == 1) {
|
||||||
|
|||||||
@@ -567,6 +567,44 @@ ui_close_connected_win(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ui_close_all_wins(void)
|
||||||
|
{
|
||||||
|
int curr = 0, count = 0;
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
|
||||||
|
for (curr = 1; curr <= 9; curr++) {
|
||||||
|
if (ui_win_exists(curr)) {
|
||||||
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
ui_close_connected_win(curr);
|
||||||
|
}
|
||||||
|
ui_close_win(curr);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ui_close_read_wins(void)
|
||||||
|
{
|
||||||
|
int curr = 0, count = 0;
|
||||||
|
jabber_conn_status_t conn_status = jabber_get_connection_status();
|
||||||
|
|
||||||
|
for (curr = 1; curr <= 9; curr++) {
|
||||||
|
if (ui_win_exists(curr) && (ui_win_unread(curr) == 0)) {
|
||||||
|
if (conn_status == JABBER_CONNECTED) {
|
||||||
|
ui_close_connected_win(curr);
|
||||||
|
}
|
||||||
|
ui_close_win(curr);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ui_switch_win(const int i)
|
ui_switch_win(const int i)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ void ui_print_error_from_recipient(const char * const from, const char *err_msg)
|
|||||||
void ui_print_system_msg_from_recipient(const char * const from, const char *message);
|
void ui_print_system_msg_from_recipient(const char * const from, const char *message);
|
||||||
gint ui_unread(void);
|
gint ui_unread(void);
|
||||||
void ui_close_connected_win(int index);
|
void ui_close_connected_win(int index);
|
||||||
|
int ui_close_all_wins(void);
|
||||||
|
int ui_close_read_wins(void);
|
||||||
|
|
||||||
// current window actions
|
// current window actions
|
||||||
void ui_close_current(void);
|
void ui_close_current(void);
|
||||||
|
|||||||
Reference in New Issue
Block a user