Esempio n. 1
0
void CIrcProto::DoUserhostWithReason(int type, CMString reason, bool bSendCommand, CMString userhostparams, ...)
{
    TCHAR temp[4096];
    CMString S = _T("");
    switch( type ) {
    case 1:
        S = _T("USERHOST");
        break;
    case 2:
        S = _T("WHO");
        break;
    default:
        S = _T("USERHOST");
        break;
    }

    va_list ap;
    va_start(ap, userhostparams);
    mir_vsntprintf(temp, SIZEOF(temp), (S + _T(" ") + userhostparams).c_str(), ap);
    va_end(ap);

    // Add reason
    if ( type == 1 )
        vUserhostReasons.insert( new CMString( reason ));
    else if ( type == 2 )
        vWhoInProgress.insert( new CMString( reason));

    // Do command
    if ( IsConnected() && bSendCommand )
        SendIrcMessage( temp, false );
}
Esempio n. 2
0
void AddToStatus(int flags, const TCHAR* fmt, ...)
{
	va_list vararg;
	va_start(vararg, fmt);

	TCHAR str[256];
	mir_vsntprintf(str, _countof(str), fmt, vararg);
	va_end(vararg);

	int i = SendMessage(hwndStatus, LB_ADDSTRING, 0, (LPARAM)str);
	SendMessage(hwndStatus, LB_SETITEMDATA, i, flags);
	InvalidateRect(hwndStatus, NULL, FALSE);
	SendMessage(hwndStatus, LB_SETTOPINDEX, i, 0);

#ifdef _DEBUG
	OutputDebugString(str);
	OutputDebugStringA("\n");
#endif

	switch (flags & STATUS_CLASSMASK) {
	case STATUS_ERROR:
	case STATUS_FATAL:
		errorCount++;
	}
}
Esempio n. 3
0
int _DebugPopup(HANDLE hContact, const TCHAR *fmt, ...)
{
	va_list	va;
	TCHAR		debug[1024];
	int			ibsize = 1023;

	va_start(va, fmt);
	mir_vsntprintf(debug, ibsize, fmt, va);

	if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
		MIRANDASYSTRAYNOTIFY tn;
		TCHAR	szTitle[128];
		mir_sntprintf(szTitle, SIZEOF(szTitle), TranslateT("TabSRMM Message (%s)"),
			(hContact != 0) ? pcli->pfnGetContactDisplayName(hContact, 0) : TranslateT("Global"));

		tn.szProto = NULL;
		tn.cbSize = sizeof(tn);
		tn.tszInfoTitle = szTitle;
		tn.tszInfo = debug;
		tn.dwInfoFlags = NIIF_INFO;
		tn.dwInfoFlags |= NIIF_INTERN_UNICODE;
		tn.uTimeout = 1000 * 4;
		CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn);
	}
	return 0;
}
Esempio n. 4
0
int AddDebugLogMessage(const TCHAR* fmt, ...)
{

	int res;
	TCHAR tszText[MAX_DEBUG], tszFinal[MAX_DEBUG];
	char *szFinal;
	va_list va;

	va_start(va, fmt);
	mir_vsntprintf(tszText, _countof(tszText), fmt, va);
	va_end(va);
#ifdef MODULENAME
	mir_sntprintf(tszFinal, _countof(tszFinal), _T("%s: %s"), MODULENAME, tszText);
#else
	_tcsncpy(tszFinal, tszText, _countof(tszFinal));
#endif


	szFinal = mir_t2a(tszFinal);

	res = WriteToDebugLogA(szFinal);
	mir_free(szFinal);

	return res;
}
Esempio n. 5
0
int _DebugTraceW(const wchar_t *fmt, ...)
{
	wchar_t 	debug[2048];
	int     	ibsize = 2047;
	SYSTEMTIME	st;
	va_list 	va;
	char		tszTime[50];
	va_start(va, fmt);

	GetLocalTime(&st);

	mir_snprintf(tszTime, "%02d.%02d.%04d - %02d:%02d:%02d.%04d: ", st.wDay, st.wMonth, st.wYear, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);


	mir_vsntprintf(debug, ibsize - 10, fmt, va);
	//#ifdef _DEBUG
	OutputDebugStringW(debug);
	//#else
	{
		char szLogFileName[MAX_PATH], szDataPath[MAX_PATH];
		FILE *f;

		CallService(MS_DB_GETPROFILEPATH, MAX_PATH, (LPARAM)szDataPath);
		mir_snprintf(szLogFileName, "%s\\%s", szDataPath, "tabsrmm_debug.log");
		f = fopen(szLogFileName, "a+");
		if (f) {
			fputs(tszTime, f);
			fputs(T2Utf(debug), f);
			fputs("\n", f);
			fclose(f);
		}
	}
	//#endif
	return 0;
}
Esempio n. 6
0
void log_p(const wchar_t* szText, ...){
	va_list args;
	va_start(args, szText);
	int len = _vscwprintf(szText, args ) + 1; // _vscprintf doesn't count terminating '\0' //!!!!!!!!!!!!!!!!
	wchar_t* buffer = new wchar_t[len * sizeof(wchar_t)];
	mir_vsntprintf(buffer, len, szText, args);
	va_end(args);
	log(buffer);
	delete[] buffer;
}
Esempio n. 7
0
void CMsnProto::MSN_ShowError(const char* msgtext, ...)
{
	TCHAR   tBuffer[4096];
	va_list tArgs;

	TCHAR *buf = Langpack_PcharToTchar(msgtext);

	va_start(tArgs, msgtext);
	mir_vsntprintf(tBuffer, SIZEOF(tBuffer), buf, tArgs);
	va_end(tArgs);

	mir_free(buf);

	MSN_ShowPopup(m_tszUserName, tBuffer, MSN_ALLOW_MSGBOX | MSN_SHOW_ERROR, NULL);
}
Esempio n. 8
0
int ShowPopup(HANDLE hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, TCHAR* pszRoomName, COLORREF crBkg, const TCHAR* fmt, ...)
{
	POPUPDATAT pd = { 0 };
	va_list marker;
	static TCHAR szBuf[4 * 1024];

	if (!fmt || lstrlen(fmt) == 0 || lstrlen(fmt) > 2000)
		return 0;

	va_start(marker, fmt);
	mir_vsntprintf(szBuf, SIZEOF(szBuf), fmt, marker);
	va_end(marker);

	pd.lchContact = hContact;

	if (hIcon)
		pd.lchIcon = hIcon;
	else
		pd.lchIcon = LoadIconEx(IDI_CHANMGR, "window", 0, 0);

	PROTOACCOUNT *pa = ProtoGetAccount(pszProtoName);
	mir_sntprintf(pd.lptzContactName, MAX_CONTACTNAME - 1, _T("%s - %s"),
		(pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName,
		pcli->pfnGetContactDisplayName(hContact, 0));

	lstrcpyn(pd.lptzText, TranslateTS(szBuf), MAX_SECONDLINE);
	pd.iSeconds = g_Settings.iPopupTimeout;

	if (g_Settings.iPopupStyle == 2) {
		pd.colorBack = 0;
		pd.colorText = 0;
	}
	else if (g_Settings.iPopupStyle == 3) {
		pd.colorBack = g_Settings.crPUBkgColour;
		pd.colorText = g_Settings.crPUTextColour;
	}
	else {
		pd.colorBack = g_Settings.crLogBackground;
		pd.colorText = crBkg;
	}

	pd.PluginWindowProc = PopupDlgProc;
	pd.PluginData = si;
	return PUAddPopupT(&pd);
}
Esempio n. 9
0
/**
 * name:	UpdateContact
 * class:	CProgress
 * desc:	increase contact's progressbar by one and set new text
 * params:	pszFormat	- the text to display for the contact
 * return:	FALSE if user pressed cancel, TRUE otherwise
 **/
BYTE CProgress::UpdateContact(LPCTSTR pszFormat, ...)
{
	if (_hDlg != NULL) {
		HWND hProg = GetDlgItem(_hDlg, IDC_PROGRESS2);
		if (pszFormat) {
			TCHAR buf[MAX_PATH];
			va_list vl;

			va_start(vl, pszFormat);
			mir_vsntprintf(buf, _countof(buf), TranslateTS(pszFormat), vl);
			va_end(vl);
			SetDlgItemText(_hDlg, TXT_CONTACT, buf);	 
		}
		SendMessage(hProg, PBM_SETPOS, (int)SendMessage(hProg, PBM_GETPOS, 0, 0) + 1,	0);
		return Update();
	}
	return TRUE;
}
Esempio n. 10
0
int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char *pszProtoName, TCHAR*, COLORREF crBkg, const TCHAR *fmt, ...)
{
	static TCHAR szBuf[4 * 1024];

	if (!fmt || fmt[0] == 0 || mir_tstrlen(fmt) > 2000)
		return 0;

	va_list marker;
	va_start(marker, fmt);
	mir_vsntprintf(szBuf, 4096, fmt, marker);
	va_end(marker);

	POPUPDATAT pd = { 0 };
	pd.lchContact = hContact;

	if (hIcon)
		pd.lchIcon = hIcon;
	else
		pd.lchIcon = LoadIconEx("window", FALSE);

	PROTOACCOUNT *pa = Proto_GetAccount(pszProtoName);
	mir_sntprintf(pd.lptzContactName, _T("%s - %s"), (pa == NULL) ? _A2T(pszProtoName) : pa->tszAccountName, cli.pfnGetContactDisplayName(hContact, 0));
	mir_tstrncpy(pd.lptzText, TranslateTS(szBuf), _countof(pd.lptzText));
	pd.iSeconds = g_Settings->iPopupTimeout;

	if (g_Settings->iPopupStyle == 2) {
		pd.colorBack = 0;
		pd.colorText = 0;
	}
	else if (g_Settings->iPopupStyle == 3) {
		pd.colorBack = g_Settings->crPUBkgColour;
		pd.colorText = g_Settings->crPUTextColour;
	}
	else {
		pd.colorBack = g_Settings->crLogBackground;
		pd.colorText = crBkg;
	}

	pd.PluginWindowProc = PopupDlgProc;
	pd.PluginData = si;
	return PUAddPopupT(&pd);
}
Esempio n. 11
0
/**
* name:	MsgErr
* desc:	calls a messagebox
* param:
**/
INT_PTR CALLBACK MsgErr(HWND hParent, LPCTSTR pszFormat, ...)
{
	TCHAR tszTitle[MAX_SECONDLINE], tszMsg[MAX_SECONDLINE];
	mir_sntprintf(tszTitle, _T("%s - %s"), _T(MODNAME), TranslateT("Error"));

	va_list vl;
	va_start(vl, pszFormat);
	mir_vsntprintf(tszMsg, TranslateTS(pszFormat), vl);
	va_end(vl);

	MSGBOX mb = {0};
	mb.cbSize = sizeof(MSGBOX);
	mb.hParent = hParent;
	mb.hiLogo = IcoLib_GetIcon(ICO_COMMON_MAIN);
	mb.hiMsg = NULL;
	mb.ptszTitle = tszTitle;
	mb.ptszMsg = tszMsg;
	mb.uType = MB_OK | MB_ICON_ERROR;
	return MsgBoxService(NULL, (LPARAM)&mb);
}
Esempio n. 12
0
/**
* name:	MsgBox
* desc:	calls a messagebox
* param:
**/
INT_PTR CALLBACK MsgBox(HWND hParent, UINT uType, LPCTSTR pszTitle, LPCTSTR pszInfo, LPCTSTR pszFormat, ...)
{
	TCHAR tszMsg[MAX_SECONDLINE];

	va_list vl;
	va_start(vl, pszFormat);
	mir_vsntprintf(tszMsg, _countof(tszMsg), TranslateTS(pszFormat), vl);
	va_end(vl);

	MSGBOX mb = { 0 };
	mb.cbSize = sizeof(MSGBOX);
	mb.hParent = hParent;
	mb.hiLogo = IcoLib_GetIcon(ICO_COMMON_MAIN);
	mb.hiMsg = NULL;
	mb.ptszTitle = TranslateTS(pszTitle);
	mb.ptszInfoText = TranslateTS(pszInfo);
	mb.ptszMsg = tszMsg;
	mb.uType = uType;
	return MsgBoxService(NULL, (LPARAM)&mb);
}
Esempio n. 13
0
void ShowMessage(int type, const TCHAR* format, ...)
{
	POPUPDATAT pi = { 0 };

	va_list va;
	va_start(va, format);
	int len = mir_vsntprintf(pi.lptzText, _countof(pi.lptzText) - 1, format, va);
	pi.lptzText[len] = 0;
	va_end(va);

	if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
		mir_tstrcpy(pi.lptzContactName, TEXT(PluginName));
		pi.lchIcon = LoadIconEx(IDI_VI);
		pi.PluginWindowProc = DlgProcPopup;
		pi.PluginData = (void*)type;

		PUAddPopupT(&pi);
	}
	else MessageBox(NULL, pi.lptzText, TEXT(PluginName), MB_OK | MB_ICONINFORMATION);
}
Esempio n. 14
0
/**
 * name:	UpdateContact
 * class:	CProgress
 * desc:	increase setting's progressbar by one and set new text
 * params:	pszFormat	- the text to display for the setting
 * return:	FALSE if user pressed cancel, TRUE otherwise
 **/
