diff options
Diffstat (limited to 'plugins/DbEditorPP/src')
| -rw-r--r-- | plugins/DbEditorPP/src/headers.h | 76 | ||||
| -rw-r--r-- | plugins/DbEditorPP/src/icons.cpp | 29 | ||||
| -rw-r--r-- | plugins/DbEditorPP/src/main.cpp | 87 | ||||
| -rw-r--r-- | plugins/DbEditorPP/src/main_window.cpp | 48 | ||||
| -rw-r--r-- | plugins/DbEditorPP/src/moduletree.cpp | 205 | 
5 files changed, 239 insertions, 206 deletions
diff --git a/plugins/DbEditorPP/src/headers.h b/plugins/DbEditorPP/src/headers.h index 75a3830f6a..ff5bac7f74 100644 --- a/plugins/DbEditorPP/src/headers.h +++ b/plugins/DbEditorPP/src/headers.h @@ -47,12 +47,12 @@  #include "Version.h"
  #include "modsettingenum.h"
 -#define DEF_ICON    5
 +#define DEF_ICON 5
  #define crlf_string "\r\n\0"
  /////// icons support
 -void addIcons(TCHAR* szModuleFileName);
 +void addIcons();
  HICON LoadSkinnedDBEIcon(int icon);
  int AddIconToList(HIMAGELIST hil, HICON hIcon);
  void AddProtoIconsToList(HIMAGELIST hil, int newshift);
 @@ -70,15 +70,15 @@ extern MCONTACT hRestore;  #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 nick_unknown	"(UNKNOWN)"
 +#define nick_unknownW	L"(UNKNOWN)"
 -#define WM_FINDITEM (WM_USER+1) // onyl for the main window, wparam is ItemIfno* lparam is 0
 +#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)strlen(ptr))
 -#define mir_strncpy(dst, src, len) strncpy(dst, src, len)[len-1]=0;
 -#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2)?strcmp(ptr1, ptr2):1) // (ptr1||ptr2)
 +#define mir_strlen(ptr) ((ptr == NULL) ? 0 : (int)strlen(ptr))
 +#define mir_strncpy(dst, src, len) strncpy(dst, src, len)[len - 1] = 0;
 +#define mir_strcmp(ptr1, ptr2) ((ptr1 && ptr2) ? strcmp(ptr1, ptr2) : 1) // (ptr1||ptr2)
  #define ListView_SetItemTextW(hwndLV, i, iSubItem_, pszText_) \
  { LV_ITEMW _ms_lvi;\
 @@ -113,7 +113,7 @@ typedef struct {  typedef struct {
  	MCONTACT hContact;
 -	char* module;
 +	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
 @@ -170,34 +170,34 @@ extern MIDatabase *g_db;  extern BOOL usePopups;
 -#define NAMEORDERCOUNT 8
 +#define NAMEORDERCOUNT	8
 -#define MODE_UNLOADED  1
 -#define MODE_LOADED    2
 -#define MODE_ALL       3
 +#define MODE_UNLOADED	1
 +#define MODE_LOADED		2
 +#define MODE_ALL		3
 -#define HEX_BYTE       1
 -#define HEX_WORD       2
 -#define HEX_DWORD      4
 +#define HEX_BYTE		1
 +#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 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 );
 +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);
 +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);
 +int deleteModule(char *module, MCONTACT hContact, int fromMenu);
  void deleteModuleGui();
 -void renameModule(char* oldName, char* newName, MCONTACT hContact);
 +void renameModule(char *oldName, char *newName, MCONTACT hContact);
  INT_PTR CALLBACK AddModDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  int CloneContact(MCONTACT hContact);
 @@ -206,42 +206,42 @@ void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const cha  void refreshTree(BOOL restore);
  void __cdecl PopulateModuleTreeThreadFunc(LPVOID di);
  void freeTree(HWND hwnd2Tree, MCONTACT hContact);
 -int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char* module);
 +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);
 +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
 +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 exportDB(MCONTACT hContact, 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, char *FilePath);
  // find window.c
  INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  // copymodule.c
 -void copyModuleMenuItem(char* module, MCONTACT hContact);
 -void copyModule(char* module, MCONTACT hContactFrom, MCONTACT hContactTo);
 +void copyModuleMenuItem(char *module, MCONTACT hContact);
 +void copyModule(char *module, MCONTACT hContactFrom, MCONTACT hContactTo);
  // options.c
 -int OptInit(WPARAM wParam,LPARAM lParam);
 +int OptInit(WPARAM wParam, LPARAM lParam);
  // watchlist
 -int addSettingToWatchList(MCONTACT hContact, char* module, char* setting);
 +int addSettingToWatchList(MCONTACT hContact, char *module, char *setting);
  void freeWatchListItem(int item);
  void PopulateWatchedWindow(HWND hwnd);
  void freeAllWatches();
  INT_PTR CALLBACK WatchDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
 -void popupWatchedVar(MCONTACT hContact,const char* module,const char* setting);
 +void popupWatchedVar(MCONTACT hContact, const char *module, const char *setting);
 -#endif //_COMMONHEADERS_H
