static int sig_check_netjoins(void) { GSList *tmp, *next; int diff; for (tmp = joinservers; tmp != NULL; tmp = next) { NETJOIN_SERVER_REC *server = tmp->data; next = tmp->next; diff = time(NULL)-server->last_netjoin; if (diff <= NETJOIN_WAIT_TIME) { /* wait for more JOINs */ continue; } if (server->netjoins != NULL) print_netjoins(server); else if (diff >= NETJOIN_MAX_WAIT) { /* waited long enough, remove the netjoin */ netjoin_server_remove(server); } } if (joinservers == NULL) { g_source_remove(join_tag); signal_remove("print starting", (SIGNAL_FUNC) sig_print_starting); join_tag = -1; } return 1; }
void fe_netjoin_deinit(void) { while (joinservers != NULL) netjoin_server_remove(joinservers->data); if (join_tag != -1) { g_source_remove(join_tag); signal_remove("print starting", (SIGNAL_FUNC) sig_print_starting); } signal_remove("setup changed", (SIGNAL_FUNC) read_settings); }
void fe_netjoin_deinit(void) { while (joinservers != NULL) netjoin_server_remove(joinservers->data); if (join_tag != -1) { g_source_remove(join_tag); signal_remove("print starting", (SIGNAL_FUNC) sig_print_starting); } signal_remove("setup changed", (SIGNAL_FUNC) read_settings); signal_remove("message quit", (SIGNAL_FUNC) msg_quit); signal_remove("message join", (SIGNAL_FUNC) msg_join); signal_remove("message irc mode", (SIGNAL_FUNC) msg_mode); }
static int sig_check_netjoins(void) { GSList *tmp, *next; int diff; time_t now; now = time(NULL); /* first print all netjoins which haven't had any new joins * for NETJOIN_WAIT_TIME; this may cause them to be removed * (all users who rejoined, rejoined all channels) */ for (tmp = joinservers; tmp != NULL; tmp = next) { NETJOIN_SERVER_REC *server = tmp->data; next = tmp->next; diff = now-server->last_netjoin; if (diff <= NETJOIN_WAIT_TIME) { /* wait for more JOINs */ continue; } if (server->netjoins != NULL) print_netjoins(server, NULL); } /* now remove all netjoins which haven't had any new joins * for NETJOIN_MAX_WAIT (user rejoined some but not all channels * after split) */ for (tmp = joinservers; tmp != NULL; tmp = next) { NETJOIN_SERVER_REC *server = tmp->data; next = tmp->next; diff = now-server->last_netjoin; if (diff >= NETJOIN_MAX_WAIT) { /* waited long enough, forget about the rest */ netjoin_server_remove(server); } } if (joinservers == NULL) { g_source_remove(join_tag); signal_remove("print starting", (SIGNAL_FUNC) sig_print_starting); join_tag = -1; } return 1; }
static void print_netjoins(NETJOIN_SERVER_REC *server) { TEMP_PRINT_REC *temp; GHashTable *channels; GSList *tmp, *next, *old; g_return_if_fail(server != NULL); printing_joins = TRUE; /* save nicks to string, clear now_channels and remove the same channels from old_channels list */ channels = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal); for (tmp = server->netjoins; tmp != NULL; tmp = next) { NETJOIN_REC *rec = tmp->data; next = tmp->next; while (rec->now_channels != NULL) { char *channel = rec->now_channels->data; char *realchannel = channel + isnickflag(*channel); temp = g_hash_table_lookup(channels, realchannel); if (temp == NULL) { temp = g_new0(TEMP_PRINT_REC, 1); temp->nicks = g_string_new(NULL); g_hash_table_insert(channels, g_strdup(realchannel), temp); } temp->count++; if (temp->count <= netjoin_max_nicks) { if (isnickflag(*channel)) g_string_append_c(temp->nicks, *channel); g_string_sprintfa(temp->nicks, "%s, ", rec->nick); } /* remove the channel from old_channels too */ old = gslist_find_icase_string(rec->old_channels, realchannel); if (old != NULL) { g_free(old->data); rec->old_channels = g_slist_remove(rec->old_channels, old->data); } g_free(channel); rec->now_channels = g_slist_remove(rec->now_channels, channel); } if (rec->old_channels == NULL) netjoin_remove(server, rec); } g_hash_table_foreach(channels, (GHFunc) print_channel_netjoins, server); g_hash_table_destroy(channels); if (server->netjoins == NULL) netjoin_server_remove(server); printing_joins = FALSE; }
static void print_netjoins(NETJOIN_SERVER_REC *server, const char *filter_channel) { TEMP_PRINT_REC *temp; GHashTable *channels; GSList *tmp, *tmp2, *next, *next2, *old; g_return_if_fail(server != NULL); printing_joins = TRUE; /* save nicks to string, clear now_channels and remove the same channels from old_channels list */ channels = g_hash_table_new((GHashFunc) g_istr_hash, (GCompareFunc) g_istr_equal); for (tmp = server->netjoins; tmp != NULL; tmp = next) { NETJOIN_REC *rec = tmp->data; next = g_slist_next(tmp); for (tmp2 = rec->now_channels; tmp2 != NULL; tmp2 = next2) { char *channel = tmp2->data; char *realchannel = channel + 1; next2 = g_slist_next(tmp2); /* Filter the results by channel if asked to do so */ if (filter_channel != NULL && strcasecmp(realchannel, filter_channel) != 0) continue; temp = g_hash_table_lookup(channels, realchannel); if (temp == NULL) { temp = g_new0(TEMP_PRINT_REC, 1); temp->nicks = g_string_new(NULL); g_hash_table_insert(channels, g_strdup(realchannel), temp); } temp->count++; if (temp->count <= netjoin_max_nicks) { if (*channel != ' ') g_string_append_c(temp->nicks, *channel); g_string_append_printf(temp->nicks, "%s, ", rec->nick); } /* remove the channel from old_channels too */ old = gslist_find_icase_string(rec->old_channels, realchannel); if (old != NULL) { void *data = old->data; rec->old_channels = g_slist_remove(rec->old_channels, data); g_free(data); } /* drop tmp2 from the list */ rec->now_channels = g_slist_delete_link(rec->now_channels, tmp2); g_free(channel); } if (rec->old_channels == NULL) netjoin_remove(server, rec); } g_hash_table_foreach(channels, (GHFunc) print_channel_netjoins, server); g_hash_table_destroy(channels); if (server->netjoins == NULL) netjoin_server_remove(server); printing_joins = FALSE; }