예제 #1
0
HANDLE NetlibInitSecurityProvider(const TCHAR* szProvider, const TCHAR* szPrincipal)
{
	HANDLE hSecurity = NULL;

	if (mir_tstrcmpi(szProvider, _T("Basic")) == 0) {
		NtlmHandleType* hNtlm = (NtlmHandleType*)mir_calloc(sizeof(NtlmHandleType));
		hNtlm->szProvider = mir_tstrdup(szProvider);
		SecInvalidateHandle(&hNtlm->hClientContext);
		SecInvalidateHandle(&hNtlm->hClientCredential);
		ntlmCnt++;

		return hNtlm;
	}

	mir_cslock lck(csSec);

	PSecPkgInfo ntlmSecurityPackageInfo;
	bool isGSSAPI = mir_tstrcmpi(szProvider, _T("GSSAPI")) == 0;
	const TCHAR *szProviderC = isGSSAPI ? _T("Kerberos") : szProvider;
	SECURITY_STATUS sc = QuerySecurityPackageInfo((LPTSTR)szProviderC, &ntlmSecurityPackageInfo);
	if (sc == SEC_E_OK) {
		NtlmHandleType* hNtlm;

		hSecurity = hNtlm = (NtlmHandleType*)mir_calloc(sizeof(NtlmHandleType));
		hNtlm->cbMaxToken = ntlmSecurityPackageInfo->cbMaxToken;
		FreeContextBuffer(ntlmSecurityPackageInfo);

		hNtlm->szProvider = mir_tstrdup(szProvider);
		hNtlm->szPrincipal = mir_tstrdup(szPrincipal ? szPrincipal : _T(""));
		SecInvalidateHandle(&hNtlm->hClientContext);
		SecInvalidateHandle(&hNtlm->hClientCredential);
		ntlmCnt++;
	}
	return hSecurity;
}
예제 #2
0
bool parse_quote(const IXMLNode::TXMLNodePtr& pTop, CQuotesProviderBase::CQuote& q)
{
	tstring sSymbol;
	tstring sDescription;
	tstring sID;

	size_t cChild = pTop->GetChildCount();
	for (size_t i = 0; i < cChild; ++i) {
		IXMLNode::TXMLNodePtr pNode = pTop->GetChildNode(i);
		tstring sName = pNode->GetName();
		if (0 == mir_tstrcmpi(_T("symbol"), sName.c_str())) {
			sSymbol = pNode->GetText();
			if (true == sSymbol.empty())
				return false;
		}
		else if (0 == mir_tstrcmpi(_T("description"), sName.c_str())) {
			sDescription = pNode->GetText();
		}
		else if (0 == mir_tstrcmpi(_T("id"), sName.c_str())) {
			sID = pNode->GetText();
			if (true == sID.empty())
				return false;
		}
	}

	q = CQuotesProviderBase::CQuote(sID, TranslateTS(sSymbol.c_str()), TranslateTS(sDescription.c_str()));
	return true;
}
예제 #3
0
bool parse_section(const IXMLNode::TXMLNodePtr& pTop, CQuotesProviderBase::CQuoteSection& qs)
{
	CQuotesProviderBase::CQuoteSection::TSections aSections;
	CQuotesProviderBase::CQuoteSection::TQuotes aQuotes;
	tstring sSectionName;

	size_t cChild = pTop->GetChildCount();
	for (size_t i = 0; i < cChild; ++i) {
		IXMLNode::TXMLNodePtr pNode = pTop->GetChildNode(i);
		tstring sName = pNode->GetName();
		if (0 == mir_tstrcmpi(_T("section"), sName.c_str())) {
			CQuotesProviderBase::CQuoteSection qs1;
			if (true == parse_section(pNode, qs1))
				aSections.push_back(qs1);
		}
		else if (0 == mir_tstrcmpi(_T("quote"), sName.c_str())) {
			CQuotesProviderBase::CQuote q;
			if (true == parse_quote(pNode, q))
				aQuotes.push_back(q);
		}
		else if (0 == mir_tstrcmpi(_T("name"), sName.c_str())) {
			sSectionName = pNode->GetText();
			if (true == sSectionName.empty())
				return false;
		}
	}

	qs = CQuotesProviderBase::CQuoteSection(TranslateTS(sSectionName.c_str()), aSections, aQuotes);
	return true;
}
예제 #4
0
static BOOL IsValidRunCommand(const TCHAR *pszRunCmd)
{
	TCHAR *buf,*pexe,*pargs;
	TCHAR szFullExe[MAX_PATH],*pszFilePart;
	buf=mir_tstrcpy((TCHAR*)_alloca((mir_tstrlen(pszRunCmd)+1)*sizeof(TCHAR)),pszRunCmd);
	/* split into executable path and arguments */
	if (buf[0]==_T('\"')) {
		pargs=_tcschr(&buf[1],_T('\"'));
		if (pargs!=NULL) *(pargs++)=0;
		pexe=&buf[1];
		if (*pargs==_T(' ')) ++pargs;
	} else {
		pargs=_tcschr(buf,_T(' '));
		if (pargs!=NULL) *pargs=0;
		pexe=buf;
	}
	if (SearchPath(NULL,pexe,_T(".exe"),_countof(szFullExe),szFullExe,&pszFilePart)) {
		if (pszFilePart!=NULL)
			if (!mir_tstrcmpi(pszFilePart,_T("rundll32.exe")) || !mir_tstrcmpi(pszFilePart,_T("rundll.exe"))) {
				/* split into dll path and arguments */
				if (pargs[0]==_T('\"')) {
					++pargs;
					pexe=_tcschr(&pargs[1],_T('\"'));
					if (pexe!=NULL) *pexe=0;
				} else {
					pexe=_tcschr(pargs,_T(','));
					if (pexe!=NULL) *pexe=0;
				}
				return SearchPath(NULL,pargs,_T(".dll"),0,NULL,NULL)!=0;
			}
			return TRUE;
	}
	return FALSE;
}
예제 #5
0
BOOL IsTypeEnabled(LISTENINGTOINFO *lti)
{
	if (lti == NULL)
		return TRUE;


	if (lti->dwFlags & LTI_UNICODE) {
		if (mir_tstrcmpi(lti->ptszType, LPGENT("Music")) == 0)
			return opts.enable_music;
		if (mir_tstrcmpi(lti->ptszType, LPGENT("Radio")) == 0)
			return opts.enable_radio;
		if (mir_tstrcmpi(lti->ptszType, LPGENT("Video")) == 0)
			return opts.enable_video;
		return opts.enable_others;
	}
	else

	{
		if (strcmpi(lti->pszType, "Music") == 0)
			return opts.enable_music;
		if (strcmpi(lti->pszType, "Radio") == 0)
			return opts.enable_radio;
		if (strcmpi(lti->pszType, "Video") == 0)
			return opts.enable_video;
		return opts.enable_others;
	}
}
예제 #6
0
static int lua_FindIterator(lua_State *L)
{
	HANDLE hFind = lua_touserdata(L, lua_upvalueindex(1));
	TCHAR* path = (TCHAR*)lua_touserdata(L, lua_upvalueindex(2));

	WIN32_FIND_DATA ffd = { 0 };
	if (hFind == NULL)
	{
		hFind = FindFirstFile(path, &ffd);
		if (hFind == INVALID_HANDLE_VALUE)
		{
			mir_free(path);
			lua_pushnil(L);
			return 1;
		}
	}
	else
	{
		if (FindNextFile(hFind, &ffd) == 0)
		{
			FindClose(hFind);
			mir_free(path);
			lua_pushnil(L);
			return 1;
		}
	}

	if (!mir_tstrcmpi(ffd.cFileName, _T(".")) ||
		!mir_tstrcmpi(ffd.cFileName, _T("..")) ||
		(ffd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT))
	{
		lua_pushlightuserdata(L, hFind);
		lua_replace(L, lua_upvalueindex(1));

		return lua_FindIterator(L);
	}

	LARGE_INTEGER size;
	size.HighPart = ffd.nFileSizeHigh;
	size.LowPart = ffd.nFileSizeLow;

	lua_newtable(L);
	lua_pushliteral(L, "Name");
	lua_pushstring(L, T2Utf(ffd.cFileName));
	lua_settable(L, -3);
	lua_pushliteral(L, "Size");
	lua_pushinteger(L, size.QuadPart);
	lua_settable(L, -3);
	lua_pushliteral(L, "IsFile");
	lua_pushboolean(L, !(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
	lua_settable(L, -3);
	lua_pushliteral(L, "IsDirectory");
	lua_pushboolean(L, ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
	lua_settable(L, -3);

	lua_pushlightuserdata(L, hFind);
	lua_replace(L, lua_upvalueindex(1));

	return 1;
}
예제 #7
0
void AddDialogString(HWND hWndDlg, const PageHash key)
{
	TCHAR title[2048];
	GetWindowText(hWndDlg, title, _countof(title));
	if (mir_tstrlen(title) > 0)
		AddFilterString(key, title);

	TCHAR szClass[64];
	GetClassName(hWndDlg, szClass, _countof(szClass));

	if (mir_tstrcmpi(szClass, _T("SysTreeView32")) == 0) {
		HTREEITEM hItem = TreeView_GetRoot(hWndDlg);
		AddTreeViewNodes(hWndDlg, key, hItem);
		return;
	}

	if (mir_tstrcmpi(szClass, _T("listbox")) == 0) {
		if (GetWindowStyle(hWndDlg) & LBS_HASSTRINGS) {
			int count = ListBox_GetCount(hWndDlg);
			for (int i=0; i < count; i++) {
				title[0] = 0; //safety
				int res = ListBox_GetText(hWndDlg, i, title);
				if (res != LB_ERR) {
					title[_countof(title) - 1] = 0;
					if (mir_tstrlen(title) > 0)
						AddFilterString(key, title);
				}
			}
		}
		return;
	}

	if (mir_tstrcmpi(szClass, _T("SysListView32")) == 0) {
		int count = ListView_GetItemCount(hWndDlg);
		for (int i=0; i < count; i++) {
			title[0] = 0; //safety
			ListView_GetItemText(hWndDlg, i, 0, title, _countof(title));

			if (mir_tstrlen(title) > 0)
				AddFilterString(key, title);
		}
		return;
	}

	if (mir_tstrcmpi(szClass, _T("combobox")) == 0) {
		if (GetWindowStyle(hWndDlg) & CBS_HASSTRINGS) {
			int count = ComboBox_GetCount(hWndDlg);
			for (int i=0; i < count; i++) {
				title[0] = 0; //safety
				int res = ComboBox_GetLBText(hWndDlg, i, title);
				if (res != CB_ERR) {
					title[_countof(title) - 1] = 0;

					if (mir_tstrlen(title) > 0)
						AddFilterString(key, title);
				}
			}
		}
	}
}
예제 #8
0
파일: utils.cpp 프로젝트: Seldom/miranda-ng
MCONTACT GetContactFromID(TCHAR *szID, char *szProto)
{
	TCHAR *szHandle;
	TCHAR dispName[1024];
	char cProtocol[256];
	TCHAR *tmp;

	int found = 0;
	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
		GetContactProtocol(hContact, cProtocol, sizeof(cProtocol));
		szHandle = GetContactID(hContact, cProtocol);
		
		tmp = pcli->pfnGetContactDisplayName(hContact, 0);
		_tcsncpy(dispName, tmp, _countof(dispName));
		
		if ((szHandle) && ((mir_tstrcmpi(szHandle, szID) == 0) || (mir_tstrcmpi(dispName, szID) == 0)) && ((szProto == NULL) || (_stricmp(szProto, cProtocol) == 0)))
			found = 1;

		if (szHandle) { free(szHandle); }
	
		if (found)
			return hContact;
	}
	
	return NULL;
}
예제 #9
0
inline bool is_rate_watched(MCONTACT hContact,
	const CQuotesProviderBase::CQuote& from,
	const CQuotesProviderBase::CQuote& to)
{
	tstring sFrom = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_FROM_ID);
	tstring sTo = Quotes_DBGetStringT(hContact, QUOTES_PROTOCOL_NAME, DB_STR_TO_ID);
	return ((0 == mir_tstrcmpi(from.GetID().c_str(), sFrom.c_str()))
		&& (0 == mir_tstrcmpi(to.GetID().c_str(), sTo.c_str())));
}
예제 #10
0
bool CJabberIqManager::HandleIqPermanent(HXML pNode)
{
	for (int i = 0; i < m_arHandlers.getCount(); i++) {
		CJabberIqPermanentInfo &pInfo = m_arHandlers[i];
		// have to get all data here, in the loop, because there's always possibility that previous handler modified it
		const TCHAR *szType = XmlGetAttrValue(pNode, _T("type"));
		if (!szType)
			return FALSE;

		CJabberIqInfo iqInfo;
		iqInfo.m_nIqType = JABBER_IQ_TYPE_FAIL;
		if (!mir_tstrcmpi(szType, _T("get")))
			iqInfo.m_nIqType = JABBER_IQ_TYPE_GET;
		else if (!mir_tstrcmpi(szType, _T("set")))
			iqInfo.m_nIqType = JABBER_IQ_TYPE_SET;
		else
			return FALSE;

		if (!(pInfo.m_nIqTypes & iqInfo.m_nIqType))
			continue;

		HXML pFirstChild = XmlGetChild(pNode , 0);
		if (!pFirstChild || !XmlGetName(pFirstChild))
			return FALSE;

		const TCHAR *szTagName = XmlGetName(pFirstChild);
		const TCHAR *szXmlns = XmlGetAttrValue(pFirstChild, _T("xmlns"));

		if ((!pInfo.m_szXmlns || (szXmlns && !mir_tstrcmp(pInfo.m_szXmlns, szXmlns))) &&
			 (!pInfo.m_szTag || !mir_tstrcmp(pInfo.m_szTag, szTagName)))
		{
			// node suits handler criteria, call the handler
			iqInfo.m_pChildNode = pFirstChild;
			iqInfo.m_szChildTagName = (TCHAR*)szTagName;
			iqInfo.m_szChildTagXmlns = (TCHAR*)szXmlns;
			iqInfo.m_szId = (TCHAR*)XmlGetAttrValue(pNode, _T("id"));
			iqInfo.m_pUserData = pInfo.m_pUserData;

			if (pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_TO)
				iqInfo.m_szTo = (TCHAR*)XmlGetAttrValue(pNode, _T("to"));

			if (pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
				iqInfo.m_szFrom = (TCHAR*)XmlGetAttrValue(pNode, _T("from"));

			if ((pInfo.m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT) && (iqInfo.m_szFrom))
				iqInfo.m_hContact = ppro->HContactFromJID(iqInfo.m_szFrom);

			ppro->debugLog(_T("Handling iq id %s, type %s, from %s"), iqInfo.m_szId, szType, iqInfo.m_szFrom);
			if ((ppro->*(pInfo.m_pHandler))(pNode, &iqInfo))
				return true;
		}
	}

	return false;
}
예제 #11
0
int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2)
{
	if (!mir_tstrcmpi(jid1, jid2))
		return 0;

	// match only node@domain part
	TCHAR szTempJid1[JABBER_MAX_JID_LEN], szTempJid2[JABBER_MAX_JID_LEN];
	return mir_tstrcmpi(
		JabberStripJid(jid1, szTempJid1, _countof(szTempJid1)),
		JabberStripJid(jid2, szTempJid2, _countof(szTempJid2)));
}
예제 #12
0
int CMsnProto::MSN_GCMenuHook(WPARAM, LPARAM lParam)
{
	GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;

	if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;

	if (gcmi->Type == MENU_ON_LOG) {
		static const struct gc_item Items[] =
		{
			{ LPGENT("&Invite user..."), 10, MENU_ITEM, FALSE },
			{ LPGENT("&Leave chat session"), 20, MENU_ITEM, FALSE }
		};
		gcmi->nItems = _countof(Items);
		gcmi->Item = (gc_item*)Items;
	}
	else if (gcmi->Type == MENU_ON_NICKLIST) {
		char *email = mir_t2a(gcmi->pszUID);
		if (!_stricmp(GetMyUsername(NETID_SKYPE), email)) {
			static const struct gc_item Items[] =
			{
				{ LPGENT("User &details"), 10, MENU_ITEM, FALSE },
				{ LPGENT("User &history"), 20, MENU_ITEM, FALSE },
				{ _T(""), 100, MENU_SEPARATOR, FALSE },
				{ LPGENT("&Leave chat session"), 110, MENU_ITEM, FALSE }
			};
			gcmi->nItems = _countof(Items);
			gcmi->Item = (gc_item*)Items;
		}
		else {
			static struct gc_item Items[] =
			{
				{ LPGENT("User &details"), 10, MENU_ITEM, FALSE },
				{ LPGENT("User &history"), 20, MENU_ITEM, FALSE },
				{ LPGENT("&Kick user")   , 30, MENU_ITEM, FALSE },
				{ LPGENT("&Op user")     , 40, MENU_ITEM, FALSE }
			};
			GCThreadData* thread = MSN_GetThreadByChatId(gcmi->pszID);
			if (thread && thread->mMe && mir_tstrcmpi(thread->mMe->role, _T("admin"))) {
				Items[2].bDisabled = TRUE;
				Items[3].bDisabled = TRUE;
			}
			else {
				const TCHAR *pszRole = MSN_GCGetRole(thread, email);
				if (pszRole && !mir_tstrcmpi(pszRole, _T("admin")))
					Items[3].pszDesc = LPGENT("&Deop user");
			}
			gcmi->nItems = _countof(Items);
			gcmi->Item = (gc_item*)Items;
		}
		mir_free(email);
	}

	return 0;
}
예제 #13
0
bool CJabberIqManager::HandleIq(int nIqId, HXML pNode)
{
	if (nIqId == -1 || pNode == NULL)
		return false;

	const TCHAR *szType = XmlGetAttrValue(pNode, _T("type"));
	if (!szType)
		return false;

	int nIqType = JABBER_IQ_TYPE_FAIL;
	if (!mir_tstrcmpi(szType, _T("result")))
		nIqType = JABBER_IQ_TYPE_RESULT;
	else if (!mir_tstrcmpi(szType, _T("error")))
		nIqType = JABBER_IQ_TYPE_ERROR;
	else
		return false;

	CJabberIqInfo *pInfo = DetouchInfo(nIqId);
	if (pInfo == NULL)
		return false;

	do {
		pInfo->m_nIqType = nIqType;
		if (nIqType == JABBER_IQ_TYPE_RESULT) {
			if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NODE)
				pInfo->m_pChildNode = XmlGetChild(pNode , 0);

			if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_NAME))
				pInfo->m_szChildTagName = (TCHAR*)XmlGetName(pInfo->m_pChildNode);
			if (pInfo->m_pChildNode && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_CHILD_TAG_XMLNS))
				pInfo->m_szChildTagXmlns = (TCHAR*)XmlGetAttrValue(pNode, _T("xmlns"));
		}

		if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_TO)
			pInfo->m_szTo = (TCHAR*)XmlGetAttrValue(pNode, _T("to"));

		if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_FROM)
			pInfo->m_szFrom = (TCHAR*)XmlGetAttrValue(pNode, _T("from"));
		if (pInfo->m_szFrom && (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_HCONTACT))
			pInfo->m_hContact = ppro->HContactFromJID(pInfo->m_szFrom);

		if (pInfo->m_dwParamsToParse & JABBER_IQ_PARSE_ID_STR)
			pInfo->m_szId = (TCHAR*)XmlGetAttrValue(pNode, _T("id"));

		(ppro->*(pInfo->m_pHandler))(pNode, pInfo);
		delete pInfo;
	}
		while ((pInfo = DetouchInfo(nIqId)) != NULL);
	return true;
}
예제 #14
0
static BOOL CALLBACK TranslateDialogEnumProc(HWND hwnd, LPARAM lParam)
{
	int _hLangpack = (int)lParam;
	MUUID *uuid = Langpack_LookupUuid(_hLangpack);

	TCHAR szClass[32];
	GetClassName(hwnd, szClass, _countof(szClass));
	if (!mir_tstrcmpi(szClass, _T("static")) || !mir_tstrcmpi(szClass, _T("hyperlink")) || !mir_tstrcmpi(szClass, _T("button")) || !mir_tstrcmpi(szClass, _T("MButtonClass")) || !mir_tstrcmpi(szClass, _T("MHeaderbarCtrl")))
		TranslateWindow(uuid, hwnd);
	else if (!mir_tstrcmpi(szClass, _T("edit"))) {
		if (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY)
			TranslateWindow(uuid, hwnd);
	}
	return TRUE;
}
예제 #15
0
SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* currSession, SESSION_INFO* prevSession, const TCHAR* pszOriginal, const TCHAR* pszCurrent)
{
	SESSION_INFO* pResult = NULL;
	if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
		pResult = currSession;
	else {
		TCHAR* pszName = NULL;
		SESSION_INFO* pTemp = pci->wndList;
		if (currSession == prevSession)
			pszCurrent = pszOriginal;

		while (pTemp != NULL) {
			if (pTemp != currSession && !mir_strcmpi(pszModule, pTemp->pszModule)) {
				if (my_strstri(pTemp->ptszName, pszOriginal) == pTemp->ptszName) {
					if (prevSession != pTemp && mir_tstrcmpi(pTemp->ptszName, pszCurrent) > 0 && (!pszName || mir_tstrcmpi(pTemp->ptszName, pszName) < 0)) {
						pResult = pTemp;
						pszName = pTemp->ptszName;
					}
				}
			}
			pTemp = pTemp->next;
		}
	}
	return pResult;
}
예제 #16
0
	static BOOL EnumProfilesForList(TCHAR *tszFullPath, TCHAR *profile, LPARAM lParam)
	{
		ProfileEnumData *ped = (ProfileEnumData*)lParam;
		CCtrlListView &list = ped->list;

		TCHAR sizeBuf[64];
		bool bFileLocked = true;

		TCHAR *p = _tcsrchr(profile, '.');
		mir_tstrcpy(sizeBuf, _T("0 KB"));
		if (p != NULL) *p = 0;

		LVITEM item = { 0 };
		item.mask = LVIF_TEXT | LVIF_IMAGE;
		item.pszText = profile;
		item.iItem = 0;

		struct _stat statbuf;
		if (_tstat(tszFullPath, &statbuf) == 0) {
			if (statbuf.st_size > 1000000) {
				mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0);
				mir_tstrcpy(sizeBuf + 5, _T(" MB"));
			}
			else {
				mir_sntprintf(sizeBuf, _countof(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0);
				mir_tstrcpy(sizeBuf + 5, _T(" KB"));
			}
			bFileLocked = !fileExist(tszFullPath);
		}

		DATABASELINK *dblink;
		switch (touchDatabase(tszFullPath, &dblink)) {
		case ERROR_SUCCESS:
			item.iImage = bFileLocked;
			break;

		case EGROKPRF_OBSOLETE:
			item.iImage = 2;
			break;

		default:
			item.iImage = 3;
		}

		int iItem = list.InsertItem(&item);
		if (mir_tstrcmpi(ped->szProfile, tszFullPath) == 0)
			list.SetItemState(iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);

		list.SetItemText(iItem, 2, sizeBuf);

		if (dblink != NULL) {
			if (bFileLocked) // file locked
				list.SetItemText(iItem, 1, TranslateT("<In use>"));
			else
				list.SetItemText(iItem, 1, TranslateTS(dblink->szFullName));
		}
		else list.SetItemText(iItem, 1, TranslateT("<Unknown format>"));

		return TRUE;
	}