BYTE CProgress::UpdateSetting(LPCTSTR pszFormat, ...)
{
	if (_hDlg != NULL) {
		HWND hProg = GetDlgItem(_hDlg, IDC_PROGRESS);
		if (pszFormat) {
			TCHAR buf[MAX_PATH];
			TCHAR tmp[MAX_PATH];
			va_list vl;

			va_start(vl, pszFormat);
			mir_vsntprintf(buf, _countof(buf), TranslateTS(pszFormat), vl);
			va_end(vl);
			GetDlgItemText(_hDlg, TXT_SETTING, tmp, _countof(tmp));
			if (mir_tstrcmpi(tmp,buf))
				SetDlgItemText(_hDlg, TXT_SETTING, buf);
		}
		SendMessage(hProg, PBM_SETPOS, (int)SendMessage(hProg, PBM_GETPOS, 0, 0) + 1, 0);
		return Update();
	}
	return TRUE;
}
Esempio n. 15
0
//---------------------------------------------------------------------------
void CSend::Error(LPCTSTR pszFormat, ...)
{
	TCHAR tszMsg[MAX_SECONDLINE];

	mir_sntprintf(tszMsg, _T("%s - %s"), _T(SZ_SENDSS), TranslateT("Error"));
	mir_free(m_ErrorTitle), m_ErrorTitle = mir_tstrdup(tszMsg);

	va_list vl;
	va_start(vl, pszFormat);
	mir_vsntprintf(tszMsg, _countof(tszMsg), TranslateTS(pszFormat), vl);
	va_end(vl);
	mir_free(m_ErrorMsg), m_ErrorMsg = mir_tstrdup(tszMsg);

	memset(&m_box, 0, sizeof(MSGBOX));
	m_box.cbSize = sizeof(MSGBOX);
	m_box.hParent = NULL;
	m_box.hiLogo = GetIcon(ICO_MAIN);
	m_box.hiMsg = NULL;
	m_box.ptszTitle = m_ErrorTitle;
	m_box.ptszMsg = m_ErrorMsg;
	m_box.uType = MB_OK | MB_ICON_ERROR;
}
Esempio n. 16
0
int 
m_log(const TCHAR *function, const TCHAR *fmt, ...)
{
#if 0
	va_list va;
	TCHAR text[1024];
	size_t len;

	mir_sntprintf(text, MAX_REGS(text) - 10, _T("[%08u - %08u] [%s] "), 
				 GetCurrentThreadId(), GetTickCount(), function);
	len = lstrlen(text);

	va_start(va, fmt);
	mir_vsntprintf(&text[len], MAX_REGS(text) - len, fmt, va);
	va_end(va);

	BOOL writeBOM = (GetFileAttributes(_T("c:\\miranda_listeningto.log.txt")) == INVALID_FILE_ATTRIBUTES);

	FILE *fp = _tfopen(_T("c:\\miranda_listeningto.log.txt"), _T("ab"));

	if (fp != NULL)
	{
#ifdef UNICODE
		if (writeBOM)
			fwprintf(fp, L"\xFEFF");
#endif

		_ftprintf(fp, _T("%s\r\n"), text);
		fclose(fp);
		return 0;
	}
	else
	{
		return -1;
	}
#else
	return 0;
#endif
}
Esempio n. 17
0
static void Log_AppendRTF(LOGSTREAMDATA *streamData, BOOL simpleMode, CMStringA &str, const TCHAR *fmt, ...)
{
	int textCharsCount = 0;
	TCHAR *line = (TCHAR*)_alloca(8001 * sizeof(TCHAR));

	va_list va;
	va_start(va, fmt);
	int lineLen = mir_vsntprintf(line, 8000, fmt, va);
	if (lineLen < 0)
		lineLen = 8000;
	line[lineLen] = 0;
	va_end(va);

	CMStringA res;

	for (; *line; line++, textCharsCount++) {
		if (*line == '\r' && line[1] == '\n') {
			res.Append("\\par ");
			line++;
		}
		else if (*line == '\n') {
			res.Append("\\line ");
		}
		else if (*line == '%' && !simpleMode) {
			char szTemp[200]; szTemp[0] = '\0';
			switch (*++line) {
			case '\0':
			case '%':
				res.AppendChar('%');
				break;

			case 'c':
			case 'f':
				if (g_Settings.bStripFormat || streamData->bStripFormat)
					line += 2;
				else if (line[1] != '\0' && line[2] != '\0') {
					TCHAR szTemp3[3], c = *line;
					int col;
					szTemp3[0] = line[1];
					szTemp3[1] = line[2];
					szTemp3[2] = '\0';
					line += 2;

					col = _ttoi(szTemp3);
					col += (OPTIONS_FONTCOUNT + 1);
					res.AppendFormat((c == 'c') ? "\\cf%u " : "\\highlight%u ", col);
				}
				break;
			case 'C':
			case 'F':
				if (!g_Settings.bStripFormat && !streamData->bStripFormat) {
					int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin);
					if (*line == 'C')
						res.AppendFormat("\\cf%u ", j + 1);
					else
						res.Append("\\highlight0 ");
				}
				break;
			case 'b':
			case 'u':
			case 'i':
				if (!streamData->bStripFormat)
					res.AppendFormat((*line == 'u') ? "\\%cl " : "\\%c ", *line);
				break;

			case 'B':
			case 'U':
			case 'I':
				if (!streamData->bStripFormat)
					res.AppendFormat((*line == 'U') ? "\\%cl0 " : "\\%c0 ", tolower(*line));
				break;

			case 'r':
				if (!streamData->bStripFormat) {
					int index = EventToIndex(streamData->lin);
					res.AppendFormat("%s ", pci->Log_SetStyle(index));
				}
				break;
			}
		}
		else if (*line == '\t' && !streamData->bStripFormat) {
			res.Append("\\tab ");
		}
		else if ((*line == '\\' || *line == '{' || *line == '}') && !streamData->bStripFormat) {
			res.AppendChar('\\');
			res.AppendChar(*line);
		}
		else if (*line > 0 && *line < 128) {
			res.AppendChar((char)*line);
		}
		else res.AppendFormat("\\u%u ?", (WORD)* line);
	}

	str += res;
}
Esempio n. 18
0
static int Log_AppendRTF(LOGSTREAMDATA *streamData, BOOL simpleMode, char *&buffer, size_t &cbBufferEnd, size_t &cbBufferAlloced, const TCHAR *fmt, ...)
{
	va_list va;
	int lineLen, textCharsCount = 0;
	TCHAR* line = (TCHAR*)alloca(8001 * sizeof(TCHAR));

	va_start(va, fmt);
	lineLen = mir_vsntprintf(line, 8000, fmt, va);
	if (lineLen < 0) lineLen = 8000;
	line[lineLen] = 0;
	va_end(va);

	lineLen = lineLen * 20 + 8;
	if (cbBufferEnd + lineLen > cbBufferAlloced) {
		cbBufferAlloced += (lineLen + 1024 - lineLen % 1024);
		buffer = (char *)mir_realloc(buffer, cbBufferAlloced);
	}

	char *d = buffer + cbBufferEnd;

	for (; *line; line++, textCharsCount++) {
		if (*line == '\r' && line[1] == '\n') {
			memcpy(d, "\\par ", 5);
			line++;
			d += 5;
		}
		else if (*line == '\n') {
			memcpy(d, "\\line ", 6);
			d += 6;
		}
		else if (*line == '%' && !simpleMode) {
			char szTemp[200];

			szTemp[0] = '\0';
			switch (*++line) {
			case '\0':
			case '%':
				*d++ = '%';
				break;

			case 'c':
			case 'f':
				if (g_Settings->bStripFormat || streamData->bStripFormat)
					line += 2;

				else if (line[1] != '\0' && line[2] != '\0') {
					TCHAR szTemp3[3], c = *line;
					int col;
					szTemp3[0] = line[1];
					szTemp3[1] = line[2];
					szTemp3[2] = '\0';
					line += 2;

					col = _ttoi(szTemp3);
					col += (OPTIONS_FONTCOUNT + 1);
					mir_snprintf(szTemp, (c == 'c') ? "\\cf%u " : "\\highlight%u ", col);
				}
				break;
			case 'C':
			case 'F':
				if (!g_Settings->bStripFormat && !streamData->bStripFormat) {
					int j = streamData->lin->bIsHighlighted ? 16 : EventToIndex(streamData->lin);
					if (*line == 'C')
						mir_snprintf(szTemp, "\\cf%u ", j + 1);
					else
						mir_snprintf(szTemp, "\\highlight0 ");
				}
				break;
			case 'b':
			case 'u':
			case 'i':
				if (!streamData->bStripFormat)
					mir_snprintf(szTemp, (*line == 'u') ? "\\%cl " : "\\%c ", *line);
				break;

			case 'B':
			case 'U':
			case 'I':
				if (!streamData->bStripFormat) {
					mir_snprintf(szTemp, (*line == 'U') ? "\\%cl0 " : "\\%c0 ", *line);
					CharLowerA(szTemp);
				}
				break;

			case 'r':
				if (!streamData->bStripFormat) {
					int index = EventToIndex(streamData->lin);
					mir_snprintf(szTemp, "%s ", Log_SetStyle(index));
				}
				break;
			}

			if (szTemp[0]) {
				size_t iLen = mir_strlen(szTemp);
				memcpy(d, szTemp, iLen);
				d += iLen;
			}
		}
		else if (*line == '\t' && !streamData->bStripFormat) {
			memcpy(d, "\\tab ", 5);
			d += 5;
		}
		else if ((*line == '\\' || *line == '{' || *line == '}') && !streamData->bStripFormat) {
			*d++ = '\\';
			*d++ = (char)*line;
		}
		else if (*line > 0 && *line < 128) {
			*d++ = (char)*line;
		}
		else d += sprintf(d, "\\u%u ?", (WORD)*line); //!!!!!!!!!!!
	}

	cbBufferEnd = (int)(d - buffer);
	return textCharsCount;
}