diff options
66 files changed, 1265 insertions, 1928 deletions
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index 051690457c..97dae60205 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -251,29 +251,6 @@ const    MS_DB_EVENT_GETSTRINGT:PAnsiChar = 'DB/Event/GetStringT';
 -//************************** Encryption ****************************
 -
 -  {
 -    wParam : size in bytes of string buffer (including null term)
 -    lParam : pointer to string buffer
 -    Affect : Scrambles the string buffer in place using a strange encryption algorithm,
 -             see notes
 -    Returns: Always returns 0
 -    notes  : this service may be changed at a later date such that it increasess
 -             the length of the string
 -  }
 -  MS_DB_CRYPT_ENCODESTRING:PAnsiChar = 'DB/Crypt/EncodeString';
 -
 -  {
 -    wParam : size in bytes of string buffer, including null term
 -    lParam : pointer to string buffer
 -    Affect : Descrambles pszString in-place using the strange encryption algorithm,
 -             see notes.
 -    Return : Always returns 0
 -    notes  : Reverses the operation done by MS_DB_CRYPT_ENCODINGSTRING
 -  }
 -  MS_DB_CRYPT_DECODESTRING:PAnsiChar = 'DB/Crypt/DecodeString';
 -
  //**************************** Time ********************************
    {
 diff --git a/include/m_database.h b/include/m_database.h index 828037353f..ddc32d1e7b 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -366,30 +366,6 @@ __forceinline TCHAR* DbGetEventStringT(DBEVENTINFO* dbei, const char* str)  	return (TCHAR*)CallService(MS_DB_EVENT_GETSTRINGT, (WPARAM)dbei, (LPARAM)str);
  }
 -/************************** Encryption ****************************/
 -
 -/* DB/Crypt/EncodeString
 -Scrambles pszString in-place using a strange encryption algorithm
 -  wParam = (WPARAM)(int)cbString
 -  lParam = (LPARAM)(char*)pszString
 -cbString is the size of the buffer pointed to by pszString, *not* the length
 -of pszString. This service may be changed at a later date such that it
 -increases the length of pszString
 -Returns 0 always
 -*/
 -#define MS_DB_CRYPT_ENCODESTRING  "DB/Crypt/EncodeString"
 -
 -/* DB/Crypt/DecodeString
 -Descrambles pszString in-place using the strange encryption algorithm
 -  wParam = (WPARAM)(int)cbString
 -  lParam = (LPARAM)(char*)pszString
 -Reverses the operation done by crypt/encodestring
 -cbString is the size of the buffer pointed to by pszString, *not* the length
 -of pszString.
 -Returns 0 always
 -*/
 -#define MS_DB_CRYPT_DECODESTRING  "DB/Crypt/DecodeString"
 -
  /**************************** Time ********************************/
  /* DB/Time/TimestampToLocal
 diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index a208c2e40f..dd20160964 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -421,13 +421,11 @@ LRESULT CALLBACK ListenWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)  			if (g_wMask & OPT_REQPASS){  //password request
  				DBVARIANT dbVar = {0};
 -				if (!db_get_s(NULL,MOD_NAME,"password",&dbVar))
 -				{
 +				if (!db_get_s(NULL,MOD_NAME,"password",&dbVar)) {
  					g_fPassRequested = true;
  					strncpy(g_password, dbVar.pszVal, MAXPASSLEN);
  					db_free(&dbVar);
 -					CallService(MS_DB_CRYPT_DECODESTRING, MAXPASSLEN+1, ( LPARAM )g_password );
  					int res = DialogBox(g_hInstance,(MAKEINTRESOURCE(IDD_PASSDIALOGNEW)),GetForegroundWindow(), DlgStdInProc);
 diff --git a/plugins/BossKeyPlus/src/Options.cpp b/plugins/BossKeyPlus/src/Options.cpp index 68d5916204..e19d31454b 100644 --- a/plugins/BossKeyPlus/src/Options.cpp +++ b/plugins/BossKeyPlus/src/Options.cpp @@ -23,30 +23,14 @@ bool g_fOptionsOpen;  bool g_fReqRass;
  extern HGENMENU g_hMenuItem;
 -//void Disable_ChildWindows(HWND hwndParent)
 -//{
 -//	if (hwndParent != NULL)
 -//	{
 -//		HWND hWorkWnd = GetWindow(hwndParent,GW_CHILD); // first child
 -//		while (hWorkWnd != NULL)
 -//		{
 -//			EnableWindow(hWorkWnd,false);
 -//			hWorkWnd = GetNextWindow(hWorkWnd,GW_HWNDNEXT);
 -//		}
 -//	}
 -//}
 -
 -
  INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  {
  	static bool s_fRedraw;
 -	switch (msg)
 -	{
 -		case WM_INITDIALOG:
 +	switch (msg) {
 +	case WM_INITDIALOG:
 +		TranslateDialogDefault(hwndDlg);
  		{
 -			TranslateDialogDefault(hwndDlg);
 -
  			g_fOptionsOpen = true;
  			s_fRedraw = false;
 @@ -57,10 +41,7 @@ INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)  			DBVARIANT dbVar;
 -			if (!db_get_s(NULL,MOD_NAME,"password",&dbVar))
 -			{
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen( dbVar.pszVal )+1, ( LPARAM )dbVar.pszVal );
 -
 +			if (!db_get_s(NULL,MOD_NAME,"password",&dbVar)) {
  				SetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,dbVar.pszVal);
  				db_free(&dbVar);
  			}
 @@ -82,87 +63,77 @@ INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)  			SendMessage(hwndDlg,WM_USER + 50,0,0);
  			s_fRedraw = true;
 -			return true;
 -		} break;
 -		case WM_NOTIFY:
 -		{
 -			NMHDR* nmhdr = (NMHDR*)lParam;
 -			switch (nmhdr->code)
 -			{
 -				case PSN_APPLY:
 -				{
 -					WORD wMask = 0;
 -					// we apply changes here
 -					// this plugin ain't that big, no need for a seperate routine
 -
 -					// write down status type
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED)
 -					{
 -						db_set_b(NULL,MOD_NAME,"stattype",(BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0));
 -
 -						// status msg, if needed
 -						if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG))) // meaning we should save it
 -						{
 -							TCHAR tszMsg[1025];
 -							GetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,tszMsg,1024);
 -							if (tszMsg[0] != 0)
 -								db_set_ts(NULL,MOD_NAME,"statmsg",tszMsg);
 -							else // delete current setting
 -								db_unset(NULL,MOD_NAME,"statmsg");
 -						}
 -						wMask |= OPT_CHANGESTATUS;
 -					}
 -
 -					// checkbox
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED)
 -					{
 -						char szPass[MAXPASSLEN+1];
 -						GetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,szPass,MAXPASSLEN+1);
 -						if (szPass[0] != 0){
 -							CallService(MS_DB_CRYPT_ENCODESTRING, MAXPASSLEN+1, ( LPARAM )szPass );
 -							db_set_s(NULL,MOD_NAME,"password",szPass);
 -							wMask |= OPT_REQPASS;
 -						}
 -					}
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK;
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask	|= OPT_DISABLESNDS;
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY;
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)  wMask |= OPT_USEDEFMSG;
 -					if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_TRAYICON) == BST_CHECKED)  wMask |= OPT_TRAYICON;
 -
 -					db_set_w(NULL,MOD_NAME,"optsmask",wMask);
 -					g_wMask = wMask;
 -
 -					return true;
 -				} break;
 +		}
 +		return true;
 +
 +	case WM_NOTIFY:
 +		switch (((NMHDR*)lParam)->code) {
 +		case PSN_APPLY:
 +			WORD wMask = 0;
 +			// we apply changes here
 +			// this plugin ain't that big, no need for a seperate routine
 +
 +			// write down status type
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) {
 +				db_set_b(NULL,MOD_NAME,"stattype",(BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0));
 +
 +				// status msg, if needed
 +				if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG))) { // meaning we should save it
 +					TCHAR tszMsg[1025];
 +					GetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,tszMsg,1024);
 +					if (tszMsg[0] != 0)
 +						db_set_ts(NULL,MOD_NAME,"statmsg",tszMsg);
 +					else // delete current setting
 +						db_unset(NULL,MOD_NAME,"statmsg");
 +				}
 +				wMask |= OPT_CHANGESTATUS;
  			}
 -		} break;
 -		case WM_USER+50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly
 +
 +			// checkbox
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED) {
 +				char szPass[MAXPASSLEN+1];
 +				GetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,szPass,MAXPASSLEN+1);
 +				if (szPass[0] != 0){
 +					db_set_s(NULL,MOD_NAME,"password",szPass);
 +					wMask |= OPT_REQPASS;
 +				}
 +			}
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK;
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask	|= OPT_DISABLESNDS;
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY;
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)  wMask |= OPT_USEDEFMSG;
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_TRAYICON) == BST_CHECKED)  wMask |= OPT_TRAYICON;
 +
 +			db_set_w(NULL,MOD_NAME,"optsmask",wMask);
 +			g_wMask = wMask;
 +			return true;
 +		}
 +		break;
 +
 +	case WM_USER+50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly
  		{
  			BYTE bSelection = (BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0);
  			WORD wMode = STATUS_ARR_TO_ID[bSelection];
 -			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)
 -			{
 +			if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) {
  				TCHAR *ptszDefMsg = GetDefStatusMsg(wMode, 0);
  				SetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, ptszDefMsg);
  				if(ptszDefMsg)
  					mir_free(ptszDefMsg);
  			}
 -			else
 -			{
 +			else {
  				DBVARIANT dbVar;
  				SendDlgItemMessage(hwndDlg,IDC_MAINOPT_STATMSG,EM_LIMITTEXT,1024,0);
 -				if (!db_get_ts(NULL,MOD_NAME,"statmsg",&dbVar))
 -				{
 +				if (!db_get_ts(NULL,MOD_NAME,"statmsg",&dbVar)) {
  					SetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,dbVar.ptszVal);
  					db_free(&dbVar);
  				}
  			}
  			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG),(IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) && (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) != BST_CHECKED));
  			ShowWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG)) && ServiceExists(MS_VARS_FORMATSTRING));
 -			return true;
 -		} break;
 -		case WM_USER+60:
 +		}
 +		return true;
 +
 +	case WM_USER+60:
  		{
  			bool fEnable = IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED;
  			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_CHGSTS),fEnable);
 @@ -170,89 +141,71 @@ INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)  			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_ONLINEONLY),fEnable);
  			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_USEDEFMSG),fEnable);			
  			EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_PASS),IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED);
 -			return true;
 -		} break;
 -		case WM_COMMAND:
 -		{
 -			switch (HIWORD(wParam))
 -			{
 -				case CBN_SELCHANGE:
 -				{
 -					// check the type
 -					// if type doesn't require a msg, we don't use one
 -					if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS)
 -					{
 -						SendMessage(hwndDlg,WM_USER + 50,0,0);
 -					}
 -					SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -					return 0;
 -				} break;
 -				case BN_CLICKED:
 -				{
 -					switch(LOWORD(wParam))
 -					{
 -						case IDC_MAINOPT_DISABLESNDS:
 -						case IDC_MAINOPT_SETONLINEBACK:
 -						case IDC_MAINOPT_ONLINEONLY:
 -						case IDC_MAINOPT_TRAYICON:
 -						{
 -							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -							return true;
 -						} break;
 -						case IDC_MAINOPT_USEDEFMSG:
 -						{
 -							SendMessage(hwndDlg,WM_USER + 50,0,0);
 -							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -							return true;
 -						} break;
 -						case IDC_MAINOPT_CHANGESTATUSBOX:
 -						{
 -							SendMessage(hwndDlg,WM_USER + 60,0,0);
 -							SendMessage(hwndDlg,WM_USER + 50,0,0);
 -							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -							return true;
 -						} break;
 -						case IDC_MAINOPT_REQPASS:
 -						{
 -							SendMessage(hwndDlg,WM_USER + 60,0,0);
 -							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -							return true;
 -						} break;
 -						case IDC_MAINOPT_VARHELP:
 -						{
 -							variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT|VHF_HELP, 0, 0);
 -							SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -							return true;
 -						} break;
 -						case IDC_MAINOPT_LNK_HOTKEY:
 -						{
 -							OPENOPTIONSDIALOG ood = {0};
 -							ood.cbSize = sizeof(ood);
 -							ood.pszGroup = "Customize";
 -							ood.pszPage = "Hotkeys";
 -							Options_Open(&ood);
 -							return (true);
 -						} break;
 -					}
 -					return 0;
 -				} break;
 -				case EN_UPDATE:
 -				{
 -					switch( LOWORD( wParam )) {
 -						case IDC_MAINOPT_STATMSG:
 -						case IDC_MAINOPT_PASS:
 -							if (s_fRedraw)
 -								SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 -					}
 -				} break;
 -				default:break;
 +		}
 +		return true;
 +
 +	case WM_COMMAND:
 +		switch (HIWORD(wParam)) {
 +		case CBN_SELCHANGE:
 +			if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS)
 +				SendMessage(hwndDlg,WM_USER + 50,0,0);
 +
 +			SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +			return 0;
 +
 +		case BN_CLICKED:
 +			switch(LOWORD(wParam)) {
 +			case IDC_MAINOPT_DISABLESNDS:
 +			case IDC_MAINOPT_SETONLINEBACK:
 +			case IDC_MAINOPT_ONLINEONLY:
 +			case IDC_MAINOPT_TRAYICON:
 +				SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +				return true;
 +
 +			case IDC_MAINOPT_USEDEFMSG:
 +				SendMessage(hwndDlg,WM_USER + 50,0,0);
 +				SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +				return true;
 +
 +			case IDC_MAINOPT_CHANGESTATUSBOX:
 +				SendMessage(hwndDlg,WM_USER + 60,0,0);
 +				SendMessage(hwndDlg,WM_USER + 50,0,0);
 +				SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +				return true;
 +
 +			case IDC_MAINOPT_REQPASS:
 +				SendMessage(hwndDlg,WM_USER + 60,0,0);
 +				SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +				return true;
 +
 +			case IDC_MAINOPT_VARHELP:
 +				variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT|VHF_HELP, 0, 0);
 +				SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +				return true;
 +
 +			case IDC_MAINOPT_LNK_HOTKEY:
 +				OPENOPTIONSDIALOG ood = {0};
 +				ood.cbSize = sizeof(ood);
 +				ood.pszGroup = "Customize";
 +				ood.pszPage = "Hotkeys";
 +				Options_Open(&ood);
 +				return (true);
  			}
 -		} break;
 -		case WM_DESTROY:
 -		{
 -			g_fOptionsOpen = false;
  			return 0;
 -		} break;
 +
 +		case EN_UPDATE:
 +			switch( LOWORD( wParam )) {
 +			case IDC_MAINOPT_STATMSG:
 +			case IDC_MAINOPT_PASS:
 +				if (s_fRedraw)
 +					SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
 +			}
 +		}
 +		break;
 +
 +	case WM_DESTROY:
 +		g_fOptionsOpen = false;
 +		return 0;
  	}
  	return(false);
  }
 diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp index d8a616c370..66da7e6b6c 100644 --- a/plugins/CrashDumper/src/ui.cpp +++ b/plugins/CrashDumper/src/ui.cpp @@ -205,7 +205,6 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP  				db_free(&dbv);
  			}
  			if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -227,7 +226,6 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP  			db_set_s(NULL, PluginName, "Username", szSetting);
  			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, SIZEOF(szSetting));
 -			CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(szSetting), (LPARAM)szSetting);
  			db_set_s(NULL, PluginName, "Password", szSetting);
  			db_set_b(NULL, PluginName, "UploadChanged", 
 diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index da280a1959..dfe664396e 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -46,8 +46,6 @@ void GetLoginStr(char* user, size_t szuser, char* pass)  	else user[0] = 0;
  	if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
 -
  		BYTE hash[16];
  		mir_md5_state_t context;
 diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp index e00cd92c93..d0ea542bb5 100644 --- a/plugins/Db3x_mmap/src/dbsettings.cpp +++ b/plugins/Db3x_mmap/src/dbsettings.cpp @@ -37,6 +37,41 @@ DWORD __forceinline GetSettingValueLength(PBYTE pSetting)  #define MoveAlong(n)   {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);}
  #define VLT(n) ((n == DBVT_UTF8)?DBVT_ASCIIZ:n)
 +static bool isEncrypted(LPCSTR szModule, LPCSTR szSetting)
 +{
 +	if (!_strnicmp(szSetting, "password", 8))       return true;
 +	if (!strcmp(szSetting, "NLProxyAuthPassword")) return true;
 +	if (!strcmp(szSetting, "FileProxyPassword"))   return true;
 +	if (!strcmp(szSetting, "TokenSecret"))         return true;
 +
 +	if (!strcmp(szModule, "SecureIM")) {
 +		if (!strcmp(szSetting, "pgp"))              return true;
 +		if (!strcmp(szSetting, "pgpPrivKey"))       return true;
 +	}
 +	return false;
 +}
 +
 +//VERY VERY VERY BASIC ENCRYPTION FUNCTION
 +
 +static void Encrypt(char *msg, BOOL up)
 +{
 +	int jump = (up) ? 5 : -5;
 +	for (int i = 0; msg[i]; i++)
 +		msg[i] = msg[i] + jump;
 +}
 +
 +__forceinline void EncodeString(LPSTR buf)
 +{
 +	Encrypt(buf, TRUE);
 +}
 +
 +__forceinline void DecodeString(LPSTR buf)
 +{
 +	Encrypt(buf, FALSE);
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +
  int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs,int isStatic)
  {
  	DWORD ofsModuleName,ofsContact,ofsSettingsGroup,ofsBlobPtr;
 @@ -92,6 +127,8 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs  					dbcgs->pValue->pszVal = (char*)mir_alloc(strlen(pCachedValue->pszVal)+1);
  					strcpy(dbcgs->pValue->pszVal,pCachedValue->pszVal);
  				}
 +				if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +					DecodeString(dbcgs->pValue->pszVal);
  			}
  			else memcpy( dbcgs->pValue, pCachedValue, sizeof( DBVARIANT ));
 @@ -114,6 +151,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs  	ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
  	if (ofsSettingsGroup) {
 +		bool bEncrypted = false;
  		ofsBlobPtr = ofsSettingsGroup+offsetof(DBContactSettings,blob);
  		pBlob = DBRead(ofsBlobPtr,sizeof(DBContactSettings),&bytesRemaining);
  		while (pBlob[0]) {
 @@ -135,6 +173,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs  					case DBVT_DWORD: DecodeCopyMemory(&(dbcgs->pValue->dVal), (PDWORD)(pBlob+1), 4); break;
  					case DBVT_UTF8:
  					case DBVT_ASCIIZ:
 +						bEncrypted = isEncrypted(dbcgs->szModule, dbcgs->szSetting);
  						NeedBytes(3+*(PWORD)(pBlob+1));
  						if (isStatic) {
  							dbcgs->pValue->cchVal--;
 @@ -164,13 +203,18 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs  				}
  				/**** add to cache **********************/
 -				if ( dbcgs->pValue->type != DBVT_BLOB ) {
 -					DBVARIANT* pCachedValue = m_cache->GetCachedValuePtr( hContact, szCachedSettingName, 1 );
 -					if ( pCachedValue != NULL ) {
 +				if (dbcgs->pValue->type != DBVT_BLOB && !bEncrypted) {
 +					DBVARIANT* pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
 +					if (pCachedValue != NULL) {
  						m_cache->SetCachedVariant(dbcgs->pValue, pCachedValue);
  						log3("set cached [%08p] %s (%p)", hContact, szCachedSettingName, pCachedValue);
  					}
  				}
 +
 +				// don't cache decrypted values
 +				if (dbcgs->pValue->type == DBVT_UTF8 || dbcgs->pValue->type == DBVT_ASCIIZ)
 +					if (bEncrypted)
 +						DecodeString(dbcgs->pValue->pszVal);
  				return 0;
  			}
  			NeedBytes(1);
 @@ -181,8 +225,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs  	}	}
  	/**** add missing setting to cache **********************/
 -	if ( dbcgs->pValue->type != DBVT_BLOB )
 -	{
 +	if ( dbcgs->pValue->type != DBVT_BLOB ) {
  		DBVARIANT* pCachedValue = m_cache->GetCachedValuePtr( hContact, szCachedSettingName, 1 );
  		if ( pCachedValue != NULL ) {
  			pCachedValue->type = DBVT_DELETED;
 @@ -400,7 +443,7 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT  	char* szCachedSettingName = m_cache->GetCachedSetting(tmp.szModule, tmp.szSetting, moduleNameLen, settingNameLen);
  	log3("set [%08p] %s (%p)", hContact, szCachedSettingName, szCachedSettingName);
 -	if ( tmp.value.type != DBVT_BLOB ) {
 +	if (tmp.value.type != DBVT_BLOB && !isEncrypted(dbcws->szModule, dbcws->szSetting)) {
  		DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
  		if ( pCachedValue != NULL ) {
  			bool bIsIdentical = false;
 @@ -410,7 +453,7 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT  					case DBVT_WORD:   bIsIdentical = pCachedValue->wVal == tmp.value.wVal;  break;
  					case DBVT_DWORD:  bIsIdentical = pCachedValue->dVal == tmp.value.dVal;  break;
  					case DBVT_UTF8:
 -					case DBVT_ASCIIZ: bIsIdentical = strcmp( pCachedValue->pszVal, tmp.value.pszVal ) == 0; break;
 +					case DBVT_ASCIIZ: bIsIdentical = strcmp(pCachedValue->pszVal, tmp.value.pszVal) == 0; break;
  				}
  				if ( bIsIdentical )
  					return 0;
 @@ -479,11 +522,10 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT  			NeedBytes(3);
  			if (pBlob[0] != tmp.value.type || ((pBlob[0] == DBVT_ASCIIZ || pBlob[0] == DBVT_UTF8) && *(PWORD)(pBlob+1) != strlen(tmp.value.pszVal)) || (pBlob[0] == DBVT_BLOB && *(PWORD)(pBlob+1) != tmp.value.cpbVal)) {
  				//bin it
 -				int nameLen,valLen;
  				DWORD ofsSettingToCut;
  				NeedBytes(3);
 -				nameLen = 1+settingNameLen;
 -				valLen = 1+GetSettingValueLength(pBlob);
 +				int nameLen = 1+settingNameLen;
 +				int valLen = 1 + GetSettingValueLength(pBlob);
  				ofsSettingToCut = ofsBlobPtr-nameLen;
  				MoveAlong(valLen);
  				NeedBytes(1);
 @@ -501,12 +543,16 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT  				//replace existing setting at pBlob
  				MoveAlong(1);	//skip data type
  				switch(tmp.value.type) {
 -					case DBVT_BYTE: DBWrite(ofsBlobPtr,&tmp.value.bVal,1); break;
 -					case DBVT_WORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.wVal,2); break;
 +					case DBVT_BYTE:  DBWrite(ofsBlobPtr,&tmp.value.bVal,1); break;
 +					case DBVT_WORD:  EncodeDBWrite(ofsBlobPtr,&tmp.value.wVal,2); break;
  					case DBVT_DWORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.dVal,4); break;
 +					case DBVT_BLOB:  EncodeDBWrite(ofsBlobPtr + 2, tmp.value.pbVal, tmp.value.cpbVal); break;
  					case DBVT_UTF8:
 -					case DBVT_ASCIIZ: EncodeDBWrite(ofsBlobPtr+2,tmp.value.pszVal,(int)strlen(tmp.value.pszVal)); break;
 -					case DBVT_BLOB: EncodeDBWrite(ofsBlobPtr+2,tmp.value.pbVal,tmp.value.cpbVal); break;
 +					case DBVT_ASCIIZ: 
 +						if (isEncrypted(dbcws->szModule, dbcws->szSetting))
 +							EncodeString(tmp.value.pszVal);
 +						EncodeDBWrite(ofsBlobPtr+2,tmp.value.pszVal,(int)strlen(tmp.value.pszVal));
 +						break;
  				}
  				//quit
  				DBFlush(1);
 @@ -577,7 +623,10 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT  		case DBVT_DWORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.dVal,4); MoveAlong(4); break;
  		case DBVT_UTF8:
  		case DBVT_ASCIIZ:
 -			{	int len = (int)strlen(tmp.value.pszVal);
 +			{	
 +				int len = (int)strlen(tmp.value.pszVal);
 +				if (isEncrypted(dbcws->szModule, dbcws->szSetting))
 +					EncodeString(tmp.value.pszVal);
  				DBWrite(ofsBlobPtr,&len,2);
  				EncodeDBWrite(ofsBlobPtr+2,tmp.value.pszVal,len);
  				MoveAlong(2+len);
 diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index 1d87461333..db3f939418 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -1076,12 +1076,8 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here  	///////////////////////// convert to submenu
  	case MENU_VIEWDECRYPT:
  		if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
 -			if (lstrcmpA(setting, "LoginPassword")) {
 -				char *text = mir_strdup(dbv.pszVal);
 -				CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text);
 -				msg(text, Translate("Decoded string.."));
 -				mir_free(text);
 -			}
 +			if (lstrcmpA(setting, "LoginPassword"))
 +				msg(dbv.pszVal, Translate("Decoded string.."));
  			else {
  				char *str = mir_strdup(dbv.pszVal);
  				char *str1 = str;
 @@ -1100,32 +1096,20 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here  		break;
  	case MENU_VIEWENCRYPT:
 -		if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
 -			char *text = mir_tstrdup(dbv.pszVal);
 -			CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
 -			msg(text, Translate("Encoded string.."));
 -			mir_free(text);
 -		}
 +		if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ)
 +			msg(dbv.pszVal, Translate("Encoded string.."));
  		db_free(&dbv);
  		break;
  	case MENU_DECRYPT:
 -		if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
 -			char *text = mir_tstrdup(dbv.pszVal);
 -			CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
 -			db_set_s(hContact,module,setting,text);
 -			mir_free(text);
 -		}
 +		if (!db_get_s(hContact,module,setting,&dbv))
 +			db_set_s(hContact,module,setting,dbv.pszVal);
  		db_free(&dbv);
  		break;
  	case MENU_ENCRYPT:
 -		if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
 -			char *text = mir_tstrdup(dbv.pszVal);
 -			CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
 -			db_set_s(hContact,module,setting,text);
 -			mir_free(text);
 -		}
 +		if (!db_get_s(hContact,module,setting,&dbv))
 +			db_set_s(hContact,module,setting,dbv.pszVal);
  		db_free(&dbv);
  		break;
 diff --git a/plugins/Dbx_mmap_SA/src/commonheaders.h b/plugins/Dbx_mmap_SA/src/commonheaders.h index cfee1a77ae..877f0ff65d 100644 --- a/plugins/Dbx_mmap_SA/src/commonheaders.h +++ b/plugins/Dbx_mmap_SA/src/commonheaders.h @@ -59,11 +59,6 @@ extern HGENMENU hSetPwdMenu;  #endif
  //global procedures
 -//int InitSkin();
 -void EncodeCopyMemory(void * dst, void * src, size_t size );
 -void DecodeCopyMemory(void * dst, void * src, size_t size );
 -void EncodeDBWrite(DWORD ofs, void * src, size_t size);
 -void DecodeDBWrite(DWORD ofs, void * src, size_t size);
  struct DlgStdInProcParam
  {
 diff --git a/plugins/Dbx_tree/src/Compatibility.cpp b/plugins/Dbx_tree/src/Compatibility.cpp index 23cca177e5..921b772370 100644 --- a/plugins/Dbx_tree/src/Compatibility.cpp +++ b/plugins/Dbx_tree/src/Compatibility.cpp @@ -153,6 +153,43 @@ STDMETHODIMP_(HANDLE) CDataBase::FindNextContact(HANDLE hContact, const char* sz  	return NULL;
  }
 +/////////////////////////////////////////////////////////////////////////////////////////
 +
 +static bool isEncrypted(LPCSTR szModule, LPCSTR szSetting)
 +{
 +	if (!_strnicmp(szSetting, "password", 8))       return true;
 +	if (!strcmp(szSetting, "NLProxyAuthPassword")) return true;
 +	if (!strcmp(szSetting, "FileProxyPassword"))   return true;
 +	if (!strcmp(szSetting, "TokenSecret"))         return true;
 +
 +	if (!strcmp(szModule, "SecureIM")) {
 +		if (!strcmp(szSetting, "pgp"))              return true;
 +		if (!strcmp(szSetting, "pgpPrivKey"))       return true;
 +	}
 +	return false;
 +}
 +
 +//VERY VERY VERY BASIC ENCRYPTION FUNCTION
 +
 +static void Encrypt(char *msg, BOOL up)
 +{
 +	int jump = (up) ? 5 : -5;
 +	for (int i = 0; msg[i]; i++)
 +		msg[i] = msg[i] + jump;
 +}
 +
 +__forceinline void EncodeString(LPSTR buf)
 +{
 +	Encrypt(buf, TRUE);
 +}
 +
 +__forceinline void DecodeString(LPSTR buf)
 +{
 +	Encrypt(buf, FALSE);
 +}
 +
 +/////////////////////////////////////////////////////////////////////////////////////////
 +
  STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
  {
  	dbcgs->pValue->type = 0;
 @@ -181,67 +218,61 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSE  	if (DBSettingRead(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
  		return -1;
 -	switch (set.Type)
 -	{
 -		case DBT_ST_ANSI:
 -		{
 -			dbcgs->pValue->type = DBVT_ASCIIZ;
 -			dbcgs->pValue->pszVal = set.Value.pAnsi;
 -			dbcgs->pValue->cchVal = set.Value.Length - 1;
 -		} break;
 -		case DBT_ST_UTF8:
 -		{
 -			dbcgs->pValue->type = DBVT_WCHAR;
 -			dbcgs->pValue->pwszVal = mir_utf8decodeW(set.Value.pUTF8);
 -			if (dbcgs->pValue->pwszVal)
 -				dbcgs->pValue->cchVal = static_cast<uint32_t>(wcslen(dbcgs->pValue->pwszVal));
 -			else
 -				dbcgs->pValue->cchVal = 0;
 -			mir_free(set.Value.pUTF8);
 -		} break;
 -		case DBT_ST_WCHAR:
 -		{
 -			dbcgs->pValue->type = DBVT_WCHAR;
 -			dbcgs->pValue->pwszVal = set.Value.pWide;
 -			dbcgs->pValue->cchVal = set.Value.Length - 1;
 -		} break;
 -		case DBT_ST_BLOB:
 -		{
 -			dbcgs->pValue->type = DBVT_BLOB;
 -			dbcgs->pValue->pbVal = set.Value.pBlob;
 -			dbcgs->pValue->cpbVal = set.Value.Length;
 -		} break;
 -		case DBT_ST_BOOL:
 -		{
 -			dbcgs->pValue->type = DBVT_BYTE;
 -			dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
 -		} break;
 -		case DBT_ST_BYTE: case DBT_ST_CHAR:
 -		{
 -			dbcgs->pValue->type = DBVT_BYTE;
 -			dbcgs->pValue->bVal = set.Value.Byte;
 -		} break;
 -		case DBT_ST_SHORT: case DBT_ST_WORD:
 -		{
 -			dbcgs->pValue->type = DBVT_WORD;
 -			dbcgs->pValue->wVal = set.Value.Word;
 -		} break;
 -		case DBT_ST_INT: case DBT_ST_DWORD:
 -		{
 -			dbcgs->pValue->type = DBVT_DWORD;
 -			dbcgs->pValue->dVal = set.Value.DWord;
 -		} break;
 -		case DBT_ST_INT64: case DBT_ST_QWORD:
 -		case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
 -		{
 -			dbcgs->pValue->type = DBVT_BLOB;
 -			dbcgs->pValue->cpbVal = sizeof(set.Value);
 -			dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
 -			memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
 -		} break;
 -
 -		default:
 -			return -1;
 +	switch (set.Type) {
 +	case DBT_ST_ANSI:
 +		dbcgs->pValue->type = DBVT_ASCIIZ;
 +		dbcgs->pValue->pszVal = set.Value.pAnsi;
 +		dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +			DecodeString(dbcgs->pValue->pszVal);
 +		break;
 +	case DBT_ST_UTF8:
 +		if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +			DecodeString(set.Value.pUTF8);
 +		dbcgs->pValue->type = DBVT_WCHAR;
 +		dbcgs->pValue->pwszVal = mir_utf8decodeW(set.Value.pUTF8);
 +		if (dbcgs->pValue->pwszVal)
 +			dbcgs->pValue->cchVal = static_cast<uint32_t>(wcslen(dbcgs->pValue->pwszVal));
 +		else
 +			dbcgs->pValue->cchVal = 0;
 +		mir_free(set.Value.pUTF8);
 +		break;
 +	case DBT_ST_WCHAR:
 +		dbcgs->pValue->type = DBVT_WCHAR;
 +		dbcgs->pValue->pwszVal = set.Value.pWide;
 +		dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		break;
 +	case DBT_ST_BLOB:
 +		dbcgs->pValue->type = DBVT_BLOB;
 +		dbcgs->pValue->pbVal = set.Value.pBlob;
 +		dbcgs->pValue->cpbVal = set.Value.Length;
 +		break;
 +	case DBT_ST_BOOL:
 +		dbcgs->pValue->type = DBVT_BYTE;
 +		dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
 +		break;
 +	case DBT_ST_BYTE: case DBT_ST_CHAR:
 +		dbcgs->pValue->type = DBVT_BYTE;
 +		dbcgs->pValue->bVal = set.Value.Byte;
 +		break;
 +	case DBT_ST_SHORT: case DBT_ST_WORD:
 +		dbcgs->pValue->type = DBVT_WORD;
 +		dbcgs->pValue->wVal = set.Value.Word;
 +		break;
 +	case DBT_ST_INT: case DBT_ST_DWORD:
 +		dbcgs->pValue->type = DBVT_DWORD;
 +		dbcgs->pValue->dVal = set.Value.DWord;
 +		break;
 +	case DBT_ST_INT64: case DBT_ST_QWORD:
 +	case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
 +		dbcgs->pValue->type = DBVT_BLOB;
 +		dbcgs->pValue->cpbVal = sizeof(set.Value);
 +		dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
 +		memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
 +		break;
 +
 +	default:
 +		return -1;
  	}
  	return 0;
 @@ -272,9 +303,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE  	set.cbSize = sizeof(set);
  	set.Descriptor = &desc;
 -
 -	switch (dbcgs->pValue->type)
 -	{
 +	switch (dbcgs->pValue->type) {
  		case DBVT_ASCIIZ: set.Type = DBT_ST_ANSI; break;
  		case DBVT_BLOB:   set.Type = DBT_ST_BLOB; break;
  		case DBVT_UTF8:   set.Type = DBT_ST_UTF8; break;
 @@ -284,69 +313,65 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE  	if (DBSettingRead(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
  		return -1;
 -	switch (set.Type)
 -	{
 -		case DBT_ST_ANSI:
 -		{
 -			dbcgs->pValue->type = DBVT_ASCIIZ;
 -			dbcgs->pValue->pszVal = set.Value.pAnsi;
 +	switch (set.Type) {
 +	case DBT_ST_ANSI:
 +		dbcgs->pValue->type = DBVT_ASCIIZ;
 +		dbcgs->pValue->pszVal = set.Value.pAnsi;
 +		dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +			DecodeString(dbcgs->pValue->pszVal);
 +		break;
 +	case DBT_ST_UTF8:
 +		dbcgs->pValue->type = DBVT_UTF8;
 +		dbcgs->pValue->pszVal = set.Value.pUTF8;
 +		dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +			DecodeString(dbcgs->pValue->pszVal);
 +		break;
 +	case DBT_ST_WCHAR:
 +		if (dbcgs->pValue->type == DBVT_WCHAR) {
 +			dbcgs->pValue->pwszVal = set.Value.pWide;
  			dbcgs->pValue->cchVal = set.Value.Length - 1;
 -		} break;
 -		case DBT_ST_UTF8:
 -		{
 +		}
 +		else {
  			dbcgs->pValue->type = DBVT_UTF8;
 -			dbcgs->pValue->pszVal = set.Value.pUTF8;
 -			dbcgs->pValue->cchVal = set.Value.Length - 1;
 -		} break;
 -		case DBT_ST_WCHAR:
 -		{
 -			if (dbcgs->pValue->type == DBVT_WCHAR)
 -			{
 -				dbcgs->pValue->pwszVal = set.Value.pWide;
 -				dbcgs->pValue->cchVal = set.Value.Length - 1;
 -			} else {
 -				dbcgs->pValue->type = DBVT_UTF8;
 -				dbcgs->pValue->pszVal = mir_utf8encodeW(set.Value.pWide);
 -				dbcgs->pValue->cchVal = static_cast<uint32_t>(strlen(dbcgs->pValue->pszVal));
 -				mir_free(set.Value.pWide);
 -			}
 -		} break;
 -		case DBT_ST_BLOB:
 -		{
 -			dbcgs->pValue->type = DBVT_BLOB;
 -			dbcgs->pValue->pbVal = set.Value.pBlob;
 -			dbcgs->pValue->cpbVal = set.Value.Length;
 -		} break;
 -		case DBT_ST_BOOL:
 -		{
 -			dbcgs->pValue->type = DBVT_BYTE;
 -			dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
 -		} break;
 -		case DBT_ST_BYTE: case DBT_ST_CHAR:
 -		{
 -			dbcgs->pValue->type = DBVT_BYTE;
 -			dbcgs->pValue->bVal = set.Value.Byte;
 -		} break;
 -		case DBT_ST_SHORT: case DBT_ST_WORD:
 -		{
 -			dbcgs->pValue->type = DBVT_WORD;
 -			dbcgs->pValue->wVal = set.Value.Word;
 -		} break;
 -		case DBT_ST_INT: case DBT_ST_DWORD:
 -		{
 -			dbcgs->pValue->type = DBVT_DWORD;
 -			dbcgs->pValue->dVal = set.Value.DWord;
 -		} break;
 -		case DBT_ST_INT64: case DBT_ST_QWORD:
 -		case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
 -		{
 -			dbcgs->pValue->type = DBVT_BLOB;
 -			dbcgs->pValue->cpbVal = sizeof(set.Value);
 -			dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
 -			memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
 -		} break;
 -		default:
 -			return -1;
 +			dbcgs->pValue->pszVal = mir_utf8encodeW(set.Value.pWide);
 +			dbcgs->pValue->cchVal = static_cast<uint32_t>(strlen(dbcgs->pValue->pszVal));
 +			if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +				DecodeString(dbcgs->pValue->pszVal);
 +			mir_free(set.Value.pWide);
 +		}
 +		break;
 +	case DBT_ST_BLOB:
 +		dbcgs->pValue->type = DBVT_BLOB;
 +		dbcgs->pValue->pbVal = set.Value.pBlob;
 +		dbcgs->pValue->cpbVal = set.Value.Length;
 +		break;
 +	case DBT_ST_BOOL:
 +		dbcgs->pValue->type = DBVT_BYTE;
 +		dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
 +		break;
 +	case DBT_ST_BYTE: case DBT_ST_CHAR:
 +		dbcgs->pValue->type = DBVT_BYTE;
 +		dbcgs->pValue->bVal = set.Value.Byte;
 +		break;
 +	case DBT_ST_SHORT: case DBT_ST_WORD:
 +		dbcgs->pValue->type = DBVT_WORD;
 +		dbcgs->pValue->wVal = set.Value.Word;
 +		break;
 +	case DBT_ST_INT: case DBT_ST_DWORD:
 +		dbcgs->pValue->type = DBVT_DWORD;
 +		dbcgs->pValue->dVal = set.Value.DWord;
 +		break;
 +	case DBT_ST_INT64: case DBT_ST_QWORD:
 +	case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
 +		dbcgs->pValue->type = DBVT_BLOB;
 +		dbcgs->pValue->cpbVal = sizeof(set.Value);
 +		dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
 +		memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
 +		break;
 +	default:
 +		return -1;
  	}
  	return 0;
 @@ -381,92 +406,86 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC  		return -1;
  	}
 -	switch (set.Type)
 -	{
 -		case DBT_ST_ANSI:
 -		{
 -			if (dbcgs->pValue->cchVal < set.Value.Length)
 -			{
 -				memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, dbcgs->pValue->cchVal);
 -				dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
 -			} else {
 -				memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, set.Value.Length);
 -			}
 -			dbcgs->pValue->type = DBVT_ASCIIZ;
 -			dbcgs->pValue->cchVal = set.Value.Length - 1;
 +	switch (set.Type) {
 +	case DBT_ST_ANSI:
 +		if (dbcgs->pValue->cchVal < set.Value.Length) {
 +			memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, dbcgs->pValue->cchVal);
 +			dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
 +		}
 +		else memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, set.Value.Length);
 +
 +		dbcgs->pValue->type = DBVT_ASCIIZ;
 +		dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +			DecodeString(dbcgs->pValue->pszVal);
 +
 +		mir_free(set.Value.pAnsi);
 +		break;
 +	case DBT_ST_UTF8:
 +		set.Value.pUTF8 = mir_utf8decode(set.Value.pUTF8, NULL);
 +		set.Value.Length = static_cast<uint32_t>(strlen(set.Value.pUTF8));
 +
 +		if (dbcgs->pValue->cchVal < set.Value.Length) {
 +			memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, dbcgs->pValue->cchVal);
 +			dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
 +		}
 +		else memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, set.Value.Length);
 -			mir_free(set.Value.pAnsi);
 -		} break;
 -		case DBT_ST_UTF8:
 -		{
 -			set.Value.pUTF8 = mir_utf8decode(set.Value.pUTF8, NULL);
 -			set.Value.Length = static_cast<uint32_t>(strlen(set.Value.pUTF8));
 -
 -			if (dbcgs->pValue->cchVal < set.Value.Length)
 -			{
 -				memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, dbcgs->pValue->cchVal);
 -				dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
 -			} else {
 -				memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, set.Value.Length);
 -			}
 -			dbcgs->pValue->type = DBVT_ASCIIZ;
 -			dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		dbcgs->pValue->type = DBVT_ASCIIZ;
 +		dbcgs->pValue->cchVal = set.Value.Length - 1;
 +		if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +			DecodeString(dbcgs->pValue->pszVal);
 -			mir_free(set.Value.pUTF8);
 -		} break;
 -		case DBT_ST_WCHAR:
 +		mir_free(set.Value.pUTF8);
 +		break;
 +	case DBT_ST_WCHAR:
  		{
 -			char * tmp = mir_u2a(set.Value.pWide);
 +			char *tmp = mir_u2a(set.Value.pWide);
  			WORD l = static_cast<WORD>(strlen(tmp));
  			mir_free(set.Value.pWide);
 -			if (dbcgs->pValue->cchVal < l + 1)
 -			{
 +			if (dbcgs->pValue->cchVal < l + 1) {
  				memcpy(dbcgs->pValue->pszVal, tmp, dbcgs->pValue->cchVal);
  				dbcgs->pValue->pszVal[l] = 0;
 -			} else {
 -				memcpy(dbcgs->pValue->pszVal, tmp, l + 1);
  			}
 +			else memcpy(dbcgs->pValue->pszVal, tmp, l + 1);
 +
  			dbcgs->pValue->type = DBVT_ASCIIZ;
  			dbcgs->pValue->cchVal = l;
 +			if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
 +				DecodeString(dbcgs->pValue->pszVal);
  			mir_free(tmp);
 -		} break;
 -		case DBT_ST_BLOB:
 -		{
 -			if (dbcgs->pValue->cchVal < set.Value.Length)
 -			{
 -				memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, dbcgs->pValue->cchVal);
 -			} else {
 -				memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, set.Value.Length);
 -			}
 -			dbcgs->pValue->type = DBVT_BLOB;
 -			dbcgs->pValue->cchVal = set.Value.Length;
 -
 -			mir_free(set.Value.pBlob);
 -		} break;
 -		case DBT_ST_BOOL:
 -		{
 -			dbcgs->pValue->type = DBVT_BYTE;
 -			dbcgs->pValue->bVal = set.Value.Bool ? TRUE : FALSE;
 -		} break;
 -		case DBT_ST_BYTE: case DBT_ST_CHAR:
 -		{
 -			dbcgs->pValue->type = DBVT_BYTE;
 -			dbcgs->pValue->bVal = set.Value.Byte;
 -		} break;
 -		case DBT_ST_SHORT: case DBT_ST_WORD:
 -		{
 -			dbcgs->pValue->type = DBVT_WORD;
 -			dbcgs->pValue->wVal = set.Value.Word;
 -		} break;
 -		case DBT_ST_INT: case DBT_ST_DWORD:
 -		{
 -			dbcgs->pValue->type = DBVT_DWORD;
 -			dbcgs->pValue->dVal = set.Value.DWord;
 -		} break;
 -		default:
 -			return -1;
 +		}
 +		break;
 +	case DBT_ST_BLOB:
 +		if (dbcgs->pValue->cchVal < set.Value.Length)
 +			memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, dbcgs->pValue->cchVal);
 +		else
 +			memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, set.Value.Length);
 +
 +		dbcgs->pValue->type = DBVT_BLOB;
 +		dbcgs->pValue->cchVal = set.Value.Length;
 +		mir_free(set.Value.pBlob);
 +		break;
 +	case DBT_ST_BOOL:
 +		dbcgs->pValue->type = DBVT_BYTE;
 +		dbcgs->pValue->bVal = set.Value.Bool ? TRUE : FALSE;
 +		break;
 +	case DBT_ST_BYTE: case DBT_ST_CHAR:
 +		dbcgs->pValue->type = DBVT_BYTE;
 +		dbcgs->pValue->bVal = set.Value.Byte;
 +		break;
 +	case DBT_ST_SHORT: case DBT_ST_WORD:
 +		dbcgs->pValue->type = DBVT_WORD;
 +		dbcgs->pValue->wVal = set.Value.Word;
 +		break;
 +	case DBT_ST_INT: case DBT_ST_DWORD:
 +		dbcgs->pValue->type = DBVT_DWORD;
 +		dbcgs->pValue->dVal = set.Value.DWord;
 +		break;
 +	default:
 +		return -1;
  	}
  	return 0;
 @@ -474,12 +493,11 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC  STDMETHODIMP_(BOOL) CDataBase::FreeVariant(DBVARIANT *dbv)
  {
 -	if ((dbv->type == DBVT_BLOB) && (dbv->pbVal))
 -	{
 +	if (dbv->type == DBVT_BLOB && dbv->pbVal) {
  		mir_free(dbv->pbVal);
  		dbv->pbVal = 0;
 -	} else if ((dbv->type & DBVTF_VARIABLELENGTH) && (dbv->pszVal))
 -	{
 +	}
 +	else if ((dbv->type & DBVTF_VARIABLELENGTH) && (dbv->pszVal)) {
  		mir_free(dbv->pszVal);
  		dbv->pszVal = NULL;
  	}
 @@ -506,72 +524,66 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI  	set.cbSize = sizeof(set);
  	set.Descriptor = &desc;
 -	switch (dbcws->value.type)
 -	{
 -		case DBVT_ASCIIZ:
 -		{
 -			set.Type = DBT_ST_ANSI;
 -			set.Value.pAnsi = dbcws->value.pszVal;
 -		} break;
 -		case DBVT_UTF8:
 +	switch (dbcws->value.type) {
 +	case DBVT_ASCIIZ:
 +		set.Type = DBT_ST_ANSI;
 +		set.Value.pAnsi = dbcws->value.pszVal;
 +		if (isEncrypted(dbcws->szModule, dbcws->szSetting))
 +			EncodeString(dbcws->value.pszVal);
 +		break;
 +	case DBVT_UTF8:
 +		if (isEncrypted(dbcws->szModule, dbcws->szSetting))
 +			EncodeString(dbcws->value.pszVal);
  		{
  			wchar_t * tmp = mir_utf8decodeW(dbcws->value.pszVal);
 -			if (tmp == 0)
 -			{
 +			if (tmp == 0) {
  				if (IsDebuggerPresent())
  				{
  					DebugBreak();
  #ifdef _DEBUG
 -				} else {
 +				}
 +				else {
  					LOG(logWARNING, _T("Trying to write malformed UTF8 setting \"%hs\" in module \"%hs\""), dbcws->szSetting, dbcws->szModule);
  					CLogger::Instance().ShowMessage();
  #endif
  				}
  				return -1;
 -			} else {
 -				mir_free(tmp);
  			}
 -
 -			set.Type = DBT_ST_UTF8;
 -			set.Value.pUTF8 = dbcws->value.pszVal;
 -		} break;
 -		case DBVT_WCHAR:
 -		{
 -			set.Type = DBT_ST_WCHAR;
 -			set.Value.pWide = dbcws->value.pwszVal;
 -		} break;
 -		case DBVT_BLOB:
 -		{
 -			set.Type = DBT_ST_BLOB;
 -			set.Value.pBlob = dbcws->value.pbVal;
 -			set.Value.Length = dbcws->value.cpbVal;
 -		} break;
 -		case DBVT_BYTE:
 -		{
 -			set.Type = DBT_ST_BYTE;
 -			set.Value.Byte = dbcws->value.bVal;
 -		} break;
 -		case DBVT_WORD:
 -		{
 -			set.Type = DBT_ST_WORD;
 -			set.Value.Word = dbcws->value.wVal;
 -		} break;
 -		case DBVT_DWORD:
 -		{
 -			set.Type = DBT_ST_DWORD;
 -			set.Value.DWord = dbcws->value.dVal;
 -		} break;
 -		default:
 -		{
 -			return -1;
 +			else mir_free(tmp);
  		}
 +
 +		set.Type = DBT_ST_UTF8;
 +		set.Value.pUTF8 = dbcws->value.pszVal;
 +		break;
 +	case DBVT_WCHAR:
 +		set.Type = DBT_ST_WCHAR;
 +		set.Value.pWide = dbcws->value.pwszVal;
 +		break;
 +	case DBVT_BLOB:
 +		set.Type = DBT_ST_BLOB;
 +		set.Value.pBlob = dbcws->value.pbVal;
 +		set.Value.Length = dbcws->value.cpbVal;
 +		break;
 +	case DBVT_BYTE:
 +		set.Type = DBT_ST_BYTE;
 +		set.Value.Byte = dbcws->value.bVal;
 +		break;
 +	case DBVT_WORD:
 +		set.Type = DBT_ST_WORD;
 +		set.Value.Word = dbcws->value.wVal;
 +		break;
 +	case DBVT_DWORD:
 +		set.Type = DBT_ST_DWORD;
 +		set.Value.DWord = dbcws->value.dVal;
 +		break;
 +	default:
 +		return -1;
  	}
  	if (DBSettingWrite(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
  		return -1;
 -	if (dbcws->value.type == DBVT_WCHAR)
 -	{
 +	if (dbcws->value.type == DBVT_WCHAR) {
  		dbcws->value.type = DBVT_UTF8;
  		wchar_t * tmp = dbcws->value.pwszVal;
  		dbcws->value.pszVal = mir_utf8encodeW(dbcws->value.pwszVal);
 @@ -579,9 +591,8 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI  		mir_free(dbcws->value.pszVal);
  		dbcws->value.type = DBVT_WCHAR;
  		dbcws->value.pwszVal = tmp;		
 -	} else {
 -		NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)dbcws);
  	}
 +	else NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)dbcws);
  	return 0;
  }
 diff --git a/plugins/Exchange/src/MirandaExchange.cpp b/plugins/Exchange/src/MirandaExchange.cpp index fcca1f5c1c..9c2dabe005 100644 --- a/plugins/Exchange/src/MirandaExchange.cpp +++ b/plugins/Exchange/src/MirandaExchange.cpp @@ -59,23 +59,23 @@ HRESULT HrMAPIFindDefaultMsgStore(    // RETURNS: return code      // Get the list of available message stores from MAPI
      hrT = MAPICALL(lplhSession)->GetMsgStoresTable( 0, &lpTable);
 -	if(!FAILED(hrT))
 +	if (!FAILED(hrT))
  	{
  		// Get the row count for the message recipient table
  		hrT = MAPICALL(lpTable)->GetRowCount(0, &cRows);
 -		if(!FAILED(hrT))
 +		if (!FAILED(hrT))
  		{
  			// Set the columns to return
  			hrT = MAPICALL(lpTable)->SetColumns((LPSPropTagArray)&rgPropTagArray, 0);
 -			if(!FAILED(hrT))
 +			if (!FAILED(hrT))
  			{
  				// Go to the beginning of the recipient table for the envelope
  				hrT = MAPICALL(lpTable)->SeekRow( BOOKMARK_BEGINNING, 0, NULL);
 -				if(!FAILED(hrT))
 +				if (!FAILED(hrT))
  				{
  					// Read all the rows of the table
  					hrT = MAPICALL(lpTable)->QueryRows( cRows, 0, &lpRows);
 -					if(SUCCEEDED(hrT) && (lpRows != NULL) && (lpRows->cRows == 0))
 +					if (SUCCEEDED(hrT) && (lpRows != NULL) && (lpRows->cRows == 0))
  					{
  						FreeProws(lpRows);
  						lpRows = NULL;
 @@ -86,18 +86,18 @@ HRESULT HrMAPIFindDefaultMsgStore(    // RETURNS: return code  		}
  	}
 -    if( !FAILED(hrT) )
 +    if ( !FAILED(hrT) )
      {
  		bool bGetOut = false;
  		for(i = 0; (i < cRows) && (!bGetOut); i++)
  		{
 -			if(lpRows->aRow[i].lpProps[0].Value.b == TRUE)
 +			if (lpRows->aRow[i].lpProps[0].Value.b == TRUE)
  			{
  				cbeid = lpRows->aRow[i].lpProps[1].Value.bin.cb;
  				sc = MAPIAllocateBuffer(cbeid, (void **)&lpeid);
 -				if(FAILED(sc))
 +				if (FAILED(sc))
  				{
  					cbeid = 0;
  					lpeid = NULL;
 @@ -113,7 +113,7 @@ HRESULT HrMAPIFindDefaultMsgStore(    // RETURNS: return code  		}
      }
 -    if(lpRows != NULL)
 +    if (lpRows != NULL)
      {
          FreeProws(lpRows);
      }
 @@ -228,7 +228,7 @@ CMirandaExchange::~CMirandaExchange()  		m_lpMDB = NULL;
  	}
 -	if( NULL!= m_lpMAPISession )
 +	if ( NULL!= m_lpMAPISession )
  	{
  		m_lpMAPISession->Logoff(NULL,NULL,NULL);
  		UlRelease(m_lpMAPISession );
 @@ -448,12 +448,12 @@ HRESULT CMirandaExchange::InitializeAndLogin( LPCTSTR szUsername, LPCTSTR szPass  		LPMDB lpMDB         = NULL;
  		MAPIINIT_0 mapiInit = { MAPI_INIT_VERSION , MAPI_MULTITHREAD_NOTIFICATIONS };
 -		if( !m_bNoInitAgain) {
 +		if ( !m_bNoInitAgain) {
  			m_bNoInitAgain = true;
  			hr = MAPIInitialize( &mapiInit) ;
  		}
 -		if( SUCCEEDED(hr)) {
 +		if ( SUCCEEDED(hr)) {
  			TCHAR	szPIDandName[128];
  			TCHAR	szPID[20];
 @@ -694,7 +694,7 @@ HRESULT CMirandaExchange::LogOFF()  			m_lpMDB = NULL;
  		}
 -		if( NULL!= m_lpMAPISession )
 +		if ( NULL!= m_lpMAPISession )
  		{
  			m_lpMAPISession->Logoff( NULL, NULL, NULL );
  			m_lpMAPISession->Release();
 @@ -788,7 +788,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )  		CMAPIInterface<LPMAPITABLE> lpMessageTable;
  		hr = lpFolder->GetContentsTable( 0, &lpMessageTable );
 -		if( HR_FAILED( hr ) )
 +		if ( HR_FAILED( hr ) )
  		{
  			return -1;
  		}
 @@ -808,7 +808,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )  		//////////////////////////////////////////////////////////////////////////
 -		if( HR_FAILED( hr ) )
 +		if ( HR_FAILED( hr ) )
  		{
  			return -1;
  		}
 @@ -823,21 +823,21 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )  				if ( !(lpRowsR->aRow[ i ].lpProps[ 1 ].Value.l & MSGFLAG_READ) )
  				{
 -					if( !FAILED(lpRowsR->aRow[i].lpProps[2].Value.err) ) 
 +					if ( !FAILED(lpRowsR->aRow[i].lpProps[2].Value.err) ) 
  					{
  						szSenderName = lpRowsR->aRow[i].lpProps[2].Value.lpszW;
  					}
  					if ( NULL == szSenderName)
  					{
 -						if( !FAILED(lpRowsR->aRow[i].lpProps[3].Value.err))
 +						if ( !FAILED(lpRowsR->aRow[i].lpProps[3].Value.err))
  						{
  							szSenderName = lpRowsR->aRow[i].lpProps[3].Value.lpszW;
  						}
  					}
 -					if( !FAILED(lpRowsR->aRow[i].lpProps[4].Value.err) )
 +					if ( !FAILED(lpRowsR->aRow[i].lpProps[4].Value.err) )
  					{
  						szSubject = lpRowsR->aRow[i].lpProps[4].Value.lpszW;
  					}
 @@ -887,7 +887,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )  						lpRowProp = lpRow->aRow[i].lpProps;
  						CMAPIInterface<LPMAPIFOLDER> lpSubFolder = NULL;
  						hr = CallOpenEntry( m_lpMDB, NULL, NULL, NULL, lpRowProp[IENTRYID].Value.bin.cb, (LPENTRYID)lpRowProp[IENTRYID].Value.bin.lpb, MAPI_BEST_ACCESS, NULL, (LPUNKNOWN*)&lpSubFolder );
 -						if( !FAILED(hr) )
 +						if ( !FAILED(hr) )
  						{
  							hr = CheckInFolder( lpSubFolder );
  							//if (FAILED(hr) ){//Log("failed checkinfolder for %s\n",lpRowProp[IDISPNAME].Value.lpszA );}
 @@ -917,7 +917,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )  	DWORD dwLength  = 512 ;
  	DWORD dwType = REG_SZ;
 -	if( RegOpenKeyEx(HKEY_CLASSES_ROOT,
 +	if ( RegOpenKeyEx(HKEY_CLASSES_ROOT,
          _T("mailto\\shell\\open\\command"),
          0,
          KEY_ALL_ACCESS | KEY_EXECUTE | KEY_QUERY_VALUE ,
 @@ -927,7 +927,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )  		LONG lResult = RegQueryValueEx( hTheKey, NULL, NULL,  (LPDWORD)&dwType, (LPBYTE)szRegValue, &dwLength);
  		RegCloseKey( hTheKey );
 -		if( lResult != ERROR_SUCCESS )
 +		if ( lResult != ERROR_SUCCESS )
  		{
  			hRes = E_FAIL;
  		}
 @@ -936,7 +936,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )  			TCHAR* szTheEnd = _tcsstr( szRegValue,_T(".EXE") );
 -			if( NULL != szTheEnd )
 +			if ( NULL != szTheEnd )
  			{
  				szRegValue[ _tcslen(szRegValue) - _tcslen(szTheEnd) +5 ]  = _T('\0');
  				_tcscat( szRegValue, _T(" /recycle") );
 @@ -951,7 +951,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )  				si.dwFlags      =   STARTF_USESHOWWINDOW;
  				si.wShowWindow  =   SW_SHOWNORMAL;
 -				if( CreateProcess   (   NULL,
 +				if ( CreateProcess   (   NULL,
  					szRegValue,
  					NULL,
  					NULL,
 diff --git a/plugins/Exchange/src/MirandaExchange.h b/plugins/Exchange/src/MirandaExchange.h index 17edac4a92..9644e69fdb 100644 --- a/plugins/Exchange/src/MirandaExchange.h +++ b/plugins/Exchange/src/MirandaExchange.h @@ -175,7 +175,7 @@ public:      // DESTRUCTOR logs off of the MAPI session and releases the session handle.
      ~CMAPISession() 
      {
 -        if( m_ptr)
 +        if ( m_ptr)
              m_ptr->Logoff( 0L, 0L, 0L);
      }
  };
 diff --git a/plugins/Exchange/src/dlg_handlers.cpp b/plugins/Exchange/src/dlg_handlers.cpp index 9a8095eba6..631febea78 100644 --- a/plugins/Exchange/src/dlg_handlers.cpp +++ b/plugins/Exchange/src/dlg_handlers.cpp @@ -30,182 +30,117 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara  {
  	static int bInitializing; //true when dialog is being created
 -	switch (msg)
 +	switch (msg) {
 +	case WM_INITDIALOG:
 +		TranslateDialogDefault(hWnd);
  		{
 -			case WM_INITDIALOG:
 -				{
 -					TCHAR buffer[4096];
 -					char apassword[1024];
 -					long port;
 -					long interval;
 -					int bCheck;
 -					int portCheck;
 -					int retries;
 -					bInitializing = 1;
 -					DBVARIANT dbv = {0};
 -					
 -					
 -					dbv.type = DBVT_ASCIIZ;
 -					
 -					TranslateDialogDefault(hWnd);
 -					
 -					bCheck = db_get_b(NULL, ModuleName, "Check", 1);
 -					GetStringFromDatabase("Username", _T(""), buffer, sizeof(buffer));
 -					SetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer);
 -					GetStringFromDatabase("Password", _T(""), buffer, sizeof(buffer));
 -					strcpy(apassword,mir_t2a(buffer));
 -					CallService(MS_DB_CRYPT_DECODESTRING, sizeof(apassword), (LPARAM) apassword);
 -					SetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), mir_a2t(apassword));
 -					GetStringFromDatabase("Server", _T(""), buffer, sizeof(buffer));
 -					SetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer);
 -					
 -					port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
 -					//_itoa(port, buffer, 10);
 -					//SetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer);
 -					SetDlgItemInt(hWnd,IDC_PORT_EDIT,port,FALSE);
 -					
 -					interval = db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL);
 -					//_itoa(interval, buffer, 10);
 -					//SetWindowText(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), buffer);
 -					SetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,interval,FALSE);
 -
 -					CheckDlgButton(hWnd, IDC_RECONNECT, (db_get_b(NULL, ModuleName, "Reconnect", 0)) ? BST_CHECKED : BST_UNCHECKED);
 -					
 -					interval = db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL);
 -					//_itoa(interval, buffer, 10);
 -					//SetWindowText(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), buffer);
 -					SetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,interval,FALSE);
 -					CheckDlgButton(hWnd, IDC_USE_POPUPS, (BOOL) db_get_b(NULL, ModuleName, "UsePopups", 0) ? BST_CHECKED : BST_UNCHECKED);
 -					EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), ServiceExists(MS_POPUP_ADDPOPUP)); //disable the popups checkbox if no popup module is present
 -					
 -					CheckDlgButton(hWnd, IDC_CHECK_EMAILS, (bCheck) ? BST_CHECKED : BST_UNCHECKED);
 -					EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), bCheck);
 -					
 -					portCheck = (BOOL) db_get_b(NULL, ModuleName, "UsePortCheck", 1);
 -					CheckDlgButton(hWnd, IDC_USE_PORTCHECK, (portCheck) ? BST_CHECKED : BST_UNCHECKED);
 -					EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
 -					
 -					//_itoa(db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES), buffer, 10);
 -					//SetWindowText(GetDlgItem(hWnd, IDC_MAX_RETRIES), buffer);
 -					retries=db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES);
 -					SetDlgItemInt(hWnd,IDC_MAX_RETRIES,retries,FALSE);
 -
 -					EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
 -
 -					bInitializing = 0;
 -					
 -					return TRUE;
 -				}
 -				
 -			case WM_COMMAND:
 -				{
 -					switch (LOWORD(wParam))
 -						{
 -							case IDC_USER_EDIT:
 -							case IDC_PASSWORD_EDIT:
 -							case IDC_SERVER_EDIT:
 -							case IDC_PORT_EDIT:
 -							case IDC_INTERVAL_EDIT:
 -							case IDC_RECONNECT_INTERVAL:
 -							case IDC_MAX_RETRIES:
 -								{
 -									if ((!bInitializing) && (HIWORD(wParam) == EN_CHANGE))// || (HIWORD(wParam) == CBN_SELENDOK))
 -										{
 -											SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
 -										}
 -										
 -									break;
 -								}
 -							case IDC_USE_POPUPS:
 -							case IDC_CHECK_EMAILS:
 -							case IDC_RECONNECT:
 -							case IDC_USE_PORTCHECK:
 -								{
 -									int portCheck = IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK);
 -									SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
 -									
 -									EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS));
 -									EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
 -									EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
 -									//EnableWindow(GetDlgItem(hWnd, IDC_MAX_RETRIES), portCheck);
 -									
 -									break;
 -								}
 -						}
 -						
 -					break;
 -				}
 -				
 -		case WM_NOTIFY:
 -			{
 -				switch(((LPNMHDR)lParam)->idFrom)
 -					{
 -						case 0:
 -							{
 -								switch (((LPNMHDR)lParam)->code)
 -									{
 -										case PSN_APPLY:
 -											{
 -												TCHAR buffer[4096];
 -												char apassword[1024];
 -												long port = 0;
 -												long interval = DEFAULT_INTERVAL;
 -												int bCheck = IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS);
 -												int retries = MAX_EXCHANGE_CONNECT_RETRIES;
 -												
 -												db_set_b(NULL, ModuleName, "Check", bCheck);
 -												GetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer, sizeof(buffer));
 -												db_set_ts(NULL, ModuleName, "Username", buffer);
 -												GetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer, sizeof(buffer));
 -												strcpy(apassword,mir_t2a(buffer));
 -
 -												CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(apassword), (LPARAM) apassword);
 -
 -												db_set_ts(NULL, ModuleName, "Password", mir_a2t(apassword));
 -
 -												GetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer, sizeof(buffer));
 -												db_set_ts(NULL, ModuleName, "Server", buffer);
 -												GetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer, sizeof(buffer));
 -												//port = atoi(buffer);
 -												//db_set_dw(NULL, ModuleName, "Port", port);
 -												db_set_dw(NULL, ModuleName, "Port", GetDlgItemInt(hWnd,IDC_PORT_EDIT,NULL,FALSE));
 -
 -												//GetWindowText(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), buffer, sizeof(buffer));
 -												//interval = atoi(buffer);
 -												interval=GetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,NULL,FALSE);
 -												db_set_dw(NULL, ModuleName, "Interval", interval);
 -												
 -												db_set_b(NULL, ModuleName, "Reconnect", IsDlgButtonChecked(hWnd, IDC_RECONNECT));
 -												
 -												GetWindowText(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), buffer, sizeof(buffer));
 -												//interval = atoi(buffer);
 -												interval=GetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,NULL,FALSE);
 -												db_set_dw(NULL, ModuleName, "ReconnectInterval", interval);
 -												
 -												db_set_b(NULL, ModuleName, "UsePopups", IsDlgButtonChecked(hWnd, IDC_USE_POPUPS));
 -												db_set_b(NULL, ModuleName, "UsePortCheck", IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK));
 -												
 -												//GetWindowText(GetDlgItem(hWnd, IDC_MAX_RETRIES), buffer, sizeof(buffer));
 -												//retries = atoi(buffer);
 -												retries=GetDlgItemInt(hWnd,IDC_MAX_RETRIES,NULL,FALSE);
 -												db_set_b(NULL, ModuleName, "MaxRetries", retries);
 -												
 -												
 -												exchangeServer.Reconnect(); //login info may be changed
 -												UpdateTimers(); //interval might get changed
 -												
 -												break;
 -											}
 -									}
 -									
 -								break;
 -							}
 -					}
 -					
 -				break;
 +			bInitializing = 1;
 +			DBVARIANT dbv = {0};
 +			dbv.type = DBVT_ASCIIZ;
 +
 +			int bCheck = db_get_b(NULL, ModuleName, "Check", 1);
 +
 +			TCHAR buffer[4096];
 +			GetStringFromDatabase("Username", _T(""), buffer, SIZEOF(buffer));
 +			SetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer);
 +
 +			GetStringFromDatabase("Password", _T(""), buffer, SIZEOF(buffer));
 +			SetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer);
 +
 +			GetStringFromDatabase("Server", _T(""), buffer, sizeof(buffer));
 +			SetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer);
 +
 +			SetDlgItemInt(hWnd, IDC_PORT_EDIT, db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT), FALSE);
 +
 +			SetDlgItemInt(hWnd, IDC_INTERVAL_EDIT, db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL), FALSE);
 +
 +			CheckDlgButton(hWnd, IDC_RECONNECT, (db_get_b(NULL, ModuleName, "Reconnect", 0)) ? BST_CHECKED : BST_UNCHECKED);
 +
 +			SetDlgItemInt(hWnd, IDC_RECONNECT_INTERVAL, db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL), FALSE);
 +			CheckDlgButton(hWnd, IDC_USE_POPUPS, (BOOL) db_get_b(NULL, ModuleName, "UsePopups", 0) ? BST_CHECKED : BST_UNCHECKED);
 +			EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), ServiceExists(MS_POPUP_ADDPOPUP)); //disable the popups checkbox if no popup module is present
 +
 +			CheckDlgButton(hWnd, IDC_CHECK_EMAILS, (bCheck) ? BST_CHECKED : BST_UNCHECKED);
 +			EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), bCheck);
 +
 +			int portCheck = db_get_b(NULL, ModuleName, "UsePortCheck", 1);
 +			CheckDlgButton(hWnd, IDC_USE_PORTCHECK, (portCheck) ? BST_CHECKED : BST_UNCHECKED);
 +			EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
 +
 +			int retries = db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES);
 +			SetDlgItemInt(hWnd,IDC_MAX_RETRIES,retries,FALSE);
 +
 +			EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
 +
 +			bInitializing = 0;
 +		}
 +		return TRUE;
 +
 +	case WM_COMMAND:
 +		switch (LOWORD(wParam)) {
 +		case IDC_USER_EDIT:
 +		case IDC_PASSWORD_EDIT:
 +		case IDC_SERVER_EDIT:
 +		case IDC_PORT_EDIT:
 +		case IDC_INTERVAL_EDIT:
 +		case IDC_RECONNECT_INTERVAL:
 +		case IDC_MAX_RETRIES:
 +			if ((!bInitializing) && (HIWORD(wParam) == EN_CHANGE))// || (HIWORD(wParam) == CBN_SELENDOK))
 +				SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
 +			break;
 +
 +		case IDC_USE_POPUPS:
 +		case IDC_CHECK_EMAILS:
 +		case IDC_RECONNECT:
 +		case IDC_USE_PORTCHECK:
 +			int portCheck = IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK);
 +			SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
 +
 +			EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS));
 +			EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
 +			EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
 +			break;
 +		}
 +		break;
 +
 +	case WM_NOTIFY:
 +		switch(((LPNMHDR)lParam)->idFrom) {
 +		case 0:
 +			switch (((LPNMHDR)lParam)->code) {
 +			case PSN_APPLY:
 +				db_set_b(NULL, ModuleName, "Check", IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS));
 +
 +				TCHAR buffer[4096];
 +				GetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer, SIZEOF(buffer));
 +				db_set_ts(NULL, ModuleName, "Username", buffer);
 +
 +				GetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer, SIZEOF(buffer));
 +				db_set_ts(NULL, ModuleName, "Password", buffer);
 +
 +				GetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer, SIZEOF(buffer));
 +				db_set_ts(NULL, ModuleName, "Server", buffer);
 +
 +				GetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer, SIZEOF(buffer));
 +				db_set_dw(NULL, ModuleName, "Port", GetDlgItemInt(hWnd,IDC_PORT_EDIT,NULL,FALSE));
 +
 +				db_set_dw(NULL, ModuleName, "Interval", GetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,NULL,FALSE));
 +				db_set_dw(NULL, ModuleName, "ReconnectInterval", GetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,NULL,FALSE));
 +
 +				db_set_b(NULL, ModuleName, "Reconnect", IsDlgButtonChecked(hWnd, IDC_RECONNECT));
 +
 +				db_set_b(NULL, ModuleName, "UsePopups", IsDlgButtonChecked(hWnd, IDC_USE_POPUPS));
 +				db_set_b(NULL, ModuleName, "UsePortCheck", IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK));
 +
 +				db_set_b(NULL, ModuleName, "MaxRetries", GetDlgItemInt(hWnd,IDC_MAX_RETRIES,NULL,FALSE));
 +
 +				exchangeServer.Reconnect(); //login info may be changed
 +				UpdateTimers(); //interval might get changed
  			}
 +		}
 +
 +		break;
  	}
 -	
 +
  	return 0;
  }
 @@ -219,276 +154,195 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW  int CALLBACK ListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch (msg)
 -		{
 -			case WM_KEYUP:
 -				{
 -					if (wParam == VK_ESCAPE)
 -						{
 -							SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
 -						}
 -						
 -					break;
 -				}
 -				
 -			case WM_SYSKEYDOWN:
 -				{
 -					if (wParam == 'X')
 -						{
 -							SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);						
 -						}
 -						
 -					break;
 -				}
 -				
 -			case WM_LBUTTONDBLCLK:
 -				{
 -					int count = ListView_GetItemCount(hWnd);
 -					for (int i = 0; i < count; i++)	
 -						{
 -							if (ListView_GetItemState(hWnd, i, LVIS_SELECTED))
 -								{
 -									TCHAR emailID[4096]; //uhh
 -									ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID));
 -									exchangeServer.OpenMessage(emailID);
 -								}
 -						}
 -						
 -					break;
 -				}
 +	switch (msg) {
 +	case WM_KEYUP:
 +		if (wParam == VK_ESCAPE)
 +			SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
 +
 +		break;
 +
 +	case WM_SYSKEYDOWN:
 +		if (wParam == 'X')
 +			SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);						
 +
 +		break;
 +
 +	case WM_LBUTTONDBLCLK:
 +		int count = ListView_GetItemCount(hWnd);
 +		for (int i = 0; i < count; i++) {
 +			if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) {
 +				TCHAR emailID[4096]; //uhh
 +				ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID));
 +				exchangeServer.OpenMessage(emailID);
 +			}
  		}
 -		
 +		break;
 +	}
 +
  	return CallWindowProc(OldListProc, hWnd, msg, wParam, lParam);
  }
  INT_PTR CALLBACK DlgProcEmails(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch (msg)
 +	switch (msg) {
 +	case WM_INITDIALOG:
 +		TranslateDialogDefault(hWnd);
  		{
 -			case WM_INITDIALOG:
 -				{
 -					TranslateDialogDefault(hWnd);
 -					
 -					SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hiMailIcon);
 -					
 -					LVCOLUMN col = {0};
 -					HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 -					OldListProc = (WNDPROC) SetWindowLong(hList, GWLP_WNDPROC, (LONG) ListSubclassProc);
 -					ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
 -					col.mask = LVCF_TEXT | LVCF_WIDTH;
 -					col.cx = 100;
 -					col.pszText = TranslateT("Entry ID");
 -					col.cchTextMax = _tcslen(col.pszText) + 1;
 -					ListView_InsertColumn(hList, 0, &col);
 -					col.pszText = TranslateT("Subject");
 -					col.cx = 300;
 -					col.cchTextMax = _tcslen(col.pszText) + 1;
 -					ListView_InsertColumn(hList, 0, &col);
 -					col.cx = 200;
 -					col.iSubItem = 1;
 -					col.pszText = TranslateT("Sender");
 -					col.cchTextMax = _tcslen(col.pszText) + 1;
 -					ListView_InsertColumn(hList, 0, &col);
 -					
 -					return TRUE;
 -				}
 -				
 -			case WM_DESTROY:
 -				{
 -					hEmailsDlg = NULL;
 -					
 -					break;
 -				}
 -				
 -			case WM_CLOSE:
 -				{
 -					//ShowWindow(hWnd, SW_HIDE);
 -					DestroyWindow(hWnd); //close the window - no need to keep it in memory
 -					//SavePosition(hWnd);
 -					
 -					break;
 -				}
 -			
 -			case EXM_UPDATE_EMAILS:
 -				{
 -					HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 -					ListView_DeleteAllItems(hList);
 -					int count = GetWindowLong(hWnd, GWLP_USERDATA);
 +			SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hiMailIcon);
 +
 +			LVCOLUMN col = {0};
 +			HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 +			OldListProc = (WNDPROC) SetWindowLong(hList, GWLP_WNDPROC, (LONG) ListSubclassProc);
 +			ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
 +			col.mask = LVCF_TEXT | LVCF_WIDTH;
 +			col.cx = 100;
 +			col.pszText = TranslateT("Entry ID");
 +			col.cchTextMax = (int)_tcslen(col.pszText) + 1;
 +			ListView_InsertColumn(hList, 0, &col);
 +			col.pszText = TranslateT("Subject");
 +			col.cx = 300;
 +			col.cchTextMax = (int)_tcslen(col.pszText) + 1;
 +			ListView_InsertColumn(hList, 0, &col);
 +			col.cx = 200;
 +			col.iSubItem = 1;
 +			col.pszText = TranslateT("Sender");
 +			col.cchTextMax = (int)_tcslen(col.pszText) + 1;
 +			ListView_InsertColumn(hList, 0, &col);
 +		}
 +		return TRUE;
 +
 +	case WM_DESTROY:
 +		hEmailsDlg = NULL;
 +		break;
 +
 +	case WM_CLOSE:
 +		DestroyWindow(hWnd); //close the window - no need to keep it in memory
 +		break;
 +
 +	case EXM_UPDATE_EMAILS:
 +		{
 +			HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 +			ListView_DeleteAllItems(hList);
 +			int count = GetWindowLong(hWnd, GWLP_USERDATA);
 +			LVITEM item = {0};
 +			TEmailHeader email = {0};
 +			email.cbSize = sizeof(TEmailHeader);
 +			TCHAR sender[1024] = _T("");
 +			TCHAR subject[1024] = _T("");
 +			//char buffer[4096];
 +			email.cSender = sizeof(sender);
 +			email.cSubject = sizeof(subject);
 +			email.szSender = sender;
 +			email.szSubject = subject;
 +			item.mask = LVIF_TEXT;
 +
 +			for (int i = 0; i < count; i++)
 +			{
 +				exchangeServer.GetEmailHeader(i, &email);
 +				item.iItem = i;
 +				item.iSubItem = 0;
 +				item.pszText = email.szSender;
 +				ListView_InsertItem(hList, &item);
 +				ListView_SetItemText(hList, i, 1, email.szSubject);
 +				ListView_SetItemText(hList, i, 2, mir_a2t(email.emailID));
 +			}
 +			SetFocus(hList);
 +		}
 +		break;
 +
 +	case WM_SHOWWINDOW:
 +		if (wParam)
 +			SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
 +		break;
 +
 +	case WM_KEYUP:
 +		if (wParam == VK_ESCAPE)
 +			SendMessage(hWnd, WM_CLOSE, 0, 0);
 +		break;
 +
 +	case WM_SYSKEYDOWN:
 +		if (wParam == 'X')
 +			SendMessage(hWnd, WM_CLOSE, 0, 0);
 +		break;
 +
 +	case WM_WINDOWPOSCHANGING:
 +		{
 +			HDWP hdWnds = BeginDeferWindowPos(3);
 +			RECT rParent;
 +			WINDOWPOS *wndPos = (WINDOWPOS *) lParam;
 +
 +			if ((!wndPos) || (wndPos->flags & SWP_NOSIZE))
 +				break;
 +
 +			GetWindowRect(hWnd, &rParent);
 +			if (wndPos->cx < MIN_EMAILS_WIDTH)
 +				wndPos->cx = MIN_EMAILS_WIDTH;
 +			if (wndPos->cy < MIN_EMAILS_HEIGHT)
 +				wndPos->cy = MIN_EMAILS_HEIGHT;
 +
 +			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_EMAILS_LIST), &rParent, wndPos, ANCHOR_ALL);
 +			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_RIGHT);
 +			AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_MARK_READ), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_LEFT);
 +
 +			EndDeferWindowPos(hdWnds);
 +		}
 +		break;
 +
 +	case WM_COMMAND:
 +		switch (LOWORD(wParam)) {
 +		case IDC_CLOSE:
 +			SendMessage(hWnd, WM_CLOSE, 0, 0);
 +			break;
 +
 +		case IDC_MARK_READ:
 +			HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 +			int count = ListView_GetItemCount(hList);
 +			for (int i = 0; i < count; i++) {
 +				if (ListView_GetCheckState(hList, i)) {
 +					TCHAR emailID[2048]; //uhh ohh
  					LVITEM item = {0};
 -					TEmailHeader email = {0};
 -					email.cbSize = sizeof(TEmailHeader);
 -					TCHAR sender[1024] = _T("");
 -					TCHAR subject[1024] = _T("");
 -					//char buffer[4096];
 -					email.cSender = sizeof(sender);
 -					email.cSubject = sizeof(subject);
 -					email.szSender = sender;
 -					email.szSubject = subject;
 +					item.iItem = i;
  					item.mask = LVIF_TEXT;
 -					
 -					for (int i = 0; i < count; i++)
 -						{
 -							exchangeServer.GetEmailHeader(i, &email);
 -							item.iItem = i;
 -							item.iSubItem = 0;
 -							item.pszText = email.szSender;
 -							ListView_InsertItem(hList, &item);
 -							ListView_SetItemText(hList, i, 1, email.szSubject);
 -							ListView_SetItemText(hList, i, 2, mir_a2t(email.emailID));
 -						}
 -					SetFocus(hList);
 -					
 -					break;
 -				}
 -				
 -			case WM_SHOWWINDOW:
 -				{
 -					if (wParam)
 -						{
 -							SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
 -						}
 -						
 -					break;
 -				}
 -				
 -			case WM_KEYUP:
 -				{
 -					if (wParam == VK_ESCAPE)
 -						{
 -							SendMessage(hWnd, WM_CLOSE, 0, 0);
 -						}
 -						
 -					break;
 +					item.iSubItem = 2;
 +					item.cchTextMax = sizeof(emailID);
 +					item.pszText = emailID;
 +					ListView_GetItem(hList, &item);
 +					exchangeServer.MarkEmailAsRead(emailID);
  				}
 -				
 -			case WM_SYSKEYDOWN:
 -				{
 -					if (wParam == 'X')
 -						{
 -							SendMessage(hWnd, WM_CLOSE, 0, 0);
 -						}
 -						
 -					break;
 -				}
 -				
 -			case WM_WINDOWPOSCHANGING:
 -				{
 -					HDWP hdWnds = BeginDeferWindowPos(3);
 -					RECT rParent;
 -					WINDOWPOS *wndPos = (WINDOWPOS *) lParam;
 -					
 -					if ((!wndPos) || (wndPos->flags & SWP_NOSIZE))
 -						{
 -							break;
 -						}
 -					GetWindowRect(hWnd, &rParent);
 -					if (wndPos->cx < MIN_EMAILS_WIDTH)
 -						{
 -							wndPos->cx = MIN_EMAILS_WIDTH;
 -						}
 -					if (wndPos->cy < MIN_EMAILS_HEIGHT)
 -						{
 -							wndPos->cy = MIN_EMAILS_HEIGHT;
 -						}
 -					AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_EMAILS_LIST), &rParent, wndPos, ANCHOR_ALL);
 -					AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_RIGHT);
 -					AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_MARK_READ), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_LEFT);
 -					
 -					EndDeferWindowPos(hdWnds);
 -					
 -					break;
 -				}
 -				
 -			case WM_COMMAND:
 -				{
 -					switch (LOWORD(wParam))
 -						{
 -							case IDC_CLOSE:
 -								{
 -									SendMessage(hWnd, WM_CLOSE, 0, 0);
 -									//HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 -									//ListView_SetItemState(hList, -1, LVIS_SELECTED, LVIS_SELECTED);
 -									//SetFocus(hList);
 -									
 -									break;
 -								}
 -								
 -							case IDC_MARK_READ:
 -								{
 -									HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
 -									int count = ListView_GetItemCount(hList);
 -									for (int i = 0; i < count; i++)
 -										{
 -											if (ListView_GetCheckState(hList, i))
 -												{
 -													//char sender[1024]; //nooo
 -													TCHAR emailID[2048]; //uhh ohh
 -													LVITEM item = {0};
 -													item.iItem = i;
 -													item.mask = LVIF_TEXT;
 -													//item.pszText = sender;
 -													//item.cchTextMax = sizeof(sender);
 -													//ListView_GetItem(hList, &item);
 -													
 -													item.iSubItem = 2;
 -													item.cchTextMax = sizeof(emailID);
 -													item.pszText = emailID;
 -													ListView_GetItem(hList, &item);
 -													exchangeServer.MarkEmailAsRead(emailID);
 -												}
 -										}
 -									count = exchangeServer.GetUnreadEmailsCount();
 -									if (count > 0)
 -										{
 -											SetWindowLong(hWnd, GWLP_USERDATA, count);
 -											SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
 -										}
 -										else{
 -											SendMessage(hWnd, WM_CLOSE, 0, 0);
 -										}
 -										
 -									break;
 -								}
 -						}
 -						
 -					break;
 -				}
 -			default:
 -			
 -				break;
 +			}
 +			count = exchangeServer.GetUnreadEmailsCount();
 +			if (count > 0)
 +			{
 +				SetWindowLong(hWnd, GWLP_USERDATA, count);
 +				SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
 +			}
 +			else SendMessage(hWnd, WM_CLOSE, 0, 0);
  		}
 +		break;
 +	}
 +
  	return 0;
  }
  LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch (msg)
 -		{
 -			case WM_COMMAND:
 -				{
 -					switch (HIWORD(wParam))
 -						{
 -							case STN_CLICKED:
 -								{
 -									//HWND hParent = FindWindow(MIRANDACLASS, NULL);
 -									//CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), hParent, DlgProcEmails);
 -									int count = (int) PUGetPluginData(hWnd);
 -									ShowEmailsWindow(count);
 -									PUDeletePopup(hWnd);
 -									
 -									break;
 -								}
 -						}
 -						
 -					break;
 -				}
 -			case WM_CONTEXTMENU:
 -				{
 -					PUDeletePopup(hWnd);
 -					
 -					break;
 -				}
 +	switch (msg) {
 +	case WM_COMMAND:
 +		switch (HIWORD(wParam)) {
 +		case STN_CLICKED:
 +			{
 +				int count = (int) PUGetPluginData(hWnd);
 +				ShowEmailsWindow(count);
 +				PUDeletePopup(hWnd);
 +				break;
 +			}
  		}
 +		break;
 +
 +	case WM_CONTEXTMENU:
 +		PUDeletePopup(hWnd);
 +		break;
 +	}
  	return DefWindowProc(hWnd, msg, wParam, lParam);
  }