예제 #17
0
void CToxOptionsMain::ProfileExport_OnClick(CCtrlButton*)
{
	TCHAR filter[MAX_PATH];
	mir_sntprintf(filter, _T("%s(*.tox)%c*.tox%c%c"),
		TranslateT("Tox profile"), 0, 0, 0);

	TCHAR profilePath[MAX_PATH];
	mir_tstrncpy(profilePath, _T("tox_save.tox"), _countof(profilePath));

	OPENFILENAME ofn = { sizeof(ofn) };
	ofn.hwndOwner = m_hwnd;
	ofn.lpstrFilter = filter;
	ofn.nFilterIndex = 0;
	ofn.lpstrFile = profilePath;
	ofn.lpstrTitle = TranslateT("Save Tox profile");
	ofn.nMaxFile = MAX_PATH;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_EXPLORER;
	ofn.lpstrInitialDir = _T("%HOMEPATH%");

	if (!GetSaveFileName(&ofn))
		return;

	ptrT defaultProfilePath(m_proto->GetToxProfilePath());
	if (mir_tstrcmpi(profilePath, defaultProfilePath) != 0)
		CopyFile(defaultProfilePath, profilePath, FALSE);
}
예제 #18
0
void* AddTempGroup(HWND hwnd, ClcData *dat, const TCHAR *szName, DWORD flags, int groupId, int calcTotalMembers)
{
	int i = 0;
	int f = 0;
	DWORD groupFlags;

	if (wildcmp(_T2A(szName), "-@-HIDDEN-GROUP-@-"))
		return NULL;

	for (i = 1;; i++) {
		TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags);
		if (szGroupName == NULL) break;
		if (!mir_tstrcmpi(szGroupName, szName)) f = 1;
	}
	if (!f) {
		char buf[20];
		TCHAR b2[255];
		void * res = NULL;
		mir_snprintf(buf, SIZEOF(buf), "%d", (i - 1));
		mir_sntprintf(b2, SIZEOF(b2), _T("#%s"), szName);
		b2[0] = 1 | GROUPF_EXPANDED;
		db_set_ws(NULL, "CListGroups", buf, b2);
		pcli->pfnGetGroupName(i, &groupFlags);
		res = cli_AddGroup(hwnd, dat, szName, groupFlags, i, 0);
		return res;
	}
	return NULL;
}
예제 #19
0
void CJabberDlgBookmarks::OpenBookmark()
{
	int iItem = m_lvBookmarks.GetNextItem(-1, LVNI_SELECTED);
	if (iItem < 0) return;

	TCHAR *address = (TCHAR *)m_lvBookmarks.GetItemData(iItem);
	if (address == NULL) return;

	JABBER_LIST_ITEM *item = m_proto->ListGetItemPtr(LIST_BOOKMARK, address);
	if (item == NULL) return;

	if (!mir_tstrcmpi(item->type, _T("conference"))) {
		m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item

		/* some hack for using bookmark to transport not under XEP-0048 */
		if (!_tcschr(item->jid, _T('@')))
			//the room name is not provided let consider that it is transport and send request to registration
			m_proto->RegisterAgent(NULL, item->jid);
		else {
			TCHAR *room = NEWTSTR_ALLOCA(item->jid);
			TCHAR *server = _tcschr(room, _T('@'));
			*(server++) = 0;

			if (item->nick && *item->nick)
				m_proto->GroupchatJoinRoom(server, room, item->nick, item->password);
			else
				m_proto->GroupchatJoinRoom(server, room, ptrT(JabberNickFromJID(m_proto->m_szJabberJID)), item->password);
		}
	}
	else Utils_OpenUrlT(item->jid);
}
예제 #20
0
void CVkOptionAccountForm::OnInitDialog()
{
	m_ptszOldLogin = m_edtLogin.GetText();
	m_edtLogin.SendMsg(EM_LIMITTEXT, 1024, 0);

	m_ptszOldPass = m_proto->GetUserStoredPassword();
	m_edtPassword.SetText(m_ptszOldPass);
	m_edtPassword.SendMsg(EM_LIMITTEXT, 1024, 0);

	m_ptszOldGroup = m_edtGroupName.GetText();

	m_cbMarkMessageOnRead.SetState(m_proto->m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnRead);
	m_cbMarkMessageOnReceive.SetState(m_proto->m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReceive);
	m_cbMarkMessageOnReply.SetState(m_proto->m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnReply);
	m_cbMarkMessageOnTyping.SetState(m_proto->m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnTyping);

	m_cbSyncHistoryOff.SetState(m_proto->m_vkOptions.iSyncHistoryMetod == SyncHistoryMetod::syncOff);
	m_cbSyncHistoryAuto.SetState(m_proto->m_vkOptions.iSyncHistoryMetod == SyncHistoryMetod::syncAuto);
	m_cbSyncHistoryForLast1Day.SetState(m_proto->m_vkOptions.iSyncHistoryMetod == SyncHistoryMetod::sync1Days);
	m_cbSyncHistoryForLast3Day.SetState(m_proto->m_vkOptions.iSyncHistoryMetod == SyncHistoryMetod::sync3Days);
	
	for (size_t i = 0; i < _countof(vkLangCodes); i++) {
		m_cbxVKLang.AddString(TranslateTS(vkLangCodes[i].szDescription), (LPARAM)vkLangCodes[i].szCode);
		if (!mir_tstrcmpi(vkLangCodes[i].szCode, m_proto->m_vkOptions.ptszVKLang))
			m_cbxVKLang.SetCurSel(i);
	}
	
}
예제 #21
0
void CToxOptionsMain::ProfileImport_OnClick(CCtrlButton*)
{
	TCHAR filter[MAX_PATH];
	mir_sntprintf(filter, _T("%s(*.tox)%c*.tox%c%s(*.*)%c*.*%c%c"),
		TranslateT("Tox profile"), 0, 0, TranslateT("All files"), 0, 0, 0);

	TCHAR profilePath[MAX_PATH] = { 0 };

	OPENFILENAME ofn = { sizeof(ofn) };
	ofn.hwndOwner = m_hwnd;
	ofn.lpstrFilter = filter;
	ofn.nFilterIndex = 1;
	ofn.lpstrFile = profilePath;
	ofn.lpstrTitle = TranslateT("Select Tox profile");
	ofn.nMaxFile = MAX_PATH;
	ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
	ofn.lpstrInitialDir = _T("%APPDATA%\\Tox");

	if (!GetOpenFileName(&ofn))
		return;

	ptrT defaultProfilePath(m_proto->GetToxProfilePath());
	if (mir_tstrcmpi(profilePath, defaultProfilePath) != 0)
		CopyFile(profilePath, defaultProfilePath, FALSE);

	m_profileCreate.OnClick(&m_profileCreate);
}
예제 #22
0
	// This method clears the list and adds contacts again, according to the current filter settings.
	void RebuildList()
	{
		LPSTR pszProto;
		MTime mtNow;
		MAnnivDate ad;
		int i = 0;
		DWORD age = 0;
		WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
		WORD numMale = 0;
		WORD numFemale = 0;
		WORD numContacts = 0;
		WORD numBirthContacts = 0;

		ShowWindow(_hList, SW_HIDE);
		DeleteAllItems();
		mtNow.GetLocalTime();

		// insert the items into the list
		for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
			// ignore meta subcontacts here, as they are not interesting.
			if (!db_mc_isSub(hContact)) {
				// filter protocol
				pszProto = Proto_GetBaseAccountName(hContact);
				if (pszProto) {
					numContacts++;
					switch (GenderOf(hContact, pszProto)) {
					case 'M':
						numMale++;
						break;
					case 'F':
						numFemale++;
					}

					if (!ad.DBGetBirthDate(hContact, pszProto)) {
						age += ad.Age(&mtNow);
						numBirthContacts++;

						// add birthday
						if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto)))
							AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
					}

					// add anniversaries
					if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) 
						for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++)
							if (!_filter.pszAnniv || !mir_tstrcmpi(_filter.pszAnniv, ad.Description()))
								AddRow(hContact, pszProto, ad, mtNow, wDaysBefore);
				}
			}
		}
		ListView_SortItemsEx(_hList, (CMPPROC)cmpProc, this);
		ShowWindow(_hList, SW_SHOW);

		// display statistics
		SetDlgItemInt(_hDlg, TXT_NUMBIRTH, numBirthContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_NUMCONTACT, numContacts, FALSE);
		SetDlgItemInt(_hDlg, TXT_FEMALE, numFemale, FALSE);
		SetDlgItemInt(_hDlg, TXT_MALE, numMale, FALSE);
		SetDlgItemInt(_hDlg, TXT_AGE, numBirthContacts > 0 ? (age - (age % numBirthContacts)) / numBirthContacts : 0, FALSE);
	}
