summaryrefslogtreecommitdiff
path: root/plugins/SecureIM
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-31 19:09:56 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-31 19:09:56 +0000
commit33ed395de0eb385315d949c77b4e1289a6684112 (patch)
tree6698849d0a9396582130b7b2758565566b72f694 /plugins/SecureIM
parentcecb2a6e6e221b6cb94e48ef601d12bfde7f60f4 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@4267 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM')
-rw-r--r--plugins/SecureIM/src/commonheaders.cpp20
-rw-r--r--plugins/SecureIM/src/commonheaders.h1
-rw-r--r--plugins/SecureIM/src/crypt.h55
-rw-r--r--plugins/SecureIM/src/crypt_check.cpp333
-rw-r--r--plugins/SecureIM/src/crypt_dll.cpp41
-rw-r--r--plugins/SecureIM/src/crypt_icons.cpp6
-rw-r--r--plugins/SecureIM/src/crypt_lists.cpp228
-rw-r--r--plugins/SecureIM/src/crypt_metacontacts.cpp70
-rw-r--r--plugins/SecureIM/src/crypt_misc.cpp2
-rw-r--r--plugins/SecureIM/src/crypt_popups.cpp151
-rw-r--r--plugins/SecureIM/src/loadicons.cpp2
-rw-r--r--plugins/SecureIM/src/main.cpp32
-rw-r--r--plugins/SecureIM/src/options.cpp1669
-rw-r--r--plugins/SecureIM/src/options.h1
-rw-r--r--plugins/SecureIM/src/popupOptions.cpp345
-rw-r--r--plugins/SecureIM/src/splitmsg.cpp4
-rw-r--r--plugins/SecureIM/src/svcs_clist.cpp23
-rw-r--r--plugins/SecureIM/src/svcs_menu.cpp229
-rw-r--r--plugins/SecureIM/src/svcs_proto.cpp67
-rw-r--r--plugins/SecureIM/src/svcs_rsa.cpp4
-rw-r--r--plugins/SecureIM/src/svcs_srmm.cpp32
21 files changed, 1468 insertions, 1847 deletions
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp
index 5895a51b04..ed88af67f9 100644
--- a/plugins/SecureIM/src/commonheaders.cpp
+++ b/plugins/SecureIM/src/commonheaders.cpp
@@ -37,22 +37,9 @@ PLUGININFOEX pluginInfoEx = {
{0x1B2A39E5, 0xE2F6, 0x494D, {0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5}}
};
-LPSTR myDBGetString(HANDLE hContact, const char *szModule, const char *szSetting)
-{
- char *val=NULL;
- DBVARIANT dbv;
- dbv.type = DBVT_ASCIIZ;
- DBGetContactSetting(hContact,szModule,szSetting,&dbv);
- if ( dbv.pszVal && (dbv.type==DBVT_ASCIIZ || dbv.type==DBVT_UTF8 || dbv.type==DBVT_WCHAR))
- val = mir_strdup(dbv.pszVal);
- DBFreeVariant(&dbv);
- return val;
-}
-
-
LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSetting)
{
- char *val = myDBGetString(hContact,szModule,szSetting);
+ char *val = db_get_sa(hContact,szModule,szSetting);
if (!val) return NULL;
size_t len = strlen(val)+64;
char *buf = (LPSTR)mir_alloc(len);
@@ -61,14 +48,13 @@ LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSet
return buf;
}
-
int myDBWriteStringEncode(HANDLE hContact,const char *szModule,const char *szSetting,const char *val)
{
int len = (int)strlen(val)+64;
char *buf = (LPSTR)alloca(len);
strncpy(buf,val,len);
CallService(MS_DB_CRYPT_ENCODESTRING,(WPARAM)len,(LPARAM)buf);
- int ret = DBWriteContactSettingString(hContact,szModule,szSetting,buf);
+ int ret = db_set_s(hContact,szModule,szSetting,buf);
return ret;
}
@@ -112,7 +98,7 @@ int ca2u=0;
LPSTR TranslateU( LPCSTR lpText )
{
int i;
- for(i=0;i<ca2u;i++) {
+ for (i=0;i<ca2u;i++) {
if ( pa2u[i].a == lpText ) {
return pa2u[i].u;
}
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h
index 3965536da0..8ab8fbcb30 100644
--- a/plugins/SecureIM/src/commonheaders.h
+++ b/plugins/SecureIM/src/commonheaders.h
@@ -100,7 +100,6 @@ int onModulesLoaded(WPARAM, LPARAM);
int onSystemOKToExit(WPARAM, LPARAM);
int ModuleLoad(WPARAM wParam, LPARAM lParam);
-LPSTR myDBGetString(HANDLE,const char *,const char *);
LPSTR myDBGetStringDecode(HANDLE,const char *,const char *);
int myDBWriteStringEncode(HANDLE,const char *,const char *,const char *);
diff --git a/plugins/SecureIM/src/crypt.h b/plugins/SecureIM/src/crypt.h
index 8825655048..1b6680584c 100644
--- a/plugins/SecureIM/src/crypt.h
+++ b/plugins/SecureIM/src/crypt.h
@@ -12,8 +12,8 @@
struct SupPro {
LPSTR name;
BOOL inspecting;
- int split_on,tsplit_on;
- int split_off,tsplit_off;
+ int split_on, tsplit_on;
+ int split_off, tsplit_off;
};
typedef SupPro *pSupPro;
@@ -37,9 +37,10 @@ typedef partitionMessage* pPM;
#define EMPTYH 0xF1E2D3C4
// memory struct for keys
-struct UinKey {
- u_int header; // HEADER
+struct UinKey
+{
HANDLE hContact; // handle of contact
+ u_int header; // HEADER
pSupPro proto; // proto struct
BYTE mode,tmode; // mode: Native,PGP,GPG,RSA/AES,RSA [0..4]
BYTE status,tstatus; // status: Disabled,Enabled,AlwaysTry [0..2] for Native mode
@@ -93,18 +94,18 @@ struct TWaitForExchange {
extern char szUIN[NAMSIZE];
extern char szName[NAMSIZE];
-extern pSupPro proto;
-extern pUinKey clist;
-extern int proto_cnt;
-extern int clist_cnt;
+
+extern LIST<SupPro> arProto;
+extern LIST<UinKey> arClist;
// crypt_lists.cpp
void loadContactList();
void freeContactList();
-pUinKey addContact(HANDLE);
-void delContact(HANDLE);
+pUinKey addContact(HANDLE hContact);
+void delContact(HANDLE hContact);
pSupPro getSupPro(HANDLE);
-pUinKey getUinKey(HANDLE);
+pUinKey findUinKey(HANDLE hContact);
+pUinKey getUinKey(HANDLE hContact);
pUinKey getUinCtx(HANDLE);
void addMsg2Queue(pUinKey,WPARAM,LPSTR);
@@ -116,22 +117,22 @@ void getContactUinA(HANDLE hContact, LPSTR szUIN);
// crypt_check.cpp
int getContactStatus(HANDLE);
-BOOL isSecureProtocol(HANDLE);
-BYTE isContactSecured(HANDLE);
-BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda=FALSE);
-BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda=FALSE);
-BOOL isProtoSmallPackets(HANDLE);
-BOOL isContactInvisible(HANDLE);
-BOOL isNotOnList(HANDLE);
-BOOL isContactNewPG(HANDLE);
-BOOL isContactPGP(HANDLE);
-BOOL isContactGPG(HANDLE);
-BOOL isContactRSAAES(HANDLE);
-BOOL isContactRSA(HANDLE);
-BOOL isChatRoom(HANDLE);
-BOOL isFileExist(LPCSTR);
-BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM=FALSE);
-BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM=FALSE);
+bool isSecureProtocol(HANDLE hContact);
+BYTE isContactSecured(HANDLE hContact);
+bool isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda=FALSE);
+bool isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda=FALSE);
+bool isProtoSmallPackets(HANDLE);
+bool isContactInvisible(HANDLE);
+bool isNotOnList(HANDLE);
+bool isContactNewPG(HANDLE);
+bool isContactPGP(HANDLE);
+bool isContactGPG(HANDLE);
+bool isContactRSAAES(HANDLE);
+bool isContactRSA(HANDLE);
+bool isChatRoom(HANDLE);
+bool isFileExist(LPCSTR);
+bool isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM=FALSE);
+bool isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM=FALSE);
// crypt_icons.cpp
HICON mode2icon(int,int);
diff --git a/plugins/SecureIM/src/crypt_check.cpp b/plugins/SecureIM/src/crypt_check.cpp
index a8d3ebf2a5..1f9bd04249 100644
--- a/plugins/SecureIM/src/crypt_check.cpp
+++ b/plugins/SecureIM/src/crypt_check.cpp
@@ -1,267 +1,216 @@
#include "commonheaders.h"
-
-int getContactStatus(HANDLE hContact) {
-
+int getContactStatus(HANDLE hContact)
+{
pSupPro ptr = getSupPro(hContact);
if (ptr)
- return DBGetContactSettingWord(hContact, ptr->name, "Status", ID_STATUS_OFFLINE);
+ return db_get_w(hContact, ptr->name, "Status", ID_STATUS_OFFLINE);
return -1;
}
-
-BOOL isSecureProtocol(HANDLE hContact) {
-
+bool isSecureProtocol(HANDLE hContact)
+{
pSupPro ptr = getSupPro(hContact);
- if (!ptr) return false;
+ if (!ptr)
+ return false;
- return ptr->inspecting;
+ return ptr->inspecting != 0;
}
-
-BYTE isContactSecured(HANDLE hContact) {
+BYTE isContactSecured(HANDLE hContact)
+{
// нужна проверка на Offline и в этом случае другие статусы
- if (!clist_cnt) return 0;
+ if (!arClist.getCount()) 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,MODULENAME,"pgp",&dbv);
- if ( dbv.type!=0 ) r|=SECURED;
- DBFreeVariant(&dbv);
- break;
- case MODE_GPG:
- DBGetContactSetting(hContact,MODULENAME,"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;
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting)
+ return false;
+
+ BYTE res = p->mode;
+ DBVARIANT dbv;
+ switch(p->mode) {
+ case MODE_NATIVE:
+ if (cpp_keyx(p->cntx) != 0) res |= SECURED;
+ break;
+
+ case MODE_PGP:
+ if (!db_get_s(hContact, MODULENAME, "pgp", &dbv)) {
+ res |= SECURED;
+ db_free(&dbv);
}
- }
- return r; // (mode&SECURED) - проверка на EST/DIS
-}
+ break;
+
+ case MODE_GPG:
+ if (!db_get_s(hContact, MODULENAME, "gpg", &dbv)) {
+ res |= SECURED;
+ db_free(&dbv);
+ }
+ break;
+ case MODE_RSAAES:
+ if (exp->rsa_get_state(p->cntx) == 7) res |= SECURED;
+ break;
-BOOL isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda) {
+ case MODE_RSA:
+ if (p->cntx != 0) res |= SECURED;
+ break;
+ }
+ return res;
+}
- if ( !bMCD ) return true;
- if ( !ptr->proto->inspecting ) return false;
+bool isClientMiranda(pUinKey ptr, BOOL emptyMirverAsMiranda)
+{
+ if (!bMCD) return true;
+ if (!ptr->proto->inspecting) return false;
- BOOL isMiranda = true;
- LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer");
- if ( mirver ) {
+ bool isMiranda = true;
+ LPSTR mirver = db_get_sa(ptr->hContact,ptr->proto->name,"MirVer");
+ if (mirver) {
isMiranda = (emptyMirverAsMiranda && !*mirver) || (strstr(mirver,"Miranda")!=NULL);
mir_free(mirver);
}
return isMiranda;
}
+bool isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda)
+{
+ if (!bMCD) return true;
+ if (!arClist.getCount()) return false;
-BOOL isClientMiranda(HANDLE hContact, BOOL emptyMirverAsMiranda) {
-
- if ( !bMCD ) return true;
- if ( !clist_cnt ) return false;
-
- for(int j=0;j<clist_cnt;j++) {
- if ( clist[j].hContact == hContact ) {
- return isClientMiranda(&clist[j],emptyMirverAsMiranda);
- }
- }
- return false;
+ pUinKey p = findUinKey(hContact);
+ return (p) ? isClientMiranda(p, emptyMirverAsMiranda) : false;
}
+bool isProtoSmallPackets(HANDLE hContact)
+{
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting)
+ return false;
-BOOL isProtoSmallPackets(HANDLE hContact) {
-
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if ( clist[j].hContact == hContact ) {
- if ( !clist[j].proto->inspecting ) break;
- return strstr(clist[j].proto->name,"IRC")!=NULL ||
- strstr(clist[j].proto->name,"WinPopup")!=NULL ||
- strstr(clist[j].proto->name,"VyChat")!=NULL;
- }
- }
- return false;
+ return strstr(p->proto->name,"IRC") != NULL || strstr(p->proto->name,"WinPopup") != NULL || strstr(p->proto->name,"VyChat") != NULL;
}
+bool isContactInvisible(HANDLE hContact)
+{
+ if (db_get_b(hContact, "CList", "Hidden", 0))
+ return true;
+
+ pUinKey p = findUinKey(hContact);
+ if (!p || p->waitForExchange || !p->proto || !p->proto->inspecting)
+ return false;
-BOOL isContactInvisible(HANDLE hContact) {
-
- if ( !db_get_b(hContact,"CList","Hidden",0)) {
- if ( !clist_cnt ) return false;
- for(int j=0;j<clist_cnt;j++) {
- if ( clist[j].hContact == hContact ) {
- if ( !clist[j].proto->inspecting ) return false;
- if ( clist[j].waitForExchange ) return false;
- switch( (int)DBGetContactSettingWord(hContact,clist[j].proto->name,"ApparentMode",0)) {
- case 0:
- return (CallProtoService(clist[j].proto->name,PS_GETSTATUS,0,0)==ID_STATUS_INVISIBLE);
- case ID_STATUS_ONLINE:
- return false;
- case ID_STATUS_OFFLINE:
- return true;
- } //switch
- break;
- }
- }// for
+ switch(db_get_w(hContact, p->proto->name, "ApparentMode", 0)) {
+ case 0:
+ return CallProtoService(p->proto->name, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE;
+ case ID_STATUS_ONLINE:
+ return false;
+ case ID_STATUS_OFFLINE:
+ return true;
}
- return true;
+ return false;
}
-
-BOOL isNotOnList(HANDLE hContact) {
- return db_get_b(hContact, "CList", "NotOnList", 0);
+bool isNotOnList(HANDLE hContact)
+{
+ return db_get_b(hContact, "CList", "NotOnList", 0) != 0;
}
+bool isContactNewPG(HANDLE hContact)
+{
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting || !p->cntx)
+ return false;
-BOOL isContactNewPG(HANDLE hContact) {
-
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- if ( !clist[j].proto->inspecting ) break;
- if ( !clist[j].cntx ) break;
- return (clist[j].features & CPP_FEATURES_NEWPG) != 0;
- }
- }
- return false;
+ return (p->features & CPP_FEATURES_NEWPG) != 0;
}
+bool isContactPGP(HANDLE hContact)
+{
+ if (!bPGPloaded || (!bPGPkeyrings && !bPGPprivkey)) return false;
-BOOL isContactPGP(HANDLE hContact) {
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting || p->mode != MODE_PGP)
+ return false;
- if (!bPGPloaded || (!bPGPkeyrings && !bPGPprivkey)) return false;
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- if ( !clist[j].proto->inspecting ) break;
- if ( clist[j].mode!=MODE_PGP ) break;
- DBVARIANT dbv;
- DBGetContactSetting(hContact,MODULENAME,"pgp",&dbv);
- BOOL r=(dbv.type!=0);
- DBFreeVariant(&dbv);
- return r;
- }
- }
- return false;
+ DBVARIANT dbv;
+ if (db_get_s(hContact, MODULENAME, "pgp", &dbv)) return false;
+ db_free(&dbv);
+ return true;
}
+bool isContactGPG(HANDLE hContact)
+{
+ if (!bGPGloaded || !bGPGkeyrings) return false;
-BOOL isContactGPG(HANDLE hContact) {
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting || p->mode != MODE_GPG)
+ return false;
- if (!bGPGloaded || !bGPGkeyrings) return false;
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- if ( !clist[j].proto->inspecting ) break;
- if ( clist[j].mode!=MODE_GPG ) break;
- DBVARIANT dbv;
- DBGetContactSetting(hContact,MODULENAME,"gpg",&dbv);
- BOOL r=(dbv.type!=0);
- DBFreeVariant(&dbv);
- return r;
- }
- }
- return false;
+ DBVARIANT dbv;
+ if (db_get_s(hContact, MODULENAME, "gpg", &dbv)) return false;
+ db_free(&dbv);
+ return true;
}
+bool isContactRSAAES(HANDLE hContact)
+{
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting)
+ return false;
-BOOL isContactRSAAES(HANDLE hContact) {
-
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- if ( !clist[j].proto->inspecting ) break;
- if ( clist[j].mode!=MODE_RSAAES ) break;
- return true;
- }
- }
- return false;
+ return p->mode == MODE_RSAAES;
}
+bool isContactRSA(HANDLE hContact)
+{
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting)
+ return false;
-BOOL isContactRSA(HANDLE hContact) {
-
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- if ( !clist[j].proto->inspecting ) break;
- if ( clist[j].mode!=MODE_RSA ) break;
- return true;
- }
- }
- return false;
+ return p->mode == MODE_RSA;
}
+bool isChatRoom(HANDLE hContact)
+{
+ pUinKey p = findUinKey(hContact);
+ if (!p || !p->proto || !p->proto->inspecting)
+ return false;
-BOOL isChatRoom(HANDLE hContact) {
-
- if (!clist_cnt) return false;
- for(int j=0;j<clist_cnt;j++) {
- if ( clist[j].hContact == hContact ) {
- if ( !clist[j].proto->inspecting ) break;
- return (db_get_b(hContact,clist[j].proto->name,"ChatRoom",0)!=0);
- }
- }
- return false;
+ return db_get_b(hContact, p->proto->name, "ChatRoom", 0) != 0;
}
-
-BOOL isFileExist(LPCSTR filename) {
+bool isFileExist(LPCSTR filename)
+{
return (GetFileAttributes(filename)!=(UINT)-1);
}
+bool isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM)
+{
+ if (!bAIP) return false;
+ if (!ptr->proto->inspecting) return false;
-BOOL isSecureIM(pUinKey ptr, BOOL emptyMirverAsSecureIM) {
-
- if ( !bAIP ) return false;
- if ( !ptr->proto->inspecting ) return false;
-
- BOOL isSecureIM = false;
- if ( bNOL && db_get_b(ptr->hContact,"CList","NotOnList",0)) {
+ if (bNOL && db_get_b(ptr->hContact, "CList", "NotOnList", 0))
return false;
- }
- LPSTR mirver = myDBGetString(ptr->hContact,ptr->proto->name,"MirVer");
- if ( mirver ) {
+
+ bool isSecureIM = false;
+ LPSTR mirver = db_get_sa(ptr->hContact,ptr->proto->name,"MirVer");
+ if (mirver) {
isSecureIM = (emptyMirverAsSecureIM && !*mirver) || (strstr(mirver,"SecureIM")!=NULL) || (strstr(mirver,"secureim")!=NULL);
mir_free(mirver);
}
return isSecureIM;
}
+bool isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM)
+{
+ if (!bAIP) return false;
-BOOL isSecureIM(HANDLE hContact, BOOL emptyMirverAsSecureIM) {
-
- if ( !bAIP ) return false;
- if ( !clist_cnt ) return false;
-
- for(int j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- return isSecureIM(&clist[j],emptyMirverAsSecureIM);
- }
- }
- return false;
+ pUinKey p = findUinKey(hContact);
+ return (p) ? isSecureIM(p, emptyMirverAsSecureIM) : false;
}
-
// EOF
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp
index 3a2e5ad6a3..5bd50c4ca3 100644
--- a/plugins/SecureIM/src/crypt_dll.cpp
+++ b/plugins/SecureIM/src/crypt_dll.cpp
@@ -9,7 +9,7 @@ LPSTR InitKeyA(pUinKey ptr,int features) {
if ( !ptr->cntx )
ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0);
- char *tmp = myDBGetString(ptr->hContact,MODULENAME,"PSK");
+ char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK");
if (tmp) {
cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password
mir_free(tmp);
@@ -50,7 +50,7 @@ int InitKeyB(pUinKey ptr,LPCSTR key) {
ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0);
if (!cpp_keyp(ptr->cntx)) {
- char *tmp = myDBGetString(ptr->hContact,MODULENAME,"PSK");
+ char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK");
if (tmp) {
cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password
mir_free(tmp);
@@ -100,7 +100,7 @@ BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
// store timeout of key in database (2 days)
cws.szSetting = "offlineKeyTimeout";
cws.value.type = DBVT_DWORD;
- cws.value.dVal = gettime()+(60*60*24*DBGetContactSettingWord(0,MODULENAME,"okt",2));
+ cws.value.dVal = gettime()+(60*60*24*db_get_w(0,MODULENAME,"okt",2));
CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&cws);
// key exchange is finished
@@ -199,32 +199,31 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
}
-BOOL LoadKeyPGP(pUinKey ptr) {
- int mode = db_get_b(ptr->hContact,MODULENAME,"pgp_mode",255);
- if (mode==0) {
- DBVARIANT dbv;
- DBGetContactSetting(ptr->hContact,MODULENAME,"pgp",&dbv);
+BOOL LoadKeyPGP(pUinKey ptr)
+{
+ int mode = db_get_b(ptr->hContact,MODULENAME,"pgp_mode",255);
+ if (mode == 0) {
+ DBVARIANT dbv;
+ DBGetContactSetting(ptr->hContact,MODULENAME,"pgp",&dbv);
BOOL r=(dbv.type==DBVT_BLOB);
if (r) pgp_set_keyid(ptr->cntx,(PVOID)dbv.pbVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
return r;
- }
- else
- if (mode==1) {
- LPSTR key = myDBGetStringDecode(ptr->hContact,MODULENAME,"pgp");
- if ( key ) {
- pgp_set_key(ptr->cntx,key);
- mir_free(key);
- return 1;
- }
- }
+ }
+ else if (mode == 1) {
+ LPSTR key = myDBGetStringDecode(ptr->hContact,MODULENAME,"pgp");
+ if (key) {
+ pgp_set_key(ptr->cntx,key);
+ mir_free(key);
+ return 1;
+ }
+ }
return 0;
}
-
BOOL LoadKeyGPG(pUinKey ptr) {
- LPSTR key = myDBGetString(ptr->hContact,MODULENAME,"gpg");
+ LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"gpg");
if ( key ) {
gpg_set_keyid(ptr->cntx,key);
mir_free(key);
diff --git a/plugins/SecureIM/src/crypt_icons.cpp b/plugins/SecureIM/src/crypt_icons.cpp
index b22fc909cf..6bcfcde382 100644
--- a/plugins/SecureIM/src/crypt_icons.cpp
+++ b/plugins/SecureIM/src/crypt_icons.cpp
@@ -15,7 +15,7 @@ static ICON_CACHE& getCacheItem(int mode, int type)
int m = mode & 0x0f, s = (mode & SECURED)>>4, i; // разобрали на части - режим и состояние
HICON icon;
- for(i=0; i < arIcoList.getCount(); i++)
+ for (i=0; i < arIcoList.getCount(); i++)
if (arIcoList[i].mode == ((type<<8) | mode))
return arIcoList[i];
@@ -78,7 +78,7 @@ void ShowStatusIcon(HANDLE hContact, int mode)
if ( ServiceExists(MS_MSG_MODIFYICON)) { // обновить иконки в srmm
StatusIconData sid = {sizeof(sid) };
sid.szModule = (char*)MODULENAME;
- for(int i = MODE_NATIVE; i < MODE_CNT; i++) {
+ for (int i = MODE_NATIVE; i < MODE_CNT; i++) {
sid.dwId = i;
sid.flags = (mode & SECURED) ? 0 : MBF_DISABLED;
if (mode == -1 || (mode & 0x0f) != i || isChatRoom(hContact))
@@ -97,7 +97,7 @@ void ShowStatusIcon(HANDLE hContact)
void ShowStatusIconNotify(HANDLE hContact)
{
- int mode = isContactSecured(hContact);
+ BYTE mode = isContactSecured(hContact);
NotifyEventHooks(g_hEvent[(mode&SECURED)!=0], (WPARAM)hContact, 0);
ShowStatusIcon(hContact,mode);
}
diff --git a/plugins/SecureIM/src/crypt_lists.cpp b/plugins/SecureIM/src/crypt_lists.cpp
index 964cb7b4ff..30f6c432d8 100644
--- a/plugins/SecureIM/src/crypt_lists.cpp
+++ b/plugins/SecureIM/src/crypt_lists.cpp
@@ -1,135 +1,120 @@
#include "commonheaders.h"
-pSupPro proto=NULL;
-pUinKey clist=NULL;
-int proto_cnt = 0;
-int clist_cnt = 0;
-int clist_inc = 100;
+LIST<SupPro> arProto(10, LIST<SupPro>::FTSortFunc(HandleKeySortT));
+LIST<UinKey> arClist(100, LIST<UinKey>::FTSortFunc(HandleKeySortT));
-void loadSupportedProtocols() {
- int numberOfProtocols;
- PROTOACCOUNT **protos;
- LPSTR szNames = myDBGetString(0,MODULENAME,"protos");
- if ( szNames && strchr(szNames,':') == NULL ) {
+void loadSupportedProtocols()
+{
+ LPSTR szNames = db_get_sa(0,MODULENAME,"protos");
+ if (szNames && strchr(szNames,':') == NULL) {
LPSTR tmp = (LPSTR) mir_alloc(2048); int j=0;
- for(int i=0; szNames[i]; i++) {
- if ( szNames[i] == ';' ) {
+ for (int i=0; szNames[i]; i++) {
+ if (szNames[i] == ';')
memcpy((PVOID)(tmp+j),(PVOID)":1:0:0",6); j+=6;
- }
+
tmp[j++] = szNames[i];
}
tmp[j] = '\0';
SAFE_FREE(szNames); szNames = tmp;
- DBWriteContactSettingString(0,MODULENAME,"protos",szNames);
+ db_set_s(0,MODULENAME,"protos",szNames);
}
+ int numberOfProtocols;
+ PROTOACCOUNT **protos;
ProtoEnumAccounts(&numberOfProtocols, &protos);
for (int i=0; i < numberOfProtocols; i++) {
- if (protos[i]->szModuleName && CallProtoService(protos[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0)) {
- int j = proto_cnt; proto_cnt++;
- proto = (pSupPro) mir_realloc(proto,sizeof(SupPro)*proto_cnt);
- memset(&proto[j],0,sizeof(SupPro));
- proto[j].name = mir_strdup(protos[i]->szModuleName);
- if ( szNames ) {
- if ( proto[j].name ) {
- char tmp[128]; strcpy(tmp,proto[j].name); strcat(tmp,":");
- LPSTR szName = strstr(szNames,tmp);
- if ( szName ) {
+ if (!protos[i]->szModuleName || !CallProtoService(protos[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0))
+ continue;
+
+ SupPro *p = (SupPro*)mir_calloc(sizeof(SupPro));
+ p->name = mir_strdup(protos[i]->szModuleName);
+ if (szNames && p->name) {
+ char tmp[128]; strcpy(tmp, p->name); strcat(tmp,":");
+ LPSTR szName = strstr(szNames, tmp);
+ if (szName) {
+ szName = strchr(szName,':');
+ if (szName) {
+ p->inspecting = (*++szName == '1');
+ szName = strchr(szName,':');
+ if (szName) {
+ p->split_on = atoi(++szName); p->tsplit_on = p->split_on;
szName = strchr(szName,':');
- if ( szName ) {
- proto[j].inspecting = (*++szName == '1');
- szName = strchr(szName,':');
- if ( szName ) {
- proto[j].split_on = atoi(++szName); proto[j].tsplit_on = proto[j].split_on;
- szName = strchr(szName,':');
- if ( szName ) {
- proto[j].split_off = atoi(++szName); proto[j].tsplit_off = proto[j].split_off;
- }
- }
- }
+ if (szName)
+ p->split_off = atoi(++szName); p->tsplit_off = p->split_off;
}
}
}
- else proto[j].inspecting = true;
}
+ else p->inspecting = true;
+ arProto.insert(p);
}
SAFE_FREE(szNames);
}
+void freeSupportedProtocols()
+{
+ for (int j=0; j < arProto.getCount(); j++) {
+ mir_free(arProto[j]->name);
+ mir_free(arProto[j]);
+ }
-void freeSupportedProtocols() {
- for (int j=0;j<proto_cnt;j++)
- mir_free(proto[j].name);
-
- SAFE_FREE(proto);
- proto_cnt = 0;
+ arProto.destroy();
}
-pSupPro getSupPro(HANDLE hContact) {
- int j;
- for(j=0;j<proto_cnt && !CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)proto[j].name);j++);
- if (j==proto_cnt) return NULL;
- return &proto[j];
+pSupPro getSupPro(HANDLE hContact)
+{
+ for (int j=0; j < arProto.getCount(); j++)
+ if ( CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)arProto[j]->name))
+ return arProto[j];
+
+ return NULL;
}
// add contact in the list of secureIM users
-pUinKey addContact(HANDLE hContact) {
- int j;
- if (hContact) {
- pSupPro proto = getSupPro(hContact);
- if ( proto ) {
- for(j=0;j<clist_cnt;j++) {
- if ( !clist[j].hContact ) break;
- }
- if (j==clist_cnt) {
- clist_cnt+=clist_inc;
- clist = (pUinKey) mir_realloc(clist,sizeof(UinKey)*clist_cnt);
- memset(&clist[j],0,sizeof(UinKey)*clist_inc);
- }
- else
- memset(&clist[j],0,sizeof(UinKey));
- clist[j].header = HEADER;
- clist[j].footer = FOOTER;
- clist[j].hContact = hContact;
- clist[j].proto = proto;
- clist[j].mode = db_get_b(hContact, MODULENAME, "mode", 99);
- if ( clist[j].mode == 99 ) {
- if ( isContactPGP(hContact)) clist[j].mode = MODE_PGP;
- else
- if ( isContactGPG(hContact)) clist[j].mode = MODE_GPG;
- else
- clist[j].mode = MODE_RSAAES;
- db_set_b(hContact, MODULENAME, "mode", clist[j].mode);
- }
- clist[j].status = db_get_b(hContact, MODULENAME, "StatusID", STATUS_ENABLED);
- clist[j].gpgMode = db_get_b(hContact, MODULENAME, "gpgANSI", 0);
- return &clist[j];
- }
+pUinKey addContact(HANDLE hContact)
+{
+ if (hContact == NULL) return NULL;
+
+ pSupPro proto = getSupPro(hContact);
+ if (proto == NULL) return NULL;
+
+ pUinKey p = (pUinKey)mir_calloc(sizeof(UinKey));
+ p->header = HEADER;
+ p->footer = FOOTER;
+ p->hContact = hContact;
+ p->proto = proto;
+ p->mode = db_get_b(hContact, MODULENAME, "mode", 99);
+ if (p->mode == 99) {
+ if ( isContactPGP(hContact))
+ p->mode = MODE_PGP;
+ else
+ p->mode = isContactGPG(hContact) ? MODE_GPG : MODE_RSAAES;
+ db_set_b(hContact, MODULENAME, "mode", p->mode);
}
- return NULL;
+ p->status = db_get_b(hContact, MODULENAME, "StatusID", STATUS_ENABLED);
+ p->gpgMode = db_get_b(hContact, MODULENAME, "gpgANSI", 0);
+ arClist.insert(p);
+ return p;
}
// delete contact from the list of secureIM users
-void delContact(HANDLE hContact) {
- if (hContact) {
- int j;
- for(j=0;j<clist_cnt;j++) {
- if (clist[j].hContact == hContact) {
- cpp_delete_context(clist[j].cntx); clist[j].cntx = 0;
- clist[j].hContact = 0;
- SAFE_FREE(clist[j].tmp);
- SAFE_FREE(clist[j].msgSplitted);
- clist[j].header = clist[j].footer = EMPTYH;
- return;
- }
- }
+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);
}
}
// load contactlist in the list of secureIM users
-void loadContactList() {
-
+void loadContactList()
+{
freeContactList();
loadSupportedProtocols();
@@ -141,35 +126,40 @@ void loadContactList() {
}
// free list of secureIM users
-void freeContactList() {
-
- for(int j=0;j<clist_cnt;j++) {
- cpp_delete_context(clist[j].cntx);
- SAFE_FREE(clist[j].tmp);
- SAFE_FREE(clist[j].msgSplitted);
+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);
}
- SAFE_FREE(clist);
- clist_cnt = 0;
+ arClist.destroy();
freeSupportedProtocols();
}
-
// find user in the list of secureIM users and add him, if unknow
-pUinKey getUinKey(HANDLE hContact) {
- int j;
- for(j=0;j<clist_cnt && clist[j].hContact!=hContact;j++);
- if (j==clist_cnt) return addContact(hContact);
- return &clist[j];
+pUinKey findUinKey(HANDLE hContact)
+{
+ return arClist.find((pUinKey)&hContact);
}
-pUinKey getUinCtx(HANDLE cntx) {
- int j;
- for(j=0;j<clist_cnt && clist[j].cntx!=cntx;j++);
- if (j==clist_cnt) return NULL;
- return &clist[j];
+pUinKey getUinKey(HANDLE hContact)
+{
+ pUinKey p = arClist.find((pUinKey)&hContact);
+ return (p) ? p : addContact(hContact);
}
+pUinKey getUinCtx(HANDLE cntx)
+{
+ for (int j=0; j < arClist.getCount(); j++)
+ if (arClist[j]->cntx == cntx)
+ return arClist[j];
+
+ return NULL;
+}
// add message to user queue for send later
void addMsg2Queue(pUinKey ptr,WPARAM wParam,LPSTR szMsg) {
@@ -221,12 +211,13 @@ void getContactName(HANDLE hContact, LPSTR szName)
wcscpy((LPWSTR)szName, (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GSMDF_UNICODE));
}
-void getContactUinA(HANDLE hContact, LPSTR szUIN) {
-
+void getContactUinA(HANDLE hContact, LPSTR szUIN)
+{
*szUIN = 0;
pSupPro ptr = getSupPro(hContact);
- if (!ptr) return;
+ if (!ptr)
+ return;
DBVARIANT dbv_uniqueid;
LPSTR uID = (LPSTR) CallProtoService(ptr->name, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
@@ -243,7 +234,7 @@ void getContactUinA(HANDLE hContact, LPSTR szUIN) {
}
else strcpy(szUIN, "=== unknown ===");
- DBFreeVariant(&dbv_uniqueid);
+ db_free(&dbv_uniqueid);
}
void getContactUin(HANDLE hContact, LPSTR szUIN)
@@ -256,5 +247,4 @@ void getContactUin(HANDLE hContact, LPSTR szUIN)
}
}
-
// EOF
diff --git a/plugins/SecureIM/src/crypt_metacontacts.cpp b/plugins/SecureIM/src/crypt_metacontacts.cpp
index d78f4adc49..87e948716a 100644
--- a/plugins/SecureIM/src/crypt_metacontacts.cpp
+++ b/plugins/SecureIM/src/crypt_metacontacts.cpp
@@ -1,58 +1,48 @@
#include "commonheaders.h"
-
-BOOL isProtoMetaContacts(HANDLE hContact) {
- if (bMetaContacts) {
- LPSTR proto = GetContactProto(hContact);
- if ( proto && strcmp(proto,"MetaContacts")==0 ) {
- return true;
- }
- }
-// for(int j=0;j<clist_cnt;j++)
-// if (clist[j].hContact==hContact && clist[j].proto->inspecting)
-// return strstr(clist[j].proto->name,"MetaContacts")!=NULL;
- return false;
+BOOL isProtoMetaContacts(HANDLE hContact)
+{
+ if (bMetaContacts) {
+ LPSTR proto = GetContactProto(hContact);
+ if ( proto && !strcmp(proto,"MetaContacts"))
+ return true;
+ }
+ return false;
}
+BOOL isDefaultSubContact(HANDLE hContact)
+{
+ if (bMetaContacts)
+ return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0) == hContact;
-BOOL isDefaultSubContact(HANDLE hContact) {
-
- if (bMetaContacts) {
- return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0),0)==hContact;
- }
- return false;
+ return false;
}
+HANDLE getMetaContact(HANDLE hContact)
+{
+ if (bMetaContacts)
+ return (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
-HANDLE getMetaContact(HANDLE hContact) {
-
- if (bMetaContacts) {
- return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
- }
- return 0;
+ return 0;
}
+HANDLE getMostOnline(HANDLE hContact)
+{
+ if (bMetaContacts)
+ return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
-HANDLE getMostOnline(HANDLE hContact) {
-
- if (bMetaContacts) {
- return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
- }
- return 0;
+ return 0;
}
-
// remove all secureim connections on subcontacts
-void DeinitMetaContact(HANDLE hContact) {
-
+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);
- }
+ if (hMetaContact) {
+ for (int i=0; i < CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hMetaContact,0); i++) {
+ HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hMetaContact, i);
+ if (hSubContact && (isContactSecured(hSubContact)&SECURED))
+ CallContactService(hSubContact,PSS_MESSAGE, PREF_METANODB, (LPARAM)SIG_DEIN);
}
}
}
diff --git a/plugins/SecureIM/src/crypt_misc.cpp b/plugins/SecureIM/src/crypt_misc.cpp
index 4b82746279..3675a4198e 100644
--- a/plugins/SecureIM/src/crypt_misc.cpp
+++ b/plugins/SecureIM/src/crypt_misc.cpp
@@ -43,7 +43,7 @@ unsigned __stdcall sttWaitForExchange( LPVOID param ) {
if ( !ptr ) return 0;
- for(int i=0;i<DBGetContactSettingWord(0,MODULENAME,"ket",10)*10; i++) {
+ for (int i=0;i<db_get_w(0,MODULENAME,"ket",10)*10; i++) {
Sleep( 100 );
if ( ptr->waitForExchange != 1 ) break;
} // for
diff --git a/plugins/SecureIM/src/crypt_popups.cpp b/plugins/SecureIM/src/crypt_popups.cpp
index 6f217273c1..721dafd0b5 100644
--- a/plugins/SecureIM/src/crypt_popups.cpp
+++ b/plugins/SecureIM/src/crypt_popups.cpp
@@ -1,78 +1,44 @@
#include "commonheaders.h"
-/*
-static int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
- switch(message) {
- case WM_COMMAND:
- if (wParam == STN_CLICKED) { // It was a click on the Popup.
- PUDeletePopUp(hWnd);
- return TRUE;
- }
- break;
- case UM_FREEPLUGINDATA: {
- return TRUE; //TRUE or FALSE is the same, it gets ignored.
- }
- default:
- break;
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
-}
-*/
-
-void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type) {
+void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type)
+{
//type=0 key colors
//type=1 session colors
//type=2 SR colors
if (!bPopupExists) return;
- //hContact = A_VALID_HANDLE_YOU_GOT_FROM_SOMEWHERE;
- COLORREF colorBackKey = RGB(230,230,255);
- COLORREF colorTextKey = RGB(0,0,0);
- COLORREF colorBackSec = RGB(255,255,200);
- COLORREF colorTextSec = RGB(0,0,0);
- COLORREF colorBackSR = RGB(200,255,200);
- COLORREF colorTextSR = RGB(0,0,0);
- COLORREF colorBack = 0;
- COLORREF colorText = 0;
+ COLORREF colorBack, colorText;
int timeout=0;
- int res;
- DBVARIANT dbv_timeout;
+ DBVARIANT dbv;
- if (type==0) {
- colorBack=DBGetContactSettingDword(0,MODULENAME,"colorKeyb",(UINT)-1);
- colorText=DBGetContactSettingDword(0,MODULENAME,"colorKeyt",(UINT)-1);
- if (colorBack==(UINT)-1) colorBack=colorBackKey;
- if (colorText==(UINT)-1) colorText=colorTextKey;
-
- res=DBGetContactSetting(0,MODULENAME,"timeoutKey",&dbv_timeout);
- if (res==0) timeout=atoi(dbv_timeout.pszVal);
- DBFreeVariant(&dbv_timeout);
+ if (type == 0) {
+ colorBack = db_get_dw(0, MODULENAME, "colorKeyb", RGB(230,230,255));
+ colorText = db_get_dw(0, MODULENAME, "colorKeyt", RGB(0,0,0));
+ if (!db_get_s(0, MODULENAME, "timeoutKey", &dbv)) {
+ timeout = atoi(dbv.pszVal);
+ db_free(&dbv);
+ }
}
- else if (type==1) {
- colorBack=DBGetContactSettingDword(0,MODULENAME,"colorSecb",(UINT)-1);
- colorText=DBGetContactSettingDword(0,MODULENAME,"colorSect",(UINT)-1);
- if (colorBack==(UINT)-1) colorBack=colorBackSec;
- if (colorText==(UINT)-1) colorText=colorTextSec;
-
- res=DBGetContactSetting(0,MODULENAME,"timeoutSec",&dbv_timeout);
- if (res==0) timeout=atoi(dbv_timeout.pszVal);
- DBFreeVariant(&dbv_timeout);
+ else if (type == 1) {
+ colorBack = db_get_dw(0, MODULENAME, "colorSecb", RGB(255,255,200));
+ colorText = db_get_dw(0, MODULENAME, "colorSect", RGB(0,0,0));
+ if (!db_get_s(0, MODULENAME, "timeoutSec" ,&dbv)) {
+ timeout = atoi(dbv.pszVal);
+ db_free(&dbv);
+ }
}
- else if (type>=2) {
- colorBack=DBGetContactSettingDword(0, MODULENAME, "colorSRb", (UINT)-1);
- colorText=DBGetContactSettingDword(0, MODULENAME, "colorSRt", (UINT)-1);
- if (colorBack==(UINT)-1) colorBack=colorBackSR;
- if (colorText==(UINT)-1) colorText=colorTextSR;
-
- res=DBGetContactSetting(0,MODULENAME,"timeoutSR",&dbv_timeout);
- if (res==0) timeout=atoi(dbv_timeout.pszVal);
- DBFreeVariant(&dbv_timeout);
+ else if (type >= 2) {
+ colorBack = db_get_dw(0, MODULENAME, "colorSRb", RGB(200,255,200));
+ colorText = db_get_dw(0, MODULENAME, "colorSRt", RGB(0,0,0));
+ if (!db_get_s(0, MODULENAME, "timeoutSR", &dbv)) {
+ timeout = atoi(dbv.pszVal);
+ db_free(&dbv);
+ }
}
POPUPDATAW ppd = {0};
-
ppd.lchContact = hContact; //Be sure to use a GOOD handle, since this will not be checked.
ppd.lchIcon = hIcon;
LPWSTR lpwzContactName = (LPWSTR)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GSMDF_UNICODE);
@@ -83,46 +49,57 @@ void showPopUp(LPCSTR lpzText,HANDLE hContact,HICON hIcon, UINT type) {
ppd.colorBack = colorBack;
ppd.colorText = colorText;
ppd.iSeconds = timeout;
-
- //Now that every field has been filled, we want to see the popup.
PUAddPopUpW(&ppd);
}
-
-void showPopUpDCmsg(HANDLE hContact,LPCSTR msg) {
- int indic=db_get_b(0, MODULENAME, "dc",1);
- if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_DIS],1);
+void showPopUpDCmsg(HANDLE hContact,LPCSTR msg)
+{
+ if (db_get_b(0, MODULENAME, "dc", 1))
+ showPopUp(msg, hContact, g_hPOP[POP_PU_DIS], 1);
}
-void showPopUpDC(HANDLE hContact) {
- int indic=db_get_b(0, MODULENAME, "dc",1);
- if (indic==1) showPopUp(sim006,hContact,g_hPOP[POP_PU_DIS],1);
+
+void showPopUpDC(HANDLE hContact)
+{
+ if (db_get_b(0, MODULENAME, "dc", 1))
+ showPopUp(sim006, hContact, g_hPOP[POP_PU_DIS], 1);
}
-void showPopUpEC(HANDLE hContact) {
- int indic=db_get_b(0, MODULENAME, "ec",1);
- if (indic==1) showPopUp(sim001,hContact,g_hPOP[POP_PU_EST],1);
+
+void showPopUpEC(HANDLE hContact)
+{
+ if (db_get_b(0, MODULENAME, "ec", 1))
+ showPopUp(sim001, hContact, g_hPOP[POP_PU_EST], 1);
}
-void showPopUpKS(HANDLE hContact) {
- int indic=db_get_b(0, MODULENAME, "ks",1);
- if (indic==1) showPopUp(sim007,hContact,g_hPOP[POP_PU_PRC],0);
+
+void showPopUpKS(HANDLE hContact)
+{
+ if (db_get_b(0, MODULENAME, "ks",1))
+ showPopUp(sim007, hContact, g_hPOP[POP_PU_PRC], 0);
}
-void showPopUpKRmsg(HANDLE hContact,LPCSTR msg) {
- int indic=db_get_b(0, MODULENAME, "kr",1);
- if (indic==1) showPopUp(msg,hContact,g_hPOP[POP_PU_PRC],0);
+
+void showPopUpKRmsg(HANDLE hContact,LPCSTR msg)
+{
+ if (db_get_b(0, MODULENAME, "kr", 1))
+ showPopUp(msg, hContact, g_hPOP[POP_PU_PRC], 0);
}
-void showPopUpKR(HANDLE hContact) {
- int indic=db_get_b(0, MODULENAME, "kr",1);
- if (indic==1) showPopUp(sim008,hContact,g_hPOP[POP_PU_PRC],0);
+
+void showPopUpKR(HANDLE hContact)
+{
+ if (db_get_b(0, MODULENAME, "kr", 1))
+ showPopUp(sim008, hContact, g_hPOP[POP_PU_PRC], 0);
}
-void showPopUpSM(HANDLE hContact) {
- int indic=db_get_b(0, MODULENAME, "ss",0);
- if (indic==1) showPopUp(sim009,hContact,g_hPOP[POP_PU_MSS],2);
+
+void showPopUpSM(HANDLE hContact)
+{
+ if (db_get_b(0, MODULENAME, "ss", 0))
+ showPopUp(sim009, hContact, g_hPOP[POP_PU_MSS], 2);
SkinPlaySound("OutgoingSecureMessage");
}
-void showPopUpRM(HANDLE hContact) {
- int indic=db_get_b(0, MODULENAME, "sr",0);
- if (indic==1) showPopUp(sim010,hContact,g_hPOP[POP_PU_MSR],2);
+
+void showPopUpRM(HANDLE hContact)
+{
+ if (db_get_b(0, MODULENAME, "sr", 0))
+ showPopUp(sim010, hContact, g_hPOP[POP_PU_MSR], 2);
SkinPlaySound("IncomingSecureMessage");
}
-
// EOF
diff --git a/plugins/SecureIM/src/loadicons.cpp b/plugins/SecureIM/src/loadicons.cpp
index cf86cb77dc..473bc7108a 100644
--- a/plugins/SecureIM/src/loadicons.cpp
+++ b/plugins/SecureIM/src/loadicons.cpp
@@ -46,7 +46,7 @@ HINSTANCE LoadIconsPack(const char* szIconsPack)
{
HINSTANCE hNewIconInst = LoadLibrary(szIconsPack);
if (hNewIconInst != NULL) {
- for(int i = ID_FIRSTICON; i <= ID_LASTICON; i++)
+ for (int i = ID_FIRSTICON; i <= ID_LASTICON; i++)
if (LoadIcon(hNewIconInst, MAKEINTRESOURCE(i)) == NULL) {
FreeLibrary(hNewIconInst);
hNewIconInst = NULL;
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp
index 94b8c68473..4876f94887 100644
--- a/plugins/SecureIM/src/main.cpp
+++ b/plugins/SecureIM/src/main.cpp
@@ -156,12 +156,12 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
if ( DBGetContactSetting(0,MODULENAME,"rsa_priv",&dbv) == 0 ) {
exp->rsa_set_keypair(CPP_MODE_RSA_4096,dbv.pbVal,dbv.cpbVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
rsa_4096=1;
}
else if ( DBGetContactSetting(0,MODULENAME,"rsa_priv_4096",&dbv) == 0 ) {
exp->rsa_set_keypair(CPP_MODE_RSA_4096|CPP_MODE_RSA_BER,dbv.pbVal,dbv.cpbVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
char priv_key[4096]; int priv_len;
char pub_key[4096]; int pub_len;
@@ -192,7 +192,7 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
CloseHandle( (HANDLE) _beginthreadex(NULL, 0, sttGenerateRSA, NULL, 0, &tID));
}
- exp->rsa_set_timeout( DBGetContactSettingWord(0,MODULENAME,"ket",10));
+ exp->rsa_set_timeout( db_get_w(0,MODULENAME,"ket",10));
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("pgp_init");
@@ -216,12 +216,12 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
}
else {
LPSTR tmp;
- tmp = myDBGetString(0,MODULENAME,"pgpPubRing");
+ tmp = db_get_sa(0,MODULENAME,"pgpPubRing");
if (tmp) {
strncpy(PubRingPath,tmp,sizeof(PubRingPath));
mir_free(tmp);
}
- tmp = myDBGetString(0,MODULENAME,"pgpSecRing");
+ tmp = db_get_sa(0,MODULENAME,"pgpSecRing");
if (tmp) {
strncpy(SecRingPath,tmp,sizeof(SecRingPath));
mir_free(tmp);
@@ -229,8 +229,8 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
if (PubRingPath[0] && SecRingPath[0]) {
bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath);
if (bPGPkeyrings) {
- DBWriteContactSettingString(0,MODULENAME,"pgpPubRing",PubRingPath);
- DBWriteContactSettingString(0,MODULENAME,"pgpSecRing",SecRingPath);
+ db_set_s(0,MODULENAME,"pgpPubRing",PubRingPath);
+ db_set_s(0,MODULENAME,"pgpSecRing",SecRingPath);
}
else {
db_unset(0, MODULENAME, "pgpPubRing");
@@ -251,19 +251,19 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
char gpgexec[MAX_PATH], gpghome[MAX_PATH];
gpgexec[0]='\0'; gpghome[0]='\0';
- LPSTR tmp = myDBGetString(0,MODULENAME,"gpgExec");
+ LPSTR tmp = db_get_sa(0,MODULENAME,"gpgExec");
if (tmp) {
strncpy(gpgexec,tmp,sizeof(gpgexec));
mir_free(tmp);
}
- tmp = myDBGetString(0,MODULENAME,"gpgHome");
+ tmp = db_get_sa(0,MODULENAME,"gpgHome");
if (tmp) {
strncpy(gpghome,tmp,sizeof(gpghome));
mir_free(tmp);
}
if (db_get_b(0, MODULENAME, "gpgLogFlag",0)) {
- tmp = myDBGetString(0,MODULENAME,"gpgLog");
+ tmp = db_get_sa(0,MODULENAME,"gpgLog");
if (tmp) {
gpg_set_log(tmp);
mir_free(tmp);
@@ -271,7 +271,7 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
}
if (db_get_b(0, MODULENAME, "gpgTmpFlag",0)) {
- tmp = myDBGetString(0,MODULENAME,"gpgTmp");
+ tmp = db_get_sa(0,MODULENAME,"gpgTmp");
if (tmp) {
gpg_set_tmp(tmp);
mir_free(tmp);
@@ -280,8 +280,8 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
bGPGkeyrings = gpg_open_keyrings(gpgexec,gpghome);
if (bGPGkeyrings) {
- DBWriteContactSettingString(0,MODULENAME,"gpgExec",gpgexec);
- DBWriteContactSettingString(0,MODULENAME,"gpgHome",gpghome);
+ db_set_s(0,MODULENAME,"gpgExec",gpgexec);
+ db_set_s(0,MODULENAME,"gpgHome",gpghome);
}
else {
db_unset(0, MODULENAME, "gpgExec");
@@ -290,7 +290,7 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
bSavePass = db_get_b(0,MODULENAME,"gpgSaveFlag",0);
if (bSavePass) {
- tmp = myDBGetString(0,MODULENAME,"gpgSave");
+ tmp = db_get_sa(0,MODULENAME,"gpgSave");
if (tmp) {
gpg_set_passphrases(tmp);
mir_free(tmp);
@@ -311,7 +311,7 @@ int onModulesLoaded(WPARAM wParam, LPARAM lParam)
Sent_NetLog("init extra icons");
#endif
// init extra icons
- for(int i=0;i<1+MODE_CNT*IEC_CNT;i++)
+ for (int i=0;i<1+MODE_CNT*IEC_CNT;i++)
g_IEC[i] = (HANDLE)-1;
#if defined(_DEBUG) || defined(NETLIB_LOG)
@@ -440,7 +440,7 @@ int onSystemOKToExit(WPARAM wParam, LPARAM lParam)
{
if (bSavePass) {
LPSTR tmp = gpg_get_passphrases();
- DBWriteContactSettingString(0,MODULENAME,"gpgSave",tmp);
+ db_set_s(0,MODULENAME,"gpgSave",tmp);
LocalFree(tmp);
}
else db_unset(0,MODULENAME,"gpgSave");
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp
index 719fb2fc87..4789e9dfca 100644
--- a/plugins/SecureIM/src/options.cpp
+++ b/plugins/SecureIM/src/options.cpp
@@ -9,16 +9,15 @@ BOOL hasKey(pUinKey ptr)
{
BOOL ret = 0;
if ( ptr->mode==MODE_NATIVE ) {
- LPSTR str = myDBGetString(ptr->hContact,MODULENAME,"PSK");
+ LPSTR str = db_get_sa(ptr->hContact,MODULENAME,"PSK");
ret = (str!=NULL); SAFE_FREE(str);
}
- else
- if ( ptr->mode==MODE_RSAAES ) {
+ else if ( ptr->mode==MODE_RSAAES ) {
DBVARIANT dbv;
dbv.type = DBVT_BLOB;
if ( DBGetContactSetting(ptr->hContact,MODULENAME,"rsa_pub",&dbv) == 0 ) {
ret = 1;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
return ret;
@@ -86,12 +85,12 @@ void LV_GetItemTextA(HWND hwnd, WPARAM wparam, int iSubItem, LPSTR text, int cch
INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
-
static int iInit = TRUE;
TCITEM tci;
switch(msg) {
- case WM_INITDIALOG: {
+ case WM_INITDIALOG:
+ {
RECT rcClient;
GetClientRect(hwnd, &rcClient);
@@ -128,85 +127,77 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
// add more tabs here if needed
// activate the final tab
iInit = FALSE;
- return TRUE;
}
+ return TRUE;
+
+ case PSM_CHANGED: // used so tabs dont have to call SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0);
+ if (!iInit)
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
- case PSM_CHANGED: // used so tabs dont have to call SendMessage(GetParent(GetParent(hwnd)), PSM_CHANGED, 0, 0);
- if (!iInit)
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case ID_UPDATE_CLIST:
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),0,&tci);
+ SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0);
break;
- case WM_COMMAND: {
- switch(LOWORD(wParam)) {
- case ID_UPDATE_CLIST: {
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),0,&tci);
- SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0);
- }
- break;
- case ID_UPDATE_PLIST: {
- if ( !bPGP ) break;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),2,&tci);
- SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0);
- }
- break;
- case ID_UPDATE_GLIST: {
- if ( !bGPG ) break;
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),3,&tci);
- SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_GLIST,0);
- }
- break;
- }
+ case ID_UPDATE_PLIST:
+ if ( !bPGP ) break;
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),2,&tci);
+ SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_CLIST,0);
+ break;
+
+ case ID_UPDATE_GLIST:
+ if ( !bGPG ) break;
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),3,&tci);
+ SendMessage((HWND)tci.lParam,WM_COMMAND,ID_UPDATE_GLIST,0);
+ break;
}
break;
- case WM_NOTIFY: {
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0: {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY: {
- tci.mask = TCIF_PARAM;
- int cnt = TabCtrl_GetItemCount(GetDlgItem(hwnd,IDC_OPTIONSTAB));
- for (int i=0;i<cnt;i++) {
- TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),i,&tci);
- SendMessage((HWND)tci.lParam,WM_NOTIFY,0,lParam);
- }
- }
- break;
- }
- } // case 0
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ tci.mask = TCIF_PARAM;
+ int cnt = TabCtrl_GetItemCount(GetDlgItem(hwnd,IDC_OPTIONSTAB));
+ for (int i=0;i<cnt;i++) {
+ TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),i,&tci);
+ SendMessage((HWND)tci.lParam,WM_NOTIFY,0,lParam);
+ }
+ }
+ break;
+
+ case IDC_OPTIONSTAB:
+ switch (((LPNMHDR)lParam)->code) {
+ case TCN_SELCHANGING:
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci);
+ ShowWindow((HWND)tci.lParam,SW_HIDE);
break;
- case IDC_OPTIONSTAB: {
- switch (((LPNMHDR)lParam)->code) {
- case TCN_SELCHANGING: {
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci);
- ShowWindow((HWND)tci.lParam,SW_HIDE);
- }
- break;
- case TCN_SELCHANGE: {
- tci.mask = TCIF_PARAM;
- TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci);
- ShowWindow((HWND)tci.lParam,SW_SHOW);
- }
- break;
- }
- } // case IDC_OPTIONSTAB
+ case TCN_SELCHANGE:
+ tci.mask = TCIF_PARAM;
+ TabCtrl_GetItem(GetDlgItem(hwnd,IDC_OPTIONSTAB),TabCtrl_GetCurSel(GetDlgItem(hwnd,IDC_OPTIONSTAB)),&tci);
+ ShowWindow((HWND)tci.lParam,SW_SHOW);
break;
}
- } // case WM_NOTIFY
+ }
break;
}
+
return FALSE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
-
static int iInit = TRUE;
static HIMAGELIST hLarge, hSmall;
int i,idx; pUinKey ptr;
@@ -214,231 +205,211 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR
HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST);
switch (wMsg) {
- case WM_INITDIALOG: {
- TranslateDialogDefault(hDlg);
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("DlgProcOptionsGeneral(WN_INITDIALOG)");
-#endif
- iInit = TRUE;
- ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
- hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1);
- hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1);
- for (i = 0; i < ICO_CNT; i++) {
- ImageList_AddIcon(hSmall, g_hICO[i]);
- ImageList_AddIcon(hLarge, g_hICO[i]);
- }
+ iInit = TRUE;
+ ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
- ListView_SetImageList(hLV, hSmall, LVSIL_SMALL);
- ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL);
+ hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1);
+ hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1);
+ for (i=0; i < ICO_CNT; i++) {
+ ImageList_AddIcon(hSmall, g_hICO[i]);
+ ImageList_AddIcon(hLarge, g_hICO[i]);
+ }
+ ListView_SetImageList(hLV, hSmall, LVSIL_SMALL);
+ ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL);
+ {
static const char *szColHdr[] = { sim203, sim204, sim230, sim205, "", sim234, 0 };
static int iColWidth[] = { 150, 110, 60, 55, 35, 330 };
+
LVCOLUMN lvc;
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
lvc.fmt = LVCFMT_LEFT;
- for (i = 0; szColHdr[i]; i++) {
+ for (i=0; szColHdr[i]; i++) {
lvc.iSubItem = i;
lvc.pszText = (LPSTR)szColHdr[i];
lvc.cx = iColWidth[i];
LV_InsertColumn(hLV, i, &lvc);
}
+ }
- RefreshGeneralDlg(hDlg,TRUE);
- EnableWindow(hLV, true);
+ RefreshGeneralDlg(hDlg,TRUE);
+ EnableWindow(hLV, true);
- iInit = FALSE;
- return TRUE;
- } // WM_INITDIALOG
- break;
+ iInit = FALSE;
+ return TRUE;
- case WM_DESTROY: {
- ImageList_Destroy(hSmall);
- ImageList_Destroy(hLarge);
- } // WM_DESTROY
+ case WM_DESTROY:
+ ImageList_Destroy(hSmall);
+ ImageList_Destroy(hLarge);
break;
- case WM_PAINT: {
- if (!iInit)
- InvalidateRect(hDlg,NULL,FALSE);
- } // WM_PAINT
+ case WM_PAINT:
+ if (!iInit)
+ InvalidateRect(hDlg,NULL,FALSE);
break;
- case WM_COMMAND: {
- switch(LOWORD(wParam)) {
- case ID_ALWAYS:
- case ID_ENABLED:
- case ID_DISABLED: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- ptr->tstatus = LOWORD(wParam)-ID_DISABLED;
- setListViewStatus(hLV,idx,ptr->tstatus);
- setListViewIcon(hLV,idx,ptr);
- }
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case ID_ALWAYS:
+ case ID_ENABLED:
+ case ID_DISABLED:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ ptr->tstatus = LOWORD(wParam)-ID_DISABLED;
+ setListViewStatus(hLV,idx,ptr->tstatus);
+ setListViewIcon(hLV,idx,ptr);
}
break;
- case ID_SIM_NATIVE:
- case ID_SIM_PGP:
- case ID_SIM_GPG:
- case ID_SIM_RSAAES:
- case ID_SIM_RSA: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- ptr->tmode = LOWORD(wParam)-ID_SIM_NATIVE;
- setListViewMode(hLV,idx,ptr->tmode);
- setListViewIcon(hLV,idx,ptr);
- }
+ case ID_SIM_NATIVE:
+ case ID_SIM_PGP:
+ case ID_SIM_GPG:
+ case ID_SIM_RSAAES:
+ case ID_SIM_RSA:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ ptr->tmode = LOWORD(wParam)-ID_SIM_NATIVE;
+ setListViewMode(hLV,idx,ptr->tmode);
+ setListViewIcon(hLV,idx,ptr);
}
break;
- case ID_SETPSK: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- LPSTR buffer = (LPSTR)alloca(PSKSIZE+1);
- getContactName(ptr->hContact, buffer);
- int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PSK),NULL,DlgProcSetPSK,(LPARAM)buffer);
- if (res == IDOK) {
- setListViewPSK(hLV,idx,1);
- DBWriteContactSettingString(ptr->hContact,MODULENAME,"tPSK",buffer);
- }
+ case ID_SETPSK:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ LPSTR buffer = (LPSTR)alloca(PSKSIZE+1);
+ getContactName(ptr->hContact, buffer);
+ int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PSK),NULL,DlgProcSetPSK,(LPARAM)buffer);
+ if (res == IDOK) {
+ setListViewPSK(hLV,idx,1);
+ db_set_s(ptr->hContact,MODULENAME,"tPSK",buffer);
}
}
break;
- case ID_DELPSK: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- setListViewPSK(hLV,idx,0);
- db_unset(ptr->hContact, MODULENAME, "tPSK");
- }
+ case ID_DELPSK:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ setListViewPSK(hLV,idx,0);
+ db_unset(ptr->hContact, MODULENAME, "tPSK");
}
break;
- case ID_DELPUBL: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- setListViewPUB(hLV,idx,0);
- }
+ case ID_DELPUBL:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ setListViewPUB(hLV,idx,0);
}
break;
- case ID_EXPPUBL: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- if ( !ptr->keyLoaded ) {
- createRSAcntx(ptr);
- loadRSAkey(ptr);
- }
- if ( ptr->keyLoaded ) {
- LPSTR buffer = (LPSTR) alloca(RSASIZE);
- exp->rsa_export_pubkey(ptr->cntx,buffer);
- if ( !SaveExportRSAKeyDlg(hDlg,buffer,0))
- msgbox(hDlg,sim114,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
- }
+ case ID_EXPPUBL:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ if ( !ptr->keyLoaded ) {
+ createRSAcntx(ptr);
+ loadRSAkey(ptr);
+ }
+ if ( ptr->keyLoaded ) {
+ LPSTR buffer = (LPSTR) alloca(RSASIZE);
+ exp->rsa_export_pubkey(ptr->cntx,buffer);
+ if ( !SaveExportRSAKeyDlg(hDlg,buffer,0))
+ msgbox(hDlg,sim114,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
}
- return TRUE;
}
- break;
+ return TRUE;
- case ID_IMPPUBL: {
- idx = ListView_GetSelectionMark(hLV);
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if (ptr) {
- createRSAcntx(ptr);
- LPSTR pub = (LPSTR) alloca(RSASIZE);
- if ( !LoadImportRSAKeyDlg(hDlg,pub,0)) return TRUE;
- if ( exp->rsa_import_pubkey(ptr->cntx,pub)) {
- int len;
- exp->rsa_get_pubkey(ptr->cntx,(PBYTE)pub,&len);
-
- DBCONTACTWRITESETTING cws;
- cws.szModule = MODULENAME;
- cws.szSetting = "rsa_pub";
- cws.value.type = DBVT_BLOB;
- cws.value.pbVal = (PBYTE)pub;
- cws.value.cpbVal = len;
- CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws);
-
- setListViewPUB(hLV,idx,1);
- }
- else
- msgbox(hDlg,sim115,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
+ case ID_IMPPUBL:
+ idx = ListView_GetSelectionMark(hLV);
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if (ptr) {
+ createRSAcntx(ptr);
+ LPSTR pub = (LPSTR) alloca(RSASIZE);
+ if ( !LoadImportRSAKeyDlg(hDlg,pub,0)) return TRUE;
+ if ( exp->rsa_import_pubkey(ptr->cntx,pub)) {
+ int len;
+ exp->rsa_get_pubkey(ptr->cntx,(PBYTE)pub,&len);
+
+ DBCONTACTWRITESETTING cws;
+ cws.szModule = MODULENAME;
+ cws.szSetting = "rsa_pub";
+ cws.value.type = DBVT_BLOB;
+ cws.value.pbVal = (PBYTE)pub;
+ cws.value.cpbVal = len;
+ CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)ptr->hContact, (LPARAM)&cws);
+
+ setListViewPUB(hLV,idx,1);
}
- return TRUE;
+ else msgbox(hDlg,sim115,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
}
- break;
+ return TRUE;
- case ID_UPDATE_CLIST: {
-// iInit = TRUE;
-// RefreshGeneralDlg(hDlg,FALSE);
-// iInit = FALSE;
- return TRUE;
- }
- break;
+ case ID_UPDATE_CLIST:
+ // iInit = TRUE;
+ // RefreshGeneralDlg(hDlg,FALSE);
+ // iInit = FALSE;
+ return TRUE;
- case IDC_RESET: {
- if (!iInit)
- ResetGeneralDlg(hDlg);
- }
+ case IDC_RESET:
+ if (!iInit)
+ ResetGeneralDlg(hDlg);
break;
- case IDC_ADV8:
- case IDC_ADV7:
- case IDC_ADV6:
- case IDC_ADV5:
- case IDC_ADV4:
- case IDC_ADV3:
- case IDC_ADV2:
- case IDC_ADV1:
- case IDC_ADV0:
- case IDC_GPG:
- case IDC_PGP:
- case IDC_NO_PGP:
- case IDC_NOL:
- case IDC_AAK:
- case IDC_MCM:
- case IDC_AIP:
- case IDC_SOM:
- case IDC_SFT:
- case IDC_ASI:
- case IDC_MCD:
- case IDC_KET:
- case IDC_SCM:
- case IDC_DGP:
- case IDC_OKT:
- break;
+ case IDC_ADV8:
+ case IDC_ADV7:
+ case IDC_ADV6:
+ case IDC_ADV5:
+ case IDC_ADV4:
+ case IDC_ADV3:
+ case IDC_ADV2:
+ case IDC_ADV1:
+ case IDC_ADV0:
+ case IDC_GPG:
+ case IDC_PGP:
+ case IDC_NO_PGP:
+ case IDC_NOL:
+ case IDC_AAK:
+ case IDC_MCM:
+ case IDC_AIP:
+ case IDC_SOM:
+ case IDC_SFT:
+ case IDC_ASI:
+ case IDC_MCD:
+ case IDC_KET:
+ case IDC_SCM:
+ case IDC_DGP:
+ case IDC_OKT:
+ break;
- default:
- return FALSE;
- }
- if (!iInit)
+ default:
+ return FALSE;
+ }
+ if (!iInit)
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
- } // WM_COMMAND
break;
- case WM_NOTIFY: {
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0: {
- if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
- iInit = TRUE;
- ApplyGeneralSettings(hDlg);
- RefreshContactListIcons();
- iInit = FALSE;
- }
- }
- break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
+ iInit = TRUE;
+ ApplyGeneralSettings(hDlg);
+ RefreshContactListIcons();
+ iInit = FALSE;
+ }
+ break;
- case IDC_STD_USERLIST: {
- switch(((LPNMHDR)lParam)->code) {
- case NM_DBLCLK: {
+ case IDC_STD_USERLIST:
+ switch(((LPNMHDR)lParam)->code) {
+ case NM_DBLCLK:
if (LPNMLISTVIEW(lParam)->iSubItem == 2) {
idx = LPNMLISTVIEW(lParam)->iItem;
ptr = (pUinKey) getListViewParam(hLV,idx);
@@ -462,71 +433,68 @@ INT_PTR CALLBACK DlgProcOptionsGeneral(HWND hDlg, UINT wMsg, WPARAM wParam, LPAR
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
}
}
- } break;
- case NM_RCLICK: {
-// idx = ListView_GetSelectionMark(hLV);
- LPNMLISTVIEW lpLV = (LPNMLISTVIEW)lParam;
- ptr = (pUinKey) getListViewParam(hLV,lpLV->iItem);
- if (ptr) {
- POINT p; GetCursorPos(&p);
- HMENU hMenu = NULL;
- if ( ptr->tmode==MODE_NATIVE || ptr->tmode==MODE_RSAAES ) {
- switch( lpLV->iSubItem ) {
- case 2: // mode
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2));
- break;
- case 3: // status
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST01:IDM_CLIST11));
- break;
- case 4: // PSK/PUB
- case 5: // SHA1
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST02:IDM_CLIST12));
- break;
- default: // full menu
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST0:IDM_CLIST1));
- break;
- }
- CheckMenuItem(hMenu, ID_DISABLED+ptr->tstatus, MF_CHECKED );
- if ( ptr->tmode==MODE_NATIVE ) {
- if ( !hasKey(ptr)) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED );
- }
- else
- if ( ptr->tmode==MODE_RSAAES ) {
- if ( !hasKey(ptr)) {
- EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED );
- EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED );
- }
+ break;
+
+ case NM_RCLICK:
+ {
+ LPNMLISTVIEW lpLV = (LPNMLISTVIEW)lParam;
+ ptr = (pUinKey) getListViewParam(hLV,lpLV->iItem);
+ if (ptr) {
+ POINT p; GetCursorPos(&p);
+ HMENU hMenu = NULL;
+ if ( ptr->tmode==MODE_NATIVE || ptr->tmode==MODE_RSAAES ) {
+ switch( lpLV->iSubItem ) {
+ case 2: // mode
+ hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2));
+ break;
+ case 3: // status
+ hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST01:IDM_CLIST11));
+ break;
+ case 4: // PSK/PUB
+ case 5: // SHA1
+ hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST02:IDM_CLIST12));
+ break;
+ default: // full menu
+ hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE((ptr->tmode==MODE_NATIVE)?IDM_CLIST0:IDM_CLIST1));
+ break;
+ }
+ CheckMenuItem(hMenu, ID_DISABLED+ptr->tstatus, MF_CHECKED );
+ if ( ptr->tmode==MODE_NATIVE ) {
+ if ( !hasKey(ptr)) EnableMenuItem(hMenu, ID_DELPSK, MF_GRAYED );
+ }
+ else if ( ptr->tmode==MODE_RSAAES ) {
+ if ( !hasKey(ptr)) {
+ EnableMenuItem(hMenu, ID_EXPPUBL, MF_GRAYED );
+ EnableMenuItem(hMenu, ID_DELPUBL, MF_GRAYED );
+ }
+ }
}
+ if ( !hMenu )
+ hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2));
+ TranslateMenu(hMenu);
+ CheckMenuItem(hMenu, ID_SIM_NATIVE+ptr->tmode, MF_CHECKED );
+ if ( !bPGP ) EnableMenuItem(hMenu, ID_SIM_PGP, MF_GRAYED );
+ if ( !bGPG ) EnableMenuItem(hMenu, ID_SIM_GPG, MF_GRAYED );
+ TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0);
+ DestroyMenu(hMenu);
}
- if ( !hMenu )
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST2));
- TranslateMenu(hMenu);
- CheckMenuItem(hMenu, ID_SIM_NATIVE+ptr->tmode, MF_CHECKED );
- if ( !bPGP ) EnableMenuItem(hMenu, ID_SIM_PGP, MF_GRAYED );
- if ( !bGPG ) EnableMenuItem(hMenu, ID_SIM_GPG, MF_GRAYED );
-// CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND );
- TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0);
- DestroyMenu(hMenu);
- }
- } break;
- case LVN_COLUMNCLICK: {
- bChangeSortOrder = true;
- ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x01));
- bChangeSortOrder = false;
- }
}
+ break;
+
+ case LVN_COLUMNCLICK:
+ bChangeSortOrder = true;
+ ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x01));
+ bChangeSortOrder = false;
}
break;
- }
- } // WM_NOTIFY
+ }
break;
}
- return FALSE;
+ return FALSE;
}
-
-INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) {
-
+INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
+{
static int iInit = TRUE;
char buf[32];
int idx;
@@ -534,548 +502,462 @@ INT_PTR CALLBACK DlgProcOptionsProto(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM
HWND hLV = GetDlgItem(hDlg,IDC_PROTO);
switch (wMsg) {
- case WM_INITDIALOG: {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
- TranslateDialogDefault(hDlg);
+ iInit = TRUE;
+ ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("DlgProcOptionsProto(WN_INITDIALOG)");
-#endif
- iInit = TRUE;
- ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+ lvc.pszText = (LPSTR)sim210;
+ lvc.cx = 150;
+ LV_InsertColumn(hLV, 0, &lvc);
- LVCOLUMN lvc;
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
- lvc.pszText = (LPSTR)sim210;
- lvc.cx = 150;
- LV_InsertColumn(hLV, 0, &lvc);
+ RefreshProtoDlg(hDlg);
+ EnableWindow(hLV, true);
- RefreshProtoDlg(hDlg);
- EnableWindow(hLV, true);
+ iInit = FALSE;
+ return TRUE;
- iInit = FALSE;
- return TRUE;
- } // WM_INITDIALOG
+ case WM_PAINT:
+ if (!iInit)
+ InvalidateRect(hDlg,NULL,FALSE);
break;
- case WM_PAINT: {
- if (!iInit)
- InvalidateRect(hDlg,NULL,FALSE);
- } // WM_PAINT
- break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_RSA_COPY:
+ char txt[128];
+ GetDlgItemText(hDlg, IDC_RSA_SHA, txt, sizeof(txt));
+ CopyToClipboard(hDlg,txt);
+ return TRUE;
- case WM_COMMAND: {
- switch(LOWORD(wParam)) {
- case IDC_RSA_COPY: {
- char txt[128];
- GetDlgItemText(hDlg, IDC_RSA_SHA, txt, sizeof(txt));
- CopyToClipboard(hDlg,txt);
- return TRUE;
- } break;
- case IDC_RSA_EXP: {
- LPSTR pub = (LPSTR) alloca(RSASIZE);
- exp->rsa_export_keypair(CPP_MODE_RSA,NULL,pub,NULL);
+ case IDC_RSA_EXP:
+ {
+ LPSTR pub = (LPSTR) alloca(RSASIZE);
+ exp->rsa_export_keypair(CPP_MODE_RSA,NULL,pub,NULL);
if ( !SaveExportRSAKeyDlg(hDlg,pub,0))
msgbox(hDlg,sim114,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
- return TRUE;
- } break;
- case IDC_RSA_EXPPRIV: {
+ }
+ return TRUE;
+
+ case IDC_RSA_EXPPRIV:
+ {
LPSTR passphrase = (LPSTR) alloca(RSASIZE);
int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,DlgProcSetPassphrase,(LPARAM)passphrase);
if ( res==IDOK ) {
- LPSTR priv = (LPSTR) alloca(RSASIZE);
- exp->rsa_export_keypair(CPP_MODE_RSA,priv,NULL,passphrase);
+ LPSTR priv = (LPSTR) alloca(RSASIZE);
+ exp->rsa_export_keypair(CPP_MODE_RSA,priv,NULL,passphrase);
if ( !SaveExportRSAKeyDlg(hDlg,priv,1))
msgbox(hDlg,sim112,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
}
- return TRUE;
- } break;
- case IDC_RSA_IMPPRIV: {
- LPSTR priv = (LPSTR) alloca(RSASIZE);
- if ( !LoadImportRSAKeyDlg(hDlg,priv,1)) return TRUE;
- //
+ }
+ return TRUE;
+
+ case IDC_RSA_IMPPRIV:
+ {
+ LPSTR priv = (LPSTR) alloca(RSASIZE);
+ if ( !LoadImportRSAKeyDlg(hDlg,priv,1))
+ return TRUE;
+
LPSTR passphrase = (LPSTR) alloca(RSASIZE);
int res = DialogBoxParam(g_hInst,MAKEINTRESOURCE(IDD_PASSPHRASE),NULL,DlgProcSetPassphrase,(LPARAM)passphrase);
if ( res==IDOK ) {
- if ( !exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase)) {
+ if ( !exp->rsa_import_keypair(CPP_MODE_RSA,priv,passphrase))
msgbox(hDlg,sim113,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
- }
- else {
- // обновить SHA1 значение
+ else // обновить SHA1 значение
RefreshProtoDlg(hDlg);
- }
- }
- return TRUE;
- } break;
- case IDC_SPLITON:
- case IDC_SPLITOFF: {
- if ( HIWORD(wParam) == EN_CHANGE ) {
+ }
+ }
+ return TRUE;
+
+ case IDC_SPLITON:
+ case IDC_SPLITOFF:
+ if ( HIWORD(wParam) == EN_CHANGE ) {
idx = ListView_GetSelectionMark(hLV);
- if ( idx == -1 ) break;
- idx = (int) getListViewParam(hLV,idx);
+ if (idx == -1)
+ break;
+
+ idx = getListViewParam(hLV, idx);
switch(LOWORD(wParam)) {
case IDC_SPLITON:
GetDlgItemText(hDlg,IDC_SPLITON,buf,5);
- proto[idx].tsplit_on = atoi(buf);
- break;
+ arProto[idx]->tsplit_on = atoi(buf);
+ break;
case IDC_SPLITOFF:
GetDlgItemText(hDlg,IDC_SPLITOFF,buf,5);
- proto[idx].tsplit_off = atoi(buf);
- break;
+ arProto[idx]->tsplit_off = atoi(buf);
+ break;
}
- }
- if (!iInit)
+ }
+ if (!iInit)
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
- } break;
- }
+ break;
}
break;
- case WM_NOTIFY: {
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0: {
- if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
- iInit = TRUE;
- ApplyProtoSettings(hDlg);
- RefreshProtoDlg(hDlg);
- RefreshContactListIcons();
- SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0);
-// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_PLIST,0);
-// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_GLIST,0);
- iInit = FALSE;
- }
- }
- break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
+ iInit = TRUE;
+ ApplyProtoSettings(hDlg);
+ RefreshProtoDlg(hDlg);
+ RefreshContactListIcons();
+ SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0);
+ iInit = FALSE;
+ }
+ break;
- case IDC_PROTO: {
- if (((LPNMHDR)lParam)->code == (UINT)NM_CLICK) {
- idx = (int) getListViewParam(hLV,LPNMLISTVIEW(lParam)->iItem);
- if ( idx == -1 ) break;
- EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), true);
- EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), true);
- mir_itoa(proto[idx].tsplit_on,buf,10); SetDlgItemText(hDlg,IDC_SPLITON,buf);
- mir_itoa(proto[idx].tsplit_off,buf,10); SetDlgItemText(hDlg,IDC_SPLITOFF,buf);
- SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
- }
- }
- break;
- }
- } // WM_NOTIFY
+ case IDC_PROTO:
+ if (((LPNMHDR)lParam)->code == (UINT)NM_CLICK) {
+ idx = (int)getListViewParam(hLV,LPNMLISTVIEW(lParam)->iItem);
+ if (idx == -1)
+ break;
+
+ EnableWindow(GetDlgItem(hDlg,IDC_SPLITON), true);
+ EnableWindow(GetDlgItem(hDlg,IDC_SPLITOFF), true);
+ mir_itoa(arProto[idx]->tsplit_on,buf,10); SetDlgItemText(hDlg,IDC_SPLITON,buf);
+ mir_itoa(arProto[idx]->tsplit_off,buf,10); SetDlgItemText(hDlg,IDC_SPLITOFF,buf);
+ SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
+ }
+ }
break;
}
return FALSE;
}
-
static BOOL bPGP9;
-INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) {
-
- static int iInit = TRUE;
+INT_PTR CALLBACK DlgProcOptionsPGP(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
+{
+ static int iInit = TRUE;
static HIMAGELIST hLarge, hSmall;
int i;
- HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST);
+ HWND hLV = GetDlgItem(hDlg,IDC_PGP_USERLIST);
switch (wMsg) {
- case WM_INITDIALOG: {
-
- TranslateDialogDefault(hDlg);
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("DlgProcOptionsPGP(WN_INITDIALOG)");
-#endif
- iInit = TRUE;
- ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
-
- hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1);
- hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1);
- for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) {
- ImageList_AddIcon(hSmall, g_hICO[i]);
- ImageList_AddIcon(hLarge, g_hICO[i]);
- }
-
- ListView_SetImageList(hLV, hSmall, LVSIL_SMALL);
- ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL);
-
- static const char *szColHdr[] = { sim203, sim204, sim215, 0 };
- static int iColWidth[] = { 160, 150, 80 };
- LVCOLUMN lvc;
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
- for (i = 0; szColHdr[i]; i++) {
- lvc.iSubItem = i;
- lvc.pszText = (LPSTR)szColHdr[i];
- lvc.cx = iColWidth[i];
- LV_InsertColumn(hLV, i, &lvc);
- }
-
- RefreshPGPDlg(hDlg,TRUE);
-// EnableWindow(hLV, bPGPkeyrings);
-
- iInit = FALSE;
- return TRUE;
- } // WM_INITDIALOG
- break;
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
+
+ iInit = TRUE;
+ ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
- case WM_DESTROY: {
- ImageList_Destroy(hSmall);
- ImageList_Destroy(hLarge);
- } // WM_DESTROY
+ hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1);
+ hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1);
+ for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) {
+ ImageList_AddIcon(hSmall, g_hICO[i]);
+ ImageList_AddIcon(hLarge, g_hICO[i]);
+ }
+
+ ListView_SetImageList(hLV, hSmall, LVSIL_SMALL);
+ ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL);
+ {
+ static const char *szColHdr[] = { sim203, sim204, sim215, 0 };
+ static int iColWidth[] = { 160, 150, 80 };
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+ for (i = 0; szColHdr[i]; i++) {
+ lvc.iSubItem = i;
+ lvc.pszText = (LPSTR)szColHdr[i];
+ lvc.cx = iColWidth[i];
+ LV_InsertColumn(hLV, i, &lvc);
+ }
+ }
+ RefreshPGPDlg(hDlg,TRUE);
+ iInit = FALSE;
+ return TRUE;
+
+ case WM_DESTROY:
+ ImageList_Destroy(hSmall);
+ ImageList_Destroy(hLarge);
break;
- case WM_PAINT: {
- if (!iInit)
- InvalidateRect(hDlg,NULL,FALSE);
- } // WM_PAINT
+ case WM_PAINT:
+ if (!iInit)
+ InvalidateRect(hDlg,NULL,FALSE);
break;
- case WM_COMMAND: {
- switch(LOWORD(wParam)) {
- case IDC_SET_KEYRINGS: {
- char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH];
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_SET_KEYRINGS:
+ {
+ char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH];
PubRingPath[0]='\0'; SecRingPath[0]='\0';
bPGPkeyrings = pgp_open_keyrings(PubRingPath,SecRingPath);
if (bPGPkeyrings && PubRingPath[0] && SecRingPath[0]) {
- DBWriteContactSettingString(0,MODULENAME,"pgpPubRing",PubRingPath);
- DBWriteContactSettingString(0,MODULENAME,"pgpSecRing",SecRingPath);
+ db_set_s(0,MODULENAME,"pgpPubRing",PubRingPath);
+ db_set_s(0,MODULENAME,"pgpSecRing",SecRingPath);
}
SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bPGPkeyrings?Translate(sim216):Translate(sim217));
-// EnableWindow(hLV, bPGPkeyrings);
-// RefreshPGPDlg(hDlg);
- return FALSE;
- }
- break;
- case IDC_NO_KEYRINGS: {
- BOOL bNoKR = (SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED);
+ }
+ return FALSE;
+
+ case IDC_NO_KEYRINGS:
+ {
+ BOOL bNoKR = (SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED);
EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), !bNoKR);
EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), bNoKR);
SetDlgItemText(hDlg, IDC_KEYRING_STATUS, bNoKR?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217))));
- }
- break;
- case IDC_LOAD_PRIVKEY: {
+ }
+ break;
+
+ case IDC_LOAD_PRIVKEY:
+ {
char KeyPath[MAX_PATH]; KeyPath[0]='\0';
- if (ShowSelectKeyDlg(hDlg,KeyPath)) {
- char *priv = LoadKeys(KeyPath,true);
- if (priv) {
- DBWriteContactSettingString(0,MODULENAME,"tpgpPrivKey",priv);
- mir_free(priv);
- }
- else {
- db_unset(0,MODULENAME,"tpgpPrivKey");
- }
- }
- }
- break;
- case ID_UPDATE_PLIST: {
+ if (ShowSelectKeyDlg(hDlg,KeyPath)) {
+ char *priv = LoadKeys(KeyPath,true);
+ if (priv) {
+ db_set_s(0,MODULENAME,"tpgpPrivKey",priv);
+ mir_free(priv);
+ }
+ else {
+ db_unset(0,MODULENAME,"tpgpPrivKey");
+ }
+ }
+ }
+ break;
+
+ case ID_UPDATE_PLIST:
+ iInit = TRUE;
+ RefreshPGPDlg(hDlg,FALSE);
+ iInit = FALSE;
+ return TRUE;
+ }
+ if (!iInit)
+ SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
iInit = TRUE;
+ ApplyPGPSettings(hDlg);
RefreshPGPDlg(hDlg,FALSE);
iInit = FALSE;
- return TRUE;
}
break;
- default:
- break;
- }
- if (!iInit)
- SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
- }
- break;
- case WM_NOTIFY: {
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0: {
- if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
- iInit = TRUE;
- ApplyPGPSettings(hDlg);
- RefreshPGPDlg(hDlg,FALSE);
-// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0);
- iInit = FALSE;
- }
- }
+ case IDC_PGP_USERLIST:
+ switch(((LPNMHDR)lParam)->code) {
+ case LVN_COLUMNCLICK:
+ bChangeSortOrder = true;
+ ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x11));
+ bChangeSortOrder = false;
break;
- case IDC_PGP_USERLIST: {
- switch(((LPNMHDR)lParam)->code) {
-/* case NM_RCLICK: {
- POINT p;
- GetCursorPos(&p);
- HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST));
- CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND );
- TranslateMenu(hMenu);
- TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0);
- DestroyMenu(hMenu);
- } break;*/
- case LVN_COLUMNCLICK: {
- bChangeSortOrder = true;
- ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x11));
- bChangeSortOrder = false;
- }
- }
- }
- break;
- }
- } // WM_NOTIFY
+ }
+ }
break;
}
return FALSE;
}
-
-INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) {
-
- static int iInit = TRUE;
+INT_PTR CALLBACK DlgProcOptionsGPG(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
+{
+ static int iInit = TRUE;
static HIMAGELIST hLarge, hSmall;
int i, idx; pUinKey ptr;
- HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST);
+ HWND hLV = GetDlgItem(hDlg,IDC_GPG_USERLIST);
switch (wMsg) {
- case WM_INITDIALOG: {
-
- TranslateDialogDefault(hDlg);
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("DlgProcOptionsGPG(WN_INITDIALOG)");
-#endif
- iInit = TRUE;
- ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
-
- hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1);
- hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1);
- for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) {
- ImageList_AddIcon(hSmall, g_hICO[i]);
- ImageList_AddIcon(hLarge, g_hICO[i]);
- }
-
- ListView_SetImageList(hLV, hSmall, LVSIL_SMALL);
- ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL);
-
- static const char *szColHdr[] = { sim203, sim204, sim215, sim227, 0 };
- static int iColWidth[] = { 140, 120, 120, 40 };
- LVCOLUMN lvc;
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
- for (i = 0; szColHdr[i]; i++) {
- lvc.iSubItem = i;
- lvc.pszText = (LPSTR)szColHdr[i];
- lvc.cx = iColWidth[i];
- LV_InsertColumn(hLV, i, &lvc);
- }
-
- RefreshGPGDlg(hDlg,TRUE);
-// EnableWindow(hLV, bPGPkeyrings);
-
- iInit = FALSE;
- return TRUE;
- } // WM_INITDIALOG
- break;
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
+
+ iInit = TRUE;
+ ListView_SetExtendedListViewStyle(hLV, ListView_GetExtendedListViewStyle(hLV) | LVS_EX_FULLROWSELECT);
+
+ hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), iBmpDepth, 1, 1);
+ hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), iBmpDepth, 1, 1);
+ for (i = ICO_ST_DIS; i <= ICO_ST_TRY; i++) {
+ ImageList_AddIcon(hSmall, g_hICO[i]);
+ ImageList_AddIcon(hLarge, g_hICO[i]);
+ }
+
+ ListView_SetImageList(hLV, hSmall, LVSIL_SMALL);
+ ListView_SetImageList(hLV, hLarge, LVSIL_NORMAL);
+ {
+ static const char *szColHdr[] = { sim203, sim204, sim215, sim227, 0 };
+ static int iColWidth[] = { 140, 120, 120, 40 };
+ LVCOLUMN lvc;
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+ for (i = 0; szColHdr[i]; i++) {
+ lvc.iSubItem = i;
+ lvc.pszText = (LPSTR)szColHdr[i];
+ lvc.cx = iColWidth[i];
+ LV_InsertColumn(hLV, i, &lvc);
+ }
+ }
- case WM_DESTROY: {
- ImageList_Destroy(hSmall);
- ImageList_Destroy(hLarge);
- } // WM_DESTROY
+ RefreshGPGDlg(hDlg,TRUE);
+ iInit = FALSE;
+ return TRUE;
+
+ case WM_DESTROY:
+ ImageList_Destroy(hSmall);
+ ImageList_Destroy(hLarge);
break;
- case WM_PAINT: {
- if (!iInit)
- InvalidateRect(hDlg,NULL,FALSE);
- } // WM_PAINT
+ case WM_PAINT:
+ if (!iInit)
+ InvalidateRect(hDlg,NULL,FALSE);
break;
- case WM_COMMAND: {
- switch(LOWORD(wParam)) {
-/* case IDC_LOAD_PRIVKEY: {
- char KeyPath[MAX_PATH] = {0};
- if (ShowSelectKeyDlg(hDlg,KeyPath)) {
- char *priv = LoadKeys(KeyPath,true);
- if (priv) {
- DBWriteContactSettingString(0,MODULENAME,"tpgpPrivKey",priv);
- mir_free(priv);
- }
- else {
- db_unset(0,MODULENAME,"tpgpPrivKey");
- }
- }
- }
- break;*/
- case IDC_BROWSEEXECUTABLE_BTN: {
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_BROWSEEXECUTABLE_BTN:
+ {
char gpgexe[256];
char filter[128];
- OPENFILENAME ofn = {0};
+ GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, sizeof(gpgexe));
- GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, gpgexe, sizeof(gpgexe));
-
- // filter zusammensetzen
+ // filter zusammensetzen
mir_snprintf(filter, SIZEOF(filter), _T("%s (*.exe)%c*.exe%c%c"), Translate("Executable Files"), 0, 0, 0);
- // OPENFILENAME initialisieren
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hDlg;
- ofn.lpstrFilter = filter;
- ofn.lpstrFile = gpgexe;
- ofn.nMaxFile = sizeof(gpgexe);
- ofn.lpstrTitle = Translate("Select GnuPG Executable");
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
-
- if (GetOpenFileName(&ofn))
- {
- SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, ofn.lpstrFile);
- }
- }
- break;
- case ID_UPDATE_GLIST: {
+ // OPENFILENAME initialisieren
+ OPENFILENAME ofn = { sizeof(ofn) };
+ ofn.hwndOwner = hDlg;
+ ofn.lpstrFilter = filter;
+ ofn.lpstrFile = gpgexe;
+ ofn.nMaxFile = sizeof(gpgexe);
+ ofn.lpstrTitle = Translate("Select GnuPG Executable");
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_HIDEREADONLY;
+
+ if (GetOpenFileName(&ofn))
+ SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, ofn.lpstrFile);
+ }
+ break;
+
+ case ID_UPDATE_GLIST:
+ iInit = TRUE;
+ RefreshGPGDlg(hDlg,FALSE);
+ iInit = FALSE;
+ return TRUE;
+ }
+ if (!iInit)
+ SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
iInit = TRUE;
+ ApplyGPGSettings(hDlg);
RefreshGPGDlg(hDlg,FALSE);
iInit = FALSE;
- return TRUE;
}
break;
- default:
- break;
- }
- if (!iInit)
- SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
- }
- break;
- case WM_NOTIFY: {
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0: {
- if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) {
- iInit = TRUE;
- ApplyGPGSettings(hDlg);
- RefreshGPGDlg(hDlg,FALSE);
-// SendMessage(GetParent(hDlg),WM_COMMAND,ID_UPDATE_CLIST,0);
- iInit = FALSE;
- }
- }
- break;
- case IDC_GPG_USERLIST: {
- switch(((LPNMHDR)lParam)->code) {
- case NM_DBLCLK: {
- if (LPNMLISTVIEW(lParam)->iSubItem == 3) {
- idx = LPNMLISTVIEW(lParam)->iItem;
- ptr = (pUinKey) getListViewParam(hLV,idx);
- if ( !ptr ) break;
- ptr->tgpgMode++; ptr->tgpgMode&=1;
- LV_SetItemTextA(hLV, LPNMLISTVIEW(lParam)->iItem, LPNMLISTVIEW(lParam)->iSubItem, (ptr->tgpgMode)?Translate(sim228):Translate(sim229));
- SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
- }
- } break;
-/* case NM_RCLICK: {
- POINT p;
- GetCursorPos(&p);
- HMENU hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDM_CLIST));
- CheckMenuItem(hMenu, ID_ENCRYPTION, MF_BYCOMMAND );
- TranslateMenu(hMenu);
- TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_LEFTALIGN | TPM_TOPALIGN, p.x, p.y, 0, hDlg, 0);
- DestroyMenu(hMenu);
- } break;*/
- case LVN_COLUMNCLICK: {
- bChangeSortOrder = true;
- ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x21));
- bChangeSortOrder = false;
- }
- }
+ case IDC_GPG_USERLIST:
+ switch(((LPNMHDR)lParam)->code) {
+ case NM_DBLCLK:
+ if (LPNMLISTVIEW(lParam)->iSubItem == 3) {
+ idx = LPNMLISTVIEW(lParam)->iItem;
+ ptr = (pUinKey) getListViewParam(hLV,idx);
+ if ( !ptr ) break;
+ ptr->tgpgMode++; ptr->tgpgMode&=1;
+ LV_SetItemTextA(hLV, LPNMLISTVIEW(lParam)->iItem, LPNMLISTVIEW(lParam)->iSubItem, (ptr->tgpgMode)?Translate(sim228):Translate(sim229));
+ SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
}
break;
- }
- } // WM_NOTIFY
+
+ case LVN_COLUMNCLICK:
+ bChangeSortOrder = true;
+ ListView_Sort(hLV,(LPARAM)(LPNMLISTVIEW(lParam)->iSubItem+0x21));
+ bChangeSortOrder = false;
+ }
+ }
break;
}
return FALSE;
}
-
-INT_PTR CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
- static char *buffer;
+INT_PTR CALLBACK DlgProcSetPSK(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+{
+ static char *buffer;
switch(uMsg) {
- case WM_INITDIALOG: {
+ case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
SendDlgItemMessage(hDlg, IDC_EDIT1, EM_LIMITTEXT, PSKSIZE-1, 0);
SetDlgItemTextW(hDlg, IDC_EDIT2, (LPWSTR)lParam);
buffer = (LPSTR)lParam;
- return (TRUE);
- }
- case WM_COMMAND: {
+ return TRUE;
+
+ case WM_COMMAND:
switch(LOWORD(wParam)) {
- case IDOK: {
- int len = GetDlgItemTextA(hDlg,IDC_EDIT1,buffer,PSKSIZE);
- if (len<8) {
- msgbox1(hDlg,sim211,MODULENAME,MB_OK|MB_ICONEXCLAMATION);
+ case IDOK:
+ if ( GetDlgItemTextA(hDlg, IDC_EDIT1, buffer, PSKSIZE) < 8) {
+ msgbox1(hDlg, sim211, MODULENAME, MB_OK | MB_ICONEXCLAMATION);
return TRUE;
}
- else {
- EndDialog(hDlg,IDOK);
- }
- }
- break;
- case IDCANCEL: {
+ EndDialog(hDlg,IDOK);
+ break;
+
+ case IDCANCEL:
EndDialog(hDlg,IDCANCEL);
+ break;
}
break;
- }
- }
- break;
+
default:
- return (FALSE);
+ return FALSE;
}
- return (TRUE);
+ return TRUE;
}
-INT_PTR CALLBACK DlgProcSetPassphrase(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) {
+INT_PTR CALLBACK DlgProcSetPassphrase(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
+{
static LPSTR buffer;
+
switch(uMsg) {
- case WM_INITDIALOG: {
+ case WM_INITDIALOG:
TranslateDialogDefault(hDlg);
SendDlgItemMessage(hDlg,IDC_PASSPHRASE,EM_LIMITTEXT,RSASIZE-1,0);
buffer = (LPSTR)lParam;
- return (TRUE);
- }
- case WM_COMMAND: {
+ return TRUE;
+
+ case WM_COMMAND:
switch(LOWORD(wParam)) {
- case IDOK: {
-// memset(buffer,0,RSASIZE);
+ case IDOK:
GetDlgItemTextA(hDlg,IDC_PASSPHRASE,buffer,RSASIZE);
EndDialog(hDlg,IDOK);
- }
- break;
- case IDCANCEL: {
+ break;
+
+ case IDCANCEL:
EndDialog(hDlg,IDCANCEL);
+ break;
}
break;
- }
- }
- break;
+
default:
- return (FALSE);
+ return FALSE;
}
- return (TRUE);
+ return TRUE;
}
-
///////////////////
// R E F R E S H //
///////////////////
-
-void RefreshGeneralDlg(HWND hDlg, BOOL iInit) {
-
+void RefreshGeneralDlg(HWND hDlg, BOOL iInit)
+{
char timeout[10];
- UINT data;
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("RefreshGeneralDlg");
-#endif
// Key Exchange Timeout
- data = DBGetContactSettingWord(0, MODULENAME, "ket", 10);
+ UINT data = db_get_w(0, MODULENAME, "ket", 10);
mir_itoa(data,timeout,10);
SetDlgItemText(hDlg,IDC_KET,timeout);
// Offline Key Timeout
- data = DBGetContactSettingWord(0, MODULENAME, "okt", 2);
+ data = db_get_w(0, MODULENAME, "okt", 2);
mir_itoa(data,timeout,10);
SetDlgItemText(hDlg,IDC_OKT,timeout);
@@ -1109,7 +991,6 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) {
while (hContact) {
pUinKey ptr = getUinKey(hContact);
if ( ptr && isSecureProtocol(hContact) && !isChatRoom(hContact)) {
-
if ( iInit ) {
ptr->tmode = ptr->mode;
ptr->tstatus = ptr->status;
@@ -1137,29 +1018,20 @@ void RefreshGeneralDlg(HWND hDlg, BOOL iInit) {
ListView_Sort(hLV,0);
}
-
-void RefreshProtoDlg(HWND hDlg) {
-
- int i;
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("RefreshProtoDlg");
-#endif
+void RefreshProtoDlg(HWND hDlg)
+{
HWND hLV = GetDlgItem(hDlg,IDC_PROTO);
ListView_DeleteAllItems(hLV);
- LVITEM lvi; memset(&lvi,0,sizeof(lvi));
+ LVITEM lvi = { 0 };
lvi.mask = LVIF_TEXT | LVIF_PARAM;
- for(i=0;i<proto_cnt;i++) {
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("LV_InsertItemA(%d,%s);",i,proto[i].name);
-#endif
+ for (int i=0; i < arProto.getCount(); i++) {
lvi.iItem = i+1;
- lvi.pszText = proto[i].name;
+ lvi.pszText = arProto[i]->name;
lvi.lParam = (LPARAM)i;
int itemNum = LV_InsertItemA(hLV, &lvi);
- ListView_SetCheckState(hLV,itemNum,proto[i].inspecting);
+ ListView_SetCheckState(hLV,itemNum, arProto[i]->inspecting);
}
SetDlgItemText(hDlg,IDC_SPLITON,_T("0"));
@@ -1173,15 +1045,11 @@ void RefreshProtoDlg(HWND hDlg) {
mir_free(txt);
}
-
-void RefreshPGPDlg(HWND hDlg, BOOL iInit) {
-
+void RefreshPGPDlg(HWND hDlg, BOOL iInit)
+{
int ver = pgp_get_version();
bPGP9 = (ver>=0x03050000);
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("RefreshPGPDlg");
-#endif
EnableWindow(GetDlgItem(hDlg, IDC_SET_KEYRINGS), bUseKeyrings && !bPGP9);
EnableWindow(GetDlgItem(hDlg, IDC_LOAD_PRIVKEY), !bUseKeyrings);
SetDlgItemText(hDlg, IDC_PGP_PRIVKEY, bPGPprivkey?Translate(sim222):Translate(sim223));
@@ -1191,9 +1059,8 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) {
sprintf(pgpVerStr, Translate(sim218), ver >> 24, (ver >> 16) & 255, (ver >> 8) & 255);
SetDlgItemText(hDlg, IDC_PGP_SDK, pgpVerStr);
}
- else {
- SetDlgItemText(hDlg, IDC_PGP_SDK, Translate(sim219));
- }
+ else SetDlgItemText(hDlg, IDC_PGP_SDK, Translate(sim219));
+
SetDlgItemText(hDlg, IDC_KEYRING_STATUS, !bUseKeyrings?Translate(sim225):((bPGP9)?Translate(sim220):(bPGPkeyrings?Translate(sim216):Translate(sim217))));
// Disable keyrings use
@@ -1210,11 +1077,9 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) {
char tmp[NAMSIZE];
while (hContact) {
-
pUinKey ptr = getUinKey(hContact);
if (ptr && ptr->mode==MODE_PGP && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) {
-
- LPSTR szKeyID = myDBGetString(hContact,MODULENAME,"pgp_abbr");
+ LPSTR szKeyID = db_get_sa(hContact,MODULENAME,"pgp_abbr");
lvi.iItem++;
lvi.iImage = (szKeyID!=0);
@@ -1235,27 +1100,21 @@ void RefreshPGPDlg(HWND hDlg, BOOL iInit) {
ListView_Sort(hLV,(LPARAM)0x10);
}
-
-void RefreshGPGDlg(HWND hDlg, BOOL iInit) {
-
- LPSTR path;
-
-#if defined(_DEBUG) || defined(NETLIB_LOG)
- Sent_NetLog("RefreshGPGDlg");
-#endif
- path = myDBGetString(0,MODULENAME,"gpgExec");
+void RefreshGPGDlg(HWND hDlg, BOOL iInit)
+{
+ LPSTR path = db_get_sa(0,MODULENAME,"gpgExec");
if (path) {
SetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, path);
mir_free(path);
}
- path = myDBGetString(0,MODULENAME,"gpgHome");
+ path = db_get_sa(0,MODULENAME,"gpgHome");
if (path) {
SetDlgItemText(hDlg, IDC_GPGHOME_EDIT, path);
mir_free(path);
}
BOOL bGPGLogFlag = db_get_b(0, MODULENAME, "gpgLogFlag",0);
SendMessage(GetDlgItem(hDlg,IDC_LOGGINGON_CBOX),BM_SETCHECK,(bGPGLogFlag)?BST_CHECKED:BST_UNCHECKED,0L);
- path = myDBGetString(0,MODULENAME,"gpgLog");
+ path = db_get_sa(0,MODULENAME,"gpgLog");
if (path) {
SetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, path);
mir_free(path);
@@ -1263,7 +1122,7 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) {
SendMessage(GetDlgItem(hDlg,IDC_SAVEPASS_CBOX),BM_SETCHECK,(bSavePass)?BST_CHECKED:BST_UNCHECKED,0L);
BOOL bGPGTmpFlag = db_get_b(0, MODULENAME, "gpgTmpFlag",0);
SendMessage(GetDlgItem(hDlg,IDC_TMPPATHON_CBOX),BM_SETCHECK,(bGPGTmpFlag)?BST_CHECKED:BST_UNCHECKED,0L);
- path = myDBGetString(0,MODULENAME,"gpgTmp");
+ path = db_get_sa(0,MODULENAME,"gpgTmp");
if (path) {
SetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, path);
mir_free(path);
@@ -1280,15 +1139,12 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) {
char tmp[NAMSIZE];
while (hContact) {
-
pUinKey ptr = getUinKey(hContact);
if (ptr && ptr->mode==MODE_GPG && isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) {
-
- if ( iInit ) {
+ if ( iInit )
ptr->tgpgMode = ptr->gpgMode;
- }
- LPSTR szKeyID = myDBGetString(hContact,MODULENAME,"gpg");
+ LPSTR szKeyID = db_get_sa(hContact,MODULENAME,"gpg");
lvi.iItem++;
lvi.iImage = (szKeyID!=0);
@@ -1310,14 +1166,12 @@ void RefreshGPGDlg(HWND hDlg, BOOL iInit) {
ListView_Sort(hLV,(LPARAM)0x20);
}
-
///////////////
// R E S E T //
///////////////
-
-void ResetGeneralDlg(HWND hDlg) {
-
+void ResetGeneralDlg(HWND hDlg)
+{
SetDlgItemText(hDlg,IDC_KET,_T("10"));
SetDlgItemText(hDlg,IDC_OKT,_T("2"));
@@ -1337,52 +1191,42 @@ void ResetGeneralDlg(HWND hDlg) {
LVITEM lvi; memset(&lvi,0,sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
- HANDLE hContact = db_find_first();
char tmp[NAMSIZE];
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (!isSecureProtocol(hContact) || isChatRoom(hContact))
+ continue;
- while (hContact) {
-
- if (isSecureProtocol(hContact) /*&& !getMetaContact(hContact)*/ && !isChatRoom(hContact)) {
-
- pUinKey ptr = getUinKey(hContact);
- if (!ptr) continue;
+ pUinKey ptr = getUinKey(hContact);
+ if (!ptr) continue;
- ptr->tmode=MODE_NATIVE;
- ptr->tstatus=STATUS_ENABLED;
+ ptr->tmode=MODE_NATIVE;
+ ptr->tstatus=STATUS_ENABLED;
- lvi.iItem++;
- lvi.iImage = ptr->tstatus;
- lvi.lParam = (LPARAM)ptr;
+ lvi.iItem++;
+ lvi.iImage = ptr->tstatus;
+ lvi.lParam = (LPARAM)ptr;
- getContactName(hContact, tmp);
- lvi.pszText = (LPSTR)&tmp;
- int itemNum = LV_InsertItem(hLV, &lvi);
+ getContactName(hContact, tmp);
+ lvi.pszText = (LPSTR)&tmp;
+ int itemNum = LV_InsertItem(hLV, &lvi);
- getContactUin(hContact, tmp);
- LV_SetItemText(hLV, itemNum, 1, tmp);
+ getContactUin(hContact, tmp);
+ LV_SetItemText(hLV, itemNum, 1, tmp);
- setListViewMode(hLV, itemNum, ptr->tmode);
- setListViewStatus(hLV, itemNum, ptr->tstatus);
- if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, 0);
- else setListViewPUB(hLV, itemNum, 0);
- setListViewIcon(hLV, itemNum, ptr);
- }
- hContact = db_find_next(hContact);
+ setListViewMode(hLV, itemNum, ptr->tmode);
+ setListViewStatus(hLV, itemNum, ptr->tstatus);
+ if ( ptr->mode==MODE_NATIVE ) setListViewPSK(hLV, itemNum, 0);
+ else setListViewPUB(hLV, itemNum, 0);
+ setListViewIcon(hLV, itemNum, ptr);
}
}
-
-void ResetProtoDlg(HWND hDlg) {
-}
-
-
///////////////
// A P P L Y //
///////////////
-
-void ApplyGeneralSettings(HWND hDlg) {
-
+void ApplyGeneralSettings(HWND hDlg)
+{
char timeout[5];
int tmp,i;
@@ -1390,7 +1234,7 @@ void ApplyGeneralSettings(HWND hDlg) {
GetDlgItemText(hDlg,IDC_KET,timeout,5);
tmp = atoi(timeout); if (tmp > 65535) tmp = 65535;
DBWriteContactSettingWord(0,MODULENAME,"ket",tmp);
- exp->rsa_set_timeout( DBGetContactSettingWord(0,MODULENAME,"ket",10));
+ exp->rsa_set_timeout( db_get_w(0,MODULENAME,"ket",10));
mir_itoa(tmp,timeout,10);
SetDlgItemText(hDlg,IDC_KET,timeout);
@@ -1416,18 +1260,18 @@ void ApplyGeneralSettings(HWND hDlg) {
// PGP &| GPG flags
{
- tmp = 0;
- i = SendMessage(GetDlgItem(hDlg, IDC_PGP),BM_GETCHECK,0L,0L)==BST_CHECKED;
- if (i!=bPGP) {
- bPGP = i; tmp++;
- db_set_b(0, MODULENAME, "pgp", bPGP);
- }
- i = SendMessage(GetDlgItem(hDlg, IDC_GPG),BM_GETCHECK,0L,0L)==BST_CHECKED;
- if (i!=bGPG) {
- bGPG = i; tmp++;
- db_set_b(0, MODULENAME, "gpg", bGPG);
- }
- if (tmp) msgbox1(hDlg, sim224, MODULENAME, MB_OK|MB_ICONINFORMATION);
+ tmp = 0;
+ i = SendMessage(GetDlgItem(hDlg, IDC_PGP),BM_GETCHECK,0L,0L)==BST_CHECKED;
+ if (i!=bPGP) {
+ bPGP = i; tmp++;
+ db_set_b(0, MODULENAME, "pgp", bPGP);
+ }
+ i = SendMessage(GetDlgItem(hDlg, IDC_GPG),BM_GETCHECK,0L,0L)==BST_CHECKED;
+ if (i!=bGPG) {
+ bGPG = i; tmp++;
+ db_set_b(0, MODULENAME, "gpg", bGPG);
+ }
+ if (tmp) msgbox1(hDlg, sim224, MODULENAME, MB_OK|MB_ICONINFORMATION);
}
HWND hLV = GetDlgItem(hDlg,IDC_STD_USERLIST);
@@ -1446,71 +1290,65 @@ void ApplyGeneralSettings(HWND hDlg) {
}
if ( ptr->mode==MODE_NATIVE ) {
if ( getListViewPSK(hLV,i)) {
- LPSTR tmp = myDBGetString(ptr->hContact,MODULENAME,"tPSK");
- DBWriteContactSettingString(ptr->hContact, MODULENAME, "PSK", tmp);
- mir_free(tmp);
- }
- else {
- db_unset(ptr->hContact, MODULENAME, "PSK");
+ LPSTR tmp = db_get_sa(ptr->hContact,MODULENAME,"tPSK");
+ db_set_s(ptr->hContact, MODULENAME, "PSK", tmp);
+ mir_free(tmp);
}
+ else db_unset(ptr->hContact, MODULENAME, "PSK");
+
db_unset(ptr->hContact, MODULENAME, "tPSK");
}
- else
- if ( ptr->mode==MODE_RSAAES ) {
- if ( !getListViewPUB(hLV,i)) {
- db_unset(ptr->hContact, MODULENAME, "rsa_pub");
- }
+ else if ( ptr->mode==MODE_RSAAES ) {
+ if ( !getListViewPUB(hLV,i))
+ db_unset(ptr->hContact, MODULENAME, "rsa_pub");
}
i = ListView_GetNextItem(hLV,i,LVNI_ALL);
}
}
-
-void ApplyProtoSettings(HWND hDlg) {
-
+void ApplyProtoSettings(HWND hDlg)
+{
LPSTR szNames = (LPSTR) alloca(2048); *szNames = '\0';
HWND hLV = GetDlgItem(hDlg,IDC_PROTO);
int i = ListView_GetNextItem(hLV,(UINT)-1,LVNI_ALL);
- while(i!=-1) {
- int j = getListViewProto(hLV,i);
- proto[j].inspecting = ListView_GetCheckState(hLV,i);
+ while(i != -1) {
+ pSupPro p = arProto[ getListViewProto(hLV,i) ];
+ p->inspecting = ListView_GetCheckState(hLV,i);
char tmp[128];
- sprintf(tmp,"%s:%d:%d:%d;",proto[j].name,proto[j].inspecting,proto[j].tsplit_on,proto[j].tsplit_off);
+ sprintf(tmp, "%s:%d:%d:%d;", p->name, p->inspecting, p->tsplit_on, p->tsplit_off);
strcat(szNames,tmp);
- proto[j].split_on = proto[j].tsplit_on;
- proto[j].split_off = proto[j].tsplit_off;
+ p->split_on = p->tsplit_on;
+ p->split_off = p->tsplit_off;
i = ListView_GetNextItem(hLV,i,LVNI_ALL);
}
- DBWriteContactSettingString(0,MODULENAME,"protos",szNames);
+ db_set_s(0,MODULENAME,"protos",szNames);
}
-
-void ApplyPGPSettings(HWND hDlg) {
-
+void ApplyPGPSettings(HWND hDlg)
+{
bUseKeyrings = !(SendMessage(GetDlgItem(hDlg, IDC_NO_KEYRINGS),BM_GETCHECK,0L,0L)==BST_CHECKED);
db_set_b(0,MODULENAME,"ukr",bUseKeyrings);
- char *priv = myDBGetString(0,MODULENAME,"tpgpPrivKey");
+ char *priv = db_get_sa(0,MODULENAME,"tpgpPrivKey");
if (priv) {
- bPGPprivkey = true;
- pgp_set_priv_key(priv);
+ bPGPprivkey = true;
+ pgp_set_priv_key(priv);
myDBWriteStringEncode(0,MODULENAME,"pgpPrivKey",priv);
mir_free(priv);
- db_unset(0,MODULENAME,"tpgpPrivKey");
+ db_unset(0,MODULENAME,"tpgpPrivKey");
}
}
-
-void ApplyGPGSettings(HWND hDlg) {
-
+void ApplyGPGSettings(HWND hDlg)
+{
char tmp[256];
GetDlgItemText(hDlg, IDC_GPGEXECUTABLE_EDIT, tmp, sizeof(tmp));
- DBWriteContactSettingString(0,MODULENAME,"gpgExec",tmp);
+ db_set_s(0,MODULENAME,"gpgExec",tmp);
GetDlgItemText(hDlg, IDC_GPGHOME_EDIT, tmp, sizeof(tmp));
- DBWriteContactSettingString(0,MODULENAME,"gpgHome",tmp);
+ db_set_s(0,MODULENAME,"gpgHome",tmp);
bSavePass = (SendMessage(GetDlgItem(hDlg, IDC_SAVEPASS_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED);
db_set_b(0,MODULENAME,"gpgSaveFlag",bSavePass);
@@ -1518,14 +1356,14 @@ void ApplyGPGSettings(HWND hDlg) {
BOOL bgpgLogFlag = (SendMessage(GetDlgItem(hDlg, IDC_LOGGINGON_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED);
db_set_b(0,MODULENAME,"gpgLogFlag",bgpgLogFlag);
GetDlgItemText(hDlg, IDC_GPGLOGFILE_EDIT, tmp, sizeof(tmp));
- DBWriteContactSettingString(0,MODULENAME,"gpgLog",tmp);
+ db_set_s(0,MODULENAME,"gpgLog",tmp);
if (bgpgLogFlag) gpg_set_log(tmp);
else gpg_set_log(0);
BOOL bgpgTmpFlag = (SendMessage(GetDlgItem(hDlg, IDC_TMPPATHON_CBOX),BM_GETCHECK,0L,0L)==BST_CHECKED);
db_set_b(0,MODULENAME,"gpgTmpFlag",bgpgTmpFlag);
GetDlgItemText(hDlg, IDC_GPGTMPPATH_EDIT, tmp, sizeof(tmp));
- DBWriteContactSettingString(0,MODULENAME,"gpgTmp",tmp);
+ db_set_s(0,MODULENAME,"gpgTmp",tmp);
if (bgpgTmpFlag) gpg_set_tmp(tmp);
else gpg_set_tmp(0);
@@ -1544,14 +1382,12 @@ void ApplyGPGSettings(HWND hDlg) {
}
}
-
///////////////
// O T H E R //
///////////////
-
-LPARAM getListViewParam(HWND hLV, UINT iItem) {
-
+LPARAM getListViewParam(HWND hLV, UINT iItem)
+{
LVITEM lvi; memset(&lvi,0,sizeof(lvi));
lvi.iItem = iItem;
lvi.mask = LVIF_PARAM;
@@ -1559,9 +1395,8 @@ LPARAM getListViewParam(HWND hLV, UINT iItem) {
return lvi.lParam;
}
-
-void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr) {
-
+void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr)
+{
LVITEM lvi; memset(&lvi,0,sizeof(lvi));
lvi.iItem = iItem;
switch(ptr->tmode) {
@@ -1580,49 +1415,43 @@ void setListViewIcon(HWND hLV, UINT iItem, pUinKey ptr) {
ListView_SetItem(hLV, &lvi);
}
-
-void setListViewMode(HWND hLV, UINT iItem, UINT iMode) {
-
+void setListViewMode(HWND hLV, UINT iItem, UINT iMode)
+{
char tmp[256];
strncpy(tmp, Translate(sim231[iMode]), sizeof(tmp));
LV_SetItemTextA(hLV, iItem, 2, tmp);
}
-
-void setListViewStatus(HWND hLV, UINT iItem, UINT iStatus) {
-
+void setListViewStatus(HWND hLV, UINT iItem, UINT iStatus)
+{
char tmp[128];
strncpy(tmp, Translate(sim232[iStatus]), sizeof(tmp));
LV_SetItemTextA(hLV, iItem, 3, tmp);
}
-
-UINT getListViewPSK(HWND hLV, UINT iItem) {
-
+UINT getListViewPSK(HWND hLV, UINT iItem)
+{
char str[128];
LV_GetItemTextA(hLV, iItem, 4, str, sizeof(str));
return strncmp(str, Translate(sim206), sizeof(str))==0;
}
-
-void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus) {
-
+void setListViewPSK(HWND hLV, UINT iItem, UINT iStatus)
+{
char str[128];
strncpy(str, (iStatus)?Translate(sim206):"-", sizeof(str));
LV_SetItemTextA(hLV, iItem, 4, str);
}
-
-UINT getListViewPUB(HWND hLV, UINT iItem) {
-
+UINT getListViewPUB(HWND hLV, UINT iItem)
+{
char str[128];
LV_GetItemTextA(hLV, iItem, 4, str, sizeof(str));
return strncmp(str, Translate(sim233), sizeof(str))==0;
}
-
-void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) {
-
+void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus)
+{
char str[128];
strncpy(str, (iStatus)?Translate(sim233):"-", sizeof(str));
LV_SetItemTextA(hLV, iItem, 4, str);
@@ -1636,7 +1465,7 @@ void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) {
int len;
exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)str,&len);
sha = mir_strdup(to_hex((PBYTE)str,len));
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
if ( sha ) {
@@ -1646,90 +1475,90 @@ void setListViewPUB(HWND hLV, UINT iItem, UINT iStatus) {
else LV_SetItemTextA(hLV, iItem, 5, "");
}
-
-int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) {
- char t1[NAMSIZE], t2[NAMSIZE];
- int s,d,m=1;
- DBVARIANT dbv1,dbv2;
-
- if (lParamSort&0x100) {
- lParamSort&=0xFF;
- m=-1;
+int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
+{
+ pUinKey p1 = pUinKey(lParam1), p2 = pUinKey(lParam2);
+ char t1[NAMSIZE], t2[NAMSIZE];
+ int s,d,m=1;
+ DBVARIANT dbv1 = { 0 }, dbv2 = { 0 };
+
+ if (lParamSort & 0x100) {
+ lParamSort &= 0xFF;
+ m = -1;
}
switch(lParamSort){
case 0x01:
case 0x11:
- case 0x21: {
- getContactNameA(pUinKey(lParam1)->hContact, t1);
- getContactNameA(pUinKey(lParam2)->hContact, t2);
+ case 0x21:
+ getContactNameA(p1->hContact, t1);
+ getContactNameA(p2->hContact, t2);
return strncmp(t1,t2,NAMSIZE)*m;
- } break;
+
case 0x02:
case 0x12:
- case 0x22: {
- getContactUinA(pUinKey(lParam1)->hContact, t1);
- getContactUinA(pUinKey(lParam2)->hContact, t2);
+ case 0x22:
+ getContactUinA(p1->hContact, t1);
+ getContactUinA(p2->hContact, t2);
return strncmp(t1,t2,NAMSIZE)*m;
- } break;
- case 0x03: {
- s = pUinKey(lParam1)->tmode;
- d = pUinKey(lParam2)->tmode;
+
+ case 0x03:
+ s = p1->tmode;
+ d = p2->tmode;
return (s-d)*m;
- } break;
- case 0x13: {
- DBGetContactSetting(pUinKey(lParam1)->hContact,MODULENAME,"pgp_abbr",&dbv1);
- DBGetContactSetting(pUinKey(lParam2)->hContact,MODULENAME,"pgp_abbr",&dbv2);
+
+ case 0x13:
+ db_get_s(p1->hContact,MODULENAME,"pgp_abbr",&dbv1);
+ db_get_s(p2->hContact,MODULENAME,"pgp_abbr",&dbv2);
s=(dbv1.type==DBVT_ASCIIZ);
d=(dbv2.type==DBVT_ASCIIZ);
if (s && d) {
s=strcmp(dbv1.pszVal,dbv2.pszVal);
d=0;
}
- DBFreeVariant(&dbv1);
- DBFreeVariant(&dbv2);
+ db_free(&dbv1);
+ db_free(&dbv2);
return (s-d)*m;
- } break;
- case 0x23: {
- DBGetContactSetting(pUinKey(lParam1)->hContact,MODULENAME,"gpg",&dbv1);
- DBGetContactSetting(pUinKey(lParam2)->hContact,MODULENAME,"gpg",&dbv2);
- s=(dbv1.type==DBVT_ASCIIZ);
- d=(dbv2.type==DBVT_ASCIIZ);
+
+ case 0x23:
+ db_get_s(p1->hContact,MODULENAME,"gpg",&dbv1);
+ db_get_s(p2->hContact,MODULENAME,"gpg",&dbv2);
+ s = (dbv1.type == DBVT_ASCIIZ);
+ d = (dbv2.type == DBVT_ASCIIZ);
if (s && d) {
- s=strcmp(dbv1.pszVal,dbv2.pszVal);
- d=0;
+ s = strcmp(dbv1.pszVal,dbv2.pszVal);
+ d = 0;
}
- DBFreeVariant(&dbv1);
- DBFreeVariant(&dbv2);
+ db_free(&dbv1);
+ db_free(&dbv2);
return (s-d)*m;
- } break;
- case 0x04: {
- s = pUinKey(lParam1)->tstatus;
- d = pUinKey(lParam2)->tstatus;
+
+ case 0x04:
+ s = p1->tstatus;
+ d = p2->tstatus;
return (s-d)*m;
- } break;
- case 0x05: {
- DBGetContactSetting(pUinKey(lParam1)->hContact,MODULENAME,"PSK",&dbv1);
+
+ case 0x05:
+ db_get_s(p1->hContact,MODULENAME,"PSK",&dbv1);
s=(dbv1.type==DBVT_ASCIIZ);
- DBFreeVariant(&dbv1);
- DBGetContactSetting(pUinKey(lParam2)->hContact,MODULENAME,"PSK",&dbv2);
+ db_free(&dbv1);
+ db_get_s(p2->hContact,MODULENAME,"PSK",&dbv2);
d=(dbv2.type==DBVT_ASCIIZ);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
return (s-d)*m;
- } break;
}
return 0;
}
-
-void ListView_Sort(HWND hLV, LPARAM lParamSort) {
- char t[32];
+void ListView_Sort(HWND hLV, LPARAM lParamSort)
+{
+ char t[32];
// restore sort column
sprintf(t,"os%02x",(UINT)lParamSort&0xF0);
- if ((lParamSort&0x0F)==0) {
+ if ((lParamSort&0x0F)==0)
lParamSort=(int)db_get_b(0, MODULENAME, t, lParamSort+1);
- }
+
db_set_b(0, MODULENAME, t, (BYTE)lParamSort);
// restore sort order
@@ -1740,11 +1569,9 @@ void ListView_Sort(HWND hLV, LPARAM lParamSort) {
ListView_SortItems(hLV,&CompareFunc,lParamSort|(m<<8));
}
-
BOOL ShowSelectKeyDlg(HWND hParent, LPSTR KeyPath)
{
- OPENFILENAME ofn = {0};
- ofn.lStructSize = sizeof(ofn);
+ OPENFILENAME ofn = { sizeof(ofn) };
ofn.hwndOwner = hParent;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_NONETWORKBUTTON;
@@ -1765,7 +1592,8 @@ LPCSTR priv_end = "-----END PGP PRIVATE KEY BLOCK-----";
LPCSTR publ_beg = "-----BEGIN PGP PUBLIC KEY BLOCK-----";
LPCSTR publ_end = "-----END PGP PUBLIC KEY BLOCK-----";
-LPSTR LoadKeys(LPCSTR file,BOOL priv) {
+LPSTR LoadKeys(LPCSTR file,BOOL priv)
+{
FILE *f=fopen(file,"r");
if (!f) return NULL;
@@ -1786,25 +1614,16 @@ LPSTR LoadKeys(LPCSTR file,BOOL priv) {
LPSTR keys = (LPSTR)mir_alloc(flen+1);
int i=0; BOOL b=false;
while(fgets(keys+i,128,f)) {
- if (!b && strncmp(keys+i,beg,strlen(beg))==0) {
+ if (!b && strncmp(keys+i,beg,strlen(beg))==0)
b=true;
- }
- else
- if (b && strncmp(keys+i,end,strlen(end))==0) {
+ else if (b && strncmp(keys+i,end,strlen(end))==0) {
i+=(int)strlen(keys+i);
b=false;
}
- if (b) {
+ if (b)
i+=(int)strlen(keys+i);
- }
}
*(keys+i)='\0';
-/* while(flen) {
- int block = (flen>32768)?32768:flen;
- fread(keys+i,block,1,f);
- i+=block;
- flen-=block;
- }*/
fclose(f);
return keys;
}
@@ -1815,8 +1634,7 @@ BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv)
if (priv)
_tcscpy(szFile, _T("rsa_priv.asc"));
- OPENFILENAME ofn = {0};
- ofn.lStructSize = sizeof(ofn);
+ OPENFILENAME ofn = { sizeof(ofn) };
char temp[MAX_PATH];
mir_snprintf(temp, SIZEOF(temp), _T("%s (*.asc)%c*.asc%c%s (*.*)%c*.*%c%c"), Translate("ASC files"), 0, 0, Translate("All files"), 0, 0, 0);
ofn.lpstrFilter = temp;
@@ -1838,7 +1656,6 @@ BOOL SaveExportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv)
return TRUE;
}
-
BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv)
{
TCHAR szFile[MAX_PATH] = _T("rsa_pub.asc");
@@ -1872,14 +1689,12 @@ BOOL LoadImportRSAKeyDlg(HWND hParent, LPSTR key, BOOL priv)
fread(key, flen, 1, f);
fclose(f);
-
return TRUE;
}
int onRegisterOptions(WPARAM wParam, LPARAM)
{
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = g_hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONSTAB);
odp.pszTitle = (char*)MODULENAME;
diff --git a/plugins/SecureIM/src/options.h b/plugins/SecureIM/src/options.h
index 4af841d598..b1f2b65b0e 100644
--- a/plugins/SecureIM/src/options.h
+++ b/plugins/SecureIM/src/options.h
@@ -17,7 +17,6 @@ void RefreshProtoDlg(HWND);
void RefreshPGPDlg(HWND,BOOL);
void RefreshGPGDlg(HWND,BOOL);
void ResetGeneralDlg(HWND);
-void ResetProtoDlg(HWND);
LPARAM getListViewParam(HWND,UINT);
void setListViewIcon(HWND,UINT,pUinKey);
void setListViewMode(HWND,UINT,UINT);
diff --git a/plugins/SecureIM/src/popupOptions.cpp b/plugins/SecureIM/src/popupOptions.cpp
index 9095c3c482..9f135b62fb 100644
--- a/plugins/SecureIM/src/popupOptions.cpp
+++ b/plugins/SecureIM/src/popupOptions.cpp
@@ -1,233 +1,168 @@
#include "commonheaders.h"
+INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
+{
+ char getTimeout[5];
-INT_PTR CALLBACK PopOptionsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam) {
-
- char getTimeout[5];
-
- HWND hec = GetDlgItem(hDlg, IDC_EC);
- HWND hdc = GetDlgItem(hDlg, IDC_DC);
- HWND hks = GetDlgItem(hDlg, IDC_KS);
- HWND hkr = GetDlgItem(hDlg, IDC_KR);
- HWND hss = GetDlgItem(hDlg, IDC_SS);
- HWND hsr = GetDlgItem(hDlg, IDC_SR);
+ HWND hec = GetDlgItem(hDlg, IDC_EC);
+ HWND hdc = GetDlgItem(hDlg, IDC_DC);
+ HWND hks = GetDlgItem(hDlg, IDC_KS);
+ HWND hkr = GetDlgItem(hDlg, IDC_KR);
+ HWND hss = GetDlgItem(hDlg, IDC_SS);
+ HWND hsr = GetDlgItem(hDlg, IDC_SR);
switch (wMsg) {
- case WM_COMMAND: {
-
- if (HIWORD(wParam) == CPN_COLOURCHANGED) {
- //It's a colour picker change. LOWORD(wParam) is the control id.
- DWORD color = SendDlgItemMessage(hDlg,LOWORD(wParam),CPM_GETCOLOUR,0,0);
-
- switch(LOWORD(wParam)) {
- case IDC_BACKKEY:
- DBWriteContactSettingDword(0, MODULENAME, "colorKeyb", color);
- break;
- case IDC_TEXTKEY:
- DBWriteContactSettingDword(0, MODULENAME, "colorKeyt", color);
- break;
- case IDC_BACKSEC:
- DBWriteContactSettingDword(0, MODULENAME, "colorSecb", color);
- break;
- case IDC_TEXTSEC:
- DBWriteContactSettingDword(0, MODULENAME, "colorSect", color);
- break;
- case IDC_BACKSR:
- DBWriteContactSettingDword(0, MODULENAME, "colorSRb", color);
- break;
- case IDC_TEXTSR:
- DBWriteContactSettingDword(0, MODULENAME, "colorSRt", color);
- break;
- }
- return TRUE;
- }
-
- switch (LOWORD(wParam)) {
- case IDC_PREV: {
- //preview popups...
- showPopUp(LPGEN("Key Popup"),NULL,g_hPOP[POP_PU_PRC],0);
- showPopUp(LPGEN("Secure Popup"),NULL,g_hPOP[POP_PU_EST],1);
- showPopUp(LPGEN("Message Popup"),NULL,g_hPOP[POP_PU_MSR],2);
- }
- break;
- case IDC_EC: {
- //set ec checkbox value
- db_set_b(0, MODULENAME, "ec", (BYTE)(SendMessage(hec,BM_GETCHECK,0L,0L)==BST_CHECKED));
- }
- break;
- case IDC_DC: {
- //set dc checkbox value
- db_set_b(0, MODULENAME, "dc", (BYTE)(SendMessage(hdc,BM_GETCHECK,0L,0L)==BST_CHECKED));
- }
- break;
- case IDC_SS: {
- //set ss checkbox value
- db_set_b(0, MODULENAME, "ss", (BYTE)(SendMessage(hss,BM_GETCHECK,0L,0L)==BST_CHECKED));
- }
- break;
- case IDC_SR: {
- //set sr checkbox value
- db_set_b(0, MODULENAME, "sr", (BYTE)(SendMessage(hsr,BM_GETCHECK,0L,0L)==BST_CHECKED));
- }
- break;
- case IDC_KS: {
- //set indicator checkbox value
- db_set_b(0, MODULENAME, "ks", (BYTE)(SendMessage(hks,BM_GETCHECK,0L,0L)==BST_CHECKED));
- }
- break;
- case IDC_KR: {
- //set indicator checkbox value
- db_set_b(0, MODULENAME, "kr", (BYTE)(SendMessage(hkr,BM_GETCHECK,0L,0L)==BST_CHECKED));
- }
- break;
- case IDC_TIMEKEY: {
- //set timeout value
- GetDlgItemText(hDlg,IDC_TIMEKEY,getTimeout,sizeof(getTimeout));
- mir_itoa(atoi(getTimeout),getTimeout,10);
- DBWriteContactSettingString(0, MODULENAME, "timeoutKey", getTimeout);
- }
- break;
- case IDC_TIMESEC: {
- //set timeout value
- GetDlgItemText(hDlg,IDC_TIMESEC,getTimeout,sizeof(getTimeout));
- mir_itoa(atoi(getTimeout),getTimeout,10);
- DBWriteContactSettingString(0, MODULENAME, "timeoutSec", getTimeout);
- }
- break;
- case IDC_TIMESR: {
- //set timeout value
- GetDlgItemText(hDlg,IDC_TIMESR,getTimeout,sizeof(getTimeout));
- mir_itoa(atoi(getTimeout),getTimeout,10);
- DBWriteContactSettingString(0, MODULENAME, "timeoutSR", getTimeout);
- }
- break;
- } //switch
-
- RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr);
- break;
- }
-
- case WM_DESTROY:
- break;
-
- case WM_INITDIALOG: {
- TranslateDialogDefault(hDlg);
- RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr);
-
- DBVARIANT dbv;
- char *timeout;
-
- //set timeout value for Key
- if (DBGetContactSetting(0, MODULENAME, "timeoutKey", &dbv) == 0) timeout=dbv.pszVal;
- else timeout="0";
- SetDlgItemText(hDlg, IDC_TIMEKEY, timeout);
- DBFreeVariant(&dbv);
-
- //set timeout value for SEC
- if (DBGetContactSetting(0, MODULENAME, "timeoutSec", &dbv) == 0) timeout=dbv.pszVal;
- else timeout="0";
- SetDlgItemText(hDlg, IDC_TIMESEC, timeout);
- DBFreeVariant(&dbv);
-
- //set timeout value for SR
- if (DBGetContactSetting(0, MODULENAME, "timeoutSR", &dbv) == 0) timeout=dbv.pszVal;
- else timeout="0";
- SetDlgItemText(hDlg, IDC_TIMESR, timeout);
- DBFreeVariant(&dbv);
-
- //key color
- SendDlgItemMessage(hDlg,IDC_BACKKEY,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, MODULENAME, "colorKeyb", RGB(230,230,255)));
- SendDlgItemMessage(hDlg,IDC_TEXTKEY,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, MODULENAME, "colorKeyt", RGB(0,0,0)));
-
- //Session color
- SendDlgItemMessage(hDlg,IDC_BACKSEC,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, MODULENAME, "colorSecb", RGB(255,255,200)));
- SendDlgItemMessage(hDlg,IDC_TEXTSEC,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, MODULENAME, "colorSect", RGB(0,0,0)));
-
- //SR color
- SendDlgItemMessage(hDlg,IDC_BACKSR,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, MODULENAME, "colorSRb", RGB(200,255,200)));
- SendDlgItemMessage(hDlg,IDC_TEXTSR,CPM_SETCOLOUR,0,DBGetContactSettingDword(0, MODULENAME, "colorSRt", RGB(0,0,0)));
-
- break;
- }
-
- case WM_NOTIFY: {
- break;
- }
- default:
- return FALSE;
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hDlg);
+ RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr);
+
+ DBVARIANT dbv;
+ char *timeout;
+
+ //set timeout value for Key
+ if (DBGetContactSetting(0, MODULENAME, "timeoutKey", &dbv) == 0) timeout=dbv.pszVal;
+ else timeout="0";
+ SetDlgItemText(hDlg, IDC_TIMEKEY, timeout);
+ db_free(&dbv);
+
+ //set timeout value for SEC
+ if (DBGetContactSetting(0, MODULENAME, "timeoutSec", &dbv) == 0) timeout=dbv.pszVal;
+ else timeout="0";
+ SetDlgItemText(hDlg, IDC_TIMESEC, timeout);
+ db_free(&dbv);
+
+ //set timeout value for SR
+ if (DBGetContactSetting(0, MODULENAME, "timeoutSR", &dbv) == 0) timeout=dbv.pszVal;
+ else timeout="0";
+ SetDlgItemText(hDlg, IDC_TIMESR, timeout);
+ db_free(&dbv);
+
+ //key color
+ SendDlgItemMessage(hDlg,IDC_BACKKEY,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorKeyb", RGB(230,230,255)));
+ SendDlgItemMessage(hDlg,IDC_TEXTKEY,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorKeyt", RGB(0,0,0)));
+
+ //Session color
+ SendDlgItemMessage(hDlg,IDC_BACKSEC,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSecb", RGB(255,255,200)));
+ SendDlgItemMessage(hDlg,IDC_TEXTSEC,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSect", RGB(0,0,0)));
+
+ //SR color
+ SendDlgItemMessage(hDlg,IDC_BACKSR,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSRb", RGB(200,255,200)));
+ SendDlgItemMessage(hDlg,IDC_TEXTSR,CPM_SETCOLOUR,0,db_get_dw(0, MODULENAME, "colorSRt", RGB(0,0,0)));
+ break;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == CPN_COLOURCHANGED) {
+ //It's a colour picker change. LOWORD(wParam) is the control id.
+ DWORD color = SendDlgItemMessage(hDlg,LOWORD(wParam),CPM_GETCOLOUR,0,0);
+
+ switch(LOWORD(wParam)) {
+ case IDC_BACKKEY:
+ DBWriteContactSettingDword(0, MODULENAME, "colorKeyb", color);
+ break;
+ case IDC_TEXTKEY:
+ DBWriteContactSettingDword(0, MODULENAME, "colorKeyt", color);
+ break;
+ case IDC_BACKSEC:
+ DBWriteContactSettingDword(0, MODULENAME, "colorSecb", color);
+ break;
+ case IDC_TEXTSEC:
+ DBWriteContactSettingDword(0, MODULENAME, "colorSect", color);
+ break;
+ case IDC_BACKSR:
+ DBWriteContactSettingDword(0, MODULENAME, "colorSRb", color);
+ break;
+ case IDC_TEXTSR:
+ DBWriteContactSettingDword(0, MODULENAME, "colorSRt", color);
+ break;
+ }
+ return TRUE;
+ }
+
+ switch (LOWORD(wParam)) {
+ case IDC_PREV:
+ //preview popups...
+ showPopUp(LPGEN("Key Popup"),NULL,g_hPOP[POP_PU_PRC],0);
+ showPopUp(LPGEN("Secure Popup"),NULL,g_hPOP[POP_PU_EST],1);
+ showPopUp(LPGEN("Message Popup"),NULL,g_hPOP[POP_PU_MSR],2);
+ break;
+ case IDC_EC:
+ //set ec checkbox value
+ db_set_b(0, MODULENAME, "ec", (BYTE)(SendMessage(hec,BM_GETCHECK,0L,0L)==BST_CHECKED));
+ break;
+ case IDC_DC:
+ //set dc checkbox value
+ db_set_b(0, MODULENAME, "dc", (BYTE)(SendMessage(hdc,BM_GETCHECK,0L,0L)==BST_CHECKED));
+ break;
+ case IDC_SS:
+ //set ss checkbox value
+ db_set_b(0, MODULENAME, "ss", (BYTE)(SendMessage(hss,BM_GETCHECK,0L,0L)==BST_CHECKED));
+ break;
+ case IDC_SR:
+ //set sr checkbox value
+ db_set_b(0, MODULENAME, "sr", (BYTE)(SendMessage(hsr,BM_GETCHECK,0L,0L)==BST_CHECKED));
+ break;
+ case IDC_KS:
+ //set indicator checkbox value
+ db_set_b(0, MODULENAME, "ks", (BYTE)(SendMessage(hks,BM_GETCHECK,0L,0L)==BST_CHECKED));
+ break;
+ case IDC_KR:
+ //set indicator checkbox value
+ db_set_b(0, MODULENAME, "kr", (BYTE)(SendMessage(hkr,BM_GETCHECK,0L,0L)==BST_CHECKED));
+ break;
+ case IDC_TIMEKEY:
+ //set timeout value
+ GetDlgItemText(hDlg,IDC_TIMEKEY,getTimeout,sizeof(getTimeout));
+ mir_itoa(atoi(getTimeout),getTimeout,10);
+ db_set_s(0, MODULENAME, "timeoutKey", getTimeout);
+ break;
+ case IDC_TIMESEC:
+ //set timeout value
+ GetDlgItemText(hDlg,IDC_TIMESEC,getTimeout,sizeof(getTimeout));
+ mir_itoa(atoi(getTimeout),getTimeout,10);
+ db_set_s(0, MODULENAME, "timeoutSec", getTimeout);
+ break;
+ case IDC_TIMESR:
+ //set timeout value
+ GetDlgItemText(hDlg,IDC_TIMESR,getTimeout,sizeof(getTimeout));
+ mir_itoa(atoi(getTimeout),getTimeout,10);
+ db_set_s(0, MODULENAME, "timeoutSR", getTimeout);
+ break;
+ }
+
+ RefreshPopupOptionsDlg(hec,hdc,hss,hsr,hks,hkr);
+ break;
+
+ default:
+ return FALSE;
}
return TRUE;
}
-
-void RefreshPopupOptionsDlg(HWND hec,HWND hdc,HWND hss,HWND hsr,HWND hks,HWND hkr) {
-
- DBVARIANT dbv;
- int indic;
-
+void RefreshPopupOptionsDlg(HWND hec,HWND hdc,HWND hss,HWND hsr,HWND hks,HWND hkr)
+{
// ec checkbox
- if (DBGetContactSetting(0, MODULENAME, "ec", &dbv) == 0)
- {indic=dbv.bVal;
- }
- else indic=1;
-
- if (indic==1)SendMessage(hec,BM_SETCHECK,BST_CHECKED,0L);
- else SendMessage(hec,BM_SETCHECK,BST_UNCHECKED,0L);
+ SendMessage(hec, BM_SETCHECK, db_get_b(0, MODULENAME, "ec", 1), 0L);
// dc checkbox
- if (DBGetContactSetting(0, MODULENAME, "dc", &dbv) == 0)
- {indic=dbv.bVal;
- }
- else indic=1;
-
- if (indic==1)SendMessage(hdc,BM_SETCHECK,BST_CHECKED,0L);
- else SendMessage(hdc,BM_SETCHECK,BST_UNCHECKED,0L);
+ SendMessage(hdc, BM_SETCHECK, db_get_b(0, MODULENAME, "dc", 1), 0L);
// ks checkbox
- if (DBGetContactSetting(0, MODULENAME, "ks", &dbv) == 0)
- {indic=dbv.bVal;
- }
- else indic=1;
-
- if (indic==1)SendMessage(hks,BM_SETCHECK,BST_CHECKED,0L);
- else SendMessage(hks,BM_SETCHECK,BST_UNCHECKED,0L);
+ SendMessage(hks, BM_SETCHECK, db_get_b(0, MODULENAME, "ks", 1), 0L);
// kr checkbox
- if (DBGetContactSetting(0, MODULENAME, "kr", &dbv) == 0)
- {indic=dbv.bVal;
- }
- else indic=1;
-
- if (indic==1)SendMessage(hkr,BM_SETCHECK,BST_CHECKED,0L);
- else SendMessage(hkr,BM_SETCHECK,BST_UNCHECKED,0L);
+ SendMessage(hkr, BM_SETCHECK, db_get_b(0, MODULENAME, "kr", 1), 0L);
//ss checkbox
- if (DBGetContactSetting(0, MODULENAME, "ss", &dbv) == 0)
- {indic=dbv.bVal;
- }
- else indic=0;
-
- if (indic==1)SendMessage(hss,BM_SETCHECK,BST_CHECKED,0L);
- else SendMessage(hss,BM_SETCHECK,BST_UNCHECKED,0L);
+ SendMessage(hss, BM_SETCHECK, db_get_b(0, MODULENAME, "ss", 0), 0L);
//sr checkbox
- if (DBGetContactSetting(0, MODULENAME, "sr", &dbv) == 0)
- {indic=dbv.bVal;
- }
- else indic=0;
-
- if (indic==1)SendMessage(hsr,BM_SETCHECK,BST_CHECKED,0L);
- else SendMessage(hsr,BM_SETCHECK,BST_UNCHECKED,0L);
-
- DBFreeVariant(&dbv);
+ SendMessage(hsr, BM_SETCHECK, db_get_b(0, MODULENAME, "sr", 0), 0L);
}
-
int onRegisterPopOptions(WPARAM wParam, LPARAM)
{
if (bPopupExists) {
- OPTIONSDIALOGPAGE odp = {0};
- odp.cbSize = sizeof(odp);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = g_hInst;
odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUP);
odp.pszTitle = (char*)MODULENAME;
diff --git a/plugins/SecureIM/src/splitmsg.cpp b/plugins/SecureIM/src/splitmsg.cpp
index 4cf6e5f91d..74583df741 100644
--- a/plugins/SecureIM/src/splitmsg.cpp
+++ b/plugins/SecureIM/src/splitmsg.cpp
@@ -11,11 +11,11 @@ LPSTR splitMsg(LPSTR szMsg, int iLen) {
LPSTR out = (LPSTR) mir_alloc(len*2);
LPSTR buf = out;
- WORD msg_id = DBGetContactSettingWord(0, MODULENAME, "msgid", 0) + 1;
+ WORD msg_id = db_get_w(0, MODULENAME, "msgid", 0) + 1;
DBWriteContactSettingWord(0, MODULENAME, "msgid", msg_id);
int part_all = (len+iLen-1)/iLen;
- for(int part_num=0; part_num<part_all; part_num++) {
+ for (int part_num=0; part_num<part_all; part_num++) {
int sz = (len>iLen)?iLen:len;
mir_snprintf(buf,32,"%s%04X%02X%02X",SIG_SECP,msg_id,part_num,part_all);
memcpy(buf+LEN_SECP+8,szMsg,sz);
diff --git a/plugins/SecureIM/src/svcs_clist.cpp b/plugins/SecureIM/src/svcs_clist.cpp
index e1c1d7e19c..bcec8fb8fa 100644
--- a/plugins/SecureIM/src/svcs_clist.cpp
+++ b/plugins/SecureIM/src/svcs_clist.cpp
@@ -82,7 +82,7 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) {
if (!ptr) {
// hide menu bars
mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN;
- for(i=0;i<SIZEOF(g_hMenu);i++) {
+ for (i=0;i<SIZEOF(g_hMenu);i++) {
if ( g_hMenu[i] )
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[i],(LPARAM)&mi);
}
@@ -90,20 +90,19 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) {
}
// char *szProto = GetContactProto(hContact,0);
-// if (szProto==NULL) // || DBGetContactSettingDword(hContact, szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
+// if (szProto==NULL) // || db_get_dw(hContact, szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
// return 0;
- BOOL isSecureProto = isSecureProtocol(hContact);
- BOOL isPGP = isContactPGP(hContact);
- BOOL isGPG = isContactGPG(hContact);
-// BOOL isRSAAES = isContactRSAAES(hContact);
- BOOL isSecured = isContactSecured(hContact)&SECURED;
- BOOL isChat = isChatRoom(hContact);
- BOOL isMiranda = isClientMiranda(hContact);
+ 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
mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN;
- for(i=0;i<SIZEOF(g_hMenu);i++) {
+ for (i=0;i<SIZEOF(g_hMenu);i++) {
if ( g_hMenu[i] )
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[i],(LPARAM)&mi);
}
@@ -132,7 +131,7 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) {
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[2],(LPARAM)&mi);
mi.flags = CMIM_FLAGS | CMIM_ICON;
- for(i=0;i<=(ptr->mode==MODE_RSAAES?1:2);i++) {
+ for (i=0;i<=(ptr->mode==MODE_RSAAES?1:2);i++) {
mi.hIcon = (i == ptr->status) ? g_hICO[ICO_ST_DIS+ptr->status] : NULL;
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[3+i],(LPARAM)&mi);
}
@@ -165,7 +164,7 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) {
CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)g_hMenu[10],(LPARAM)&mi);
mi.flags = CMIM_FLAGS | CMIM_ICON;
- for(i=0;i<MODE_CNT;i++) {
+ 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;
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);
}
diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp
index 509cb9ecf6..bae34792a8 100644
--- a/plugins/SecureIM/src/svcs_proto.cpp
+++ b/plugins/SecureIM/src/svcs_proto.cpp
@@ -4,9 +4,9 @@
// return SignID
int getSecureSig(LPCSTR szMsg, LPSTR *szPlainMsg=NULL) {
if (szPlainMsg) *szPlainMsg=(LPSTR)szMsg;
- for(int i=0;signs[i].len;i++) {
+ for (int i=0;signs[i].len;i++) {
if (memcmp(szMsg,signs[i].sig,signs[i].len)==0) {
-/* for(int i=strlen(szMsg)-1;i;i--) {
+/* for (int i=strlen(szMsg)-1;i;i--) {
if ( szMsg[i] == '\x0D' || szMsg[i] == '\x0A' )
((LPSTR)szMsg)[i] = '\0';
else
@@ -326,7 +326,7 @@ INT_PTR __cdecl onRecvMsg(WPARAM wParam, LPARAM lParam) {
// if valid key is succefully retrieved
ptr->offlineKey = true;
InitKeyX(ptr,dbv.pbVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
// decrypting message
szPlainMsg = decodeMsg(ptr,lParam,szEncMsg);
@@ -776,7 +776,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) {
}
// contact is offline
- if ( stat==ID_STATUS_OFFLINE ) {
+ if (stat == ID_STATUS_OFFLINE) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("onSendMsg: message for offline");
#endif
@@ -786,24 +786,24 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) {
}
if ( !bSOM ) {
- if ( ssig!=SiG_NONE ) {
+ if ( ssig!=SiG_NONE )
return returnNoError(pccsd->hContact);
- }
+
// exit and send unencrypted message
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
BOOL isMiranda = isClientMiranda(ptr->hContact);
- if ( stid==STATUS_ALWAYSTRY && isMiranda ) { // always try && Miranda
+ if (stid == STATUS_ALWAYSTRY && isMiranda) { // always try && Miranda
// set key for offline user
DBVARIANT dbv; dbv.type = DBVT_BLOB;
- if ( DBGetContactSettingDword(ptr->hContact, MODULENAME, "offlineKeyTimeout", 0) > gettime() &&
+ if ( db_get_dw(ptr->hContact, MODULENAME, "offlineKeyTimeout", 0) > gettime() &&
DBGetContactSetting(ptr->hContact, MODULENAME, "offlineKey", &dbv) == 0
) {
// if valid key is succefully retrieved
ptr->offlineKey = true;
InitKeyX(ptr,dbv.pbVal);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
else {
db_unset(ptr->hContact,MODULENAME,"offlineKey");
@@ -899,9 +899,9 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) {
#endif
// send KeyA if init || always_try || waitkey || always_if_possible
if ( ssig==SiG_INIT || (stid==STATUS_ALWAYSTRY && isClientMiranda(ptr->hContact)) || isSecureIM(ptr->hContact) || ptr->waitForExchange ) {
- if (ssig==SiG_NONE) {
+ if (ssig==SiG_NONE)
addMsg2Queue(ptr, pccsd->wParam, (LPSTR)pccsd->lParam);
- }
+
if ( !ptr->waitForExchange ) {
// init || always_try || always_if_possible
LPSTR keyToSend = InitKeyA(ptr,0); // calculate public and private key & fill KeyA
@@ -937,12 +937,11 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam)
pUinKey ptr = getUinKey(pccsd->hContact);
if (!ptr || !bSFT) return CallService(PSS_FILE, wParam, lParam);
- if ( isContactSecured(pccsd->hContact)&SECURED ) {
-
+ if (isContactSecured(pccsd->hContact)&SECURED) {
char **file=(char **)pccsd->lParam;
if (file_idx==100) file_idx=0;
int i;
- for(i=0;file[i];i++) {
+ for (i=0;file[i];i++) {
if (strstr(file[i],".AESHELL")) continue;
@@ -966,16 +965,16 @@ INT_PTR __cdecl onSendFile(WPARAM wParam, LPARAM lParam)
file[i]=file_out;
}
if ( ptr->fileSend ) { // очистим сохраненный список
- for(int j=0;ptr->fileSend[j];j++) {
+ for (int j=0; ptr->fileSend[j]; j++)
mir_free(ptr->fileSend[j]);
- }
+
SAFE_FREE(ptr->fileSend);
}
- if ( i ) { // скопируем новый список
+ if (i) { // скопируем новый список
ptr->fileSend = (char **) mir_alloc(sizeof(char*)*(i+1));
- for(i=0;file[i];i++) {
+ for (i=0;file[i];i++)
ptr->fileSend[i] = mir_strdup(file[i]);
- }
+
ptr->fileSend[i] = NULL;
}
}
@@ -991,18 +990,19 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam)
pUinKey ptr = getUinKey(ack->hContact);
if (!ptr || (f && (f->flags & PFTS_SENDING) && !bSFT)) return 0;
- if ( isContactSecured(ack->hContact)&SECURED ) {
+ if (isContactSecured(ack->hContact)&SECURED) {
switch(ack->result) {
case ACKRESULT_DATA:
- if ( !( f->flags & PFTS_SENDING )) {
+ if (f->flags & PFTS_SENDING) {
+ ptr->finFileSend = (f->currentFileSize == f->currentFileProgress);
+ if (!ptr->lastFileSend)
+ ptr->lastFileSend = mir_strdup(f->szCurrentFile);
+ }
+ else {
ptr->finFileRecv = (f->currentFileSize == f->currentFileProgress);
- if ( !ptr->lastFileRecv ) ptr->lastFileRecv = mir_strdup(f->szCurrentFile);
+ if (!ptr->lastFileRecv)
+ ptr->lastFileRecv = mir_strdup(f->szCurrentFile);
}
- else
- if ( f->flags & PFTS_SENDING ) {
- ptr->finFileSend = (f->currentFileSize == f->currentFileProgress);
- if ( !ptr->lastFileSend ) ptr->lastFileSend = mir_strdup(f->szCurrentFile);
- }
break;
case ACKRESULT_DENIED:
@@ -1017,7 +1017,7 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam)
}
if ( ptr->fileSend ) {
char **file=ptr->fileSend;
- for(int j=0;file[j];j++) {
+ for (int j=0;file[j];j++) {
if ( strstr(file[j],".AESHELL")) mir_unlink(file[j]);
mir_free(file[j]);
}
@@ -1042,7 +1042,7 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam)
strcpy(buf,p);
pos=p;
}
- for(int i=1;i<10000;i++) {
+ for (int i=1;i<10000;i++) {
sprintf(pos," (%d)%s",i,buf);
if ( !isFileExist(file_out)) break;
}
@@ -1051,12 +1051,11 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam)
sprintf(buf,"%s\n%s",Translate(sim012),file_out);
showPopUp(buf,NULL,g_hPOP[POP_PU_MSR],2);
- if ( ptr->mode==MODE_RSAAES ) {
+ if ( ptr->mode == MODE_RSAAES )
exp->rsa_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out);
- }
- else {
+ else
cpp_decrypt_file(ptr->cntx,ptr->lastFileRecv,file_out);
- }
+
mir_free(file_out);
mir_unlink(ptr->lastFileRecv);
}
@@ -1069,7 +1068,7 @@ int __cdecl onProtoAck(WPARAM wParam,LPARAM lParam)
ptr->finFileSend = false;
}
break;
- } // switch
+ }
}
return 0;
}
diff --git a/plugins/SecureIM/src/svcs_rsa.cpp b/plugins/SecureIM/src/svcs_rsa.cpp
index ed7430b16d..552b79dab9 100644
--- a/plugins/SecureIM/src/svcs_rsa.cpp
+++ b/plugins/SecureIM/src/svcs_rsa.cpp
@@ -47,7 +47,7 @@ int __cdecl rsa_check_pub(HANDLE context, PBYTE pub, int pubLen, PBYTE sig, int
PBYTE buf = (PBYTE) alloca(sigLen); int len;
exp->rsa_get_hash((PBYTE)dbv.pbVal,dbv.cpbVal,(PBYTE)buf,&len);
sha_old = mir_strdup(to_hex(buf,len));
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
if ( bAAK ) {
if ( k ) mir_snprintf(msg,MSGSIZE,Translate(sim523),cnm,uin,sha,sha_old);
@@ -190,7 +190,7 @@ BYTE loadRSAkey(pUinKey ptr) {
#if defined(_DEBUG) || defined(NETLIB_LOG)
Sent_NetLog("loadRSAkey %d", ptr->keyLoaded);
#endif
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
return ptr->keyLoaded;
diff --git a/plugins/SecureIM/src/svcs_srmm.cpp b/plugins/SecureIM/src/svcs_srmm.cpp
index 005f93f76e..bfc3a3e371 100644
--- a/plugins/SecureIM/src/svcs_srmm.cpp
+++ b/plugins/SecureIM/src/svcs_srmm.cpp
@@ -1,33 +1,29 @@
#include "commonheaders.h"
-
-int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) {
-
+int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam)
+{
MessageWindowEventData *mwd = (MessageWindowEventData *)lParam;
- if (mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING) {
+ if (mwd->uType == MSG_WINDOW_EVT_OPEN || mwd->uType == MSG_WINDOW_EVT_OPENING)
ShowStatusIcon(mwd->hContact);
- }
+
return 0;
}
-
-int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) {
+int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
+{
HANDLE hContact = (HANDLE)wParam;
if ( isProtoMetaContacts(hContact))
hContact = getMostOnline(hContact); // возьмем тот, через который пойдет сообщение
StatusIconClickData *sicd = (StatusIconClickData *)lParam;
- if ( strcmp(sicd->szModule, MODULENAME) != 0 ||
- !isSecureProtocol(hContact)) return 0; // not our event
-
- BOOL isPGP = isContactPGP(hContact);
- BOOL isGPG = isContactGPG(hContact);
- BOOL isSecured = isContactSecured(hContact)&SECURED;
- BOOL isChat = isChatRoom(hContact);
-
- if ( !isPGP && !isGPG && !isChat ) {
- if (isSecured) Service_DisableIM(wParam,0);
- else Service_CreateIM(wParam,0);
+ 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(wParam,0);
+ else
+ Service_CreateIM(wParam,0);
}
return 0;