示例#1
0
// Helper to process texts
static char * HtmlEncodeUTF8T(const TCHAR *src)
{
	if (src == NULL)
		return mir_strdup("");

	return HtmlEncode(UTF8(src));
}
示例#2
0
String StringUtil::HtmlEncode(const String& input, QuoteStyle quoteStyle,
                              const char *charset, bool dEncode, bool htmlEnt) {
  return HtmlEncode(input, static_cast<int64_t>(quoteStyle),
                    charset, dEncode, htmlEnt);
}
示例#3
0
void CMsnProto::MSN_SendStatusMessage(const char* msg)
{
	if (!msnLoggedIn)
		return;

	char* msgEnc = HtmlEncode(msg ? msg : "");

	size_t sz;
	char  szMsg[2048];
	if (msnCurrentMedia.cbSize == 0) {
		sz = mir_snprintf(szMsg, sizeof(szMsg), "<Data><PSM>%s</PSM><CurrentMedia></CurrentMedia><MachineGuid>%s</MachineGuid>"
			"<DDP></DDP><SignatureSound></SignatureSound><Scene></Scene><ColorScheme></ColorScheme></Data>",
			msgEnc, MyOptions.szMachineGuid);
	}
	else {
		char *szFormatEnc;
		if (ServiceExists(MS_LISTENINGTO_GETPARSEDTEXT)) {
			LISTENINGTOINFO lti = {0};
			lti.cbSize = sizeof(lti);
			if (msnCurrentMedia.ptszTitle != NULL) lti.ptszTitle = _T("{0}");
			if (msnCurrentMedia.ptszArtist != NULL) lti.ptszArtist = _T("{1}");
			if (msnCurrentMedia.ptszAlbum != NULL) lti.ptszAlbum = _T("{2}");
			if (msnCurrentMedia.ptszTrack != NULL) lti.ptszTrack = _T("{3}");
			if (msnCurrentMedia.ptszYear != NULL) lti.ptszYear = _T("{4}");
			if (msnCurrentMedia.ptszGenre != NULL) lti.ptszGenre = _T("{5}");
			if (msnCurrentMedia.ptszLength != NULL) lti.ptszLength = _T("{6}");
			if (msnCurrentMedia.ptszPlayer != NULL) lti.ptszPlayer = _T("{7}");
			if (msnCurrentMedia.ptszType != NULL) lti.ptszType = _T("{8}");

			TCHAR *tmp = (TCHAR *)CallService(MS_LISTENINGTO_GETPARSEDTEXT, (WPARAM) _T("%title% - %artist%"), (LPARAM) &lti);
			szFormatEnc = HtmlEncodeUTF8T(tmp);
			mir_free(tmp);
		}
		else szFormatEnc = HtmlEncodeUTF8T(_T("{0} - {1}"));

		char *szArtist = HtmlEncodeUTF8T(msnCurrentMedia.ptszArtist);
		char *szAlbum = HtmlEncodeUTF8T(msnCurrentMedia.ptszAlbum);
		char *szTitle = HtmlEncodeUTF8T(msnCurrentMedia.ptszTitle);
		char *szTrack = HtmlEncodeUTF8T(msnCurrentMedia.ptszTrack);
		char *szYear = HtmlEncodeUTF8T(msnCurrentMedia.ptszYear);
		char *szGenre = HtmlEncodeUTF8T(msnCurrentMedia.ptszGenre);
		char *szLength = HtmlEncodeUTF8T(msnCurrentMedia.ptszLength);
		char *szPlayer = HtmlEncodeUTF8T(msnCurrentMedia.ptszPlayer);
		char *szType = HtmlEncodeUTF8T(msnCurrentMedia.ptszType);

		sz = mir_snprintf(szMsg, sizeof szMsg,
			"<Data>"
			"<PSM>%s</PSM>"
			"<CurrentMedia>%s\\0%s\\01\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0%s\\0\\0</CurrentMedia>"
			"<MachineGuid>%s</MachineGuid><DDP></DDP><SignatureSound></SignatureSound><Scene></Scene><ColorScheme></ColorScheme>"
			"<DDP></DDP><SignatureSound></SignatureSound><Scene></Scene><ColorScheme></ColorScheme>"
			"</Data>",
			msgEnc, szPlayer, szType, szFormatEnc, szTitle, szArtist, szAlbum, szTrack, szYear, szGenre,
			szLength, szPlayer, szType, MyOptions.szMachineGuid);

		mir_free(szArtist);
		mir_free(szAlbum);
		mir_free(szTitle);
		mir_free(szTrack);
		mir_free(szYear);
		mir_free(szGenre);
		mir_free(szLength);
		mir_free(szPlayer);
		mir_free(szType);
	}
	mir_free(msgEnc);

	if (msnPreviousUUX == NULL || strcmp(msnPreviousUUX, szMsg)) {
		replaceStr(msnPreviousUUX, szMsg);
		msnNsThread->sendPacket("UUX", "%d\r\n%s", sz, szMsg);
		mStatusMsgTS = clock();
	}
}