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 void sig_window_changed(WINDOW_REC *active, WINDOW_REC *old) { window_read(active); window_read(old); textbuffer_view_set_bookmark_bottom(WINDOW_GUI(active)->view, "useless_end"); LINE_REC *linerec = textbuffer_view_get_bookmark(WINDOW_GUI(active)->view, "trackbar"); LINE_REC *last_line = textbuffer_view_get_bookmark(WINDOW_GUI(active)->view, "useless_end"); if(linerec == last_line && linerec) textbuffer_view_remove_line(WINDOW_GUI(active)->view, linerec); }
static void sig_away_changed(SERVER_REC *server) { GSList *tmp; if (!server->usermode_away) return; for (tmp = windows; tmp != NULL; tmp = tmp->next) { WINDOW_REC *rec = tmp->data; textbuffer_view_set_bookmark_bottom(WINDOW_GUI(rec)->view, "lastlog_last_away"); } }
static void show_lastlog(const char *searchtext, GHashTable *optlist, int start, int count, FILE *fhandle) { WINDOW_REC *window; LINE_REC *startline; GList *list, *tmp; GString *line; char *str; int level, before, after, len, date = FALSE; level = cmd_options_get_level("lastlog", optlist); if (level == -1) return; /* error in options */ if (level == 0) level = MSGLEVEL_ALL; if (g_hash_table_lookup(optlist, "clear") != NULL) { textbuffer_view_remove_lines_by_level(WINDOW_GUI(active_win)->view, MSGLEVEL_LASTLOG); if (*searchtext == '\0') return; } /* which window's lastlog to look at? */ window = active_win; str = g_hash_table_lookup(optlist, "window"); if (str != NULL) { window = is_numeric(str, '\0') ? window_find_refnum(atoi(str)) : window_find_item(NULL, str); if (window == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_REFNUM_NOT_FOUND, str); return; } } if (g_hash_table_lookup(optlist, "new") != NULL) startline = textbuffer_view_get_bookmark(WINDOW_GUI(window)->view, "lastlog_last_check"); else if (g_hash_table_lookup(optlist, "away") != NULL) startline = textbuffer_view_get_bookmark(WINDOW_GUI(window)->view, "lastlog_last_away"); else startline = NULL; if (startline == NULL) startline = textbuffer_view_get_lines(WINDOW_GUI(window)->view); str = g_hash_table_lookup(optlist, "#"); if (str != NULL) { before = after = atoi(str); } else { str = g_hash_table_lookup(optlist, "before"); before = str == NULL ? 0 : *str != '\0' ? atoi(str) : DEFAULT_LASTLOG_BEFORE; str = g_hash_table_lookup(optlist, "after"); if (str == NULL) str = g_hash_table_lookup(optlist, "a"); after = str == NULL ? 0 : *str != '\0' ? atoi(str) : DEFAULT_LASTLOG_AFTER; } if (g_hash_table_lookup(optlist, "date") != NULL) date = TRUE; list = textbuffer_find_text(WINDOW_GUI(window)->view->buffer, startline, level, MSGLEVEL_LASTLOG, searchtext, before, after, g_hash_table_lookup(optlist, "regexp") != NULL, g_hash_table_lookup(optlist, "word") != NULL, g_hash_table_lookup(optlist, "case") != NULL); len = g_list_length(list); if (count <= 0) tmp = list; else { int pos = len-count-start; if (pos < 0) pos = 0; tmp = pos > len ? NULL : g_list_nth(list, pos); len = g_list_length(tmp); } if (g_hash_table_lookup(optlist, "count") != NULL) { printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, TXT_LASTLOG_COUNT, len); g_list_free(list); return; } if (len > MAX_LINES_WITHOUT_FORCE && fhandle == NULL && g_hash_table_lookup(optlist, "force") == NULL) { printformat_window(active_win, MSGLEVEL_CLIENTNOTICE|MSGLEVEL_LASTLOG, TXT_LASTLOG_TOO_LONG, len); g_list_free(list); return; } if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL) printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_START); line = g_string_new(NULL); while (tmp != NULL && (count < 0 || count > 0)) { LINE_REC *rec = tmp->data; if (rec == NULL) { if (tmp->next == NULL) break; if (fhandle != NULL) { fwrite("--\n", 3, 1, fhandle); } else { printformat_window(active_win, MSGLEVEL_LASTLOG, TXT_LASTLOG_SEPARATOR); } tmp = tmp->next; continue; } /* get the line text */ textbuffer_line2text(rec, fhandle == NULL, line); if (!settings_get_bool("timestamps")) { struct tm *tm = localtime(&rec->info.time); char timestamp[10]; g_snprintf(timestamp, sizeof(timestamp), "%02d:%02d ", tm->tm_hour, tm->tm_min); g_string_prepend(line, timestamp); } if (date == TRUE) prepend_date(window, rec, line); /* write to file/window */ if (fhandle != NULL) { fwrite(line->str, line->len, 1, fhandle); fputc('\n', fhandle); } else { printtext_window(active_win, MSGLEVEL_LASTLOG, "%s", line->str); } count--; tmp = tmp->next; } g_string_free(line, TRUE); if (fhandle == NULL && g_hash_table_lookup(optlist, "-") == NULL) printformat(NULL, NULL, MSGLEVEL_LASTLOG, TXT_LASTLOG_END); textbuffer_view_set_bookmark_bottom(WINDOW_GUI(window)->view, "lastlog_last_check"); g_list_free(list); }