summaryrefslogtreecommitdiff
path: root/plugins/DbEditorPP/src/headers.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/DbEditorPP/src/headers.h')
-rw-r--r--plugins/DbEditorPP/src/headers.h288
1 files changed, 172 insertions, 116 deletions
diff --git a/plugins/DbEditorPP/src/headers.h b/plugins/DbEditorPP/src/headers.h
index 425f14ec61..3f8c5b6c1a 100644
--- a/plugins/DbEditorPP/src/headers.h
+++ b/plugins/DbEditorPP/src/headers.h
@@ -39,98 +39,70 @@
#include <m_icolib.h>
#include <m_hotkeys.h>
#include <m_string.h>
+#include <m_metacontacts.h>
#include "m_toptoolbar.h"
#include "resource.h"
#include "Version.h"
-#include "modsettingenum.h"
-#define DEF_ICON 5
-#define crlf_string "\r\n\0"
-
-/////// icons support
-
-void addIcons();
-HICON LoadSkinnedDBEIcon(int icon);
-int AddIconToList(HIMAGELIST hil, HICON hIcon);
-void AddProtoIconsToList(HIMAGELIST hil, int newshift);
-int GetProtoIcon(char *szProto);
-extern MCONTACT hRestore;
-/////////////////////
-
-#ifndef NDEBUG
-#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
-#endif
//=======================================================
// Definitions
//=======================================================
#define modname "DBEditorpp"
#define modFullname "Database Editor++"
-#define msg(a,b) MessageBoxA(0,a,b,MB_OK)
-#define nick_unknown "(UNKNOWN)"
-#define nick_unknownW L"(UNKNOWN)"
+#define msg(a) MessageBox(hwnd2mainWindow,a,_A2T(modFullname),MB_OK)
+#define dlg(a,b) MessageBox(hwnd2mainWindow,a,_A2T(modFullname),b)
-#define WM_FINDITEM (WM_USER + 1) // onyl for the main window, wparam is ItemIfno* lparam is 0
-
-#define mir_strlen(ptr) ((ptr == NULL) ? 0 : (int)mir_strlen(ptr))
-#define mir_strncpy(dst, src, len) strncpy(dst, src, len)[len - 1] = 0;
-#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2) ? mir_strcmp(ptr1, ptr2) : 1) // (ptr1||ptr2)
-
-#define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \
-{ LV_ITEMW _ms_lvi;\
- _ms_lvi.iSubItem = iSubItem_;\
- _ms_lvi.pszText = pszText_;\
- SendMessageW((hwndLV), LVM_SETITEMTEXTW, (WPARAM)(i), (LPARAM)(LV_ITEMW *)&_ms_lvi);\
-}
-
-#define ListView_InsertItemW(hwnd, pitem) \
- SendMessageW((hwnd), LVM_INSERTITEMW, 0, (LPARAM)(const LV_ITEMW *)(pitem))
+#define FLD_SIZE 256
+#define MSG_SIZE 256
+#define NAME_SIZE 128
+#define WM_FINDITEM (WM_USER + 1) // onyl for the main window, wparam is ItemIfno* lparam is 0
-#define TreeView_InsertItemW(hwnd, lpis) \
- (HTREEITEM)SendMessageW((hwnd), TVM_INSERTITEMW, 0, (LPARAM)(LPTV_INSERTSTRUCTW)(lpis))
/***********************
ModuleTreeInfoStruct
this gets dumped as the lparam for each module tree item
************************/
+
// types
#define CONTACT_ROOT_ITEM 0
-#define CONTACT 1
-#define MODULE 0x2
-#define KNOWN_MODULE 2
-#define STUB 4
-#define EMPTY 8
+#define CONTACT 1
+#define MODULE 2
+#define STUB 4
+#define EMPTY 8
-typedef struct {
+
+struct ModuleTreeInfoStruct {
int type; // from above types
MCONTACT hContact;
-} ModuleTreeInfoStruct;
+};
-typedef struct {
+
+struct SettingListInfo {
MCONTACT hContact;
- char *module;
- HWND hwnd2Edit;
int selectedItem; // item that is currently selected
- int clicks; // set to 0 when selection changes, 1 after another click.. cant edit till this is 1
-} SettingListInfo;
+ char module[FLD_SIZE];
+ // for edit
+ HWND hwnd2Edit;
+ char setting[FLD_SIZE];
+ int subitem;
+};
-#define WATCH_MODULE 1
-#define WATCH_SETTING 0
struct DBsetting {
- DBVARIANT dbv;
MCONTACT hContact;
char *module;
char *setting;
- int WatchModule; // above defines
+ DBVARIANT dbv;
};
+
typedef struct {
- char module[256];
+ char module[FLD_SIZE];
MCONTACT hContact;
} ModuleAndContact;
@@ -142,31 +114,79 @@ typedef struct {
typedef struct {
int type; // above types
MCONTACT hContact;
- char module[256];
- char setting[256];
+ char module[FLD_SIZE];
+ char setting[FLD_SIZE];
} ItemInfo;
// watchwindow
-struct WatchListArrayStruct{
+struct WatchListArrayStruct {
struct DBsetting *item; // gotta malloc this
int count;
int size;
};
-extern WatchListArrayStruct WatchListArray;
+
+// module setting enum
+struct ModSetLinkLinkItem
+{
+ char *name;
+ ModSetLinkLinkItem *next;
+};
+
+struct ModuleSettingLL
+{
+ ModSetLinkLinkItem *first;
+ ModSetLinkLinkItem *last;
+};
+
+struct ColumnsSettings {
+ TCHAR *name;
+ int index;
+ char *dbname;
+ int defsize;
+};
+
+struct ColumnsSortParams {
+ HWND hList;
+ int column;
+ int last;
+};
+
+
+enum ICONS {
+ IMAGE_EMPTY,
+ IMAGE_BINARY,
+ IMAGE_BYTE,
+ IMAGE_WORD,
+ IMAGE_DWORD,
+ IMAGE_STRING,
+ IMAGE_UNICODE,
+ IMAGE_HANDLE,
+ IMAGE_SETTINGS,
+ IMAGE_CLOSED,
+ IMAGE_OPENED,
+ IMAGE_CONTACTS,
+ IMAGE_ONLINE,
+ IMAGE_OFFLINE
+};
+
//=======================================================
// Variables
//=======================================================
extern HINSTANCE hInst;
-extern HWND hwnd2mainWindow, hwnd2watchedVarsWindow, hwnd2importWindow;
-extern HIMAGELIST himl;
-extern HIMAGELIST himl2;
-extern int Mode;
-extern int Hex;
-extern int Order;
+
+extern HWND hwnd2mainWindow;
+
+extern int g_Mode;
+extern int g_Hex;
+extern int g_Order;
+extern int g_Inline;
+
+extern MCONTACT hRestore;
extern MIDatabase *g_db;
+extern BOOL bServiceMode;
extern BOOL usePopups;
#define NAMEORDERCOUNT 8
@@ -179,68 +199,104 @@ extern BOOL usePopups;
#define HEX_WORD 2
#define HEX_DWORD 4
-//main.c
-int DBGetContactSettingStringStatic(MCONTACT hContact, char *szModule, char *szSetting, char *value, int maxLength);
-int WriteBlobFromString(MCONTACT hContact, const char *szModule, const char *szSetting, const char *Value, int len);
-int GetSetting(MCONTACT hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv);
-int GetValue(MCONTACT hContact, const char *szModule, const char *szSetting, char *Value, int length);
-int GetValueW(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *Value, int length);
-char *u2a(wchar_t *src);
-wchar_t *a2u(char *src, wchar_t *buffer, int len);
-WCHAR *GetContactName(MCONTACT hContact, const char *szProto, int unicode);
-BOOL IsProtocolLoaded(char *pszProtocolName);
-
-// main_window.c
-INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
-// modules.c
-int deleteModule(char *module, MCONTACT hContact, int fromMenu);
-void deleteModuleGui();
-void renameModule(char *oldName, char *newName, MCONTACT hContact);
-INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-int CloneContact(MCONTACT hContact);
+#ifdef _UNICODE
+ #define GetValue(a,b,c,d,e) GetValueW(a,b,c,d,e)
+#else
+ #define GetValue(a,b,c,d,e) GetValueA(a,b,c,d,e)
+#endif
-// moduletree.c
-void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const char *newModule);
+//main
+char *StringFromBlob(BYTE *blob, WORD len);
+int WriteBlobFromString(MCONTACT hContact, const char *module, const char *setting, const char *value, int len);
+TCHAR *DBVType(BYTE type);
+DWORD getNumericValue(DBVARIANT *dbv);
+int setNumericValue(MCONTACT hContact, const char *module, const char *setting, DWORD value, int type);
+int IsRealUnicode(TCHAR *value);
+int setTextValue(MCONTACT hContact, const char *module, const char *setting, TCHAR *value, int type);
+int GetValueA(MCONTACT hContact, const char *module, const char *setting, char *value, int length);
+int GetValueW(MCONTACT hContact, const char *module, const char *setting, WCHAR *value, int length);
+int GetContactName(MCONTACT hContact, const char *proto, TCHAR *value, int maxlen);
+int ApplyProtoFilter(MCONTACT hContact);
+void loadListSettings(HWND hwnd, ColumnsSettings *cs);
+void saveListSettings(HWND hwnd, ColumnsSettings *cs);
+INT_PTR CALLBACK ColumnsCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam);
+
+// main_window
+void openMainWindow();
+
+// deletemodules
+int deleteModule(MCONTACT hContact, const char *module, int confirm);
+void deleteModuleDlg();
+
+// renamemodule
+int renameModule(MCONTACT hContact, const char *oldName, const char *newName);
+void renameModuleDlg();
+void addModuleDlg(MCONTACT hContact);
+
+// moduletree
+void insertItem(MCONTACT hContact, const char *module, HTREEITEM hParent);
+HTREEITEM findItemInTree(MCONTACT hContact, const char *module);
+void replaceTreeItem(MCONTACT hContact, const char *module, const char *newModule);
void refreshTree(BOOL restore);
-void __cdecl PopulateModuleTreeThreadFunc(LPVOID di);
-void freeTree(HWND hwnd2Tree, MCONTACT hContact);
-int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char *module);
-
-// settinglist.c
-void setupSettingsList(HWND hwnd2List);
-void saveListSettings(HWND hwnd2List);
-void ClearListview(HWND hwnd2Settings);
-void DeleteSettingsFromList(HWND hSettings, MCONTACT hContact, char *module, char *setting);
-void PopulateSettings(HWND hwnd2Settings, MCONTACT hContact, char *module);
-void SelectSetting(char *setting);
-
-// addeditsettingsdlg.c
-INT_PTR CALLBACK EditSettingDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-void editSetting(MCONTACT hContact, char *module, char *setting);
-BOOL convertSetting(MCONTACT hContact, char *module, char *setting, int toType); // 0 = byte, 1 = word, 2 = dword, 3 = string
-
-// exportimport.c
-void exportDB(MCONTACT hContact, char *module); // hContact == -1 export entire db. module == NULL export entire contact
+void freeTree(MCONTACT hContact);
+
+// settinglist
+int ListView_GetItemTextA(HWND hwndLV, int i, int iSubItem, char *pszText, int cchTextMax);
+int ListView_SetItemTextA(HWND hwndLV, int i, int iSubItem, const char *pszText);
+void ClearListView();
+void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *setting);
+void addListHandle(MCONTACT hContact);
+void PopulateSettings(MCONTACT hContact, const char *module);
+void SelectSetting(const char *setting);
+void settingChanged(MCONTACT hContact, const char *module, const char *setting, DBVARIANT *dbv);
+
+// settingsdlg
+void editSetting(MCONTACT hContact, const char *module, const char *setting);
+void copySetting(MCONTACT hContact, const char *module, const char *setting);
+void newSetting(MCONTACT hContact, const char *module, int type);
+
+// exportimport
+void exportDB(MCONTACT hContact, const char *module); // hContact == -1 export entire db. module == NULL export entire contact
void ImportSettingsMenuItem(MCONTACT hContact);
-void ImportSettingsFromFileMenuItem(MCONTACT hContact, char *FilePath);
+void ImportSettingsFromFileMenuItem(MCONTACT hContact, const char *filePath); // ansi!
-// find window.c
-INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+// find window
+void newFindWindow();
-// copymodule.c
-void copyModuleMenuItem(char *module, MCONTACT hContact);
-void copyModule(char *module, MCONTACT hContactFrom, MCONTACT hContactTo);
+// copymodule
+void copyModuleMenuItem(MCONTACT hContact, const char *module);
+void copyModule(const char *module, MCONTACT hContactFrom, MCONTACT hContactTo);
+int CloneContact(MCONTACT hContact);
-// options.c
+// options
int OptInit(WPARAM wParam, LPARAM lParam);
-// watchlist
-int addSettingToWatchList(MCONTACT hContact, char *module, char *setting);
+// watchedvars
+int WatchedArrayIndex(MCONTACT hContact, const char *module, const char *setting, int strict);
+int addSettingToWatchList(MCONTACT hContact, const char *module, const char *setting);
void freeWatchListItem(int item);
-void PopulateWatchedWindow(HWND hwnd);
+void PopulateWatchedWindow();
void freeAllWatches();
-INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+void openWatchedVarWindow();
void popupWatchedVar(MCONTACT hContact, const char *module, const char *setting);
+// modsettingenum
+int EnumModules(ModuleSettingLL *msll);
+int EnumSettings(MCONTACT hContact, const char *module, ModuleSettingLL *msll);
+void FreeModuleSettingLL(ModuleSettingLL *msll);
+int IsModuleEmpty(MCONTACT hContact, const char *module);
+int LoadResidentSettings();
+void FreeResidentSettings();
+int IsResidentSetting(const char *module, const char *setting);
+int EnumResidentSettings(const char *module, ModuleSettingLL *msll);
+int EnumResidentModules(ModuleSettingLL *msll);
+int fixResidentSettings();
+
+// icons
+HANDLE GetIcoLibHandle(int icon);
+void IcoLibRegister();
+HICON LoadSkinnedDBEIcon(int icon);
+HIMAGELIST LoadIcons();
+int GetProtoIconIndex(const char *proto);
+
#endif //_COMMONHEADERS_H