diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/TabSRMM/src/chat/log.cpp | 6 | ||||
| -rw-r--r-- | plugins/TipperYM/src/message_pump.cpp | 4 | ||||
| -rw-r--r-- | plugins/TipperYM/src/popwin.cpp | 76 | ||||
| -rw-r--r-- | plugins/TipperYM/src/subst.cpp | 173 | ||||
| -rw-r--r-- | plugins/Utils/mir_buffer.h | 26 | 
5 files changed, 119 insertions, 166 deletions
| diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 9e2a5c573e..19e37c2676 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -989,9 +989,9 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedra  		fi.chrg.cpMin = 0;
  		fi.chrg.cpMax = -1;
  		if (SendMessage(hwndRich, EM_FINDTEXTEX, FR_DOWN, (LPARAM)&fi) != 0) {
 -			CHARRANGE sel;
 -			sel.cpMin = 0;
 -			sel.cpMax = 20;
 +			CHARRANGE rng;
 +			rng.cpMin = 0;
 +			rng.cpMax = 20;
  			SendMessage(hwndRich, EM_SETSEL, 0, fi.chrgText.cpMax + 1);
  			SendMessage(hwndRich, EM_REPLACESEL, TRUE, (LPARAM)_T(""));
  		}
 diff --git a/plugins/TipperYM/src/message_pump.cpp b/plugins/TipperYM/src/message_pump.cpp index fa9f32515d..949d5d9603 100644 --- a/plugins/TipperYM/src/message_pump.cpp +++ b/plugins/TipperYM/src/message_pump.cpp @@ -48,7 +48,7 @@ bool NeedWaitForContent(CLCINFOTIPEX *clcitex)  	bool bNeedWait = false;
  	if (opt.bWaitForContent && IsContactTooltip(clcitex))
  	{
 -		MCONTACT hContact = (MCONTACT) clcitex->hItem;
 +		MCONTACT hContact = (DWORD_PTR)clcitex->hItem;
  		char *szProto = GetContactProto(hContact);
  		if (!szProto) return false;
 @@ -157,7 +157,7 @@ unsigned int CALLBACK MessagePumpThread(void*)  					}
  					if (swzMsg) {
 -						db_set_ts((MCONTACT)clcitex->hItem, MODULE, "TempStatusMsg", swzMsg);
 +						db_set_ts((DWORD_PTR)clcitex->hItem, MODULE, "TempStatusMsg", swzMsg);
  						mir_free(swzMsg);
  					}
 diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 15b6f6f7f9..8907f068b1 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -37,10 +37,11 @@ __inline void AddRow(PopupWindowData *pwd, TCHAR *swzLabel, TCHAR *swzValue, cha  LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)   { +	POINT pt;  	RECT rc;  	PopupWindowData *pwd = (PopupWindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA); -	switch(uMsg) { +	switch (uMsg) {  	case WM_CREATE:  		{  			CREATESTRUCT *cs = (CREATESTRUCT *)lParam; @@ -126,11 +127,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  				if (wStatus >= ID_STATUS_ONLINE && wStatus <= ID_STATUS_OUTTOLUNCH) {  					// status message -					TCHAR *swzText = GetProtoStatusMessage(pwd->clcit.szProto, wStatus); -					if (swzText) { -						StripBBCodesInPlace(swzText); -						AddRow(pwd, TranslateT("Status message:"), swzText, pwd->clcit.szProto, true, true, true); -						mir_free(swzText); +					ptrT ptszStatus(GetProtoStatusMessage(pwd->clcit.szProto, wStatus)); +					if (ptszStatus) { +						StripBBCodesInPlace(ptszStatus); +						AddRow(pwd, TranslateT("Status message:"), ptszStatus, pwd->clcit.szProto, true, true, true);  					}  					// jabber mood or icq xstatus @@ -139,11 +139,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  						StripBBCodesInPlace(swzAdvTitle);  						AddRow(pwd, TranslateT("Mood:"), swzAdvTitle, pwd->clcit.szProto, true, false, true); -						TCHAR *swzAdvText = GetJabberAdvStatusText(pwd->clcit.szProto, "mood", "text"); +						ptrT swzAdvText(GetJabberAdvStatusText(pwd->clcit.szProto, "mood", "text"));  						if (swzAdvText) {  							StripBBCodesInPlace(swzAdvText);  							AddRow(pwd, _T(""), swzAdvText, pwd->clcit.szProto, true, true, false); -							mir_free(swzAdvText);  						}  					}  					else { @@ -156,11 +155,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  							}  							// xstatus message -							TCHAR *swzAdvText = GetProtoExtraStatusMessage(pwd->clcit.szProto); +							ptrT swzAdvText(GetProtoExtraStatusMessage(pwd->clcit.szProto));  							if (swzAdvText) {  								StripBBCodesInPlace(swzAdvText);  								AddRow(pwd, _T(""), swzAdvText, pwd->clcit.szProto, true, true, false); -								mir_free(swzAdvText);  							}  						}  					} @@ -175,26 +173,23 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  					}  					// jabber activity -					TCHAR *swzActTitle = GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "title"); +					ptrT swzActTitle(GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "title"));  					if (swzActTitle) {  						StripBBCodesInPlace(swzActTitle);  						AddRow(pwd, TranslateT("Activity:"), swzActTitle, pwd->clcit.szProto, true, false, true); -						mir_free(swzActTitle);  					} -					TCHAR *swzActText = GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "text"); +					ptrT swzActText(GetJabberAdvStatusText(pwd->clcit.szProto, "activity", "text"));  					if (swzActText) {  						StripBBCodesInPlace(swzActText);  						AddRow(pwd, _T(""), swzActText, pwd->clcit.szProto, true, true, false); -						mir_free(swzActText);  					}  					// listening to -					TCHAR *swzListening = GetListeningTo(pwd->clcit.szProto); +					ptrT swzListening(GetListeningTo(pwd->clcit.szProto));  					if (swzListening) {  						StripBBCodesInPlace(swzListening);  						AddRow(pwd, TranslateT("Listening to:"), swzListening, NULL, false, true, true); -						mir_free(swzListening);  					}  				}  			} @@ -304,22 +299,20 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  				pwd->bIsTextTip = false;  				pwd->iIndent = opt.iTextIndent;  				pwd->iSidebarWidth = opt.iSidebarWidth; -				pwd->hContact = (MCONTACT)pwd->clcit.hItem; +				pwd->hContact = (DWORD_PTR)pwd->clcit.hItem;  				pwd->iIconIndex = (int)CallService(MS_CLIST_GETCONTACTICON, pwd->hContact, 0);  				// don't use stored status message  				if (!opt.bWaitForContent)  					db_unset(pwd->hContact, MODULE, "TempStatusMsg"); -				TCHAR *swzNick = pcli->pfnGetContactDisplayName(pwd->hContact, 0); -				_tcsncpy(pwd->swzTitle, swzNick, TITLE_TEXT_LEN); +				_tcsncpy_s(pwd->swzTitle, pcli->pfnGetContactDisplayName(pwd->hContact, 0), _TRUNCATE);  				char *szProto = GetContactProto(pwd->hContact);  				pwd->spiTitle = Smileys_PreParse(pwd->swzTitle, -1, szProto);  				// get extra icons -				DBVARIANT dbv = { 0 }; -				int i = 0; +				int i;  				if (szProto) {  					// status icon @@ -336,10 +329,13 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  						if (iXstatus) {  							char szIconProto[64];  							if (mir_strcmp(szProto, META_PROTO) != 0) -								strncpy(szIconProto, szProto, sizeof(szIconProto) - 1); -							else if (!db_get_s(pwd->hContact, szProto, "XStatusProto", &dbv)) { -								strncpy(szIconProto, dbv.pszVal, sizeof(szIconProto) - 1); -								db_free(&dbv); +								strncpy_s(szIconProto, szProto, _TRUNCATE); +							else { +								ptrA szXProto(db_get_sa(pwd->hContact, szProto, "XStatusProto")); +								if (szXProto != NULL) +									strncpy_s(szIconProto, szXProto, _TRUNCATE); +								else +									szIconProto[0] = 0;  							}  							pwd->extraIcons[i].hIcon = (HICON)CallProtoService(szIconProto, PS_GETCUSTOMSTATUSICON, (WPARAM)iXstatus, LR_SHARED); @@ -386,10 +382,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  					if (pwd->bIsIconVisible[5]) {  						for (i = 0; opt.exIconsOrder[i] != 5; i++);  						if (ServiceExists(MS_FP_GETCLIENTICONT)) { -							if (!db_get_ts(pwd->hContact, szProto, "MirVer", &dbv)) { -								pwd->extraIcons[i].hIcon = Finger_GetClientIcon(dbv.ptszVal, 0); +							ptrT tszVersion(db_get_tsa(pwd->hContact, szProto, "MirVer")); +							if (tszVersion != NULL) { +								pwd->extraIcons[i].hIcon = Finger_GetClientIcon(tszVersion, 0);  								pwd->extraIcons[i].bDestroy = true; -								db_free(&dbv);  							}  						}  					} @@ -425,7 +421,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  			// since tipper win is topmost, this should put it at top of topmost windows  			SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); -	} +		}  		return 0;  	case WM_ERASEBKGND: @@ -487,7 +483,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  					rcAvatar.right = rcAvatar.left + pwd->iRealAvatarWidth;  					r2.left += pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); // padding re-added for text  				} -				else if (opt.avatarLayout == PAV_RIGHT) { +				else {  					rcAvatar.right = r.right - opt.iOuterAvatarPadding;  					rcAvatar.left = rcAvatar.right - pwd->iRealAvatarWidth;  					r2.right -= pwd->iRealAvatarWidth + (opt.iOuterAvatarPadding + opt.iInnerAvatarPadding - opt.iPadding); @@ -786,7 +782,6 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  				}  			} -			POINT pt;  			GetCursorPos(&pt);  			SetForegroundWindow(hwnd);  			int iSelItem = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, 0); @@ -953,16 +948,14 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  			SendMessage(hwnd, PUM_UPDATERGN, 1, 0);  			break;  		case ID_TIMER_CHECKMOUSE: -		{ -			// workaround for tips that just won't go away -			POINT pt; - -			GetCursorPos(&pt); -			// mouse has moved beyond tollerance -			if (abs(pt.x - pwd->ptCursorStartPos.x) > opt.iMouseTollerance || abs(pt.y - pwd->ptCursorStartPos.y) > opt.iMouseTollerance) -				PostMPMessage(MUM_DELETEPOPUP, 0, 0); -		} -		break; +			{ +				// workaround for tips that just won't go away +				GetCursorPos(&pt); +				// mouse has moved beyond tollerance +				if (abs(pt.x - pwd->ptCursorStartPos.x) > opt.iMouseTollerance || abs(pt.y - pwd->ptCursorStartPos.y) > opt.iMouseTollerance) +					PostMPMessage(MUM_DELETEPOPUP, 0, 0); +			} +			break;  		case ID_TIMER_TRAYTIP:  			KillTimer(hwnd, ID_TIMER_TRAYTIP);  			SendMessage(hwnd, PUM_EXPANDTRAYTIP, 0, 0); @@ -1454,7 +1447,6 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa  			Smileys_FreeParse(pwd->rows[i].spi);  		} -  		mir_free(pwd->rows);  		pwd->rows = NULL;  		pwd->iRowCount = 0; diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index f149ba63e5..10335265d9 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -76,44 +76,44 @@ bool CheckContactType(MCONTACT hContact, const DISPLAYITEM &di)  	return false;  } -void StripBBCodesInPlace(TCHAR *swzText) +void StripBBCodesInPlace(TCHAR *ptszText)  {  	if (!db_get_b(0, MODULE, "StripBBCodes", 1))  		return; -	if (swzText == 0) +	if (ptszText == 0)  		return;  	size_t iRead = 0, iWrite = 0; -	size_t iLen = mir_tstrlen(swzText); +	size_t iLen = mir_tstrlen(ptszText);  	while(iRead <= iLen) { // copy terminating null too -		while (iRead <= iLen && swzText[iRead] != '[') { -			if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead]; +		while (iRead <= iLen && ptszText[iRead] != '[') { +			if (ptszText[iRead] != ptszText[iWrite]) ptszText[iWrite] = ptszText[iRead];  			iRead++; iWrite++;  		}  		if (iRead > iLen)  			break; -		if (iLen - iRead >= 3 && (_tcsnicmp(swzText + iRead, _T("[b]"), 3) == 0 || _tcsnicmp(swzText + iRead, _T("[i]"), 3) == 0)) +		if (iLen - iRead >= 3 && (_tcsnicmp(ptszText + iRead, _T("[b]"), 3) == 0 || _tcsnicmp(ptszText + iRead, _T("[i]"), 3) == 0))  			iRead += 3; -		else if (iLen - iRead >= 4 && (_tcsnicmp(swzText + iRead, _T("[/b]"), 4) == 0 || _tcsnicmp(swzText + iRead, _T("[/i]"), 4) == 0)) +		else if (iLen - iRead >= 4 && (_tcsnicmp(ptszText + iRead, _T("[/b]"), 4) == 0 || _tcsnicmp(ptszText + iRead, _T("[/i]"), 4) == 0))  			iRead += 4; -		else if (iLen - iRead >= 6 && (_tcsnicmp(swzText + iRead, _T("[color"), 6) == 0)) { -			while (iRead < iLen && swzText[iRead] != ']') iRead++; +		else if (iLen - iRead >= 6 && (_tcsnicmp(ptszText + iRead, _T("[color"), 6) == 0)) { +			while (iRead < iLen && ptszText[iRead] != ']') iRead++;  			iRead++;// skip the ']'  		} -		else if (iLen - iRead >= 8 && (_tcsnicmp(swzText + iRead, _T("[/color]"), 8) == 0)) +		else if (iLen - iRead >= 8 && (_tcsnicmp(ptszText + iRead, _T("[/color]"), 8) == 0))  			iRead += 8; -		else if (iLen - iRead >= 5 && (_tcsnicmp(swzText + iRead, _T("[size"), 5) == 0)) { -			while (iRead < iLen && swzText[iRead] != ']') iRead++; +		else if (iLen - iRead >= 5 && (_tcsnicmp(ptszText + iRead, _T("[size"), 5) == 0)) { +			while (iRead < iLen && ptszText[iRead] != ']') iRead++;  			iRead++;// skip the ']'  		} -		else if (iLen - iRead >= 7 && (_tcsnicmp(swzText + iRead, _T("[/size]"), 7) == 0)) +		else if (iLen - iRead >= 7 && (_tcsnicmp(ptszText + iRead, _T("[/size]"), 7) == 0))  			iRead += 7;  		else { -			if (swzText[iRead] != swzText[iWrite]) swzText[iWrite] = swzText[iRead]; +			if (ptszText[iRead] != ptszText[iWrite]) ptszText[iWrite] = ptszText[iRead];  			iRead++; iWrite++;  		}  	} @@ -162,7 +162,7 @@ bool UidName(char *szProto, TCHAR *buff, int bufflen)  	return false;  } -TCHAR *GetLastMessageText(MCONTACT hContact, bool received) +TCHAR* GetLastMessageText(MCONTACT hContact, bool received)  {  	for (MEVENT hDbEvent = db_event_last(hContact); hDbEvent; hDbEvent = db_event_prev(hContact, hDbEvent)) {  		DBEVENTINFO dbei = {	sizeof(dbei) }; @@ -673,17 +673,17 @@ bool GetValueText(MCONTACT hContact, const DISPLAYITEM &di, TCHAR *buff, size_t  	return ApplySubst(hContact, di.swzValue, di.bParseTipperVarsFirst, buff, bufflen);  } -void TruncateString(TCHAR *swzText) +void TruncateString(TCHAR *ptszText)  { -	if (swzText && opt.iLimitCharCount > 3) { -		if ((int)mir_tstrlen(swzText) > opt.iLimitCharCount) { -			swzText[opt.iLimitCharCount - 3] = 0; -			mir_tstrcat(swzText, _T("...")); +	if (ptszText && opt.iLimitCharCount > 3) { +		if ((int)mir_tstrlen(ptszText) > opt.iLimitCharCount) { +			ptszText[opt.iLimitCharCount - 3] = 0; +			mir_tstrcat(ptszText, _T("..."));  		}  	}  } -TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus) +TCHAR* GetProtoStatusMessage(char *szProto, WORD wStatus)  {  	if (!szProto || wStatus == ID_STATUS_OFFLINE)  		return NULL; @@ -693,150 +693,115 @@ TCHAR *GetProtoStatusMessage(char *szProto, WORD wStatus)  	if (!(flags & Proto_Status2Flag(wStatus)))  		return NULL; -	TCHAR *swzText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); -	if ((INT_PTR)swzText == CALLSERVICE_NOTFOUND) -		swzText = (TCHAR *)CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, (LPARAM)szProto); +	TCHAR *ptszText = (TCHAR *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, SGMA_TCHAR); +	if ((INT_PTR)ptszText == CALLSERVICE_NOTFOUND) +		ptszText = (TCHAR *)CallService(MS_AWAYMSG_GETSTATUSMSGT, wStatus, (LPARAM)szProto); -	else if (swzText == NULL) { +	else if (ptszText == NULL) {  		// try to use service without SGMA_TCHAR  		char *tmpMsg = (char *)CallProtoService(szProto, PS_GETMYAWAYMSG, 0, 0);  		if (tmpMsg && (INT_PTR)tmpMsg != CALLSERVICE_NOTFOUND) { -			swzText = mir_a2t(tmpMsg); +			ptszText = mir_a2t(tmpMsg);  			mir_free(tmpMsg);  		}  	} -	if (swzText && !swzText[0]) { -		mir_free(swzText); -		swzText = NULL; +	if (ptszText && !ptszText[0]) { +		mir_free(ptszText); +		ptszText = NULL;  	} -	if (swzText && opt.bLimitMsg) -		TruncateString(swzText); +	if (ptszText && opt.bLimitMsg) +		TruncateString(ptszText); -	return swzText; +	return ptszText;  } -TCHAR *GetProtoExtraStatusTitle(char *szProto) +TCHAR* GetProtoExtraStatusTitle(char *szProto)  { -	DBVARIANT dbv; -	TCHAR *swzText = NULL; -  	if (!szProto)  		return NULL; -	if (!db_get_ts(0, szProto, "XStatusName", &dbv)) { -		if (mir_tstrlen(dbv.ptszVal) != 0) -			swzText = mir_tstrdup(dbv.ptszVal); -		db_free(&dbv); -	} - -	if (!swzText) { +	TCHAR *ptszText = db_get_tsa(0, szProto, "XStatusName"); +	if (!ptszText) {  		TCHAR buff[256];  		if (EmptyXStatusToDefaultName(0, szProto, 0, buff, 256)) -			swzText = mir_tstrdup(buff); +			ptszText = mir_tstrdup(buff);  	}  	if (opt.bLimitMsg) -		TruncateString(swzText); +		TruncateString(ptszText); -	return swzText; +	return ptszText;  } -TCHAR *GetProtoExtraStatusMessage(char *szProto) +TCHAR* GetProtoExtraStatusMessage(char *szProto)  {  	if (!szProto)  		return NULL; -	TCHAR *swzText = NULL; -	DBVARIANT dbv; -	if (!db_get_ts(0, szProto, "XStatusMsg", &dbv)) { -		if (mir_tstrlen(dbv.ptszVal) != 0) -			swzText = mir_tstrdup(dbv.ptszVal); -		db_free(&dbv); +	TCHAR *ptszText = db_get_tsa(0, szProto, "XStatusMsg"); +	if (ptszText == NULL) +		return NULL; -		if (ServiceExists(MS_VARS_FORMATSTRING)) { -			MCONTACT hContact = db_find_first(); -			char *proto = GetContactProto(hContact); -			while (!proto) { -				hContact = db_find_next(hContact); -				if (hContact) -					proto = GetContactProto(hContact); -				else { -					hContact = NULL; -					break; -				} +	if (ServiceExists(MS_VARS_FORMATSTRING)) { +		MCONTACT hContact = db_find_first(); +		char *proto = GetContactProto(hContact); +		while (!proto) { +			hContact = db_find_next(hContact); +			if (hContact) +				proto = GetContactProto(hContact); +			else { +				hContact = NULL; +				break;  			} - -			TCHAR *tszParsed = variables_parse(swzText, NULL, hContact); -			if (tszParsed) -				replaceStrT(swzText, tszParsed);  		} + +		TCHAR *tszParsed = variables_parse(ptszText, NULL, hContact); +		if (tszParsed) +			replaceStrT(ptszText, tszParsed);  	}  	if (opt.bLimitMsg) -		TruncateString(swzText); +		TruncateString(ptszText); -	return swzText; +	return ptszText;  } -TCHAR *GetListeningTo(char *szProto) +TCHAR* GetListeningTo(char *szProto)  { -	DBVARIANT dbv; -	TCHAR *swzText = NULL; -  	if (!szProto)  		return NULL; -	if (!db_get_ts(0, szProto, "ListeningTo", &dbv)) { -		if (mir_tstrlen(dbv.ptszVal) != 0) -			swzText = mir_tstrdup(dbv.ptszVal); -		db_free(&dbv); -	} - +	TCHAR *ptszText = db_get_tsa(0, szProto, "ListeningTo");  	if (opt.bLimitMsg) -		TruncateString(swzText); +		TruncateString(ptszText); -	return swzText; +	return ptszText;  } -TCHAR *GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szValue) +TCHAR* GetJabberAdvStatusText(char *szProto, const char *szSlot, const char *szValue)  { -	DBVARIANT dbv; -	TCHAR *swzText = NULL; -  	if (!szProto)  		return NULL;  	char szSetting[128];  	mir_snprintf(szSetting, "%s/%s/%s", szProto, szSlot, szValue); -	if (!db_get_ts(0, "AdvStatus", szSetting, &dbv)) { -		if (mir_tstrlen(dbv.ptszVal) != 0) -			swzText = mir_tstrdup(dbv.ptszVal); -		db_free(&dbv); -	} - +	TCHAR *ptszText = db_get_tsa(0, "AdvStatus", szSetting);  	if (opt.bLimitMsg) -		TruncateString(swzText); +		TruncateString(ptszText); -	return swzText; +	return ptszText;  }  HICON GetJabberActivityIcon(MCONTACT hContact, char *szProto)  { -	DBVARIANT dbv; -	HICON hIcon = NULL; -  	if (!szProto)  		return NULL;  	char szSetting[128];  	mir_snprintf(szSetting, "%s/%s/%s", szProto, "activity", "icon"); -	if (!db_get_s(hContact, "AdvStatus", szSetting, &dbv)) { -		hIcon = IcoLib_GetIcon(dbv.pszVal); -		db_free(&dbv); -	} - -	return hIcon; -}
\ No newline at end of file +	ptrA szIcon(db_get_sa(hContact, "AdvStatus", szSetting)); +	return (szIcon != NULL) ? IcoLib_GetIcon(szIcon) : NULL; +} diff --git a/plugins/Utils/mir_buffer.h b/plugins/Utils/mir_buffer.h index c8388bd731..4d5361b8ab 100644 --- a/plugins/Utils/mir_buffer.h +++ b/plugins/Utils/mir_buffer.h @@ -27,67 +27,63 @@ Boston, MA 02111-1307, USA.  #include <m_timezones.h>
  template<class T>
 -static inline size_t __blen(const T *str)
 +inline size_t __blen(const T *str)
  {
  	return 0;
  }
  template<>
 -static inline size_t __blen<char>(const char *str)
 +inline size_t __blen<char>(const char *str)
  {
  	return mir_strlen(str);
  }
  template<>
 -static inline size_t __blen<wchar_t>(const wchar_t *str)
 +inline size_t __blen<wchar_t>(const wchar_t *str)
  {
  	return mir_wstrlen(str);
  }
  template<class T>
 -static inline T * __bTranslate(const T *str)
 +inline T * __bTranslate(const T *str)
  {
  	return 0;
  }
  template<>
 -static inline char * __bTranslate<char>(const char *str)
 +inline char * __bTranslate<char>(const char *str)
  {
  	return Translate(str);
  }
  template<>
 -static inline wchar_t * __bTranslate<wchar_t>(const wchar_t *str)
 +inline wchar_t * __bTranslate<wchar_t>(const wchar_t *str)
  {
  	return TranslateW(str);
  }
  template<class O, class D>
 -static void __bcopy(D *dest, const O *orig, size_t len)
 +inline void __bcopy(D *dest, const O *orig, size_t len)
  {
  }
 -template<>
 -static void __bcopy(char *dest, const char *orig, size_t len)
 +inline void __bcopy(char *dest, const char *orig, size_t len)
  {
  	strncpy(dest, orig, len);
  }
 -template<>
 -static void __bcopy(WCHAR *dest, const WCHAR *orig, size_t len)
 +inline void __bcopy(WCHAR *dest, const WCHAR *orig, size_t len)
  {
  	wcsncpy(dest, orig, len);
  }
 -template<>
 -static void __bcopy(WCHAR *dest, const char *orig, size_t len)
 +inline void __bcopy(WCHAR *dest, const char *orig, size_t len)
  {
  	MultiByteToWideChar(CallService("LangPack/GetCodePage", 0, 0), 0, orig, (int)len, dest, (int)len);
  }
 -template<>
 -static void __bcopy(char *dest, const WCHAR *orig, size_t len)
 +inline void __bcopy(char *dest, const WCHAR *orig, size_t len)
  {
  	WideCharToMultiByte(CallService("LangPack/GetCodePage", 0, 0), 0, orig, (int)len, dest, (int)len, NULL, NULL);
  }
 | 