예제 #23
0
void* AddTempGroup(HWND hwnd, ClcData *dat, const TCHAR *szName)
{
	int i = 0;
	int f = 0;
	DWORD groupFlags;

	if (wildcmp(_T2A(szName), "-@-HIDDEN-GROUP-@-"))
		return NULL;

	for (i = 1;; i++) {
		TCHAR *szGroupName = pcli->pfnGetGroupName(i, &groupFlags);
		if (szGroupName == NULL) break;
		if (!mir_tstrcmpi(szGroupName, szName)) f = 1;
	}

	if (f)
		return NULL;

	char buf[20];
	_itoa_s(i - 1, buf, 10);

	TCHAR b2[255];
	mir_sntprintf(b2, _T("#%s"), szName);
	b2[0] = 1 | GROUPF_EXPANDED;
	db_set_ws(NULL, "CListGroups", buf, b2);
	pcli->pfnGetGroupName(i, &groupFlags);
	return cli_AddGroup(hwnd, dat, szName, groupFlags, i, 0);
}
예제 #24
0
bool CSteamProto::Relogin()
{
	ptrA token(getStringA("TokenSecret"));
	if (mir_strlen(token) <= 0)
		return false;

	HttpRequest *request = new LogonRequest(token);
	HttpResponse *response = request->Send(m_hNetlibUser);

	bool success = false;
	if (CheckResponse(response))
	{
		JSONROOT root(response->pData);
		if (root != NULL) {
			JSONNode *node = json_get(root, "error");

			ptrT error(json_as_string(node));
			if (!mir_tstrcmpi(error, _T("OK")))
			{
				node = json_get(root, "umqid");
				setString("UMQID", ptrA(mir_u2a(ptrT(json_as_string(node)))));

				node = json_get(root, "message");
				setDword("MessageID", json_as_int(node));

				success = true;
			}
		}
	}

	delete request;
	delete response;

	return success;
}
예제 #25
0
/*
*	Get the text for First Line
*/
void Cache_GetFirstLineText(ClcData *dat, ClcContact *contact)
{
	if (GetCurrentThreadId() != g_dwMainThreadID)
		return;

	ClcCacheEntry *pdnce = pcli->pfnGetCacheEntry(contact->hContact);
	TCHAR *name = pcli->pfnGetContactDisplayName(contact->hContact, 0);
	if (dat->first_line_append_nick && (!dat->force_in_dialog)) {
		DBVARIANT dbv = { 0 };
		if (!db_get_ts(pdnce->hContact, pdnce->m_cache_cszProto, "Nick", &dbv)) {
			TCHAR nick[_countof(contact->szText)];
			mir_tstrncpy(nick, dbv.ptszVal, _countof(contact->szText));
			db_free(&dbv);

			// They are the same -> use the name to keep the case
			if (mir_tstrcmpi(name, nick) == 0)
				mir_tstrncpy(contact->szText, name, _countof(contact->szText));
			else // Append then
				mir_sntprintf(contact->szText, _T("%s - %s"), name, nick);
		}
		else mir_tstrncpy(contact->szText, name, _countof(contact->szText));
	}
	else mir_tstrncpy(contact->szText, name, _countof(contact->szText));

	if (!dat->force_in_dialog) {
		SHORTDATA data = { 0 };
		Sync(CLUI_SyncGetShortData, (WPARAM)pcli->hwndContactTree, (LPARAM)&data);
		contact->ssText.ReplaceSmileys(&data, pdnce, contact->szText, dat->first_line_draw_smileys);
	}
}
예제 #26
0
 static int sortFunc(const CTimeZone *tz1, const CTimeZone *tz2)
 {
     int result = tz2->Bias - tz1->Bias;
     // DO NOT USE mir_tcsicmp here as it does only return TRUE or FALSE!!!
     // mir_tstrcmpi takes care of umlauts e.g. Ä,Ö,....
     return (result || !tz1->ptszDisplay || !tz2->ptszDisplay) ? result : mir_tstrcmpi(tz1->ptszDisplay, tz2->ptszDisplay);
 }
