diff options
Diffstat (limited to 'plugins/SecureIM/src/main.cpp')
-rw-r--r-- | plugins/SecureIM/src/main.cpp | 154 |
1 files changed, 76 insertions, 78 deletions
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 0b144fe738..22d7d44e6a 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -17,7 +17,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfoEx;
}
-HGENMENU AddMenuItem(LPCSTR name,int pos,HICON hicon,LPCSTR service,int flags=0,WPARAM wParam=0)
+HGENMENU AddMenuItem(LPCSTR name, int pos, HICON hicon, LPCSTR service, int flags = 0, WPARAM wParam = 0)
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = flags | CMIF_HIDDEN;
@@ -29,7 +29,7 @@ HGENMENU AddMenuItem(LPCSTR name,int pos,HICON hicon,LPCSTR service,int flags=0, return Menu_AddContactMenuItem(&mi);
}
-HGENMENU AddSubItem(HANDLE rootid,LPCSTR name,int pos,int poppos,LPCSTR service,WPARAM wParam=0)
+HGENMENU AddSubItem(HANDLE rootid, LPCSTR name, int pos, int poppos, LPCSTR service, WPARAM wParam = 0)
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_CHILDPOPUP | CMIF_HIDDEN;
@@ -49,23 +49,23 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) InitializeCriticalSection(&localQueueMutex);
char temp[MAX_PATH];
- GetTempPath(sizeof(temp),temp);
- GetLongPathName(temp,TEMP,sizeof(TEMP));
+ GetTempPath(sizeof(temp), temp);
+ GetLongPathName(temp, TEMP, sizeof(TEMP));
TEMP_SIZE = (int)strlen(TEMP);
- if (TEMP[TEMP_SIZE-1] == '\\') {
+ if (TEMP[TEMP_SIZE - 1] == '\\') {
TEMP_SIZE--;
- TEMP[TEMP_SIZE]='\0';
+ TEMP[TEMP_SIZE] = '\0';
}
// check for support TrueColor Icons
BOOL bIsComCtl6 = FALSE;
HMODULE hComCtlDll = LoadLibrary(_T("comctl32.dll"));
if (hComCtlDll) {
- typedef HRESULT (CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*);
- PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION) GetProcAddress(hComCtlDll,"DllGetVersion");
+ typedef HRESULT(CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*);
+ PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION)GetProcAddress(hComCtlDll, "DllGetVersion");
if (pfnDllGetVersion) {
DLLVERSIONINFO dvi;
- memset(&dvi,0,sizeof(dvi));
+ memset(&dvi, 0, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
HRESULT hRes = (*pfnDllGetVersion)(&dvi);
if (SUCCEEDED(hRes) && dvi.dwMajorVersion >= 6) {
@@ -77,11 +77,11 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) if (bIsComCtl6) iBmpDepth = ILC_COLOR32 | ILC_MASK; // 32-bit images are supported
else iBmpDepth = ILC_COLOR24 | ILC_MASK;
- iCoreVersion = CallService(MS_SYSTEM_GETVERSION,0,0);
+ iCoreVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0);
// load crypo++ dll
if (!loadlib()) {
- msgbox1(0,sim107,MODULENAME,MB_OK|MB_ICONSTOP);
+ msgbox1(0, sim107, MODULENAME, MB_OK | MB_ICONSTOP);
return 1;
}
@@ -102,20 +102,20 @@ extern "C" __declspec(dllexport) int __cdecl Load(void) g_hEvent[0] = CreateHookableEvent(MODULENAME"/Disabled");
g_hEvent[1] = CreateHookableEvent(MODULENAME"/Established");
- CreateServiceFunction(MODULENAME"/IsContactSecured",Service_IsContactSecured);
- CreateServiceFunction(MODULENAME"/SIM_EST",Service_CreateIM);
- CreateServiceFunction(MODULENAME"/SIM_DIS",Service_DisableIM);
- CreateServiceFunction(MODULENAME"/SIM_ST_DIS",Service_StatusDis);
- CreateServiceFunction(MODULENAME"/SIM_ST_ENA",Service_StatusEna);
- CreateServiceFunction(MODULENAME"/SIM_ST_TRY",Service_StatusTry);
- CreateServiceFunction(MODULENAME"/PGP_SET",Service_PGPsetKey);
- CreateServiceFunction(MODULENAME"/PGP_DEL",Service_PGPdelKey);
- CreateServiceFunction(MODULENAME"/GPG_SET",Service_GPGsetKey);
- CreateServiceFunction(MODULENAME"/GPG_DEL",Service_GPGdelKey);
- CreateServiceFunction(MODULENAME"/MODE_NAT",Service_ModeNative);
- CreateServiceFunction(MODULENAME"/MODE_PGP",Service_ModePGP);
- CreateServiceFunction(MODULENAME"/MODE_GPG",Service_ModeGPG);
- CreateServiceFunction(MODULENAME"/MODE_RSA",Service_ModeRSAAES);
+ CreateServiceFunction(MODULENAME"/IsContactSecured", Service_IsContactSecured);
+ CreateServiceFunction(MODULENAME"/SIM_EST", Service_CreateIM);
+ CreateServiceFunction(MODULENAME"/SIM_DIS", Service_DisableIM);
+ CreateServiceFunction(MODULENAME"/SIM_ST_DIS", Service_StatusDis);
+ CreateServiceFunction(MODULENAME"/SIM_ST_ENA", Service_StatusEna);
+ CreateServiceFunction(MODULENAME"/SIM_ST_TRY", Service_StatusTry);
+ CreateServiceFunction(MODULENAME"/PGP_SET", Service_PGPsetKey);
+ CreateServiceFunction(MODULENAME"/PGP_DEL", Service_PGPdelKey);
+ CreateServiceFunction(MODULENAME"/GPG_SET", Service_GPGsetKey);
+ CreateServiceFunction(MODULENAME"/GPG_DEL", Service_GPGdelKey);
+ CreateServiceFunction(MODULENAME"/MODE_NAT", Service_ModeNative);
+ CreateServiceFunction(MODULENAME"/MODE_PGP", Service_ModePGP);
+ CreateServiceFunction(MODULENAME"/MODE_GPG", Service_ModeGPG);
+ CreateServiceFunction(MODULENAME"/MODE_RSA", Service_ModeRSAAES);
return 0;
}
@@ -148,19 +148,19 @@ int onModulesLoaded(WPARAM, LPARAM) DBVARIANT dbv;
dbv.type = DBVT_BLOB;
- if (db_get(0,MODULENAME,"rsa_priv",&dbv) == 0) {
- exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal);
+ if (db_get(0, MODULENAME, "rsa_priv", &dbv) == 0) {
+ exp->rsa_set_keypair(CPP_MODE_RSA_4096, dbv.pbVal, dbv.cpbVal);
db_free(&dbv);
- rsa_4096=1;
+ rsa_4096 = 1;
}
- else if (db_get(0,MODULENAME,"rsa_priv_4096",&dbv) == 0) {
- exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal);
+ else if (db_get(0, MODULENAME, "rsa_priv_4096", &dbv) == 0) {
+ exp->rsa_set_keypair(CPP_MODE_RSA_4096 | CPP_MODE_RSA_BER, dbv.pbVal, dbv.cpbVal);
db_free(&dbv);
char priv_key[4096]; int priv_len;
char pub_key[4096]; int pub_len;
- exp->rsa_get_keypair(CPP_MODE_RSA_4096,(PBYTE)&priv_key,&priv_len,(PBYTE)&pub_key,&pub_len);
+ exp->rsa_get_keypair(CPP_MODE_RSA_4096, (PBYTE)&priv_key, &priv_len, (PBYTE)&pub_key, &pub_len);
db_set_blob(NULL, MODULENAME, "rsa_priv", priv_key, priv_len);
db_set_blob(NULL, MODULENAME, "rsa_pub", &pub_key, pub_len);
db_unset(NULL, MODULENAME, "rsa_priv_2048");
@@ -171,15 +171,15 @@ int onModulesLoaded(WPARAM, LPARAM) if (!rsa_4096)
mir_forkthread(sttGenerateRSA, NULL);
- exp->rsa_set_timeout( db_get_w(0,MODULENAME,"ket",10));
+ exp->rsa_set_timeout(db_get_w(0, MODULENAME, "ket", 10));
Sent_NetLog("pgp_init");
bPGP = db_get_b(0, MODULENAME, "pgp", 0);
if (bPGP) { //PGP
bPGPloaded = pgp_init();
- bUseKeyrings = db_get_b(0,MODULENAME,"ukr",1);
- LPSTR priv = db_get_sa(0,MODULENAME,"pgpPrivKey");
+ bUseKeyrings = db_get_b(0, MODULENAME, "ukr", 1);
+ LPSTR priv = db_get_sa(0, MODULENAME, "pgpPrivKey");
if (priv) {
bPGPprivkey = true;
if (bPGPloaded)
@@ -188,25 +188,25 @@ int onModulesLoaded(WPARAM, LPARAM) }
if (bPGPloaded && bUseKeyrings) {
char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH];
- PubRingPath[0]='\0'; SecRingPath[0]='\0';
- if (pgp_get_version()<0x02000000) { // 6xx
- bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath);
+ PubRingPath[0] = '\0'; SecRingPath[0] = '\0';
+ if (pgp_get_version() < 0x02000000) { // 6xx
+ bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath);
}
else {
- LPSTR tmp = db_get_sa(0,MODULENAME,"pgpPubRing");
+ LPSTR tmp = db_get_sa(0, MODULENAME, "pgpPubRing");
if (tmp) {
- strncpy(PubRingPath,tmp,sizeof(PubRingPath));
+ strncpy(PubRingPath, tmp, sizeof(PubRingPath));
mir_free(tmp);
}
- if (tmp = db_get_sa(0,MODULENAME,"pgpSecRing")) {
- strncpy(SecRingPath,tmp,sizeof(SecRingPath));
+ if (tmp = db_get_sa(0, MODULENAME, "pgpSecRing")) {
+ strncpy(SecRingPath, tmp, sizeof(SecRingPath));
mir_free(tmp);
}
if (PubRingPath[0] && SecRingPath[0]) {
- bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath);
+ bPGPkeyrings = pgp_open_keyrings(PubRingPath, SecRingPath);
if (bPGPkeyrings) {
- db_set_s(0,MODULENAME,"pgpPubRing",PubRingPath);
- db_set_s(0,MODULENAME,"pgpSecRing",SecRingPath);
+ db_set_s(0, MODULENAME, "pgpPubRing", PubRingPath);
+ db_set_s(0, MODULENAME, "pgpSecRing", SecRingPath);
}
else {
db_unset(0, MODULENAME, "pgpPubRing");
@@ -224,45 +224,45 @@ int onModulesLoaded(WPARAM, LPARAM) bGPGloaded = gpg_init();
char gpgexec[MAX_PATH], gpghome[MAX_PATH];
- gpgexec[0]='\0'; gpghome[0]='\0';
+ gpgexec[0] = '\0'; gpghome[0] = '\0';
- LPSTR tmp = db_get_sa(0,MODULENAME,"gpgExec");
+ LPSTR tmp = db_get_sa(0, MODULENAME, "gpgExec");
if (tmp) {
- strncpy(gpgexec,tmp,sizeof(gpgexec));
+ strncpy(gpgexec, tmp, sizeof(gpgexec));
mir_free(tmp);
}
- if (tmp = db_get_sa(0,MODULENAME,"gpgHome")) {
- strncpy(gpghome,tmp,sizeof(gpghome));
+ if (tmp = db_get_sa(0, MODULENAME, "gpgHome")) {
+ strncpy(gpghome, tmp, sizeof(gpghome));
mir_free(tmp);
}
- if (db_get_b(0, MODULENAME, "gpgLogFlag",0)) {
- if (tmp = db_get_sa(0,MODULENAME,"gpgLog")) {
+ if (db_get_b(0, MODULENAME, "gpgLogFlag", 0)) {
+ if (tmp = db_get_sa(0, MODULENAME, "gpgLog")) {
gpg_set_log(tmp);
mir_free(tmp);
}
}
- if (db_get_b(0, MODULENAME, "gpgTmpFlag",0)) {
- if (tmp = db_get_sa(0,MODULENAME,"gpgTmp")) {
+ if (db_get_b(0, MODULENAME, "gpgTmpFlag", 0)) {
+ if (tmp = db_get_sa(0, MODULENAME, "gpgTmp")) {
gpg_set_tmp(tmp);
mir_free(tmp);
}
}
- bGPGkeyrings = gpg_open_keyrings(gpgexec,gpghome);
+ bGPGkeyrings = gpg_open_keyrings(gpgexec, gpghome);
if (bGPGkeyrings) {
- db_set_s(0,MODULENAME,"gpgExec",gpgexec);
- db_set_s(0,MODULENAME,"gpgHome",gpghome);
+ db_set_s(0, MODULENAME, "gpgExec", gpgexec);
+ db_set_s(0, MODULENAME, "gpgHome", gpghome);
}
else {
db_unset(0, MODULENAME, "gpgExec");
db_unset(0, MODULENAME, "gpgHome");
}
- bSavePass = db_get_b(0,MODULENAME,"gpgSaveFlag",0);
+ bSavePass = db_get_b(0, MODULENAME, "gpgSaveFlag", 0);
if (bSavePass) {
- if (tmp = db_get_sa(0,MODULENAME,"gpgSave")) {
+ if (tmp = db_get_sa(0, MODULENAME, "gpgSave")) {
gpg_set_passphrases(tmp);
mir_free(tmp);
}
@@ -273,11 +273,11 @@ int onModulesLoaded(WPARAM, LPARAM) loadContactList();
// add new skin sound
- SkinAddNewSound("IncomingSecureMessage",LPGEN("Incoming Secure Message"),"Sounds\\iSecureMessage.wav");
- SkinAddNewSound("OutgoingSecureMessage",LPGEN("Outgoing Secure Message"),"Sounds\\oSecureMessage.wav");
+ SkinAddNewSound("IncomingSecureMessage", LPGEN("Incoming Secure Message"), "Sounds\\iSecureMessage.wav");
+ SkinAddNewSound("OutgoingSecureMessage", LPGEN("Outgoing Secure Message"), "Sounds\\oSecureMessage.wav");
// init extra icons
- for (int i=0; i < SIZEOF(g_IEC); i++)
+ for (int i = 0; i < SIZEOF(g_IEC); i++)
g_IEC[i] = (HANDLE)-1;
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onRebuildContactMenu);
@@ -316,28 +316,28 @@ int onModulesLoaded(WPARAM, LPARAM) }
if (bPGPloaded) {
- g_hMenu[6] = AddMenuItem(sim306, 110006, mode2icon(MODE_PGP|SECURED,2), MODULENAME"/PGP_SET", 0);
- g_hMenu[7] = AddMenuItem(sim307, 110007, mode2icon(MODE_PGP,2), MODULENAME"/PGP_DEL", 0);
+ g_hMenu[6] = AddMenuItem(sim306, 110006, mode2icon(MODE_PGP | SECURED, 2), MODULENAME"/PGP_SET", 0);
+ g_hMenu[7] = AddMenuItem(sim307, 110007, mode2icon(MODE_PGP, 2), MODULENAME"/PGP_DEL", 0);
}
if (bGPGloaded) {
- g_hMenu[8] = AddMenuItem(sim308, 110008, mode2icon(MODE_GPG|SECURED,2), MODULENAME"/GPG_SET", 0);
- g_hMenu[9] = AddMenuItem(sim309, 110009, mode2icon(MODE_GPG,2), MODULENAME"/GPG_DEL", 0);
+ g_hMenu[8] = AddMenuItem(sim308, 110008, mode2icon(MODE_GPG | SECURED, 2), MODULENAME"/GPG_SET", 0);
+ g_hMenu[9] = AddMenuItem(sim309, 110009, mode2icon(MODE_GPG, 2), MODULENAME"/GPG_DEL", 0);
}
if (ServiceExists(MS_CLIST_MENUBUILDSUBGROUP)) {
- g_hMenu[10] = AddMenuItem(sim311[0],110010,NULL,NULL,CMIF_ROOTPOPUP);
- g_hMenu[11] = AddSubItem(g_hMenu[10],sim231[0],110011,110010,MODULENAME"/MODE_NAT");
- g_hMenu[12] = AddSubItem(g_hMenu[10],sim231[1],110012,110010,MODULENAME"/MODE_PGP");
- g_hMenu[13] = AddSubItem(g_hMenu[10],sim231[2],110013,110010,MODULENAME"/MODE_GPG");
- g_hMenu[14] = AddSubItem(g_hMenu[10],sim231[3],110014,110010,MODULENAME"/MODE_RSA");
+ g_hMenu[10] = AddMenuItem(sim311[0], 110010, NULL, NULL, CMIF_ROOTPOPUP);
+ g_hMenu[11] = AddSubItem(g_hMenu[10], sim231[0], 110011, 110010, MODULENAME"/MODE_NAT");
+ g_hMenu[12] = AddSubItem(g_hMenu[10], sim231[1], 110012, 110010, MODULENAME"/MODE_PGP");
+ g_hMenu[13] = AddSubItem(g_hMenu[10], sim231[2], 110013, 110010, MODULENAME"/MODE_GPG");
+ g_hMenu[14] = AddSubItem(g_hMenu[10], sim231[3], 110014, 110010, MODULENAME"/MODE_RSA");
}
else {
g_hMenu[10] = 0;
- g_hMenu[11] = AddMenuItem(sim231[0],110011,NULL,MODULENAME"/MODE_NAT");
- g_hMenu[12] = AddMenuItem(sim231[1],110012,NULL,MODULENAME"/MODE_PGP");
- g_hMenu[13] = AddMenuItem(sim231[2],110013,NULL,MODULENAME"/MODE_GPG");
- g_hMenu[14] = AddMenuItem(sim231[3],110014,NULL,MODULENAME"/MODE_RSA");
+ g_hMenu[11] = AddMenuItem(sim231[0], 110011, NULL, MODULENAME"/MODE_NAT");
+ g_hMenu[12] = AddMenuItem(sim231[1], 110012, NULL, MODULENAME"/MODE_PGP");
+ g_hMenu[13] = AddMenuItem(sim231[2], 110013, NULL, MODULENAME"/MODE_GPG");
+ g_hMenu[14] = AddMenuItem(sim231[3], 110014, NULL, MODULENAME"/MODE_RSA");
}
InitSRMMIcons();
@@ -348,10 +348,10 @@ int onShutdown(WPARAM, LPARAM) {
if (bSavePass) {
LPSTR tmp = gpg_get_passphrases();
- db_set_s(0,MODULENAME,"gpgSave",tmp);
+ db_set_s(0, MODULENAME, "gpgSave", tmp);
LocalFree(tmp);
}
- else db_unset(0,MODULENAME,"gpgSave");
+ else db_unset(0, MODULENAME, "gpgSave");
if (bPGPloaded) pgp_done();
if (bGPGloaded) gpg_done();
@@ -366,5 +366,3 @@ int onShutdown(WPARAM, LPARAM) DeinitNetlib();
return 0;
}
-
-// EOF
|