static WinStatus tray_get_window_status(void) { session *sess = sess_list->data; switch (fe_gui_info(sess, 0)) { case 0: return WS_NORMAL; case 1: return WS_FOCUSED; case 2: default: return WS_HIDDEN; } }
const char * hexchat_get_info (hexchat_plugin *ph, const char *id) { session *sess; guint32 hash; /* 1234567890 */ if (!strncmp (id, "event_text", 10)) { char *e = (char *)id + 10; if (*e == ' ') e++; /* 2.8.0 only worked without a space */ return text_find_format_string (e); } hash = str_hash (id); /* do the session independant ones first */ switch (hash) { case 0x325acab5: /* libdirfs */ #ifdef USE_PLUGIN return plugin_get_libdir (); #else return NULL; #endif case 0x14f51cd8: /* version */ return PACKAGE_VERSION; case 0xdd9b1abd: /* xchatdir */ case 0xe33f6c4a: /* xchatdirfs */ case 0xd00d220b: /* configdir */ return get_xdir (); } sess = ph->context; if (!is_session (sess)) { DEBUG(PrintTextf(0, "%s\thexchat_get_info called without a valid context.\n", ph->name)); return NULL; } switch (hash) { case 0x2de2ee: /* away */ if (sess->server->is_away) return sess->server->last_away_reason; return NULL; case 0x2c0b7d03: /* channel */ return sess->channel; case 0x2c0d614c: /* charset */ { const char *locale; if (sess->server->encoding) return sess->server->encoding; locale = NULL; g_get_charset (&locale); return locale; } case 0x30f5a8: /* host */ return sess->server->hostname; case 0x1c0e99c1: /* inputbox */ return fe_get_inputbox_contents (sess); case 0x633fb30: /* modes */ return sess->current_modes; case 0x6de15a2e: /* network */ return server_get_network (sess->server, FALSE); case 0x339763: /* nick */ return sess->server->nick; case 0x4889ba9b: /* password */ case 0x438fdf9: /* nickserv */ if (sess->server->network) return ((ircnet *)sess->server->network)->pass; return NULL; case 0xca022f43: /* server */ if (!sess->server->connected) return NULL; return sess->server->servername; case 0x696cd2f: /* topic */ return sess->topic; case 0x3419f12d: /* gtkwin_ptr */ return fe_gui_info_ptr (sess, 1); case 0x506d600b: /* native win_ptr */ return fe_gui_info_ptr (sess, 0); case 0x6d3431b5: /* win_status */ switch (fe_gui_info (sess, 0)) /* check window status */ { case 0: return "normal"; case 1: return "active"; case 2: return "hidden"; } return NULL; } return NULL; }
const char* xchat_get_info(xchat_plugin *ph, const char *id) { session *sess; unsigned int hash; // 1234567890 if (!strncmp(id, "event_text", 10)) { char *e = (char*)id + 10; if (*e == ' ') e++; // 2.8.0 only worked without a space return text_find_format_string(e); } hash = str_hash(id); // do the session independant ones first switch (hash) { case 0x325acab5: // libdirfs return XCHATLIBDIR; case 0x14f51cd8: // version return PACKAGE_VERSION; case 0xdd9b1abd: // xchatdir return get_xdir_utf8(); case 0xe33f6c4a: // xchatdirfs return get_xdir_fs(); } sess = ph->context; if (!is_session(sess)) { DEBUG(PrintTextf(0, "%s\txchat_get_info called without a valid context.\n", ph->name)); return nullptr; } switch (hash) { case 0x2de2ee: // away if (sess->server->is_away) return sess->server->last_away_reason; return nullptr; case 0x2c0b7d03: // channel return sess->channel; case 0x2c0d614c: // charset { const char *locale; if (sess->server->encoding) return sess->server->encoding; locale = nullptr; g_get_charset(&locale); return locale; } case 0x30f5a8: // host return sess->server->hostname; case 0x1c0e99c1: // inputbox return fe_get_inputbox_contents(sess); case 0x633fb30: // modes return sess->current_modes; case 0x6de15a2e: // network return server_get_network(sess->server, FALSE); case 0x339763: // nick return sess->server->nick; case 0x438fdf9: // nickserv if (sess->server->network) return ((ircnet*)sess->server->network)->nickserv; return nullptr; case 0xca022f43: // server if (!sess->server->connected) return nullptr; return sess->server->servername; case 0x696cd2f: // topic return sess->topic; case 0x3419f12d: // gtkwin_ptr return (const char*)fe_gui_info_ptr(sess, 1); case 0x506d600b: // native win_ptr return (const char*)fe_gui_info_ptr(sess, 0); case 0x6d3431b5: // win_status switch (fe_gui_info(sess, 0)) // check window status { case 0: return "normal"; case 1: return "active"; case 2: return "hidden"; } return nullptr; } return nullptr; }