summaryrefslogtreecommitdiff
path: root/plugins/CSList/src/cslist.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CSList/src/cslist.h')
-rw-r--r--plugins/CSList/src/cslist.h440
1 files changed, 125 insertions, 315 deletions
diff --git a/plugins/CSList/src/cslist.h b/plugins/CSList/src/cslist.h
index c565adbf61..d6b83b30f4 100644
--- a/plugins/CSList/src/cslist.h
+++ b/plugins/CSList/src/cslist.h
@@ -88,9 +88,6 @@
#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
// ====[ DEFAULT DB VALUES ]==================================================
@@ -125,34 +122,35 @@
#define deleteSetting( setting ) DBDeleteContactSetting( NULL, __INTERNAL_NAME, setting )
// --
-typedef void (__cdecl *pForAllProtosFunc)( char*, void* );
+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;
+struct StatusItem // list item structure
+{
+ int m_iIcon;
+ TCHAR m_tszTitle[EXTRASTATUS_TITLE_LIMIT];
+ TCHAR m_tszMessage[EXTRASTATUS_MESSAGE_LIMIT];
+ BOOL m_bFavourite;
StatusItem()
{
- this->iIcon = 0;
- lstrcpy(this->tszTitle, _T(""));
- lstrcpy(this->tszMessage, _T(""));
- this->bFavourite = FALSE;
+ m_iIcon = 0;
+ lstrcpy(m_tszTitle, _T(""));
+ lstrcpy(m_tszMessage, _T(""));
+ m_bFavourite = FALSE;
}
StatusItem( const StatusItem& p )
{
- this->iIcon = p.iIcon;
- lstrcpy( this->tszTitle, p.tszTitle );
- lstrcpy( this->tszMessage, p.tszMessage );
- this->bFavourite = p.bFavourite;
+ m_iIcon = p.m_iIcon;
+ lstrcpy( m_tszTitle, p.m_tszTitle );
+ lstrcpy( m_tszMessage, p.m_tszMessage );
+ m_bFavourite = p.m_bFavourite;
}
- ~StatusItem( )
+ ~StatusItem()
{
}
};
@@ -161,7 +159,7 @@ static struct CSForm { // icons + buttons
int idc;
TCHAR* ptszTitle;
TCHAR* ptszDescr;
- char* pszIconIcoLib;
+ char * pszIconIcoLib;
int iconNoIcoLib;
HANDLE hIcoLibItem;
@@ -180,170 +178,35 @@ static struct CSForm { // icons + buttons
{ IDOK, LPGENT( "Set custom status to selected one and close" ), LPGENT( "Set" ), "apply", IDI_APPLY, NULL },
};
-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 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;
+ T* m_item;
+ ListItem* m_next;
- ListItem( )
+ ListItem()
{
- this->item = NULL;
- this->next = NULL;
+ m_item = NULL;
+ m_next = NULL;
}
- ~ListItem( )
+ ~ListItem()
{
- delete this->item;
+ delete m_item;
}
ListItem( StatusItem* si )
{
- this->item = si;
- this->next = NULL;
+ m_item = si;
+ m_next = NULL;
}
ListItem( const ListItem& p )
{
- this->item = p.item;
- this->next = NULL;
+ m_item = p.item;
+ m_next = NULL;
}
};
@@ -351,50 +214,50 @@ template< class T > struct ListItem
template< class T > struct List
{
private:
- ListItem< T >* items;
- unsigned int count;
+ ListItem< T >* m_items;
+ unsigned int m_count;
public:
typedef int ( *compareFunc )( const T* p1, const T* p2 );
- compareFunc compare;
+ compareFunc m_compare;
List( compareFunc compFnc )
{
- this->items = NULL;
- this->count = 0;
- this->compare = compFnc;
+ m_items = NULL;
+ m_count = 0;
+ m_compare = compFnc;
}
- ~List( )
+ ~List()
{
- this->destroy( );
+ destroy();
}
- ListItem< T >* getListHead( )
+ ListItem< T >* getListHead()
{
- return items;
+ return m_items;
}
- unsigned int getCount( )
+ unsigned int getCount()
{
- return count;
+ return m_count;
}
int add( T* csi )
{
int position = 0;
ListItem< T >* item = new ListItem< T >( csi );
- if ( this->items == NULL )
- this->items = item;
+ if ( m_items == NULL )
+ m_items = item;
else
{
ListItem< T >* help = item;
- item->next = items;
- while ( help->next != NULL )
+ item->m_next = m_items;
+ while ( help->m_next != NULL )
{
- int cmp = compare( item->item, help->next->item );
- if ( cmp == 1 )
- help = help->next;
+ 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;
@@ -406,50 +269,49 @@ public:
}
if ( help != item )
{
- item->next = help->next;
- help->next = item;
+ item->m_next = help->m_next;
+ help->m_next = item;
}
- else
- items = item;
+ else m_items = item;
}
- this->count++;
+ m_count++;
return position;
}
int remove( const unsigned int item )
{
int position = 0;
- if ( item < 0 || item >= this->count )
+ if ( item < 0 || item >= m_count )
return -1;
- ListItem< T >* help = items;
+ ListItem< T >* help = m_items;
ListItem< T >* removed;
if ( item == 0 )
{
- items = items->next;
+ m_items = m_items->m_next;
removed = help;
}
else
{
for ( unsigned int i = 0; i < item - 1; i++ )
{
- help = help->next;
+ help = help->m_next;
position++;
}
- removed = help->next;
- help->next = help->next->next;
+ removed = help->m_next;
+ help->m_next = help->m_next->m_next;
}
delete removed;
- this->count--;
+ m_count--;
return position;
}
T* get( const unsigned int item )
{
- ListItem< T >* help = items;
+ ListItem< T >* help = m_items;
for ( unsigned int i = 0; i < item; i++ )
- help = help->next;
- return help->item;
+ help = help->m_next;
+ return help->m_item;
}
T* operator[]( const unsigned int item )
@@ -457,98 +319,72 @@ public:
return get( item );
}
- void destroy( )
+ void destroy()
{
- while ( this->count > 0 )
- this->remove( 0 );
+ while ( m_count > 0 )
+ remove( 0 );
}
};
// ====[ CLASSING -- FUNNY STUFF :) ]=========================================
-struct CSList;
struct CSWindow;
struct CSAMWindow;
-struct CSItemsList;
-struct CSListView;
-
-// --------
struct CSListView
{
- HWND handle;
- CSWindow* parent;
+ 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 removeItems();
+ int getPositionInList();
void setFullFocusedSelection( int selection );
};
struct CSItemsList
{
- List< StatusItem >* list;
+ List< StatusItem > *m_list;
static int compareItems( const StatusItem* p1, const StatusItem* p2 );
- void loadItems(char* protoName);
- void saveItems(char* protoName);
+ void loadItems(char *protoName);
+ void saveItems(char *protoName);
- CSItemsList(char* protoName);
+ CSItemsList(char *protoName);
~CSItemsList();
};
-
-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();
-};
-
-
struct CSWindow
{
- HWND handle;
- BOOL bExtraIcons;
- CSItemsList* itemslist;
- CSListView* listview;
- CSAMWindow* addModifyDlg;
- HIMAGELIST icons;
- BOOL bSomethingChanged;
- TCHAR* filterString;
- char* protoName;
- CSWindow(char* protoName);
+ 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( );
- static void __cdecl showWindow( void* arg );
- static void __cdecl closeWindow( void* arg );
- void loadWindowPosition( );
- BOOL toggleButtons( );
- void toggleEmptyListMessage( );
- void toggleFilter( );
+ 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 )
@@ -560,74 +396,51 @@ struct CSWindow
}
};
-
-struct CSList
+struct CSAMWindow
{
- // global variables
- static HINSTANCE handle;
- static DWORD dwMirandaVersion;
-
- // 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);
+ 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();
};
-HINSTANCE CSList::handle = NULL;
-DWORD CSList::dwMirandaVersion = 0x00000000;
-// ====[ GLOBALS ]============================================================
+// service functions
+INT_PTR __cdecl showList(WPARAM, LPARAM, LPARAM);
+void closeList( HWND );
-CSList* cslist = NULL;
+// protocols enumeration related functions
+void forAllProtocols(pForAllProtosFunc pFunc, void *arg);
+void addProtoStatusMenuItem( char *protoName, void *arg);
+void countProtos( char *protoName, void *arg);
+void importCustomStatusUIStatusesFromAllProtos( char *protoName, void *arg );
-// ====[ INIT STUFF ]=========================================================
+// other functions
+void IitIcoLib();
+void RegisterHotkeys(char buf[200], TCHAR* accName, int Number);
+void RebuildMenuItems();
+void SetStatus(WORD code, StatusItem* item, char *protoName);
-BOOL WINAPI DllMain( HINSTANCE, DWORD, LPVOID );
+// ====[ INIT STUFF ]=========================================================
extern "C" __declspec( dllexport ) PLUGININFOEX* MirandaPluginInfoEx( DWORD );
extern "C" __declspec( dllexport ) int Load(void);
extern "C" __declspec( dllexport ) int Unload( void );
-
-// ====[ THREAD FORK ]========================================================
-
-void ForkThread( pThreadFunc pFunc, void* arg );
-
-
// ====[ PROCEDURES ]=========================================================
INT_PTR CALLBACK CSWindowProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam );
@@ -635,11 +448,8 @@ INT_PTR CALLBACK CSAMWindowProc( HWND hwnd, UINT message, WPARAM wparam, 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 );
-
// ====[ HELPERS ]============================================================
-HICON LoadIconExEx( const char*, int );
-
void __fastcall SAFE_FREE(void** p)
{
if (*p)