int hexchat_plugin_init (hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { ph = plugin_handle; *plugin_name = name; *plugin_desc = desc; *plugin_version = version; char buffer[bsize]; hexchat_hook_command (ph, "SYSINFO", HEXCHAT_PRI_NORM, sysinfo_cb, sysinfo_help, NULL); hexchat_hook_command (ph, "NETDATA", HEXCHAT_PRI_NORM, netdata_cb, NULL, NULL); hexchat_hook_command (ph, "NETSTREAM", HEXCHAT_PRI_NORM, netstream_cb, NULL, NULL); /* this is required for the very first run */ if (hexchat_pluginpref_get_str (ph, "pciids", buffer) == 0) { hexchat_pluginpref_set_str (ph, "pciids", DEFAULT_PCIIDS); } if (hexchat_pluginpref_get_str (ph, "format", buffer) == 0) { hexchat_pluginpref_set_str (ph, "format", DEFAULT_FORMAT); } if (hexchat_pluginpref_get_int (ph, "percent") == -1) { hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT); } hexchat_command (ph, "MENU ADD \"Window/Display System Info\" \"SYSINFO\""); hexchat_printf (ph, "%s plugin loaded\n", name); return 1; }
static void reset_settings () { hexchat_pluginpref_set_str (ph, "pciids", DEFAULT_PCIIDS); hexchat_pluginpref_set_str (ph, "format", DEFAULT_FORMAT); hexchat_pluginpref_set_int (ph, "percent", DEFAULT_PERCENT); }
static int api_hexchat_pluginprefs_meta_newindex(lua_State *L) { script_info *script = get_info(L); const char *key; hexchat_plugin *h; if(!script->name) return luaL_error(L, "cannot use hexchat.pluginprefs before registering with hexchat.register"); key = luaL_checkstring(L, 2); h = script->handle; switch(lua_type(L, 3)) { case LUA_TSTRING: hexchat_pluginpref_set_str(h, key, lua_tostring(L, 3)); return 0; case LUA_TNUMBER: hexchat_pluginpref_set_int(h, key, lua_tointeger(L, 3)); return 0; case LUA_TNIL: case LUA_TNONE: hexchat_pluginpref_delete(h, key); return 0; default: return luaL_argerror(L, 3, "expected string, number, or nil"); } }
static int add_info (char const* login, char const* password, char const* network) { char buffer[512]; sprintf (buffer, "%s:%s", login, password); return hexchat_pluginpref_set_str (ph, network, buffer); }
void SavePrefs(int iDlg) { hexchat_pluginpref_set_int (ph, "settings", g_dwPrefs); hexchat_pluginpref_set_int (ph, "aot", g_iTime); hexchat_pluginpref_set_int (ph, "key", g_hHotKey.key); hexchat_pluginpref_set_int (ph, "mod", g_hHotKey.mod); hexchat_pluginpref_set_str (ph, "away", (const char*) g_szAway); }
static XS (XS_HexChat_plugin_pref_set) { dMARK; dAX; XSRETURN_IV ((IV) hexchat_pluginpref_set_str (ph, SvPV_nolen (ST (0)), SvPV_nolen (ST (1)))); }
static int sysinfo_cb (char *word[], char *word_eol[], void *userdata) { error_printed = 0; int announce = 0; int buffer; char format[bsize]; if (!hexchat_pluginpref_get_str (ph, "format", format)) { hexchat_printf (ph, "%s\tError reading config file!", name); return HEXCHAT_EAT_ALL; } if (hexchat_list_int (ph, NULL, "type") >= 2) { announce = 1; } if (!g_ascii_strcasecmp ("HELP", word[2])) { hexchat_printf (ph, sysinfo_help); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("LIST", word[2])) { list_settings (); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("SET", word[2])) { if (!g_ascii_strcasecmp ("", word_eol[4])) { hexchat_printf (ph, "%s\tEnter a value!\n", name); return HEXCHAT_EAT_ALL; } if (!g_ascii_strcasecmp ("format", word[3])) { hexchat_pluginpref_set_str (ph, "format", word_eol[4]); hexchat_printf (ph, "%s\tformat is set to: %s\n", name, word_eol[4]); } else if (!g_ascii_strcasecmp ("percent", word[3])) { buffer = atoi (word[4]); /* don't use word_eol, numbers must not contain spaces */ if (buffer > 0 && buffer < INT_MAX) { hexchat_pluginpref_set_int (ph, "percent", buffer); hexchat_printf (ph, "%s\tpercent is set to: %d\n", name, buffer); } else { hexchat_printf (ph, "%s\tInvalid input!\n", name); } } else if (!g_ascii_strcasecmp ("pciids", word[3])) { hexchat_pluginpref_set_str (ph, "pciids", word_eol[4]); hexchat_printf (ph, "%s\tpciids is set to: %s\n", name, word_eol[4]); } else { hexchat_printf (ph, "%s\tInvalid variable name! Use 'pciids', 'format' or 'percent'!\n", name); return HEXCHAT_EAT_ALL; } return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("RESET", word[2])) { reset_settings (); hexchat_printf (ph, "%s\tSettings have been restored to defaults.\n", name); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("OS", word[2])) { print_os (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("DISTRO", word[2])) { print_distro (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("CPU", word[2])) { print_cpu (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("RAM", word[2])) { print_ram (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("DISK", word[2])) { print_disk (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("VGA", word[2])) { print_vga (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("SOUND", word[2])) { print_sound (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("ETHERNET", word[2])) { print_ethernet (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("UPTIME", word[2])) { print_uptime (announce, format); return HEXCHAT_EAT_ALL; } else if (!g_ascii_strcasecmp ("", word[2])) { print_summary (announce, format); return HEXCHAT_EAT_ALL; } else { hexchat_printf (ph, sysinfo_help); return HEXCHAT_EAT_ALL; } }
int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) { ph = plugin_handle; *plugin_name = "HexTray"; *plugin_desc = "Minimize HexChat to the Windows system tray"; *plugin_version = "1.3.0"; char buffer[256]; /***************************************************************************************************************************/ /************************* Initialize our preferences if they don't exist yet **********************************************/ /***************************************************************************************************************************/ if (hexchat_pluginpref_get_int (ph, "settings") == -1) { hexchat_pluginpref_set_int (ph, "settings", HT_DEF_SET); } if (hexchat_pluginpref_get_int (ph, "aot") == -1) { hexchat_pluginpref_set_int (ph, "aot", HT_DEF_AOT); } if (hexchat_pluginpref_get_int (ph, "key") == -1) { hexchat_pluginpref_set_int (ph, "key", HT_DEF_KEY); } if (hexchat_pluginpref_get_int (ph, "mod") == -1) { hexchat_pluginpref_set_int (ph, "mod", HT_DEF_MOD); } if (hexchat_pluginpref_get_str (ph, "away", buffer) == 0) { hexchat_pluginpref_set_str (ph, "away", ""); } /***************************************************************************************************************************/ /************************* Load our preferences ****************************************************************************/ /***************************************************************************************************************************/ LoadPrefs(); /***************************************************************************************************************************/ /************************* Finds the HexChat window and saves it for later use *********************************************/ /***************************************************************************************************************************/ g_hXchatWnd = (HWND)hexchat_get_info(ph, "win_ptr"); if(g_hXchatWnd == NULL) { EnumThreadWindows(GetCurrentThreadId(), EnumWindowsProc, 0); } g_hOldProc = (WNDPROC)GetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC); SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)WindowProc); /***************************************************************************************************************************/ /************************* Grab the HexChat Icon, Load our menu, create the window to receive the hotkey messages *********/ /************************* and register the windows message so we know if explorer crashes ***********/ /***************************************************************************************************************************/ g_hTrayMenu = GetSubMenu(LoadMenu((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDR_TRAY_MENU)), 0); g_hHotkeyWnd = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_ALERT), NULL, (DLGPROC)HotKeyProc); g_hPrefDlg = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_PREF), g_hXchatWnd, (DLGPROC)PrefProc); g_hIcons[0] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_XCHAT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[2] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_HIGHLIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[5] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_BANNED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[6] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_KICKED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[8] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_PMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[10]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_SNOTICE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[11]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_DISCONNECTED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); g_hIcons[22] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_CHANMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); /***************************************************************************************************************************/ /************************* Add our icon to the tray ************************************************************************/ /***************************************************************************************************************************/ char szVersion[64]; _snprintf(szVersion, 64, "HexChat %s", hexchat_get_info(ph, "version")); AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG); /***************************************************************************************************************************/ /***************************************************************************************************************************/ /***************************************************************************************************************************/ if(g_dwPrefs & (1<<PREF_DNSIT)) { DWORD dwStyle; dwStyle = GetWindowLong(g_hXchatWnd, GWL_STYLE); dwStyle |= (1<<WS_CHILD); SetWindowLongPtr(g_hXchatWnd, GWL_STYLE, (LONG_PTR)dwStyle); SetWindowLongPtr(g_hXchatWnd, GWL_HWNDPARENT, (LONG_PTR)g_hHotkeyWnd); } /***************************************************************************************************************************/ /************************* Set our hooks and save them for later so we can unhook them *************************************/ /***************************************************************************************************************************/ g_vHooks.push_back(hexchat_hook_print(ph, "Channel Msg Hilight", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_HILIGHT)); g_vHooks.push_back(hexchat_hook_print(ph, "Channel Message", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_MESSAGE)); g_vHooks.push_back(hexchat_hook_print(ph, "Topic Change", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_TOPIC_CHANGE)); g_vHooks.push_back(hexchat_hook_print(ph, "Channel Action Hilight", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_HILIGHT)); g_vHooks.push_back(hexchat_hook_print(ph, "Channel INVITE", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_INVITE)); g_vHooks.push_back(hexchat_hook_print(ph, "You Kicked", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_KICKED)); g_vHooks.push_back(hexchat_hook_print(ph, "Banned", HEXCHAT_PRI_NORM, event_cb, (void *)CHAN_BANNED)); g_vHooks.push_back(hexchat_hook_print(ph, "CTCP Generic", HEXCHAT_PRI_NORM, event_cb, (void *)CTCP_GENERIC)); g_vHooks.push_back(hexchat_hook_print(ph, "Private Message", HEXCHAT_PRI_NORM, event_cb, (void *)PMSG_RECEIVE)); g_vHooks.push_back(hexchat_hook_print(ph, "Private Message to Dialog", HEXCHAT_PRI_NORM, event_cb, (void *)PMSG_RECEIVE)); g_vHooks.push_back(hexchat_hook_print(ph, "Disconnected", HEXCHAT_PRI_NORM, event_cb, (void *)SERV_DISCONNECT)); g_vHooks.push_back(hexchat_hook_print(ph, "Killed", HEXCHAT_PRI_NORM, event_cb, (void *)SERV_KILLED)); g_vHooks.push_back(hexchat_hook_print(ph, "Notice", HEXCHAT_PRI_NORM, event_cb, (void *)SERV_NOTICE)); g_vHooks.push_back(hexchat_hook_command(ph, "tray_alert", HEXCHAT_PRI_NORM, command_cb, "Create an Alert", NULL)); return 1; }