From 7f10992af0dd1ff0c8f3b6f4d6931032108b9052 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Sun, 26 Apr 2015 06:23:50 +0000 Subject: CSlist - common project git-svn-id: http://svn.miranda-ng.org/main/trunk@13158 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CSList/cslist.vcxproj | 28 +++ plugins/CSList/cslist.vcxproj.filters | 4 + plugins/CSList/cslist_10.vcxproj | 206 ---------------- plugins/CSList/cslist_10.vcxproj.filters | 47 ---- plugins/CSList/cslist_12.vcxproj | 209 ---------------- plugins/CSList/cslist_12.vcxproj.filters | 47 ---- plugins/CSList/src/cslist.cpp | 2 +- plugins/CSList/src/cslist.h | 410 ------------------------------- plugins/CSList/src/stdafx.cpp | 18 -- plugins/CSList/src/stdafx.cxx | 18 ++ plugins/CSList/src/stdafx.h | 408 ++++++++++++++++++++++++++++++ 11 files changed, 459 insertions(+), 938 deletions(-) create mode 100644 plugins/CSList/cslist.vcxproj create mode 100644 plugins/CSList/cslist.vcxproj.filters delete mode 100644 plugins/CSList/cslist_10.vcxproj delete mode 100644 plugins/CSList/cslist_10.vcxproj.filters delete mode 100644 plugins/CSList/cslist_12.vcxproj delete mode 100644 plugins/CSList/cslist_12.vcxproj.filters delete mode 100644 plugins/CSList/src/cslist.h delete mode 100644 plugins/CSList/src/stdafx.cpp create mode 100644 plugins/CSList/src/stdafx.cxx create mode 100644 plugins/CSList/src/stdafx.h (limited to 'plugins/CSList') diff --git a/plugins/CSList/cslist.vcxproj b/plugins/CSList/cslist.vcxproj new file mode 100644 index 0000000000..d4792c19c4 --- /dev/null +++ b/plugins/CSList/cslist.vcxproj @@ -0,0 +1,28 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + CSList + {2AD2FF74-06E1-4BD8-984A-526F3C6315B3} + + + + + \ No newline at end of file diff --git a/plugins/CSList/cslist.vcxproj.filters b/plugins/CSList/cslist.vcxproj.filters new file mode 100644 index 0000000000..de5ad9f66c --- /dev/null +++ b/plugins/CSList/cslist.vcxproj.filters @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/plugins/CSList/cslist_10.vcxproj b/plugins/CSList/cslist_10.vcxproj deleted file mode 100644 index dd416acbc1..0000000000 --- a/plugins/CSList/cslist_10.vcxproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - CSList - {2AD2FF74-06E1-4BD8-984A-526F3C6315B3} - - - - DynamicLibrary - Unicode - - - DynamicLibrary - Unicode - - - DynamicLibrary - Unicode - true - - - DynamicLibrary - Unicode - true - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - true - Level3 - false - Use - cslist.h - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - true - false - $(IntDir)$(TargetName).lib - true - Windows - $(ProfileDir)..\..\bin10\lib - /PDBALTPATH:%_PDB% - comctl32.lib;%(AdditionalDependencies) - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - true - Level3 - false - Use - cslist.h - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - true - false - $(IntDir)$(TargetName).lib - true - Windows - $(ProfileDir)..\..\bin10\lib - /PDBALTPATH:%_PDB% - comctl32.lib;%(AdditionalDependencies) - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - MultiThreadedDebugDLL - true - Fast - Level3 - EditAndContinue - false - Use - cslist.h - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - false - $(IntDir)$(TargetName).lib - Windows - $(ProfileDir)..\..\bin10\lib - comctl32.lib;%(AdditionalDependencies) - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - MultiThreadedDebugDLL - true - Fast - Level3 - false - Use - cslist.h - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - false - $(IntDir)$(TargetName).lib - Windows - $(ProfileDir)..\..\bin10\lib - comctl32.lib;%(AdditionalDependencies) - - - - - - Create - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/CSList/cslist_10.vcxproj.filters b/plugins/CSList/cslist_10.vcxproj.filters deleted file mode 100644 index a38e2f705e..0000000000 --- a/plugins/CSList/cslist_10.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {8dd75aec-9e99-4df2-9de1-7015fb55c28a} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {1370dfbb-66b8-4c0b-b76a-bd7aa558e483} - h;hpp;hxx;hm;inl - - - {0c22408f-3e3b-4310-970e-525e94308c9d} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/CSList/cslist_12.vcxproj b/plugins/CSList/cslist_12.vcxproj deleted file mode 100644 index 8847c600b0..0000000000 --- a/plugins/CSList/cslist_12.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - CSList - {2AD2FF74-06E1-4BD8-984A-526F3C6315B3} - - - - DynamicLibrary - Unicode - v120_xp - - - DynamicLibrary - Unicode - v120_xp - - - DynamicLibrary - Unicode - true - v120_xp - - - DynamicLibrary - Unicode - true - v120_xp - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)\Plugins\ - $(SolutionDir)$(Configuration)64\Plugins\ - $(SolutionDir)$(Configuration)\Obj\$(ProjectName)\ - $(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\ - true - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - true - Level4 - false - Use - cslist.h - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - true - false - $(IntDir)$(TargetName).lib - true - Windows - $(ProfileDir)..\..\bin12\lib - comctl32.lib;%(AdditionalDependencies) - - - - - Full - OnlyExplicitInline - Size - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - true - Level4 - false - Use - cslist.h - - - NDEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - true - false - $(IntDir)$(TargetName).lib - true - Windows - $(ProfileDir)..\..\bin12\lib - comctl32.lib;%(AdditionalDependencies) - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - MultiThreadedDebugDLL - true - Fast - Level4 - EditAndContinue - false - Use - cslist.h - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - false - $(IntDir)$(TargetName).lib - Windows - $(ProfileDir)..\..\bin12\lib - comctl32.lib;%(AdditionalDependencies) - false - - - - - Disabled - ..\..\include;..\ExternalAPI;%(AdditionalIncludeDirectories) - NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - MultiThreadedDebugDLL - true - Fast - Level4 - false - Use - cslist.h - - - _DEBUG;%(PreprocessorDefinitions) - ..\..\include\msapi - - - true - false - $(IntDir)$(TargetName).lib - Windows - $(ProfileDir)..\..\bin12\lib - comctl32.lib;%(AdditionalDependencies) - - - - - - Create - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/plugins/CSList/cslist_12.vcxproj.filters b/plugins/CSList/cslist_12.vcxproj.filters deleted file mode 100644 index a38e2f705e..0000000000 --- a/plugins/CSList/cslist_12.vcxproj.filters +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {8dd75aec-9e99-4df2-9de1-7015fb55c28a} - cpp;c;cxx;rc;def;r;odl;idl;hpj;bat - - - {1370dfbb-66b8-4c0b-b76a-bd7aa558e483} - h;hpp;hxx;hm;inl - - - {0c22408f-3e3b-4310-970e-525e94308c9d} - ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe - - - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - Resource Files - - - Resource Files - - - \ No newline at end of file diff --git a/plugins/CSList/src/cslist.cpp b/plugins/CSList/src/cslist.cpp index 3c1a3d8ebb..29de682404 100644 --- a/plugins/CSList/src/cslist.cpp +++ b/plugins/CSList/src/cslist.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ======================================================================== */ -#include "cslist.h" +#include "stdafx.h" #include "strpos.h" CLIST_INTERFACE *pcli; diff --git a/plugins/CSList/src/cslist.h b/plugins/CSList/src/cslist.h deleted file mode 100644 index 219a63771a..0000000000 --- a/plugins/CSList/src/cslist.h +++ /dev/null @@ -1,410 +0,0 @@ -/* ======================================================================== - - Custom Status List - __________________ - - Custom Status List plugin for Miranda-IM (www.miranda-im.org) - Follower of Custom Status History List by HANAX - Copyright © 2006-2008 HANAX - Copyright © 2007-2009 jarvis - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - DESCRIPTION: - - Offers List of your Custom Statuses. - - ============================================================================ - - // ====[ INCLUDES AND DEFINITIONS ]======================================== */ - -#ifndef __CSLIST_H -#define __CSLIST_H 1 - -#define _CRT_SECURE_NO_WARNINGS - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "resource.h" -#include "version.h" - -// ====[ BASIC DEFINITIONS ]================================================== - -#define MODULENAME LPGEN("Custom Status List") -#define MODNAME "CSList" - -// ====[ LIMITS ]============================================================= - -#define EXTRASTATUS_TITLE_LIMIT 64 // limit of chars for extra status title -#define EXTRASTATUS_MESSAGE_LIMIT 2048 // limit of chars for extra status message - -// ====[ DEFAULT DB VALUES ]================================================== - -#define DEFAULT_ICQ_XSTATUS_ENABLED 1 -#define DEFAULT_PLUGIN_SHOW_RELNOTES 0 -#define DEFAULT_PLUGIN_SHOW_NONSTANDARD_XSTATUSES 1 -#define DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION 1 -#define DEFAULT_PLUGIN_DELETE_AFTER_IMPORT 0 -#define DEFAULT_ITEMS_COUNT 0 -#define DEFAULT_ITEM_ICON 0 -#define DEFAULT_ITEM_IS_FAVOURITE 0 -#define DEFAULT_ALLOW_EXTRA_ICONS 1 -#define DEFAULT_REMEMBER_WINDOW_POSITION 1 - - -// ====[ FUNCTION MACROS ]==================================================== - -// set which row is selected (cannot be only focused, but fully selected - second param ;)) -#define ListView_GetSelectedItemMacro( hwnd ) ListView_GetNextItem( hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED ); -#ifndef ListView_SetSelectionMark -#define ListView_SetSelectionMark( x, y ) 0 -#endif - -#define getByte(setting, error) db_get_b(NULL, MODNAME, setting, error) -#define setByte(setting, value) db_set_b(NULL, MODNAME, setting, value) -#define getWord(setting, error) db_get_w(NULL, MODNAME, setting, error) -#define setWord(setting, value) db_set_w(NULL, MODNAME, setting, value) -#define getDword(setting, error) db_get_dw(NULL, MODNAME, setting, error) -#define setDword(setting, value) db_set_dw(NULL, MODNAME, setting, value) -#define getTString(setting, dest) db_get_ts(NULL, MODNAME, setting, dest) -#define setTString(setting, value) db_set_ts(NULL, MODNAME, setting, value) -#define deleteSetting(setting) db_unset(NULL, MODNAME, setting) - -// -- -typedef void(__cdecl *pForAllProtosFunc)(char*, void *); - - -// ====[ STRUCTURES ]========================================================= - -struct StatusItem // list item structure -{ - int m_iIcon; - TCHAR m_tszTitle[EXTRASTATUS_TITLE_LIMIT]; - TCHAR m_tszMessage[EXTRASTATUS_MESSAGE_LIMIT]; - BOOL m_bFavourite; - - StatusItem() - { - m_iIcon = 0; - mir_tstrcpy(m_tszTitle, _T("")); - mir_tstrcpy(m_tszMessage, _T("")); - m_bFavourite = FALSE; - } - - StatusItem(const StatusItem& p) - { - m_iIcon = p.m_iIcon; - mir_tstrcpy(m_tszTitle, p.m_tszTitle); - mir_tstrcpy(m_tszMessage, p.m_tszMessage); - m_bFavourite = p.m_bFavourite; - } - - ~StatusItem() - { - } -}; - -static struct CSForm { // icons + buttons - int idc; - TCHAR* ptszTitle; - TCHAR* ptszDescr; - char * pszIconIcoLib; - int iconNoIcoLib; - HANDLE hIcoLibItem; - -} forms[] = { - - { -1, LPGENT("Main Menu"), LPGENT("Main Icon"), "icon", IDI_CSLIST }, - { IDC_ADD, LPGENT("Add new item"), LPGENT("Add"), "add", IDI_ADD }, - { IDC_MODIFY, LPGENT("Modify selected item"), LPGENT("Modify"), "modify", IDI_MODIFY }, - { IDC_REMOVE, LPGENT("Delete selected item"), LPGENT("Remove"), "remove", IDI_REMOVE }, - { IDC_FAVOURITE, LPGENT("Set/unset current item as favorite"), LPGENT("Favorite"), "favourite", IDI_FAVOURITE }, - { IDC_UNDO, LPGENT("Undo changes"), LPGENT("Undo changes"), "undo", IDI_UNDO }, - { IDC_IMPORT, LPGENT("Import statuses from database"), LPGENT("Import"), "import", IDI_IMPORT }, - { IDC_FILTER, LPGENT("Filter list"), LPGENT("Filter"), "filter", IDI_FILTER }, - { IDCLOSE, LPGENT("Close without changing custom status"), LPGENT("No change"), "nochng", IDI_CLOSE }, - { IDC_CANCEL, LPGENT("Clear custom status (reset to None) and close"), LPGENT("Clear"), "clear", IDI_UNSET }, - { IDOK, LPGENT("Set custom status to selected one and close"), LPGENT("Set"), "apply", IDI_APPLY } -}; - -// ====[ MY BITCHY LIST IMPLEMENTATION x)) ]================================== -// TODO: Optimize it all x)) - -template< class T > struct ListItem -{ - T* m_item; - ListItem* m_next; - - ListItem() - { - m_item = NULL; - m_next = NULL; - } - - ~ListItem() - { - delete m_item; - } - - ListItem(StatusItem* si) - { - m_item = si; - m_next = NULL; - } - - ListItem(const ListItem& p) - { - m_item = p.item; - m_next = NULL; - } -}; - - -template< class T > struct List -{ -private: - ListItem< T >* m_items; - unsigned int m_count; - -public: - typedef int(*compareFunc)(const T* p1, const T* p2); - compareFunc m_compare; - - List(compareFunc compFnc) - { - m_items = NULL; - m_count = 0; - m_compare = compFnc; - } - - ~List() - { - destroy(); - } - - ListItem< T >* getListHead() - { - return m_items; - } - - unsigned int getCount() - { - return m_count; - } - - int add(T* csi) - { - int position = 0; - ListItem< T >* item = new ListItem< T >(csi); - if (m_items == NULL) - m_items = item; - else - { - ListItem< T >* help = item; - item->m_next = m_items; - while (help->m_next != NULL) - { - int cmp = m_compare(item->m_item, help->m_next->m_item); - if (cmp == 1) - help = help->m_next; - else if (cmp == 0) - { - delete item; - return -1; - } - else - break; - position++; - } - if (help != item) - { - item->m_next = help->m_next; - help->m_next = item; - } - else m_items = item; - } - m_count++; - return position; - } - - int remove(const unsigned int item) - { - int position = 0; - if (item >= m_count) - return -1; - - ListItem< T >* help = m_items; - ListItem< T >* removed; - if (item == 0) - { - m_items = m_items->m_next; - removed = help; - } - else - { - for (unsigned int i = 0; i < item - 1; i++) - { - help = help->m_next; - position++; - } - removed = help->m_next; - help->m_next = help->m_next->m_next; - } - delete removed; - m_count--; - return position; - } - - T* get(const unsigned int item) - { - ListItem< T >* help = m_items; - for (unsigned int i = 0; i < item; i++) - help = help->m_next; - return help->m_item; - } - - T* operator[](const unsigned int item) - { - return get(item); - } - - void destroy() - { - while (m_count > 0) - remove(0); - } -}; - - -// ====[ CLASSING -- FUNNY STUFF :) ]========================================= - -struct CSWindow; -struct CSAMWindow; - -struct CSListView -{ - HWND m_handle; - CSWindow* m_parent; - - CSListView(HWND, CSWindow*); - - void addItem(StatusItem* item, int itemNumber); - void initItems(ListItem< StatusItem >* items); - void reinitItems(ListItem< StatusItem >* items); - void removeItems(); - int getPositionInList(); - void setFullFocusedSelection(int selection); -}; - - -struct CSItemsList -{ - List< StatusItem > *m_list; - - static int compareItems(const StatusItem* p1, const StatusItem* p2); - void loadItems(char *protoName); - void saveItems(char *protoName); - - CSItemsList(char *protoName); - ~CSItemsList(); -}; - -struct CSWindow -{ - HWND m_handle; - BOOL m_bExtraIcons; - CSItemsList* m_itemslist; - CSListView* m_listview; - CSAMWindow* m_addModifyDlg; - HIMAGELIST m_icons; - int m_statusCount; - BOOL m_bSomethingChanged; - TCHAR* m_filterString; - char * m_protoName; - - CSWindow(char *protoName); - ~CSWindow(); - - void initIcons(); - void deinitIcons(); - void initButtons(); - void loadWindowPosition(); - BOOL toggleButtons(); - void toggleEmptyListMessage(); - void toggleFilter(); - BOOL itemPassedFilter(ListItem< StatusItem >* li); - - void __inline saveWindowPosition(HWND hwnd) - { - if (getByte("RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION) == TRUE) - Utils_SaveWindowPosition(hwnd, NULL, MODNAME, "Position"); - } -}; - -struct CSAMWindow -{ - WORD m_action; - StatusItem* m_item; - CSWindow* m_parent; - BOOL m_bChanged; - - HWND m_handle; - HWND m_hCombo; - HWND m_hMessage; - - CSAMWindow(WORD action, CSWindow* parent); - ~CSAMWindow(); - - void exec(); - void setCombo(); - void fillDialog(); - void checkFieldLimit(WORD action, WORD item); - void checkItemValidity(); -}; - - -// service functions -INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM); - -// protocols enumeration related functions -void addProtoStatusMenuItem(char *protoName); - -// other functions -void IitIcoLib(); -void RegisterHotkeys(char buf[200], TCHAR* accName, int Number); -void SetStatus(WORD code, StatusItem* item, char *protoName); - -// ====[ PROCEDURES ]========================================================= - -INT_PTR CALLBACK CSWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -INT_PTR CALLBACK CSAMWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -INT_PTR CALLBACK CSRNWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); -INT_PTR CALLBACK CSOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); - -#endif /* __CSLIST_H */ diff --git a/plugins/CSList/src/stdafx.cpp b/plugins/CSList/src/stdafx.cpp deleted file mode 100644 index f481d2b8d8..0000000000 --- a/plugins/CSList/src/stdafx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org) - -This program 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 version 2 -of the License. - -This program 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 this program. If not, see . -*/ - -#include "cslist.h" \ No newline at end of file diff --git a/plugins/CSList/src/stdafx.cxx b/plugins/CSList/src/stdafx.cxx new file mode 100644 index 0000000000..6fb37564b7 --- /dev/null +++ b/plugins/CSList/src/stdafx.cxx @@ -0,0 +1,18 @@ +/* +Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org) + +This program 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 version 2 +of the License. + +This program 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 this program. If not, see . +*/ + +#include "stdafx.h" \ No newline at end of file diff --git a/plugins/CSList/src/stdafx.h b/plugins/CSList/src/stdafx.h new file mode 100644 index 0000000000..491041b688 --- /dev/null +++ b/plugins/CSList/src/stdafx.h @@ -0,0 +1,408 @@ +/* ======================================================================== + + Custom Status List + __________________ + + Custom Status List plugin for Miranda-IM (www.miranda-im.org) + Follower of Custom Status History List by HANAX + Copyright © 2006-2008 HANAX + Copyright © 2007-2009 jarvis + + This program 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. + + This program 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 this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + DESCRIPTION: + + Offers List of your Custom Statuses. + + ============================================================================ + + // ====[ INCLUDES AND DEFINITIONS ]======================================== */ + +#ifndef __CSLIST_H +#define __CSLIST_H 1 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "resource.h" +#include "version.h" + +// ====[ BASIC DEFINITIONS ]================================================== + +#define MODULENAME LPGEN("Custom Status List") +#define MODNAME "CSList" + +// ====[ LIMITS ]============================================================= + +#define EXTRASTATUS_TITLE_LIMIT 64 // limit of chars for extra status title +#define EXTRASTATUS_MESSAGE_LIMIT 2048 // limit of chars for extra status message + +// ====[ DEFAULT DB VALUES ]================================================== + +#define DEFAULT_ICQ_XSTATUS_ENABLED 1 +#define DEFAULT_PLUGIN_SHOW_RELNOTES 0 +#define DEFAULT_PLUGIN_SHOW_NONSTANDARD_XSTATUSES 1 +#define DEFAULT_PLUGIN_CONFIRM_ITEMS_DELETION 1 +#define DEFAULT_PLUGIN_DELETE_AFTER_IMPORT 0 +#define DEFAULT_ITEMS_COUNT 0 +#define DEFAULT_ITEM_ICON 0 +#define DEFAULT_ITEM_IS_FAVOURITE 0 +#define DEFAULT_ALLOW_EXTRA_ICONS 1 +#define DEFAULT_REMEMBER_WINDOW_POSITION 1 + + +// ====[ FUNCTION MACROS ]==================================================== + +// set which row is selected (cannot be only focused, but fully selected - second param ;)) +#define ListView_GetSelectedItemMacro( hwnd ) ListView_GetNextItem( hwnd, -1, LVNI_FOCUSED | LVNI_SELECTED ); +#ifndef ListView_SetSelectionMark +#define ListView_SetSelectionMark( x, y ) 0 +#endif + +#define getByte(setting, error) db_get_b(NULL, MODNAME, setting, error) +#define setByte(setting, value) db_set_b(NULL, MODNAME, setting, value) +#define getWord(setting, error) db_get_w(NULL, MODNAME, setting, error) +#define setWord(setting, value) db_set_w(NULL, MODNAME, setting, value) +#define getDword(setting, error) db_get_dw(NULL, MODNAME, setting, error) +#define setDword(setting, value) db_set_dw(NULL, MODNAME, setting, value) +#define getTString(setting, dest) db_get_ts(NULL, MODNAME, setting, dest) +#define setTString(setting, value) db_set_ts(NULL, MODNAME, setting, value) +#define deleteSetting(setting) db_unset(NULL, MODNAME, setting) + +// -- +typedef void(__cdecl *pForAllProtosFunc)(char*, void *); + + +// ====[ STRUCTURES ]========================================================= + +struct StatusItem // list item structure +{ + int m_iIcon; + TCHAR m_tszTitle[EXTRASTATUS_TITLE_LIMIT]; + TCHAR m_tszMessage[EXTRASTATUS_MESSAGE_LIMIT]; + BOOL m_bFavourite; + + StatusItem() + { + m_iIcon = 0; + mir_tstrcpy(m_tszTitle, _T("")); + mir_tstrcpy(m_tszMessage, _T("")); + m_bFavourite = FALSE; + } + + StatusItem(const StatusItem& p) + { + m_iIcon = p.m_iIcon; + mir_tstrcpy(m_tszTitle, p.m_tszTitle); + mir_tstrcpy(m_tszMessage, p.m_tszMessage); + m_bFavourite = p.m_bFavourite; + } + + ~StatusItem() + { + } +}; + +static struct CSForm { // icons + buttons + int idc; + TCHAR* ptszTitle; + TCHAR* ptszDescr; + char * pszIconIcoLib; + int iconNoIcoLib; + HANDLE hIcoLibItem; + +} forms[] = { + + { -1, LPGENT("Main Menu"), LPGENT("Main Icon"), "icon", IDI_CSLIST }, + { IDC_ADD, LPGENT("Add new item"), LPGENT("Add"), "add", IDI_ADD }, + { IDC_MODIFY, LPGENT("Modify selected item"), LPGENT("Modify"), "modify", IDI_MODIFY }, + { IDC_REMOVE, LPGENT("Delete selected item"), LPGENT("Remove"), "remove", IDI_REMOVE }, + { IDC_FAVOURITE, LPGENT("Set/unset current item as favorite"), LPGENT("Favorite"), "favourite", IDI_FAVOURITE }, + { IDC_UNDO, LPGENT("Undo changes"), LPGENT("Undo changes"), "undo", IDI_UNDO }, + { IDC_IMPORT, LPGENT("Import statuses from database"), LPGENT("Import"), "import", IDI_IMPORT }, + { IDC_FILTER, LPGENT("Filter list"), LPGENT("Filter"), "filter", IDI_FILTER }, + { IDCLOSE, LPGENT("Close without changing custom status"), LPGENT("No change"), "nochng", IDI_CLOSE }, + { IDC_CANCEL, LPGENT("Clear custom status (reset to None) and close"), LPGENT("Clear"), "clear", IDI_UNSET }, + { IDOK, LPGENT("Set custom status to selected one and close"), LPGENT("Set"), "apply", IDI_APPLY } +}; + +// ====[ MY BITCHY LIST IMPLEMENTATION x)) ]================================== +// TODO: Optimize it all x)) + +template< class T > struct ListItem +{ + T* m_item; + ListItem* m_next; + + ListItem() + { + m_item = NULL; + m_next = NULL; + } + + ~ListItem() + { + delete m_item; + } + + ListItem(StatusItem* si) + { + m_item = si; + m_next = NULL; + } + + ListItem(const ListItem& p) + { + m_item = p.item; + m_next = NULL; + } +}; + + +template< class T > struct List +{ +private: + ListItem< T >* m_items; + unsigned int m_count; + +public: + typedef int(*compareFunc)(const T* p1, const T* p2); + compareFunc m_compare; + + List(compareFunc compFnc) + { + m_items = NULL; + m_count = 0; + m_compare = compFnc; + } + + ~List() + { + destroy(); + } + + ListItem< T >* getListHead() + { + return m_items; + } + + unsigned int getCount() + { + return m_count; + } + + int add(T* csi) + { + int position = 0; + ListItem< T >* item = new ListItem< T >(csi); + if (m_items == NULL) + m_items = item; + else + { + ListItem< T >* help = item; + item->m_next = m_items; + while (help->m_next != NULL) + { + int cmp = m_compare(item->m_item, help->m_next->m_item); + if (cmp == 1) + help = help->m_next; + else if (cmp == 0) + { + delete item; + return -1; + } + else + break; + position++; + } + if (help != item) + { + item->m_next = help->m_next; + help->m_next = item; + } + else m_items = item; + } + m_count++; + return position; + } + + int remove(const unsigned int item) + { + int position = 0; + if (item >= m_count) + return -1; + + ListItem< T >* help = m_items; + ListItem< T >* removed; + if (item == 0) + { + m_items = m_items->m_next; + removed = help; + } + else + { + for (unsigned int i = 0; i < item - 1; i++) + { + help = help->m_next; + position++; + } + removed = help->m_next; + help->m_next = help->m_next->m_next; + } + delete removed; + m_count--; + return position; + } + + T* get(const unsigned int item) + { + ListItem< T >* help = m_items; + for (unsigned int i = 0; i < item; i++) + help = help->m_next; + return help->m_item; + } + + T* operator[](const unsigned int item) + { + return get(item); + } + + void destroy() + { + while (m_count > 0) + remove(0); + } +}; + + +// ====[ CLASSING -- FUNNY STUFF :) ]========================================= + +struct CSWindow; +struct CSAMWindow; + +struct CSListView +{ + HWND m_handle; + CSWindow* m_parent; + + CSListView(HWND, CSWindow*); + + void addItem(StatusItem* item, int itemNumber); + void initItems(ListItem< StatusItem >* items); + void reinitItems(ListItem< StatusItem >* items); + void removeItems(); + int getPositionInList(); + void setFullFocusedSelection(int selection); +}; + + +struct CSItemsList +{ + List< StatusItem > *m_list; + + static int compareItems(const StatusItem* p1, const StatusItem* p2); + void loadItems(char *protoName); + void saveItems(char *protoName); + + CSItemsList(char *protoName); + ~CSItemsList(); +}; + +struct CSWindow +{ + HWND m_handle; + BOOL m_bExtraIcons; + CSItemsList* m_itemslist; + CSListView* m_listview; + CSAMWindow* m_addModifyDlg; + HIMAGELIST m_icons; + int m_statusCount; + BOOL m_bSomethingChanged; + TCHAR* m_filterString; + char * m_protoName; + + CSWindow(char *protoName); + ~CSWindow(); + + void initIcons(); + void deinitIcons(); + void initButtons(); + void loadWindowPosition(); + BOOL toggleButtons(); + void toggleEmptyListMessage(); + void toggleFilter(); + BOOL itemPassedFilter(ListItem< StatusItem >* li); + + void __inline saveWindowPosition(HWND hwnd) + { + if (getByte("RememberWindowPosition", DEFAULT_REMEMBER_WINDOW_POSITION) == TRUE) + Utils_SaveWindowPosition(hwnd, NULL, MODNAME, "Position"); + } +}; + +struct CSAMWindow +{ + WORD m_action; + StatusItem* m_item; + CSWindow* m_parent; + BOOL m_bChanged; + + HWND m_handle; + HWND m_hCombo; + HWND m_hMessage; + + CSAMWindow(WORD action, CSWindow* parent); + ~CSAMWindow(); + + void exec(); + void setCombo(); + void fillDialog(); + void checkFieldLimit(WORD action, WORD item); + void checkItemValidity(); +}; + + +// service functions +INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM); + +// protocols enumeration related functions +void addProtoStatusMenuItem(char *protoName); + +// other functions +void IitIcoLib(); +void RegisterHotkeys(char buf[200], TCHAR* accName, int Number); +void SetStatus(WORD code, StatusItem* item, char *protoName); + +// ====[ PROCEDURES ]========================================================= + +INT_PTR CALLBACK CSWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); +INT_PTR CALLBACK CSAMWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); +INT_PTR CALLBACK CSRNWindowProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); +INT_PTR CALLBACK CSOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); + +#endif /* __CSLIST_H */ -- cgit v1.2.3