\ No newline at end of file diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp index 39dfa6d86a..25261a4ea2 100644 --- a/plugins/Exchange/src/emails.cpp +++ b/plugins/Exchange/src/emails.cpp @@ -35,60 +35,43 @@ CExchangeServer::~CExchangeServer()  int CExchangeServer::Connect(int bForceConnect)
  {
  	int maxRetries = db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES);
 -	if (bForceConnect)
 -	{
 +	if (bForceConnect) {
  		bTryConnect = 1;
  		cConnections = 0;
  	}
 -	if (cConnections >= maxRetries)
 -	{
 +	if (cConnections >= maxRetries) {
  		bTryConnect = 0;
  		cConnections = 0;
  		_popupUtil("Maximum number of retries reached.\nPlugin will stop trying to connect automatically.");
  	}
 +
  	if (bTryConnect)
 -	{
  		cConnections++;
 -	}
 -	if ((bTryConnect) && !IsServerAvailable())
 -	{
 +	if ((bTryConnect) && !IsServerAvailable()) {
  		bTryConnect = 0;
  		_popupUtil("Server not available");
  	}		
 -	if ((!IsConnected()) && (bTryConnect))
 -		{
 -			TCHAR user[1024]; //lovely
 -			TCHAR password[1024]; //i know
 -			char apassword[1024];
 -			TCHAR server[1024];
 -			int port;
 -			
 -			GetStringFromDatabase("Username", _T(""), user, _countof(user));
 -			if (ServiceExists(MS_UTILS_REPLACEVARS))
 -			{
 -				TCHAR *tmpUser = Utils_ReplaceVarsT(user);
 -				
 -				_tcsncpy(user, tmpUser, _countof(user));
 -				mir_free(tmpUser);
 -			}
 -			
 -			GetStringFromDatabase("Password", _T(""), password, _countof(password));
 -			strcpy(apassword,mir_t2a(password));
 -			CallService(MS_DB_CRYPT_DECODESTRING, sizeof(apassword), (LPARAM) apassword);
 -			_tcsncpy(password,mir_a2t(apassword),_countof(password));
 -			GetStringFromDatabase("Server", _T(""), server, _countof(server));
 -			port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
 -			if (_tcslen(server) > 0) //only connect if there's a server to connect to
 -			{
 -				return DoConnect(user, password, server, port);			
 -			}
 -			else {
 -				_popupUtil("Server is not configured...");
 -			}
 -		}
 +	if ( !IsConnected() && bTryConnect) {
 +		TCHAR user[1024]; //lovely
 +		TCHAR password[1024]; //i know
 +		TCHAR server[1024];
 +
 +		GetStringFromDatabase("Username", _T(""), user, _countof(user));
 +		if (ServiceExists(MS_UTILS_REPLACEVARS))
 +			_tcsncpy_s(user, _countof(user), VARST(user), _TRUNCATE);
 +
 +		GetStringFromDatabase("Password", _T(""), password, _countof(password));
 +		GetStringFromDatabase("Server", _T(""), server, _countof(server));
 +
 +		int port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
 +		if (_tcslen(server) > 0) //only connect if there's a server to connect to
 +			return DoConnect(user, password, server, port);			
 +
 +		_popupUtil("Server is not configured...");
 +	}
  	return -1; //0 on success, != 0 otherwise
  }
 @@ -151,44 +134,37 @@ void InitSocketAddr(sockaddr_in *addrServer, char *szServer)  	hp = gethostbyname(szServer);
  	addrServer->sin_family = AF_INET;
  	if (hp == NULL)
 -	{
  		addrServer->sin_addr.s_addr = inet_addr(szServer);
 -	}
 -	else{
 +	else
  		memcpy(&(addrServer->sin_addr), hp->h_addr, hp->h_length);		
 -	}
 +
  	int port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
  	addrServer->sin_port = htons(port);
  }
  int CExchangeServer::IsServerAvailable()
  {
 -	int check = db_get_b(NULL, ModuleName, "UsePortCheck", 1);
 -	if (check)
 -	{
 -		SOCKET sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
 -		if (sServer == INVALID_SOCKET)
 -		{
 -			return 0; //server is not available
 -		}
 -		TCHAR szServer[1024];
 -		GetStringFromDatabase("Server", _T(""), szServer, sizeof(szServer));
 -		sockaddr_in addrServer;
 -		InitSocketAddr(&addrServer, mir_t2a(szServer));
 -		int res = connect(sServer, (sockaddr *) &addrServer, sizeof(addrServer));
 -		int bAvailable = 0;
 -		if (!res)
 -		{//if connected then close smtp connection by sending a quit message
 -			bAvailable = 1;
 -			char message[] = "quit\n";
 -			res = send(sServer, message, strlen(message), 0); 
 -		}
 -		res = closesocket(sServer); //close the socket
 -		return bAvailable;
 -	}
 -	else{
 -		return 1; //if we're not using port check assume the server is available.
 +	if (!db_get_b(NULL, ModuleName, "UsePortCheck", 1))
 +		return 1;
 +
 +	SOCKET sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
 +	if (sServer == INVALID_SOCKET)
 +		return 0; //server is not available
 +
 +	TCHAR szServer[1024];
 +	GetStringFromDatabase("Server", _T(""), szServer, sizeof(szServer));
 +	sockaddr_in addrServer;
 +	InitSocketAddr(&addrServer, mir_t2a(szServer));
 +	int res = connect(sServer, (sockaddr *) &addrServer, sizeof(addrServer));
 +	int bAvailable = 0;
 +	if (!res) {
 +		// if connected then close smtp connection by sending a quit message
 +		bAvailable = 1;
 +		char message[] = "quit\n";
 +		send(sServer, message, strlen(message), 0); 
  	}
 +	res = closesocket(sServer); //close the socket
 +	return bAvailable;
  }
  int CExchangeServer::GetUnreadEmailsCount()
 @@ -220,42 +196,29 @@ int CExchangeServer::GetUnreadEmailsCount()  int CExchangeServer::GetEmailHeader(int iUnreadEmail, TEmailHeader *emailInfo)
  {
  	if (!IsConnected())
 -	{
 -		//Connect();
  		return -1;
 -	}
 +
  	if (emailInfo->cbSize != sizeof(TEmailHeader))
 -	{
  		return -1;
 -	}
  #ifndef NO_EXCHANGE_TEST
 -	if(NULL!=m_HeadersKeeper[iUnreadEmail])
 -	{
 +	if (NULL != m_HeadersKeeper[iUnreadEmail]) {
  		TCHAR* szSender  = m_HeadersKeeper[iUnreadEmail]->m_szSender;
  		TCHAR* szSubject = m_HeadersKeeper[iUnreadEmail]->m_szSubject;
 -		if( NULL == szSender)
 -		{
 +		if (NULL == szSender)
  			szSender = _T("");
 -		}
 -		if( NULL == szSubject)
 -		{
 +		if (NULL == szSubject)
  			szSubject = _T("");
 -		}
  		emailInfo->szSender  = szSender;
  		emailInfo->szSubject = szSubject;
  		emailInfo->emailID   = (NULL!=m_HeadersKeeper[iUnreadEmail]->m_szEntryID)?m_HeadersKeeper[iUnreadEmail]->m_szEntryID:"";
  	}
 -	else {
 -		return -1;
 -	}
 -
 -
 +	else return -1;
  #else
  	emailInfo->szSender = "<sender>";
  	emailInfo->szSubject = "<subject>";
 @@ -268,9 +231,7 @@ int CExchangeServer::GetEmailHeader(int iUnreadEmail, TEmailHeader *emailInfo)  int CExchangeServer::MarkEmailAsRead(TCHAR *emailID)
  {
  	if (!IsConnected())
 -	{
  		return -1;
 -	}
  #ifndef NO_EXCHANGE_TEST	
  	MarkAsRead( emailID );
 @@ -282,87 +243,50 @@ int CExchangeServer::MarkEmailAsRead(TCHAR *emailID)  int CExchangeServer::OpenMessage(TCHAR *emailID)
  {
  	if (!IsConnected())
 -	{
  		return -1;
 -	}
  #ifndef NO_EXCHANGE_TEST	
  	OpenTheMessage( emailID );
  #endif
 -
  	return 0;
  }
  int CExchangeServer::Check(int bNoEmailsNotify)
  {
 -
  	int count = -1;
 -	if (IsConnected())
 -	{
 -		count =	GetUnreadEmailsCount();
 -
 -		if (count==-1)
 -		{
 +	if (IsConnected()) {
 +		count = GetUnreadEmailsCount();
 +		if (count == -1) {
  			Reconnect();	
  			if (IsConnected())
 -			{	
  				count = GetUnreadEmailsCount();	
 -			}
 -			else {
 +			else
  				return -1;
 -			}
  		}
 -
  	}
  	else {	
  		Reconnect();
  		if (IsConnected())
 -		{	
  			count = GetUnreadEmailsCount();	
 -		}
 -		else {
 +		else
  			return -1;
 -		}
  		if (count==-1)
 -		{
  			return -1;
 -		}
  	}
 -	if( ( (count > 0) || ((bNoEmailsNotify) && (count >= 0)) )&& (count!=-1))
 -	{
 +	if (((count > 0) || ((bNoEmailsNotify) && (count >= 0))) && (count != -1)) {
  		TCHAR buffer[1024];
  		if (count != 1)
 -		{
  			mir_sntprintf(buffer,_countof(buffer), TranslateT("You have %d unread emails..."), count);
 -		}
 -		else {
 +		else
  			mir_sntprintf(buffer, _countof(buffer),TranslateT("You have one unread email..."));
 -		}
  		ShowMessage(buffer, count);
 -		/*int i;
 -				TEmailHeader emailInfo = {0};
 -				char sender[1024];
 -				char subject[1024];
 -				emailInfo.cbSize = sizeof(emailInfo);
 -				emailInfo.szSender = sender;
 -				emailInfo.szSubject = subject;
 -				emailInfo.cSender = sizeof(sender);
 -				emailInfo.cSubject = sizeof(subject);
 -				for (i = 0; i < count; i++)
 -					{
 -						GetEmailHeader(i, &emailInfo);
 -						sprintf(buffer, "Unread email #%d:\nSender :%s\nSubject :%s", i + 1, sender, subject);
 -						ShowMessage(buffer);
 -					}*/
  	}
  	if (count==-1)
 -	{
  		_popupUtil("Cannot connect to Exchange server...");
 -	}
  	return count;
  }
 @@ -371,14 +295,9 @@ int ShowMessage(TCHAR *message, int cUnreadEmails)  {
  	int usePopups = ServiceExists(MS_POPUP_ADDPOPUP) ? db_get_b(NULL, ModuleName, "UsePopups", 0) : 0;
  	if (usePopups)
 -	{
  		return ShowPopupMessage(TranslateT("Exchange email"), message, cUnreadEmails);
 -	}
 -	else{
 -		return ShowMessageBoxMessage(TranslateT("Do you want to see the email headers?"), message, cUnreadEmails);
 -	}
 -	
 -	return 0;
 +
 +	return ShowMessageBoxMessage(TranslateT("Do you want to see the email headers?"), message, cUnreadEmails);
  }
  int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails)
 @@ -398,30 +317,21 @@ int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails)  int ShowMessageBoxMessage(TCHAR *title, TCHAR *message, int cUnreadEmails)
  {
  	if (MessageBox(0, message, title, MB_YESNO) == IDYES)
 -	{
  		ShowEmailsWindow(cUnreadEmails);
 -	}
 -	
  	return 0;
  }
  int ShowEmailsWindow(int cUnreadEmails)
  {
 -	if (cUnreadEmails > 0) //show window only if there are unread emails
 -	{
 +	if (cUnreadEmails > 0) { //show window only if there are unread emails
  		if (!hEmailsDlg)
 -		{
  			hEmailsDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), NULL, DlgProcEmails);
 -		}
  		SetWindowLong(hEmailsDlg, GWLP_USERDATA, cUnreadEmails);
  		if (IsWindowVisible(hEmailsDlg))
 -		{
  			SendMessage(hEmailsDlg, EXM_UPDATE_EMAILS, 0, 0);
 -		}
 -		else {
 +		else
  			ShowWindow(hEmailsDlg, SW_SHOW);
 -		}
  	}
  	return 0;
 -}
\ No newline at end of file +}
 diff --git a/plugins/FTPFileYM/src/mir_db.cpp b/plugins/FTPFileYM/src/mir_db.cpp index 63e85cc056..13d1d645a7 100644 --- a/plugins/FTPFileYM/src/mir_db.cpp +++ b/plugins/FTPFileYM/src/mir_db.cpp @@ -53,14 +53,6 @@ int DB::setStringF(HANDLE hContact, char *szModule, char *szSetting, int id, TCH  	return db_set_ts(hContact, szModule, formSet, stzValue);
  }
 -int DB::setCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue)
 -{
 -	char buff[256];
 -	strcpy(buff, szValue);
 -	CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)sizeof(buff), (LPARAM)buff);
 -	return db_set_s(hContact, szModule, szSetting, buff);
 -}
 -
  int DB::getByteF(HANDLE hContact, char *szModule, char *szSetting, int id, int iErrorValue)
  {
  	char formSet[256];
 @@ -124,20 +116,6 @@ int DB::getStringF(HANDLE hContact, char *szModule, char *szSetting, int id, TCH  	return getString(hContact, szModule, formSet, buff);
  }
 -int DB::getCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue)
 -{
 -	char buff[256];
 -	if (!getAString(hContact, szModule, szSetting, buff))
 -	{
 -		CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)sizeof(buff), (LPARAM)buff);
 -		strcpy(szValue, buff);
 -		return 0;
 -	}
 -
 -	szValue[0] = 0;
 -	return 1;
 -}
 -
  int DB::deleteSettingF(HANDLE hContact, char *szModule, char *szSetting, int id)
  {
  	char formSet[256];
 diff --git a/plugins/FTPFileYM/src/mir_db.h b/plugins/FTPFileYM/src/mir_db.h index 84f81b82bb..d46b16fb06 100644 --- a/plugins/FTPFileYM/src/mir_db.h +++ b/plugins/FTPFileYM/src/mir_db.h @@ -40,8 +40,5 @@ public:  	static int getString(HANDLE hContact, char *szModule, char *szSetting, TCHAR *buff);
  	static int getStringF(HANDLE hContact, char *szModule, char *szSetting, int id, TCHAR *buff);
 -	static int setCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue);
 -	static int getCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue);
 -
  	static int deleteSettingF(HANDLE hContact, char *szModule, char *szSetting, int id);
  };
 diff --git a/plugins/FTPFileYM/src/serverlist.cpp b/plugins/FTPFileYM/src/serverlist.cpp index 79aea87d29..d199228675 100644 --- a/plugins/FTPFileYM/src/serverlist.cpp +++ b/plugins/FTPFileYM/src/serverlist.cpp @@ -46,7 +46,7 @@ void ServerList::saveToDb() const  	char buff[256];
  	mir_snprintf(buff, sizeof(buff), "Password%d", opt.selected);
 -	DB::setCryptedString(0, MODULE, buff, ftp->szPass);
 +	DB::setAStringF(0, MODULE, buff, opt.selected, ftp->szPass);
  	DB::setStringF(0, MODULE, "Name%d", opt.selected, ftp->stzName);
  	DB::setAStringF(0, MODULE, "Server%d", opt.selected, ftp->szServer);
 @@ -64,14 +64,10 @@ void ServerList::saveToDb() const  ServerList::FTP::FTP(int index)
  {
 -	char buff[256];
 -
  	if (DB::getStringF(0, MODULE, "Name%d", index, this->stzName))
  		mir_sntprintf(this->stzName, SIZEOF(this->stzName), TranslateT("FTP Server %d"), index + 1);
 -	mir_snprintf(buff, sizeof(buff), "Password%d", index);
 -	DB::getCryptedString(0, MODULE, buff, this->szPass);
 -
 +	DB::getAStringF(0, MODULE, "Password%d", index, this->szPass);
  	DB::getAStringF(0, MODULE, "Server%d", index, this->szServer);
  	DB::getAStringF(0, MODULE, "User%d", index, this->szUser);
  	DB::getAStringF(0, MODULE, "Url%d", index, this->szUrl);
 diff --git a/plugins/NewsAggregator/Src/Authentication.cpp b/plugins/NewsAggregator/Src/Authentication.cpp index 4503fc7ef9..ce45f95cff 100644 --- a/plugins/NewsAggregator/Src/Authentication.cpp +++ b/plugins/NewsAggregator/Src/Authentication.cpp @@ -29,10 +29,7 @@ void CreateAuthString(char *auth, HANDLE hContact, HWND hwndDlg)  			tlogin = mir_tstrdup(dbv.ptszVal);
  			db_free(&dbv);
  		}
 -		ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
 -		if (pwd)
 -			CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
 -		tpass = mir_a2t(pwd);
 +		tpass = db_get_tsa(hContact, MODULE, "Password");
  	}
  	else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
  		GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf));
 @@ -110,7 +107,6 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA  				else if (SelItem.hContact) {
  					db_set_b(SelItem.hContact, MODULE, "UseAuth", 1);
  					db_set_ts(SelItem.hContact, MODULE, "Login", username);
 -					CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
  					db_set_s(SelItem.hContact, MODULE, "Password", passw);
  				}
  				EndDialog(hwndDlg, IDOK);
 diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index bcc128ab46..db787541dd 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -74,7 +74,6 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA  					GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
  					db_set_ts(hContact, MODULE, "Login", str);
  					GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
  					db_set_s(hContact, MODULE, "Password", passw);
  				}
  				DeleteAllItems(hwndList);
 @@ -157,45 +156,44 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  			HANDLE hContact;
  			for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
 -				DBVARIANT dbNick = {0};
 -				if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
 +				ptrT dbNick( db_get_tsa(hContact, MODULE, "Nick"));
 +				if (dbNick == NULL)
  					continue;
 -				else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) {
 -					db_free(&dbNick);
 -					DBVARIANT dbURL = {0};
 -					if (db_get_ts(hContact, MODULE, "URL", &dbURL))
 -						continue;
 -					else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) {
 -						db_free(&dbURL);
 -						nSelItem->hContact = hContact;
 -						SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
 -						SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
 -						SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
 -						SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
 -						DBVARIANT dbMsg = {0};
 -						if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
 -							SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
 -							db_free(&dbMsg);
 -						}
 -						if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
 -							CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
 -							EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
 -							EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
 -							DBVARIANT dbLogin = {0};
 -							if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
 -								SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
 -								db_free(&dbLogin);
 -							}
 -							ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
 -							if (pwd)
 -								CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
 -							SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
 -						}
 -						break;
 +
 +				if (lstrcmp(dbNick, SelItem.nick) != 0)
 +					continue;
 +
 +				ptrT dbURL( db_get_tsa(hContact, MODULE, "URL"));
 +				if (dbURL == NULL)
 +					continue;
 +
 +				if (lstrcmp(dbURL, SelItem.url) != 0)
 +					continue;
 +
 +				nSelItem->hContact = hContact;
 +				SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
 +				SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
 +				SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
 +				SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
 +				
 +				DBVARIANT dbMsg = {0};
 +				if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
 +					SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
 +					db_free(&dbMsg);
 +				}
 +				if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
 +					CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
 +					EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
 +					EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
 +					DBVARIANT dbLogin = {0};
 +					if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
 +						SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
 +						db_free(&dbLogin);
  					}
 -					db_free(&dbURL);
 +					ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
 +					SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
  				}
 -				db_free(&dbNick);
 +				break;
  			}
  			WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact);
  			Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg");
 @@ -235,10 +233,11 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  				db_set_ts(SelItem->hContact, MODULE, "MsgFormat", str);
  				if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
  					db_set_b(SelItem->hContact, MODULE, "UseAuth", 1);
 +
  					GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
  					db_set_ts(SelItem->hContact, MODULE, "Login", str);
 +
  					GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
  					db_set_s(SelItem->hContact, MODULE, "Password", passw);
  				}
  				else
 @@ -353,9 +352,6 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP  					db_free(&dbv);
  				}
  				ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
 -
 -				if (pwd)
 -					CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
  			}
  		}
 @@ -394,10 +390,11 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP  				db_set_ts(hContact, MODULE, "MsgFormat", str);
  				if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
  					db_set_b(hContact, MODULE, "UseAuth", 1);
 +
  					GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
  					db_set_ts(hContact, MODULE, "Login", str);
 +
  					GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
  					db_set_s(hContact, MODULE, "Password", passw);
  				}
  				else
 diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index 4f92e5a34c..97f2f5f13f 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -45,7 +45,6 @@ LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSet  	size_t len = strlen(val)+64;
  	char *buf = (LPSTR)mir_alloc(len);
  	strncpy(buf,val,len); mir_free(val);
 -	CallService(MS_DB_CRYPT_DECODESTRING,(WPARAM)len,(LPARAM)buf);
  	return buf;
  }
 @@ -54,7 +53,6 @@ int myDBWriteStringEncode(HANDLE hContact,const char *szModule,const char *szSet  	int len = (int)strlen(val)+64;
  	char *buf = (LPSTR)alloca(len);
  	strncpy(buf,val,len);
 -	CallService(MS_DB_CRYPT_ENCODESTRING,(WPARAM)len,(LPARAM)buf);
  	int ret = db_set_s(hContact,szModule,szSetting,buf);
  	return ret;
  }
 diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index dc4797b7ce..1485484f3d 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -108,9 +108,6 @@ __forceinline int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hP  	return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam);
  }
 -LPSTR myDBGetStringDecode(HANDLE,const char *,const char *);
 -int myDBWriteStringEncode(HANDLE,const char *,const char *,const char *);
 -
  extern HANDLE hNetlibUser;
  void InitNetlib();
  void DeinitNetlib();
 diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp index 05220acf99..f9b5325e2f 100644 --- a/plugins/SecureIM/src/crypt_dll.cpp +++ b/plugins/SecureIM/src/crypt_dll.cpp @@ -1,6 +1,5 @@  #include "commonheaders.h"
 -
  // generate KeyA pair and return public key
  LPSTR InitKeyA(pUinKey ptr,int features)
  {
 @@ -11,8 +10,8 @@ LPSTR InitKeyA(pUinKey ptr,int features)  	char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK");
  	if (tmp) {
 -	    cpp_init_keyp(ptr->cntx,tmp);	// make pre-shared key from password
 -	    mir_free(tmp);
 +		cpp_init_keyp(ptr->cntx,tmp);	// make pre-shared key from password
 +		mir_free(tmp);
  	}
  	LPSTR pub_text = cpp_init_keya(ptr->cntx,features);	// calculate public and private key & fill KeyA
 @@ -24,8 +23,7 @@ LPSTR InitKeyA(pUinKey ptr,int features)  		else
  			keysig = (LPSTR)SIG_KEYA;
  	}
 -	else
 -	if (isProtoSmallPackets(ptr->hContact))
 +	else if (isProtoSmallPackets(ptr->hContact))
  		keysig = (LPSTR)SIG_KEY4;
  	else
  		keysig = (LPSTR)SIG_KEY3;
 @@ -65,8 +63,8 @@ int InitKeyB(pUinKey ptr,LPCSTR key)  // store KeyX into context
 -void InitKeyX(pUinKey ptr,BYTE *key) {
 -
 +void InitKeyX(pUinKey ptr,BYTE *key)
 +{
  	if (!ptr->cntx)
  		ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0);
 @@ -75,8 +73,8 @@ void InitKeyX(pUinKey ptr,BYTE *key) {  // calculate secret key
 -BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
 -
 +BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact)
 +{
  	int agr = cpp_calc_keyx(ptr->cntx);
  	if (agr) {
  		// do this only if key exchanged is ok
 @@ -105,8 +103,8 @@ BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {  // encrypt message
 -LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) {
 -
 +LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg)
 +{
  	LPSTR szSig = (LPSTR) (ptr->offlineKey?SIG_ENOF:SIG_ENON);
  	int slen = (int)strlen(szSig);
 @@ -121,30 +119,27 @@ LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) {  // encode message
 -LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) {
 -
 +LPSTR encodeMsg(pUinKey ptr, LPARAM lParam)
 +{
  	CCSDATA *pccsd = (CCSDATA *)lParam;
  	LPSTR szNewMsg = NULL;
  	LPSTR szOldMsg = (LPSTR) pccsd->lParam;
  	if (pccsd->wParam & PREF_UTF )
  		szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg));
 -	else
 -	if (pccsd->wParam & PREF_UNICODE )
 +	else if (pccsd->wParam & PREF_UNICODE )
  		szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1)));
  	else
  		szNewMsg = encrypt(ptr,cpp_encodeA(ptr->cntx,szOldMsg));
 -//	pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF);
  	pccsd->wParam &= ~PREF_UNICODE;
 -
  	return szNewMsg;
  }
  // decode message
 -LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
 -
 +LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg)
 +{
  	CCSDATA *pccsd = (CCSDATA *)lParam;
  	PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
 @@ -152,7 +147,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {  	LPSTR szOldMsg = (ppre->flags&PREF_UTF)?cpp_decodeU(ptr->cntx,szEncMsg):cpp_decode(ptr->cntx,szEncMsg);
  	if (szOldMsg == NULL) {
 -		ptr->decoded=false;
 +		ptr->decoded = false;
  		switch(cpp_get_error(ptr->cntx)) {
  		case CPP_ERROR_BAD_LEN:
  			szNewMsg = mir_strdup(Translate(sim102));
 @@ -160,10 +155,9 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {  		case CPP_ERROR_BAD_CRC:
  			szNewMsg = mir_strdup(Translate(sim103));
  			break;
 -		default: {
 +		default:
  			ptr->decoded=true;
 -    			szNewMsg = mir_strdup(Translate(sim101));
 -    		}
 +			szNewMsg = mir_strdup(Translate(sim101));
  			break;
  		}
  		ppre->flags &= ~(PREF_UNICODE|PREF_UTF);
 @@ -200,8 +194,8 @@ BOOL LoadKeyPGP(pUinKey ptr)  		db_free(&dbv);
  		return r;
  	}
 -	else if (mode == 1) {
 -		LPSTR key = myDBGetStringDecode(ptr->hContact,MODULENAME,"pgp");
 +	if (mode == 1) {
 +		LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"pgp");
  		if (key) {
  			pgp_set_key(ptr->cntx,key);
  			mir_free(key);
 @@ -211,15 +205,15 @@ BOOL LoadKeyPGP(pUinKey ptr)  	return 0;
  }
 -BOOL LoadKeyGPG(pUinKey ptr) {
 -
 +BOOL LoadKeyGPG(pUinKey ptr)
 +{
  	LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"gpg");
  	if (key) {
  		gpg_set_keyid(ptr->cntx,key);
  		mir_free(key);
 -	   	return 2;
 +		return 2;
  	}
 -   	return 0;
 +	return 0;
  }
  // EOF
 diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index a08f3c3035..63f191d663 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -180,13 +180,13 @@ int onModulesLoaded(WPARAM, LPARAM)  	if (bPGP) { //PGP
  		bPGPloaded = pgp_init();
  		bUseKeyrings = db_get_b(0,MODULENAME,"ukr",1);
 -		LPSTR priv = myDBGetStringDecode(0,MODULENAME,"pgpPrivKey");
 +		LPSTR priv = db_get_sa(0,MODULENAME,"pgpPrivKey");
  		if (priv) {
  			bPGPprivkey = true;
  			if (bPGPloaded)
  				pgp_set_priv_key(priv);
  			mir_free(priv);
 -		}// if (priv)
 +		}
  		if (bPGPloaded && bUseKeyrings) {
  			char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH];
  			PubRingPath[0]='\0'; SecRingPath[0]='\0';
 @@ -215,8 +215,8 @@ int onModulesLoaded(WPARAM, LPARAM)  					}
  				}
  			}
 -		}// if (bPGPloaded && bUseKeyrings)
 -	}// if (bPGP)
 +		}
 +	}
  	Sent_NetLog("gpg_init");
 diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp index 7e7d7aece5..432d0ccb4d 100644 --- a/plugins/SecureIM/src/options.cpp +++ b/plugins/SecureIM/src/options.cpp @@ -1319,7 +1319,7 @@ void ApplyPGPSettings(HWND hDlg)  	if (priv) {
  		bPGPprivkey = true;
  		pgp_set_priv_key(priv);
 -		myDBWriteStringEncode(0,MODULENAME,"pgpPrivKey",priv);
 +		db_set_s(0,MODULENAME,"pgpPrivKey",priv);
  		mir_free(priv);
  		db_unset(0,MODULENAME,"tpgpPrivKey");
  	}
 diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp index f9a22638c3..b8fba61f48 100644 --- a/plugins/SecureIM/src/svcs_menu.cpp +++ b/plugins/SecureIM/src/svcs_menu.cpp @@ -88,7 +88,7 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam)  				char *publ = LoadKeys(KeyPath,false);
  				if (publ) {
  					db_unset((HANDLE)wParam,MODULENAME,"pgp");
 -					myDBWriteStringEncode((HANDLE)wParam,MODULENAME,"pgp",publ);
 +					db_set_s((HANDLE)wParam,MODULENAME,"pgp",publ);
  					db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",1);
  					db_set_s((HANDLE)wParam,MODULENAME,"pgp_abbr","(binary)");
  					mir_free(publ);
 diff --git a/plugins/VersionInfo/src/dlgHandlers.cpp b/plugins/VersionInfo/src/dlgHandlers.cpp index 375506347d..8a36de678c 100644 --- a/plugins/VersionInfo/src/dlgHandlers.cpp +++ b/plugins/VersionInfo/src/dlgHandlers.cpp @@ -299,7 +299,6 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)  			SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer);
  			GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer));
 -			CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer);
  			SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer);
  		}
 diff --git a/plugins/Watrack/lastfm/i_last_opt.inc b/plugins/Watrack/lastfm/i_last_opt.inc index f18b590a87..a8fb4457af 100644 --- a/plugins/Watrack/lastfm/i_last_opt.inc +++ b/plugins/Watrack/lastfm/i_last_opt.inc @@ -10,12 +10,7 @@ procedure SaveOpt;  var
    tmppass:array [0..255] of AnsiChar;
  begin
 -  if lfm_password<>nil then
 -  begin
 -    StrCopy(tmppass,lfm_password);
 -    CallService(MS_DB_CRYPT_ENCODESTRING,StrLen(tmppass)+1,lparam(@tmppass));
 -  end;
 -  DBWriteString(0,PluginShort,optPassword,tmppass);
 +  DBWriteString(0,PluginShort,optPassword,lfm_password);
    DBWriteString(0,PluginShort,optLogin   ,lfm_login);
    DBWriteByte  (0,PluginShort,optTries   ,lfm_tries);
    DBWriteByte  (0,PluginShort,optScrobble,lfm_on and 1);
 @@ -29,8 +24,6 @@ begin    lfm_on   :=DBReadByte(0,PluginShort,optScrobble,0);
    mFreeMem(lfm_login   ); lfm_login   :=DBReadString(0,PluginShort,optLogin);
    mFreeMem(lfm_password); lfm_password:=DBReadString(0,PluginShort,optPassword);
 -  if lfm_password<>nil then
 -    CallService(MS_DB_CRYPT_DECODESTRING,StrLen(lfm_password)+1,lparam(lfm_password));
    if (lfm_login=nil) or (lfm_password=nil) then
      CallService(MS_POPUP_SHOWMESSAGEW,
        wparam(TranslateW('Don''t forget to enter Login and Password to use Last.fm service')),
 diff --git a/plugins/Watrack/myshows/i_myshows_opt.inc b/plugins/Watrack/myshows/i_myshows_opt.inc index f3287aba05..f136c4c658 100644 --- a/plugins/Watrack/myshows/i_myshows_opt.inc +++ b/plugins/Watrack/myshows/i_myshows_opt.inc @@ -11,16 +11,10 @@ procedure SaveOpt;  var
    tmppass:array [0..255] of AnsiChar;
  begin
 -  if msh_password<>nil then
 -  begin
 -    StrCopy(tmppass,msh_password);
 -    CallService(MS_DB_CRYPT_ENCODESTRING,StrLen(tmppass)+1,LPARAM(@tmppass));
 -  end;
 -  DBWriteString(0,PluginShort,optPassword,tmppass);
 +  DBWriteString(0,PluginShort,optPassword,msh_password);
    DBWriteString(0,PluginShort,optLogin   ,msh_login);
    DBWriteByte  (0,PluginShort,optTries   ,msh_tries);
    DBWriteByte  (0,PluginShort,optScrobPos,msh_scrobpos);
 -//  DBWriteWord  (0,PluginShort,optTries   ,msh_timeout);
    DBWriteByte  (0,PluginShort,optScrobble,msh_on and 1);
  end;
 @@ -32,8 +26,6 @@ begin    msh_on      :=DBReadByte(0,PluginShort,optScrobble,0);
    mFreeMem(msh_login   ); msh_login   :=DBReadString(0,PluginShort,optLogin);
    mFreeMem(msh_password); msh_password:=DBReadString(0,PluginShort,optPassword);
 -  if msh_password<>nil then
 -    CallService(MS_DB_CRYPT_DECODESTRING,StrLen(msh_password)+1,LPARAM(msh_password));
    if (msh_login=nil) or (msh_password=nil) then
      CallService(MS_POPUP_SHOWMESSAGEW,
        WPARAM(TranslateW('Don''t forget to enter Login and Password to use MyShows service')),
 diff --git a/protocols/AimOscar/src/connection.cpp b/protocols/AimOscar/src/connection.cpp index fcff93ef09..d9acb8d542 100644 --- a/protocols/AimOscar/src/connection.cpp +++ b/protocols/AimOscar/src/connection.cpp @@ -61,22 +61,14 @@ HANDLE CAimProto::aim_peer_connect(unsigned long ip, unsigned short port)  void CAimProto::aim_connection_authorization(void)
  {
 -	DBVARIANT dbv;
 -	char *password = NULL;
 -
  	NETLIBPACKETRECVER packetRecv = {0};
  	HANDLE hServerPacketRecver = NULL;
  	if (m_iDesiredStatus == ID_STATUS_OFFLINE)
  		goto exit;
 -	if (!getString(AIM_KEY_PW, &dbv))
 -	{
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 -		password = mir_strdup(dbv.pszVal);
 -		db_free(&dbv);
 -	}
 -	else
 +	char *password = getStringA(AIM_KEY_PW);
 +	if (password == NULL)
  		goto exit;
  	mir_free(username);
 @@ -87,44 +79,37 @@ void CAimProto::aim_connection_authorization(void)  	hServerPacketRecver = (HANDLE)CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM)hServerConn, 2048 * 4);
  	packetRecv.cbSize = sizeof(packetRecv);
  	packetRecv.dwTimeout = 5000;
 -	for (;;)
 -	{
 +	for (;;) {
  		int recvResult = CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM) hServerPacketRecver, (LPARAM) & packetRecv);
 -		if (recvResult == 0)
 -		{
 +		if (recvResult == 0) {
  			debugLogA("Connection Closed: No Error? during Connection Authorization");
  			break;
  		}
 -		else if (recvResult < 0)
 -		{
 +		else if (recvResult < 0) {
  			debugLogA("Connection Closed: Socket Error during Connection Authorization %d", WSAGetLastError());
  			break;
  		}
 -		else
 -		{
 +		else {
  			unsigned short flap_length=0;
 -			for (;packetRecv.bytesUsed<packetRecv.bytesAvailable;packetRecv.bytesUsed=flap_length)
 -			{
 +			for (;packetRecv.bytesUsed<packetRecv.bytesAvailable;packetRecv.bytesUsed = flap_length) {
  				if (!packetRecv.buffer)
  					break;
 +
  				FLAP flap((char*)&packetRecv.buffer[packetRecv.bytesUsed],(unsigned short)(packetRecv.bytesAvailable-packetRecv.bytesUsed));
  				if (!flap.len())
  					break;
 +
  				flap_length+=FLAP_SIZE+flap.len();
 -				if (flap.cmp(0x01))
 -				{
 +				if (flap.cmp(0x01)) {
  					if (aim_send_connection_packet(hServerConn, seqno,flap.val())==0)//cookie challenge
  						aim_authkey_request(hServerConn, seqno);//md5 authkey request
  				}
 -				else if (flap.cmp(0x02))
 -				{
 +				else if (flap.cmp(0x02)) {
  					SNAC snac(flap.val(),flap.snaclen());
 -					if (snac.cmp(0x0017))
 -					{
 +					if (snac.cmp(0x0017)) {
  						snac_md5_authkey(snac,hServerConn,seqno, username, password);
  						int authres = snac_authorization_reply(snac);
 -						switch (authres)
 -						{
 +						switch (authres) {
  						case 1:
  							mir_free(password);
  							Netlib_CloseHandle(hServerPacketRecver);
 @@ -141,8 +126,7 @@ void CAimProto::aim_connection_authorization(void)  						}
  					}
  				}
 -				else if (flap.cmp(0x04))
 -				{
 +				else if (flap.cmp(0x04)) {
  					debugLogA("Connection Authorization Thread Ending: Flap 0x04");
  					goto exit;
  				}
 diff --git a/protocols/AimOscar/src/ui.cpp b/protocols/AimOscar/src/ui.cpp index ea80e9be76..acbdfc7557 100644 --- a/protocols/AimOscar/src/ui.cpp +++ b/protocols/AimOscar/src/ui.cpp @@ -779,8 +779,7 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP  {
  	CAimProto* ppro = (CAimProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 -	switch (msg)
 -	{
 +	switch (msg) {
  	case WM_INITDIALOG:
  		TranslateDialogDefault(hwndDlg);
 @@ -788,34 +787,27 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP  		ppro = (CAimProto*)lParam;
  		{
  			DBVARIANT dbv;
 -			if (!ppro->getString(AIM_KEY_SN, &dbv))
 -			{
 +			if (!ppro->getString(AIM_KEY_SN, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_SN, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			if (!ppro->getString(AIM_KEY_NK, &dbv))
 -			{
 +			if (!ppro->getString(AIM_KEY_NK, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_NK, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			else if (!ppro->getString(AIM_KEY_SN, &dbv))
 -			{
 +			else if (!ppro->getString(AIM_KEY_SN, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_NK, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			if (!ppro->getString(AIM_KEY_PW, &dbv))
 -			{
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 +			if (!ppro->getString(AIM_KEY_PW, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_PW, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			if (!ppro->getString(AIM_KEY_HN, &dbv))
 -			{
 +			if (!ppro->getString(AIM_KEY_HN, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_HN, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			else
 -				SetDlgItemTextA(hwndDlg, IDC_HN, ppro->getByte(AIM_KEY_DSSL, 0) ? AIM_DEFAULT_SERVER_NS : AIM_DEFAULT_SERVER);
 +			else SetDlgItemTextA(hwndDlg, IDC_HN, ppro->getByte(AIM_KEY_DSSL, 0) ? AIM_DEFAULT_SERVER_NS : AIM_DEFAULT_SERVER);
  			SetDlgItemInt(hwndDlg, IDC_PN, ppro->get_default_port(), FALSE);
 @@ -892,11 +884,9 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP  				//PW
  				GetDlgItemTextA(hwndDlg, IDC_PW, str, sizeof(str));
  				if (str[0] != 0)
 -				{
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
  					ppro->setString(AIM_KEY_PW, str);
 -				}
 -				else ppro->delSetting(AIM_KEY_PW);
 +				else
 +					ppro->delSetting(AIM_KEY_PW);
  				//END PW
  				//HN
 @@ -1166,58 +1156,50 @@ int CAimProto::OnOptionsInit(WPARAM wParam,LPARAM lParam)  INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch (msg)
 -	{
 -	case WM_INITDIALOG:
 -		{
 -			TranslateDialogDefault(hwndDlg);
 +	CAimProto* ppro = (CAimProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 -			CAimProto* ppro = (CAimProto*)lParam;
 -			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
 +	switch (msg) {
 +	case WM_INITDIALOG:
 +		TranslateDialogDefault(hwndDlg);
 +		ppro = (CAimProto*)lParam;
 +		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
 +		{
  			DBVARIANT dbv;
 -			if (!ppro->getString(AIM_KEY_SN, &dbv))
 -			{
 +			if (!ppro->getString(AIM_KEY_SN, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_SN, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			if (!ppro->getString(AIM_KEY_PW, &dbv))
 -			{
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 +			if (!ppro->getString(AIM_KEY_PW, &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_PW, dbv.pszVal);
  				db_free(&dbv);
  			}
 -			return TRUE;
  		}
 +		return TRUE;
  	case WM_COMMAND:
 -		if (LOWORD(wParam) == IDC_NEWAIMACCOUNTLINK)
 -		{
 +		if (LOWORD(wParam) == IDC_NEWAIMACCOUNTLINK) {
  			CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.aim.com/redirects/inclient/register.adp");
  			return TRUE;
  		}
 -		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
 -		{
 -			switch(LOWORD(wParam))
 -			{
 -			case IDC_SN:			case IDC_PW:
 +		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
 +			switch(LOWORD(wParam)) {
 +			case IDC_SN:
 +			case IDC_PW:
  				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  			}
  		}
  		break;
  	case WM_NOTIFY:
 -		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
 -		{
 -			CAimProto* ppro = (CAimProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 -
 +		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
  			char str[128];
  			GetDlgItemTextA(hwndDlg, IDC_SN, str, sizeof(str));
  			ppro->setString(AIM_KEY_SN, str);
 +
  			GetDlgItemTextA(hwndDlg, IDC_PW, str, sizeof(str));
 -			CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
  			ppro->setString(AIM_KEY_PW, str);
  			return TRUE;
  		}
 @@ -1241,8 +1223,7 @@ INT_PTR CALLBACK instant_idle_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  {
  	CAimProto* ppro = (CAimProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 -	switch (msg)
 -	{
 +	switch (msg) {
  	case WM_INITDIALOG:
  		TranslateDialogDefault(hwndDlg);
 @@ -1257,6 +1238,7 @@ INT_PTR CALLBACK instant_idle_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  			SetDlgItemInt(hwndDlg, IDC_IIM, minutes,0);
  		}
  		break;
 +
  	case WM_CLOSE:
  		EndDialog(hwndDlg, 0);
  		break;
 @@ -1271,13 +1253,12 @@ INT_PTR CALLBACK instant_idle_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  			unsigned short minutes=(unsigned short)GetDlgItemInt(hwndDlg, IDC_IIM,0,0);
  			if (minutes > 59)
  				minutes = 59;
 +
  			ppro->setDword(AIM_KEY_IIT, hours*60+minutes);
 -			switch (LOWORD(wParam))
 -			{
 +			switch (LOWORD(wParam)) {
  			case IDOK:
  				//Instant Idle
 -				if (ppro->state==1)
 -				{
 +				if (ppro->state == 1) {
  					ppro->aim_set_idle(ppro->hServerConn,ppro->seqno,hours * 60 * 60 + minutes * 60);
  					ppro->instantidle=1;
  				}
 @@ -1304,8 +1285,7 @@ INT_PTR CALLBACK join_chat_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM  {
  	CAimProto* ppro = (CAimProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 -	switch (msg)
 -	{
 +	switch (msg) {
  	case WM_INITDIALOG:
  		TranslateDialogDefault(hwndDlg);
 @@ -1323,24 +1303,20 @@ INT_PTR CALLBACK join_chat_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM  		break;
  	case WM_COMMAND:
 -		{
 -			switch (LOWORD(wParam))
 -			{
 -			case IDOK:
 -				char room[128];
 -				GetDlgItemTextA(hwndDlg, IDC_ROOM, room, sizeof(room));
 -				if (ppro->state == 1 && room[0] != 0)
 -				{
 -					chatnav_param* par = new chatnav_param(room, 4);
 -					ppro->ForkThread(&CAimProto::chatnav_request_thread, par);
 -				}
 -				EndDialog(hwndDlg, IDOK);
 -				break;
 -
 -			case IDCANCEL:
 -				EndDialog(hwndDlg, IDCANCEL);
 -				break;
 +		switch (LOWORD(wParam)) {
 +		case IDOK:
 +			char room[128];
 +			GetDlgItemTextA(hwndDlg, IDC_ROOM, room, sizeof(room));
 +			if (ppro->state == 1 && room[0] != 0) {
 +				chatnav_param* par = new chatnav_param(room, 4);
 +				ppro->ForkThread(&CAimProto::chatnav_request_thread, par);
  			}
 +			EndDialog(hwndDlg, IDOK);
 +			break;
 +
 +		case IDCANCEL:
 +			EndDialog(hwndDlg, IDCANCEL);
 +			break;
  		}
  		break;
  	}
 diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index abfb0a607b..3b6a57e45e 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -148,12 +148,11 @@ bool FacebookProto::NegotiateConnection()  	}
  	ptrA password( getStringA(FACEBOOK_KEY_PASS));
 -	if (!password || !strlen(password)) {
 +	if (!password || !*password) {
  		NotifyEvent(m_tszUserName,TranslateT("Please enter a password."),NULL,FACEBOOK_EVENT_CLIENT);
  		return false;
  	}
 -	CallService(MS_DB_CRYPT_DECODESTRING, strlen(password) + 1, password);
  	password = mir_utf8encode(password);
  	// Refresh last time of feeds update
 diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 3df11ce99c..fbc388bf26 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -58,16 +58,15 @@ INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp  		if (!db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,&dbv))
  		{
 -			CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
 -				reinterpret_cast<LPARAM>(dbv.pszVal));
  			SetDlgItemTextA(hwnd,IDC_PW,dbv.pszVal);
  			db_free(&dbv);
  		}
 -		if (!proto->isOffline()) {
 +		if (!proto->isOffline())
 +		{
  			SendMessage(GetDlgItem(hwnd,IDC_UN),EM_SETREADONLY,1,0);
 -			SendMessage(GetDlgItem(hwnd,IDC_PW),EM_SETREADONLY,1,0); }
 -
 +			SendMessage(GetDlgItem(hwnd,IDC_PW),EM_SETREADONLY,1,0);
 +		}
  		return TRUE;
  	case WM_COMMAND:
 @@ -97,9 +96,7 @@ INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp  			db_set_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,str);
  			GetDlgItemTextA(hwnd,IDC_PW,str,sizeof(str));
 -			CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast<LPARAM>(str));
  			db_set_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,str);
 -
  			return TRUE;
  		}
  		break;
 @@ -356,7 +353,6 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp  		if (!db_get_s(0,proto->ModuleName(),FACEBOOK_KEY_PASS,&dbv))
  		{
 -			CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,reinterpret_cast<LPARAM>(dbv.pszVal));
  			SetDlgItemTextA(hwnd,IDC_PW,dbv.pszVal);
  			db_free(&dbv);
  		}
 @@ -409,7 +405,6 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp  			db_set_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,str);
  			GetDlgItemTextA(hwnd,IDC_PW,str,sizeof(str));
 -			CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast<LPARAM>(str));
  			proto->setString(FACEBOOK_KEY_PASS, str);
  			GetDlgItemText(hwnd,IDC_GROUP,tstr,sizeof(tstr));
 diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index f8e44b03f8..074c2128ba 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -284,45 +284,37 @@ void __cdecl GGPROTO::mainthread(void *)  	// Setup proxy
  	nlus.cbSize = sizeof(nlus);
 -	if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus))
 -	{
 +	if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus)) {
  		if (nlus.useProxy)
  			debugLogA("mainthread() (%x): Using proxy %s:%d.", this, nlus.szProxyServer, nlus.wProxyPort);
  		gg_proxy_enabled = nlus.useProxy;
  		gg_proxy_host = nlus.szProxyServer;
  		gg_proxy_port = nlus.wProxyPort;
 -		if (nlus.useProxyAuth)
 -		{
 +		if (nlus.useProxyAuth) {
  			gg_proxy_username = nlus.szProxyAuthUser;
  			gg_proxy_password = nlus.szProxyAuthPassword;
  		}
  		else gg_proxy_username = gg_proxy_password = NULL;
  	}
 -	else
 -	{
 +	else {
  		debugLogA("mainthread() (%x): Failed loading proxy settings.", this);
  		gg_proxy_enabled = 0;
  	}
  	// Check out manual host setting
 -	if (getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST))
 -	{
 -		if (!getString(GG_KEY_SERVERHOSTS, &dbv))
 -		{
 +	if (getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST)) {
 +		if (!getString(GG_KEY_SERVERHOSTS, &dbv)) {
  			hostcount = gg_decodehosts(dbv.pszVal, hosts, 64);
  			db_free(&dbv);
  		}
  	}
  	// Readup password
 -	if (!getString(GG_KEY_PASSWORD, &dbv))
 -	{
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 +	if (!getString(GG_KEY_PASSWORD, &dbv)) {
  		p.password = mir_strdup(dbv.pszVal);
  		db_free(&dbv);
  	}
 -	else
 -	{
 +	else {
  		debugLogA("mainthread() (%x): No password specified. Exiting.", this);
  		broadcastnewstatus(ID_STATUS_OFFLINE);
  #ifdef DEBUGMODE
 @@ -332,8 +324,7 @@ void __cdecl GGPROTO::mainthread(void *)  	}
  	// Readup number
 -	if (!(p.uin = getDword(GG_KEY_UIN, 0)))
 -	{
 +	if (!(p.uin = getDword(GG_KEY_UIN, 0))) {
  		debugLogA("mainthread() (%x): No Gadu-Gadu number specified. Exiting.", this);
  		broadcastnewstatus(ID_STATUS_OFFLINE);
  		mir_free(p.password);
 @@ -352,8 +343,7 @@ void __cdecl GGPROTO::mainthread(void *)  	////////////////////////////// DCC STARTUP /////////////////////////////
  	// Uin is ok so startup dcc if not started already
 -	if (!dcc)
 -	{
 +	if (!dcc) {
  		hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  		dccstart();
 @@ -364,13 +354,11 @@ void __cdecl GGPROTO::mainthread(void *)  		while (WaitForSingleObjectEx(hEvent, INFINITE, TRUE) != WAIT_OBJECT_0);
  		CloseHandle(hEvent); hEvent = NULL;
  	}
 +
  	// Check if dcc is running and setup forwarding port
 -	if (dcc && getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING))
 -	{
 -		if (!getString(GG_KEY_FORWARDHOST, &dbv))
 -		{
 -			if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal)))
 -			{
 +	if (dcc && getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING)) {
 +		if (!getString(GG_KEY_FORWARDHOST, &dbv)) {
 +			if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal))) {
  				TCHAR error[128];
  				TCHAR* forwardHostT = mir_a2t(dbv.pszVal);
  				mir_sntprintf(error, SIZEOF(error), TranslateT("External direct connections hostname %s is invalid. Disabling external host forwarding."), forwardHostT);
 diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index eb47f96fab..2e9093015c 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -252,7 +252,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,  				ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_HIDE);
  			}
  			if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -414,7 +413,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,  					// Update password
  					if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
 -						CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
  						SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
  						db_free(&dbv);
  					}
 @@ -462,7 +460,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,  			GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str));
  			uin = atoi(str);
  			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str));
 -			CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
  			gg->checknewuser(uin, str);
  			gg->setDword(GG_KEY_UIN, uin);
  			gg->setString(GG_KEY_PASSWORD, str);
 @@ -957,7 +954,6 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP  			if (num = gg->getDword(GG_KEY_UIN, 0))
  				SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
  			if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -1000,7 +996,6 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP  					// Update password
  					if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
 -						CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
  						SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
  						db_free(&dbv);
  					}
 @@ -1030,7 +1025,6 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP  					GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str));
  					uin = atoi(str);
  					GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
  					gg->checknewuser(uin, str);
  					gg->setDword(GG_KEY_UIN, uin);
  					gg->setString(GG_KEY_PASSWORD, str);
 diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index 7c28acd9df..12233c226c 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -253,10 +253,6 @@ void GGPROTO::parsecontacts(char *contacts)  INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam)
  {
 -	char *password;
 -	uin_t uin;
 -	DBVARIANT dbv;
 -
  	// Check if connected
  	if (!isonline())
  	{
 @@ -268,14 +264,11 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam)  	}
  	// Readup password
 -	if (!getString(GG_KEY_PASSWORD, &dbv))
 -	{
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 -		password = _strdup(dbv.pszVal);
 -		db_free(&dbv);
 -	}
 -	else return 0;
 +	char *password = getStringA(GG_KEY_PASSWORD);
 +	if (password == NULL)
 +		return 0;
 +	uin_t uin;
  	if (!(uin = getDword(GG_KEY_UIN, 0)))
  		return 0;
 @@ -300,13 +293,8 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam)  INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam)
  {
 -	char *password;
 -	uin_t uin;
 -	DBVARIANT dbv;
 -
  	// Check if connected
 -	if (!isonline())
 -	{
 +	if (!isonline()) {
  		MessageBox(NULL,
  			TranslateT("You have to be connected before you can import/export contacts from/to server."),
  			m_tszUserName, MB_OK | MB_ICONSTOP
 @@ -315,14 +303,11 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam)  	}
  	// Readup password
 -	if (!getString(GG_KEY_PASSWORD, &dbv))
 -	{
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 -		password = _strdup(dbv.pszVal);
 -		db_free(&dbv);
 -	}
 -	else return 0;
 +	char *password = getStringA(GG_KEY_PASSWORD);
 +	if (password == NULL)
 +		return 0;
 +	uin_t uin;
  	if (!(uin = getDword(GG_KEY_UIN, 0)))
  		return 0;
 @@ -491,14 +476,10 @@ INT_PTR GGPROTO::export_server(WPARAM wParam, LPARAM lParam)  	}
  	// Readup password
 -	DBVARIANT dbv;
 -	if (getString(GG_KEY_PASSWORD, &dbv))
 +	char *password = getStringA(GG_KEY_PASSWORD);
 +	if (password == NULL)
  		return 0;
 -	CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 -	char *password = _strdup(dbv.pszVal);
 -	db_free(&dbv);
 -
  	uin_t uin = getDword(GG_KEY_UIN, 0);
  	if (!uin)
  		return 0;
 diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index db2a8220f9..4b6f07e295 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -295,28 +295,18 @@ char* GGPROTO::oauth_header(const char *httpmethod, const char *url)  	UIN2IDA( getDword(GG_KEY_UIN, 0), uin);
  	ptrA token( getStringA(GG_KEY_TOKEN));
  	ptrA password( getStringA(GG_KEY_PASSWORD));
 -	if (password != NULL)
 -		CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(password) + 1, (LPARAM)password);
  	ptrA token_secret( getStringA(GG_KEY_TOKENSECRET));
 -	if (token_secret != NULL)
 -		CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(token_secret) + 1, (LPARAM)token_secret);
 -
  	return oauth_auth_header(httpmethod, url, HMACSHA1, uin, password, token, token_secret);
  }
  int GGPROTO::oauth_receivetoken()
  {
 -	char szUrl[256], uin[32], *password = NULL, *str, *token = NULL, *token_secret = NULL;
 -	DBVARIANT dbv;
 +	char szUrl[256], uin[32], *str, *token = NULL, *token_secret = NULL;
  	int res = 0;
  	HANDLE nlc = NULL;
  	UIN2IDA( getDword(GG_KEY_UIN, 0), uin);
 -	if (!getString(GG_KEY_PASSWORD, &dbv)) {
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
 -		password = mir_strdup(dbv.pszVal);
 -		db_free(&dbv);
 -	}
 +	char *password = getStringA(GG_KEY_PASSWORD);
  	// 1. Obtaining an Unauthorized Request Token
  	debugLogA("oauth_receivetoken(): Obtaining an Unauthorized Request Token...");
 @@ -435,7 +425,6 @@ int GGPROTO::oauth_receivetoken()  	if (token != NULL && token_secret != NULL) {
  		setString(GG_KEY_TOKEN, token);
 -		CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)(int)strlen(token_secret) + 1, (LPARAM) token_secret);
  		setString(GG_KEY_TOKENSECRET, token_secret);
  		debugLogA("oauth_receivetoken(): Access Token obtained successfully.");
  		res = 1;
 diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index b33dcd33bc..d7b4643de8 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -38,8 +38,7 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail)  	// Load token
  	if (!gg->gettoken(&token)) return NULL;
 -	if (!(h = gg_register3(newEmail, newPass, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success || !s->uin)
 -	{
 +	if (!(h = gg_register3(newEmail, newPass, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success || !s->uin) {
  		TCHAR error[128];
  		mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot register new account because of error:\n\t%s"),
  			(h && !s) ? http_error_string(h ? h->error : 0) :
 @@ -47,10 +46,8 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail)  		MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
  		gg->debugLogA("gg_doregister(): Cannot register. errno=%d: %s", errno, strerror(errno));
  	}
 -	else
 -	{
 +	else {
  		gg->setDword(GG_KEY_UIN, s->uin);
 -		CallService(MS_DB_CRYPT_ENCODESTRING, strlen(newPass) + 1, (LPARAM) newPass);
  		gg->checknewuser(s->uin, newPass);
  		gg->setString(GG_KEY_PASSWORD, newPass);
  		gg->setString(GG_KEY_EMAIL, newEmail);
 @@ -149,7 +146,6 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass)  	else
  	{
  		gg_pubdir_free(h);
 -		CallService(MS_DB_CRYPT_ENCODESTRING, strlen(newPass) + 1, (LPARAM) newPass);
  		gg->setString(GG_KEY_PASSWORD, newPass);
  		gg->debugLogA("gg_dochpass(): Password change succesful.");
  		MessageBox(NULL, TranslateT("Your password has been changed."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
 diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp index ea5e4e116c..31a2a2be9a 100644 --- a/protocols/IRCG/src/options.cpp +++ b/protocols/IRCG/src/options.cpp @@ -719,7 +719,6 @@ void CConnectPrefsDlg::OnApply()  		m_port.GetTextA( m_proto->m_portStart, SIZEOF(m_proto->m_portStart));
  		m_port2.GetTextA( m_proto->m_portEnd, SIZEOF(m_proto->m_portEnd));
  		m_pass.GetTextA( m_proto->m_password, SIZEOF(m_proto->m_password));
 -		CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(m_proto->m_password), (LPARAM)m_proto->m_password);
  	}
  	else m_proto->m_serverName[0] = m_proto->m_portStart[0] = m_proto->m_portEnd[0] = m_proto->m_password[0] = 0;
 @@ -812,8 +811,6 @@ void CConnectPrefsDlg::OnApply()  	}	}	}
  	m_proto->WriteSettings( ConnectSettings, SIZEOF( ConnectSettings ));
 -
 -	CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(m_proto->m_password), (LPARAM)m_proto->m_password);
  }
  /////////////////////////////////////////////////////////////////////////////////////////
 @@ -1713,8 +1710,6 @@ void CIrcProto::InitPrefs(void)  	ReadSettings(OtherSettings, SIZEOF( OtherSettings ));
  	ReadSettings(IgnoreSettings, SIZEOF( IgnoreSettings ));
 -	CallService(MS_DB_CRYPT_DECODESTRING, 499, (LPARAM)m_password);
 -
  	int x = getDword( "SizeOfListBottom", -1 );
  	if ( x != -1 ) {
  		db_unset( NULL, m_szModuleName, "SizeOfListBottom" );
 @@ -1816,7 +1811,6 @@ struct CDlgAccMgrUI : public CProtoDlgBase<CIrcProto>  		m_port.GetTextA( m_proto->m_portStart, SIZEOF(m_proto->m_portStart));
  		m_port2.GetTextA( m_proto->m_portEnd, SIZEOF(m_proto->m_portEnd));
  		m_pass.GetTextA( m_proto->m_password, SIZEOF(m_proto->m_password));
 -		CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(m_proto->m_password), (LPARAM)m_proto->m_password);
  		m_nick.GetText( m_proto->m_nick, SIZEOF(m_proto->m_nick));
  		removeSpaces(m_proto->m_nick);
 @@ -1827,7 +1821,6 @@ struct CDlgAccMgrUI : public CProtoDlgBase<CIrcProto>  		removeSpaces(m_proto->m_userID);
  		m_name.GetText( m_proto->m_name, SIZEOF(m_proto->m_name));
  		m_proto->WriteSettings( ConnectSettings, SIZEOF( ConnectSettings ));
 -		CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(m_proto->m_password), (LPARAM)m_proto->m_password);
  	}
  	void OnChangeCombo( CCtrlCombo* )
 diff --git a/protocols/IRCG/src/windows.cpp b/protocols/IRCG/src/windows.cpp index d4dc453e07..f67e3345fd 100644 --- a/protocols/IRCG/src/windows.cpp +++ b/protocols/IRCG/src/windows.cpp @@ -644,9 +644,7 @@ void CQuickDlg::OnOk( CCtrlButton* )  		m_proto->setString("ServerName",m_proto->m_serverName);
  		m_proto->setString("PortStart",m_proto->m_portStart);
  		m_proto->setString("PortEnd",m_proto->m_portEnd);
 -		CallService(MS_DB_CRYPT_ENCODESTRING, 499, (LPARAM)m_proto->m_password);
  		m_proto->setString("Password",m_proto->m_password);
 -		CallService(MS_DB_CRYPT_DECODESTRING, 499, (LPARAM)m_proto->m_password);
  		m_proto->setString("Network",m_proto->m_network);
  		m_proto->setByte("UseSSL",m_proto->m_iSSL);
  	}
 diff --git a/protocols/IcqOscarJ/src/changeinfo/upload.cpp b/protocols/IcqOscarJ/src/changeinfo/upload.cpp index 8e562b80f0..b619f099e2 100644 --- a/protocols/IcqOscarJ/src/changeinfo/upload.cpp +++ b/protocols/IcqOscarJ/src/changeinfo/upload.cpp @@ -36,7 +36,8 @@ int CIcqProto::StringToListItemId(const char *szSetting,int def)  		if (!strcmpnull(szSetting,setting[i].szDbSetting))
  			break;
 -	if (i==settingCount) return def;
 +	if (i == settingCount)
 +		return def;
  	FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
 @@ -57,8 +58,7 @@ int CIcqProto::StringToListItemId(const char *szSetting,int def)  int ChangeInfoData::UploadSettings(void)
  {
 -	if (!ppro->icqOnline())
 -	{
 +	if (!ppro->icqOnline()) {
  		MessageBox(hwndDlg, TranslateT("You are not currently connected to the ICQ network. You must be online in order to update your information on the server."), TranslateT("Change ICQ Details"), MB_OK);
  		return 0;
  	}
 @@ -67,10 +67,8 @@ int ChangeInfoData::UploadSettings(void)  	//password
  	char* tmp = ppro->GetUserPassword(TRUE);
 -	if (tmp)
 -	{
 -		if (strlennull(Password) > 0 && strcmpnull(Password, tmp))
 -		{
 +	if (tmp) {
 +		if (strlennull(Password) > 0 && strcmpnull(Password, tmp)) {
  			// update password in user info dialog (still open)
  			strcpy(Password, tmp);
  			// update password in protocol
 @@ -79,16 +77,9 @@ int ChangeInfoData::UploadSettings(void)  			hUpload[1] = (HANDLE)ppro->icq_changeUserPasswordServ(tmp);
  			char szPwd[PASSWORDMAXLEN] = {0};
 +			// password is stored in DB, update
  			if (ppro->GetUserStoredPassword(szPwd, sizeof(szPwd)))
 -			{ // password is stored in DB, update
 -				char ptmp[PASSWORDMAXLEN];
 -
 -				strcpy(ptmp, tmp);
 -
 -				CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ptmp), (LPARAM)ptmp);
 -
 -				ppro->setString("Password", ptmp);
 -			}
 +				ppro->setString("Password", tmp);
  		}
  	}
 diff --git a/protocols/IcqOscarJ/src/icq_firstrun.cpp b/protocols/IcqOscarJ/src/icq_firstrun.cpp index 9a5d6bbe11..47dd485da1 100644 --- a/protocols/IcqOscarJ/src/icq_firstrun.cpp +++ b/protocols/IcqOscarJ/src/icq_firstrun.cpp @@ -29,13 +29,11 @@  // -----------------------------------------------------------------------------
  #include "icqoscar.h"
 -
  static void accountLoadDetails(CIcqProto *ppro, HWND hwndDlg)
  {
  	char pszUIN[20];
  	DWORD dwUIN = ppro->getContactUin(NULL);
 -	if (dwUIN)
 -	{
 +	if (dwUIN) {
  		mir_snprintf(pszUIN, 20, "%u", dwUIN);
  		SetDlgItemTextA(hwndDlg, IDC_UIN, pszUIN);
  	}
 @@ -45,7 +43,6 @@ static void accountLoadDetails(CIcqProto *ppro, HWND hwndDlg)  		SetDlgItemTextA(hwndDlg, IDC_PW, pszPwd);
  }
 -
  INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
  	CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr( hwndDlg, GWLP_USERDATA );
 @@ -75,48 +72,42 @@ INT_PTR CALLBACK icq_FirstRunDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  		break;
  	case WM_COMMAND:
 -		switch (LOWORD(wParam))
 -    {
 +		switch (LOWORD(wParam)) {
  		case IDC_REGISTER:
  			CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_REGISTER);
  			break;
 -    case IDC_UIN:
 -    case IDC_PW:
 -			if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
 -			{
 -        SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 +		case IDC_UIN:
 +		case IDC_PW:
 +			if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
 +				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  				break;
  			}
 -    }
 -    break;
 +		}
 +		break;
  	case WM_NOTIFY:
 -		switch (((LPNMHDR)lParam)->code)
 -		{
 +		switch (((LPNMHDR)lParam)->code) {
  		case PSN_APPLY:
 -			{
 -        char str[128];
 -        GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str));
 -        ppro->setDword(UNIQUEIDSETTING, atoi(str));
 -        GetDlgItemTextA(hwndDlg, IDC_PW, str, sizeof(ppro->m_szPassword));
 -        strcpy(ppro->m_szPassword, str);
 -        CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ppro->m_szPassword), (LPARAM) str);
 -        ppro->setString("Password", str);
 -      }
 -      break;
 -
 -    case PSN_RESET:
 -      accountLoadDetails(ppro, hwndDlg);
 -      break;
 -    }
 +			char str[128];
 +			GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str));
 +			ppro->setDword(UNIQUEIDSETTING, atoi(str));
 +
 +			GetDlgItemTextA(hwndDlg, IDC_PW, str, sizeof(ppro->m_szPassword));
 +			strcpy(ppro->m_szPassword, str);
 +			ppro->setString("Password", str);
 +			break;
 +
 +		case PSN_RESET:
 +			accountLoadDetails(ppro, hwndDlg);
 +			break;
 +		}
  		break;
  	}
  	return FALSE;
  }
 -
  INT_PTR CIcqProto::OnCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
  {
  	return (INT_PTR)CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQACCOUNT), (HWND)lParam, icq_FirstRunDlgProc, LPARAM(this));
 diff --git a/protocols/IcqOscarJ/src/icq_opts.cpp b/protocols/IcqOscarJ/src/icq_opts.cpp index f8c3e3c2a9..ded5f25990 100644 --- a/protocols/IcqOscarJ/src/icq_opts.cpp +++ b/protocols/IcqOscarJ/src/icq_opts.cpp @@ -78,12 +78,10 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  			SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, PASSWORDMAXLEN - 1, 0);
 +			// bit of a security hole here, since it's easy to extract a password from an edit box
  			char pszPwd[PASSWORDMAXLEN];
  			if (ppro->GetUserStoredPassword(pszPwd, sizeof(pszPwd)))
 -			{
 -				//bit of a security hole here, since it's easy to extract a password from an edit box
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pszPwd);
 -			}
  			LoadDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection", DEFAULT_SECURE_CONNECTION);
  			LoadDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin", DEFAULT_SECURE_LOGIN);
 @@ -106,86 +104,73 @@ static INT_PTR CALLBACK DlgProcIcqOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  		return TRUE;
  	case WM_HSCROLL:
 -		{
 -			SetDlgItemText(hwndDlg, IDC_LEVELDESCR, TranslateTS(szLogLevelDescr[4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL,TBM_GETPOS, 0, 0)]));
 -			OptDlgChanged(hwndDlg);
 -		}
 +		SetDlgItemText(hwndDlg, IDC_LEVELDESCR, TranslateTS(szLogLevelDescr[4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL,TBM_GETPOS, 0, 0)]));
 +		OptDlgChanged(hwndDlg);
  		break;
  	case WM_COMMAND:
 -		{
 -			switch (LOWORD(wParam)) {
 -			case IDC_LOOKUPLINK:
 -				CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_FORGOT_PASSWORD);
 -				return TRUE;
 -
 -			case IDC_NEWUINLINK:
 -				CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_REGISTER);
 -				return TRUE;
 -
 -			case IDC_RESETSERVER:
 -				SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE);
 +		switch (LOWORD(wParam)) {
 +		case IDC_LOOKUPLINK:
 +			CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_FORGOT_PASSWORD);
 +			return TRUE;
 -			case IDC_SSL:
 -				SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_HOST_SSL : DEFAULT_SERVER_HOST);
 -				SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE);
 -				OptDlgChanged(hwndDlg);
 -				return TRUE;
 -			}
 +		case IDC_NEWUINLINK:
 +			CallService(MS_UTILS_OPENURL, 1, (LPARAM)URL_REGISTER);
 +			return TRUE;
 -			if (ppro->icqOnline() && LOWORD(wParam) != IDC_NOERRMULTI)
 -			{
 -				char szClass[80];
 -				GetClassNameA((HWND)lParam, szClass, sizeof(szClass));
 +		case IDC_RESETSERVER:
 +			SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE);
 -				if (stricmpnull(szClass, "EDIT") || HIWORD(wParam) == EN_CHANGE)
 -					ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_SHOW);
 -			}
 +		case IDC_SSL:
 +			SetDlgItemTextA(hwndDlg, IDC_ICQSERVER, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_HOST_SSL : DEFAULT_SERVER_HOST);
 +			SetDlgItemInt(hwndDlg, IDC_ICQPORT, IsDlgButtonChecked(hwndDlg, IDC_SSL) ? DEFAULT_SERVER_PORT_SSL : DEFAULT_SERVER_PORT, FALSE);
 +			OptDlgChanged(hwndDlg);
 +			return TRUE;
 +		}
 -			if ((LOWORD(wParam)==IDC_ICQNUM || LOWORD(wParam)==IDC_PASSWORD || LOWORD(wParam)==IDC_ICQSERVER || LOWORD(wParam)==IDC_ICQPORT) &&
 -				(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()))
 -			{
 -				return 0;
 -			}
 +		if (ppro->icqOnline() && LOWORD(wParam) != IDC_NOERRMULTI) {
 +			char szClass[80];
 +			GetClassNameA((HWND)lParam, szClass, sizeof(szClass));
 -			OptDlgChanged(hwndDlg);
 -			break;
 +			if (stricmpnull(szClass, "EDIT") || HIWORD(wParam) == EN_CHANGE)
 +				ShowDlgItem(hwndDlg, IDC_RECONNECTREQD, SW_SHOW);
  		}
 -	case WM_NOTIFY:
 +		if ((LOWORD(wParam)==IDC_ICQNUM || LOWORD(wParam)==IDC_PASSWORD || LOWORD(wParam)==IDC_ICQSERVER || LOWORD(wParam)==IDC_ICQPORT) &&
 +			(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus()))
  		{
 -			switch (((LPNMHDR)lParam)->code)
 -			{
 +			return 0;
 +		}
 -			case PSN_APPLY:
 -				{
 -					char str[128];
 +		OptDlgChanged(hwndDlg);
 +		break;
 -					ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE));
 -					GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(ppro->m_szPassword));
 -					if (strlennull(str))
 -					{
 -						strcpy(ppro->m_szPassword, str);
 -						ppro->m_bRememberPwd = TRUE;
 -					}
 -					else
 -						ppro->m_bRememberPwd = ppro->getByte("RememberPass", 0);
 -
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(ppro->m_szPassword), (LPARAM)str);
 -					ppro->setString("Password", str);
 -					GetDlgItemTextA(hwndDlg,IDC_ICQSERVER, str, sizeof(str));
 -					ppro->setString("OscarServer", str);
 -					ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE));
 -					StoreDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive");
 -					StoreDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection");
 -					StoreDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin");
 -					StoreDBCheckState(ppro, hwndDlg, IDC_LEGACY, "LegacyFix");
 -					StoreDBCheckState(ppro, hwndDlg, IDC_NOERRMULTI, "IgnoreMultiErrorBox");
 -					ppro->setByte("ShowLogLevel", (BYTE)(4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0)));
 -
 -					return TRUE;
 -				}
 +	case WM_NOTIFY:
 +		switch (((LPNMHDR)lParam)->code) {
 +		case PSN_APPLY:
 +			char str[128];
 +
 +			ppro->setDword(UNIQUEIDSETTING, GetDlgItemInt(hwndDlg, IDC_ICQNUM, NULL, FALSE));
 +			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(ppro->m_szPassword));
 +			if (strlennull(str)) {
 +				strcpy(ppro->m_szPassword, str);
 +				ppro->m_bRememberPwd = TRUE;
  			}
 +			else ppro->m_bRememberPwd = ppro->getByte("RememberPass", 0);
 +			ppro->setString("Password", str);
 +
 +			GetDlgItemTextA(hwndDlg,IDC_ICQSERVER, str, sizeof(str));
 +			ppro->setString("OscarServer", str);
 +
 +			ppro->setWord("OscarPort", (WORD)GetDlgItemInt(hwndDlg, IDC_ICQPORT, NULL, FALSE));
 +
 +			StoreDBCheckState(ppro, hwndDlg, IDC_KEEPALIVE, "KeepAlive");
 +			StoreDBCheckState(ppro, hwndDlg, IDC_SSL, "SecureConnection");
 +			StoreDBCheckState(ppro, hwndDlg, IDC_MD5LOGIN, "SecureLogin");
 +			StoreDBCheckState(ppro, hwndDlg, IDC_LEGACY, "LegacyFix");
 +			StoreDBCheckState(ppro, hwndDlg, IDC_NOERRMULTI, "IgnoreMultiErrorBox");
 +			ppro->setByte("ShowLogLevel", (BYTE)(4-SendDlgItemMessage(hwndDlg, IDC_LOGLEVEL, TBM_GETPOS, 0, 0)));
 +			return TRUE;
  		}
  		break;
  	}
 diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 1e073e55b0..de9d020fd6 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -1791,12 +1791,9 @@ char* __fastcall ICQTranslateUtfStatic(const char *src, char *buf, size_t bufsiz  char* CIcqProto::GetUserStoredPassword(char *szBuffer, int cbSize)
  {
  	if (!getSettingStringStatic(NULL, "Password", szBuffer, cbSize))
 -	{
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlennull(szBuffer) + 1, (LPARAM)szBuffer);
 -
  		if (strlennull(szBuffer))
  			return szBuffer;
 -	}
 +
  	return NULL;
  }
 diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 44561e2faa..4d0a5631ba 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -159,7 +159,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const TCHAR *aUserName) :  	ptrA szPassword( getStringA("Password"));
  	if (szPassword != NULL) {
 -		CallService(MS_DB_CRYPT_DECODESTRING, lstrlenA(szPassword) + 1, szPassword);
  		JSetStringCrypt(NULL, "LoginPassword", _A2T(szPassword));
  		delSetting("Password");
  	}
 diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index dd860176c6..e69972e28a 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -135,7 +135,6 @@ int CMsnProto::MSN_GetPassportAuth(void)  	char szPassword[100];
  	getStaticString(NULL, "Password", szPassword, sizeof(szPassword));
 -	CallService(MS_DB_CRYPT_DECODESTRING, strlen(szPassword)+1, (LPARAM)szPassword);
  	szPassword[16] = 0;
  	char* szEncPassword = HtmlEncode(szPassword);
 diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp index 240768ee53..6f809e39d1 100644 --- a/protocols/MSN/src/msn_opts.cpp +++ b/protocols/MSN/src/msn_opts.cpp @@ -80,21 +80,17 @@ INT_PTR CALLBACK DlgProcMsnServLists(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch (msg)
 -	{
 +	switch (msg) {
  	case WM_INITDIALOG:
 +		TranslateDialogDefault(hwndDlg);
  		{
 -			TranslateDialogDefault(hwndDlg);
 -
  			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
  			CMsnProto* proto = (CMsnProto*)lParam;
  			SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);
  			char tBuffer[MAX_PATH];
 -			if (!proto->getStaticString(NULL, "Password", tBuffer, sizeof(tBuffer)))
 -			{
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(tBuffer)+1, (LPARAM)tBuffer);
 +			if (!proto->getStaticString(NULL, "Password", tBuffer, sizeof(tBuffer))) {
  				tBuffer[16] = 0;
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
  			}
 @@ -102,8 +98,7 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  			HWND wnd = GetDlgItem(hwndDlg, IDC_HANDLE2);
  			DBVARIANT dbv;
 -			if (!proto->getTString("Nick", &dbv))
 -			{
 +			if (!proto->getTString("Nick", &dbv)) {
  				SetWindowText(wnd, dbv.ptszVal);
  				db_free(&dbv);
  			}
 @@ -123,35 +118,30 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  			if (!proto->getStaticString(NULL, "MailerPath", tBuffer, sizeof(tBuffer)))
  				SetDlgItemTextA(hwndDlg, IDC_MAILER_APP, tBuffer);
 -			if (!proto->msnLoggedIn)
 -			{
 +			if (!proto->msnLoggedIn) {
  				EnableWindow(GetDlgItem(hwndDlg, IDC_MANAGEGROUPS), FALSE);
  				EnableWindow(GetDlgItem(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS), FALSE);
  			}
  			else CheckDlgButton(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS, proto->msnOtherContactsBlocked);
 -			return TRUE;
  		}
 +		return TRUE;
  	case WM_COMMAND:
 -		if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK)
 -		{
 +		if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK) {
  			CallService(MS_UTILS_OPENURL, 1, (LPARAM)"https://signup.live.com");
  			return TRUE;
  		}
 -		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
 -		{
 -			switch(LOWORD(wParam))
 -			{
 +		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
 +			switch(LOWORD(wParam)) {
  			case IDC_HANDLE:			case IDC_PASSWORD:			case IDC_HANDLE2:
  			case IDC_GATEWAYSERVER: 	case IDC_YOURHOST:			case IDC_DIRECTSERVER:
  				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  			}
  		}
 -		if (HIWORD(wParam) == BN_CLICKED)
 -			switch(LOWORD(wParam))
 -		{
 +		if (HIWORD(wParam) == BN_CLICKED) {
 +			switch(LOWORD(wParam)) {
  			case IDC_SENDFONTINFO:
  			case IDC_DISABLE_ANOTHER_CONTACTS:
  			case IDC_MOBILESEND:
 @@ -159,8 +149,7 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  				break;
  			case IDC_MANAGEGROUPS:
 -				if (IsDlgButtonChecked(hwndDlg, IDC_MANAGEGROUPS))
 -				{
 +				if (IsDlgButtonChecked(hwndDlg, IDC_MANAGEGROUPS)) {
  					if (IDYES == MessageBox(hwndDlg,
  						TranslateT("Server groups import may change your contact list layout after next login. Do you want to upload your groups to the server?"),
  						TranslateT("MSN Protocol"), MB_YESNOCANCEL))
 @@ -178,8 +167,8 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  					EnableWindow(GetDlgItem(hwndDlg, IDC_MAILER_APP), tIsChosen);
  					EnableWindow(GetDlgItem(hwndDlg, IDC_ENTER_MAILER_APP), tIsChosen);
  					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 -					break;
  				}
 +				break;
  			case IDC_ENTER_MAILER_APP:
  				{
 @@ -190,11 +179,9 @@ static INT_PTR CALLBACK DlgProcMsnOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP  					size_t tSelectLen = 0;
 -					if (szFile[0] == '\"')
 -					{
 +					if (szFile[0] == '\"') {
  						char* p = strchr(szFile+1, '\"');
 -						if (p != NULL)
 -						{
 +						if (p != NULL) {
  							*p = '\0';
  							memmove(szFile, szFile+1, strlen(szFile));
  							tSelectLen += 2;
 @@ -218,8 +205,7 @@ LBL_Continue:  					if (GetOpenFileNameA(&ofn) != TRUE)
  						break;
 -					if (strchr(szFile, ' ') != NULL)
 -					{
 +					if (strchr(szFile, ' ') != NULL) {
  						char tmpBuf[MAX_PATH + 2];
  						mir_snprintf(tmpBuf, sizeof(tmpBuf), "\"%s\"", szFile);
  						strcpy(szFile, tmpBuf);
 @@ -229,13 +215,12 @@ LBL_Continue:  					SendMessageA(tEditField, EM_REPLACESEL, TRUE, LPARAM(szFile));
  					SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  				}
 +			}
  		}
 -
  		break;
  	case WM_NOTIFY:
 -		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
 -		{
 +		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
  			bool reconnectRequired = false;
  			TCHAR screenStr[MAX_PATH];
  			char  password[100], szEmail[MSN_MAX_EMAIL_LEN];
 @@ -244,52 +229,41 @@ LBL_Continue:  			CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  			GetDlgItemTextA(hwndDlg, IDC_HANDLE, szEmail, sizeof(szEmail));
 -			if (strcmp(_strlwr(szEmail), proto->MyOptions.szEmail))
 -			{
 +			if (strcmp(_strlwr(szEmail), proto->MyOptions.szEmail)) {
  				reconnectRequired = true;
  				strcpy(proto->MyOptions.szEmail, szEmail);
  				proto->setString("e-mail", szEmail);
  			}
  			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, sizeof(password));
 -			CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(password),(LPARAM)password);
 -			if (!proto->getString("Password", &dbv))
 -			{
 -				if (strcmp(password, dbv.pszVal))
 -				{
 +			if (!proto->getString("Password", &dbv)) {
 +				if (strcmp(password, dbv.pszVal)) {
  					reconnectRequired = true;
  					proto->setString("Password", password);
  				}
  				db_free(&dbv);
  			}
 -			else
 -			{
 +			else {
  				reconnectRequired = true;
  				proto->setString("Password", password);
  			}
  			GetDlgItemText(hwndDlg, IDC_HANDLE2, screenStr, SIZEOF(screenStr));
 -			if	(!proto->getTString("Nick", &dbv))
 -			{
 +			if	(!proto->getTString("Nick", &dbv)) {
  				if (_tcscmp(dbv.ptszVal, screenStr))
  					proto->MSN_SendNickname(screenStr);
  				db_free(&dbv);
  			}
 -			else
 -			{
 -				proto->MSN_SendNickname(screenStr);
 -			}
 +			else proto->MSN_SendNickname(screenStr);
  			BYTE mblsnd = IsDlgButtonChecked(hwndDlg, IDC_MOBILESEND) == BST_CHECKED;
 -			if (mblsnd != proto->getByte("MobileAllowed", 0))
 -			{
 +			if (mblsnd != proto->getByte("MobileAllowed", 0)) {
  				proto->msnNsThread->sendPacket("PRP", "MOB %c", mblsnd ? 'Y' : 'N');
  				proto->MSN_SetServerStatus(proto->m_iStatus);
  			}
  			unsigned tValue = IsDlgButtonChecked(hwndDlg, IDC_DISABLE_ANOTHER_CONTACTS);
 -			if (tValue != proto->msnOtherContactsBlocked && proto->msnLoggedIn)
 -			{
 +			if (tValue != proto->msnOtherContactsBlocked && proto->msnLoggedIn) {
  				proto->msnOtherContactsBlocked = tValue;
  				proto->msnNsThread->sendPacket("BLP", tValue ? "BL" : "AL");
  				proto->MSN_ABUpdateAttr(NULL, "MSN.IM.BLP", tValue ? "0" : "1");
 @@ -304,8 +278,9 @@ LBL_Continue:  			proto->setTString("MailerPath", screenStr);
  			if (reconnectRequired && proto->msnLoggedIn)
 -				MessageBox(hwndDlg, TranslateT("The changes you have made require you to reconnect to the MSN Messenger network before they take effect"),
 -				TranslateT("MSN Options"), MB_OK);
 +				MessageBox(hwndDlg,
 +					TranslateT("The changes you have made require you to reconnect to the MSN Messenger network before they take effect"),
 +					TranslateT("MSN Options"), MB_OK);
  			proto->LoadOptions();
  			return TRUE;
 @@ -330,15 +305,13 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
  			CMsnProto* proto = (CMsnProto*)lParam;
 -			if (!proto->getString("DirectServer", &dbv))
 -			{
 +			if (!proto->getString("DirectServer", &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_DIRECTSERVER, dbv.pszVal);
  				db_free(&dbv);
  			}
  			else SetDlgItemTextA(hwndDlg, IDC_DIRECTSERVER,  MSN_DEFAULT_LOGIN_SERVER);
 -			if (!proto->getString("GatewayServer", &dbv))
 -			{
 +			if (!proto->getString("GatewayServer", &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_GATEWAYSERVER, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -367,13 +340,11 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  			else
  				SetDlgItemText(hwndDlg, IDC_YOURHOST, TranslateT("IP info available only after login"));
  			EnableWindow(GetDlgItem(hwndDlg, IDC_YOURHOST), gethst == 1);
 -
 -			return TRUE;
  		}
 +		return TRUE;
  	case WM_COMMAND:
 -		switch (LOWORD(wParam))
 -		{
 +		switch (LOWORD(wParam)) {
  		case IDC_RESETSERVER:
  			SetDlgItemTextA(hwndDlg, IDC_DIRECTSERVER, MSN_DEFAULT_LOGIN_SERVER);
  			SetDlgItemTextA(hwndDlg, IDC_GATEWAYSERVER, MSN_DEFAULT_GATEWAY);
 @@ -389,15 +360,13 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  		}
 -		if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_HOSTOPT)
 -		{
 +		if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_HOSTOPT) {
  			unsigned gethst = SendMessage((HWND)lParam, CB_GETCURSEL, 0, 0);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_YOURHOST), gethst == 1);
  			SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  		}
 -		if (HIWORD(wParam) == BN_CLICKED)
 -		{
 +		if (HIWORD(wParam) == BN_CLICKED) {
  			switch(LOWORD(wParam)) {
  			case IDC_SLOWSEND:
  				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
 @@ -407,8 +376,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  		break;
  	case WM_NOTIFY:
 -		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
 -		{
 +		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
  			bool reconnectRequired = false;
  			char str[MAX_PATH];
 @@ -427,8 +395,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  				proto->delSetting("GatewayServer");
  			proto->setByte("SlowSend",   (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SLOWSEND ));
 -			if (proto->getByte("SlowSend", FALSE))
 -			{
 +			if (proto->getByte("SlowSend", FALSE)) {
  				if (db_get_dw(NULL, "SRMsg", "MessageTimeout", 60000) < 60000 ||
  					db_get_dw(NULL, "SRMM",  "MessageTimeout", 60000) < 60000)
  				{
 @@ -442,8 +409,7 @@ static INT_PTR CALLBACK DlgProcMsnConnOpts(HWND hwndDlg, UINT msg, WPARAM wParam  			if (gethst < 2) gethst = !gethst;
  			proto->setByte("AutoGetHost", (BYTE)gethst);
 -			if (gethst == 0)
 -			{
 +			if (gethst == 0) {
  				GetDlgItemTextA(hwndDlg, IDC_YOURHOST, str, sizeof(str));
  				proto->setString("YourHost", str);
  			}
 @@ -550,65 +516,55 @@ static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, L  			SetDlgItemTextA(hwndDlg, IDC_HANDLE, proto->MyOptions.szEmail);
  			char tBuffer[MAX_PATH];
 -			if (!proto->getStaticString(NULL, "Password", tBuffer, sizeof(tBuffer)))
 -			{
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(tBuffer)+1, (LPARAM)tBuffer);
 +			if (!proto->getStaticString(NULL, "Password", tBuffer, sizeof(tBuffer))) {
  				tBuffer[16] = 0;
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, tBuffer);
  			}
  			SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_SETLIMITTEXT, 16, 0);
  			DBVARIANT dbv;
 -			if (!proto->getTString("Place", &dbv))
 -			{
 +			if (!proto->getTString("Place", &dbv)) {
  				SetDlgItemText(hwndDlg, IDC_PLACE, dbv.ptszVal);
  				db_free(&dbv);
  			}
 -			return TRUE;
  		}
 +		return TRUE;
  	case WM_COMMAND:
 -		if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK)
 -		{
 +		if (LOWORD(wParam) == IDC_NEWMSNACCOUNTLINK) {
  			CallService(MS_UTILS_OPENURL, 1, (LPARAM)"https://signup.live.com");
  			return TRUE;
  		}
 -		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
 -		{
 -			switch(LOWORD(wParam))
 -			{
 -			case IDC_HANDLE:			case IDC_PASSWORD:
 +		if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
 +			switch(LOWORD(wParam)) {
 +			case IDC_HANDLE:
 +			case IDC_PASSWORD:
  				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
  			}
  		}
  		break;
  	case WM_NOTIFY:
 -		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
 -		{
 +		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
  			char  password[100], szEmail[MSN_MAX_EMAIL_LEN];
  			DBVARIANT dbv;
  			CMsnProto* proto = (CMsnProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  			GetDlgItemTextA(hwndDlg, IDC_HANDLE, szEmail, sizeof(szEmail));
 -			if (strcmp(szEmail, proto->MyOptions.szEmail))
 -			{
 +			if (strcmp(szEmail, proto->MyOptions.szEmail)) {
  				strcpy(proto->MyOptions.szEmail, szEmail);
  				proto->setString("e-mail", szEmail);
  			}
  			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, sizeof(password));
 -			CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(password),(LPARAM)password);
 -			if (!proto->getString("Password", &dbv))
 -			{
 +			if (!proto->getString("Password", &dbv)) {
  				if (strcmp(password, dbv.pszVal))
  					proto->setString("Password", password);
  				db_free(&dbv);
  			}
 -			else
 -				proto->setString("Password", password);
 +			else proto->setString("Password", password);
  			TCHAR szPlace[64];
  			GetDlgItemText(hwndDlg, IDC_PLACE, szPlace, SIZEOF(szPlace));
 @@ -627,8 +583,7 @@ static INT_PTR CALLBACK DlgProcAccMgrUI(HWND hwndDlg, UINT msg, WPARAM wParam, L  INT_PTR CALLBACK DlgDeleteContactUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch(msg)
 -	{
 +	switch(msg) {
  	case WM_INITDIALOG:
  		TranslateDialogDefault(hwndDlg);
  		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
 @@ -639,20 +594,16 @@ INT_PTR CALLBACK DlgDeleteContactUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA  		break;
  	case WM_COMMAND:
 -		if (LOWORD(wParam) == IDOK)
 -		{
 +		if (LOWORD(wParam) == IDOK) {
  			int isBlock = IsDlgButtonChecked(hwndDlg, IDC_REMOVEBLOCK);
  			int isHot = IsDlgButtonChecked(hwndDlg, IDC_REMOVEHOT);
  			DeleteParam *param = (DeleteParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
  			char szEmail[MSN_MAX_EMAIL_LEN];
 -			if (!param->proto->getStaticString(param->hContact, "e-mail", szEmail, sizeof(szEmail)))
 -			{
 +			if (!param->proto->getStaticString(param->hContact, "e-mail", szEmail, sizeof(szEmail))) {
  				param->proto->MSN_AddUser(param->hContact, szEmail, 0, LIST_FL | (isHot ? LIST_REMOVE : LIST_REMOVENH));
 -
 -				if (isBlock)
 -				{
 +				if (isBlock) {
  					param->proto->MSN_AddUser(param->hContact, szEmail, 0, LIST_AL | LIST_REMOVE);
  					param->proto->MSN_AddUser(param->hContact, szEmail, 0, LIST_BL);
  				}
 @@ -664,6 +615,7 @@ INT_PTR CALLBACK DlgDeleteContactUI(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA  	return FALSE;
  }
 +
  /////////////////////////////////////////////////////////////////////////////////////////
  // Initialize options pages
 diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index ceb0748dcb..7111f2b637 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -95,8 +95,6 @@ bool CSkypeProto::PreparePassword()  				this->rememberPassword = param.rememberPassword;
  			}
  		}
 -		else
 -			::CallService(MS_DB_CRYPT_DECODESTRING, ::strlen(this->password), (LPARAM)this->password);
  	}
  	return true;
 @@ -221,10 +219,6 @@ void CSkypeProto::OnLoggedIn()  		::mir_free(this->password);
  		this->password = NULL;
  	}
 -	else
 -	{
 -		::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(this->password), (LPARAM)this->password);
 -	}
  	this->SetServerStatus(this->m_iDesiredStatus);
 diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 3a830b2471..9eeb4bd25c 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -18,9 +18,6 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR  			}
  			{
  				ptrA pwd( ::db_get_sa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD));
 -				if (pwd)
 -					::CallService(MS_DB_CRYPT_DECODESTRING, ::strlen(pwd), pwd);
 -
  				SetDlgItemTextA(hwnd, IDC_PW, pwd);
  			}
  			{
 @@ -157,7 +154,6 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR  			char pwd[128];
  			GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
 -			::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(pwd), (LPARAM)&pwd);
  			::db_set_s(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, pwd);
  			HWND item = GetDlgItem(hwnd, IDC_PORT);
 diff --git a/protocols/SkypeClassic/src/skypeapi.cpp b/protocols/SkypeClassic/src/skypeapi.cpp index c041a53a43..c7d8ab8010 100644 --- a/protocols/SkypeClassic/src/skypeapi.cpp +++ b/protocols/SkypeClassic/src/skypeapi.cpp @@ -407,14 +407,17 @@ char *SkypeRcvTime(char *what, time_t st, DWORD maxwait) {  	LOG(("<SkypeRcv: (empty)"));	
  	return NULL;
  }
 -char *SkypeRcv(char *what, DWORD maxwait) {
 +
 +char *SkypeRcv(char *what, DWORD maxwait)
 +{
  	return SkypeRcvTime(what, 0, maxwait);
  }
 -char *SkypeRcvMsg(char *what, time_t st, HANDLE hContact, DWORD maxwait) {
 -    char *msg, msgid[32]={0}, *pMsg, *pCurMsg;
 +char *SkypeRcvMsg(char *what, time_t st, HANDLE hContact, DWORD maxwait)
 +{
 +	char *msg, msgid[32]={0}, *pMsg, *pCurMsg;
  	struct MsgQueue *ptr;
 -	int iLenWhat = strlen(what);
 +	int iLenWhat = (int)strlen(what);
  	DWORD dwWaitStat;
  	BOOL bIsError, bProcess;
 @@ -1346,7 +1349,8 @@ static int my_spawnv(const char *cmdname, const char *const *argv, PROCESS_INFOR  	BOOL bRet;
  	memset (pi, 0, sizeof(PROCESS_INFORMATION));
 -	for (i=0; argv[i]; i++) iLen+=strlen(argv[i])+1;
 +	for (i=0; argv[i]; i++)
 +		iLen += (int)strlen(argv[i])+1;
  	if (!(CommandLine = (char*)calloc(1, iLen))) return -1;
  	for (i=0; argv[i]; i++) {
  		if (i) strcat (CommandLine, " ");
 @@ -1407,11 +1411,9 @@ static int _ConnectToSkypeAPI(char *path, int iStart) {  		{
  				char reply=0;
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
 -				if ((reply=SendSkypeproxyCommand(AUTHENTICATE))==-1) 
 -				{
 -						db_free(&dbv);
 -						return -1;
 +				if ((reply=SendSkypeproxyCommand(AUTHENTICATE))==-1) {
 +					db_free(&dbv);
 +					return -1;
  				}
  				if (!reply) {
  					OUTPUT(_T("Authentication is not supported/needed for this Skype proxy server. It will be disabled."));
 @@ -1492,7 +1494,7 @@ static int _ConnectToSkypeAPI(char *path, int iStart) {  		if (iStart != 2 || counter)
  		{
  			LOG(("ConnectToSkypeAPI sending discover message.. hWnd=%08X", (long)g_hWnd));
 -			retval=SendMessageTimeout(HWND_BROADCAST, ControlAPIDiscover, (WPARAM)g_hWnd, 0, SMTO_ABORTIFHUNG, 3000, NULL);
 +			retval = (int)SendMessageTimeout(HWND_BROADCAST, ControlAPIDiscover, (WPARAM)g_hWnd, 0, SMTO_ABORTIFHUNG, 3000, NULL);
  			LOG(("ConnectToSkypeAPI sent discover message returning %d", retval));
  		}
 @@ -1521,7 +1523,7 @@ static int _ConnectToSkypeAPI(char *path, int iStart) {  					LOG(("ConnectToSkypeAPI Starting Skype, as it's not running"));
  					j=1;
 -					for (i=0; i<sizeof(SkypeOptions)/sizeof(SkypeOptions[0]); i++)
 +					for (i=0; i < SIZEOF(SkypeOptions); i++)
  						if (db_get_b(NULL, SKYPE_PROTONAME, SkypeOptions[i]+1, SkypeDefaults[i])) {
  							DBVARIANT dbv;
 @@ -1532,7 +1534,7 @@ static int _ConnectToSkypeAPI(char *path, int iStart) {  								{
  									int paramSize;
  									TranslateMirandaRelativePathToAbsolute(dbv.pszVal, szAbsolutePath, TRUE);
 -									paramSize = strlen(SkypeOptions[i]) + strlen(szAbsolutePath);
 +									paramSize = (int)strlen(SkypeOptions[i]) + (int)strlen(szAbsolutePath);
  									pFree = args[j] = (char*)malloc(paramSize + 1);
  									sprintf(args[j],"%s%s",SkypeOptions[i],szAbsolutePath);
  									db_free(&dbv);
 diff --git a/protocols/SkypeClassic/src/skypeopt.cpp b/protocols/SkypeClassic/src/skypeopt.cpp index 078770d1a6..db077b8b74 100644 --- a/protocols/SkypeClassic/src/skypeopt.cpp +++ b/protocols/SkypeClassic/src/skypeopt.cpp @@ -210,10 +210,10 @@ INT_PTR CALLBACK OptPopupDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar  				case IDC_POPUPBACKCOLOR:
  				case IDC_POPUPTEXTCOLORERR:
  				case IDC_POPUPBACKCOLORERR:
 -					popupBackColor = SendDlgItemMessage(hwnd,IDC_POPUPBACKCOLOR,CPM_GETCOLOUR,0,0);
 -					popupTextColor = SendDlgItemMessage(hwnd,IDC_POPUPTEXTCOLOR,CPM_GETCOLOUR,0,0);
 -					popupBackColorErr = SendDlgItemMessage(hwnd,IDC_POPUPBACKCOLORERR,CPM_GETCOLOUR,0,0);
 -					popupTextColorErr = SendDlgItemMessage(hwnd,IDC_POPUPTEXTCOLORERR,CPM_GETCOLOUR,0,0);
 +					popupBackColor = (UINT)SendDlgItemMessage(hwnd,IDC_POPUPBACKCOLOR,CPM_GETCOLOUR,0,0);
 +					popupTextColor = (UINT)SendDlgItemMessage(hwnd,IDC_POPUPTEXTCOLOR,CPM_GETCOLOUR,0,0);
 +					popupBackColorErr = (UINT)SendDlgItemMessage(hwnd,IDC_POPUPBACKCOLORERR,CPM_GETCOLOUR,0,0);
 +					popupTextColorErr = (UINT)SendDlgItemMessage(hwnd,IDC_POPUPTEXTCOLORERR,CPM_GETCOLOUR,0,0);
  					SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
  					break;
  				case IDC_USEWINCOLORS:
 @@ -385,7 +385,6 @@ INT_PTR CALLBACK OptionsProxyDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA  			CheckDlgButton(hwndDlg, IDC_REQPASS, (BYTE)db_get_b(NULL, SKYPE_PROTONAME, "RequiresPassword", 0));
  			CheckDlgButton(hwndDlg, IDC_USES2S, (BYTE)db_get_b(NULL, SKYPE_PROTONAME, "UseSkype2Socket", 0));
  			if (!db_get_s(NULL, SKYPE_PROTONAME, "Password", &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
  				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -408,7 +407,6 @@ INT_PTR CALLBACK OptionsProxyDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA  					db_set_b (NULL, SKYPE_PROTONAME, "UseSkype2Socket", (BYTE)(SendMessage(GetDlgItem(hwndDlg, IDC_USES2S), BM_GETCHECK,0,0)));
  					ZeroMemory(buf, sizeof(buf));
  					GetDlgItemTextA(hwndDlg, IDC_PASSWORD, buf, sizeof(buf));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(buf), (LPARAM)buf);
  					db_set_s(NULL, SKYPE_PROTONAME, "Password", buf);
  					return TRUE;
  				}
 diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index dbb36e1108..0bf2926e3e 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -187,13 +187,9 @@ INT_PTR TlenProtocol::MenuHandleInbox(WPARAM wParam, LPARAM lParam)  		login = mir_strdup(dbv.pszVal);
  		db_free(&dbv);
  	}
 -	if (db_get_b(NULL, m_szModuleName, "SavePassword", TRUE) == TRUE) {
 -		if (!db_get(NULL, m_szModuleName, "Password", &dbv)) {
 -			CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
 -			password = mir_strdup(dbv.pszVal);
 -			db_free(&dbv);
 -		}
 -	}
 +
 +	if (db_get_b(NULL, m_szModuleName, "SavePassword", TRUE) == TRUE)
 +		password = db_get_sa(NULL, m_szModuleName, "Password");
  	else if (threadData != NULL && strlen(threadData->password) > 0)
  		password = mir_strdup(threadData->password);
 diff --git a/protocols/Tlen/src/tlen_opt.cpp b/protocols/Tlen/src/tlen_opt.cpp index d8c47e0859..5d8a66af30 100644 --- a/protocols/Tlen/src/tlen_opt.cpp +++ b/protocols/Tlen/src/tlen_opt.cpp @@ -127,7 +127,6 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  				db_free(&dbv);
  			}
  			if (!db_get(NULL, proto->m_szModuleName, "Password", &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
  				SetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -167,7 +166,6 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  				if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) {
  					GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, sizeof(text));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(text), (LPARAM) text);
  					if (db_get(NULL, proto->m_szModuleName, "Password", &dbv) || strcmp(text, dbv.pszVal))
  						reconnectRequired = TRUE;
  					if (dbv.pszVal != NULL)	db_free(&dbv);
 @@ -205,7 +203,6 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara  				db_free(&dbv);
  			}
  			if (!db_get(NULL, proto->m_szModuleName, "Password", &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
  				SetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -303,7 +300,6 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara  				if (IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD)) {
  					GetDlgItemTextA(hwndDlg, IDC_EDIT_PASSWORD, text, sizeof(text));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(text), (LPARAM) text);
  					if (db_get(NULL, proto->m_szModuleName, "Password", &dbv) || strcmp(text, dbv.pszVal))
  						reconnectRequired = TRUE;
  					if (dbv.pszVal != NULL)	db_free(&dbv);
 @@ -399,9 +395,8 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,  			if (!db_get_ts(NULL, proto->m_szModuleName, "LoginServer", &dbv)) {
  				SetDlgItemText(hwndDlg, IDC_EDIT_LOGIN_SERVER, dbv.ptszVal);
  				db_free(&dbv);
 -			} else {
 -				SetDlgItemText(hwndDlg, IDC_EDIT_LOGIN_SERVER, _T("tlen.pl"));
  			}
 +			else SetDlgItemText(hwndDlg, IDC_EDIT_LOGIN_SERVER, _T("tlen.pl"));
  			EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), TRUE);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_HOSTPORT), TRUE);
 @@ -409,8 +404,9 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,  			if (!db_get_ts(NULL, proto->m_szModuleName, "ManualHost", &dbv)) {
  				SetDlgItemText(hwndDlg, IDC_HOST, dbv.ptszVal);
  				db_free(&dbv);
 -			} else
 -				SetDlgItemText(hwndDlg, IDC_HOST, _T("s1.tlen.pl"));
 +			}
 +			else SetDlgItemText(hwndDlg, IDC_HOST, _T("s1.tlen.pl"));
 +
  			SetDlgItemInt(hwndDlg, IDC_HOSTPORT, db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT), FALSE);
  			CheckDlgButton(hwndDlg, IDC_KEEPALIVE, db_get_b(NULL, proto->m_szModuleName, "KeepAlive", TRUE));
 @@ -431,11 +427,11 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,  			EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_PORT_LABEL), bChecked);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_PORT), bChecked);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_USE_AUTH), bChecked);
 -			if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE) == TRUE) {
 +			if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE) == TRUE)
  				CheckDlgButton(hwndDlg, IDC_FILE_PROXY_USE_AUTH, TRUE);
 -			} else {
 +			else
  				bChecked = FALSE;
 -			}
 +
  			EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_USER_LABEL), bChecked);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_USER), bChecked);
  			EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_PROXY_PASSWORD_LABEL), bChecked);
 @@ -454,8 +450,7 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,  				SetDlgItemText(hwndDlg, IDC_FILE_PROXY_USER, dbv.ptszVal);
  				db_free(&dbv);
  			}
 -			if (!db_get(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
 +			if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
  				SetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -503,63 +498,63 @@ static INT_PTR CALLBACK TlenAdvOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam,  			}
  		}
  		break;
 +
  	case WM_NOTIFY:
 -		{
 -			switch (((LPNMHDR) lParam)->code) {
 -			case PSN_APPLY:
 -				{
 -					WORD port;
 -					BOOL useEncryption;
 -					BOOL reconnectRequired = FALSE;
 -					DBVARIANT dbv;
 -					GetDlgItemTextA(hwndDlg, IDC_EDIT_LOGIN_SERVER, text, sizeof(text));
 -					if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv) || strcmp(text, dbv.pszVal))
 -						reconnectRequired = TRUE;
 -					if (dbv.pszVal != NULL)	db_free(&dbv);
 -					db_set_s(NULL, proto->m_szModuleName, "LoginServer", strlwr(text));
 +		switch (((LPNMHDR) lParam)->code) {
 +		case PSN_APPLY:
 +			WORD port;
 +			BOOL useEncryption;
 +			BOOL reconnectRequired = FALSE;
 +			DBVARIANT dbv;
 +			GetDlgItemTextA(hwndDlg, IDC_EDIT_LOGIN_SERVER, text, sizeof(text));
 +			if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv) || strcmp(text, dbv.pszVal))
 +				reconnectRequired = TRUE;
 +			if (dbv.pszVal != NULL)	db_free(&dbv);
 +			db_set_s(NULL, proto->m_szModuleName, "LoginServer", strlwr(text));
 -					GetDlgItemTextA(hwndDlg, IDC_HOST, text, sizeof(text));
 -					if (db_get(NULL, proto->m_szModuleName, "ManualHost", &dbv) || strcmp(text, dbv.pszVal))
 -						reconnectRequired = TRUE;
 -					if (dbv.pszVal != NULL)	db_free(&dbv);
 -					db_set_s(NULL, proto->m_szModuleName, "ManualHost", text);
 +			GetDlgItemTextA(hwndDlg, IDC_HOST, text, sizeof(text));
 +			if (db_get(NULL, proto->m_szModuleName, "ManualHost", &dbv) || strcmp(text, dbv.pszVal))
 +				reconnectRequired = TRUE;
 +			if (dbv.pszVal != NULL)	db_free(&dbv);
 +			db_set_s(NULL, proto->m_szModuleName, "ManualHost", text);
 -					port = (WORD) GetDlgItemInt(hwndDlg, IDC_HOSTPORT, NULL, FALSE);
 -					if (db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT) != port)
 -						reconnectRequired = TRUE;
 -					db_set_w(NULL, proto->m_szModuleName, "ManualPort", port);
 +			port = (WORD) GetDlgItemInt(hwndDlg, IDC_HOSTPORT, NULL, FALSE);
 +			if (db_get_w(NULL, proto->m_szModuleName, "ManualPort", TLEN_DEFAULT_PORT) != port)
 +				reconnectRequired = TRUE;
 +			db_set_w(NULL, proto->m_szModuleName, "ManualPort", port);
 -					proto->tlenOptions.sendKeepAlive = IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE);
 -					db_set_b(NULL, proto->m_szModuleName, "KeepAlive", (BYTE) proto->tlenOptions.sendKeepAlive);
 +			proto->tlenOptions.sendKeepAlive = IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE);
 +			db_set_b(NULL, proto->m_szModuleName, "KeepAlive", (BYTE) proto->tlenOptions.sendKeepAlive);
 -					useEncryption = IsDlgButtonChecked(hwndDlg, IDC_USE_SSL);
 -					if (db_get_b(NULL, proto->m_szModuleName, "UseEncryption", TRUE) != useEncryption)
 -						reconnectRequired = TRUE;
 -					db_set_b(NULL, proto->m_szModuleName, "UseEncryption", (BYTE) useEncryption);
 -
 -					db_set_b(NULL, proto->m_szModuleName, "VisibilitySupport", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_VISIBILITY_SUPPORT));
 -					// File transfer options
 -					db_set_b(NULL, proto->m_szModuleName, "UseFileProxy", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_USE_PROXY));
 -					db_set_w(NULL, proto->m_szModuleName, "FileProxyType", (WORD) SendDlgItemMessage(hwndDlg, IDC_FILE_PROXY_TYPE, CB_GETCURSEL, 0, 0));
 -					GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, sizeof(text));
 -					db_set_s(NULL, proto->m_szModuleName, "FileProxyHost", text);
 -					db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, NULL, FALSE));
 -					db_set_b(NULL, proto->m_szModuleName, "FileProxyAuth", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_PROXY_USE_AUTH));
 -					GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, sizeof(text));
 -					db_set_s(NULL, proto->m_szModuleName, "FileProxyUsername", text);
 -					GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, text, sizeof(text));
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(text), (LPARAM) text);
 -					db_set_s(NULL, proto->m_szModuleName, "FileProxyPassword", text);
 -					if (reconnectRequired && proto->isConnected)
 -						MessageBox(hwndDlg, TranslateT("These changes will take effect the next time you connect to the Tlen network."), TranslateT("Tlen Protocol Option"), MB_OK|MB_SETFOREGROUND);
 -					ApplyChanges(proto, 4);
 -					return TRUE;
 -				}
 -			}
 +			useEncryption = IsDlgButtonChecked(hwndDlg, IDC_USE_SSL);
 +			if (db_get_b(NULL, proto->m_szModuleName, "UseEncryption", TRUE) != useEncryption)
 +				reconnectRequired = TRUE;
 +			db_set_b(NULL, proto->m_szModuleName, "UseEncryption", (BYTE) useEncryption);
 +
 +			db_set_b(NULL, proto->m_szModuleName, "VisibilitySupport", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_VISIBILITY_SUPPORT));
 +
 +			// File transfer options
 +			db_set_b(NULL, proto->m_szModuleName, "UseFileProxy", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_USE_PROXY));
 +			db_set_w(NULL, proto->m_szModuleName, "FileProxyType", (WORD) SendDlgItemMessage(hwndDlg, IDC_FILE_PROXY_TYPE, CB_GETCURSEL, 0, 0));
 +
 +			GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_HOST, text, sizeof(text));
 +			db_set_s(NULL, proto->m_szModuleName, "FileProxyHost", text);
 +
 +			db_set_w(NULL, proto->m_szModuleName, "FileProxyPort", (WORD) GetDlgItemInt(hwndDlg, IDC_FILE_PROXY_PORT, NULL, FALSE));
 +			db_set_b(NULL, proto->m_szModuleName, "FileProxyAuth", (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FILE_PROXY_USE_AUTH));
 +
 +			GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_USER, text, sizeof(text));
 +			db_set_s(NULL, proto->m_szModuleName, "FileProxyUsername", text);
 +
 +			GetDlgItemTextA(hwndDlg, IDC_FILE_PROXY_PASSWORD, text, sizeof(text));
 +			db_set_s(NULL, proto->m_szModuleName, "FileProxyPassword", text);
 +
 +			if (reconnectRequired && proto->isConnected)
 +				MessageBox(hwndDlg, TranslateT("These changes will take effect the next time you connect to the Tlen network."), TranslateT("Tlen Protocol Option"), MB_OK|MB_SETFOREGROUND);
 +			ApplyChanges(proto, 4);
 +			return TRUE;
  		}
  		break;
 -	case WM_DESTROY:
 -		break;
  	}
  	return FALSE;
 diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index 88e561803b..c8ca8df1dd 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -470,12 +470,11 @@ HANDLE TlenP2PListen(TLEN_FILE_TRANSFER *ft)  			strcpy(sb.szPassword, "");
  			if (db_get_b(NULL, proto->m_szModuleName, "FileProxyAuth", FALSE)) {
  				sb.useAuth = TRUE;
 -				if (!db_get(NULL, proto->m_szModuleName, "FileProxyUsername", &dbv)) {
 +				if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyUsername", &dbv)) {
  					strcpy(sb.szUser, dbv.pszVal);
  					db_free(&dbv);
  				}
 -				if (!db_get(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
 -					CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
 +				if (!db_get_s(NULL, proto->m_szModuleName, "FileProxyPassword", &dbv)) {
  					strcpy(sb.szPassword, dbv.pszVal);
  					db_free(&dbv);
  				}
 diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index 42a34bfa5f..ca7bce7e61 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -167,21 +167,23 @@ void __cdecl TlenServerThread(ThreadData *info)  			QueueUserAPC(TlenPasswordCreateDialogApcProc, hMainThread, (DWORD) jidStr);
  			WaitForSingleObject(hEventPasswdDlg, INFINITE);
  			CloseHandle(hEventPasswdDlg);
 -			//if ((p=(char *)DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, TlenPasswordDlgProc, (LPARAM) jidStr)) != onlinePassword) {
 +			
  			if (onlinePassword[0] != (char) -1) {
  				strncpy(info->password, onlinePassword, sizeof(info->password));
  				info->password[sizeof(info->password)-1] = '\0';
 -			} else {
 +			}
 +			else {
  				info->proto->debugLogA("Thread ended, password request dialog was canceled");
  				loginErr = LOGINERR_BADUSERID;
  			}
 -		} else {
 +		}
 +		else {
  			if (!db_get(NULL, info->proto->m_szModuleName, "Password", &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM) dbv.pszVal);
  				strncpy(info->password, dbv.pszVal, sizeof(info->password));
  				info->password[sizeof(info->password)-1] = '\0';
  				db_free(&dbv);
 -			} else {
 +			}
 +			else {
  				info->proto->debugLogA("Thread ended, password is not configured");
  				loginErr = LOGINERR_BADUSERID;
  			}
 diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index c412e3ca5c..db2b2654d5 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -20,11 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.  TCHAR* CVkProto::GetUserStoredPassword()
  {
  	ptrA szRawPass( getStringA("Password"));
 -	if (szRawPass != NULL) {
 -		CallService(MS_DB_CRYPT_DECODESTRING, strlen(szRawPass), szRawPass);
 -		return mir_utf8decodeT(szRawPass);
 -	}
 -	return NULL;
 +	return (szRawPass != NULL) ? mir_utf8decodeT(szRawPass) : NULL;
  }
  void CVkProto::SetAllContactStatuses(int iStatus)
 diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp index c8d7ed7796..ae722029c4 100644 --- a/protocols/VKontakte/src/vk_options.cpp +++ b/protocols/VKontakte/src/vk_options.cpp @@ -68,10 +68,8 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP  			GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
  			ptrA szRawPasswd( mir_utf8encodeT(str));
 -			if (szRawPasswd != NULL) {
 -				CallService(MS_DB_CRYPT_ENCODESTRING, strlen(szRawPasswd), szRawPasswd);
 +			if (szRawPasswd != NULL)
  				ppro->setString("Password", szRawPasswd);
 -			}
  		}
  		break;
 diff --git a/protocols/WhatsApp/src/connection.cpp b/protocols/WhatsApp/src/connection.cpp index 9aae55ac32..5fc08ec1dc 100644 --- a/protocols/WhatsApp/src/connection.cpp +++ b/protocols/WhatsApp/src/connection.cpp @@ -87,8 +87,6 @@ void WhatsAppProto::stayConnectedLoop(void*)  	error = true;
  	if ( !getString(WHATSAPP_KEY_PASS, &dbv))
  	{
 -		CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
 -			reinterpret_cast<LPARAM>(dbv.pszVal));
  		pass = dbv.pszVal;
  		db_free(&dbv);
  		error = pass.empty();
 diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index 73f420f2f0..6a909346a8 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -4,8 +4,7 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPA  {
  	WhatsAppProto *proto;
 -	switch (message)
 -	{
 +	switch (message) {
  	case WM_INITDIALOG:
  		TranslateDialogDefault(hwnd);
 @@ -36,17 +35,15 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPA  		if ( !db_get_s(0,proto->ModuleName(),WHATSAPP_KEY_PASS,&dbv,DBVT_ASCIIZ))
  		{
 -			CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
 -				reinterpret_cast<LPARAM>(dbv.pszVal));
  			SetDlgItemTextA(hwnd,IDC_PW,dbv.pszVal);
  			db_free(&dbv);
  		}
  		if (!proto->isOffline()) {
 -			SendMessage(GetDlgItem(hwnd,IDC_CC),EM_SETREADONLY,1,0);
 -			SendMessage(GetDlgItem(hwnd,IDC_LOGIN),EM_SETREADONLY,1,0);
 -			SendMessage(GetDlgItem(hwnd,IDC_NICK),EM_SETREADONLY,1,0);
 -			SendMessage(GetDlgItem(hwnd,IDC_PW),EM_SETREADONLY,1,0);
 +			SendMessage(GetDlgItem(hwnd, IDC_CC), EM_SETREADONLY, 1, 0);
 +			SendMessage(GetDlgItem(hwnd, IDC_LOGIN), EM_SETREADONLY, 1, 0);
 +			SendMessage(GetDlgItem(hwnd, IDC_NICK), EM_SETREADONLY, 1, 0);
 +			SendMessage(GetDlgItem(hwnd, IDC_PW), EM_SETREADONLY, 1, 0);
  			EnableWindow(GetDlgItem(hwnd, IDC_SSL), FALSE);
  		}
 @@ -88,7 +85,6 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPA  				string pw = proto->Register(REG_STATE_REG_CODE, string(cc), string(number), string(code));
  				if (!pw.empty())
  				{
 -					CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(pw.c_str()), (LPARAM)pw.c_str());
  					proto->setString(WHATSAPP_KEY_PASS, pw.c_str());
  					MessageBox(NULL, TranslateT("Your password has been set automatically.\nIf you change your password manually you may lose it and need to request a new code!"), PRODUCT_NAME, MB_ICONWARNING);
  				}
 @@ -127,7 +123,6 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPA  			db_set_b(0, proto->ModuleName(), WHATSAPP_KEY_SSL, IsDlgButtonChecked(hwnd, IDC_SSL));
  			GetDlgItemTextA(hwnd,IDC_PW,str,sizeof(str));
 -			CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),reinterpret_cast<LPARAM>(str));
  			db_set_s(0,proto->ModuleName(),WHATSAPP_KEY_PASS,str);
  			return TRUE;
 diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp index c76e364f38..9adbe4290b 100644 --- a/protocols/Xfire/src/main.cpp +++ b/protocols/Xfire/src/main.cpp @@ -1517,49 +1517,17 @@ INT_PTR SetStatus(WPARAM wParam,LPARAM lParam)  			}
  			else
  			{
 -				CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv2.pszVal)+1,(LPARAM)dbv2.pszVal);
 -
  				if(myClient!=NULL)
  					delete myClient;
 -				//alter proxycode, entfernt da über netlib die proxysache geregelt wird
 -				/* if(db_get_b(NULL, protocolname, "useproxy" ,0))
 -				{
 -					//verbindung über proxy
 -					DBVARIANT dbv3;
 -					DBVARIANT dbv4;
 -					if(!db_get(NULL,protocolname,"proxyip",&dbv3))
 -					{
 -						if(!db_get(NULL,protocolname,"proxyport",&dbv4))
 -						{
 -							myClient = new XFireClient(dbv.pszVal,dbv2.pszVal,db_get_b(NULL,protocolname,"protover",0),1,dbv3.pszVal,atoi(dbv4.pszVal));
 -							db_free(&dbv4);
 -						}
 -						db_free(&dbv3);
 -					}
 -				}
 -				else */
 -					myClient = new XFireClient(dbv.pszVal,dbv2.pszVal,db_get_b(NULL,protocolname,"protover",0));
 +				myClient = new XFireClient(dbv.pszVal,dbv2.pszVal,db_get_b(NULL,protocolname,"protover",0));
  				//verbindung als thread
  				bpStatus = ID_STATUS_CONNECTING;
  				ProtoBroadcastAck(protocolname,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,ID_STATUS_CONNECTING);
  				mir_forkthread(ConnectingThread,(LPVOID)wParam);
 -				//alte verb
 -				/*
 -				myClient->run();
 -				if(myClient->client->connected)
 -				{
 -					sendonrecieve=TRUE;
 -				}
 -				else
 -				{
 -					MSGBOXE(Translate("Unable to connect to XFire."));
 -					wParam =ID_STATUS_OFFLINE;
 -				}
 -				*/
  				//für die vars
  				db_unset(NULL,protocolname,"currentgamename");
  				db_unset(NULL,protocolname,"currentvoicename");
 diff --git a/protocols/Xfire/src/options.cpp b/protocols/Xfire/src/options.cpp index 9d7e519e93..004242dc63 100644 --- a/protocols/Xfire/src/options.cpp +++ b/protocols/Xfire/src/options.cpp @@ -179,7 +179,6 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  			}
  			if(!db_get(NULL,protocolname,"password",&dbv)) {
  				//bit of a security hole here, since it's easy to extract a password from an edit box
 -				CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,(LPARAM)dbv.pszVal);
  				SetDlgItemTextA(hwndDlg,IDC_PASSWORD,dbv.pszVal);
  				db_free(&dbv);
  			}
 @@ -298,8 +297,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR  					if(dbv.pszVal!=NULL) db_free(&dbv);
  					GetDlgItemTextA(hwndDlg,IDC_PASSWORD,str,sizeof(str));
 -					CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(str),(LPARAM)str);
 -					dbv.pszVal=NULL;
 +					dbv.pszVal = NULL;
  					if(db_get(NULL,protocolname,"password",&dbv) || strcmp(str,dbv.pszVal))
  						reconnectRequired=1;
  					if(dbv.pszVal!=NULL) db_free(&dbv);
 diff --git a/protocols/Yahoo/src/options.cpp b/protocols/Yahoo/src/options.cpp index d53e46b965..f0fdfe9611 100644 --- a/protocols/Yahoo/src/options.cpp +++ b/protocols/Yahoo/src/options.cpp @@ -48,7 +48,6 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam,  		if ( !ppro->getString( YAHOO_PASSWORD, &dbv)) {
  			//bit of a security hole here, since it's easy to extract a password from an edit box
 -			CallService(MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, (LPARAM)dbv.pszVal);
  			SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal );
  			db_free(&dbv);
  		}
 @@ -110,7 +109,6 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam,  			ppro->setString( YAHOO_LOGINID, str );
  			GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof( str ));
 -			CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM)str);
  			dbv.pszVal = NULL;
  			if ( ppro->getString( YAHOO_PASSWORD, &dbv) || lstrcmpA( str, dbv.pszVal ))
  				reconnectRequired = true;
 diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 9c7be6525d..c7e3821ab8 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -440,28 +440,29 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus )  		* Load Yahoo ID from the database.
  		*/
  		if (!getString(YAHOO_LOGINID, &dbv)) {
 -			if (lstrlenA(dbv.pszVal) > 0) {
 +			if (lstrlenA(dbv.pszVal) > 0)
  				lstrcpynA(m_yahoo_id, dbv.pszVal, 255);
 -			} else
 +			else
  				err++;
  			db_free(&dbv);
 -		} else {
 +		}
 +		else {
  			ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID);
  			err++;
  		}
 -		if (err) {
 +		if (err)
  			lstrcpynA(errmsg, Translate("Please enter your Yahoo ID in Options/Network/Yahoo"), 80);
 -		} else {
 +		else {
  			if (!getString(YAHOO_PASSWORD, &dbv)) {
 -				CallService(MS_DB_CRYPT_DECODESTRING, lstrlenA(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 -				if (lstrlenA(dbv.pszVal) > 0) {
 +				if (lstrlenA(dbv.pszVal) > 0)
  					lstrcpynA(m_password, dbv.pszVal, 255);
 -				} else
 +				else
  					err++;
  				db_free(&dbv);
 -			}  else  {
 +			}
 +			else  {
  				ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
  				err++;
  			}
 @@ -483,9 +484,8 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus )  		FREE(m_pw_token); // No Token yet.
  		if (!getString(YAHOO_PWTOKEN, &dbv)) {
 -			if (lstrlenA(dbv.pszVal) > 0) {
 +			if (lstrlenA(dbv.pszVal) > 0)
  				m_pw_token = strdup(dbv.pszVal);
 -			}
  			db_free(&dbv);
  		}
 @@ -719,33 +719,29 @@ int __cdecl CYahooProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARA  INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  {
 -	switch (msg)
 -	{
 +	DBVARIANT dbv;
 +	CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 +
 +	switch (msg) {
  	case WM_INITDIALOG:
 -		{
 -			TranslateDialogDefault(hwndDlg);
 +		TranslateDialogDefault(hwndDlg);
 -			CYahooProto* ppro = (CYahooProto*)lParam;
 -			SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
 +		ppro = (CYahooProto*)lParam;
 +		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
 -			DBVARIANT dbv;
 -			if ( !ppro->getString(YAHOO_LOGINID, &dbv))
 -			{
 -				SetDlgItemTextA(hwndDlg, IDC_HANDLE, dbv.pszVal);
 -				db_free(&dbv);
 -			}
 -
 -			if ( !ppro->getString(YAHOO_PASSWORD, &dbv))
 -			{
 -				CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
 -				SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
 -				db_free(&dbv);
 -			}
 +		if ( !ppro->getString(YAHOO_LOGINID, &dbv)) {
 +			SetDlgItemTextA(hwndDlg, IDC_HANDLE, dbv.pszVal);
 +			db_free(&dbv);
 +		}
 -			SetButtonCheck(hwndDlg, IDC_YAHOO_JAPAN, ppro->getByte("YahooJapan", 0));
 -			return TRUE;
 +		if ( !ppro->getString(YAHOO_PASSWORD, &dbv)) {
 +			SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
 +			db_free(&dbv);
  		}
 +		SetButtonCheck(hwndDlg, IDC_YAHOO_JAPAN, ppro->getByte("YahooJapan", 0));
 +		return TRUE;
 +
  	case WM_COMMAND:
  		if ( LOWORD( wParam ) == IDC_NEWYAHOOACCOUNTLINK ) {
  			CallService(MS_UTILS_OPENURL,
 @@ -769,11 +765,8 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM  		break;
  	case WM_NOTIFY:
 -		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY )
 -		{
 -			CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
 +		if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY ) {
  			char str[128];
 -			DBVARIANT dbv;
  			BOOL reconnectRequired = FALSE;
  			GetDlgItemTextA(hwndDlg, IDC_HANDLE, str, sizeof(str));
 @@ -798,7 +791,6 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM  			if (reconnectRequired)
  				ppro->delSetting(YAHOO_PWTOKEN);
 -			CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
  			ppro->setString(YAHOO_PASSWORD, str);
  			ppro->setByte("YahooJapan", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_YAHOO_JAPAN ));
 diff --git a/src/mir_core/db.cpp b/src/mir_core/db.cpp index 7d6491c1e0..c4305ae33c 100644 --- a/src/mir_core/db.cpp +++ b/src/mir_core/db.cpp @@ -120,7 +120,7 @@ MIR_CORE_DLL(char*) db_get_sa(HANDLE hContact, const char *szModule, const char  	db_get_s(hContact, szModule, szSetting, &dbv, DBVT_ASCIIZ);
  	if (dbv.type == DBVT_ASCIIZ)
  		str = mir_strdup(dbv.pszVal);
 -	db_free(&dbv);
 +		db_free(&dbv);
  	return str;
  }
 diff --git a/src/modules/crypt/encrypt.cpp b/src/modules/crypt/encrypt.cpp index 3e5da905ee..2868eb41c4 100644 --- a/src/modules/crypt/encrypt.cpp +++ b/src/modules/crypt/encrypt.cpp @@ -23,32 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  #include "..\..\core\commonheaders.h"
 -//VERY VERY VERY BASIC ENCRYPTION FUNCTION
 -
 -void Encrypt(char*msg, BOOL up)
 -{
 -	int jump;
 -	if (up)
 -		jump = 5;
 -	else
 -		jump = -5;
 -
 -	for (int i = 0; msg[i]; i++)
 -		msg[i] = msg[i] + jump;
 -}
 -
 -static INT_PTR EncodeString(WPARAM wParam, LPARAM lParam)
 -{
 -	Encrypt((char*)lParam, TRUE);
 -	return 0;
 -}
 -
 -static INT_PTR DecodeString(WPARAM wParam, LPARAM lParam)
 -{
 -	Encrypt((char*)lParam, FALSE);
 -	return 0;
 -}
 -
  /////////////////////////////////////////////////////////////////////////////////////////
  static int CompareFunc(const CRYPTO_PROVIDER *p1, const CRYPTO_PROVIDER *p2)
 @@ -97,9 +71,6 @@ static INT_PTR srvGetProvider(WPARAM wParam, LPARAM lParam)  int InitCrypt(void)
  {
 -	CreateServiceFunction(MS_DB_CRYPT_ENCODESTRING, EncodeString);
 -	CreateServiceFunction(MS_DB_CRYPT_DECODESTRING, DecodeString);
 -
  	CreateServiceFunction(MS_CRYPTO_REGISTER_ENGINE, srvRegister);
  	CreateServiceFunction(MS_CRYPTO_ENUM_PROVIDERS,  srvEnumProviders);
  	CreateServiceFunction(MS_CRYPTO_GET_PROVIDER,    srvGetProvider);
 diff --git a/src/modules/netlib/netlib.cpp b/src/modules/netlib/netlib.cpp index 58cd922864..10c87ad5c0 100644 --- a/src/modules/netlib/netlib.cpp +++ b/src/modules/netlib/netlib.cpp @@ -122,16 +122,13 @@ static INT_PTR GetNetlibUserSettingInt(const char *szUserModule, const char *szS  	return dbv.dVal;
  }
 -static char *GetNetlibUserSettingString(const char *szUserModule, const char *szSetting, int decode)
 +static char *GetNetlibUserSettingString(const char *szUserModule, const char *szSetting)
  {
 -	DBVARIANT dbv;
 -	if (db_get_s(NULL, szUserModule, szSetting, &dbv) && db_get_s(NULL, "Netlib", szSetting, &dbv))
 -		return NULL;
 +	char *szRet = db_get_sa(NULL, szUserModule, szSetting);
 +	if (szRet == NULL)
 +		if ((szRet = db_get_sa(NULL, "Netlib", szSetting)) == NULL)
 +			return NULL;
 -	if (decode) CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
 -	char *szRet = mir_strdup(dbv.pszVal);
 -	db_free(&dbv);
 -	if (szRet == NULL) SetLastError(ERROR_OUTOFMEMORY);
  	return szRet;
  }
 @@ -186,16 +183,16 @@ static INT_PTR NetlibRegisterUser(WPARAM, LPARAM lParam)  		thisUser->settings.useProxy = 0;
  		thisUser->settings.proxyType = PROXYTYPE_SOCKS5;
  	}
 -	thisUser->settings.szProxyServer = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyServer", 0);
 +	thisUser->settings.szProxyServer = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyServer");
  	thisUser->settings.wProxyPort = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLProxyPort", 1080);
  	thisUser->settings.useProxyAuth = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxyAuth", 0);
 -	thisUser->settings.szProxyAuthUser = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthUser", 0);
 -	thisUser->settings.szProxyAuthPassword = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthPassword", 1);
 +	thisUser->settings.szProxyAuthUser = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthUser");
 +	thisUser->settings.szProxyAuthPassword = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLProxyAuthPassword");
  	thisUser->settings.dnsThroughProxy = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLDnsThroughProxy", 1);
  	thisUser->settings.specifyIncomingPorts = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyIncomingPorts", 0);
 -	thisUser->settings.szIncomingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLIncomingPorts", 0);
 +	thisUser->settings.szIncomingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLIncomingPorts");
  	thisUser->settings.specifyOutgoingPorts = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLSpecifyOutgoingPorts", 0);
 -	thisUser->settings.szOutgoingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLOutgoingPorts", 0);
 +	thisUser->settings.szOutgoingPorts = GetNetlibUserSettingString(thisUser->user.szSettingsModule, "NLOutgoingPorts");
  	thisUser->settings.enableUPnP = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLEnableUPnP", 1); //default to on
  	thisUser->settings.validateSSL = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLValidateSSL", 0);
 diff --git a/src/modules/netlib/netlibopts.cpp b/src/modules/netlib/netlibopts.cpp index 1c81da3c41..67a67c5b2a 100644 --- a/src/modules/netlib/netlibopts.cpp +++ b/src/modules/netlib/netlibopts.cpp @@ -196,7 +196,6 @@ static void ChangeSettingStringByEdit(HWND hwndDlg, UINT ctrlId, int iUser, int  static void WriteSettingsStructToDb(const char *szSettingsModule, NETLIBUSERSETTINGS *settings, DWORD flags)
  {
  	if (flags & NUF_OUTGOING) {
 -		char szEncodedPassword[512];
  		db_set_b(NULL, szSettingsModule, "NLValidateSSL", (BYTE)settings->validateSSL);
  		db_set_b(NULL, szSettingsModule, "NLUseProxy", (BYTE)settings->useProxy);
  		db_set_b(NULL, szSettingsModule, "NLProxyType", (BYTE)settings->proxyType);
 @@ -204,9 +203,7 @@ static void WriteSettingsStructToDb(const char *szSettingsModule, NETLIBUSERSETT  		db_set_w(NULL, szSettingsModule, "NLProxyPort", (WORD)settings->wProxyPort);
  		db_set_b(NULL, szSettingsModule, "NLUseProxyAuth", (BYTE)settings->useProxyAuth);
  		db_set_s(NULL, szSettingsModule, "NLProxyAuthUser", settings->szProxyAuthUser?settings->szProxyAuthUser:"");
 -		lstrcpynA(szEncodedPassword, settings->szProxyAuthPassword?settings->szProxyAuthPassword:"", SIZEOF(szEncodedPassword));
 -		CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(szEncodedPassword), (LPARAM)szEncodedPassword);
 -		db_set_s(NULL, szSettingsModule, "NLProxyAuthPassword", szEncodedPassword);
 +		db_set_s(NULL, szSettingsModule, "NLProxyAuthPassword", settings->szProxyAuthPassword?settings->szProxyAuthPassword:"");
  		db_set_b(NULL, szSettingsModule, "NLDnsThroughProxy", (BYTE)settings->dnsThroughProxy);
  		db_set_b(NULL, szSettingsModule, "NLSpecifyOutgoingPorts", (BYTE)settings->specifyOutgoingPorts);
  		db_set_s(NULL, szSettingsModule, "NLOutgoingPorts", settings->szOutgoingPorts?settings->szOutgoingPorts:"");
  | 
