diff options
Diffstat (limited to 'plugins/MirOTR')
-rw-r--r-- | plugins/MirOTR/MirOTR/src/dbfilter.cpp | 2 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/dllmain.cpp | 5 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/options.cpp | 60 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/otr.cpp | 6 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_menu.cpp | 53 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_menu.h | 1 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_srmm.cpp | 8 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/utils.cpp | 4 |
8 files changed, 54 insertions, 85 deletions
diff --git a/plugins/MirOTR/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/MirOTR/src/dbfilter.cpp index 9c0739fad3..790de635c6 100644 --- a/plugins/MirOTR/MirOTR/src/dbfilter.cpp +++ b/plugins/MirOTR/MirOTR/src/dbfilter.cpp @@ -54,7 +54,7 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { const char *proto = contact_get_proto(hContact);
if (!proto ) return 0;
- if (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1)
+ if (db_get_b(hContact, proto, "ChatRoom", 0) == 1)
return 0;
if(g_metaproto && strcmp(proto, g_metaproto) == 0) {
diff --git a/plugins/MirOTR/MirOTR/src/dllmain.cpp b/plugins/MirOTR/MirOTR/src/dllmain.cpp index ee1198e2bf..9d788fac89 100644 --- a/plugins/MirOTR/MirOTR/src/dllmain.cpp +++ b/plugins/MirOTR/MirOTR/src/dllmain.cpp @@ -101,13 +101,13 @@ extern "C" __declspec(dllexport) int Load(void) CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
// remove us as a filter to all contacts - fix filter type problem
- if(DBGetContactSettingByte(0, MODULENAME, "FilterOrderFix", 0) != 2) {
+ if(db_get_b(0, MODULENAME, "FilterOrderFix", 0) != 2) {
HANDLE hContact = db_find_first();
while ( hContact != NULL ) {
CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME);
hContact = db_find_next(hContact);
}
- DBWriteContactSettingByte(0, MODULENAME, "FilterOrderFix", 2);
+ db_set_b(0, MODULENAME, "FilterOrderFix", 2);
}
// create our services
@@ -131,7 +131,6 @@ extern "C" __declspec(dllexport) int Unload(void) DEBUGOUT_T("UNLOAD MIROTR")
DeinitSRMM();
DeinitOptions();
- DeinitMenu();
DeinitDBFilter();
lib_cs_lock();
diff --git a/plugins/MirOTR/MirOTR/src/options.cpp b/plugins/MirOTR/MirOTR/src/options.cpp index 5def9d9470..1007d0e848 100644 --- a/plugins/MirOTR/MirOTR/src/options.cpp +++ b/plugins/MirOTR/MirOTR/src/options.cpp @@ -53,7 +53,7 @@ void LoadFilenames() }
void LoadOptions() {
- options.default_policy = DBGetContactSettingWord(0, MODULENAME, "DefaultPolicy", OTRL_POLICY_OPPORTUNISTIC);
+ options.default_policy = db_get_w(0, MODULENAME, "DefaultPolicy", OTRL_POLICY_OPPORTUNISTIC);
// deal with changed flags in proto.h and new interpretation of 'manual' mode (see common.h)
switch(options.default_policy) {
case OTRL_POLICY_MANUAL:
@@ -68,26 +68,26 @@ void LoadOptions() { options.default_policy = OTRL_POLICY_OPPORTUNISTIC;
break;
}
- options.err_method = (ErrorDisplay)DBGetContactSettingWord(0, MODULENAME, "ErrorDisplay", ED_POP);
- options.prefix_messages = (DBGetContactSettingByte(0, MODULENAME, "PrefixMessages", 0) == 1);
- options.msg_inline = (DBGetContactSettingByte(0, MODULENAME, "MsgInline", 0) == 1);
- options.msg_popup = (DBGetContactSettingByte(0, MODULENAME, "MsgPopup", 1) == 1);
- options.delete_history = (DBGetContactSettingByte(0, MODULENAME, "NoHistory", 0) == 1);
- options.delete_systeminfo = (DBGetContactSettingByte(0, MODULENAME, "NoSystemHistory", 0) == 1);
- options.autoshow_verify = (DBGetContactSettingByte(0, MODULENAME, "AutoShowVerify", 1) == 1);
+ options.err_method = (ErrorDisplay)db_get_w(0, MODULENAME, "ErrorDisplay", ED_POP);
+ options.prefix_messages = (db_get_b(0, MODULENAME, "PrefixMessages", 0) == 1);
+ options.msg_inline = (db_get_b(0, MODULENAME, "MsgInline", 0) == 1);
+ options.msg_popup = (db_get_b(0, MODULENAME, "MsgPopup", 1) == 1);
+ options.delete_history = (db_get_b(0, MODULENAME, "NoHistory", 0) == 1);
+ options.delete_systeminfo = (db_get_b(0, MODULENAME, "NoSystemHistory", 0) == 1);
+ options.autoshow_verify = (db_get_b(0, MODULENAME, "AutoShowVerify", 1) == 1);
DBVARIANT dbv;
if (!DBGetContactSettingUTF8String(0, MODULENAME, "Prefix", &dbv)) {
strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN);
options.prefix[OPTIONS_PREFIXLEN-1] = 0;
- DBFreeVariant(&dbv);
+ db_free(&dbv);
} else
strcpy(options.prefix, ("OTR: "));
- options.timeout_finished = (DBGetContactSettingByte(0, MODULENAME, "TimeoutFinished", 0) == 1);
+ options.timeout_finished = (db_get_b(0, MODULENAME, "TimeoutFinished", 0) == 1);
- options.end_offline = (DBGetContactSettingByte(0, MODULENAME, "EndOffline", 1) == 1);
- options.end_window_close = (DBGetContactSettingByte(0, MODULENAME, "EndWindowClose", 0) == 1);
+ options.end_offline = (db_get_b(0, MODULENAME, "EndOffline", 1) == 1);
+ options.end_window_close = (db_get_b(0, MODULENAME, "EndWindowClose", 0) == 1);
options.bHaveMetaContacts = 0!=ServiceExists(MS_MC_GETMETACONTACT);
options.bHavePopups = 0!=ServiceExists(MS_POPUP_ADDPOPUPT) && ServiceExists(MS_POPUP_SHOWMESSAGE);
@@ -142,30 +142,22 @@ void DeinitOptions() { }
void SaveOptions() {
- DBWriteContactSettingWord(0, MODULENAME, "DefaultPolicy", options.default_policy);
- DBWriteContactSettingWord(0, MODULENAME, "ErrorDisplay", (int)options.err_method);
- DBWriteContactSettingByte(0, MODULENAME, "PrefixMessages", options.prefix_messages ? 1 : 0);
- DBWriteContactSettingByte(0, MODULENAME, "MsgInline", options.msg_inline ? 1 : 0);
- DBWriteContactSettingByte(0, MODULENAME, "MsgPopup", options.msg_popup ? 1 : 0);
-
- DBWriteContactSettingByte(0, MODULENAME, "NoHistory", options.delete_history ? 1 : 0);
- DBWriteContactSettingByte(0, MODULENAME, "NoSystemHistory", options.delete_systeminfo ? 1 : 0);
- DBWriteContactSettingByte(0, MODULENAME, "AutoShowVerify", options.autoshow_verify ? 1 : 0);
-
- /*
- if (contact_policies) {
- for(ContactPolicyMap::iterator i = contact_policies->begin(); i != contact_policies->end(); i++) {
- DBWriteContactSettingWord(i->first, MODULENAME, "Policy", i->second);
- }
- }
- */
+ db_set_w(0, MODULENAME, "DefaultPolicy", options.default_policy);
+ db_set_w(0, MODULENAME, "ErrorDisplay", (int)options.err_method);
+ db_set_b(0, MODULENAME, "PrefixMessages", options.prefix_messages ? 1 : 0);
+ db_set_b(0, MODULENAME, "MsgInline", options.msg_inline ? 1 : 0);
+ db_set_b(0, MODULENAME, "MsgPopup", options.msg_popup ? 1 : 0);
+
+ db_set_b(0, MODULENAME, "NoHistory", options.delete_history ? 1 : 0);
+ db_set_b(0, MODULENAME, "NoSystemHistory", options.delete_systeminfo ? 1 : 0);
+ db_set_b(0, MODULENAME, "AutoShowVerify", options.autoshow_verify ? 1 : 0);
- DBWriteContactSettingStringUtf(0, MODULENAME, "Prefix", options.prefix);
+ db_set_utf(0, MODULENAME, "Prefix", options.prefix);
- DBWriteContactSettingByte(0, MODULENAME, "TimeoutFinished", options.timeout_finished ? 1 : 0);
+ db_set_b(0, MODULENAME, "TimeoutFinished", options.timeout_finished ? 1 : 0);
- DBWriteContactSettingByte(0, MODULENAME, "EndOffline", options.end_offline ? 1 : 0);
- DBWriteContactSettingByte(0, MODULENAME, "EndWindowClose", options.end_window_close ? 1 : 0);
+ db_set_b(0, MODULENAME, "EndOffline", options.end_offline ? 1 : 0);
+ db_set_b(0, MODULENAME, "EndWindowClose", options.end_window_close ? 1 : 0);
}
extern "C" void set_context_contact(void *data, ConnContext *context) {
@@ -640,7 +632,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM for(ContactPolicyMap::const_iterator it = cpm->begin(); it != cpm->end(); ++it)
{
if (!it->first) continue;
- if (it->second.policy) DBWriteContactSettingDword(it->first, MODULENAME, "Policy", (DWORD)it->second.policy);
+ if (it->second.policy) db_set_dw(it->first, MODULENAME, "Policy", (DWORD)it->second.policy);
if (it->second.htmlconv) db_set_b(it->first, MODULENAME, "HTMLConv", it->second.htmlconv-1);
}
return TRUE;
diff --git a/plugins/MirOTR/MirOTR/src/otr.cpp b/plugins/MirOTR/MirOTR/src/otr.cpp index 1590d9244b..c7f37b9ac6 100644 --- a/plugins/MirOTR/MirOTR/src/otr.cpp +++ b/plugins/MirOTR/MirOTR/src/otr.cpp @@ -79,7 +79,7 @@ extern "C" { HANDLE hContact = (HANDLE)opdata;
DWORD pol;
if(hContact) {
- pol = DBGetContactSettingDword(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
+ pol = db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
if (options.bHaveSecureIM && pol != OTRL_POLICY_MANUAL_MOD && pol != OTRL_POLICY_NEVER && db_get_b(hContact, "SecureIM" , "StatusID", 0)) {
// if SecureIM is not disabled for this contact, MirOTR will be set to manual
db_set_dw(hContact, MODULENAME, "Policy", OTRL_POLICY_MANUAL_MOD);
@@ -126,7 +126,7 @@ extern "C" { DEBUGOUT_T("OTR_GUI_IS_LOGGED_IN")
HANDLE hContact = (HANDLE)opdata;
if(hContact) {
- WORD status = DBGetContactSettingWord(hContact, contact_get_proto(hContact), "Status", ID_STATUS_OFFLINE);
+ WORD status = db_get_w(hContact, contact_get_proto(hContact), "Status", ID_STATUS_OFFLINE);
if(status == ID_STATUS_OFFLINE) return 0;
else return 1;
}
@@ -141,7 +141,7 @@ extern "C" { //MessageBox(0, message, "OTR Inject", MB_OK);
HANDLE hContact = (HANDLE)opdata;
- if(protocol && DBGetContactSettingWord(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
+ if(protocol && db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
/* this would be with translation
TCHAR *decode = mir_utf8decodeT(message);
TCHAR *encode = mir_utf8encodeT(TranslateT(decide));
diff --git a/plugins/MirOTR/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/MirOTR/src/svcs_menu.cpp index d09fe916b5..f1885a31a3 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_menu.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_menu.cpp @@ -1,6 +1,6 @@ #include "stdafx.h"
-HANDLE hMenuBuildEvent, hStopItem, hStartItem;
+static HGENMENU hStopItem, hStartItem;
////////////////////////////////
///////// Menu Services ////////
@@ -11,7 +11,7 @@ int StartOTR(HANDLE hContact) { if (!proto) return 1; // error
char *uname = contact_get_id(hContact);
if (!uname) return 1; // error
- DWORD pol = DBGetContactSettingDword(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
+ DWORD pol = db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
if(pol == CONTACT_DEFAULT_POLICY) pol = options.default_policy;
lib_cs_lock();
@@ -22,6 +22,7 @@ int StartOTR(HANDLE hContact) { mir_free(uname);
return 0;
}
+
INT_PTR SVC_StartOTR(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam, hSub;
if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
@@ -44,6 +45,7 @@ INT_PTR SVC_StartOTR(WPARAM wParam, LPARAM lParam) { return 0;
}
+
INT_PTR SVC_RefreshOTR(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam, hSub;
if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
@@ -145,12 +147,7 @@ void InitMenu() hStartItem = Menu_AddContactMenuItem(&mi);
- hMenuBuildEvent = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SVC_PrebuildContactMenu);
-
-}
-
-void DeinitMenu() {
- UnhookEvent(hMenuBuildEvent);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, SVC_PrebuildContactMenu);
}
int SVC_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
@@ -163,8 +160,11 @@ int SVC_PrebuildContactMenu(WPARAM wParam, LPARAM lParam) const char *proto = contact_get_proto(hContact);
DWORD pol = CONTACT_DEFAULT_POLICY;
- if (!proto || DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1) {
- goto hide_all;
+ if (!proto || db_get_b(hContact, proto, "ChatRoom", 0) == 1) {
+hide_all:
+ Menu_ShowItem(hStartItem, false);
+ Menu_ShowItem(hStopItem, false);
+ return 0;
}
if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) {
@@ -175,36 +175,15 @@ int SVC_PrebuildContactMenu(WPARAM wParam, LPARAM lParam) proto = contact_get_proto(hContact);
}
- pol = DBGetContactSettingDword(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
+ pol = db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
if(pol == CONTACT_DEFAULT_POLICY) pol = options.default_policy;
- if(pol == OTRL_POLICY_NEVER || pol == OTRL_POLICY_ALWAYS) {
+ if(pol == OTRL_POLICY_NEVER || pol == OTRL_POLICY_ALWAYS)
goto hide_all;
- }
- {
- ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact);
- TrustLevel encrypted = otr_context_get_trust(context);
- if(encrypted != TRUST_NOT_PRIVATE) {
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hStopItem, (LPARAM)&mi);
- mi.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hStartItem, (LPARAM)&mi);
- } else {
- //if(pol == OTRL_POLICY_MANUAL_MOD) {
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hStartItem, (LPARAM)&mi);
- mi.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hStopItem, (LPARAM)&mi);
- //} else { // should only be 'opportunistic'
- // goto hide_all;
- //}
- }
- }
-
- return 0;
-
-hide_all:
- mi.flags |= CMIF_HIDDEN;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hStopItem, (LPARAM)&mi);
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hStartItem, (LPARAM)&mi);
+ ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact);
+ TrustLevel encrypted = otr_context_get_trust(context);
+ Menu_ShowItem(hStartItem, encrypted == TRUST_NOT_PRIVATE);
+ Menu_ShowItem(hStopItem, encrypted != TRUST_NOT_PRIVATE);
return 0;
}
\ No newline at end of file diff --git a/plugins/MirOTR/MirOTR/src/svcs_menu.h b/plugins/MirOTR/MirOTR/src/svcs_menu.h index 7dfc11a9ea..145a080be9 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_menu.h +++ b/plugins/MirOTR/MirOTR/src/svcs_menu.h @@ -5,7 +5,6 @@ INT_PTR SVC_StopOTR(WPARAM wParam, LPARAM lParam); INT_PTR SVC_VerifyOTR(WPARAM wParam, LPARAM lParam);
int SVC_PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
void InitMenu();
-void DeinitMenu();
#define MS_OTR_MENUSTART MODULENAME"/Start"
#define MS_OTR_MENUSTOP MODULENAME"/Stop"
diff --git a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp index ed17aa29ab..030a534b28 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp @@ -40,7 +40,7 @@ int SVC_IconPressed(WPARAM wParam, LPARAM lParam) { if(strcmp(sicd->szModule, MODULENAME) == 0) {
char *proto = GetContactProto(hContact);
- if(proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0))
+ if(proto && db_get_b(hContact, proto, "ChatRoom", 0))
return 0;
ShowOTRMenu(hContact, sicd->clickLocation);
/*
@@ -146,9 +146,9 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { //strcat(dbg_msg, (encrypted ? "true" : "false"));
char *proto = GetContactProto(hContact);
- bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0));
+ bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0));
- // if (!chat_room) DBWriteContactSettingByte(hContact, MODULENAME, "Encrypted", (encrypted ? 1 : 0));
+ // if (!chat_room) db_set_b(hContact, MODULENAME, "Encrypted", (encrypted ? 1 : 0));
if(options.bHaveSRMMIcons || options.bHaveButtonsBar) {
//strcat(dbg_msg, "\nchanging icon");
@@ -226,7 +226,7 @@ int SVC_ButtonsBarPressed(WPARAM w, LPARAM l) { HANDLE hContact = (HANDLE)w;
char *proto = GetContactProto(hContact);
- if(proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0))
+ if(proto && db_get_b(hContact, proto, "ChatRoom", 0))
return 0;
ShowOTRMenu(hContact, cbcd->pt);
diff --git a/plugins/MirOTR/MirOTR/src/utils.cpp b/plugins/MirOTR/MirOTR/src/utils.cpp index 7877065ccc..148934b9cc 100644 --- a/plugins/MirOTR/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/MirOTR/src/utils.cpp @@ -349,7 +349,7 @@ void ShowMessage(const HANDLE hContact, const TCHAR *msg) { /*
bool GetEncryptionStatus(HANDLE hContact) {
char *proto = GetContactProto(hContact);
- bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0));
+ bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0));
if (!chat_room) {
if (options.bHaveMetaContacts) {
@@ -358,7 +358,7 @@ bool GetEncryptionStatus(HANDLE hContact) { //strcat(dbg_msg, "\nrecursing for meta");
return GetEncryptionStatus(hMeta);
}
- return 0!=DBGetContactSettingByte(hContact, MODULENAME, "Encrypted", 0 );
+ return 0!=db_get_b(hContact, MODULENAME, "Encrypted", 0 );
}
}
return 0;
|