mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-20 20:16:21 +00:00
Refactored all window recipients and types
Tests need fixing
This commit is contained in:
@@ -99,7 +99,7 @@ wins_get_chat(const char * const barejid)
|
||||
}
|
||||
|
||||
ProfMucConfWin *
|
||||
wins_get_muc_conf_win(const char * const title)
|
||||
wins_get_muc_conf(const char * const title)
|
||||
{
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
GList *curr = values;
|
||||
@@ -121,16 +121,18 @@ wins_get_muc_conf_win(const char * const title)
|
||||
}
|
||||
|
||||
ProfMucWin *
|
||||
wins_get_muc_win(const char * const roomjid)
|
||||
wins_get_muc(const char * const roomjid)
|
||||
{
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
GList *curr = values;
|
||||
|
||||
while (curr != NULL) {
|
||||
ProfWin *window = curr->data;
|
||||
if ((g_strcmp0(window->from, roomjid) == 0) && window->type == WIN_MUC) {
|
||||
g_list_free(values);
|
||||
return (ProfMucWin*)window;
|
||||
if (window->type == WIN_MUC) {
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
if (g_strcmp0(mucwin->roomjid, roomjid) == 0) {
|
||||
return mucwin;
|
||||
}
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@@ -372,7 +374,7 @@ wins_get_num(ProfWin *window)
|
||||
while (curr != NULL) {
|
||||
gconstpointer num_p = curr->data;
|
||||
ProfWin *curr_win = g_hash_table_lookup(windows, num_p);
|
||||
if (g_strcmp0(curr_win->from, window->from) == 0) {
|
||||
if (curr_win == window) {
|
||||
g_list_free(keys);
|
||||
return GPOINTER_TO_INT(num_p);
|
||||
}
|
||||
@@ -426,7 +428,7 @@ wins_is_current(ProfWin *window)
|
||||
{
|
||||
ProfWin *current_window = wins_get_current();
|
||||
|
||||
if (g_strcmp0(current_window->from, window->from) == 0) {
|
||||
if (current_window == window) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@@ -438,10 +440,10 @@ wins_new_xmlconsole(void)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = get_next_available_win_num(keys);
|
||||
ProfWin *new = win_create_xmlconsole();
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), new);
|
||||
ProfWin *newwin = win_create_xmlconsole();
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
g_list_free(keys);
|
||||
return new;
|
||||
return newwin;
|
||||
}
|
||||
|
||||
ProfWin *
|
||||
@@ -449,10 +451,10 @@ wins_new_chat(const char * const barejid)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = get_next_available_win_num(keys);
|
||||
ProfWin *new = win_create_chat(barejid);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), new);
|
||||
ProfWin *newwin = win_create_chat(barejid);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
g_list_free(keys);
|
||||
return new;
|
||||
return newwin;
|
||||
}
|
||||
|
||||
ProfWin *
|
||||
@@ -460,10 +462,10 @@ wins_new_muc(const char * const roomjid)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = get_next_available_win_num(keys);
|
||||
ProfWin *new = win_create_muc(roomjid);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), new);
|
||||
ProfWin *newwin = win_create_muc(roomjid);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
g_list_free(keys);
|
||||
return new;
|
||||
return newwin;
|
||||
}
|
||||
|
||||
ProfWin *
|
||||
@@ -471,10 +473,10 @@ wins_new_muc_config(const char * const title, DataForm *form)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = get_next_available_win_num(keys);
|
||||
ProfWin *new = win_create_muc_config(title, form);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), new);
|
||||
ProfWin *newwin = win_create_muc_config(title, form);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
g_list_free(keys);
|
||||
return new;
|
||||
return newwin;
|
||||
}
|
||||
|
||||
ProfWin *
|
||||
@@ -482,10 +484,10 @@ wins_new_private(const char * const fulljid)
|
||||
{
|
||||
GList *keys = g_hash_table_get_keys(windows);
|
||||
int result = get_next_available_win_num(keys);
|
||||
ProfWin *new = win_create_private(fulljid);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), new);
|
||||
ProfWin *newwin = win_create_private(fulljid);
|
||||
g_hash_table_insert(windows, GINT_TO_POINTER(result), newwin);
|
||||
g_list_free(keys);
|
||||
return new;
|
||||
return newwin;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -627,7 +629,8 @@ wins_get_chat_recipients(void)
|
||||
while (curr != NULL) {
|
||||
ProfWin *window = curr->data;
|
||||
if (window->type == WIN_CHAT) {
|
||||
result = g_slist_append(result, window->from);
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
result = g_slist_append(result, chatwin->barejid);
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@@ -636,7 +639,7 @@ wins_get_chat_recipients(void)
|
||||
}
|
||||
|
||||
GSList *
|
||||
wins_get_prune_recipients(void)
|
||||
wins_get_prune_wins(void)
|
||||
{
|
||||
GSList *result = NULL;
|
||||
GList *values = g_hash_table_get_values(windows);
|
||||
@@ -649,7 +652,7 @@ wins_get_prune_recipients(void)
|
||||
window->type != WIN_MUC_CONFIG &&
|
||||
window->type != WIN_XML &&
|
||||
window->type != WIN_CONSOLE) {
|
||||
result = g_slist_append(result, window->from);
|
||||
result = g_slist_append(result, window);
|
||||
}
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
@@ -813,9 +816,10 @@ wins_create_summary(void)
|
||||
case WIN_CHAT:
|
||||
chat_string = g_string_new("");
|
||||
|
||||
PContact contact = roster_get_contact(window->from);
|
||||
ProfChatWin *chatwin = (ProfChatWin*)window;
|
||||
PContact contact = roster_get_contact(chatwin->barejid);
|
||||
if (contact == NULL) {
|
||||
g_string_printf(chat_string, "%d: Chat %s", ui_index, window->from);
|
||||
g_string_printf(chat_string, "%d: Chat %s", ui_index, chatwin->barejid);
|
||||
} else {
|
||||
const char *display_name = p_contact_name_or_jid(contact);
|
||||
g_string_printf(chat_string, "%d: Chat %s", ui_index, display_name);
|
||||
@@ -839,7 +843,8 @@ wins_create_summary(void)
|
||||
|
||||
case WIN_PRIVATE:
|
||||
priv_string = g_string_new("");
|
||||
g_string_printf(priv_string, "%d: Private %s", ui_index, window->from);
|
||||
ProfPrivateWin *privatewin = (ProfPrivateWin*)window;
|
||||
g_string_printf(priv_string, "%d: Private %s", ui_index, privatewin->fulljid);
|
||||
|
||||
if (window->unread > 0) {
|
||||
GString *priv_unread = g_string_new("");
|
||||
@@ -855,7 +860,8 @@ wins_create_summary(void)
|
||||
|
||||
case WIN_MUC:
|
||||
muc_string = g_string_new("");
|
||||
g_string_printf(muc_string, "%d: Room %s", ui_index, window->from);
|
||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||
g_string_printf(muc_string, "%d: Room %s", ui_index, mucwin->roomjid);
|
||||
|
||||
if (window->unread > 0) {
|
||||
GString *muc_unread = g_string_new("");
|
||||
@@ -871,7 +877,8 @@ wins_create_summary(void)
|
||||
|
||||
case WIN_MUC_CONFIG:
|
||||
muc_config_string = g_string_new("");
|
||||
g_string_printf(muc_config_string, "%d: %s", ui_index, window->from);
|
||||
ProfMucConfWin *confwin = (ProfMucConfWin*)window;
|
||||
g_string_printf(muc_config_string, "%d: %s", ui_index, confwin->from);
|
||||
if (win_has_modified_form(window)) {
|
||||
g_string_append(muc_config_string, " *");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user