INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) {

    pUinKey ptr = getUinKey((HANDLE)wParam);

    switch(--lParam) {
    case MODE_NATIVE:
    case MODE_RSAAES:
        if( isContactSecured((HANDLE)wParam)&SECURED ) {
            msgbox(NULL, sim111, szModuleName, MB_OK);
            return 0;
        }
        if( lParam!=MODE_NATIVE && ptr->status>STATUS_ENABLED ) {
            Service_Status(wParam,STATUS_ENABLED+1);
        }
    case MODE_PGP:
    case MODE_GPG:
        // нужно много проверок и отключение активного контекста если необходимо
        if(ptr) {
            if( ptr->cntx ) {
                cpp_delete_context(ptr->cntx);
                ptr->cntx = 0;
                ptr->keyLoaded = 0;
            }
            ptr->mode=(BYTE)lParam;
            DBWriteContactSettingByte((HANDLE)wParam, szModuleName, "mode", (BYTE)lParam);
        }
        ShowStatusIcon((HANDLE)wParam);
        break;
    }

    return 1;
}
Exemple #2
0
// пересоздает RSA контекст
void resetRSAcntx(pUinKey ptr) {
    if( ptr->cntx ) {
        cpp_delete_context(ptr->cntx);
        ptr->cntx = cpp_create_context(CPP_MODE_RSA);
        ptr->keyLoaded = 0;
    }
}
int __cdecl onContactSettingChanged(WPARAM wParam,LPARAM lParam) {

	HANDLE hContact = (HANDLE)wParam;
	DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam;
	if (!hContact || strcmp(cws->szSetting,"Status")) return 0;

	pUinKey ptr = getUinKey(hContact);
	int stat = getContactStatus(hContact);
	if (!ptr || stat == -1) return 0;

	if (stat == ID_STATUS_OFFLINE) { // go offline
		if (ptr->mode == MODE_NATIVE && cpp_keyx(ptr->cntx)) { // have active context
			cpp_delete_context(ptr->cntx); ptr->cntx=0; // reset context
			showPopupDC(hContact);	// show popup "Disabled"
			ShowStatusIconNotify(hContact); // change icon in CL
		}
		else if (ptr->mode == MODE_RSAAES && exp->rsa_get_state(ptr->cntx) == 7) {
			deleteRSAcntx(ptr);
			showPopupDC(hContact);	// show popup "Disabled"
			ShowStatusIconNotify(hContact); // change icon in CL
		}
	}
	else { // go not offline
		if (ptr->offlineKey) {
			cpp_reset_context(ptr->cntx);
			ptr->offlineKey = false;
		}
		ShowStatusIconNotify(hContact); // change icon in CL
	}
	return 0;
}
Exemple #4
0
INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM)
{
	if (bGPGloaded)
		db_unset(wParam, MODULENAME, "gpg");
	{
		pUinKey ptr = getUinKey(wParam);
		cpp_delete_context(ptr->cntx); ptr->cntx = 0;
	}
	ShowStatusIconNotify(wParam);
	return 1;
}
// delete contact from the list of secureIM users
void delContact(HANDLE hContact)
{
	pUinKey p = arClist.find((pUinKey)&hContact);
	if (p) {
		arClist.remove(p);

		cpp_delete_context(p->cntx); p->cntx = 0;
		mir_free(p->tmp);
		mir_free(p->msgSplitted);
		mir_free(p);
	}
}
INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM lParam) {

    if(bGPGloaded) {
        DBDeleteContactSetting((HANDLE)wParam, szModuleName, "gpg");
    }
    {
        pUinKey ptr = getUinKey((HANDLE)wParam);
        cpp_delete_context(ptr->cntx);
        ptr->cntx=0;
    }
    ShowStatusIconNotify((HANDLE)wParam);
    return 1;
}
// free list of secureIM users
void freeContactList()
{
	for (int j=0; j < arClist.getCount(); j++) {
		pUinKey p = arClist[j];
		cpp_delete_context(p->cntx); p->cntx = 0;
		mir_free(p->tmp);
		mir_free(p->msgSplitted);
		mir_free(p);
	}
	arClist.destroy();

	freeSupportedProtocols();
}
Exemple #8
0
INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM)
{
	if (bPGPloaded) {
		db_unset(wParam, MODULENAME, "pgp");
		db_unset(wParam, MODULENAME, "pgp_mode");
		db_unset(wParam, MODULENAME, "pgp_abbr");
	}
	{
		pUinKey ptr = getUinKey(wParam);
		cpp_delete_context(ptr->cntx); ptr->cntx = 0;
	}
	ShowStatusIconNotify(wParam);
	return 1;
}
INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) {

    BOOL del = true;
    if(bPGPloaded) {
        if(bPGPkeyrings) {
            char szKeyID[128];
            szKeyID[0]='\0';
            PVOID KeyID = pgp_select_keyid(GetForegroundWindow(),szKeyID);
            if(szKeyID[0]) {
                DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp");
                DBCONTACTWRITESETTING cws;
                memset(&cws,0,sizeof(cws));
                cws.szModule = szModuleName;
                cws.szSetting = "pgp";
                cws.value.type = DBVT_BLOB;
                cws.value.pbVal = (LPBYTE)KeyID;
                cws.value.cpbVal = pgp_size_keyid();
                CallService(MS_DB_CONTACT_WRITESETTING,wParam,(LPARAM)&cws);
                DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",0);
                DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr",szKeyID);
                del = false;
            }
        }
        else if(bPGPprivkey) {
            char KeyPath[MAX_PATH];
            KeyPath[0]='\0';
            if(ShowSelectKeyDlg(0,KeyPath)) {
                char *publ = LoadKeys(KeyPath,false);
                if(publ) {
                    DBDeleteContactSetting((HANDLE)wParam,szModuleName,"pgp");
                    myDBWriteStringEncode((HANDLE)wParam,szModuleName,"pgp",publ);
                    DBWriteContactSettingByte((HANDLE)wParam,szModuleName,"pgp_mode",1);
                    DBWriteContactSettingString((HANDLE)wParam,szModuleName,"pgp_abbr","(binary)");
                    mir_free(publ);
                    del = false;
                }
            }
        }
    }

    if(del) Service_PGPdelKey(wParam,lParam);
    else {
        pUinKey ptr = getUinKey((HANDLE)wParam);
        cpp_delete_context(ptr->cntx);
        ptr->cntx=0;
    }
    ShowStatusIconNotify((HANDLE)wParam);
    return 1;
}
Exemple #10
0
INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam)
{
	bool del = true;
	if (bGPGloaded && bGPGkeyrings) {
		char szKeyID[128]; szKeyID[0] = '\0';
		gpg_select_keyid(GetForegroundWindow(), szKeyID);
		if (szKeyID[0]) {
			db_set_s(wParam, MODULENAME, "gpg", szKeyID);
			del = false;
		}
	}

	if (del)
		Service_GPGdelKey(wParam, lParam);
	else {
		pUinKey ptr = getUinKey(wParam);
		cpp_delete_context(ptr->cntx); ptr->cntx = 0;
	}
	ShowStatusIconNotify(wParam);
	return 1;
}
Exemple #11
0
INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam)
{
	BOOL del = true;
	if (bPGPloaded) {
		if (bPGPkeyrings) {
			char szKeyID[128]; szKeyID[0] = '\0';
			PVOID KeyID = pgp_select_keyid(GetForegroundWindow(), szKeyID);
			if (szKeyID[0]) {
				db_unset(wParam, MODULENAME, "pgp");
				db_set_blob(wParam, MODULENAME, "pgp", KeyID, pgp_size_keyid());
				db_set_b(wParam, MODULENAME, "pgp_mode", 0);
				db_set_s(wParam, MODULENAME, "pgp_abbr", szKeyID);
				del = false;
			}
		}
		else if (bPGPprivkey) {
			char KeyPath[MAX_PATH]; KeyPath[0] = '\0';
			if (ShowSelectKeyDlg(0, KeyPath)) {
				char *publ = LoadKeys(KeyPath, false);
				if (publ) {
					db_unset(wParam, MODULENAME, "pgp");
					db_set_s(wParam, MODULENAME, "pgp", publ);
					db_set_b(wParam, MODULENAME, "pgp_mode", 1);
					db_set_s(wParam, MODULENAME, "pgp_abbr", "(binary)");
					mir_free(publ);
					del = false;
				}
			}
		}
	}

	if (del)
		Service_PGPdelKey(wParam, lParam);
	else {
		pUinKey ptr = getUinKey(wParam);
		cpp_delete_context(ptr->cntx); ptr->cntx = 0;
	}
	ShowStatusIconNotify(wParam);
	return 1;
}
Exemple #12
0
INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam) {

    BOOL del = true;
    if(bGPGloaded && bGPGkeyrings) {
        char szKeyID[128];
        szKeyID[0]='\0';
        gpg_select_keyid(GetForegroundWindow(),szKeyID);
        if(szKeyID[0]) {
            DBWriteContactSettingString((HANDLE)wParam,szModuleName,"gpg",szKeyID);
            del = false;
        }
    }

    if(del) Service_GPGdelKey(wParam,lParam);
    else {
        pUinKey ptr = getUinKey((HANDLE)wParam);
        cpp_delete_context(ptr->cntx);
        ptr->cntx=0;
    }
    ShowStatusIconNotify((HANDLE)wParam);
    return 1;
}
Exemple #13
0
// удаляет RSA контекст
void deleteRSAcntx(pUinKey ptr)
{
	cpp_delete_context(ptr->cntx);
	ptr->cntx = 0;
	ptr->keyLoaded = 0;
}