static void c_msg(char *args) { char *sep = strchr(args, ' '); if(sep) { *sep = 0; while(*(++sep) == ' '); } struct ui_tab *tab = ui_tab_cur->data; if(tab->type != UIT_HUB && tab->type != UIT_MSG) ui_m(NULL, 0, "This command can only be used on hub and message tabs."); else if(!tab->hub->nick_valid) ui_m(NULL, 0, "Not connected or logged in yet."); else if(!args[0]) ui_m(NULL, 0, "No user specified. See `/help msg' for more information."); else { struct hub_user *u = hub_user_get(tab->hub, args); if(!u) ui_m(NULL, 0, "No user found with that name. Note that usernames are case-sensitive."); else { // get or open tab and make sure it's selected struct ui_tab *t = g_hash_table_lookup(ui_msg_tabs, &u->uid); if(!t) ui_tab_open(ui_msg_create(tab->hub, u), TRUE, tab); else ui_tab_cur = g_list_find(ui_tabs, t); // if we need to send something, do so if(sep && *sep) hub_msg(tab->hub, u, sep, FALSE, 0); } } }
// Opens the user list for a hub and selects the user specified by uid or // user/utf8. Returns FALSE if a user was specified but could not be found. gboolean uit_userlist_open(hub_t *hub, guint64 uid, const char *user, gboolean utf8) { hub_user_t *u = !uid && !user ? NULL : uid ? g_hash_table_lookup(hub_uids, &uid) : utf8 ? hub_user_get(hub, user) : g_hash_table_lookup(hub->users, user); if((uid || user) && (!u || u->hub != hub)) return FALSE; ui_tab_t *ut = uit_hub_userlist(hub->tab); if(ut) ui_tab_cur = g_list_find(ui_tabs, ut); else { ut = uit_userlist_create(hub); ui_tab_open(ut, TRUE, hub->tab); uit_hub_set_userlist(hub->tab, ut); } if(u) { tab_t *t = (tab_t *)ut; // u->iter should be valid at this point. t->list->sel = u->iter; t->details = TRUE; } return TRUE; }
static void open_autoconnect() { char **hubs = db_vars_hubs(); char **hub; // TODO: make sure the tabs are opened in the same order as they were in the last run? for(hub=hubs; *hub; hub++) if(var_get_bool(db_vars_hubid(*hub), VAR_autoconnect)) ui_tab_open(uit_hub_create(*hub+1, TRUE), FALSE, NULL); listen_refresh(); g_strfreev(hubs); }