Пример #1
0
void Notify(HANDLE hContact, TCHAR *text)
{
	if (text != NULL && text[0] == _T('\0'))
		text = NULL;

	if (!opts.track_changes && text != NULL)
		return;

	if (!opts.track_removes && text == NULL)
		return;

	// Replace template with nick
	TCHAR templ[1024];
	lstrcpyn(templ, text == NULL ? opts.template_removed : opts.template_changed, MAX_REGS(templ));
	ReplaceChars(templ);

	TCHAR log[1024];
	mir_sntprintf(log, sizeof(log), templ, 
		text == NULL ? TranslateT("<no nickname>") : text);

	if (opts.history_enable)
		HistoryLog(hContact, log);

	if (opts.popup_enable)
		ShowPopup(hContact, NULL, log);
}
Пример #2
0
int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int sigLen) {
    int v=0, k=0;
    pUinKey ptr = getUinCtx(context);
    if(!ptr) return 0;
    LPSTR cnm = (LPSTR) mir_alloc(NAMSIZE);
    getContactNameA(ptr->hContact,cnm);
    LPSTR uin = (LPSTR) mir_alloc(KEYSIZE);
    getContactUinA(ptr->hContact,uin);
    LPSTR msg = (LPSTR) mir_alloc(MSGSIZE);
    LPSTR sha = mir_strdup(to_hex(sig,sigLen));
    LPSTR sha_old = NULL;
#if defined(_DEBUG) || defined(NETLIB_LOG)
    Sent_NetLog("rsa_check_pub: %s %s %s", cnm, uin, sha);
#endif
    DBVARIANT dbv;
    dbv.type = DBVT_BLOB;
    if( DBGetContactSetting(ptr->hContact,szModuleName,"rsa_pub",&dbv) == 0 ) {
        k = 1;
        PBYTE buf = (PBYTE) alloca(sigLen);
        int len;
        exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)buf,&len);
        sha_old = mir_strdup(to_hex(buf,len));
        DBFreeVariant(&dbv);
    }
    if( bAAK ) {
        if( k )	mir_snprintf(msg,MSGSIZE,Translate(sim523),cnm,uin,sha,sha_old);
        else	mir_snprintf(msg,MSGSIZE,Translate(sim521),cnm,uin,sha);
        showPopUpKRmsg(ptr->hContact,msg);
        HistoryLog(ptr->hContact,msg);
        v = 1;
#if defined(_DEBUG) || defined(NETLIB_LOG)
        Sent_NetLog("rsa_check_pub: auto accepted");
#endif
    }
    else {
        if( k ) mir_snprintf(msg,MSGSIZE,Translate(sim522),cnm,sha,sha_old);
        else	mir_snprintf(msg,MSGSIZE,Translate(sim520),cnm,sha);
        v = (msgbox(0,msg,szModuleName,MB_YESNO|MB_ICONQUESTION)==IDYES);
#if defined(_DEBUG) || defined(NETLIB_LOG)
        Sent_NetLog("rsa_check_pub: manual accepted %d",v);
#endif
    }
    if(v) {
        DBCONTACTWRITESETTING cws;
        cws.szModule = szModuleName;
        cws.szSetting = "rsa_pub";
        cws.value.type = DBVT_BLOB;
        cws.value.pbVal = pub;
        cws.value.cpbVal = pubLen;
        CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws);
        ptr->keyLoaded = true;
    }
    mir_free(cnm);
    mir_free(uin);
    mir_free(msg);
    mir_free(sha);
    SAFE_FREE(sha_old);
    return v;
}
Пример #3
0
int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int sigLen)
{
	int v = 0, k = 0;
	pUinKey ptr = getUinCtx(context); if (!ptr) return 0;
	LPSTR cnm = (LPSTR)mir_alloc(NAMSIZE); getContactNameA(ptr->hContact, cnm);
	LPSTR uin = (LPSTR)mir_alloc(KEYSIZE); getContactUinA(ptr->hContact, uin);
	LPSTR msg = (LPSTR)mir_alloc(MSGSIZE);
	LPSTR sha = mir_strdup(to_hex(sig, sigLen));
	LPSTR sha_old = NULL;

	Sent_NetLog("rsa_check_pub: %s %s %s", cnm, uin, sha);

	DBVARIANT dbv;
	dbv.type = DBVT_BLOB;
	if (db_get(ptr->hContact, MODULENAME, "rsa_pub", &dbv) == 0) {
		k = 1;
		PBYTE buf = (PBYTE)alloca(sigLen); int len;
		mir_exp->rsa_get_hash((PBYTE)dbv.pbVal, dbv.cpbVal, (PBYTE)buf, &len);
		sha_old = mir_strdup(to_hex(buf, len));
		db_free(&dbv);
	}
	if (bAAK) {
		if (k)	mir_snprintf(msg, MSGSIZE, Translate(sim523), cnm, uin, sha, sha_old);
		else	mir_snprintf(msg, MSGSIZE, Translate(sim521), cnm, uin, sha);
		showPopupKRmsg(ptr->hContact, msg);
		HistoryLog(ptr->hContact, msg);
		v = 1;
#if defined(_DEBUG) || defined(NETLIB_LOG)
		Sent_NetLog("rsa_check_pub: auto accepted");
#endif
	}
	else {
		if (k) mir_snprintf(msg, MSGSIZE, Translate(sim522), cnm, sha, sha_old);
		else	mir_snprintf(msg, MSGSIZE, Translate(sim520), cnm, sha);
		v = (msgbox(0, msg, MODULENAME, MB_YESNO | MB_ICONQUESTION) == IDYES);
#if defined(_DEBUG) || defined(NETLIB_LOG)
		Sent_NetLog("rsa_check_pub: manual accepted %d", v);
#endif
	}
	if (v) {
		db_set_blob(ptr->hContact, MODULENAME, "rsa_pub", pub, pubLen);
		ptr->keyLoaded = true;
	}
	mir_free(cnm);
	mir_free(uin);
	mir_free(msg);
	mir_free(sha);
	SAFE_FREE(sha_old);
	return v;
}
Пример #4
0
void HistoryLogFunc(HANDLE hContact, std::string message)
{
	if(gbHistoryLog)
	{
		if(hContact == INVALID_HANDLE_VALUE)
			return;
		std::string msg = message;
		msg.append("\n");
		msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: ");
		msg.append(toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR))).append(" ID: ");
		msg.append(toUTF8(GetContactUid(hContact,toUTF16(GetContactProto(hContact)))));
		HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ);
	}
}