// 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); } } } }
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; }
BYTE isContactSecured(HANDLE hContact) { // нужна проверка на Offline и в этом случае другие статусы if (!clist_cnt) return 0; BYTE r=0; if( isProtoMetaContacts(hContact) ) hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение for(int j=0;j<clist_cnt;j++) { if( clist[j].hContact == hContact ) { if( !clist[j].proto->inspecting ) break; DBVARIANT dbv; r=clist[j].mode; switch(r) { case MODE_NATIVE: if(cpp_keyx(clist[j].cntx)!=0) r|=SECURED; break; case MODE_PGP: DBGetContactSetting(hContact,szModuleName,"pgp",&dbv); if( dbv.type!=0 ) r|=SECURED; DBFreeVariant(&dbv); break; case MODE_GPG: DBGetContactSetting(hContact,szModuleName,"gpg",&dbv); if( dbv.type!=0 ) r|=SECURED; DBFreeVariant(&dbv); break; case MODE_RSAAES: if(exp->rsa_get_state(clist[j].cntx)==7) r|=SECURED; break; case MODE_RSA: if(clist[j].cntx) r|=SECURED; break; } break; } } return r; // (mode&SECURED) - проверка на EST/DIS }
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; }