static GList * get_channels(XMPP_SERVER_REC *server, const char *word) { GSList *tmp; GList *list; CHANNEL_REC *channel; CHANNEL_SETUP_REC *channel_setup; int len; g_return_val_if_fail(IS_XMPP_SERVER(server), NULL); g_return_val_if_fail(word != NULL, NULL); len = strlen(word); list = NULL; for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { channel = CHANNEL(tmp->data); if (channel != NULL && g_ascii_strncasecmp(channel->name, word, len) == 0) list = g_list_append(list, g_strdup(channel->name)); } for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) { channel_setup = tmp->data; if ((PROTO_CHECK_CAST(channel_setup, CHANNEL_SETUP_REC, chat_type, XMPP_PROTOCOL_NAME) || *channel_setup->name != '#') && g_ascii_strncasecmp(channel_setup->name, word, len) == 0 && glist_find_string(list, channel_setup->name) == NULL) list = g_list_append(list, g_strdup(channel_setup->name)); } return list; }
void quassel_irssi_set_last_seen_msg(void *arg, int buffer_id, int msgid) { (void) msgid; Quassel_SERVER_REC *server = (Quassel_SERVER_REC*)arg; if(!PROTO_CHECK_CAST(SERVER(server), Quassel_SERVER_REC, chat_type, "Quassel")) return; Quassel_CHANNEL_REC* chanrec = NULL; //First find channel GSList *chans = server->channels; while(chans) { chanrec = (Quassel_CHANNEL_REC*) chans->data; if(chanrec->buffer_id == buffer_id) break; chanrec = NULL; chans = g_slist_next(chans); } if(!chanrec) return; chanrec->last_seen_msg_id = msgid; if(chanrec->init_last_seen_msg_id == -1) chanrec->init_last_seen_msg_id = msgid; //Now find windows GSList *win = windows; while(win) { WINDOW_REC* winrec = (WINDOW_REC*) win->data; if(winrec->active_server != SERVER(server) && winrec->connect_server != SERVER(server)) goto next; if(!winrec->active) goto next; if(strcmp(winrec->active->visible_name, chanrec->name)==0) { signal_emit("window dehilight", 1, winrec); if(winrec != active_win) { LINE_REC *linerec = textbuffer_view_get_bookmark(WINDOW_GUI(winrec)->view, "trackbar"); if(linerec) textbuffer_view_remove_line(WINDOW_GUI(winrec)->view, linerec); char *str = malloc(winrec->width+3); str[0] = '%'; str[1] = 'K'; for(int i=0; i<winrec->width; ++i) str[i+2]='-'; str[winrec->width+2]=0; printtext_string_window(winrec, MSGLEVEL_NEVER, str); free(str); textbuffer_view_set_bookmark_bottom(WINDOW_GUI(winrec)->view, "trackbar"); } } next: win = g_slist_next(win); } }
static Quassel_CHANNEL_REC* window2chanrec(WINDOW_REC *window) { if(!window) return NULL; WI_ITEM_REC *wi = window->active; if(!wi) return NULL; Quassel_SERVER_REC *server = (Quassel_SERVER_REC*)wi->server; if(!PROTO_CHECK_CAST(SERVER(server), Quassel_SERVER_REC, chat_type, "Quassel")) return NULL; Quassel_CHANNEL_REC *chanrec = (Quassel_CHANNEL_REC*) channel_find(SERVER(server), wi->visible_name); return chanrec; }