コード例 #1
0
TNtlmAuth::TNtlmAuth(ThreadData *info, const char* mechanism, const TCHAR *hostname) :
	TJabberAuth(info)
{
	szName = mechanism;
	szHostName = hostname;

	const TCHAR *szProvider;
	if (!mir_strcmp(mechanism, "GSS-SPNEGO"))
		szProvider = _T("Negotiate");
	else if (!mir_strcmp(mechanism, "GSSAPI"))
		szProvider = _T("GSSAPI");
	else if (!mir_strcmp(mechanism, "NTLM"))
		szProvider = _T("NTLM");
	else {
LBL_Invalid:
		bIsValid = false;
		hProvider = NULL;
		return;
	}

	TCHAR szSpn[1024] = _T("");
	if (mir_strcmp(mechanism, "NTLM"))
		if (!getSpn(szSpn, _countof(szSpn)) && !mir_strcmp(mechanism, "GSSAPI"))
			goto LBL_Invalid;

	if ((hProvider = Netlib_InitSecurityProvider2(szProvider, szSpn)) == NULL)
		bIsValid = false;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: Seldom/miranda-ng
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;
}
コード例 #3
0
ファイル: services.cpp プロジェクト: biddyweb/miranda-ng
static void ReloadMyAvatar(LPVOID lpParam)
{
	char *szProto = (char *)lpParam;

	mir_sleep(500);
	for (int i = 0; !g_shutDown && i < g_MyAvatars.getCount(); i++) {
		char *myAvatarProto = g_MyAvatars[i].szProtoname;

		if (szProto[0] == 0) {
			// Notify to all possibles
			if (mir_strcmp(myAvatarProto, szProto)) {
				if (!ProtoServiceExists(myAvatarProto, PS_SETMYAVATAR))
					continue;
				if (!Proto_IsAvatarsEnabled(myAvatarProto))
					continue;
			}

		}
		else if (mir_strcmp(myAvatarProto, szProto))
			continue;

		if (g_MyAvatars[i].hbmPic)
			DeleteObject(g_MyAvatars[i].hbmPic);

		if (CreateAvatarInCache(INVALID_CONTACT_ID, &g_MyAvatars[i], myAvatarProto) != -1)
			NotifyEventHooks(hMyAvatarChanged, (WPARAM)myAvatarProto, (LPARAM)&g_MyAvatars[i]);
		else
			NotifyEventHooks(hMyAvatarChanged, (WPARAM)myAvatarProto, 0);
	}

	free(lpParam);
}
コード例 #4
0
void cli_AddContactToTree(HWND hwnd,struct ClcData *dat,HANDLE hContact,int updateTotalCount,int checkHideOffline)
{
	struct ClcGroup *group;
	struct ClcContact * cont;
	pdisplayNameCacheEntry cacheEntry=(pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(hContact);
	if(dat->IsMetaContactsEnabled && cacheEntry && cacheEntry->HiddenSubcontact) return;		//contact should not be added
	if(!dat->IsMetaContactsEnabled && cacheEntry && !mir_strcmp(cacheEntry->szProto,"MetaContacts")) return;
	saveAddContactToTree(hwnd,dat,hContact,updateTotalCount,checkHideOffline);
	if (FindItem(hwnd,dat,hContact,&cont,&group,NULL,FALSE))
	{
		if (cont)
		{
			//Add subcontacts
			if (cont && cont->proto)
			{	
				cont->SubAllocated=0;
				if (mir_strcmp(cont->proto,"MetaContacts")==0) 
					AddSubcontacts(dat,cont,IsShowOfflineGroup(group));
			}
			cont->avatar_pos=AVATAR_POS_DONT_HAVE;
			Cache_GetAvatar(dat,cont);
			Cache_GetText(dat,cont,1);
			Cache_GetTimezone(dat,cont->hContact);
		}
	}
	return;
}
コード例 #5
0
ファイル: contactcache.cpp プロジェクト: kmdtukl/miranda-ng
/**
 * update all or only the given status message information from the database
 *
 * @param szKey: char* database key name or 0 to reload all messages
 */
void CContactCache::updateStatusMsg(const char *szKey)
{
	if (!m_Valid)
		return;

	MCONTACT hContact = getActiveContact();

	if (szKey == 0 || (szKey && !mir_strcmp("StatusMsg", szKey))) {
		if (m_szStatusMsg)
			mir_free(m_szStatusMsg);
		m_szStatusMsg = 0;
		ptrT szStatus(db_get_tsa(hContact, "CList", "StatusMsg"));
		if (szStatus != 0)
			m_szStatusMsg = (mir_tstrlen(szStatus) > 0 ? getNormalizedStatusMsg(szStatus) : 0);
	}
	if (szKey == 0 || (szKey && !mir_strcmp("ListeningTo", szKey))) {
		if (m_ListeningInfo)
			mir_free(m_ListeningInfo);
		m_ListeningInfo = 0;
		ptrT szListeningTo(db_get_tsa(hContact, cc->szProto, "ListeningTo"));
		if (szListeningTo != 0 && *szListeningTo)
			m_ListeningInfo = szListeningTo.detach();
	}
	if (szKey == 0 || (szKey && !mir_strcmp("XStatusMsg", szKey))) {
		if (m_xStatusMsg)
			mir_free(m_xStatusMsg);
		m_xStatusMsg = 0;
		ptrT szXStatusMsg(db_get_tsa(hContact, cc->szProto, "XStatusMsg"));
		if (szXStatusMsg != 0 && *szXStatusMsg)
			m_xStatusMsg = szXStatusMsg.detach();
	}
	m_xStatus = db_get_b(hContact, cc->szProto, "XStatusId", 0);
}
コード例 #6
0
HANDLE CheckNewContact(char *myProto, char *uid, char *myName)
{
	char szProto[256], szName[256];
	HANDLE resultHandle = INVALID_HANDLE_VALUE;
	HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);

	while (hContact)
	{
		//szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
		if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, 256))
		{
			if (!mir_strcmp(szProto, myProto))
			{
				if (GetValue(hContact, szProto, uid, szName, SIZEOF(szName)) &&
					!mir_strcmp(szName, myName))
				{
					//char msg[1024];
					//_snprintf(msg, 1024, Translate("Do you want to overwrite it \"%s\"?"), szName);
					//if (MessageBox(0,msg, Translate("Contact already exists"), MB_YESNO|MB_ICONEXCLAMATION) == IDYES)
					resultHandle = hContact;
					break;
				}
			}
		}

		hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
	}

	return resultHandle;

}
コード例 #7
0
ファイル: http.cpp プロジェクト: martok/miranda-ng
// function to download webpage from the internet
// szUrl = URL of the webpage to be retrieved
// return value = 0 for success, 1 or HTTP error code for failure
// global var used: szData, szInfo = containing the retrieved data
int InternetDownloadFile (char *szUrl) 
{
	NETLIBHTTPREQUEST nlhr={0};

	// initialize the netlib request
	nlhr.cbSize=sizeof(nlhr);
	nlhr.requestType=REQUEST_GET;
	nlhr.flags=NLHRF_DUMPASTEXT;
	nlhr.szUrl= szUrl;
	// change the header so the plugin is pretended to be IE 6 + WinXP
	nlhr.headersCount++;
	nlhr.headers=(NETLIBHTTPHEADER*)malloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
	memcpy(nlhr.headers,nlhr.headers,sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
	nlhr.headers[nlhr.headersCount-1].szName="User-Agent";
	nlhr.headers[nlhr.headersCount-1].szValue="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

	// download the page
	NETLIBHTTPREQUEST *nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlibUser,(LPARAM)&nlhr);
	if (nlhrReply) {
		// return error code if the recieved code is neither 200 OK or 302 Moved
		if (nlhrReply->resultCode != 200 && nlhrReply->resultCode != 302)
			return nlhrReply->resultCode;
		// if the recieved code is 200 OK
		else if (nlhrReply->resultCode == 200) 
		{
			// allocate memory and save the retrieved data
			szData = (char *)malloc(mir_strlen(nlhrReply->pData)+2);
			mir_strncpy(szData, nlhrReply->pData, mir_strlen(nlhrReply->pData));
		}
		// if the recieved code is 302 Moved, Found, etc
		else if (nlhrReply->resultCode == 302) 
		{	// page moved
			int i;
			// get the url for the new location and save it to szInfo
			// look for the reply header "Location"
			for (i=0; i<nlhrReply->headersCount; i++) {
				if (!mir_strcmp(nlhrReply->headers[i].szName, "Location")) {
					szData = (char *)malloc(512);
					// add "Moved/Location:" in front of the new URL for identification
					mir_snprintf(szData, 512, "Moved/Location: %s\n", nlhrReply->headers[i].szValue);
					break;
				}
			}
			// log the new url into netlib log
			CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szData);
		}
	}
	// if the data does not downloaded successfully (ie. disconnected), then return 1 as error code
	else   return 1;

	// make a copy of the retrieved data, then free the memory of the http reply
	szInfo = szData;
	CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);

	// the recieved data is empty, data was not recieved, so return an error code of 1
	if (!mir_strcmp(szInfo, ""))  return 1;
	return 0;
}
コード例 #8
0
ファイル: hooked_events.cpp プロジェクト: kmdtukl/miranda-ng
static int OnContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
	DBCONTACTWRITESETTING *dw = (DBCONTACTWRITESETTING *)lParam;
	DBVARIANT dv = dw->value;
	if ((mir_strcmp(dw->szModule, DUMMY_MODULE) == 0) && (mir_strcmp(dw->szSetting, DUMMY_SETTING) == 0))
		RefreshContactListIcons(hContact);

	return 0;
}
コード例 #9
0
static int ContactSettingChanged(WPARAM wParam, LPARAM lParam)
{
	DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
	char *szProto = GetContactProto(wParam);
	if (mir_strcmp(cws->szModule, "CList") && (szProto == NULL || mir_strcmp(cws->szModule, szProto)))
		return 0;

	WindowList_Broadcast(hUrlWindowList, DM_UPDATETITLE, 0, 0);
	return 0;
}
コード例 #10
0
ファイル: dbsettings.cpp プロジェクト: kmdtukl/miranda-ng
static bool ValidLookupName(LPCSTR szModule, LPCSTR szSetting)
{
	if (!mir_strcmp(szModule, META_PROTO))
		return mir_strcmp(szSetting, "IsSubcontact") && mir_strcmp(szSetting, "ParentMetaID");

	if (!mir_strcmp(szModule, "Ignore"))
		return false;

	return true;
}
コード例 #11
0
ファイル: yamn.cpp プロジェクト: kmdtukl/miranda-ng
INT_PTR GetFcnPtrSvc(WPARAM wParam, LPARAM lParam)
{
	register int i;

	for (i=0;i<sizeof(ProtoPluginExportedFcn)/sizeof(ProtoPluginExportedFcn[0]);i++)
		if (0==mir_strcmp((char *)wParam, ProtoPluginExportedFcn[i].ID))
			return (INT_PTR)ProtoPluginExportedFcn[i].Ptr;
	for (i=0;i<sizeof(ProtoPluginExportedSvc)/sizeof(ProtoPluginExportedSvc[0]);i++)
		if (0==mir_strcmp((char *)wParam, ProtoPluginExportedSvc[i].ID))
			return (INT_PTR)ProtoPluginExportedSvc[i].Ptr;
	for (i=0;i<sizeof(SynchroExportedFcn)/sizeof(SynchroExportedFcn[0]);i++)
		if (0==mir_strcmp((char *)wParam, SynchroExportedFcn[i].ID))
			return (INT_PTR)SynchroExportedFcn[i].Ptr;
	for (i=0;i<sizeof(AccountExportedFcn)/sizeof(AccountExportedFcn[0]);i++)
		if (0==mir_strcmp((char *)wParam, AccountExportedFcn[i].ID))
			return (INT_PTR)AccountExportedFcn[i].Ptr;
	for (i=0;i<sizeof(AccountExportedSvc)/sizeof(AccountExportedSvc[0]);i++)
		if (0==mir_strcmp((char *)wParam, AccountExportedSvc[i].ID))
			return (INT_PTR)AccountExportedSvc[i].Ptr;
	for (i=0;i<sizeof(MailExportedFcn)/sizeof(MailExportedFcn[0]);i++)
		if (0==mir_strcmp((char *)wParam, MailExportedFcn[i].ID))
			return (INT_PTR)MailExportedFcn[i].Ptr;
	for (i=0;i<sizeof(MailExportedSvc)/sizeof(MailExportedSvc[0]);i++)
		if (0==mir_strcmp((char *)wParam, MailExportedSvc[i].ID))
			return (INT_PTR)MailExportedSvc[i].Ptr;
	for (i=0;i<sizeof(FilterPluginExportedFcn)/sizeof(FilterPluginExportedFcn[0]);i++)
		if (0==mir_strcmp((char *)wParam, FilterPluginExportedFcn[i].ID))
			return (INT_PTR)FilterPluginExportedFcn[i].Ptr;
	for (i=0;i<sizeof(FilterPluginExportedSvc)/sizeof(FilterPluginExportedSvc[0]);i++)
		if (0==mir_strcmp((char *)wParam, FilterPluginExportedSvc[i].ID))
			return (INT_PTR)FilterPluginExportedSvc[i].Ptr;
	return (INT_PTR)NULL;
}
コード例 #12
0
ファイル: dumper.cpp プロジェクト: kmdtukl/miranda-ng
void GetLinkedModulesInfo(TCHAR *moduleName, CMString &buffer)
{
	HANDLE hDllFile = CreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hDllFile == INVALID_HANDLE_VALUE)
		return;

	HANDLE hDllMapping = CreateFileMapping(hDllFile, NULL, PAGE_READONLY, 0, 0, NULL);
	if (hDllMapping == INVALID_HANDLE_VALUE) {
		CloseHandle(hDllFile);
		return;
	}

	LPVOID dllAddr = MapViewOfFile(hDllMapping, FILE_MAP_READ, 0, 0, 0);

	static const TCHAR format[] = TEXT("    Plugin statically linked to missing module: %S\r\n");

	__try {
		PIMAGE_NT_HEADERS nthdrs = ImageNtHeader(dllAddr);

		ULONG tableSize;
		PIMAGE_IMPORT_DESCRIPTOR importData = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(dllAddr, FALSE,
			IMAGE_DIRECTORY_ENTRY_IMPORT, &tableSize);
		if (importData) {
			while (importData->Name) {
				char* moduleName = (char*)ImageRvaToVa(nthdrs, dllAddr, importData->Name, NULL);
				if (!SearchPathA(NULL, moduleName, NULL, NULL, 0, NULL))
					buffer.AppendFormat(format, moduleName);

				importData++; //go to next record
			}
		}

		bool found = false;
		PIMAGE_EXPORT_DIRECTORY exportData = (PIMAGE_EXPORT_DIRECTORY)ImageDirectoryEntryToData(dllAddr, FALSE,
			IMAGE_DIRECTORY_ENTRY_EXPORT, &tableSize);
		if (exportData) {
			ULONG* funcAddr = (ULONG*)ImageRvaToVa(nthdrs, dllAddr, exportData->AddressOfNames, NULL);
			for (unsigned i = 0; i < exportData->NumberOfNames && !found; ++i) {
				char* funcName = (char*)ImageRvaToVa(nthdrs, dllAddr, funcAddr[i], NULL);
				found = mir_strcmp(funcName, "MirandaPluginInfoEx") == 0 || mir_strcmp(funcName, "MirandaPluginInfo") == 0;
				if (mir_strcmp(funcName, "DatabasePluginInfo") == 0) {
					buffer.Append(TEXT("    This dll is a Miranda database plugin, another database is active right now\r\n"));
					found = true;
				}
			}
		}
		if (!found)
			buffer.Append(TEXT("    This dll is not a Miranda plugin and should be removed from plugins directory\r\n"));
	}
	__except (EXCEPTION_EXECUTE_HANDLER) {}

	UnmapViewOfFile(dllAddr);
	CloseHandle(hDllMapping);
	CloseHandle(hDllFile);
}
コード例 #13
0
ファイル: test.cpp プロジェクト: Seldom/miranda-ng
static int IcqOpenFile(WPARAM wParam, LPARAM lParam)
{
	TCHAR *pszFile = (TCHAR*)lParam; /* TCHAR is specified on AssocMgr_AddNewFileTypeT() */
	FILE *fp;
	ICQFILEINFO info;
	char line[4096], *sep;
	UNREFERENCED_PARAMETER(wParam);
	/*
		send message:
		[ICQ Message User]
		UIN=1234567

		add user:
		(all the .uin files I've seen only have UIN= in them)
		[ICQ User]
		UIN=1234567
		Email=
		NickName=
		FirstName=
		LastName=
	*/
	if (pszFile == NULL) return 1; /* sanity check */
	fp = _tfopen(pszFile, _T("rt"));
	if (fp == NULL) return 1; /* open failed */
	info.type = 0;
	while (!feof(fp)) {
		if (fgets(line, sizeof(line), fp) == NULL) break;
		TrimString(line);
		if (IsEmpty(line)) continue;
		if (line[0] == '[') {
			memset(&info, 0, sizeof(info));
			if (!mir_strcmpi(line, "[ICQ Message User]"))
				info.type = ICQFILE_MESSAGEUSER;
			else if (!mir_strcmpi(line, "[ICQ User]"))
				info.type = ICQFILE_ADDUSER;
			continue;
		}
		if (info.type == 0) continue;
		sep = strchr(line, '=');
		if (sep == NULL) { info.type = 0; break; } /* format error */
		*(sep++) = '\0';
		if (!mir_strcmp("UIN", line)) mir_strncpy(info.uin, sep, sizeof(info.uin)); /* buffer safe */
		else if (!mir_strcmp("Email", line)) mir_strncpy(info.email, sep, sizeof(info.email)); /* buffer safe */
		else if (!mir_strcmp("NickName", line)) mir_strncpy(info.nick, sep, sizeof(info.nick)); /* buffer safe */
		else if (!mir_strcmp("FirstName", line)) mir_strncpy(info.firstName, sep, sizeof(info.firstName)); /* buffer safe */
		else if (!mir_strcmp("LastName", line)) mir_strncpy(info.lastName, sep, sizeof(info.lastName)); /* buffer safe */
	}
	fclose(fp);
	switch (info.type) {
	case ICQFILE_MESSAGEUSER: MessageIcqUser(&info); return 0;
	case ICQFILE_ADDUSER:     AddIcqUser(&info); return 0;
	default: return 1; /* open failed */
	}
}
コード例 #14
0
ファイル: userlist.cpp プロジェクト: ybznek/miranda-ng
void CSametimeProto::AddGroup(const char* name, bool expanded)
{
	if (name && mir_strcmp(name, "MetaContacts Hidden Group") == 0)
		return;

	if (name && mir_strcmp(name, Translate("None")) == 0)
		return;

	MGROUP hGroup = Clist_GroupCreate(NULL, ptrT(mir_utf8decodeT(name)));
	Clist_GroupSetExpanded(hGroup, expanded);
}
コード例 #15
0
/**
 * If the user changes the name order update the global value.
 *
 * @param	wParam		- handle of the contact a setting was written for (must be NULL in this case)
 * @param	lParam		- DBCONTACTWRITESETTING structure holding information about the written data
 * @return	0
 **/
