int __cdecl onExtraImageApplying(WPARAM wParam, LPARAM)
{
	if (isSecureProtocol((HANDLE)wParam))
		ExtraIcon_SetIcon(g_hCLIcon, (HANDLE)wParam, mode2clicon( isContactSecured((HANDLE)wParam), 1));

	return 0;
}
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 #3
0
void setSrmmIcon(MCONTACT h)
{
	MCONTACT hContact = metaIsProtoMetaContacts(h) ? metaGetMostOnline(h) : h;
	bool enabled = isContactSecured(hContact);	
	MCONTACT hMC = NULL;
	if(db_mc_isSub(hContact))
		hMC = db_mc_getMeta(hContact);
	else if(metaIsProtoMetaContacts(hContact))
		hMC = db_mc_getMeta(hContact);

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = szGPGModuleName;
	sid.hIcon = IconLibGetIcon("secured");
	sid.dwId = 1;
	sid.flags = enabled ? 0 : MBF_HIDDEN;
	Srmm_ModifyIcon(hContact, &sid);
	if(hMC)
		Srmm_ModifyIcon(hMC, &sid);

	sid.hIcon = IconLibGetIcon("unsecured");
	sid.dwId = 2;
	sid.flags = enabled ? MBF_HIDDEN : 0;
	Srmm_ModifyIcon(hContact, &sid);
	if(hMC)
		Srmm_ModifyIcon(hMC, &sid);
}
Exemple #4
0
void setClistIcon(MCONTACT hContact)
{
	bool enabled = isContactSecured(hContact);
	extern HANDLE g_hCLIcon;
	MCONTACT hMC = db_mc_tryMeta(hContact);
	const char *szIconId = (enabled) ? "secured" : NULL;
	ExtraIcon_SetIcon(g_hCLIcon, hContact, szIconId);
	if(hMC != hContact)
		ExtraIcon_SetIcon(g_hCLIcon, hMC, szIconId);
}
// remove all secureim connections on subcontacts
void DeinitMetaContact(HANDLE hContact) {

	HANDLE hMetaContact = isProtoMetaContacts(hContact) ? hContact : getMetaContact(hContact);

	if( hMetaContact ) {
		for(int i=0;i<CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hMetaContact,0);i++) {
			HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT,(WPARAM)hMetaContact,(LPARAM)i);
			if( hSubContact && isContactSecured(hSubContact)&SECURED ) {
				CallContactService(hSubContact,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_DEIN);
			}
		}
	}
}
Exemple #6
0
void setClistIcon(MCONTACT hContact)
{
	bool enabled = isContactSecured(hContact);
	extern HANDLE g_hCLIcon;
	MCONTACT hMC = hContact;
	if(db_mc_isSub(hContact))
		hMC = db_mc_getMeta(hContact);
	else if(metaIsProtoMetaContacts(hContact))
		hMC = db_mc_getMeta(hContact);
	const char *szIconId = (enabled) ? "secured" : NULL;
	ExtraIcon_SetIcon(g_hCLIcon, hContact, szIconId);
	if(hMC)
		ExtraIcon_SetIcon(g_hCLIcon, hMC, szIconId);
}
Exemple #7
0
int __cdecl onIconPressed(WPARAM hContact, LPARAM lParam)
{
	if (isProtoMetaContacts(hContact))
		hContact = db_mc_getMostOnline(hContact); // возьмем тот, через который пойдет сообщение

	StatusIconClickData *sicd = (StatusIconClickData *)lParam;
	if (strcmp(sicd->szModule, MODULENAME) != 0 || !isSecureProtocol(hContact))
		return 0; // not our event

	if (!isContactPGP(hContact) && !isContactGPG(hContact) && !isChatRoom(hContact)) {
		if (isContactSecured(hContact) & SECURED)
			Service_DisableIM(hContact, 0);
		else
			Service_CreateIM(hContact, 0);
	}

	return 0;
}
Exemple #8
0
void setSrmmIcon(MCONTACT h)
{
	MCONTACT hContact = db_mc_isMeta(h) ? metaGetMostOnline(h) : h;
	bool enabled = isContactSecured(hContact);	
	MCONTACT hMC = db_mc_tryMeta(hContact);

	StatusIconData sid = { sizeof(sid) };
	sid.szModule = szGPGModuleName;
	sid.hIcon = IcoLib_GetIcon("secured");
	sid.dwId = 1;
	sid.flags = enabled ? 0 : MBF_HIDDEN;
	Srmm_ModifyIcon(hContact, &sid);
	if(hMC != hContact)
		Srmm_ModifyIcon(hMC, &sid);

	sid.hIcon = IcoLib_GetIcon("unsecured");
	sid.dwId = 2;
	sid.flags = enabled ? MBF_HIDDEN : 0;
	Srmm_ModifyIcon(hContact, &sid);
	if(hMC != hContact)
		Srmm_ModifyIcon(hMC, &sid);
}
INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM lParam) {

    return (isContactSecured((HANDLE)wParam)&SECURED) || isContactPGP((HANDLE)wParam) || isContactGPG((HANDLE)wParam);
}
int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam)
{
	HANDLE hContact = (HANDLE)wParam;
	BOOL bMC = isProtoMetaContacts(hContact);
	if (bMC ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение
	pUinKey ptr = getUinKey(hContact);
	int i;
	CLISTMENUITEM mi = { sizeof(mi) };

	ShowStatusIconNotify(hContact);

	// check offline/online
	if (!ptr) {
		// hide menu bars
		for (i=0; i < SIZEOF(g_hMenu); i++)
			Menu_ShowItem(g_hMenu[i], false);
		return 0;
	}

	bool isSecureProto = isSecureProtocol(hContact);
	bool isPGP = isContactPGP(hContact);
	bool isGPG = isContactGPG(hContact);
	bool isSecured = (isContactSecured(hContact)&SECURED) != 0;
	bool isChat = isChatRoom(hContact);
	bool isMiranda = isClientMiranda(hContact);

	// hide all menu bars
	for (i=0; i < SIZEOF(g_hMenu); i++)
		Menu_ShowItem(g_hMenu[i], false);

	if (isSecureProto && !isChat && isMiranda && 
	    (ptr->mode == MODE_NATIVE || ptr->mode == MODE_RSAAES)) {
		// Native/RSAAES
		mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIM_ICON;
		if (!isSecured) {
			// create secureim connection
			mi.hIcon = mode2icon(ptr->mode|SECURED,2);
			Menu_ModifyItem(g_hMenu[0], &mi);
		}
		else {
			// disable secureim connection
			mi.hIcon = mode2icon(ptr->mode,2);
			Menu_ModifyItem(g_hMenu[1], &mi);
		}
		// set status menu
		if (bSCM && !bMC && (!isSecured || ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) {

			mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON;
			mi.hIcon = g_hICO[ICO_ST_DIS+ptr->status];
			mi.pszName = (LPSTR)sim312[ptr->status];
			Menu_ModifyItem(g_hMenu[2], &mi);

			mi.flags = CMIM_FLAGS | CMIM_ICON;
			for (i=0;i<=(ptr->mode == MODE_RSAAES?1:2);i++) {
				mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS+ptr->status] : NULL;
				Menu_ModifyItem(g_hMenu[3+i], &mi);
			}
		}
	}
	else if (isSecureProto && !isChat && (ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) {
		// PGP, GPG
		if (ptr->mode == MODE_PGP && bPGPloaded)
			if ((bPGPkeyrings || bPGPprivkey) && !isGPG)
				Menu_ShowItem(g_hMenu[isPGP+6], true);

		if (ptr->mode == MODE_GPG && bGPGloaded)
			if (bGPGkeyrings && !isPGP)
				Menu_ShowItem(g_hMenu[isGPG+8], true);
	}
	if (isSecureProto && !isChat && isMiranda) {
		// set mode menu
		if (bMCM && !bMC && (!isSecured || ptr->mode == MODE_PGP || ptr->mode == MODE_GPG)) {
			mi.flags = CMIM_FLAGS | CMIM_NAME | CMIM_ICON;
			mi.hIcon = g_hICO[ICO_OV_NAT+ptr->mode];
			mi.pszName = (LPSTR)sim311[ptr->mode];
			Menu_ModifyItem(g_hMenu[10], &mi);

			mi.flags = CMIM_FLAGS | CMIM_ICON;
			for (i=0;i<MODE_CNT;i++) {
				if (i == MODE_PGP && ptr->mode != MODE_PGP && !bPGP ) continue;
				if (i == MODE_GPG && ptr->mode != MODE_GPG && !bGPG ) continue;
				mi.hIcon = (i == ptr->mode) ? g_hICO[ICO_ST_ENA] : NULL;
				Menu_ModifyItem(g_hMenu[11+i], &mi);
			}
		}
	}

	return 0;
}
void ShowStatusIconNotify(HANDLE hContact)
{
	BYTE mode = isContactSecured(hContact);
	NotifyEventHooks(g_hEvent[(mode&SECURED) != 0], (WPARAM)hContact, 0);
	ShowStatusIcon(hContact,mode);
}
void ShowStatusIcon(HANDLE hContact)
{
	ShowStatusIcon(hContact, isContactSecured(hContact));
}
Exemple #13
0
void ShowStatusIconNotify(MCONTACT hContact)
{
	BYTE mode = isContactSecured(hContact);
	NotifyEventHooks(g_hEvent[(mode&SECURED) != 0], hContact, 0);
	ShowStatusIcon(hContact, mode);
}
Exemple #14
0
void ShowStatusIcon(MCONTACT hContact)
{
	ShowStatusIcon(hContact, isContactSecured(hContact));
}