summaryrefslogtreecommitdiff
path: root/plugins/SecureIM/src/svcs_menu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SecureIM/src/svcs_menu.cpp')
-rw-r--r--plugins/SecureIM/src/svcs_menu.cpp229
1 files changed, 108 insertions, 121 deletions
diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp
index 45cd9a9eea..7190bbe785 100644
--- a/plugins/SecureIM/src/svcs_menu.cpp
+++ b/plugins/SecureIM/src/svcs_menu.cpp
@@ -1,30 +1,30 @@
#include "commonheaders.h"
-INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM lParam) {
-
+INT_PTR __cdecl Service_IsContactSecured(WPARAM wParam, LPARAM lParam)
+{
return (isContactSecured((HANDLE)wParam)&SECURED) || isContactPGP((HANDLE)wParam) || isContactGPG((HANDLE)wParam);
}
-INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam){
- CallContactService((HANDLE)wParam,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_INIT);
+INT_PTR __cdecl Service_CreateIM(WPARAM wParam,LPARAM lParam)
+{
+ CallContactService((HANDLE)wParam,PSS_MESSAGE, PREF_METANODB,(LPARAM)SIG_INIT);
return 1;
}
-
-INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam) {
- CallContactService((HANDLE)wParam,PSS_MESSAGE,(WPARAM)PREF_METANODB,(LPARAM)SIG_DEIN);
+INT_PTR __cdecl Service_DisableIM(WPARAM wParam,LPARAM lParam)
+{
+ CallContactService((HANDLE)wParam,PSS_MESSAGE, PREF_METANODB,(LPARAM)SIG_DEIN);
return 1;
}
-
-INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam) {
-
- switch(--lParam) {
- case STATUS_DISABLED:
- case STATUS_ENABLED:
- case STATUS_ALWAYSTRY:
+INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam)
+{
+ switch(--lParam) {
+ case STATUS_DISABLED:
+ case STATUS_ENABLED:
+ case STATUS_ALWAYSTRY:
pUinKey ptr = getUinKey((HANDLE)wParam);
if (ptr) {
ptr->status=ptr->tstatus=(BYTE)lParam;
@@ -32,86 +32,81 @@ INT_PTR __cdecl Service_Status(WPARAM wParam, LPARAM lParam) {
else db_set_b(ptr->hContact, MODULENAME, "StatusID", ptr->status);
}
break;
- }
+ }
return 1;
}
-
-INT_PTR __cdecl Service_StatusDis(WPARAM wParam, LPARAM lParam) {
-
+INT_PTR __cdecl Service_StatusDis(WPARAM wParam, LPARAM lParam)
+{
return Service_Status(wParam,STATUS_DISABLED+1);
}
-
-INT_PTR __cdecl Service_StatusEna(WPARAM wParam, LPARAM lParam) {
-
+INT_PTR __cdecl Service_StatusEna(WPARAM wParam, LPARAM lParam)
+{
return Service_Status(wParam,STATUS_ENABLED+1);
}
-
-INT_PTR __cdecl Service_StatusTry(WPARAM wParam, LPARAM lParam) {
-
+INT_PTR __cdecl Service_StatusTry(WPARAM wParam, LPARAM lParam)
+{
return Service_Status(wParam,STATUS_ALWAYSTRY+1);
}
-
-INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM lParam) {
-
+INT_PTR __cdecl Service_PGPdelKey(WPARAM wParam, LPARAM lParam)
+{
if (bPGPloaded) {
- db_unset((HANDLE)wParam, MODULENAME, "pgp");
- db_unset((HANDLE)wParam, MODULENAME, "pgp_mode");
- db_unset((HANDLE)wParam, MODULENAME, "pgp_abbr");
+ db_unset((HANDLE)wParam, MODULENAME, "pgp");
+ db_unset((HANDLE)wParam, MODULENAME, "pgp_mode");
+ db_unset((HANDLE)wParam, MODULENAME, "pgp_abbr");
}
{
- pUinKey ptr = getUinKey((HANDLE)wParam);
- cpp_delete_context(ptr->cntx); ptr->cntx=0;
+ pUinKey ptr = getUinKey((HANDLE)wParam);
+ cpp_delete_context(ptr->cntx); ptr->cntx=0;
}
ShowStatusIconNotify((HANDLE)wParam);
return 1;
}
-
-INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) {
-
+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((HANDLE)wParam,MODULENAME,"pgp");
- DBCONTACTWRITESETTING cws;
- memset(&cws,0,sizeof(cws));
- cws.szModule = MODULENAME;
- 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);
- db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",0);
- DBWriteContactSettingString((HANDLE)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((HANDLE)wParam,MODULENAME,"pgp");
- myDBWriteStringEncode((HANDLE)wParam,MODULENAME,"pgp",publ);
- db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",1);
- DBWriteContactSettingString((HANDLE)wParam,MODULENAME,"pgp_abbr","(binary)");
- mir_free(publ);
- del = false;
- }
- }
- }
+ if (bPGPkeyrings) {
+ char szKeyID[128]; szKeyID[0]='\0';
+ PVOID KeyID = pgp_select_keyid(GetForegroundWindow(),szKeyID);
+ if (szKeyID[0]) {
+ db_unset((HANDLE)wParam,MODULENAME,"pgp");
+ DBCONTACTWRITESETTING cws;
+ memset(&cws,0,sizeof(cws));
+ cws.szModule = MODULENAME;
+ 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);
+ db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",0);
+ db_set_s((HANDLE)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((HANDLE)wParam,MODULENAME,"pgp");
+ myDBWriteStringEncode((HANDLE)wParam,MODULENAME,"pgp",publ);
+ db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",1);
+ db_set_s((HANDLE)wParam,MODULENAME,"pgp_abbr","(binary)");
+ mir_free(publ);
+ del = false;
+ }
+ }
+ }
}
- if (del) Service_PGPdelKey(wParam,lParam);
+ if (del)
+ Service_PGPdelKey(wParam,lParam);
else {
pUinKey ptr = getUinKey((HANDLE)wParam);
cpp_delete_context(ptr->cntx); ptr->cntx=0;
@@ -120,31 +115,28 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam) {
return 1;
}
-
-INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM lParam) {
-
- if (bGPGloaded) {
- db_unset((HANDLE)wParam, MODULENAME, "gpg");
- }
+INT_PTR __cdecl Service_GPGdelKey(WPARAM wParam, LPARAM lParam)
+{
+ if (bGPGloaded)
+ db_unset((HANDLE)wParam, MODULENAME, "gpg");
{
- pUinKey ptr = getUinKey((HANDLE)wParam);
- cpp_delete_context(ptr->cntx); ptr->cntx=0;
+ pUinKey ptr = getUinKey((HANDLE)wParam);
+ cpp_delete_context(ptr->cntx); ptr->cntx=0;
}
ShowStatusIconNotify((HANDLE)wParam);
return 1;
}
-
-INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam) {
-
- BOOL del = true;
+INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam)
+{
+ bool del = true;
if (bGPGloaded && bGPGkeyrings) {
- char szKeyID[128]; szKeyID[0]='\0';
+ char szKeyID[128]; szKeyID[0]='\0';
gpg_select_keyid(GetForegroundWindow(),szKeyID);
- if (szKeyID[0]) {
- DBWriteContactSettingString((HANDLE)wParam,MODULENAME,"gpg",szKeyID);
- del = false;
- }
+ if (szKeyID[0]) {
+ db_set_s((HANDLE)wParam,MODULENAME,"gpg",szKeyID);
+ del = false;
+ }
}
if (del) Service_GPGdelKey(wParam,lParam);
@@ -156,27 +148,26 @@ INT_PTR __cdecl Service_GPGsetKey(WPARAM wParam, LPARAM lParam) {
return 1;
}
-
-INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) {
-
+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, MODULENAME, MB_OK);
- return 0;
- }
- if ( lParam!=MODE_NATIVE && ptr->status>STATUS_ENABLED ) {
- Service_Status(wParam,STATUS_ENABLED+1);
+ switch(--lParam) {
+ case MODE_NATIVE:
+ case MODE_RSAAES:
+ if (isContactSecured((HANDLE)wParam)&SECURED) {
+ msgbox(NULL, sim111, MODULENAME, MB_OK);
+ return 0;
}
- case MODE_PGP:
- case MODE_GPG:
- // нужно много проверок и отключение активного контекста если необходимо
+ 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);
+ cpp_delete_context(ptr->cntx);
ptr->cntx = 0;
ptr->keyLoaded = 0;
}
@@ -185,33 +176,29 @@ INT_PTR __cdecl Service_Mode(WPARAM wParam, LPARAM lParam) {
}
ShowStatusIcon((HANDLE)wParam);
break;
- }
+ }
- return 1;
+ return 1;
}
-
-INT_PTR __cdecl Service_ModeNative(WPARAM wParam, LPARAM lParam) {
-
- return Service_Mode(wParam,MODE_NATIVE+1);
+INT_PTR __cdecl Service_ModeNative(WPARAM wParam, LPARAM lParam)
+{
+ return Service_Mode(wParam, MODE_NATIVE+1);
}
-
-INT_PTR __cdecl Service_ModePGP(WPARAM wParam, LPARAM lParam) {
-
- return Service_Mode(wParam,MODE_PGP+1);
+INT_PTR __cdecl Service_ModePGP(WPARAM wParam, LPARAM lParam)
+{
+ return Service_Mode(wParam, MODE_PGP+1);
}
-
-INT_PTR __cdecl Service_ModeGPG(WPARAM wParam, LPARAM lParam) {
-
- return Service_Mode(wParam,MODE_GPG+1);
+INT_PTR __cdecl Service_ModeGPG(WPARAM wParam, LPARAM lParam)
+{
+ return Service_Mode(wParam, MODE_GPG+1);
}
-
-
-INT_PTR __cdecl Service_ModeRSAAES(WPARAM wParam, LPARAM lParam) {
-
- return Service_Mode(wParam,MODE_RSAAES+1);
+
+INT_PTR __cdecl Service_ModeRSAAES(WPARAM wParam, LPARAM lParam)
+{
+ return Service_Mode(wParam, MODE_RSAAES+1);
}