예제 #27
0
//************************************************************************
// Called to compare two entrys
//************************************************************************
bool CContactList::CompareEntries(CListEntry<CContactListEntry*,CContactListGroup*> *pLeft,CListEntry<CContactListEntry*,CContactListGroup*> *pRight)
{
	CContactListEntry *pLeftEntry = GetContactData(pLeft);
	CContactListEntry *pRightEntry = GetContactData(pRight);

	if(pLeftEntry && pRightEntry)
	{
		int iLeftMessages = pLeftEntry->iMessages;
		int iRightMessages = pRightEntry->iMessages;

		if(pLeft->GetType() == CONTAINER)
			iLeftMessages += ((CListContainer<CContactListEntry*,CContactListGroup*>*)pLeft)->GetGroupData()->iEvents;
		if(pRight->GetType() == CONTAINER)
			iRightMessages += ((CListContainer<CContactListEntry*,CContactListGroup*>*)pRight)->GetGroupData()->iEvents;

		if (!iRightMessages && iLeftMessages)
			return true;
		else if (iRightMessages && !iLeftMessages)
			return false;
		else if (iLeftMessages && iRightMessages)
			return (iLeftMessages > iRightMessages);
		else if(pLeftEntry->iStatus != pRightEntry->iStatus)
			return (aiStatusPriority[pLeftEntry->iStatus - ID_STATUS_OFFLINE] > aiStatusPriority[pRightEntry->iStatus - ID_STATUS_OFFLINE]);
		else
			return mir_tstrcmpi(pLeftEntry->strName.c_str(),pRightEntry->strName.c_str())<0;
	}
	else if(pLeft->GetType() == ITEM && pRight->GetType() == CONTAINER)
		return false;
	else if(pLeft->GetType() == CONTAINER && pRight->GetType() == ITEM)
		return true;
	else if(pLeft->GetType() == CONTAINER && pRight->GetType() == CONTAINER)
	{	
		CContactListGroup *pGroup1 = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pLeft)->GetGroupData();
		CContactListGroup *pGroup2 = ((CListContainer<CContactListEntry*,CContactListGroup*>*)pRight)->GetGroupData();

		if (!pGroup2->iEvents && pGroup1->iEvents)
			return true;
		else if (pGroup2->iEvents && !pGroup1->iEvents)
			return false;
		else if (pGroup1->iEvents && pGroup2->iEvents)
			return (pGroup1->iEvents > pGroup2->iEvents);
		else
			return mir_tstrcmpi(pGroup1->strName.c_str(),pGroup2->strName.c_str())<0;
	}

	return false;
}
예제 #28
0
BOOL CALLBACK ClosePopupFunc(__in  HWND hwnd, __in LPARAM lParam)
{
	DWORD pid = 0;
	GetWindowThreadProcessId(hwnd, &pid);
	if (pid != GetCurrentProcessId())
		return TRUE;

	POPUP_IDENT_STRINGS *ppis = (POPUP_IDENT_STRINGS*)lParam;
	POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)GetProp(hwnd, PLUGIN_DATA_PROP_NAME);
	if (!ppdh)
		return TRUE;

	if (!mir_tstrcmpi(ppis->url, ppdh->url) && !mir_tstrcmpi(ppis->jid, ppdh->jid))
		SendMessage(hwnd, MESSAGE_CLOSEPOPUP, 0, 0);

	return TRUE;
}
예제 #29
0
파일: inbox.cpp 프로젝트: Seldom/miranda-ng
void OpenContactInbox(LPCSTR szModuleName)
{
	ptrT tszJid(db_get_tsa(0, szModuleName, "jid"));
	if (tszJid == NULL)
		return;

	LPTSTR host = _tcschr(tszJid, '@');
	if (!host)
		return;
	*host++ = 0;

	TCHAR buf[1024];
	if (mir_tstrcmpi(host, COMMON_GMAIL_HOST1) && mir_tstrcmpi(host, COMMON_GMAIL_HOST2))
		mir_sntprintf(buf, INBOX_URL_FORMAT, _T("a/"), host);   // hosted
	else
		mir_sntprintf(buf, INBOX_URL_FORMAT, _T(""), _T("mail")); // common
	OpenUrl(szModuleName, tszJid, buf);
}
예제 #30
0
BOOL Equals(const LISTENINGTOINFO *lti1, const LISTENINGTOINFO *lti2)
{
	if (lti1->cbSize != lti2->cbSize)
		return FALSE;

	return mir_tstrcmpi(lti1->ptszArtist, lti2->ptszArtist) == 0 
		&& mir_tstrcmpi(lti1->ptszAlbum, lti2->ptszAlbum) == 0 
		&& mir_tstrcmpi(lti1->ptszTitle, lti2->ptszTitle) == 0 
		&& mir_tstrcmpi(lti1->ptszTrack, lti2->ptszTrack) == 0 
		&& mir_tstrcmpi(lti1->ptszYear, lti2->ptszYear) == 0 
		&& mir_tstrcmpi(lti1->ptszGenre, lti2->ptszGenre) == 0 
		&& mir_tstrcmpi(lti1->ptszLength, lti2->ptszLength) == 0 
		&& mir_tstrcmpi(lti1->ptszPlayer, lti2->ptszPlayer) == 0 
		&& mir_tstrcmpi(lti1->ptszType, lti2->ptszType) == 0;
}