-
-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some fixes #1941
Some fixes #1941
Changes from all commits
64046bc
ff32f51
2b51675
c3ed0c3
629cd33
31c6d5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -259,6 +259,7 @@ iq_handlers_init(void) | |
int millis = prefs_get_autoping() * 1000; | ||
xmpp_timed_handler_add(conn, _autoping_timed_send, millis, ctx); | ||
} | ||
received_disco_items = FALSE; | ||
|
||
iq_rooms_cache_clear(); | ||
iq_handlers_clear(); | ||
|
@@ -267,8 +268,56 @@ iq_handlers_init(void) | |
rooms_cache = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)xmpp_stanza_release); | ||
} | ||
|
||
struct iq_win_finder | ||
{ | ||
gsize max, cur; | ||
char** to_be_removed; | ||
}; | ||
|
||
static void | ||
_win_find(char* key, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it appears that the name mismatches the purpose, maybe rather something like |
||
ProfIqHandler* handler, | ||
struct iq_win_finder* finder) | ||
{ | ||
if (handler->func == _mam_rsm_id_handler) { | ||
if (finder->cur >= finder->max) { | ||
finder->max *= 2; | ||
finder->to_be_removed = g_realloc_n(finder->to_be_removed, finder->max, sizeof(char*)); | ||
} | ||
finder->to_be_removed[finder->cur++] = g_strdup(key); | ||
} | ||
} | ||
|
||
void | ||
iq_handlers_remove_win(ProfWin* window) | ||
{ | ||
log_debug("Remove window %p of type %d", window, window ? window->type : -1); | ||
if (!window) | ||
return; | ||
GSList *cur = late_delivery_windows, *next; | ||
while (cur) { | ||
LateDeliveryUserdata* del_data = cur->data; | ||
next = g_slist_next(cur); | ||
if (del_data->win == (void*)window) | ||
late_delivery_windows = g_slist_delete_link(late_delivery_windows, | ||
cur); | ||
cur = next; | ||
jubalh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
struct iq_win_finder st = { 0 }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. undescriptive variable name, something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also another suggestion: make a blank space between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, it's a bit strange approach to make your own dynamic array and structure just for this, why not something like this for readability? (let's call it static void
_mam_win_match_add(char* key, ProfIqHandler* handler, GArray* to_be_removed)
{
if (handler->func == _mam_rsm_id_handler) {
// Append the element to the array
g_array_append_val(to_be_removed, g_strdup(key));
}
}
GArray* to_be_removed = g_array_new(FALSE, FALSE, sizeof(char*));
// Iterate through id_handlers and call _mam_win_match_add for each entry to identify windows to be removed.
g_hash_table_foreach(id_handlers, (GHFunc)_mam_win_match_add, to_be_removed);
// Access elements using g_array_index and free each element
for (guint n = 0; n < to_be_removed->len; ++n) {
char* to_remove = g_array_index(to_be_removed, char*, n);
g_hash_table_remove(id_handlers, to_remove);
}
g_array_free(to_be_removed, TRUE); |
||
st.max = g_hash_table_size(id_handlers); | ||
if (st.max == 0) | ||
return; | ||
st.to_be_removed = g_new(char*, st.max); | ||
g_hash_table_foreach(id_handlers, (GHFunc)_win_find, &st); | ||
for (gsize n = 0; n < st.cur; ++n) { | ||
g_hash_table_remove(id_handlers, st.to_be_removed[n]); | ||
g_free(st.to_be_removed[n]); | ||
} | ||
g_free(st.to_be_removed); | ||
} | ||
|
||
void | ||
iq_handlers_clear() | ||
iq_handlers_clear(void) | ||
{ | ||
if (id_handlers) { | ||
g_hash_table_remove_all(id_handlers); | ||
|
@@ -2696,6 +2745,10 @@ _mam_rsm_id_handler(xmpp_stanza_t* const stanza, void* const userdata) | |
gboolean is_complete = g_strcmp0(xmpp_stanza_get_attribute(fin, "complete"), "true") == 0; | ||
MamRsmUserdata* data = (MamRsmUserdata*)userdata; | ||
ProfWin* window = (ProfWin*)data->win; | ||
if (wins_get_num(window) == -1) { | ||
log_error("Window %p should not get any events anymore", window); | ||
return 0; | ||
} | ||
|
||
buffer_remove_entry(window->layout->buffer, 0); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1261,7 +1261,7 @@ _handle_muc_private_message(xmpp_stanza_t* const stanza) | |
ProfMessage* message = message_init(); | ||
message->type = PROF_MSG_TYPE_MUCPM; | ||
|
||
const gchar* from = xmpp_stanza_get_from(stanza); | ||
const char* from = xmpp_stanza_get_from(stanza); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are few more cases, I suggest to catch all of them, using regex: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to open another PR with those changes. |
||
if (!from) { | ||
goto out; | ||
} | ||
|
@@ -1360,7 +1360,7 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c | |
return; | ||
} | ||
|
||
const gchar* from = xmpp_stanza_get_from(stanza); | ||
const char* from = xmpp_stanza_get_from(stanza); | ||
if (!from) { | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
max
can be more descriptive? E.g.max_size