Example #1
0
void CJabberDlgDataPage::Layout()
{
	RECT rc; GetClientRect(m_hwnd, &rc);
	int w = rc.right - 20;
	int x = 10;
	int y = 10;

	m_height = rc.bottom;
	m_scrollPos = GetScrollPos(m_hwnd, SB_VERT);

	HDWP hdwp = BeginDeferWindowPos(m_controls.getCount());
	for (int i = 0; i < m_controls.getCount(); ++i)
		if (int h = m_controls[i].Layout(hdwp, x, y - m_scrollPos, w))
			y += h + 5;
	EndDeferWindowPos(hdwp);

	m_dataHeight = y + 5;

	SCROLLINFO si = {0};
	si.cbSize = sizeof(si);
	si.fMask = SIF_DISABLENOSCROLL|SIF_PAGE|SIF_RANGE;
	si.nPage = m_height;
	si.nMin = 0;
	si.nMax = m_dataHeight;
	SetScrollInfo(m_hwnd, SB_VERT, &si, TRUE);
}
Example #2
0
// преобразует mode в HICON который НЕ НУЖНО разрушать в конце
static ICON_CACHE& getCacheItem(int mode, int type)
{
	int m = mode & 0x0f, s = (mode & SECURED)>>4, i; // разобрали на части - режим и состояние
	HICON icon;

	for (i=0; i < arIcoList.getCount(); i++)
		if (arIcoList[i].mode == ((type<<8) | mode))
			return arIcoList[i];

	i = s;
	switch(type) {
		case 1: i += IEC_CL_DIS; break;
		case 2: i += ICO_CM_DIS; break;
		case 3: i += ICO_MW_DIS; break;
	}

	if (type == 1)
		icon = BindOverlayIcon(g_hIEC[i], g_hICO[ICO_OV_NAT+m]);
	else
		icon = BindOverlayIcon(g_hICO[i], g_hICO[ICO_OV_NAT+m]);

	ICON_CACHE *p = new ICON_CACHE;
	p->icon = icon;
	p->mode = (type << 8) | mode;
	p->hCLIcon = NULL;
	arIcoList.insert(p);

	return *p;
}
Example #3
0
MIR_CORE_DLL(HANDLE) mir_createLog(const char* pszName, const TCHAR *ptszDescr, const TCHAR *ptszFile, unsigned options)
{
	if (ptszFile == NULL)
		return NULL;

	Logger *result = new Logger(pszName, ptszDescr, ptszFile, options);
	if (result == NULL)
		return NULL;

	int idx = arLoggers.getIndex(result);
	if (idx != -1) {
		delete result;
		return &arLoggers[idx];
	}

	FILE *fp = _tfopen(ptszFile, _T("ab"));
	if (fp == NULL) {
		TCHAR tszPath[MAX_PATH];
		_tcsncpy_s(tszPath, ptszFile, _TRUNCATE);
		CreatePathToFileT(tszPath);
	}
	else fclose(fp);

	DeleteFile(ptszFile);
	arLoggers.insert(result);
	return result;
}
Example #4
0
static INT_PTR VoiceUnregister(WPARAM wParam, LPARAM lParam)
{
	char *moduleName = (char *) wParam;
	if (moduleName == NULL || moduleName[0] == 0)
		return -1;

	VoiceProvider *module = FindModule(moduleName);
	if (module == NULL)
		return -2;

	for(int i = calls.getCount() - 1; i >= 0; --i)
	{
		VoiceCall *call = &calls[i];

		if (call->module == module)
		{
			call->Drop();
			call->SetState(VOICE_STATE_ENDED);

			calls.remove(i);
		}
	}

	modules.remove(module);

	if (hwnd_frame != NULL)
		PostMessage(hwnd_frame, WMU_REFRESH, 0, 0);

	return 0;
}
Example #5
0
LRESULT CALLBACK APCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_NULL: 
		while (APCCallQueue.getCount())
		{
			APCCall tmpCall;

			WaitForSingleObject(hApcMutex, INFINITE);
			if (APCCallQueue.getCount())
			{
				tmpCall = APCCallQueue[0];
				APCCallQueue.remove(0);
			}
			ReleaseMutex(hApcMutex);
			if (tmpCall.func) tmpCall.func(tmpCall.param);
		}
		SleepEx(0, TRUE); // process APCs created by plugins that do not use core service
		break;

	case WM_TIMECHANGE:
		RecalculateTime();
		break;
	}
	return DefWindowProc(hwnd,msg,wParam,lParam);
}
Example #6
0
void __cdecl SmileyDownloadThread(void*)
{
	bool needext = false;
	HANDLE hHttpDwnl = NULL;
	WaitForSingleObject(g_hDlMutex, 3000);
	while (!Miranda_Terminated() && dlQueue.getCount()) {
		ReleaseMutex(g_hDlMutex);
		if (_taccess(dlQueue[0].fname.c_str(), 0) != 0) {
			InternetDownloadFile(T2A_SM(dlQueue[0].url.c_str()), T2A_SM(dlQueue[0].fname.c_str()), hHttpDwnl);
			WaitForSingleObject(g_hDlMutex, 3000);

			CMString fname(dlQueue[0].fname);
			if (dlQueue[0].needext) { fname += GetImageExt(fname); needext = true; }
			_trename(dlQueue[0].fname.c_str(), fname.c_str());
		}
		else WaitForSingleObject(g_hDlMutex, 3000);

		dlQueue.remove(0);
	}
	dlQueue.destroy();
	if (hHttpDwnl) Netlib_CloseHandle(hHttpDwnl);
	threadRunning = false;
	ReleaseMutex(g_hDlMutex);

	if (!Miranda_Terminated()) {
		if (needext)
			CallServiceSync(MS_SMILEYADD_RELOAD, 0, 0);
		else
			NotifyEventHooks(hEvent1, 0, 0);
	}
}
Example #7
0
INT_PTR NudgeSend(WPARAM hContact, LPARAM lParam)
{
	char *protoName = GetContactProto(hContact);
	int diff = time(NULL) - db_get_dw(hContact, "Nudge", "LastSent", time(NULL) - 30);
	if (diff < GlobalNudge.sendTimeSec) {
		TCHAR msg[500];
		mir_sntprintf(msg, TranslateT("You are not allowed to send too much nudge (only 1 each %d sec, %d sec left)"), GlobalNudge.sendTimeSec, 30 - diff);
		if (GlobalNudge.useByProtocol) {
			for (int i = 0; i < arNudges.getCount(); i++) {
				CNudgeElement &p = arNudges[i];
				if (!mir_strcmp(protoName, p.ProtocolName))
					Nudge_ShowPopup(&p, hContact, msg);
			}
		}
		else Nudge_ShowPopup(&DefaultNudge, hContact, msg);

		return 0;
	}

	db_set_dw(hContact, "Nudge", "LastSent", time(NULL));

	if (GlobalNudge.useByProtocol) {
		for (int i = 0; i < arNudges.getCount(); i++) {
			CNudgeElement &p = arNudges[i];
			if (!mir_strcmp(protoName, p.ProtocolName))
				if (p.showStatus)
					Nudge_SentStatus(&p, hContact);
		}
	}
	else if (DefaultNudge.showStatus)
		Nudge_SentStatus(&DefaultNudge, hContact);

	CallProtoService(protoName, PS_SEND_NUDGE, hContact, lParam);
	return 0;
}
Example #8
0
static void RemoveProtoIconIndex(PROTOACCOUNT *pa)
{
	for (int i = 0; i < protoIconIndex.getCount(); i++)
		if (mir_strcmp(protoIconIndex[i].szProto, pa->szModuleName) == 0) {
			protoIconIndex.remove(i);
			break;
		}
}
Example #9
0
static void RemoveVoiceCall(const char *szModule, const char *id)
{
	for(int i = calls.getCount() - 1; i >= 0; --i)
	{
		if (IsCall(&calls[i], szModule, id))
			calls.remove(i);
	}
}
Example #10
0
CContactCache* CContactCache::getContactCache(HANDLE hContact)
{
	CContactCache *cc = arContacts.find((CContactCache*)&hContact);
	if (cc == NULL) {
		cc = new CContactCache(hContact);
		arContacts.insert(cc);
	}
	return cc;
}
Example #11
0
void xpt_FreeThemeForWindow(HWND hwnd)
{
	mir_cslock lck(xptCS);
	auto T = xptObjectList.rev_iter();
	for (auto &xptObject : T)
		if (xptObject->hOwnerWindow == hwnd) {
			_sttXptCloseThemeData(xptObject);
			xptObjectList.remove(T.indexOf(&xptObject));
		}
}
Example #12
0
static void QueueRemove(MCONTACT hContact)
{
	mir_cslock lck(cs);

	for (int i = queue.getCount() - 1; i >= 0; i--) {
		QueueItem& item = queue[i];
		if (item.hContact == hContact)
			queue.remove(i);
	}
}
Example #13
0
void xpt_FreeThemeHandle(XPTHANDLE xptHandle)
{
	mir_cslock lck(xptCS);
	if (xpt_IsValidHandle(xptHandle)) {
		XPTObject* xptObject = (XPTObject*)xptHandle;
		_sttXptCloseThemeData(xptObject);
		mir_free(xptHandle);
		xptObjectList.remove(xptObjectList.indexOf(xptObject));
	}
}
Example #14
0
void CIrcProto::KillChatTimer(UINT_PTR &nIDEvent)
{
	if ( nIDEvent ) {
		EnterCriticalSection( &timers_cs );
		TimerPair temp( this, nIDEvent );
		int idx = timers.getIndex( &temp );
		if ( idx != -1 )
			timers.remove( idx );

		LeaveCriticalSection( &timers_cs );

		KillTimer(NULL, nIDEvent);
		nIDEvent = NULL;
}	}
Example #15
0
BOOL xpt_IsValidHandle(XPTHANDLE xptHandle)
{
	if (!xptHandle) return FALSE;

	mir_cslock lck(xptCS);
	return xptObjectList.indexOf((XPTObject*)xptHandle) != -1;
}
Example #16
0
void CallMainThread(MirApcFunc func, void* param)
{
	WaitForSingleObject(hApcMutex, INFINITE);
	APCCallQueue.insert(new APCCall(func, param));
	ReleaseMutex(hApcMutex);
	PostMessage(hAPCWindow, WM_NULL, 0, 0);
}
Example #17
0
void Nudge_AddAccount(PROTOACCOUNT *proto)
{
	char str[MAXMODULELABELLENGTH + 10];
	mir_snprintf(str, "%s/Nudge", proto->szModuleName);
	HANDLE hevent = HookEvent(str, NudgeReceived);
	if (hevent == NULL)
		return;

	nProtocol++;

	// Add a specific sound per protocol
	CNudgeElement *p = new CNudgeElement();
	mir_snprintf(p->NudgeSoundname, "%s: Nudge", proto->szModuleName);

	strcpy_s(p->ProtocolName, proto->szModuleName);
	_tcscpy_s(p->AccountName, proto->tszAccountName);

	p->Load();
	p->hEvent = hevent;

	TCHAR soundDesc[MAXMODULELABELLENGTH + 10];
	mir_sntprintf(soundDesc, LPGENT("Nudge for %s"), proto->tszAccountName);
	SkinAddNewSoundExT(p->NudgeSoundname, LPGENT("Nudge"), soundDesc);

	arNudges.insert(p);
}
Example #18
0
void UninitTimers( void )
{
    EnterCriticalSection( &timers_cs );
    timers.destroy();
    LeaveCriticalSection( &timers_cs );
    DeleteCriticalSection( &timers_cs );
}
Example #19
0
void RecalculateTime(void)
{
	GetTimeZoneInformation(&myInfo.myTZ.tzi);
	myInfo.timestamp = time(NULL);
	myInfo.myTZ.offset = INT_MIN;

	bool found = false;
	DYNAMIC_TIME_ZONE_INFORMATION dtzi;

	if (pfnGetDynamicTimeZoneInformation && pfnGetDynamicTimeZoneInformation(&dtzi) != TIME_ZONE_ID_INVALID) {
		TCHAR *myTzKey = mir_u2t(dtzi.TimeZoneKeyName);
		_tcsncpy_s(myInfo.myTZ.tszName, myTzKey, _TRUNCATE);
		mir_free(myTzKey);
		found = true;
	}

	for (int i = 0; i < g_timezones.getCount(); i++) {
		MIM_TIMEZONE &tz = g_timezones[i];
		if (tz.offset != INT_MIN)
			tz.offset = INT_MIN;

		if (!found) {
			if (!mir_wstrcmp(tz.tzi.StandardName, myInfo.myTZ.tzi.StandardName) || !mir_wstrcmp(tz.tzi.DaylightName, myInfo.myTZ.tzi.DaylightName)) {
				_tcsncpy_s(myInfo.myTZ.tszName, tz.tszName, _TRUNCATE);
				found = true;
			}
		}
	}
}
Example #20
0
void XPThemesUnloadModule()
{
    xptlock();
    xptunlock();
    xptObjectList.destroy();
    DeleteCriticalSection(&xptCS);
}
Example #21
0
// returns manually chosen sub in the meta window
static INT_PTR Meta_SrmmCurrentSub(WPARAM hMeta, LPARAM lParam)
{
	MetaSrmmData tmp = { hMeta };
	if (MetaSrmmData *p = arMetaWindows.find(&tmp))
		return p->m_hSub;

	return db_mc_getMostOnline(hMeta);
}
Example #22
0
void xpt_FreeThemeForWindow(HWND hwnd)
{
    xptlock();
    {
        for (int i=0; i < xptObjectList.getCount(); )
        {
            XPTObject& xptObject = xptObjectList[i];
            if (xptObject.hOwnerWindow == hwnd)
            {
                _sttXptCloseThemeData(&xptObject);
                xptObjectList.remove(i);
            }
            else i++;
        }
    }
    xptunlock();
}
Example #23
0
static void QueueAdd(MCONTACT hContact, int waitTime)
{
	if (fei == NULL || g_shutDown)
		return;

	mir_cslock lck(cs);

	// Only add if not exists yet
	for (int i = queue.getCount() - 1; i >= 0; i--)
		if (queue[i].hContact == hContact)
			return;

	QueueItem *item = new QueueItem;
	item->hContact = hContact;
	item->check_time = GetTickCount() + waitTime;
	queue.insert(item);
}
Example #24
0
VoiceProvider * FindModule(const char *szModule) 
{
	for(int i = 0; i < modules.getCount(); i++)
		if (strcmp(modules[i].name, szModule) == 0)
			return &modules[i];

	return NULL;
}
Example #25
0
void ImageBase::ProcessTimerTick(time_t ts)
{
	WaitForSingleObject(g_hMutexIm, 3000);
	if (m_lRefCount == 0 && m_timestamp < ts)
		if (!g_imagecache.remove(this))
			delete this;

	ReleaseMutex(g_hMutexIm);
}
Example #26
0
void InitTimeZones(void)
{
	REG_TZI_FORMAT	tzi;
	HKEY			hKey;

	const TCHAR *tszKey = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones");

	/*
	 * use GetDynamicTimeZoneInformation() on Vista+ - this will return a structure with
	 * the registry key name, so finding our own time zone later will be MUCH easier for
	 * localized systems or systems with a MUI pack installed
	 */
	if (IsWinVerVistaPlus())
		pfnGetDynamicTimeZoneInformation = (pfnGetDynamicTimeZoneInformation_t)GetProcAddress(GetModuleHandle(_T("kernel32")), "GetDynamicTimeZoneInformation");

	if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, tszKey, 0, KEY_ENUMERATE_SUB_KEYS, &hKey)) {
		DWORD	dwIndex = 0;
		HKEY	hSubKey;
		TCHAR	tszName[MIM_TZ_NAMELEN];

		DWORD dwSize = _countof(tszName);
		while (ERROR_NO_MORE_ITEMS != RegEnumKeyEx(hKey, dwIndex++, tszName, &dwSize, NULL, NULL, 0, NULL)) {
			if (ERROR_SUCCESS == RegOpenKeyEx(hKey, tszName, 0, KEY_QUERY_VALUE, &hSubKey)) {
				dwSize = sizeof(tszName);

				DWORD dwLength = sizeof(tzi);
				if (ERROR_SUCCESS != RegQueryValueEx(hSubKey, _T("TZI"), NULL, NULL, (unsigned char *)&tzi, &dwLength))
					continue;

				MIM_TIMEZONE *tz = new MIM_TIMEZONE;

				tz->tzi.Bias = tzi.Bias;
				tz->tzi.StandardDate = tzi.StandardDate;
				tz->tzi.StandardBias = tzi.StandardBias;
				tz->tzi.DaylightDate = tzi.DaylightDate;
				tz->tzi.DaylightBias = tzi.DaylightBias;

				mir_tstrcpy(tz->tszName, tszName);
				tz->hash = mir_hashstrT(tszName);
				tz->offset = INT_MIN;

				GetLocalizedString(hSubKey, _T("Display"), tz->szDisplay, _countof(tz->szDisplay));
				GetLocalizedString(hSubKey, _T("Std"), tz->tzi.StandardName, _countof(tz->tzi.StandardName));
				GetLocalizedString(hSubKey, _T("Dlt"), tz->tzi.DaylightName, _countof(tz->tzi.DaylightName));

				g_timezones.insert(tz);
				g_timezonesBias.insert(tz);

				RegCloseKey(hSubKey);
			}
			dwSize = _countof(tszName);
		}
		RegCloseKey(hKey);
	}

	RecalculateTime();
}
Example #27
0
void xpt_OnWM_THEMECHANGED()
{
    xptlock();
    {
        for (int i=0; i < xptObjectList.getCount(); i++)
            _sttXptReloadThemeData(&xptObjectList[i]);
    }
    xptunlock();
}
Example #28
0
static VOID CALLBACK ClearOldVoiceCalls(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
	DWORD now = GetTickCount();
	BOOL refresh = FALSE;
	for(int i = calls.getCount() - 1; i >= 0; --i)
	{
		VoiceCall *call = &calls[i];

		if (call->state == VOICE_STATE_ENDED && call->end_time + TIME_TO_SHOW_ENDED_CALL < now)
		{
			calls.remove(i);
			refresh = TRUE;
		}
	}

	if (refresh && hwnd_frame != NULL)
		PostMessage(hwnd_frame, WMU_REFRESH, 0, 0);
}
Example #29
0
void RefreshContactListIcons(void)
{
	for (int i=0; i < arIcoList.getCount(); i++)
		arIcoList[i].hCLIcon = 0;

	for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
		if (isSecureProtocol(hContact))
			ShowStatusIcon(hContact);
}
Example #30
0
static void AddMethodsFrom(OBJLIST<CallingMethod> *list, HANDLE hContact, const TCHAR *number)
{
	for(int i = 0; i < modules.getCount(); i++)
	{
		VoiceProvider *provider = &modules[i];
		if (provider->CanCall(number))
			list->insert(new CallingMethod(provider, hContact, number));
	}
}