From 1a75c8e1be58a25510642605dcd40c5c65e9c3f3 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 24 Oct 2012 21:33:02 +0200 Subject: A lot more rebranding --- plugins/hextray/callbacks.cpp | 8 +- plugins/hextray/hexchat.cpp | 320 +++++++++++++++++++++++++++++ plugins/hextray/hexchat.h | 32 +++ plugins/hextray/hextray-xp.vcxproj | 14 +- plugins/hextray/hextray-xp.vcxproj.filters | 10 +- plugins/hextray/hextray.cpp | 219 ++++++++++++++++++++ plugins/hextray/hextray.def | 3 + plugins/hextray/hextray.h | 77 +++++++ plugins/hextray/hextray.vcxproj | 14 +- plugins/hextray/hextray.vcxproj.filters | 10 +- plugins/hextray/resource.rc | 4 +- plugins/hextray/utility.cpp | 4 +- plugins/hextray/xchat.cpp | 320 ----------------------------- plugins/hextray/xchat.h | 32 --- plugins/hextray/xtray.cpp | 219 -------------------- plugins/hextray/xtray.def | 3 - plugins/hextray/xtray.h | 77 ------- 17 files changed, 683 insertions(+), 683 deletions(-) create mode 100644 plugins/hextray/hexchat.cpp create mode 100644 plugins/hextray/hexchat.h create mode 100644 plugins/hextray/hextray.cpp create mode 100644 plugins/hextray/hextray.def create mode 100644 plugins/hextray/hextray.h delete mode 100644 plugins/hextray/xchat.cpp delete mode 100644 plugins/hextray/xchat.h delete mode 100644 plugins/hextray/xtray.cpp delete mode 100644 plugins/hextray/xtray.def delete mode 100644 plugins/hextray/xtray.h (limited to 'plugins/hextray') diff --git a/plugins/hextray/callbacks.cpp b/plugins/hextray/callbacks.cpp index 96990050..e7dcfdba 100644 --- a/plugins/hextray/callbacks.cpp +++ b/plugins/hextray/callbacks.cpp @@ -23,10 +23,10 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "utility.h" -#include "xtray.h" -#include "xchat.h" +#include "hextray.h" +#include "hexchat.h" #include "callbacks.h" #include "resource.h" #include "sdTray.h" @@ -45,7 +45,7 @@ BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) TCHAR szTitle[10]; GetWindowText(hWnd, szTitle, 9); - if(_tcsstr(szTitle, _T("XChat ["))) + if(_tcsstr(szTitle, _T("HexChat ["))) { g_hXchatWnd = hWnd; return false; diff --git a/plugins/hextray/hexchat.cpp b/plugins/hextray/hexchat.cpp new file mode 100644 index 00000000..b1defc1f --- /dev/null +++ b/plugins/hextray/hexchat.cpp @@ -0,0 +1,320 @@ +/* X-Tray + * Copyright (C) 1998, 2005 Peter Zelezny, Michael Hotaling + * + * X-Tray is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * X-Tray is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include "hexchat-plugin.h" +#include "hextray.h" +#include "resource.h" +#include "hexchat.h" +#include "utility.h" + +// from util.c of xchat source code ( slightly modified to fit X-Tray Syntax ) +char *xchat_strip_color (char *text) +{ + int nc = 0; + int i = 0; + int col = 0; + int len = strlen(text); + char *new_str = (char *)malloc(len + 2); + + while (len > 0) + { + if ((col && isdigit(*text) && (nc < 2)) || (col && isdigit(*(text+1)) && (nc < 3) && (*text == ','))) + { + nc++; + + if(*text == ',') + { + nc = 0; + } + } + else + { + col = 0; + + switch (*text) + { + case '\003': /*ATTR_COLOR: */ + { + col = 1; + nc = 0; + } + break; + case '\007': /*ATTR_BEEP: */ + case '\017': /*ATTR_RESET: */ + case '\026': /*ATTR_REVERSE: */ + case '\002': /*ATTR_BOLD: */ + case '\037': /*ATTR_UNDERLINE: */ + break; + default: + { + new_str[i] = *text; + i++; + } + break; + } + } + + text++; + len--; + } + + new_str[i] = 0; + + return new_str; +} + +void check_special_chars (char *cmd) +{ + int occur = 0; + int len = strlen (cmd); + int i = 0, j = 0; + char *buf; + + if (!len) + return; + + buf = (char *)malloc (len + 1); + + if (buf) + { + while (cmd[j]) + { + switch (cmd[j]) + { + case '%': + { + occur++; + + switch (cmd[j + 1]) + { + case 'R': + buf[i] = '\026'; + break; + case 'U': + buf[i] = '\037'; + break; + case 'B': + buf[i] = '\002'; + break; + case 'C': + buf[i] = '\003'; + break; + case 'O': + buf[i] = '\017'; + break; + case '%': + buf[i] = '%'; + break; + default: + buf[i] = '%'; + j--; + break; + } + + j++; + } + break; + default: + { + buf[i] = cmd[j]; + } + break; + } + + j++; + i++; + } + + buf[i] = 0; + + if (occur) + strcpy (cmd, buf); + + free (buf); + } +} + +void xchat_globally_away(TCHAR *tszAway) +{ + char szTemp[512]; + char szAway[512]; + + ConvertString(tszAway, szAway, 512); + _snprintf(szTemp, 512, "ALLSERV AWAY %s\0", szAway); + check_special_chars(szTemp); + xchat_exec(szTemp); +} + +void xchat_away(TCHAR *tszAway) +{ + char szTemp[512]; + char szAway[512]; + + ConvertString(tszAway, szAway, 512); + _snprintf(szTemp, 512, szAway); + check_special_chars(szTemp); + xchat_commandf(ph, "AWAY %s\0", szTemp); +} + +void xchat_globally_back() +{ + std::vector xs; + std::vector::iterator xsi; + xchat_list *xl = xchat_list_get(ph, "channels"); + + if(xl) + { + while(xchat_list_next(ph, xl)) + { + xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); + + if((xsi == xs.end()) && + ((strlen(xchat_list_str(ph, xl, "server")) > 0) || + (strlen(xchat_list_str(ph, xl, "channel")) > 0))) + { + xs.push_back(xchat_list_int(ph, xl, "id")); + xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); + xchat_back(); + } + } + + xchat_list_free(ph, xl); + } +} + + + +void xchat_back() +{ + if(xchat_get_info(ph, "away")) + { + xchat_command(ph, "BACK"); + } +} + +HMENU setServerMenu() +{ + HMENU sTemp = CreateMenu(); + TCHAR wszServer[128]; + TCHAR wszNick[128]; + TCHAR wszMenuEntry[256]; + + std::vector xs; + std::vector::iterator xsi; + xchat_list *xl = xchat_list_get(ph, "channels"); + + AppendMenu(sTemp, MF_STRING, ACT_AWAY, _T("Set Globally Away")); + AppendMenu(sTemp, MF_STRING, ACT_BACK, _T("Set Globally Back")); + AppendMenu(sTemp, MF_SEPARATOR, 0, NULL); + + if(xl) + { + while(xchat_list_next(ph, xl)) + { + xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); + + if( (xsi == xs.end()) && + ((strlen(xchat_list_str(ph, xl, "server")) > 0) || + (strlen(xchat_list_str(ph, xl, "channel")) > 0))) + { + xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); + xs.push_back(xchat_list_int(ph, xl, "id")); + + char *network = _strdup(xchat_list_str(ph, xl, "network")); + char *server = _strdup(xchat_list_str(ph, xl, "server")); + char *nick = _strdup(xchat_get_info(ph, "nick")); + + if(network != NULL) + { + ConvertString(network, wszServer, 128); + } + else + { + ConvertString(server, wszServer, 128); + } + + if(server != NULL) + { + ConvertString(nick, wszNick, 128); + _sntprintf(wszMenuEntry, 256, _T("%s @ %s\0"), wszNick, wszServer); + + if(!xchat_get_info(ph, "away")) + { + AppendMenu(sTemp, MF_STRING, (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); + } + else + { + AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); + } + } + + free(network); + free(server); + free(nick); + } + } + + xchat_list_free(ph, xl); + } + + return sTemp; +} + +struct _xchat_context *xchat_find_server(int find_id) +{ + xchat_context *xc; + xchat_list *xl = xchat_list_get(ph, "channels"); + int id; + + if(!xl) + return NULL; + + while(xchat_list_next(ph, xl)) + { + id = xchat_list_int(ph, xl, "id"); + + if(id == -1) + { + return NULL; + } + else if(id == find_id) + { + xc = (xchat_context *)xchat_list_str(ph, xl, "context"); + + xchat_list_free(ph, xl); + + return xc; + } + } + + xchat_list_free(ph, xl); + + return NULL; +} + +void xchat_exec(char *command) +{ + xchat_set_context(ph, xchat_find_context(ph, NULL, NULL)); + xchat_command(ph, command); +} \ No newline at end of file diff --git a/plugins/hextray/hexchat.h b/plugins/hextray/hexchat.h new file mode 100644 index 00000000..76452aeb --- /dev/null +++ b/plugins/hextray/hexchat.h @@ -0,0 +1,32 @@ +/* X-Tray + * Copyright (C) 2005 Michael Hotaling + * + * X-Tray is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * X-Tray is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _H_XCHAT_H +#define _H_XCHAT_H + +void xchat_exec (char *); +char *xchat_strip_color (char *); +void xchat_parse (char *); +struct _xchat_context *xchat_find_server (int); +void xchat_globally_away (TCHAR *); +void xchat_away (TCHAR *); +void xchat_globally_back (); +void xchat_back (); +HMENU setServerMenu (); + +#endif \ No newline at end of file diff --git a/plugins/hextray/hextray-xp.vcxproj b/plugins/hextray/hextray-xp.vcxproj index cd7581d5..72d1599e 100644 --- a/plugins/hextray/hextray-xp.vcxproj +++ b/plugins/hextray/hextray-xp.vcxproj @@ -69,7 +69,7 @@ true true true - xtray.def + hextray.def ntstc_msvcrt.lib;%(AdditionalDependencies) @@ -89,7 +89,7 @@ true true true - xtray.def + hextray.def ntstc_msvcrt.lib;%(AdditionalDependencies) @@ -103,7 +103,7 @@ - + @@ -113,8 +113,8 @@ - - + + @@ -122,8 +122,8 @@ - - + + diff --git a/plugins/hextray/hextray-xp.vcxproj.filters b/plugins/hextray/hextray-xp.vcxproj.filters index b83dc813..1f9a4057 100644 --- a/plugins/hextray/hextray-xp.vcxproj.filters +++ b/plugins/hextray/hextray-xp.vcxproj.filters @@ -21,7 +21,7 @@ - + Resource Files @@ -70,10 +70,10 @@ Source Files - + Source Files - + Source Files @@ -93,10 +93,10 @@ Header Files - + Header Files - + Header Files diff --git a/plugins/hextray/hextray.cpp b/plugins/hextray/hextray.cpp new file mode 100644 index 00000000..9741e5f7 --- /dev/null +++ b/plugins/hextray/hextray.cpp @@ -0,0 +1,219 @@ +/* X-Tray + * Copyright (C) 2005 Michael Hotaling + * + * X-Tray is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * X-Tray is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include + +#include "hexchat-plugin.h" +#include "resource.h" +#include "callbacks.h" +#include "utility.h" +#include "hextray.h" +#include "sdTray.h" +#include "sdAlerts.h" + +/*****************************************************/ +/**** Don't want to pollute the namespace do we? *****/ +/*****************************************************/ +std::list g_vHooks; + +/*****************************************************/ +/************ Global Identifiers *********************/ +/*****************************************************/ +WNDPROC g_hOldProc; +xchat_plugin *ph; + +/*****************************************************/ +/***************** Resources *************************/ +/*****************************************************/ +HWND g_hXchatWnd; +HWND g_hHotkeyWnd; +HWND g_hPrefDlg; +HMENU g_hTrayMenu; +HICON g_hIcons[24]; +HANDLE g_hInstance; +/*****************************************************/ +/***************** Preferences ***********************/ +/*****************************************************/ +unsigned int g_dwPrefs; +TCHAR g_szAway[512]; +int g_iTime; + + +BOOL WINAPI DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpVoid) +{ + if((fdwReason == DLL_PROCESS_ATTACH) || (fdwReason == DLL_THREAD_ATTACH)) + { + g_hInstance = hModule; + } + + return TRUE; +} + +int xchat_plugin_init(xchat_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.2.4"; + + /***************************************************************************************************************************/ + /************************* Load our preferances from xTray.ini *************************************************************/ + /***************************************************************************************************************************/ + LoadPrefs(); + + /***************************************************************************************************************************/ + /************************* Finds the xChat window and saves it for later use ***********************************************/ + /***************************************************************************************************************************/ + g_hXchatWnd = (HWND)xchat_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 xChat 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", xchat_get_info(ph, "version")); + AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG); + + /***************************************************************************************************************************/ + /***************************************************************************************************************************/ + /***************************************************************************************************************************/ + if(g_dwPrefs & (1< + * + * X-Tray is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * X-Tray is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _XTRAY_H +#define _XTRAY_H + +/******************** Globals *************************/ +extern HWND g_hXchatWnd; +extern HWND g_hHotkeyWnd; +extern HWND g_hPrefDlg; +extern HMENU g_hTrayMenu; +extern HICON g_hIcons[24]; +extern HANDLE g_hInstance; +extern unsigned int g_dwPrefs; +extern TCHAR g_szAway[512]; +extern int g_iTime; +extern WNDPROC g_hOldProc; +extern struct _xchat_plugin *ph; +/******************************************************/ + +/******************** Messages ************************/ +#define WM_TRAYMSG WM_APP +/******************************************************/ + +/********************* Events *************************/ +#define CHAN_HILIGHT 1 +#define CHAN_INVITE 2 +#define CHAN_TOPIC_CHANGE 3 +#define CHAN_BANNED 4 +#define CHAN_KICKED 5 + +#define CTCP_GENERIC 6 +#define PMSG_RECEIVE 7 + +#define SERV_KILLED 8 +#define SERV_NOTICE 9 +#define SERV_DISCONNECT 10 + +/* new events */ +#define CHAN_MESSAGE 21 + +#define PREF_AOM 11 // away on minimize +#define PREF_TOT 12 // Tray on Taskbar +#define PREF_AMAE 13 // alert me about events +#define PREF_OSBWM 14 // Only Show Balloon When Minimized +#define PREF_UWIOB 15 // Use Window Instead of Balloon +#define PREF_KAOI 16 // Keep alerts open indefinitely +#define PREF_MIOC 17 // Minimize instead of close +#define PREF_BLINK 18 // blink icon +#define PREF_CICO 19 // change icon - not implemented +#define PREF_DNSIT 20 // Do not show in taskbar +/******************************************************/ +#endif + +#ifdef _WIN64 +/* use replacement with the same value, and use SetWindowLongPtr instead + of SetWindowLong. more info: + + http://msdn.microsoft.com/en-us/library/ms633591.aspx + http://msdn.microsoft.com/en-us/library/ms644898.aspx */ +#define GWL_HWNDPARENT GWLP_HWNDPARENT +#endif diff --git a/plugins/hextray/hextray.vcxproj b/plugins/hextray/hextray.vcxproj index 47f4c273..fd28aae3 100644 --- a/plugins/hextray/hextray.vcxproj +++ b/plugins/hextray/hextray.vcxproj @@ -66,7 +66,7 @@ true true true - xtray.def + hextray.def @@ -85,7 +85,7 @@ true true true - xtray.def + hextray.def @@ -98,7 +98,7 @@ - + @@ -108,8 +108,8 @@ - - + + @@ -117,8 +117,8 @@ - - + + diff --git a/plugins/hextray/hextray.vcxproj.filters b/plugins/hextray/hextray.vcxproj.filters index b83dc813..1f9a4057 100644 --- a/plugins/hextray/hextray.vcxproj.filters +++ b/plugins/hextray/hextray.vcxproj.filters @@ -21,7 +21,7 @@ - + Resource Files @@ -70,10 +70,10 @@ Source Files - + Source Files - + Source Files @@ -93,10 +93,10 @@ Header Files - + Header Files - + Header Files diff --git a/plugins/hextray/resource.rc b/plugins/hextray/resource.rc index 4b028421..01899ac7 100644 --- a/plugins/hextray/resource.rc +++ b/plugins/hextray/resource.rc @@ -201,7 +201,7 @@ END 3 TEXTINCLUDE BEGIN - "xtray.h\0" + "hextray.h\0" END 4 TEXTINCLUDE @@ -303,7 +303,7 @@ IDB_SD_LOGO BITMAP "bitmaps\\sd.bmp" // // Generated from the TEXTINCLUDE 3 resource. // -xtray.h +hextray.h ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/plugins/hextray/utility.cpp b/plugins/hextray/utility.cpp index 8f6caa27..4a2ddde7 100644 --- a/plugins/hextray/utility.cpp +++ b/plugins/hextray/utility.cpp @@ -21,9 +21,9 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "utility.h" -#include "xtray.h" +#include "hextray.h" #include "callbacks.h" #include "resource.h" diff --git a/plugins/hextray/xchat.cpp b/plugins/hextray/xchat.cpp deleted file mode 100644 index 47ce46a9..00000000 --- a/plugins/hextray/xchat.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* X-Tray - * Copyright (C) 1998, 2005 Peter Zelezny, Michael Hotaling - * - * X-Tray is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * X-Tray is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "xchat-plugin.h" -#include "xtray.h" -#include "resource.h" -#include "xchat.h" -#include "utility.h" - -// from util.c of xchat source code ( slightly modified to fit X-Tray Syntax ) -char *xchat_strip_color (char *text) -{ - int nc = 0; - int i = 0; - int col = 0; - int len = strlen(text); - char *new_str = (char *)malloc(len + 2); - - while (len > 0) - { - if ((col && isdigit(*text) && (nc < 2)) || (col && isdigit(*(text+1)) && (nc < 3) && (*text == ','))) - { - nc++; - - if(*text == ',') - { - nc = 0; - } - } - else - { - col = 0; - - switch (*text) - { - case '\003': /*ATTR_COLOR: */ - { - col = 1; - nc = 0; - } - break; - case '\007': /*ATTR_BEEP: */ - case '\017': /*ATTR_RESET: */ - case '\026': /*ATTR_REVERSE: */ - case '\002': /*ATTR_BOLD: */ - case '\037': /*ATTR_UNDERLINE: */ - break; - default: - { - new_str[i] = *text; - i++; - } - break; - } - } - - text++; - len--; - } - - new_str[i] = 0; - - return new_str; -} - -void check_special_chars (char *cmd) -{ - int occur = 0; - int len = strlen (cmd); - int i = 0, j = 0; - char *buf; - - if (!len) - return; - - buf = (char *)malloc (len + 1); - - if (buf) - { - while (cmd[j]) - { - switch (cmd[j]) - { - case '%': - { - occur++; - - switch (cmd[j + 1]) - { - case 'R': - buf[i] = '\026'; - break; - case 'U': - buf[i] = '\037'; - break; - case 'B': - buf[i] = '\002'; - break; - case 'C': - buf[i] = '\003'; - break; - case 'O': - buf[i] = '\017'; - break; - case '%': - buf[i] = '%'; - break; - default: - buf[i] = '%'; - j--; - break; - } - - j++; - } - break; - default: - { - buf[i] = cmd[j]; - } - break; - } - - j++; - i++; - } - - buf[i] = 0; - - if (occur) - strcpy (cmd, buf); - - free (buf); - } -} - -void xchat_globally_away(TCHAR *tszAway) -{ - char szTemp[512]; - char szAway[512]; - - ConvertString(tszAway, szAway, 512); - _snprintf(szTemp, 512, "ALLSERV AWAY %s\0", szAway); - check_special_chars(szTemp); - xchat_exec(szTemp); -} - -void xchat_away(TCHAR *tszAway) -{ - char szTemp[512]; - char szAway[512]; - - ConvertString(tszAway, szAway, 512); - _snprintf(szTemp, 512, szAway); - check_special_chars(szTemp); - xchat_commandf(ph, "AWAY %s\0", szTemp); -} - -void xchat_globally_back() -{ - std::vector xs; - std::vector::iterator xsi; - xchat_list *xl = xchat_list_get(ph, "channels"); - - if(xl) - { - while(xchat_list_next(ph, xl)) - { - xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); - - if((xsi == xs.end()) && - ((strlen(xchat_list_str(ph, xl, "server")) > 0) || - (strlen(xchat_list_str(ph, xl, "channel")) > 0))) - { - xs.push_back(xchat_list_int(ph, xl, "id")); - xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); - xchat_back(); - } - } - - xchat_list_free(ph, xl); - } -} - - - -void xchat_back() -{ - if(xchat_get_info(ph, "away")) - { - xchat_command(ph, "BACK"); - } -} - -HMENU setServerMenu() -{ - HMENU sTemp = CreateMenu(); - TCHAR wszServer[128]; - TCHAR wszNick[128]; - TCHAR wszMenuEntry[256]; - - std::vector xs; - std::vector::iterator xsi; - xchat_list *xl = xchat_list_get(ph, "channels"); - - AppendMenu(sTemp, MF_STRING, ACT_AWAY, _T("Set Globally Away")); - AppendMenu(sTemp, MF_STRING, ACT_BACK, _T("Set Globally Back")); - AppendMenu(sTemp, MF_SEPARATOR, 0, NULL); - - if(xl) - { - while(xchat_list_next(ph, xl)) - { - xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); - - if( (xsi == xs.end()) && - ((strlen(xchat_list_str(ph, xl, "server")) > 0) || - (strlen(xchat_list_str(ph, xl, "channel")) > 0))) - { - xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); - xs.push_back(xchat_list_int(ph, xl, "id")); - - char *network = _strdup(xchat_list_str(ph, xl, "network")); - char *server = _strdup(xchat_list_str(ph, xl, "server")); - char *nick = _strdup(xchat_get_info(ph, "nick")); - - if(network != NULL) - { - ConvertString(network, wszServer, 128); - } - else - { - ConvertString(server, wszServer, 128); - } - - if(server != NULL) - { - ConvertString(nick, wszNick, 128); - _sntprintf(wszMenuEntry, 256, _T("%s @ %s\0"), wszNick, wszServer); - - if(!xchat_get_info(ph, "away")) - { - AppendMenu(sTemp, MF_STRING, (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); - } - else - { - AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); - } - } - - free(network); - free(server); - free(nick); - } - } - - xchat_list_free(ph, xl); - } - - return sTemp; -} - -struct _xchat_context *xchat_find_server(int find_id) -{ - xchat_context *xc; - xchat_list *xl = xchat_list_get(ph, "channels"); - int id; - - if(!xl) - return NULL; - - while(xchat_list_next(ph, xl)) - { - id = xchat_list_int(ph, xl, "id"); - - if(id == -1) - { - return NULL; - } - else if(id == find_id) - { - xc = (xchat_context *)xchat_list_str(ph, xl, "context"); - - xchat_list_free(ph, xl); - - return xc; - } - } - - xchat_list_free(ph, xl); - - return NULL; -} - -void xchat_exec(char *command) -{ - xchat_set_context(ph, xchat_find_context(ph, NULL, NULL)); - xchat_command(ph, command); -} \ No newline at end of file diff --git a/plugins/hextray/xchat.h b/plugins/hextray/xchat.h deleted file mode 100644 index 76452aeb..00000000 --- a/plugins/hextray/xchat.h +++ /dev/null @@ -1,32 +0,0 @@ -/* X-Tray - * Copyright (C) 2005 Michael Hotaling - * - * X-Tray is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * X-Tray is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _H_XCHAT_H -#define _H_XCHAT_H - -void xchat_exec (char *); -char *xchat_strip_color (char *); -void xchat_parse (char *); -struct _xchat_context *xchat_find_server (int); -void xchat_globally_away (TCHAR *); -void xchat_away (TCHAR *); -void xchat_globally_back (); -void xchat_back (); -HMENU setServerMenu (); - -#endif \ No newline at end of file diff --git a/plugins/hextray/xtray.cpp b/plugins/hextray/xtray.cpp deleted file mode 100644 index df4a5c89..00000000 --- a/plugins/hextray/xtray.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* X-Tray - * Copyright (C) 2005 Michael Hotaling - * - * X-Tray is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * X-Tray is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define _WIN32_IE 0x0601 - -#include -#include -#include -#include - -#include "xchat-plugin.h" -#include "resource.h" -#include "callbacks.h" -#include "utility.h" -#include "xtray.h" -#include "sdTray.h" -#include "sdAlerts.h" - -/*****************************************************/ -/**** Don't want to pollute the namespace do we? *****/ -/*****************************************************/ -std::list g_vHooks; - -/*****************************************************/ -/************ Global Identifiers *********************/ -/*****************************************************/ -WNDPROC g_hOldProc; -xchat_plugin *ph; - -/*****************************************************/ -/***************** Resources *************************/ -/*****************************************************/ -HWND g_hXchatWnd; -HWND g_hHotkeyWnd; -HWND g_hPrefDlg; -HMENU g_hTrayMenu; -HICON g_hIcons[24]; -HANDLE g_hInstance; -/*****************************************************/ -/***************** Preferences ***********************/ -/*****************************************************/ -unsigned int g_dwPrefs; -TCHAR g_szAway[512]; -int g_iTime; - - -BOOL WINAPI DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpVoid) -{ - if((fdwReason == DLL_PROCESS_ATTACH) || (fdwReason == DLL_THREAD_ATTACH)) - { - g_hInstance = hModule; - } - - return TRUE; -} - -int xchat_plugin_init(xchat_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.2.4"; - - /***************************************************************************************************************************/ - /************************* Load our preferances from xTray.ini *************************************************************/ - /***************************************************************************************************************************/ - LoadPrefs(); - - /***************************************************************************************************************************/ - /************************* Finds the xChat window and saves it for later use ***********************************************/ - /***************************************************************************************************************************/ - g_hXchatWnd = (HWND)xchat_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 xChat 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", xchat_get_info(ph, "version")); - AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG); - - /***************************************************************************************************************************/ - /***************************************************************************************************************************/ - /***************************************************************************************************************************/ - if(g_dwPrefs & (1< - * - * X-Tray is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * X-Tray is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _XTRAY_H -#define _XTRAY_H - -/******************** Globals *************************/ -extern HWND g_hXchatWnd; -extern HWND g_hHotkeyWnd; -extern HWND g_hPrefDlg; -extern HMENU g_hTrayMenu; -extern HICON g_hIcons[24]; -extern HANDLE g_hInstance; -extern unsigned int g_dwPrefs; -extern TCHAR g_szAway[512]; -extern int g_iTime; -extern WNDPROC g_hOldProc; -extern struct _xchat_plugin *ph; -/******************************************************/ - -/******************** Messages ************************/ -#define WM_TRAYMSG WM_APP -/******************************************************/ - -/********************* Events *************************/ -#define CHAN_HILIGHT 1 -#define CHAN_INVITE 2 -#define CHAN_TOPIC_CHANGE 3 -#define CHAN_BANNED 4 -#define CHAN_KICKED 5 - -#define CTCP_GENERIC 6 -#define PMSG_RECEIVE 7 - -#define SERV_KILLED 8 -#define SERV_NOTICE 9 -#define SERV_DISCONNECT 10 - -/* new events */ -#define CHAN_MESSAGE 21 - -#define PREF_AOM 11 // away on minimize -#define PREF_TOT 12 // Tray on Taskbar -#define PREF_AMAE 13 // alert me about events -#define PREF_OSBWM 14 // Only Show Balloon When Minimized -#define PREF_UWIOB 15 // Use Window Instead of Balloon -#define PREF_KAOI 16 // Keep alerts open indefinitely -#define PREF_MIOC 17 // Minimize instead of close -#define PREF_BLINK 18 // blink icon -#define PREF_CICO 19 // change icon - not implemented -#define PREF_DNSIT 20 // Do not show in taskbar -/******************************************************/ -#endif - -#ifdef _WIN64 -/* use replacement with the same value, and use SetWindowLongPtr instead - of SetWindowLong. more info: - - http://msdn.microsoft.com/en-us/library/ms633591.aspx - http://msdn.microsoft.com/en-us/library/ms644898.aspx */ -#define GWL_HWNDPARENT GWLP_HWNDPARENT -#endif -- cgit 1.4.1