static INT OnSettingChanged(WPARAM wParam, LPARAM lParam)
{
	if ((HANDLE)wParam == NULL) {
		DBCONTACTWRITESETTING *pdbcws = (DBCONTACTWRITESETTING*) lParam;
		if (!mir_strcmp(pdbcws->szModule, "Contact") &&
			!mir_strcmp(pdbcws->szSetting, "NameOrder"))
		{
			memcpy(gNameOrder, pdbcws->value.pbVal,pdbcws->value.cpbVal);
		}
	}
	return 0;
}
コード例 #16
0
ファイル: svc_phone.cpp プロジェクト: kmdtukl/miranda-ng
static int OnContactSettingChanged(MCONTACT hContact, DBCONTACTWRITESETTING* pdbcws)
{
	if (hContact && pdbcws && pdbcws->szSetting && 
			((pdbcws->value.type & DBVTF_VARIABLELENGTH) || (pdbcws->value.type == DBVT_DELETED)) &&
			(!mir_strcmp(pdbcws->szSetting, SET_CONTACT_PHONE) ||
			 !mir_strcmp(pdbcws->szSetting, SET_CONTACT_CELLULAR) ||
			 !mir_strcmp(pdbcws->szSetting, SET_CONTACT_COMPANY_PHONE) ||
			 !mir_strcmp(pdbcws->szSetting, SET_CONTACT_COMPANY_CELLULAR) ||
			 !strncmp(pdbcws->szSetting, "MyPhone0", 8)))
		OnCListApplyIcons(hContact, 0);

	return 0;
}
コード例 #17
0
ファイル: watcher.cpp プロジェクト: biddyweb/miranda-ng
static int StatusSettingChanged(WPARAM wParam,LPARAM lParam)
{
	if (currentWatcherType&SDWTF_STATUS) {
		DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING*)lParam;
 		if ((HANDLE)wParam != NULL && dbcws->value.wVal==ID_STATUS_OFFLINE && !mir_strcmp(dbcws->szSetting,"Status")) {
			char *pszProto = GetContactProto(wParam);
			if (pszProto != NULL && !mir_strcmp(dbcws->szModule,pszProto))
				if (CheckAllContactsOffline())
					ShutdownAndStopWatcher();
		}
	}
	return 0;
}
コード例 #18
0
ファイル: groupchat.cpp プロジェクト: ybznek/miranda-ng
static MCONTACT gg_getsubcontact(GGPROTO* gg, MCONTACT hContact)
{
	char* szProto = GetContactProto(hContact);
	if (szProto && !mir_strcmp(szProto, META_PROTO)) {
		int nSubContacts = db_mc_getSubCount(hContact), i;
		for (i = 0; i < nSubContacts; i++) {
			MCONTACT hMetaContact = db_mc_getSub(hContact, i);
			szProto = GetContactProto(hMetaContact);
			if (szProto && !mir_strcmp(szProto, gg->m_szModuleName))
				return hMetaContact;
		}
	}
	return NULL;
}
コード例 #19
0
ファイル: Main.cpp プロジェクト: kmdtukl/miranda-ng
int OnSettingChanged(WPARAM wParam, LPARAM lParam)
{
	if (wParam != 0 || lParam == NULL)
		return 0;

	DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
	if (!mir_strcmp(dbcws->szModule, "Skin")) {
		if (!mir_strcmp(dbcws->szSetting, "UseSound")) {
			EnableFrameIcon(dbcws->value.bVal != 0);
			return 0;
		}
	}
	return 0;
}
コード例 #20
0
ファイル: main.cpp プロジェクト: MrtsComputers/miranda-ng
int DBSettingChanged(WPARAM wParam,LPARAM lParam)
{
	DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;
	HANDLE hContact = (HANDLE)wParam;
	char *setting;
	SettingListInfo* info;

	if (hwnd2mainWindow) {
		HWND hwnd2Settings = GetDlgItem(hwnd2mainWindow, IDC_SETTINGS);
		if (info = (SettingListInfo*)GetWindowLongPtr(hwnd2Settings, GWLP_USERDATA)) {
			if ((hContact == info->hContact) && !mir_strcmp(info->module, cws->szModule)) {
				setting = mir_strdup(cws->szSetting);
				if (cws->value.type == DBVT_DELETED) {
					LVFINDINFO lvfi;
					int index;
					lvfi.flags = LVFI_STRING;
					lvfi.psz = setting;
					lvfi.vkDirection = VK_DOWN;
					index = ListView_FindItem(hwnd2Settings, -1, &lvfi);
					if (index > -1)
						ListView_DeleteItem(hwnd2Settings, index);
					mir_free(setting);
					return 0;
				}
				settingChanged(hwnd2Settings, hContact, info->module, setting);
				mir_free(setting);
			}
		}
	}
	
	// watch list
	if (!hwnd2watchedVarsWindow && !usePopups)
		return 0;

	for (int i = 0; i < WatchListArray.count; i++) {
		if (WatchListArray.item[i].module && (hContact == WatchListArray.item[i].hContact)) {
			if (!mir_strcmp(cws->szModule, WatchListArray.item[i].module)) {
				if (!WatchListArray.item[i].setting || !mir_strcmp(cws->szSetting, WatchListArray.item[i].setting)) {
					if (usePopups)
						popupWatchedVar(hContact, cws->szModule, cws->szSetting);
					if (hwnd2watchedVarsWindow)
						PopulateWatchedWindow(GetDlgItem(hwnd2watchedVarsWindow, IDC_VARS));
					break;
				}
			}
		}
	}
	return 0;
}
コード例 #21
0
ファイル: dumper.cpp プロジェクト: kmdtukl/miranda-ng
static void GetProtocolStrings(CMString& buffer)
{
	PROTOACCOUNT **accList;
	int accCount;
	int i, j;

	Proto_EnumAccounts(&accCount, &accList);

	int protoCount;
	PROTOCOLDESCRIPTOR **protoList;
	Proto_EnumProtocols(&protoCount, &protoList);

	int protoCountMy = 0;
	char** protoListMy = (char**)alloca((protoCount + accCount) * sizeof(char*));

	for (i = 0; i < protoCount; i++) {
		if (protoList[i]->type != PROTOTYPE_PROTOCOL)
			continue;
		protoListMy[protoCountMy++] = protoList[i]->szName;
	}

	for (j = 0; j < accCount; j++) {
		for (i = 0; i < protoCountMy; i++)
			if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName))
				break;

		if (i == protoCountMy)
			protoListMy[protoCountMy++] = accList[j]->szProtoName;
	}

	ProtoCount *protos = (ProtoCount*)alloca(sizeof(ProtoCount) * protoCountMy);
	memset(protos, 0, sizeof(ProtoCount) * protoCountMy);

	for (j = 0; j < accCount; j++)
		for (i = 0; i < protoCountMy; i++)
			if (!mir_strcmp(protoListMy[i], accList[j]->szProtoName)) {
				protos[i].nloaded = accList[j]->bDynDisabled != 0;
				if (Proto_IsAccountEnabled(accList[j]))
					++protos[i].countse;
				else
					++protos[i].countsd;
				break;
			}

	for (i = 0; i < protoCountMy; i++)
		buffer.AppendFormat(TEXT("%-24s %d - Enabled %d - Disabled  %sLoaded\r\n"),
		(TCHAR*)_A2T(protoListMy[i]), protos[i].countse,
		protos[i].countsd, protos[i].nloaded ? _T("Not ") : _T(""));
}
コード例 #22
0
ファイル: extraimg.cpp プロジェクト: martok/miranda-ng
static int ExtraImgSettingChanged(WPARAM hContact, LPARAM lParam)
{
	DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam;
	if (hContact) {
		/* user details update */
		if (!mir_strcmp(dbcws->szSetting,"RealIP") || !mir_strcmp(dbcws->szSetting,"Country") || !mir_strcmp(dbcws->szSetting,"CompanyCountry")) {
			/* Extra Image */
			SetExtraImage(hContact);
			/* Status Icon */
			if (ServiceExists(MS_MSG_REMOVEICON))
				CallFunctionBuffered(UpdateStatusIcons,0,FALSE,STATUSICON_REFRESHDELAY);
		}
	}
	return 0;
}
コード例 #23
0
ファイル: clistmod.cpp プロジェクト: ybznek/miranda-ng
int IconFromStatusMode(const char *szProto, int status, MCONTACT hContact, HICON *phIcon)
{
	if (phIcon != NULL)
		*phIcon = NULL;

	char *szFinalProto;
	int finalStatus;

	if (szProto != NULL && !mir_strcmp(szProto, META_PROTO) && hContact != 0 && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) {
		MCONTACT hSubContact = db_mc_getMostOnline(hContact);
		szFinalProto = GetContactProto(hSubContact);
		finalStatus = (status == 0) ? (WORD)db_get_w(hSubContact, szFinalProto, "Status", ID_STATUS_OFFLINE) : status;
		hContact = hSubContact;
	}
	else {
		szFinalProto = (char*)szProto;
		finalStatus = status;
	}

	if (status >= ID_STATUS_CONNECTING && status < ID_STATUS_OFFLINE && phIcon != NULL) {
		if (szProto) {
			char szBuf[128];
			mir_snprintf(szBuf, "%s_conn", szProto);
			*phIcon = IcoLib_GetIcon(szBuf);
		}
	}

	return coreCli.pfnIconFromStatusMode(szFinalProto, finalStatus, hContact);
}
コード例 #24
0
ファイル: main.cpp プロジェクト: kxepal/miranda-ng
void createProtocolList(void)
{
	PROTOACCOUNT **proto;
	Proto_EnumAccounts(&ProtoList.protoCount, &proto);
	ProtoList.protoInfo = (PROTOCOL_INFO *)malloc(ProtoList.protoCount * sizeof(PROTOCOL_INFO));
	if (!ProtoList.protoInfo) {
		ProtoList.protoCount = 0;
		return;
	}

	for (int i = 0; i < ProtoList.protoCount; i++) {
		ProtoList.protoInfo[i].xstatus.count = 0;
		ProtoList.protoInfo[i].xstatus.enabled = NULL;
		ProtoList.protoInfo[i].szProto = (char *)malloc(mir_strlen(proto[i]->szModuleName) + 1);
		if (!ProtoList.protoInfo[i].szProto) {
			ProtoList.protoInfo[i].enabled = FALSE;
			ProtoList.protoInfo[i].visible = FALSE;
		}
		else {
			mir_strcpy(ProtoList.protoInfo[i].szProto, proto[i]->szModuleName);
			ProtoList.protoInfo[i].enabled = FALSE;
			if (!mir_strcmp(proto[i]->szModuleName, META_PROTO))
				ProtoList.protoInfo[i].visible = FALSE;
			else {
				ProtoList.protoInfo[i].visible = TRUE;
				updateXstatusProto(&(ProtoList.protoInfo[i]));
			}
		}
	}
}
コード例 #25
0
MIR_APP_DLL(HGENMENU) Menu_GetProtocolRoot(PROTO_INTERFACE *pThis)
{
	if (pThis == NULL)
		return 0;

	if (db_get_b(NULL, "CList", "MoveProtoMenus", TRUE)) {
		if (pThis->m_hMainMenuItem != NULL) {
			Menu_RemoveItem(pThis->m_hMainMenuItem);
			pThis->m_hMainMenuItem = NULL;
		}
		return cli.pfnGetProtocolMenu(pThis->m_szModuleName);
	}

	TIntMenuObject *pmo = GetMenuObjbyId(hMainMenuObject);
	if (pmo == NULL)
		return NULL;

	mir_cslock lck(csMenuHook);
	for (TMO_IntMenuItem *p = pmo->m_items.first; p != NULL; p = p->next)
		if (!mir_strcmp(p->UniqName, pThis->m_szModuleName))
			return p;

	// create protocol root in the main menu
	CMenuItem mi;
	mi.name.t = pThis->m_tszUserName;
	mi.position = 500090000;
	mi.flags = CMIF_TCHAR | CMIF_KEEPUNTRANSLATED;
	mi.hIcolibItem = pThis->m_hProtoIcon;
	return pThis->m_hMainMenuItem = Menu_AddMainMenuItem(&mi);
}
コード例 #26
0
ファイル: dbfilter.cpp プロジェクト: truefriend-cz/miranda-ng
int OnContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
	if (!options.end_offline)
		return 0;

	DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
	if (!lParam || mir_strcmp(cws->szSetting, "Status") != 0) return 0;
	int status = 0;
	switch (cws->value.type) {
	case DBVT_WORD:
		status = cws->value.wVal;
		break;
	case DBVT_BYTE:
		status = cws->value.bVal;
		break;
	case DBVT_DWORD:
		status = cws->value.dVal;
		break;
	}

	if (status == ID_STATUS_OFFLINE) {
		if (!hContact) {
			// Protocol is going offline
			// Terminate sessions with all contacts of that proto
			StatusModeChange((WPARAM)ID_STATUS_OFFLINE, (LPARAM)cws->szModule);
			return 0;
		}
		if (Proto_IsProtoOnContact(hContact, MODULENAME)) {
			// only care about contacts to which this filter is attached
			FinishSession(hContact);
		}
	}

	return 0;
}
コード例 #27
0
ファイル: tlen_userinfo.cpp プロジェクト: Seldom/miranda-ng
int TlenProtocol::UserInfoInit(WPARAM wParam, LPARAM lParam)
{
	if (!Proto_GetAccount(m_szModuleName))
		return 0;

	MCONTACT hContact = (MCONTACT) lParam;
	char *szProto = GetContactProto(hContact);
	if ((szProto != NULL && !mir_strcmp(szProto, m_szModuleName)) || !lParam) {
		OPTIONSDIALOGPAGE odp = { 0 };
		odp.hInstance = hInst;
		odp.flags = ODPF_TCHAR;
		odp.pfnDlgProc = TlenUserInfoDlgProc;
		odp.position = -2000000000;
		odp.pszTemplate = ((HANDLE)lParam != NULL) ? MAKEINTRESOURCEA(IDD_USER_INFO):MAKEINTRESOURCEA(IDD_USER_VCARD);
		odp.ptszTitle = (hContact != NULL) ? LPGENT("Account") : m_tszUserName;
		odp.dwInitParam = (LPARAM)this;
		UserInfo_AddPage(wParam, &odp);

	}
	if (!lParam && isOnline) {
		CCSDATA ccs = {0};
		GetInfo(0, (LPARAM) &ccs);
	}
	return 0;
}
コード例 #28
0
ファイル: netlibhttp.cpp プロジェクト: kxepal/miranda-ng
static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUser *nlu, NetlibConnection *nlc, const char *szUrl = NULL)
{
	NETLIBOPENCONNECTION nloc;

	if (szUrl == NULL)
		NetlibConnFromUrl(nlhr->szUrl, (nlhr->flags & NLHRF_SSL) != 0, nloc);
	else
		NetlibConnFromUrl(szUrl, false, nloc);

	nloc.flags |= NLOCF_HTTP;
	if (nloc.flags & NLOCF_SSL)
		nlhr->flags |= NLHRF_SSL;
	else
		nlhr->flags &= ~NLHRF_SSL;

	if (nlc != NULL) {
		bool httpProxy = !(nloc.flags & NLOCF_SSL) && nlc->proxyType == PROXYTYPE_HTTP;
		bool sameHost = mir_strcmp(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;

		if (!httpProxy && !sameHost) {
			NetlibDoClose(nlc);

			mir_free((char*)nlc->nloc.szHost);
			nlc->nloc = nloc;
			return NetlibDoConnect(nlc) ? nlc : NULL;
		}
	}
	else nlc = (NetlibConnection*)NetlibOpenConnection((WPARAM)nlu, (LPARAM)&nloc);

	mir_free((char*)nloc.szHost);

	return nlc;
}
コード例 #29
0
ファイル: events.cpp プロジェクト: truefriend-cz/miranda-ng
int ContactSettingChanged(WPARAM wParam,LPARAM lParam)
{
	MCONTACT hContact = (MCONTACT) wParam;
	DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;

	logmsg("ContactSettingChanged1");

	if(hContact==NULL || mir_strcmp(cws->szSetting,"Status")) return 0;

	WORD newStatus = cws->value.wVal;
	WORD oldStatus = DBGetContactSettingRangedWord(hContact,"UserOnline","OldStatus2",ID_STATUS_OFFLINE, ID_STATUS_MIN, ID_STATUS_MAX);
	
	if (oldStatus == newStatus) return 0;
	
	logmsg("ContactSettingChanged2");

	db_set_w(hContact,"UserOnline","OldStatus2", newStatus);

	if(CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE)) return 0;

	DWORD dwStatuses = MAKELPARAM(oldStatus, newStatus);
	NotifyEventHooks(hHookContactStatusChanged, wParam, (LPARAM)dwStatuses);

	return 0;
}
コード例 #30
0
ファイル: dbfilter.cpp プロジェクト: truefriend-cz/miranda-ng
// if it's a protocol going offline, attempt to send terminate session to all contacts of that protocol
// (this would be hooked as the ME_CLIST_STATUSMODECHANGE handler except that event is sent *after* the proto goes offline)
int StatusModeChange(WPARAM wParam, LPARAM lParam)
{
	int status = (int)wParam;
	if (status != ID_STATUS_OFFLINE)
		return 0;

	const char *proto = (char *)lParam;

	lib_cs_lock();

	ConnContext *context = otr_user_state->context_root;
	while (context) {
		if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED && (proto == 0 || mir_strcmp(proto, context->protocol) == 0)) {
			MCONTACT hContact = (UINT_PTR)context->app_data;

			if (hContact) {
				otrl_message_disconnect(otr_user_state, &ops, (void*)hContact, context->accountname, context->protocol, context->username, OTRL_INSTAG_BEST);
				SetEncryptionStatus(hContact, TRUST_NOT_PRIVATE);
			}

		}
		context = context->next;
	}

	return 0;
}