\ No newline at end of file +#endif //_COMMONHEADERS_H
 diff --git a/plugins/DbEditorPP/src/icons.cpp b/plugins/DbEditorPP/src/icons.cpp index 83d873b5e9..efee7c5d35 100644 --- a/plugins/DbEditorPP/src/icons.cpp +++ b/plugins/DbEditorPP/src/icons.cpp @@ -2,24 +2,33 @@  HIMAGELIST himl;
 -static IconItem iconList[] = 
 -{
 -	{ LPGENT("Closed Known Module"),   "DBE++_1", ICO_KNOWN },
 -	{ LPGENT("Open Known Module"),     "DBE++_2", ICO_KNOWNOPEN },
 +IconItem iconList[] = {
 +	{ LPGENT("Main icon"),             "DBE++_0", ICO_DBE_BUTT },
 +	{ LPGENT("Closed known module"),   "DBE++_1", ICO_KNOWN },
 +	{ LPGENT("Open known module"),     "DBE++_2", ICO_KNOWNOPEN },
  	{ LPGENT("Settings"),              "DBE++_5", ICO_SETTINGS },
 -	{ LPGENT("Contacts Group"),        "DBE++_6", ICO_CONTACTS },
 -	{ LPGENT("Unknown Contact"),       "DBE++_7", ICO_OFFLINE },
 -	{ LPGENT("Known Contact"),         "DBE++_8", ICO_ONLINE },
 +	{ LPGENT("Contacts group"),        "DBE++_6", ICO_CONTACTS },
 +	{ LPGENT("Unknown contact"),       "DBE++_7", ICO_OFFLINE },
 +	{ LPGENT("Known contact"),         "DBE++_8", ICO_ONLINE },
 +	{ LPGENT("Open user tree"),        "DBE++_9", ICO_REGUSER },
 +
 +	{ LPGENT("BLOB setting"),    "DBE++_BINARY",  ICO_BINARY },
 +	{ LPGENT("Byte setting"),    "DBE++_BYTE",    ICO_BYTE },
 +	{ LPGENT("Word setting"),    "DBE++_WORD",    ICO_WORD },
 +	{ LPGENT("Dword setting"),   "DBE++_DWORD",   ICO_DWORD },
 +	{ LPGENT("String setting"),  "DBE++_STRING",  ICO_STRING },
 +	{ LPGENT("Unicode setting"), "DBE++_UNICODE", ICO_UNICODE },
 +	{ LPGENT("Handle"),          "DBE++_HANDLE",  ICO_HANDLE }
  };
 -void addIcons(TCHAR* szModuleFileName)
 +void addIcons(void)
  {
  	Icon_Register(hInst, modFullname, iconList, SIZEOF(iconList));
  }
  HICON LoadSkinnedDBEIcon(int icon)
  {
 -	for (int i=0; i < SIZEOF(iconList); i++)
 +	for (int i = 0; i < SIZEOF(iconList); i++)
  		if (iconList[i].defIconID == icon)
  			return Skin_GetIconByHandle(iconList[i].hIcolib);
 @@ -71,7 +80,7 @@ int GetProtoIcon(char *szProto)  	return DEF_ICON;
  }
 -BOOL IsProtocolLoaded(char* pszProtocolName)
 +BOOL IsProtocolLoaded(char *pszProtocolName)
  {
  	if (protoCount)
  		for(int i = 0; i < protoCount; i++)
 diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index f523686d96..4bffb7ddee 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -13,7 +13,8 @@ HGENMENU hUserMenu;  WatchListArrayStruct WatchListArray;
  MCONTACT hRestore;
  HANDLE sMenuCommand, sImport, sServicemodeLaunch;
 -HANDLE hModulesLoadedHook = NULL, hSettingsChangedHook=NULL, hOptInitHook=NULL, hPreShutdownHook=NULL;
 +HANDLE hModulesLoadedHook = NULL, hSettingsChangedHook = NULL, hOptInitHook = NULL, hPreShutdownHook = NULL;
 +IconItem iconList[];
  //========================
  //  MirandaPluginInfo
 @@ -21,7 +22,7 @@ HANDLE hModulesLoadedHook = NULL, hSettingsChangedHook=NULL, hOptInitHook=NULL,  PLUGININFOEX pluginInfoEx = 
  {
 -    sizeof(PLUGININFOEX),
 +	sizeof(PLUGININFOEX),
  	__PLUGIN_NAME,
  	PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
  	__DESCRIPTION,
 @@ -34,7 +35,7 @@ PLUGININFOEX pluginInfoEx =  	{0xa8a417ef, 0x7aa, 0x4f37, {0x86, 0x9f, 0x7b, 0xfd, 0x74, 0x88, 0x65, 0x34}}
  };
 -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
 +extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
  {
  	return &pluginInfoEx;
  }
 @@ -51,17 +52,17 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)  	return TRUE;
  }
 -void settingChanged(HWND hwnd2Settings, MCONTACT hContact, char* module, char* setting);
 +void settingChanged(HWND hwnd2Settings, MCONTACT hContact, char *module, char *setting);
  int DBSettingChanged(WPARAM hContact, LPARAM lParam)
  {
 -	DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;
 +	DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING *)lParam;
  	char *setting;
 -	SettingListInfo* info;
 +	SettingListInfo *info;
  	if (hwnd2mainWindow) {
  		HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow, IDC_SETTINGS);
 -		if (info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA)) {
 +		if (info = (SettingListInfo *)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA)) {
  			if ((hContact == info->hContact) && !mir_strcmp(info->module, cws->szModule)) {
  				setting = mir_strdup(cws->szSetting);
  				if (cws->value.type == DBVT_DELETED) {
 @@ -106,7 +107,7 @@ INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM lParam)  {
  	if (!hwnd2mainWindow) { // so only opens 1 at a time
  		hRestore = wParam;
 -		SetCursor(LoadCursor(NULL,IDC_WAIT));
 +		SetCursor(LoadCursor(NULL, IDC_WAIT));
  		CreateDialog(hInst, MAKEINTRESOURCE(IDD_MAIN), 0, MainDlgProc);
  	}
  	else {
 @@ -119,7 +120,7 @@ INT_PTR DBEditorppMenuCommand(WPARAM wParam, LPARAM lParam)  	}
  	if (hTTBButt)
 -		CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTBButt, (LPARAM)(TTBST_RELEASED));
 +		CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)hTTBButt, (LPARAM)TTBST_RELEASED);
  	return 0;
  }
 @@ -130,26 +131,27 @@ BOOL IsCP_UTF8(void)  	return GetCPInfo(CP_UTF8, &CPInfo);
  }
 -static int OnTTBLoaded(WPARAM wParam,LPARAM lParam)
 +static int OnTTBLoaded(WPARAM wParam, LPARAM lParam)
  {
 -	HICON ico = LoadIcon(hInst, MAKEINTRESOURCE(ICO_DBE_BUTT));
 -
  	TTBButton ttb = { sizeof(ttb) };
  	ttb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
  	ttb.pszService = "DBEditorpp/MenuCommand";
  	ttb.name = LPGEN("Database Editor++");
 -	ttb.hIconUp = ico;
 +	ttb.hIconHandleUp = iconList[0].hIcolib;
  	ttb.pszTooltipUp = LPGEN("Open Database Editor");
  	hTTBButt = TopToolbar_AddButton(&ttb);
  	return 0;
  }
 -int ModulesLoaded(WPARAM wParam,LPARAM lParam)
 +int ModulesLoaded(WPARAM wParam, LPARAM lParam)
  {
 +	// icons
 +	addIcons();
 +
  	// Register menu item
  	CLISTMENUITEM mi = { sizeof(mi) };
  	mi.position = 1900000001;
 -	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT));
 +	mi.icolibItem = iconList[0].hIcolib;
  	mi.pszPopupName = "Database";
  	mi.pszName = modFullname;
  	mi.pszService = "DBEditorpp/MenuCommand";
 @@ -159,7 +161,7 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam)  	mi.cbSize = sizeof(mi);
  	mi.position = 1900000001;
  	mi.flags = 0;
 -	mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGUSER));
 +	mi.icolibItem = iconList[7].hIcolib;
  	mi.pszName = LPGEN("Open user tree in DBE++");
  	mi.pszService = "DBEditorpp/MenuCommand";
  	hUserMenu = Menu_AddContactMenuItem(&mi);
 @@ -173,11 +175,6 @@ int ModulesLoaded(WPARAM wParam,LPARAM lParam)  	hkd.DefHotKey = HOTKEYCODE(HOTKEYF_SHIFT | HOTKEYF_EXT, 'D');
  	Hotkey_Register(&hkd);
 -	// icons
 -	TCHAR szModuleFileName[MAX_PATH];
 -	if (GetModuleFileName(hInst, szModuleFileName, MAX_PATH))
 -		addIcons(szModuleFileName);
 -
  	UnhookEvent(hModulesLoadedHook);
  	usePopups = db_get_b(NULL, modname, "UsePopUps", 0);
 @@ -224,7 +221,7 @@ INT_PTR ServiceMode(WPARAM wParam, LPARAM lParam)  INT_PTR ImportFromFile(WPARAM wParam, LPARAM lParam)
  {
 -	ImportSettingsFromFileMenuItem(wParam, (char*)lParam);
 +	ImportSettingsFromFileMenuItem(wParam, (char *)lParam);
  	return 0;
  }
 @@ -266,7 +263,7 @@ extern "C" __declspec(dllexport) int Unload(void)  // db_get_s (prob shouldnt use this unless u know how big the string is gonna be..)
  //=======================================================
 -int DBGetContactSettingStringStatic(MCONTACT hContact, char* szModule, char* szSetting, char* value, int maxLength)
 +int DBGetContactSettingStringStatic(MCONTACT hContact, char *szModule, char *szSetting, char *value, int maxLength)
  {
  	DBVARIANT dbv;
  	if (!db_get(hContact, szModule, szSetting, &dbv)) {
 @@ -282,9 +279,9 @@ int DBGetContactSettingStringStatic(MCONTACT hContact, char* szModule, char* szS  	return 0;
  }
 -int WriteBlobFromString(MCONTACT hContact,const char *szModule,const char *szSetting, const char *szValue, int len)
 +int WriteBlobFromString(MCONTACT hContact, const char *szModule, const char *szSetting, const char *szValue, int len)
  {
 -	int j=0, i = 0;
 +	int j = 0, i = 0;
  	BYTE *data = NULL;
  	BYTE b;
  	int tmp;
 @@ -320,7 +317,7 @@ int GetSetting(MCONTACT hContact, const char *szModule, const char *szSetting, D  	return db_get_s(hContact, szModule, szSetting, dbv, 0);
  }
 -int GetValue(MCONTACT hContact, const char* szModule, const char* szSetting, char* Value, int length)
 +int GetValue(MCONTACT hContact, const char *szModule, const char *szSetting, char *Value, int length)
  {
  	DBVARIANT dbv = {0};
 @@ -340,8 +337,8 @@ int GetValue(MCONTACT hContact, const char* szModule, const char* szSetting, cha  			break;
  		case DBVT_UTF8:
  			int len = (int)strlen(dbv.pszVal) + 1;
 -			char *sz = (char*)_alloca(len * 3);
 -			WCHAR *wc = (WCHAR*)_alloca(len*sizeof(WCHAR));
 +			char *sz = (char *)_alloca(len * 3);
 +			WCHAR *wc = (WCHAR *)_alloca(len * sizeof(WCHAR));
  			MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len);
  			WideCharToMultiByte(CP_ACP, 0, wc, -1, sz, len, NULL, NULL);
  			strncpy(Value, sz, length);
 @@ -360,9 +357,9 @@ int GetValue(MCONTACT hContact, const char* szModule, const char* szSetting, cha  	return 0;
  }
 -int GetValueW(MCONTACT hContact, const char* szModule, const char* szSetting, WCHAR* Value, int length)
 +int GetValueW(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *Value, int length)
  {
 -	DBVARIANT dbv = { 0 };
 +	DBVARIANT dbv = {0};
  	WCHAR *wc;
  	int len;
 @@ -370,16 +367,16 @@ int GetValueW(MCONTACT hContact, const char* szModule, const char* szSetting, WC  		switch (dbv.type) {
  		case DBVT_UTF8:
  			len = (int)strlen(dbv.pszVal) + 1;
 -			wc = (WCHAR*)_alloca(length*sizeof(WCHAR));
 +			wc = (WCHAR *)_alloca(length * sizeof(WCHAR));
  			MultiByteToWideChar(CP_UTF8, 0, dbv.pszVal, -1, wc, len);
 -			wcsncpy((WCHAR*)Value, wc, length);
 +			wcsncpy((WCHAR *)Value, wc, length);
  			break;
  		case DBVT_ASCIIZ:
  			len = (int)strlen(dbv.pszVal) + 1;
 -			wc = (WCHAR*)_alloca(len*sizeof(WCHAR));
 +			wc = (WCHAR *)_alloca(len * sizeof(WCHAR));
  			MultiByteToWideChar(CP_ACP, 0, dbv.pszVal, -1, wc, len);
 -			wcsncpy((WCHAR*)Value, wc, length);
 +			wcsncpy((WCHAR *)Value, wc, length);
  			break;
  		case DBVT_DWORD:
 @@ -407,13 +404,13 @@ int GetValueW(MCONTACT hContact, const char* szModule, const char* szSetting, WC  	return 0;
  }
 -char* u2a(wchar_t *src)
 +char *u2a(wchar_t *src)
  {
  	if (!src)
  		return NULL;
  	int cbLen = WideCharToMultiByte(CP_ACP, 0, src, -1, NULL, 0, NULL, NULL);
 -	char* result = (char*)mir_calloc((cbLen + 1)*sizeof(char));
 +	char *result = (char *)mir_calloc((cbLen + 1) * sizeof(char));
  	if (result == NULL)
  		return NULL;
 @@ -422,7 +419,7 @@ char* u2a(wchar_t *src)  	return result;
  }
 -wchar_t* a2u(char* src, wchar_t *buffer, int len)
 +wchar_t *a2u(char *src, wchar_t *buffer, int len)
  {
  	wchar_t *result = buffer;
  	if (result == NULL || len < 3)
 @@ -434,24 +431,24 @@ wchar_t* a2u(char* src, wchar_t *buffer, int len)  	return result;
  }
 -int GetDatabaseString(MCONTACT hContact, const char *szModule, const char* szSetting, WCHAR *Value, int length, BOOL unicode)
 +int GetDatabaseString(MCONTACT hContact, const char *szModule, const char *szSetting, WCHAR *Value, int length, BOOL unicode)
  {
  	if (unicode)
  		return GetValueW(hContact, szModule, szSetting, Value, length);
  	else
 -		return GetValue(hContact, szModule, szSetting, (char*)Value, length);
 +		return GetValue(hContact, szModule, szSetting, (char *)Value, length);
  }
  WCHAR* GetContactName(MCONTACT hContact, const char *szProto, int unicode)
  {
  	int i, r = 0;
  	static WCHAR res[512];
 -	char *proto = (char*)szProto;
 +	char *proto = (char *)szProto;
  	char name[256];
  	if (hContact && !proto)
 -	if (GetValue(hContact, "Protocol", "p", name, SIZEOF(name)))
 -		proto = name;
 +		if (GetValue(hContact, "Protocol", "p", name, SIZEOF(name)))
 +			proto = name;
  	if (proto) {
  		for (i = 0; i < NAMEORDERCOUNT - 1; i++) {
 @@ -479,7 +476,7 @@ WCHAR* GetContactName(MCONTACT hContact, const char *szProto, int unicode)  			case 5: // Unique id
  				{
  					// protocol must define a PFLAG_UNIQUEIDSETTING
 -					char *uid = (char*)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
 +					char *uid = (char *)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
  					if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
  						r = GetDatabaseString(hContact, proto, uid, res, SIZEOF(res), unicode);
  				}
 @@ -492,7 +489,7 @@ WCHAR* GetContactName(MCONTACT hContact, const char *szProto, int unicode)  						if (unicode)
  							len = (int)wcslen(res);
  						else
 -							len = (int)strlen((char*)res);
 +							len = (int)strlen((char *)res);
  					}
  					else
  						res[0] = 0;
 @@ -518,5 +515,5 @@ WCHAR* GetContactName(MCONTACT hContact, const char *szProto, int unicode)  		}
  	}
 -	return (unicode) ? nick_unknownW : (WCHAR*)nick_unknown;
 +	return (unicode) ? nick_unknownW : (WCHAR *)nick_unknown;
  }
 diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 2442178da5..96acfc7daf 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -111,7 +111,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR  			tvi.pszText = module;
  			tvi.cchTextMax = 255;
  			if (TreeView_GetItem(hwnd, &tvi) && tvi.lParam) {
 -				ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct*)tvi.lParam;
 +				ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
  				MCONTACT hContact = mtis->hContact;
  				if (wParam == VK_DELETE) {
  					if ((mtis->type) & MODULE) {
 @@ -124,7 +124,7 @@ LRESULT CALLBACK ModuleTreeSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR  						if (db_get_b(NULL, "CList", "ConfirmDelete", 1)) {
  							char msg[1024];
  							mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module);
 -							if (MessageBox(0, msg, Translate("Confirm Contact Delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
 +							if (MessageBox(0, msg, Translate("Confirm contact delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDNO)
  								break;
  						}
  						CallService(MS_DB_CONTACT_DELETE, hContact, 0);
 @@ -161,8 +161,9 @@ static LRESULT CALLBACK SettingListSubclassProc(HWND hwnd, UINT msg, WPARAM wPar  		if (wParam == VK_DELETE || wParam == VK_F5 || (wParam == VK_F2 && ListView_GetSelectedCount(hwnd) == 1)) {
  			char *module, setting[256];
  			MCONTACT hContact;
 -			SettingListInfo* sli = (SettingListInfo*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
 -			if (!sli) break;
 +			SettingListInfo* sli = (SettingListInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
 +			if (!sli)
 +				break;
  			hContact = sli->hContact;
  			module = sli->module;
  			ListView_GetItemText(hwnd, ListView_GetSelectionMark(hwnd), 0, setting, 256);
 @@ -267,19 +268,19 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  				numberOfIcons = 0;
  				if (himl2 = ImageList_Create(16, 16, ILC_COLOR32 | ILC_MASK, 5, 0)) {
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_BINARY))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_BINARY)))
  						numberOfIcons++;
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_BYTE))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_BYTE)))
  						numberOfIcons++;
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_WORD))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_WORD)))
  						numberOfIcons++;
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_DWORD))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_DWORD)))
  						numberOfIcons++;
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_STRING))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_STRING)))
  						numberOfIcons++;
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_UNICODE))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_UNICODE)))
  						numberOfIcons++;
 -					if (AddIconToList(himl2, LoadIcon(hInst, MAKEINTRESOURCE(ICO_HANDLE))))
 +					if (AddIconToList(himl2, LoadSkinnedDBEIcon(ICO_HANDLE)))
  						numberOfIcons++;
  					if (numberOfIcons < 7) {
 @@ -316,8 +317,10 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  				ScreenToClient(hwnd, &pt);
  				splitterPos = rc.left + pt.x + 1;
 -				if (splitterPos<65) splitterPos = 65;
 -				if (splitterPos > rc2.right - rc2.left - 65) splitterPos = rc2.right - rc2.left - 65;
 +				if (splitterPos < 65)
 +					splitterPos = 65;
 +				if (splitterPos > rc2.right - rc2.left - 65)
 +					splitterPos = rc2.right - rc2.left - 65;
  				SetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA, splitterPos);
  				db_set_w(NULL, modname, "Splitter", (WORD)splitterPos);
  			}
 @@ -327,7 +330,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  	case WM_GETMINMAXINFO:
  		{
 -			MINMAXINFO *mmi = (MINMAXINFO*)lParam;
 +			MINMAXINFO *mmi = (MINMAXINFO *)lParam;
  			int splitterPos = GetWindowLongPtr(GetDlgItem(hwnd, IDC_SPLITTER), GWLP_USERDATA);
  			if (splitterPos + 40 > 200)
 @@ -400,7 +403,8 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  					ListView_GetItemText(hwnd2Settings, pos, 0, text, SIZEOF(text));
  					db_set_s(NULL, modname, "LastSetting", text);
  				}
 -				else db_unset(NULL, modname, "LastSetting");
 +				else
 +					db_unset(NULL, modname, "LastSetting");
  			}
  		}
  		db_set_b(NULL, modname, "HexMode", (byte)Hex);
 @@ -433,7 +437,8 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  		return 0;
  	case WM_COMMAND:
 -		if (GetKeyState(VK_ESCAPE) & 0x8000) return TRUE; // this needs to be changed to c if htere is a label edit happening..
 +		if (GetKeyState(VK_ESCAPE) & 0x8000)
 +			return TRUE; // this needs to be changed to c if htere is a label edit happening..
  		switch (LOWORD(wParam)) {
  		case MENU_REFRESH_MODS:
  			refreshTree(1);
 @@ -453,16 +458,19 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  				mtis = (ModuleTreeInfoStruct *)tvi.lParam;
  				if (mtis->type == MODULE)
  					PopulateSettings(GetDlgItem(hwnd, IDC_SETTINGS), mtis->hContact, module);
 -				else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
 +				else
 +					ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
  			}
 -			else ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
 +			else
 +				ClearListview(GetDlgItem(hwnd, IDC_SETTINGS));
  		}
  			break;
  			///////////////////////// // watches
  		case MENU_VIEW_WATCHES:
  			if (!hwnd2watchedVarsWindow) // so only opens 1 at a time
  				hwnd2watchedVarsWindow = CreateDialog(hInst, MAKEINTRESOURCE(IDD_WATCH_DIAG), 0, WatchDlgProc);
 -			else SetForegroundWindow(hwnd2watchedVarsWindow);
 +			else
 +				SetForegroundWindow(hwnd2watchedVarsWindow);
  			break;
  		case MENU_REMALL_WATCHES:
  			freeAllWatches();
 @@ -569,7 +577,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)  		return TRUE; // case WM_NOTIFY
  	case WM_FINDITEM:
 -		ItemInfo *ii = (ItemInfo*)wParam;
 +		ItemInfo *ii = (ItemInfo *)wParam;
  		HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS);
  		int hItem = findItemInTree(GetDlgItem(hwnd, IDC_MODULES), ii->hContact, ii->module);
  		if (hItem != -1) {
 diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index 4d5aa57a99..55e69821ce 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -2,8 +2,8 @@  static BOOL populating = 0;
  int Select = 0;
 -static ModuleTreeInfoStruct contacts_mtis = {CONTACT_ROOT_ITEM, 0};
 -static ModuleTreeInfoStruct settings_mtis = {CONTACT, 0};
 +static ModuleTreeInfoStruct contacts_mtis = { CONTACT_ROOT_ITEM, 0 };
 +static ModuleTreeInfoStruct settings_mtis = { CONTACT, 0 };
  int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist, MCONTACT hSelectedContact, char *SelectedModule, char *SelectedSetting)
  {
 @@ -51,7 +51,7 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist,  			lParam->type |= EMPTY;
  		// contacts name
 -		DBVARIANT dbv = { 0 };
 +		DBVARIANT dbv = {0};
  		WCHAR nick[256];
  		WCHAR protoW[256]; // unicode proto
 @@ -69,7 +69,8 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist,  				else
  					mir_snwprintf(nick, SIZEOF(nick), L"%s (%s) %s", GetContactName(hContact, szProto, 1), protoW, L"(UNLOADED)");
  			}
 -			else wcscpy(nick, nick_unknownW);
 +			else
 +				wcscpy(nick, nick_unknownW);
  		}
  		else {
  			tvi.item.iSelectedImage = (tvi.item.iImage = icon); //GetProtoIcon(szProto, 7));
 @@ -79,7 +80,7 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist,  				mir_snwprintf(nick, SIZEOF(nick), L"%s (%s)", GetContactName(hContact, szProto, 1), protoW);
  		}
 -		tvi.item.pszText = (char*)nick;
 +		tvi.item.pszText = (char *)nick;
  		contact = TreeView_InsertItemW(hwnd2Tree, &tvi);
  		itemscount++;
 @@ -113,7 +114,8 @@ int doContacts(HWND hwnd2Tree, HTREEITEM contactsRoot, ModuleSettingLL *modlist,  	if (hItem != -1) {
  		TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem);
  		TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND);
 -		if (SelectedSetting[0]) SelectSetting(SelectedSetting);
 +		if (SelectedSetting[0])
 +			SelectSetting(SelectedSetting);
  	}
  	return itemscount;
 @@ -126,7 +128,7 @@ void doItems(HWND hwnd2Tree, ModuleSettingLL *modlist, int count)  	char percent[96], title[64];
  	mir_snprintf(title, SIZEOF(title), Translate("Loading modules..."));
 -	TVITEM item = { 0 };
 +	TVITEM item = {0};
  	item.mask = TVIF_STATE | TVIF_PARAM;
  	HTREEITEM contact = TreeView_GetChild(hwnd2Tree, TVI_ROOT);
 @@ -145,7 +147,8 @@ void doItems(HWND hwnd2Tree, ModuleSettingLL *modlist, int count)  				continue;
  			mtis->type = CONTACT;
  		}
 -		else continue;
 +		else
 +			continue;
  		// Caption
  		mir_snprintf(percent, SIZEOF(percent), "%s %d%%", title, (int)(100 * i / count));
 @@ -179,12 +182,13 @@ void doItems(HWND hwnd2Tree, ModuleSettingLL *modlist, int count)  // the following code to go through the whole tree is nicked from codeguru..
  // http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680
 -int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char* module)
 +int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char *module)
  {
  	TVITEM item;
  	char text[265];
  	HTREEITEM lastItem;
 -	if (!TreeView_GetCount(hwnd2Tree)) return 0;
 +	if (!TreeView_GetCount(hwnd2Tree))
 +		return 0;
  	item.mask = TVIF_STATE | TVIF_PARAM | TVIF_TEXT;
  	item.hItem = TVI_ROOT;
 @@ -203,13 +207,11 @@ int findItemInTree(HWND hwnd2Tree, MCONTACT hContact, char* module)  				}
  				/* back to coduguru's code*/
  			}
 -		}
 -			while ((item.hItem = TreeView_GetChild(hwnd2Tree, lastItem)));
 +		} while ((item.hItem = TreeView_GetChild(hwnd2Tree, lastItem)));
 -		while ((!(item.hItem = TreeView_GetNextSibling(hwnd2Tree, lastItem))) && (lastItem = item.hItem = TreeView_GetParent(hwnd2Tree, lastItem)))
 -			;
 -	}
 -		while (item.hItem);
 +		while ((!(item.hItem = TreeView_GetNextSibling(hwnd2Tree, lastItem))) && (lastItem = item.hItem = TreeView_GetParent(hwnd2Tree, lastItem)));
 +
 +	} while (item.hItem);
  	return -1;
  }
 @@ -220,39 +222,39 @@ void freeTree(HWND hwnd2Tree, MCONTACT hContact)  {
  	TVITEM item;
  	HTREEITEM lastItem;
 -	if (!TreeView_GetCount(hwnd2Tree)) return;
 +	if (!TreeView_GetCount(hwnd2Tree))
 +		return;
 -	item.mask = TVIF_STATE|TVIF_PARAM;
 +	item.mask = TVIF_STATE | TVIF_PARAM;
  	item.hItem = TVI_ROOT;
  	do {
  		do {
  			lastItem = item.hItem;
  			if (lastItem != TVI_ROOT) {
 -				TreeView_GetItem( hwnd2Tree, &item );
 +				TreeView_GetItem(hwnd2Tree, &item);
  				/* these next 2 lines are not from code guru..... */
  				if (item.lParam) {
  					ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam;
  					if (!hContact || (hContact == mtis->hContact)) {
  						if (hContact != NULL) {
 -							TreeView_DeleteItem(hwnd2Tree,item.hItem);
 +							TreeView_DeleteItem(hwnd2Tree, item.hItem);
  							mir_free(mtis);
  						}
 -						else mtis->type = STUB;
 +						else
 +							mtis->type = STUB;
  					}
  				}
  				/* back to coduguru's code*/
  			}
 -		}
 -			while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem )));
 +		} while (item.hItem = TreeView_GetChild(hwnd2Tree, lastItem));
 -		while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {}
 +		while (!(item.hItem = TreeView_GetNextSibling(hwnd2Tree, lastItem)) && (lastItem = item.hItem = TreeView_GetParent(hwnd2Tree, lastItem))) {}
 -	}
 -		while (item.hItem);
 +	} while (item.hItem);
  }
 -BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char* module)
 +BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char *module)
  	/* the following code to go through the whole tree is nicked from codeguru..
  	http://www.codeguru.com/Cpp/controls/treeview/treetraversal/comments.php/c683/?thread=7680 */
  {
 @@ -260,30 +262,26 @@ BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char* module)  	HTREEITEM lastItem, prelastItem;
  	BOOL Result = 0;
  	char text[265];
 -	if (!TreeView_GetCount(hwnd2Tree)) return Result;
 +	if (!TreeView_GetCount(hwnd2Tree))
 +		return Result;
 -	item.mask = TVIF_STATE|TVIF_PARAM|TVIF_TEXT;
 +	item.mask = TVIF_STATE | TVIF_PARAM | TVIF_TEXT;
  	item.hItem = TVI_ROOT;
  	item.pszText = text;
  	item.cchTextMax = 264;
  	prelastItem = item.hItem;
 -	do
 -	{
 -		do
 -		{
 +	do {
 +		do {
  			lastItem = item.hItem;
 -			if (lastItem != TVI_ROOT)
 -			{
 -				TreeView_GetItem( hwnd2Tree, &item );
 +			if (lastItem != TVI_ROOT) {
 +				TreeView_GetItem(hwnd2Tree, &item);
  				/* these next lines are not from code guru..... */
 -				if (item.lParam)
 -				{
 +				if (item.lParam) {
  					ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)item.lParam;
 -					if (hContact == mtis->hContact && !mir_strcmp(text,module))
 -					{
 +					if (hContact == mtis->hContact && !mir_strcmp(text,module)) {
  						mir_free(mtis);
 -						TreeView_DeleteItem(hwnd2Tree,item.hItem);
 +						TreeView_DeleteItem(hwnd2Tree, item.hItem);
  						lastItem = prelastItem;
  						Result = 1;
  					}
 @@ -292,8 +290,9 @@ BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char* module)  				}
  				/* back to coduguru's code*/
  			}
 -		} while ( (item.hItem = TreeView_GetChild( hwnd2Tree, lastItem )));
 -		while ( (! (item.hItem = TreeView_GetNextSibling( hwnd2Tree, lastItem ))) && (lastItem = item.hItem = TreeView_GetParent( hwnd2Tree, lastItem ))) {}
 +		} while (item.hItem = TreeView_GetChild(hwnd2Tree, lastItem));
 +
 +		while (!(item.hItem = TreeView_GetNextSibling(hwnd2Tree, lastItem)) && (lastItem = item.hItem = TreeView_GetParent(hwnd2Tree, lastItem))) {}
  	} while ( item.hItem );
  	/*****************************************************************************/
 @@ -304,12 +303,13 @@ BOOL findAndRemoveDuplicates(HWND hwnd2Tree, MCONTACT hContact, char* module)  void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const char *newModule)
  {
 -	int hItem = findItemInTree(hwnd, hContact, (char*)module);
 +	int hItem = findItemInTree(hwnd, hContact, (char *)module);
  	HTREEITEM hParent;
 -	if (hItem == -1) return;
 +	if (hItem == -1)
 +		return;
 -	hParent = TreeView_GetParent(hwnd,(HTREEITEM)hItem);
 +	hParent = TreeView_GetParent(hwnd, (HTREEITEM)hItem);
  	{
  		TVITEM item;
 @@ -318,18 +318,17 @@ void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const cha  		if (TreeView_GetItem(hwnd, &item))
  			mir_free((ModuleTreeInfoStruct *)item.lParam);
 -		TreeView_DeleteItem(hwnd,item.hItem);
 +		TreeView_DeleteItem(hwnd, item.hItem);
  	}
 -	if (hParent && newModule)
 -	{
 +	if (hParent && newModule) {
  		TVINSERTSTRUCT tvi = {0};
  		ModuleTreeInfoStruct *lParam;
  		tvi.hParent = hParent;
  		tvi.hInsertAfter = TVI_SORT;
 -		tvi.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE|TVIF_PARAM;
 -		tvi.item.pszText = (char*)newModule;
 +		tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
 +		tvi.item.pszText = (char *)newModule;
  		lParam = (ModuleTreeInfoStruct *)mir_calloc(sizeof(ModuleTreeInfoStruct));
  		lParam->hContact = hContact;
 @@ -345,15 +344,16 @@ void replaceTreeItem(HWND hwnd, MCONTACT hContact, const char *module, const cha  void refreshTree(int restore)
  {
 -	if (populating) return;
 +	if (populating)
 +		return;
  	populating = 1;
 -	forkthread(PopulateModuleTreeThreadFunc,0,(HWND)restore);
 +	forkthread(PopulateModuleTreeThreadFunc, 0, (HWND)restore);
  }
  void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)
  {
  	TVINSERTSTRUCT tvi;
 -	HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow,IDC_MODULES);
 +	HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow, IDC_MODULES);
  	char SelectedModule[256] = {0};
  	char SelectedSetting[256] = {0};
  	MCONTACT hSelectedContact = hRestore;
 @@ -370,14 +370,17 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  	hRestore = NULL;
 -	if (!hwnd2Tree) { msg(Translate("Module tree not found"),modFullname); return;}
 +	if (!hwnd2Tree) {
 +		msg(Translate("Module tree not found"), modFullname);
 +		return;
 +	}
  	Select = 0;
 -	switch((int)di) {
 +	switch ((int)di) {
  	case 1: // restore after rebuild
  		if (HTREEITEM item = TreeView_GetSelection(hwnd2Tree)) {
 -			TVITEM tvi = { 0 };
 +			TVITEM tvi = {0};
  			tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT;
  			tvi.pszText = SelectedModule;
  			tvi.cchTextMax = 255;
 @@ -387,7 +390,8 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  			if (tvi.lParam) {
  				ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
  				hSelectedContact = mtis->hContact;
 -				if (mtis->type == CONTACT) SelectedModule[0] = 0;
 +				if (mtis->type == CONTACT)
 +					SelectedModule[0] = 0;
  				Select = 1;
  			}
  		}
 @@ -411,7 +415,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  	if ((int)di != 4) { // do not rebuild on just going to another setting
  		if (!EnumModules(&modlist)) {
 -			msg(Translate("Error Loading Module List"), modFullname);
 +			msg(Translate("Error loading module list"), modFullname);
  			return;
  		}
 @@ -446,7 +450,8 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  		tvi.hParent = NULL;
  		tvi.hInsertAfter = TVI_FIRST;
  		tvi.item.pszText = Translate("Settings");
 -		tvi.item.iSelectedImage = (tvi.item.iImage = 0);
 +		tvi.item.iImage = 0;
 +		tvi.item.iSelectedImage = 0;
  		contact = TreeView_InsertItem(hwnd2Tree, &tvi);
  		// to fix bug with CHANGE NOTIFY on window activation
 @@ -483,7 +488,8 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  			if (hItem != -1) {
  				TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem);
  				TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND);
 -				if (SelectedSetting[0]) SelectSetting(SelectedSetting);
 +				if (SelectedSetting[0])
 +					SelectSetting(SelectedSetting);
  			}
  			Select = 0;
  		}
 @@ -500,7 +506,8 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  		if (hItem != -1) {
  			TreeView_SelectItem(hwnd2Tree, (HTREEITEM)hItem);
  			TreeView_Expand(hwnd2Tree, hItem, TVE_EXPAND);
 -			if (SelectedSetting[0]) SelectSetting(SelectedSetting);
 +			if (SelectedSetting[0])
 +				SelectSetting(SelectedSetting);
  		}
  	}
 @@ -508,7 +515,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID di)  }
 -static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
 +static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
  	switch (msg) {
  	case WM_KEYUP:
 @@ -525,18 +532,18 @@ static LRESULT CALLBACK ModuleTreeLabelEditSubClassProc(HWND hwnd,UINT msg,WPARA  	return mir_callNextSubclass(hwnd, ModuleTreeLabelEditSubClassProc, msg, wParam, lParam);
  }
 -void moduleListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam);
 +void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam);
  void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hwnd here is to the main window, NOT the treview
  {
 -	switch (((NMHDR*)lParam)->code) {
 +	switch (((NMHDR *)lParam)->code) {
  	case TVN_ITEMEXPANDINGA:
  	case TVN_ITEMEXPANDINGW:
  		if (populating && ((LPNMTREEVIEW)lParam)->action == TVE_EXPAND) {
  			ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)((LPNMTREEVIEW)lParam)->itemNew.lParam;
  			if (mtis && (mtis->type == (CONTACT | EMPTY))) {
  				TVINSERTSTRUCT tvi;
 -				HTREEITEM item = { 0 };
 +				HTREEITEM item = {0};
  				ModuleTreeInfoStruct *_lParam;
  				HWND hwnd2Tree = GetDlgItem(hwnd2mainWindow, IDC_MODULES);
  				ModSetLinkLinkItem *module;
 @@ -545,7 +552,10 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  				mtis->type = CONTACT;
 -				if (!EnumModules(&modlist)) { msg(Translate("Error Loading Module List"), modFullname); break; }
 +				if (!EnumModules(&modlist)) {
 +					msg(Translate("Error loading module list"), modFullname);
 +					break;
 +				}
  				module = modlist.first;
  				while (module && hwnd2mainWindow) {
 @@ -578,7 +588,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  		{
  			ModuleTreeInfoStruct *mtis;
  			LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
 -			TVITEM tvi = { 0 };
 +			TVITEM tvi = {0};
  			char text[264];
  			MCONTACT hContact;
  			HWND hwnd2Settings = GetDlgItem(hwnd, IDC_SETTINGS);
 @@ -592,17 +602,18 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  				mtis = (ModuleTreeInfoStruct *)tvi.lParam;
  				hContact = mtis->hContact;
 -				if (mtis->type == STUB) break;
 +				if (mtis->type == STUB)
 +					break;
 -				if (populating) Select = 0;
 +				if (populating)
 +					Select = 0;
  				if (mtis->type == MODULE) {
 -					SettingListInfo *info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA);
 +					SettingListInfo *info = (SettingListInfo *)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA);
  					BOOL refresh = 1;
  					if (info) {
 -						if (info->hContact == hContact &&
 -							!mir_strcmp(info->module, text))
 +						if (info->hContact == hContact && !mir_strcmp(info->module, text))
  							refresh = 0;
  					}
 @@ -612,13 +623,14 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  				else if (((mtis->type & CONTACT) == CONTACT && hContact) || (mtis->type == CONTACT_ROOT_ITEM && !hContact)) {
  					char data[32], szProto[256];
  					int index, loaded, multi = 0;
 -					LVITEM lvi = { 0 };
 +					LVITEM lvi = {0};
  					lvi.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
  					lvi.iImage = 6;
  					ClearListview(hwnd2Settings);
  					SetWindowLongPtr(hwnd2Settings, GWLP_USERDATA, 0);
 -					if (himl2) ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL);
 +					if (himl2)
 +						ListView_SetImageList(hwnd2Settings, himl2, LVSIL_SMALL);
  					if (mtis->type == CONTACT_ROOT_ITEM && !hContact) {
  						multi = 1;
 @@ -640,7 +652,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  						}
  						lvi.iItem = 0;
 -						lvi.pszText = (char*)GetContactName(hContact, NULL, FALSE);
 +						lvi.pszText = (char *)GetContactName(hContact, NULL, FALSE);
  						index = ListView_InsertItem(hwnd2Settings, &lvi);
 @@ -650,12 +662,14 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  						ListView_SetItemText(hwnd2Settings, index, 2, Translate("HANDLE"));
  						ListView_SetItemText(hwnd2Settings, index, 3, "0x0004 (4)");
 -						if (!multi) break;
 +						if (!multi)
 +							break;
  						hContact = db_find_next(hContact);
  					}
  				}
 -				else ClearListview(hwnd2Settings);
 +				else
 +					ClearListview(hwnd2Settings);
  			}
  			else // clear any settings that may be there...
  				ClearListview(hwnd2Settings);
 @@ -663,7 +677,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  		break; //TVN_SELCHANGED:
  	case NM_RCLICK:
 -		if (((NMHDR*)lParam)->code == NM_RCLICK)
 +		if (((NMHDR *)lParam)->code == NM_RCLICK)
  			moduleListRightClick(hwnd, wParam, lParam);
  		break;
 @@ -685,7 +699,7 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  	case TVN_ENDLABELEDITA:
  	case TVN_ENDLABELEDITW:
  		LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
 -		TVITEM tvi = { 0 };
 +		TVITEM tvi = {0};
  		char text[264];
  		char *newtext;
  		ModuleTreeInfoStruct *mtis;
 @@ -696,12 +710,12 @@ void moduleListWM_NOTIFY(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)// hw  		TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &tvi);
  		mtis = (ModuleTreeInfoStruct *)ptvdi->item.lParam;
 -		newtext = u2a((WCHAR*)ptvdi->item.pszText);
 +		newtext = u2a((WCHAR *)ptvdi->item.pszText);
 -		if (!newtext || // edit control failed
 -			!mtis->type || // its a root item
 -			mtis->type == CONTACT || // its a contact
 -			*newtext == 0)  // empty string
 +		if (!newtext // edit control failed
 +			|| !mtis->type // its a root item
 +			|| mtis->type == CONTACT // its a contact
 +			|| *newtext == 0)  // empty string
  			SetWindowLongPtr(hwnd, DWLP_MSGRESULT, FALSE);
  		else {
  			if (mir_strcmp(tvi.pszText, newtext)) {
 @@ -735,7 +749,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here  	if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) {
  		if (hti.flags & TVHT_ONITEM) {
 -			TVITEM tvi = { 0 };
 +			TVITEM tvi = {0};
  			HMENU hMenu, hSubMenu;
  			int menuNumber;
  			char module[256];
 @@ -747,14 +761,19 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here  			if (tvi.lParam) {
  				ModuleTreeInfoStruct *mtis = (ModuleTreeInfoStruct *)tvi.lParam;
  				MCONTACT hContact = mtis->hContact;
 -				GetCursorPos(&(hti.pt));
 +				GetCursorPos(&hti.pt);
  				hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_CONTEXTMENU));
  				TranslateMenu(hMenu);
 -				if (mtis->type == CONTACT && hContact) menuNumber = 2;
 -				else if ((mtis->type == MODULE) && !hContact) menuNumber = 1;
 -				else if (mtis->type == CONTACT && !hContact) menuNumber = 3;
 -				else if (mtis->type == CONTACT_ROOT_ITEM && !hContact) menuNumber = 4;
 -				else if ((mtis->type == MODULE) && hContact) menuNumber = 5;
 +				if (mtis->type == CONTACT && hContact)
 +					menuNumber = 2;
 +				else if ((mtis->type == MODULE) && !hContact)
 +					menuNumber = 1;
 +				else if (mtis->type == CONTACT && !hContact)
 +					menuNumber = 3;
 +				else if (mtis->type == CONTACT_ROOT_ITEM && !hContact)
 +					menuNumber = 4;
 +				else if ((mtis->type == MODULE) && hContact)
 +					menuNumber = 5;
  				else return;
  				hSubMenu = GetSubMenu(hMenu, menuNumber);
 @@ -825,7 +844,7 @@ void moduleListRightClick(HWND hwnd, WPARAM wParam, LPARAM lParam) // hwnd here  						if (db_get_b(NULL, "CList", "ConfirmDelete", 1)) {
  							char msg[1024];
  							mir_snprintf(msg, SIZEOF(msg), Translate("Are you sure you want to delete contact \"%s\"?"), module);
 -							if (MessageBox(0, msg, Translate("Confirm Contact Delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) {
 +							if (MessageBox(0, msg, Translate("Confirm contact delete"), MB_YESNO | MB_ICONEXCLAMATION) == IDYES) {
  								CallService(MS_DB_CONTACT_DELETE, hContact, 0);
  								freeTree(((LPNMHDR)lParam)->hwndFrom, hContact);
  								TreeView_DeleteItem(((LPNMHDR)lParam)->hwndFrom, tvi.hItem);
  | 
