diff options
Diffstat (limited to 'custom_status_list/cslist.h')
-rw-r--r-- | custom_status_list/cslist.h | 884 |
1 files changed, 614 insertions, 270 deletions
diff --git a/custom_status_list/cslist.h b/custom_status_list/cslist.h index da3cc26..440981f 100644 --- a/custom_status_list/cslist.h +++ b/custom_status_list/cslist.h @@ -1,346 +1,690 @@ -// ############################ INCLUDES & DEFINITIONS #########################
+/* ========================================================================
+
+ 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.
+
+ ============================================================================
+
+ File name : $URL$
+ Revision : $Rev$
+ Last change on : $Date$
+ Last change by : $Author$
+
+ ============================================================================
+
+
+ DESCRIPTION:
+
+ Offers List of your Custom Statuses.
+
+ ============================================================================
+
+// ====[ INCLUDES AND DEFINITIONS ]======================================== */
#ifndef __CSLIST_H
#define __CSLIST_H 1
-#if defined( UNICODE ) && !defined( _UNICODE )
- #define _UNICODE
+#if defined UNICODE
+#define WINVER 0x501
+#define _WIN32_WINNT 0x501
+#define _WIN32_IE 0x600
+#else
+#define WINVER 0x400
+#define _WIN32_WINNT 0x400
+#define _WIN32_IE 0x400
+#define LVIF_GROUPID 0
#endif
+#define MIRANDA_VER 0x0900
+
+#pragma warning( disable: 4996 )
+#pragma comment( lib, "comctl32.lib" )
#include <windows.h>
-//#include <windef.h> // already in windows.h
-#include <stddef.h>
#include <commctrl.h>
-#if defined( _UNICODE )
- #include <string.h>
- #include <tchar.h>
- #include <win2k.h>
-#endif
+#include <tchar.h>
+#include <win2k.h>
#include <newpluginapi.h>
-#include <m_clist.h>
-#include <m_skin.h>
-#include <m_icolib.h>
#include <m_database.h>
-#include <m_system.h>
#include <m_utils.h>
-#include <m_updater.h>
#include <m_langpack.h>
-#include <m_button.h>
+#include <m_clist.h>
+#include <m_clistint.h>
+#include <m_genmenu.h>
+#include <m_skin.h>
+#include <m_icolib.h>
+#include <m_protocols.h>
+#include <m_protosvc.h>
+#include <m_icq.h>
+#include <m_jabber.h>
#include <m_options.h>
-#include <m_toolbar.h>
#include <m_hotkeys.h>
-#include <m_protocols.h>
-//#include <stdio.h>
+#include <m_variables.h>
+
+// ====[ BASIC DEFINITIONS ]==================================================
#include "resource.h"
+#include "version.h"
-#define MIID_STATUSLIST { 0x8b86253, 0xec6e, 0x4d09, { 0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8 } }
+#define MODULENAME "Custom Status List"
-#define CSLIST_RELNOTES 19 // actual eternity relnotes
-#define CSLIST_TESTING "1"
-#define CSLIST_XTITLE_LIMIT 64 // limit of chars for x-status title
-#define CSLIST_XMESSAGE_LIMIT 2048 // limit of chars for x-status message
+// {C8CC7414-6507-4AF6-925A-83C1D2F7BE8C}
+#define PLUGIN_GUUID { 0xc8cc7414, 0x6507, 0x4af6, { 0x92, 0x5a, 0x83, 0xc1, 0xd2, 0xf7, 0xbe, 0x8c } }
-#define CSLIST_MODULE_LONG_NAME "Custom Status List"
-#define CSLIST_MODULE_SHORT_NAME "CSList"
+// ====[ LIMITS ]=============================================================
-// updater strings
+#define EXTRASTATUS_TITLE_LIMIT 64 // limit of chars for extra status title
+#define EXTRASTATUS_MESSAGE_LIMIT 2048 // limit of chars for extra status message
+#define XSTATUS_COUNT 32
+#define XSTATUS_COUNT_EXTENDED 37
+#define MOODS_COUNT 84
-#define CSLIST_UPD_VERURL "http://dev.mirandaim.ru/~jarvis/"
-#define CSLIST_UPD_UPDURL "http://mirandapack.ic.cz/eternity_plugins/cslist.zip"
-#define CSLIST_UPD_FLVERURL "http://addons.miranda-im.org/details.php?action=viewfile&id=3483"
-#define CSLIST_UPD_FLUPDURL "http://addons.miranda-im.org/feed.php?dlfile=3483"
-#define CSLIST_UPD_SZPREFIX "Custom Status List</a> "
+// ====[ SERVICES ]===========================================================
-// services
+#define MS_PSEUDO_PROTO_PROTOACCSENUM ( CSList::bAccountsSupported ? MS_PROTO_ENUMACCOUNTS : MS_PROTO_ENUMPROTOCOLS )
-#define MS_CLIST_ADDSTATUSMENUITEM "CList/AddStatusMenuItem"
-#define ME_CLIST_PREBUILDSTATUSMENU "CList/PreBuildStatusMenu"
-#define PS_ICQ_SETCUSTOMSTATUSEX "ICQ/SetXStatusEx"
-#define MS_CSLIST_SHOWLIST "CSList/ShowList"
+// ====[ DEFAULT DB VALUES ]==================================================
-// status flags
+#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
-#define CSSF_MASK_STATUS 0x0001 // status member valid for set/get
-#define CSSF_MASK_NAME 0x0002 // pszName member valid for set/get
-#define CSSF_MASK_MESSAGE 0x0004 // pszMessage member valid for set/get
-#define CSSF_DISABLE_UI 0x0040 // disable default custom status UI, wParam = bEnable
-#define CSSF_DEFAULT_NAME 0x0080 // only with CSSF_MASK_NAME and get API to get default custom status name (wParam = status)
-#define CSSF_STATUSES_COUNT 0x0100 // returns number of custom statuses in wParam, only get API
-#define CSSF_STR_SIZES 0x0200 // returns sizes of custom status name & message (wParam & lParam members) in chars
-#if defined( _UNICODE )
- #define CSSF_UNICODE 0x1000 // strings are in Unicode
-#else
- #define CSSF_UNICODE 0x0000
-#endif
-#if defined( _UNICODE )
- #define tcstok( x, y ) wcstok( x, y )
- #define tcprintf( a, b, c, d ) swprintf( a, b, c, d )
-#else
- #define tcstok( x, y ) strtok( x, y )
- #define tcprintf( a, b, c, d ) sprintf( a, c, d )
+// ====[ 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
-// win2k.h
-#define SIZEOF( x ) ( sizeof( x ) / sizeof( x[0] ) )
-#define IsWinVerXPPlus() ( LOBYTE( LOWORD( GetVersion( ) ) ) >= 5 && LOWORD( GetVersion( ) ) != 5 )
-
-
-// ################################## STRUCTURES ###############################
-
-// -------------------------- WORKING LIST ITEM STRUCTURE ----------------------
-
-typedef struct {
- int ItemIcon;
- TCHAR ItemTitle[CSLIST_XTITLE_LIMIT];
- TCHAR ItemMessage[CSLIST_XMESSAGE_LIMIT];
- BOOL ItemFavourite;
-} CSLISTSTATUSITEM;
-
-
-// -------------------------- ICQ CUSTOM STATUS STRUCTURE ----------------------
-
-typedef struct {
- int cbSize; // size of the structure
- int flags; // combination of CSSF_*
- int *status; // custom status id
- union {
- char *pszName; // buffer for custom status name
- TCHAR *ptszName;
- WCHAR *pwszName;
- };
- union {
- char *pszMessage; // buffer for custom status message
- TCHAR *ptszMessage;
- WCHAR *pwszMessage;
- };
- WPARAM *wParam; // extra params, see flags
- LPARAM *lParam;
-} ICQ_CUSTOM_STATUS;
-
-
-// ------------------------------ ICONS + BUTTONS ------------------------------
-
-static struct {
- int idc;
- TCHAR *title;
- TCHAR *szDescr;
- char *iconIcoLib;
- int iconNoIcoLib;
- HANDLE hIcoLibItem;
-} cslforms[] =
-{
- { -1, L"Main Menu" , ( TCHAR * )"Main Icon", "csl_icon", IDI_CSLIST, NULL },
- { IDC_ADD, L"Add new item", ( TCHAR * )"Add", "csl_add", IDI_ADD, NULL },
- { IDC_MODIFY, L"Modify selected item", ( TCHAR * )"Modify", "csl_modify", IDI_MODIFY, NULL },
- { IDC_REMOVE, L"Delete selected item", ( TCHAR * )"Remove", "csl_remove", IDI_REMOVE, NULL },
- { IDC_IMPORT, L"Import statuses from database", ( TCHAR * )"Import", "csl_import", IDI_IMPORT, NULL },
- { IDC_WATCH, L"Whether or not watch custom status changes and add them into list", ( TCHAR * )"Watch", "csl_watch", IDI_WATCH, NULL },
- { IDC_FAV, L"Set/unset current item as favorite", ( TCHAR * )"Favorite", "csl_fav", IDI_FAV, NULL },
- { IDC_OPTS, L"Options...", ( TCHAR * )"Options", "csl_opts", IDI_OPTIONS, NULL },
- { IDC_NOCHNG, L"Close without changing custom status", ( TCHAR * )"No change", "csl_nochng", IDI_NOCHNG, NULL },
- { IDC_APPLY, L"Set custom status to selected one and close", ( TCHAR * )"Set", "csl_apply", IDI_APPLY, NULL },
- { IDC_EXIT, L"Clear custom status (reset to None) and close", ( TCHAR * )"Clear", "csl_clear", IDI_CLEAR, NULL },
+#define getByte( setting, error ) DBGetContactSettingByte( NULL, __INTERNAL_NAME, setting, error )
+#define setByte( setting, value ) DBWriteContactSettingByte( NULL, __INTERNAL_NAME, setting, value )
+#define getWord( setting, error ) DBGetContactSettingWord( NULL, __INTERNAL_NAME, setting, error )
+#define setWord( setting, value ) DBWriteContactSettingWord( NULL, __INTERNAL_NAME, setting, value )
+#define getDword( setting, error ) DBGetContactSettingDword( NULL, __INTERNAL_NAME, setting, error )
+#define setDword( setting, value ) DBWriteContactSettingDword( NULL, __INTERNAL_NAME, setting, value )
+#define getTString( setting, dest ) DBGetContactSettingTString( NULL, __INTERNAL_NAME, setting, dest )
+#define setTString( setting, value ) DBWriteContactSettingTString( NULL, __INTERNAL_NAME, setting, value )
+#define deleteSetting( setting ) DBDeleteContactSetting( NULL, __INTERNAL_NAME, setting )
+
+// --
+typedef void (__cdecl *pForAllProtosFunc)( char*, void* );
+
+
+// ====[ STRUCTURES ]=========================================================
+
+struct StatusItem { // list item structure
+ int iIcon;
+ TCHAR tszTitle[EXTRASTATUS_TITLE_LIMIT];
+ TCHAR tszMessage[EXTRASTATUS_MESSAGE_LIMIT];
+ BOOL bFavourite;
+
+ StatusItem()
+ {
+ this->iIcon = 0;
+ lstrcpy(this->tszTitle, _T(""));
+ lstrcpy(this->tszMessage, _T(""));
+ this->bFavourite = FALSE;
+ }
+
+ StatusItem( const StatusItem& p )
+ {
+ this->iIcon = p.iIcon;
+ lstrcpy( this->tszTitle, p.tszTitle );
+ lstrcpy( this->tszMessage, p.tszMessage );
+ this->bFavourite = p.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, NULL },
+ { IDC_ADD, LPGENT( "Add new item" ), LPGENT( "Add" ), "add", IDI_ADD, NULL },
+ { IDC_MODIFY, LPGENT( "Modify selected item" ), LPGENT( "Modify" ), "modify", IDI_MODIFY, NULL },
+ { IDC_REMOVE, LPGENT( "Delete selected item" ), LPGENT( "Remove" ), "remove", IDI_REMOVE, NULL },
+ { IDC_FAVOURITE, LPGENT( "Set/unset current item as favorite" ), LPGENT( "Favourite" ), "favourite", IDI_FAVOURITE, NULL },
+ { IDC_UNDO, LPGENT( "Undo changes" ), LPGENT( "Undo changes" ), "undo", IDI_UNDO, NULL },
+ { IDC_IMPORT, LPGENT( "Import statuses from database" ), LPGENT( "Import" ), "import", IDI_IMPORT, NULL },
+ { IDC_FILTER, LPGENT( "Filter list" ), LPGENT( "Filter" ), "filter", IDI_FILTER, NULL },
+ { IDCLOSE, LPGENT( "Close without changing custom status" ), LPGENT( "No change" ), "nochng", IDI_CLOSE, NULL },
+ { IDC_CANCEL, LPGENT( "Clear custom status (reset to None) and close" ), LPGENT( "Clear" ), "clear", IDI_UNSET, NULL },
+ { IDOK, LPGENT( "Set custom status to selected one and close" ), LPGENT( "Set" ), "apply", IDI_APPLY, NULL },
+};
-// ----------------------- COMBOBOXEX XICONS STRUCTURE -------------------------
+static struct CSXstatus { // combobox xstatus icons
+ int iId;
+ TCHAR* ptszTitle;
+
+} xstatus_names[] = {
+
+ { 1, LPGENT( "Angry" ) },
+ { 2, LPGENT( "Taking a bath" ) },
+ { 3, LPGENT( "Tired" ) },
+ { 4, LPGENT( "Party" ) },
+ { 5, LPGENT( "Drinking beer" ) },
+ { 6, LPGENT( "Thinking" ) },
+ { 7, LPGENT( "Eating" ) },
+ { 8, LPGENT( "Watching TV" ) },
+ { 9, LPGENT( "Meeting" ) },
+ { 10, LPGENT( "Coffee" ) },
+ { 11, LPGENT( "Listening to music" ) },
+ { 12, LPGENT( "Business" ) },
+ { 13, LPGENT( "Shooting" ) },
+ { 14, LPGENT( "Having fun" ) },
+ { 15, LPGENT( "On the phone" ) },
+ { 16, LPGENT( "Gaming" ) },
+ { 17, LPGENT( "Studying" ) },
+ { 18, LPGENT( "Shopping" ) },
+ { 19, LPGENT( "Feeling sick" ) },
+ { 20, LPGENT( "Sleeping" ) },
+ { 21, LPGENT( "Surfing" ) },
+ { 22, LPGENT( "Browsing" ) },
+ { 23, LPGENT( "Working" ) },
+ { 24, LPGENT( "Typing" ) },
+ { 25, LPGENT( "Picnic" ) },
+ { 26, LPGENT( "PDA" ) },
+ { 27, LPGENT( "On the phone" ) },
+ { 28, LPGENT( "I'm high" ) },
+ { 29, LPGENT( "On WC" ) },
+ { 30, LPGENT( "To be or not to be" ) },
+ { 31, LPGENT( "Watching pro7 on TV" ) },
+ { 32, LPGENT( "Love" ) },
+ { 33, LPGENT( "Searching" ) },
+ { 34, LPGENT( "Amorous" ) }, // I don't understand why this falls when 2 same named items appear O_o
+ { 35, LPGENT( "Journal" ) }, // edit: ..and now I REALLY don't understand why it's working now x))
+ { 36, LPGENT( "Sex" ) },
+ { 37, LPGENT( "Smoking" ) }, // -||-
+};
-static struct
-{
- int xnum;
- TCHAR *xname;
-} xstatuses[] =
-{
- {1, _T("Angry")},
- {2, _T("Taking a bath")},
- {3, _T("Tired")},
- {4, _T("Party")},
- {5, _T("Drinking beer")},
- {6, _T("Thinking")},
- {7, _T("Eating")},
- {8, _T("Watching TV")},
- {9, _T("Meeting")},
- {10, _T("Coffee")},
- {11, _T("Listening to music")},
- {12, _T("Business")},
- {13, _T("Shooting")},
- {14, _T("Having fun")},
- {15, _T("On the phone")},
- {16, _T("Gaming")},
- {17, _T("Studying")},
- {18, _T("Shopping")},
- {19, _T("Feeling sick")},
- {20, _T("Sleeping")},
- {21, _T("Surfing")},
- {22, _T("Browsing")},
- {23, _T("Working")},
- {24, _T("Typing")},
- {25, _T("Picnic")},
- {26, _T("Cooking")},
- {27, _T("Smoking")},
- {28, _T("I'm High")},
- {29, _T("On WC")},
- {30, _T("To be or not to be")},
- {31, _T("Watching pro7 on TV")},
- {32, _T("Love")},
- {33, _T("Searching")},
- {34, _T("Love")}, // I don't understand why this falls when 2 same named items appear O_o
- {35, _T("Journal")}, // edit: ..and now I REALLY don't understand why it's working now x))
- {36, _T("Sex")},
- {37, _T("Smoking")}, // -||-
+static struct CSMoods { // combobox moods icons
+ int iId;
+ TCHAR* ptszTitle;
+ char* szTag;
+} moods_names[] = {
+ { 1, LPGENT("Afraid"), "afraid" },
+ { 2, LPGENT("Amazed"), "amazed" },
+ { 3, LPGENT("Amorous"), "amorous" },
+ { 4, LPGENT("Angry"), "angry" },
+ { 5, LPGENT("Annoyed"), "annoyed" },
+ { 6, LPGENT("Anxious"), "anxious" },
+ { 7, LPGENT("Aroused"), "aroused" },
+ { 8, LPGENT("Ashamed"), "ashamed" },
+ { 9, LPGENT("Bored"), "bored" },
+ { 10, LPGENT("Brave"), "brave" },
+ { 11, LPGENT("Calm"), "calm" },
+ { 12, LPGENT("Cautious"), "cautious" },
+ { 13, LPGENT("Cold"), "cold" },
+ { 14, LPGENT("Confident"), "confident" },
+ { 15, LPGENT("Confused"), "confused" },
+ { 16, LPGENT("Contemplative"),"contemplative" },
+ { 17, LPGENT("Contented"), "contented" },
+ { 18, LPGENT("Cranky"), "cranky" },
+ { 19, LPGENT("Crazy"), "crazy" },
+ { 20, LPGENT("Creative"), "creative" },
+ { 21, LPGENT("Curious"), "curious" },
+ { 22, LPGENT("Dejected"), "dejected" },
+ { 23, LPGENT("Depressed"), "depressed" },
+ { 24, LPGENT("Disappointed"), "disappointed" },
+ { 25, LPGENT("Disgusted"), "disgusted" },
+ { 26, LPGENT("Dismayed"), "dismayed" },
+ { 27, LPGENT("Distracted"), "distracted" },
+ { 28, LPGENT("Embarrassed"), "embarrassed" },
+ { 29, LPGENT("Envious"), "envious" },
+ { 30, LPGENT("Excited"), "excited" },
+ { 31, LPGENT("Flirtatious"), "flirtatious" },
+ { 32, LPGENT("Frustrated"), "frustrated" },
+ { 33, LPGENT("Grateful"), "grateful" },
+ { 34, LPGENT("Grieving"), "grieving" },
+ { 35, LPGENT("Grumpy"), "grumpy" },
+ { 36, LPGENT("Guilty"), "guilty" },
+ { 37, LPGENT("Happy"), "happy" },
+ { 38, LPGENT("Hopeful"), "hopeful" },
+ { 39, LPGENT("Hot"), "hot" },
+ { 40, LPGENT("Humbled"), "humbled" },
+ { 41, LPGENT("Humiliated"), "humiliated" },
+ { 42, LPGENT("Hungry"), "hungry" },
+ { 43, LPGENT("Hurt"), "hurt" },
+ { 44, LPGENT("Impressed"), "impressed" },
+ { 45, LPGENT("In awe"), "in_awe" },
+ { 46, LPGENT("In love"), "in_love" },
+ { 47, LPGENT("Indignant"), "indignant" },
+ { 48, LPGENT("Interested"), "interested" },
+ { 49, LPGENT("Intoxicated"), "intoxicated" },
+ { 50, LPGENT("Invincible"), "invincible" },
+ { 51, LPGENT("Jealous"), "jealous" },
+ { 52, LPGENT("Lonely"), "lonely" },
+ { 53, LPGENT("Lost"), "lost" },
+ { 54, LPGENT("Lucky"), "lucky" },
+ { 55, LPGENT("Mean"), "mean" },
+ { 56, LPGENT("Moody"), "moody" },
+ { 57, LPGENT("Nervous"), "nervous" },
+ { 58, LPGENT("Neutral"), "neutral" },
+ { 59, LPGENT("Offended"), "offended" },
+ { 60, LPGENT("Outraged"), "outraged" },
+ { 61, LPGENT("Playful"), "playful" },
+ { 62, LPGENT("Proud"), "proud" },
+ { 63, LPGENT("Relaxed"), "relaxed" },
+ { 64, LPGENT("Relieved"), "relieved" },
+ { 65, LPGENT("Remorseful"), "remorseful" },
+ { 66, LPGENT("Restless"), "restless" },
+ { 67, LPGENT("Sad"), "sad" },
+ { 68, LPGENT("Sarcastic"), "sarcastic" },
+ { 69, LPGENT("Satisfied"), "satisfied" },
+ { 70, LPGENT("Serious"), "serious" },
+ { 71, LPGENT("Shocked"), "shocked" },
+ { 72, LPGENT("Shy"), "shy" },
+ { 73, LPGENT("Sick"), "sick" },
+ { 74, LPGENT("Sleepy"), "sleepy" },
+ { 75, LPGENT("Spontaneous"), "spontaneous" },
+ { 76, LPGENT("Stressed"), "stressed" },
+ { 77, LPGENT("Strong"), "strong" },
+ { 78, LPGENT("Surprised"), "surprised" },
+ { 79, LPGENT("Thankful"), "thankful" },
+ { 80, LPGENT("Thirsty"), "thirsty" },
+ { 81, LPGENT("Tired"), "tired" },
+ { 82, LPGENT("Undefined"), "undefined" },
+ { 83, LPGENT("Weak"), "weak" },
+ { 84, LPGENT("Worried"), "worried" },
};
+// ====[ MY BITCHY LIST IMPLEMENTATION x)) ]==================================
+// TODO: Optimize it all x))
+template< class T > struct ListItem
+{
+ T* item;
+ ListItem* next;
+
+ ListItem( )
+ {
+ this->item = NULL;
+ this->next = NULL;
+ }
+
+ ~ListItem( )
+ {
+ delete this->item;
+ }
+
+ ListItem( StatusItem* si )
+ {
+ this->item = si;
+ this->next = NULL;
+ }
+
+ ListItem( const ListItem& p )
+ {
+ this->item = p.item;
+ this->next = NULL;
+ }
+};
-// ---------------------- LIST SORTING OPTIONS STRUCTURE -----------------------
-static struct
+template< class T > struct List
{
- int columnIndex;
- HWND listView;
- BOOL isOrderDesc;
-} sorting = {
- 0, NULL, FALSE
+private:
+ ListItem< T >* items;
+ unsigned int count;
+
+public:
+ typedef int ( *compareFunc )( const T* p1, const T* p2 );
+ compareFunc compare;
+
+ List( compareFunc compFnc )
+ {
+ this->items = NULL;
+ this->count = 0;
+ this->compare = compFnc;
+ }
+
+ ~List( )
+ {
+ this->destroy( );
+ }
+
+ ListItem< T >* getListHead( )
+ {
+ return items;
+ }
+
+ unsigned int getCount( )
+ {
+ return count;
+ }
+
+ int add( T* csi )
+ {
+ int position = 0;
+ ListItem< T >* item = new ListItem< T >( csi );
+ if ( this->items == NULL )
+ this->items = item;
+ else
+ {
+ ListItem< T >* help = item;
+ item->next = items;
+ while ( help->next != NULL )
+ {
+ int cmp = compare( item->item, help->next->item );
+ if ( cmp == 1 )
+ help = help->next;
+ else if ( cmp == 0 )
+ {
+ delete item;
+ return -1;
+ }
+ else
+ break;
+ position++;
+ }
+ if ( help != item )
+ {
+ item->next = help->next;
+ help->next = item;
+ }
+ else
+ items = item;
+ }
+ this->count++;
+ return position;
+ }
+
+ int remove( const unsigned int item )
+ {
+ int position = 0;
+ if ( item < 0 || item >= this->count )
+ return -1;
+
+ ListItem< T >* help = items;
+ ListItem< T >* removed;
+ if ( item == 0 )
+ {
+ items = items->next;
+ removed = help;
+ }
+ else
+ {
+ for ( unsigned int i = 0; i < item - 1; i++ )
+ {
+ help = help->next;
+ position++;
+ }
+ removed = help->next;
+ help->next = help->next->next;
+ }
+ delete removed;
+ this->count--;
+ return position;
+ }
+
+ T* get( const unsigned int item )
+ {
+ ListItem< T >* help = items;
+ for ( unsigned int i = 0; i < item; i++ )
+ help = help->next;
+ return help->item;
+ }
+
+ T* operator[]( const unsigned int item )
+ {
+ return get( item );
+ }
+
+ void destroy( )
+ {
+ while ( this->count > 0 )
+ this->remove( 0 );
+ }
};
-// ################################## GLOBALS ##################################
-HINSTANCE hInst = NULL;
-PLUGINLINK *pluginLink = NULL;
+// ====[ CLASSING -- FUNNY STUFF :) ]=========================================
-DWORD gMirandaVersion = 0x00000000;
-BYTE gbUnicodeCore;
+struct CSList;
+struct CSWindow;
+struct CSAMWindow;
+struct CSItemsList;
+struct CSListView;
-TCHAR *rnthanks = L"induction - for his cool iconset :)\r\nfaith_healer - moral support :]\r\nCriS - project hosting @ http://dev.mirandaim.ru/ \r\nRobyer, kaye_styles, dEMoniZaToR, Drugwash, FREAK_THEMIGHTY - useful hints ;)\r\nplugin users, of course :) for their tolerance x) ;)\r\nMiranda IM Project Team - for their work on the best Instant Messenger I ever known :)";
-TCHAR *rnchanges = L"";
+// --------
-int action = 0;
-int AMResult = 0;
-int ModifiedPos = -1;
-int opened = 0;
+struct CSListView
+{
+ HWND handle;
+ CSWindow* parent;
-static HWND hDlg = NULL; // Main Dialog handler
-static HWND hList = NULL; // List View handler
-HIMAGELIST hIml = NULL;
-HWND hXCombo = NULL;
-int hMainIcon = 0; // modern toolbar // TODO: is it needed?
-LVCOLUMN LvCol = { 0 }; // Make Coluom struct for ListView
-LVITEM LvItem = { 0 }; // ListView Item struct
-COMBOBOXEXITEM CbItem = { 0 };
-int iSelect = 0;
-int flag = 0;
-BOOL bChanged = 0;
-CSLISTSTATUSITEM helpItem = { 0 };
+ CSListView( HWND, CSWindow* );
-// hooks
-HANDLE hHookMenuBuild = NULL;
-HANDLE hHookOnPluginsLoaded = NULL;
-HANDLE hHookOnOptionsInit = NULL;
-HANDLE hHookOnKatynkaIsLoggedIn = NULL;
+ void addItem( StatusItem* item, int itemNumber );
+ void initItems( ListItem< StatusItem >* items );
+ void reinitItems( ListItem< StatusItem >* items );
+ void removeItems( );
+ int getPositionInList( );
+ void setFullFocusedSelection( int selection );
+};
-// services
-HANDLE hSvcShowList = NULL;
-BOOL bStatusMenu = FALSE;
+struct CSItemsList
+{
+ List< StatusItem >* list;
-PLUGININFOEX pluginInfoEx = {
- sizeof( PLUGININFOEX ),
- CSLIST_MODULE_LONG_NAME,
- PLUGIN_MAKE_VERSION( 0, 0, 0, 19 ),
- "Offers list of your Custom Statuses. [test build #"CSLIST_TESTING" "__DATE__" "__TIME__"]",
- "jarvis [eThEreAL] .., HANAX",
- "mike.taussick@seznam.cz",
- "© 2007-2008 eternity crew .., © 2006-2007 HANAX Software",
- "http://dev.mirandaim.ru/~jarvis/",
- UNICODE_AWARE, //not transient
- 0, //doesn't replace anything built-in
- // Generate your own unique id for your plugin.
- // Do not use this UUID!
- // Use uuidgen.exe to generate the uuuid
- {0x8b86253, 0xec6e, 0x4d09, { 0xb7, 0xa9, 0x64, 0xac, 0xdf, 0x6, 0x27, 0xb8 }} //{08B86253-EC6E-4d09-B7A9-64ACDF0627B8}
+ static int compareItems( const StatusItem* p1, const StatusItem* p2 );
+ void loadItems(char* protoName);
+ void saveItems(char* protoName);
+
+ CSItemsList(char* protoName);
+ ~CSItemsList();
};
-PLUGININFO pluginInfo = {
- sizeof( PLUGININFO ),
- CSLIST_MODULE_LONG_NAME,
- PLUGIN_MAKE_VERSION( 0, 0, 0, 19 ),
- "Offers list of your Custom Statuses. [test build #"CSLIST_TESTING" "__DATE__" "__TIME__"]",
- "jarvis [eThEreAL] .., HANAX",
- "mike.taussick@seznam.cz",
- "© 2007-2008 eternity crew .., © 2006-2007 HANAX Software",
- "http://dev.mirandaim.ru/~jarvis/",
- UNICODE_AWARE, //not transient
- 0
+
+struct CSAMWindow
+{
+ WORD action;
+ StatusItem* item;
+ CSWindow* parent;
+ BOOL bChanged;
+
+ HWND handle;
+ HWND hCombo;
+ HWND hMessage;
+
+ CSAMWindow( WORD action, CSWindow* parent );
+ ~CSAMWindow( );
+
+ void exec( );
+ void setCombo( );
+ void fillDialog( );
+ void checkFieldLimit( WORD action, WORD item );
+ void checkItemValidity();
};
-// ############################# INIT STUFF ####################################
-BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved );
-static int PluginMenuCommand( WPARAM wParam, LPARAM lParam );
+struct CSWindow
+{
+ HWND handle;
+ BOOL bExtraIcons;
+ CSItemsList* itemslist;
+ CSListView* listview;
+ CSAMWindow* addModifyDlg;
+ HIMAGELIST icons;
+ BOOL bSomethingChanged;
+ TCHAR* filterString;
+ char* protoName;
+ CSWindow(char* protoName);
+ ~CSWindow();
+
+ void initIcons( );
+ void deinitIcons( );
+ void initButtons( );
+ static void __cdecl showWindow( void* arg );
+ static void __cdecl closeWindow( void* arg );
+ 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 )
+ {
+ RECT rect = { 0 };
+ GetWindowRect( hwnd, &rect );
+ setWord( "PositionX", rect.left );
+ setWord( "PositionY", rect.top );
+ }
+ }
+};
-__declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD mirandaVersion );
-__declspec( dllexport ) PLUGININFO* MirandaPluginInfo( DWORD mirandaVersion );
-static const MUUID interfaces[] = { MIID_TESTPLUGIN, MIID_STATUSLIST, MIID_LAST };
-__declspec( dllexport ) const MUUID* MirandaPluginInterfaces( void );
+struct CSList
+{
+ // global variables
+ static HINSTANCE handle;
+ static DWORD dwMirandaVersion;
+ static BOOL bUnicodeCore;
+ static BOOL bAccountsSupported;
+
+ // class components
+ CSWindow* mainWindow;
+
+ // events
+ HANDLE hHookOnPluginsLoaded;
+ HANDLE hHookOnOptionsInit;
+ HANDLE hHookOnDBSettingChanged;
+ HANDLE hHookOnStatusMenuBuild;
+
+ // services
+ HANDLE hServiceShowList;
+
+ CSList( );
+ ~CSList( );
+
+ // event functions
+ static int postLoading( WPARAM, LPARAM );
+ static int initOptions( WPARAM, LPARAM );
+ static int respondDBChange( WPARAM, LPARAM );
+ static int createMenuItems( WPARAM, LPARAM );
+
+ // service functions
+ static INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM);
+ void closeList( HWND );
+
+ // protocols enumeration related functions
+ static void ForAllProtocols( pForAllProtosFunc pFunc, void* arg );
+ static void __cdecl addProtoStatusMenuItem( char* protoName, void* arg );
+ static void __cdecl countProtos( char* protoName, void* arg );
+ static void __cdecl countPlusModProtos( char* protoName, void* arg );
+ static void __cdecl importCustomStatusUIStatusesFromAllProtos( char* protoName, void* arg );
+
+ // other functions
+ void initIcoLib( );
+ void registerHotkeys(char buf[200], TCHAR* accName, int Number);
+ void rebuildMenuItems( );
+ void setStatus(WORD code, StatusItem* item, char* protoName);
+};
-int __declspec( dllexport ) Load( PLUGINLINK *link );
-int __declspec( dllexport ) Unload( void );
-static int onPluginsLoaded( WPARAM wparam, LPARAM lparam );
-int onOptionsInit( WPARAM wparam, LPARAM lparam );
+HINSTANCE CSList::handle = NULL;
+DWORD CSList::dwMirandaVersion = 0x00000000;
+BOOL CSList::bUnicodeCore = FALSE;
+BOOL CSList::bAccountsSupported = FALSE;
-// ############################### PROCEDURES ##################################
+// ====[ GLOBALS ]============================================================
-INT_PTR CALLBACK CSListProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
-INT_PTR CALLBACK CSListAddModifyProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
-BOOL CALLBACK CSListOptionsProc( HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam );
-static int CALLBACK CSListSortProc( LPARAM, LPARAM, LPARAM );
-INT_PTR CALLBACK RelNotesProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
+static const MUUID interfaces[] = { PLUGIN_GUUID, MIID_LAST };
-// ############################# HELP FUNCTIONS ################################
+PLUGINLINK* pluginLink = NULL;
+PLUGININFOEX pluginInfoEx = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ 0,
+ PLUGIN_GUUID
+};
-int null_snprintf( char*, size_t, const char*, ... );
-static int cslist_init_menu_item( WPARAM wParam, LPARAM lParam );
+CSList* cslist = NULL;
-// ################## COMMANDS OF CSLIST #######################################
-int cslist_add_item();
-int cslist_modify_item();
-int cslist_remove_item();
-int cslist_AM_set_help_item( HWND hwndAMDlg );
+// ====[ INIT STUFF ]=========================================================
-// ################## SERVICES FOR CSLIST ######################################
+BOOL WINAPI DllMain( HINSTANCE, DWORD, LPVOID );
-void cslist_clear_selection();
-void cslist_clear_help_item();
-void cslist_sort_list();
-void cslist_import_statuses_from_icq();
-int cslist_KatysEasterEgg( WPARAM, LPARAM );
+extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD );
+extern "C" __declspec( dllexport ) PLUGININFO* MirandaPluginInfo( DWORD );
+extern "C" __declspec( dllexport ) const MUUID* MirandaPluginInterfaces( void );
-// ################## DB - LOAD AND SAVE #######################################
+extern "C" __declspec( dllexport ) int Load( PLUGINLINK* );
+extern "C" __declspec( dllexport ) int Unload( void );
-int cslist_initialize_list_content( HWND hwndDlg );
-int cslist_parse_row( TCHAR *row );
-int cslist_save_list_content( HWND hwndDlg );
-// ######################### CREATING DIALOG ###################################
+// ====[ THREAD FORK ]========================================================
-int cslist_set_status( HWND hwndDlg );
-void cslist_init_icons( void );
+void ForkThread( pThreadFunc pFunc, void* arg );
-// ######################### OTHER FUNCTIONS ###################################
+// ====[ PROCEDURES ]=========================================================
-HICON LoadIconExEx( const char* IcoLibName, int NonIcoLibIcon );
-//void DBDeleteContactSetting( char Module[64], char Setting[64] );
+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 );
-// ############################## EXTERNS ######################################
-//extern int mir_free( const int & );
-//extern int ImageList_AddIcon_IconLibLoaded( HIMAGELIST hIml, int iconId );
+// ====[ HELPERS ]============================================================
+
+HICON LoadIconExEx( const char*, int );
+
+void __fastcall SAFE_FREE(void** p)
+{
+ if (*p)
+ {
+ free(*p);
+ *p = NULL;
+ }
+}
-#pragma comment( lib, "comctl32.lib" )
-#endif /* __CSLIST_H */
\ No newline at end of file +#endif /* __CSLIST_H */
|