diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-10 08:04:30 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-10 08:04:30 +0000 |
commit | ddba4ede6b451d0cfcd0d32b5180fbd0689966bf (patch) | |
tree | 5d74f37a7013d13b92c182628d6b68a58e148ae4 /plugins/MirOTR | |
parent | c39340bf493a1745a41317bbf937fc7eb6cbb26a (diff) |
- HANDLE hContact => HCONTACT
- GCF_* prefix was added to chat constants to avoid name conflicts
git-svn-id: http://svn.miranda-ng.org/main/trunk@8078 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR')
-rw-r--r-- | plugins/MirOTR/MirOTR/src/dbfilter.cpp | 44 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/dialogs.cpp | 52 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/dllmain.cpp | 2 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/mirotrmenu.cpp | 11 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/mirotrmenu.h | 2 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/options.cpp | 23 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/options.h | 2 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/otr.cpp | 52 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_menu.cpp | 40 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_proto.cpp | 4 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_srmm.cpp | 10 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/svcs_srmm.h | 2 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/utils.cpp | 54 | ||||
-rw-r--r-- | plugins/MirOTR/MirOTR/src/utils.h | 24 |
14 files changed, 164 insertions, 158 deletions
diff --git a/plugins/MirOTR/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/MirOTR/src/dbfilter.cpp index e3d992817a..443c009574 100644 --- a/plugins/MirOTR/MirOTR/src/dbfilter.cpp +++ b/plugins/MirOTR/MirOTR/src/dbfilter.cpp @@ -5,10 +5,10 @@ static CRITICAL_SECTION RemoveChainCS={0}, *lpRemoveChainCS = &RemoveChainCS; static UINT_PTR timerId = 0;
struct DeleteEventNode {
- DeleteEventNode *next;
- time_t timestamp;
- HANDLE hContact;
- HANDLE hDbEvent;
+ DeleteEventNode *next;
+ time_t timestamp;
+ HCONTACT hContact;
+ HANDLE hDbEvent;
};
struct DeleteEventHead {
DeleteEventNode *first;
@@ -45,7 +45,7 @@ VOID CALLBACK DeleteTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTi // add prefix to sent messages
int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) {
if (!options.prefix_messages || !lParam) return 0;
- HANDLE hContact = (HANDLE)wParam;
+ HCONTACT hContact = (HCONTACT)wParam;
DBEVENTINFO *dbei = (DBEVENTINFO *)lParam;
if ((dbei->eventType != EVENTTYPE_MESSAGE) || !(dbei->flags & DBEF_SENT) || (dbei->flags & DBEF_OTR_PREFIXED))
return 0;
@@ -58,7 +58,7 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { return 0;
if(g_metaproto && strcmp(proto, g_metaproto) == 0) {
- hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
+ hContact = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
if (!hContact) return 0;
proto = contact_get_proto(hContact);
if (!proto ) return 0;
@@ -74,9 +74,9 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { char *msg = (char *)dbei->pBlob;
char *newmsg = 0;
DWORD alloclen = 0;
- DWORD msglen = strlen(msg);
+ DWORD msglen = (DWORD)strlen(msg);
if (dbei->flags & DBEF_UTF) {
- int prefixlen = strnlen(options.prefix, 64);
+ int prefixlen = (int)strnlen(options.prefix, 64);
if (strncmp(msg, options.prefix, prefixlen) == 0) return 0;
alloclen = (msglen+prefixlen+1)*sizeof(char);
@@ -108,15 +108,15 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { // yes, unicode
wchar_t* msgw = (wchar_t *)&msg[msglen];
wchar_t *prefixw = mir_utf8decodeW(options.prefix);
- int prefixlenw = wcslen(prefixw);
+ int prefixlenw = (int)wcslen(prefixw);
if (wcsncmp(msgw, prefixw, prefixlenw) == 0) {
mir_free(prefixw);
return 0;
}
- int msglenw = wcslen(msgw);
+ int msglenw = (int)wcslen(msgw);
char *prefix = mir_utf8decodeA(options.prefix);
- int prefixlen = strlen(prefix);
+ int prefixlen = (int)strlen(prefix);
alloclen = (msglen+prefixlen+1)* sizeof(char) + (msglenw + prefixlenw +1) * sizeof(wchar_t);
// get additional data
@@ -141,7 +141,7 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { }
else {
char *prefix = mir_utf8decodeA(options.prefix);
- int prefixlen = strlen(prefix);
+ int prefixlen = (int)strlen(prefix);
if (strncmp(msg, prefix, prefixlen) == 0) {
mir_free(prefix);
return 0;
@@ -183,16 +183,16 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { static char* prefixutf = mir_utf8encodeT(TranslateT(LANG_INLINE_PREFIX));
static char* prefix = Translate(LANG_INLINE_PREFIX);
- static DWORD lenutf = strlen(prefixutf);
- static DWORD len = strlen(prefix);
+ static DWORD lenutf = (DWORD)strlen(prefixutf);
+ static DWORD len = (DWORD)strlen(prefix);
DBEVENTINFO info = { sizeof(info) };
info.cbBlob = lenutf*2;
info.pBlob = (PBYTE)mir_alloc(info.cbBlob);
if (!db_event_get((HANDLE)lParam, &info)) {
if(info.eventType == EVENTTYPE_MESSAGE) {
- HANDLE hContact = (HANDLE)wParam, hSub;
- if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
+ HCONTACT hContact = (HCONTACT)wParam, hSub;
+ if(options.bHaveMetaContacts && (hSub = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hSub;
ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact);
@@ -223,7 +223,7 @@ int OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { return 0;
}
-void FinishSession(HANDLE hContact) {
+void FinishSession(HCONTACT hContact) {
if (!hContact) return;
ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact);
TrustLevel level = otr_context_get_trust(context);
@@ -247,8 +247,8 @@ int WindowEvent(WPARAM wParam, LPARAM lParam) { if(mwd->uType != MSG_WINDOW_EVT_OPEN) return 0;
- HANDLE hContact = mwd->hContact, hTemp;
- if(options.bHaveMetaContacts && (hTemp = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
+ HCONTACT hContact = mwd->hContact, hTemp;
+ if(options.bHaveMetaContacts && (hTemp = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hTemp;
if (!CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME))
@@ -271,14 +271,14 @@ int StatusModeChange(WPARAM wParam, LPARAM lParam) { if(status != ID_STATUS_OFFLINE ) return 0;
const char *proto = (char *)lParam;
- HANDLE hContact;
+ HCONTACT hContact;
lib_cs_lock();
ConnContext *context = otr_user_state->context_root;
while(context) {
if(context->msgstate == OTRL_MSGSTATE_ENCRYPTED && (proto == 0 || strcmp(proto, context->protocol) == 0)) {
- hContact = context->app_data;
+ hContact = (HCONTACT)context->app_data;
if(hContact) {
otrl_message_disconnect(otr_user_state, &ops, hContact, context->accountname, context->protocol, context->username);
@@ -296,7 +296,7 @@ int StatusModeChange(WPARAM wParam, LPARAM lParam) { int OnContactSettingChanged(WPARAM wParam, LPARAM lParam) {
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
if (!lParam || strcmp(cws->szSetting, "Status") != 0) return 0;
- HANDLE hContact = (HANDLE)wParam;
+ HCONTACT hContact = (HCONTACT)wParam;
int status=0;
switch (cws->value.type){
case DBVT_WORD:
diff --git a/plugins/MirOTR/MirOTR/src/dialogs.cpp b/plugins/MirOTR/MirOTR/src/dialogs.cpp index 0f16292577..b248ec0102 100644 --- a/plugins/MirOTR/MirOTR/src/dialogs.cpp +++ b/plugins/MirOTR/MirOTR/src/dialogs.cpp @@ -33,8 +33,8 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM smp_for_contact[context->app_data].responder = data->responder;
mir_free(data);
- TCHAR title[512], *proto = mir_a2t(contact_get_proto((HANDLE)context->app_data));
- const TCHAR *name =contact_get_nameT((HANDLE)context->app_data);
+ TCHAR title[512], *proto = mir_a2t(contact_get_proto((HCONTACT)context->app_data));
+ const TCHAR *name =contact_get_nameT((HCONTACT)context->app_data);
mir_sntprintf(title, 512, TranslateT(LANG_SMP_PROGRESS_TITLE), name, proto);
SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)title);
mir_sntprintf(title, 512, TranslateT(LANG_SMP_PROGRESS_DESC), name, proto);
@@ -168,15 +168,15 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA smp_for_contact[context->app_data].oldlevel = data->oldlevel;
smp_for_contact[context->app_data].responder = data->responder;
- TCHAR buff[512], *proto=mir_a2t(contact_get_proto(context->app_data));
- mir_sntprintf(buff, 512, TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT(context->app_data), proto);
+ TCHAR buff[512], *proto = mir_a2t(contact_get_proto((HCONTACT)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT((HCONTACT)context->app_data), proto);
mir_free(proto);
SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)buff);
SetDlgItemText(hwndDlg, IDC_STC_SMP_HEAD, buff);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)context);
if (data->question) {
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_RESPOND_DESC), contact_get_nameT(context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_RESPOND_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -195,7 +195,7 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA mir_free(data->question);
} else {
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPPASSWORD_RESPOND_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPPASSWORD_RESPOND_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -315,8 +315,8 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA return FALSE;
}
- TCHAR title[512], *proto = mir_a2t(contact_get_proto((HANDLE)context->app_data));
- mir_sntprintf(title, 512, TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT((HANDLE)context->app_data), proto);
+ TCHAR title[512], *proto = mir_a2t(contact_get_proto((HCONTACT)context->app_data));
+ mir_sntprintf(title, 512, TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT((HCONTACT)context->app_data), proto);
mir_free(proto);
SendMessage(hwndDlg, WM_SETTEXT, 0, (LPARAM)title);
SetDlgItemText(hwndDlg, IDC_STC_SMP_HEAD, title);
@@ -370,9 +370,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }
TCHAR buff[1024];
if (!fp->trust || fp->trust[0] == '\0')
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT((HCONTACT)context->app_data));
else
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -408,7 +408,7 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (_tcsncmp(msg, TranslateT(LANG_SMPTYPE_QUESTION), 255)==0) {
if (smp_for_contact.find(context->app_data) != smp_for_contact.end()) {
TCHAR msg[512];
- mir_sntprintf(msg, 512, TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(msg, 512, TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT((HCONTACT)context->app_data));
ShowError(msg);
}else {
int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, WM_GETTEXTLENGTH, 0, 0);
@@ -432,7 +432,7 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }else if (_tcsncmp(msg, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) {
if (smp_for_contact.find(context->app_data) != smp_for_contact.end()) {
TCHAR msg[512];
- mir_sntprintf(msg, 512, TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(msg, 512, TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT((HCONTACT)context->app_data));
ShowError(msg);
}else {
int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, WM_GETTEXTLENGTH, 0, 0);
@@ -477,9 +477,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA GetDlgItemText(hwndDlg, IDC_CBO_SMP_CHOOSE, buff, 255);
if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_QUESTION), 255)==0) {
if (trusted)
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT((HCONTACT)context->app_data));
else
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -497,9 +497,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
} else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) {
if (trusted)
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPPASSWORD_VERIFIED_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPPASSWORD_VERIFIED_DESC), contact_get_nameT((HCONTACT)context->app_data));
else
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPPASSWORD_VERIFY_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_SMPPASSWORD_VERIFY_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -517,9 +517,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
} else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_FINGERPRINT), 255)==0) {
if (trusted)
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT((HCONTACT)context->app_data));
else
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -662,9 +662,9 @@ INT_PTR CALLBACK DlgProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam, LPA }
TCHAR buff[512];
if (!fp->trust || fp->trust[0] == '\0')
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT((HCONTACT)context->app_data));
else
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT((HCONTACT)context->app_data));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -729,20 +729,20 @@ unsigned int CALLBACK verify_context_thread(void *param) otrl_context_set_trust(context->active_fingerprint, "verified");
otrl_privkey_write_fingerprints(otr_user_state, g_fingerprint_store_filename);
lib_cs_unlock();
- mir_sntprintf(msg, 1024, TranslateT(LANG_FINGERPRINT_VERIFIED), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(msg, 1024, TranslateT(LANG_FINGERPRINT_VERIFIED), contact_get_nameT((HCONTACT)context->app_data));
msg[1023] = '\0';
- ShowMessage((HANDLE)context->app_data, msg);
- SetEncryptionStatus(context->app_data, otr_context_get_trust(context));
+ ShowMessage((HCONTACT)context->app_data, msg);
+ SetEncryptionStatus((HCONTACT)context->app_data, otr_context_get_trust(context));
break;
case IDNO:
lib_cs_lock();
otrl_context_set_trust(context->active_fingerprint, NULL);
otrl_privkey_write_fingerprints(otr_user_state, g_fingerprint_store_filename);
lib_cs_unlock();
- mir_sntprintf(msg, 1024, TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(msg, 1024, TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT((HCONTACT)context->app_data));
msg[1023] = '\0';
- ShowMessage((HANDLE)context->app_data, msg);
- SetEncryptionStatus(context->app_data, otr_context_get_trust(context));
+ ShowMessage((HCONTACT)context->app_data, msg);
+ SetEncryptionStatus((HCONTACT)context->app_data, otr_context_get_trust(context));
break;
}
}
diff --git a/plugins/MirOTR/MirOTR/src/dllmain.cpp b/plugins/MirOTR/MirOTR/src/dllmain.cpp index e38f2ff076..1c275c4e92 100644 --- a/plugins/MirOTR/MirOTR/src/dllmain.cpp +++ b/plugins/MirOTR/MirOTR/src/dllmain.cpp @@ -88,7 +88,7 @@ extern "C" __declspec(dllexport) int Load(void) // remove us as a filter to all contacts - fix filter type problem
if(db_get_b(0, MODULENAME, "FilterOrderFix", 0) != 2) {
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME);
db_set_b(0, MODULENAME, "FilterOrderFix", 2);
}
diff --git a/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp index f886cd14e6..78fd4bf165 100644 --- a/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp +++ b/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp @@ -49,9 +49,7 @@ static INT_PTR AddMirOTRMenuItem(WPARAM, LPARAM lParam) static INT_PTR BuildMirOTRMenu(WPARAM wParam, LPARAM)
{
- HANDLE hContact = ( HANDLE )wParam;
- //NotifyEventHooks(hPreBuildMirOTRMenuEvent,(WPARAM)hMirOTR,0);
-
+ HCONTACT hContact = (HCONTACT)wParam;
ListParam param = { 0 };
param.MenuObjectHandle = hMirOTRMenuObject;
@@ -89,10 +87,9 @@ INT_PTR MirOTRMenuCheckService(WPARAM wParam,LPARAM) if ( cmep == NULL ) //this is rootsection...build it
return TRUE;
- HANDLE hContact = (HANDLE)pcpp->wParam, hSub;
- if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
+ HCONTACT hContact = (HCONTACT)pcpp->wParam, hSub;
+ if(options.bHaveMetaContacts && (hSub = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hSub;
- }
TrustLevel level = ( TrustLevel )otr_context_get_trust(otrl_context_find_miranda(otr_user_state, hContact));
@@ -181,7 +178,7 @@ LRESULT CALLBACK PopupMenuWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM return DefWindowProc(hwnd, message, wParam, lParam);
}
-void ShowOTRMenu(HANDLE hContact, POINT pt){
+void ShowOTRMenu(HCONTACT hContact, POINT pt){
HMENU menu = (HMENU) CallService(MS_MIROTR_MENUBUILDMIROTR, (WPARAM)hContact, 0);
SetWindowLongPtr(hDummyPaintWin, GWLP_USERDATA, (LONG_PTR)hContact);
TrackPopupMenu(menu, 0, pt.x, pt.y, 0, hDummyPaintWin, 0);
diff --git a/plugins/MirOTR/MirOTR/src/mirotrmenu.h b/plugins/MirOTR/MirOTR/src/mirotrmenu.h index fe070f0ba8..c92adab7fb 100644 --- a/plugins/MirOTR/MirOTR/src/mirotrmenu.h +++ b/plugins/MirOTR/MirOTR/src/mirotrmenu.h @@ -42,4 +42,4 @@ typedef struct { void InitMirOTRMenu(void);
void UninitMirOTRMenu(void);
-void ShowOTRMenu(HANDLE hContact, POINT pt);
\ No newline at end of file +void ShowOTRMenu(HCONTACT hContact, POINT pt);
diff --git a/plugins/MirOTR/MirOTR/src/options.cpp b/plugins/MirOTR/MirOTR/src/options.cpp index 04a985eccc..7ecb6051c7 100644 --- a/plugins/MirOTR/MirOTR/src/options.cpp +++ b/plugins/MirOTR/MirOTR/src/options.cpp @@ -156,10 +156,11 @@ void SaveOptions() { db_set_b(0, MODULENAME, "EndWindowClose", options.end_window_close ? 1 : 0);
}
-extern "C" void set_context_contact(void *data, ConnContext *context) {
- HANDLE hContact = find_contact(context->username, context->protocol);
- context->app_data = hContact;
- }
+extern "C" void set_context_contact(void *data, ConnContext *context)
+{
+ HCONTACT hContact = find_contact(context->username, context->protocol);
+ context->app_data = hContact;
+}
void ReadPrivkeyFiles() {
DEBUGOUT_T("READ privkey");
@@ -556,7 +557,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM const char *proto;
TCHAR *proto_t;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
proto = contact_get_proto(hContact);
if(proto && db_get_b(hContact, proto, "ChatRoom", 0) == 0 && CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)MODULENAME) // ignore chatrooms
&& (g_metaproto == 0 || strcmp(proto, g_metaproto) != 0)) // and MetaContacts
@@ -585,7 +586,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM switch ( LOWORD( wParam )) {
case IDC_CMB_CONT_POLICY:
{
- HANDLE hContact = 0;
+ HCONTACT hContact = 0;
int iUser = ListView_GetSelectionMark(GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS));
if (iUser == -1) break;
int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_GETCURSEL, 0, 0);
@@ -603,7 +604,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM lvi.iSubItem = 0;
ListView_GetItem(GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS), &lvi);
ContactPolicyMap* cpm = (ContactPolicyMap*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- hContact = (HANDLE)lvi.lParam;
+ hContact = (HCONTACT)lvi.lParam;
(*cpm)[hContact].policy = policy;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}break;
@@ -649,7 +650,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM lvi.iSubItem = 0;
SendDlgItemMessage(hwndDlg, IDC_LV_CONT_CONTACTS, LVM_GETITEM, 0, (LPARAM)&lvi);
- HANDLE hContact = (HANDLE)lvi.lParam;
+ HCONTACT hContact = (HCONTACT)lvi.lParam;
ContactPolicyMap *cp = (ContactPolicyMap *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
TCHAR buff[50];
ListView_GetItemText(((LPNMHDR)lParam)->hwndFrom, lvi.iItem, 3, buff, 50);
@@ -742,7 +743,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w Fingerprint *fp;
while (context) {
if (context->app_data) {
- user = (TCHAR*)contact_get_nameT((HANDLE)context->app_data);
+ user = (TCHAR*)contact_get_nameT((HCONTACT)context->app_data);
if (user) {
proto = mir_a2t(context->protocol);
fp = context->fingerprint_root.next;
@@ -818,7 +819,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w if (fp->context->active_fingerprint == fp) {
TCHAR buff[1024], hash[45];
otrl_privkey_hash_to_humanT(hash, fp->fingerprint);
- mir_sntprintf(buff, 1024, TranslateT(LANG_FINGERPRINT_STILL_IN_USE), hash, contact_get_nameT((HANDLE)fp->context->app_data));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_FINGERPRINT_STILL_IN_USE), hash, contact_get_nameT((HCONTACT)fp->context->app_data));
ShowError(buff);
} else {
FPModifyMap* fpm = (FPModifyMap*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
@@ -847,7 +848,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w if (it->first->context->active_fingerprint == it->first) {
TCHAR buff[1024], hash[45];
otrl_privkey_hash_to_humanT(hash, it->first->fingerprint);
- mir_sntprintf(buff, 1024, TranslateT(LANG_FINGERPRINT_NOT_DELETED), hash, contact_get_nameT((HANDLE)it->first->context->app_data));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_FINGERPRINT_NOT_DELETED), hash, contact_get_nameT((HCONTACT)it->first->context->app_data));
ShowError(buff);
} else {
otrl_context_forget_fingerprint(it->first, 1);
diff --git a/plugins/MirOTR/MirOTR/src/options.h b/plugins/MirOTR/MirOTR/src/options.h index 7625eef247..a2c39a5e93 100644 --- a/plugins/MirOTR/MirOTR/src/options.h +++ b/plugins/MirOTR/MirOTR/src/options.h @@ -51,7 +51,7 @@ struct CONTACT_DATA { OtrlPolicy policy;
int htmlconv;
};
-typedef std::map<HANDLE, CONTACT_DATA> ContactPolicyMap;
+typedef std::map<HCONTACT, CONTACT_DATA> ContactPolicyMap;
typedef enum {FPM_VERIFY, FPM_NOTRUST, FPM_DELETE } FPModify;
typedef std::map<Fingerprint*, FPModify> FPModifyMap;
diff --git a/plugins/MirOTR/MirOTR/src/otr.cpp b/plugins/MirOTR/MirOTR/src/otr.cpp index e22f7adb18..dfc22f5e70 100644 --- a/plugins/MirOTR/MirOTR/src/otr.cpp +++ b/plugins/MirOTR/MirOTR/src/otr.cpp @@ -76,7 +76,7 @@ extern "C" { /* Return the OTR policy for the given context. */
OtrlPolicy otr_gui_policy(void *opdata, ConnContext *context) {
DEBUGOUT_T("OTR_GUI_POLICY")
- HANDLE hContact = (HANDLE)opdata;
+ HCONTACT hContact = (HCONTACT)opdata;
DWORD pol;
if(hContact) {
pol = db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
@@ -110,7 +110,7 @@ extern "C" { //DWORD tid;
//CloseHandle(CreateThread(0, 0, newKeyThread, (VOID *)nkd, 0, &tid));
//QueueUserAPC(newKeyAPC, Global::mainThread, (DWORD)nkd);
- if (opdata) protocol = contact_get_proto((HANDLE)opdata);
+ if (opdata) protocol = contact_get_proto((HCONTACT)opdata);
if (!protocol) return;
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_GENKEYNOTIFY), 0, GenKeyDlgFunc, (LPARAM)protocol );
@@ -124,7 +124,7 @@ extern "C" { * logged in" errors if you're wrong. */
int otr_gui_is_logged_in(void *opdata, const char *accountname, const char *protocol, const char *recipient) {
DEBUGOUT_T("OTR_GUI_IS_LOGGED_IN")
- HANDLE hContact = (HANDLE)opdata;
+ HCONTACT hContact = (HCONTACT)opdata;
if(hContact) {
WORD status = db_get_w(hContact, contact_get_proto(hContact), "Status", ID_STATUS_OFFLINE);
if(status == ID_STATUS_OFFLINE) return 0;
@@ -139,7 +139,7 @@ extern "C" { void otr_gui_inject_message(void *opdata, const char *accountname, const char *protocol, const char *recipient, const char *message) {
DEBUGOUT_T("OTR_GUI_INJECT_MESSAGE")
//MessageBox(0, message, "OTR Inject", MB_OK);
- HANDLE hContact = (HANDLE)opdata;
+ HCONTACT hContact = (HCONTACT)opdata;
if(protocol && db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
CallContactService(hContact, PSS_MESSAGE, PREF_UTF|PREF_BYPASS_OTR, (LPARAM)message);
@@ -149,7 +149,7 @@ extern "C" { * protocol / username conversation. */
void otr_gui_notify(void *opdata, OtrlNotifyLevel level, const char *accountname, const char *protocol, const char *username, const char *title, const char *primary, const char *secondary) {
DEBUGOUT_T("OTR_GUI_NOTIFY")
- const TCHAR* uname = contact_get_nameT((HANDLE)opdata);
+ const TCHAR* uname = contact_get_nameT((HCONTACT)opdata);
TCHAR* title_t = mir_utf8decodeT(title);
TCHAR *notify = TranslateT(LANG_OTR_NOTIFY);
@@ -180,11 +180,11 @@ extern "C" { int otr_gui_display_otr_message(void *opdata, const char *accountname, const char *protocol, const char *username, const char *msg) {
DEBUGOUT_T("OTR_GUI_DISPLAY_OTR_MESSAGE")
if(options.msg_inline)
- ShowMessageInlineUtf((HANDLE)opdata, Translate(msg));
+ ShowMessageInlineUtf((HCONTACT)opdata, Translate(msg));
if(options.msg_popup) {
TCHAR buff[512];
TCHAR* proto = mir_a2t(protocol);
- mir_sntprintf(buff, 512, TranslateT(LANG_OTR_USERMESSAGE), contact_get_nameT((HANDLE)opdata), proto);
+ mir_sntprintf(buff, 512, TranslateT(LANG_OTR_USERMESSAGE), contact_get_nameT((HCONTACT)opdata), proto);
mir_free(proto);
TCHAR *msg_t = mir_utf8decodeT(msg);
ShowPopup(buff, TranslateTS(msg_t), 0);
@@ -237,18 +237,18 @@ extern "C" { DEBUGOUT_T("OTR_GUI_GONE_SECURE")
TrustLevel trusted = otr_context_get_trust(context);
// opdata is hContact
- SetEncryptionStatus((HANDLE)opdata, trusted);
+ SetEncryptionStatus((HCONTACT)opdata, trusted);
TCHAR buff[1024];
if(trusted == TRUST_PRIVATE) {
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_START_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_START_OTR), contact_get_nameT((HCONTACT)opdata));
} else if (trusted == TRUST_UNVERIFIED) {
if (options.autoshow_verify) SMPInitDialog(context); //VerifyContextDialog(context);
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_START_OTR_VERIFY), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_START_OTR_VERIFY), contact_get_nameT((HCONTACT)opdata));
} else { // should never happen
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((HCONTACT)opdata));
}
// opdata is hContact
- ShowMessage((HANDLE)opdata, buff);
+ ShowMessage((HCONTACT)opdata, buff);
}
@@ -256,14 +256,14 @@ extern "C" { void otr_gui_gone_insecure(void *opdata, ConnContext *context) {
DEBUGOUT_T("OTR_GUI_GONE_INSECURE")
TCHAR buff[512];
- mir_sntprintf(buff, 512, TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 512, TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT((HCONTACT)opdata));
//MessageBox(0, buff, Translate("OTR Information"), MB_OK);
if (!Miranda_Terminated()) {
- ShowMessage((HANDLE)opdata, buff);
+ ShowMessage((HCONTACT)opdata, buff);
}
// opdata is hContact
- SetEncryptionStatus((HANDLE)opdata, otr_context_get_trust(context));
+ SetEncryptionStatus((HCONTACT)opdata, otr_context_get_trust(context));
}
/* We have completed an authentication, using the D-H keys we
@@ -271,36 +271,36 @@ extern "C" { void otr_gui_still_secure(void *opdata, ConnContext *context, int is_reply) {
DEBUGOUT_T("OTR_GUI_STILL_SECURE")
TrustLevel trusted = otr_context_get_trust(context);
- SetEncryptionStatus((HANDLE)opdata, trusted);
+ SetEncryptionStatus((HCONTACT)opdata, trusted);
TCHAR buff[1024];
if (!is_reply) {
if(trusted == TRUST_PRIVATE) {
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_CONTINUE_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_CONTINUE_OTR), contact_get_nameT((HCONTACT)opdata));
} else if (trusted == TRUST_UNVERIFIED) {
if (options.autoshow_verify) SMPInitDialog(context); //VerifyContextDialog(context);
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_CONTINUE_OTR_VERIFY), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_CONTINUE_OTR_VERIFY), contact_get_nameT((HCONTACT)opdata));
} else { // should never happen
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((HCONTACT)opdata));
}
// opdata is hContact
- ShowMessage((HANDLE)opdata, buff);
+ ShowMessage((HCONTACT)opdata, buff);
} else {
if(trusted == TRUST_PRIVATE) {
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_HAS_CONTINUE_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_HAS_CONTINUE_OTR), contact_get_nameT((HCONTACT)opdata));
} else if (trusted == TRUST_UNVERIFIED) {
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_HAS_CONTINUE_OTR_VERIFY), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_HAS_CONTINUE_OTR_VERIFY), contact_get_nameT((HCONTACT)opdata));
} else { // should never happen
- mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((HANDLE)opdata));
+ mir_sntprintf(buff, 1024, TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((HCONTACT)opdata));
}
}
- SetEncryptionStatus((HANDLE)opdata, trusted);
+ SetEncryptionStatus((HCONTACT)opdata, trusted);
}
/* Log a message. The passed message will end in "\n". */
void otr_gui_log_message(void *opdata, const char *message) {
//MessageBox(0, message, Translate("OTR Log Message"), MB_OK);
- //ShowMessageInline((HANDLE)opdata, message);
+ //ShowMessageInline((HCONTACT)opdata, message);
#ifdef _DEBUG
char* msg = strcpy((char*)mir_alloc(strlen(message)+15), "OTR message: ");
strcat(msg, message);
@@ -314,7 +314,7 @@ extern "C" { if (context && context->protocol)
proto = context->protocol;
else
- proto = contact_get_proto(opdata);
+ proto = contact_get_proto((HCONTACT)opdata);
// ugly wokaround for ICQ. ICQ protocol reports more than 7k, but in SMP this is too long.
// possibly ICQ doesn't allow single words without spaces to become longer than ~2340?
if (strcmp("ICQ", proto)==0 || strncmp("ICQ_", proto, 4)==0)
diff --git a/plugins/MirOTR/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/MirOTR/src/svcs_menu.cpp index 9a7e4a7488..762ee5adf2 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_menu.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_menu.cpp @@ -5,7 +5,7 @@ static HGENMENU hStopItem, hStartItem; ////////////////////////////////
///////// Menu Services ////////
///////////////////////////////
-int StartOTR(HANDLE hContact) {
+int StartOTR(HCONTACT hContact) {
const char *proto = contact_get_proto(hContact);
if (!proto) return 1; // error
@@ -24,8 +24,8 @@ int StartOTR(HANDLE hContact) { }
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) {
+ HCONTACT hContact = (HCONTACT)wParam, hSub;
+ if(options.bHaveMetaContacts && (hSub = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
hContact = hSub;
}
@@ -47,8 +47,8 @@ INT_PTR SVC_StartOTR(WPARAM wParam, LPARAM lParam) { }
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) {
+ HCONTACT hContact = (HCONTACT)wParam, hSub;
+ if(options.bHaveMetaContacts && (hSub = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
hContact = hSub;
}
@@ -68,11 +68,12 @@ INT_PTR SVC_RefreshOTR(WPARAM wParam, LPARAM lParam) { return 0;
}
-int otr_disconnect_contact(HANDLE hContact) {
- HANDLE hSub;
- if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
+
+int otr_disconnect_contact(HCONTACT hContact)
+{
+ HCONTACT hSub;
+ if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hSub = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
hContact = hSub;
- }
const char *proto = contact_get_proto(hContact);
if (!proto) return 1; // error
@@ -86,8 +87,9 @@ int otr_disconnect_contact(HANDLE hContact) { return 0;
}
-INT_PTR SVC_StopOTR(WPARAM wParam, LPARAM lParam) {
- HANDLE hContact = (HANDLE)wParam;
+INT_PTR SVC_StopOTR(WPARAM wParam, LPARAM lParam)
+{
+ HCONTACT hContact = (HCONTACT)wParam;
// prevent this filter from acting on injeceted messages for metas, when they are passed though the subcontact's proto send chain
if (otr_disconnect_contact(hContact)) return 0;
@@ -102,11 +104,11 @@ INT_PTR SVC_StopOTR(WPARAM wParam, LPARAM lParam) { }
INT_PTR SVC_VerifyOTR(WPARAM wParam, LPARAM lParam) {
- HANDLE hContact = (HANDLE)wParam, hSub;
- if(options.bHaveMetaContacts && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) {
- hContact = hSub;
- }
- ConnContext *context = otrl_context_find_miranda(otr_user_state, (HANDLE)wParam);
+ HCONTACT hContact = (HCONTACT)wParam, hSub;
+ if(options.bHaveMetaContacts && (hSub = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0)
+ hContact = hSub;
+
+ ConnContext *context = otrl_context_find_miranda(otr_user_state, (HCONTACT)wParam);
if (!context) return 1;
//VerifyContextDialog(context);
SMPInitDialog(context);
@@ -114,7 +116,7 @@ INT_PTR SVC_VerifyOTR(WPARAM wParam, LPARAM lParam) { }
INT_PTR SVC_ToggleHTMLOTR(WPARAM wParam, LPARAM lParam) {
- HANDLE hContact = (HANDLE)wParam;
+ HCONTACT hContact = (HCONTACT)wParam;
if (db_get_b(hContact, MODULENAME, "HTMLConv", 0))
db_set_b(hContact, MODULENAME, "HTMLConv", 0);
else
@@ -152,7 +154,7 @@ void InitMenu() int SVC_PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact = (HANDLE)wParam;
+ HCONTACT hContact = (HCONTACT)wParam;
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_TCHAR;
@@ -169,7 +171,7 @@ hide_all: if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) {
// make menu act as per most online subcontact
- hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
+ hContact = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
if (!hContact)
goto hide_all;
proto = contact_get_proto(hContact);
diff --git a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp index 2f814087e2..a9841f3e6d 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp @@ -43,7 +43,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ }
char *tmpencode = NULL;
- ConnContext *context = otrl_context_find_miranda(otr_user_state, (void*)ccs->hContact);
+ ConnContext *context = otrl_context_find_miranda(otr_user_state, ccs->hContact);
if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0) && otr_context_get_trust(context) >= TRUST_UNVERIFIED) {
char *tmpencode = encode_html_entities_utf8(oldmessage_utf);
if (tmpencode != NULL) {
@@ -196,7 +196,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ TCHAR buff[256];
mir_sntprintf(buff, 256, TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT(ccs->hContact));
//MessageBox(0, buff, Translate("OTR Information"), MB_OK);
- ShowMessage((HANDLE)ccs->hContact, buff);
+ ShowMessage(ccs->hContact, buff);
//if(options.timeout_finished) ResetFinishedTimer();
}
diff --git a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp index 7f7987b7b4..6c8f36e85e 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp @@ -5,7 +5,7 @@ BBButton OTRButton; int SVC_IconPressed(WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact = (HANDLE)wParam;
+ HCONTACT hContact = (HCONTACT)wParam;
StatusIconClickData *sicd = (StatusIconClickData *)lParam;
if(sicd->cbSize < (int)sizeof(StatusIconClickData))
return 0;
@@ -21,7 +21,7 @@ int SVC_IconPressed(WPARAM wParam, LPARAM lParam) }
// set SRMM icon status, if applicable
-void SetEncryptionStatus(HANDLE hContact, TrustLevel level)
+void SetEncryptionStatus(HCONTACT hContact, TrustLevel level)
{
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0));
@@ -71,8 +71,8 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) db_set_dw(hContact, MODULENAME, "TrustLevel", level);
if (!chat_room && options.bHaveMetaContacts) {
- HANDLE hMeta = (HANDLE)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
- HANDLE hMostOnline = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hMeta, 0);
+ HCONTACT hMeta = (HCONTACT)CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
+ HCONTACT hMostOnline = (HCONTACT)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hMeta, 0);
if(hMeta && hContact == hMostOnline)
SetEncryptionStatus(hMeta, level);
else if(hMeta) {
@@ -95,7 +95,7 @@ int SVC_ButtonsBarPressed(WPARAM w, LPARAM l) {
CustomButtonClickData* cbcd = (CustomButtonClickData *)l;
if (cbcd->cbSize == (int)sizeof(CustomButtonClickData) && cbcd->dwButtonId == 0 && strcmp(cbcd->pszModule, MODULENAME)==0) {
- HANDLE hContact = (HANDLE)w;
+ HCONTACT hContact = (HCONTACT)w;
char *proto = GetContactProto(hContact);
if(proto && db_get_b(hContact, proto, "ChatRoom", 0))
diff --git a/plugins/MirOTR/MirOTR/src/svcs_srmm.h b/plugins/MirOTR/MirOTR/src/svcs_srmm.h index 4bc204656d..7c8842edc3 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_srmm.h +++ b/plugins/MirOTR/MirOTR/src/svcs_srmm.h @@ -2,6 +2,6 @@ int WindowEvent(WPARAM wParam, LPARAM lParam);
int SVC_IconPressed(WPARAM wParam, LPARAM lParam);
-void SetEncryptionStatus(HANDLE hContact, TrustLevel level);
+void SetEncryptionStatus(HCONTACT hContact, TrustLevel level);
void InitSRMM();
void DeinitSRMM();
\ No newline at end of file diff --git a/plugins/MirOTR/MirOTR/src/utils.cpp b/plugins/MirOTR/MirOTR/src/utils.cpp index d6daabb294..3142c0852e 100644 --- a/plugins/MirOTR/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/MirOTR/src/utils.cpp @@ -2,23 +2,29 @@ CRITICAL_SECTION lib_cs;
-void InitUtils() {
+void InitUtils()
+{
InitializeCriticalSection(&lib_cs);
}
-void DeinitUtils() {
+
+void DeinitUtils()
+{
DeleteCriticalSection(&lib_cs);
}
-void lib_cs_lock() {
+void lib_cs_lock()
+{
EnterCriticalSection(&lib_cs);
}
-void lib_cs_unlock() {
+void lib_cs_unlock()
+{
LeaveCriticalSection(&lib_cs);
}
-HANDLE find_contact(const char* userid, const char* protocol) {
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+HCONTACT find_contact(const char* userid, const char* protocol)
+{
+ for (HCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
const char *proto = contact_get_proto(hContact);
if(proto && strcmp(proto, protocol) == 0) {
char *name = contact_get_id(hContact);
@@ -38,7 +44,7 @@ HANDLE find_contact(const char* userid, const char* protocol) { * context if one does not currently exist. In that event, call
* add_app_data(data, context) so that app_data and app_data_free can be
* filled in by the application, and set *addedp to 1. */
-ConnContext * otrl_context_find_miranda(OtrlUserState us, HANDLE hContact)
+ConnContext * otrl_context_find_miranda(OtrlUserState us, HCONTACT hContact)
{
ConnContext ** curp;
if (!hContact) return NULL;
@@ -78,10 +84,10 @@ void VerifyFingerprint(ConnContext *context, bool verify) { void VerifyFingerprintMessage(ConnContext *context, bool verify) {
TCHAR msg[1024];
- mir_sntprintf(msg, 1024, (verify)?TranslateT(LANG_FINGERPRINT_VERIFIED):TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT((HANDLE)context->app_data));
+ mir_sntprintf(msg, 1024, (verify)?TranslateT(LANG_FINGERPRINT_VERIFIED):TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT((HCONTACT)context->app_data));
msg[1023] = '\0';
- ShowMessage((HANDLE)context->app_data, msg);
- SetEncryptionStatus(context->app_data, otr_context_get_trust(context));
+ ShowMessage((HCONTACT)context->app_data, msg);
+ SetEncryptionStatus((HCONTACT)context->app_data, otr_context_get_trust(context));
}
/* Convert a 20-byte hash value to a 45-byte human-readable value */
@@ -102,7 +108,7 @@ void otrl_privkey_hash_to_humanT(TCHAR human[45], const unsigned char hash[20]) *p = '\0';
}
-char* contact_get_id(HANDLE hContact, bool bNameOnError) {
+char* contact_get_id(HCONTACT hContact, bool bNameOnError) {
char* pszUniqueID = NULL;
CONTACTINFO ci;
ZeroMemory(&ci, sizeof(ci));
@@ -135,21 +141,21 @@ char* contact_get_id(HANDLE hContact, bool bNameOnError) { return pszUniqueID;
}
-__inline const TCHAR* contact_get_nameT(HANDLE hContact) {
+__inline const TCHAR* contact_get_nameT(HCONTACT hContact) {
return (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
}
-__inline const char* contact_get_proto(HANDLE hContact) {
+__inline const char* contact_get_proto(HCONTACT hContact) {
char *uproto = GetContactProto(hContact);
return uproto;
}
-__inline const char* contact_get_account(HANDLE hContact) {
+__inline const char* contact_get_account(HCONTACT hContact) {
char *uacc = (char *)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, (WPARAM)hContact, 0);
return uacc;
}
-void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const HANDLE hContact) {
+void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const HCONTACT hContact) {
if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return;
if ( !options.bHavePopups) {
@@ -157,7 +163,7 @@ void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const HANDLE mir_sntprintf(title, SIZEOF(title), _T("%s Message"), _T(MODULENAME));
if(line1 && line2) {
- int size = _tcslen(line1) + _tcslen(line2) + 3;
+ int size = int(_tcslen(line1) + _tcslen(line2) + 3);
TCHAR *message = new TCHAR[size]; // newline and null terminator
mir_sntprintf(message, size, _T("%s\r\n%s"), line1, line2);
MessageBox( NULL, message, title, MB_OK | MB_ICONINFORMATION );
@@ -214,7 +220,7 @@ void ShowWarning(TCHAR *msg) { switch(disp) {
case ED_POP:
{
- int size = _tcslen(msg) + 515;
+ int size = int(_tcslen(msg) + 515);
message = new TCHAR[size]; // newline and null terminator
mir_sntprintf(message, size, _T("%s\r\n%s"), buffer, msg);
PUShowMessageT(message, SM_WARNING);
@@ -261,7 +267,7 @@ void ShowError(TCHAR *msg) { switch(disp) {
case ED_POP:
{
- int size = _tcslen(msg) + 515;
+ int size = int(_tcslen(msg) + 515);
message = new TCHAR[size]; // newline and null terminator
mir_sntprintf(message, size, _T("%s\r\n%s"), buffer, msg);
PUShowMessageT(message, SM_WARNING);
@@ -291,7 +297,7 @@ void ShowError(TCHAR *msg) { }
-void ShowPopupUtf(const char* line1, const char* line2, int timeout, const HANDLE hContact) {
+void ShowPopupUtf(const char* line1, const char* line2, int timeout, const HCONTACT hContact) {
TCHAR* l1 = (line1) ? mir_utf8decodeT(line1) : NULL;
TCHAR* l2 = (line2) ? mir_utf8decodeT(line2) : NULL;
ShowPopup(l1, l2, timeout, hContact);
@@ -310,7 +316,7 @@ void ShowErrorUtf(char* msg) { if (m) mir_free(m);
}
-void ShowMessageInline(const HANDLE hContact, const TCHAR *msg) {
+void ShowMessageInline(const HCONTACT hContact, const TCHAR *msg) {
TCHAR buff[1024];
mir_sntprintf(buff, 1024, _T("%s%s"), TranslateT(LANG_INLINE_PREFIX), msg);
@@ -324,7 +330,7 @@ void ShowMessageInline(const HANDLE hContact, const TCHAR *msg) { mir_free(utf);
}
-void ShowMessageInlineUtf(const HANDLE hContact, const char *msg) {
+void ShowMessageInlineUtf(const HCONTACT hContact, const char *msg) {
char buff[1024];
mir_snprintf(buff, 1024, "%s%s", Translate(LANG_INLINE_PREFIX), msg);
@@ -335,14 +341,14 @@ void ShowMessageInlineUtf(const HANDLE hContact, const char *msg) { ProtoChainRecvMsg(hContact, &pre);
}
-void ShowMessageUtf(const HANDLE hContact, const char *msg) {
+void ShowMessageUtf(const HCONTACT hContact, const char *msg) {
if(options.msg_inline)
ShowMessageInlineUtf(hContact, msg);
if(options.msg_popup)
ShowPopupUtf(Translate(LANG_OTR_INFO), msg, 0, hContact);
}
-void ShowMessage(const HANDLE hContact, const TCHAR *msg) {
+void ShowMessage(const HCONTACT hContact, const TCHAR *msg) {
if(options.msg_inline)
ShowMessageInline(hContact, msg);
if(options.msg_popup)
@@ -351,7 +357,7 @@ void ShowMessage(const HANDLE hContact, const TCHAR *msg) { /*
-bool GetEncryptionStatus(HANDLE hContact) {
+bool GetEncryptionStatus(HCONTACT hContact) {
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0));
diff --git a/plugins/MirOTR/MirOTR/src/utils.h b/plugins/MirOTR/MirOTR/src/utils.h index 01c1b44f69..1e2a05c9f3 100644 --- a/plugins/MirOTR/MirOTR/src/utils.h +++ b/plugins/MirOTR/MirOTR/src/utils.h @@ -7,8 +7,8 @@ void lib_cs_lock();
void lib_cs_unlock();
-HANDLE find_contact(const char* userid, const char* protocol);
-ConnContext * otrl_context_find_miranda(OtrlUserState us, HANDLE hContact);
+HCONTACT find_contact(const char* userid, const char* protocol);
+ConnContext * otrl_context_find_miranda(OtrlUserState us, HCONTACT hContact);
typedef enum {
TRUST_NOT_PRIVATE,
@@ -22,23 +22,23 @@ void VerifyFingerprintMessage(ConnContext *context, bool verify); void otrl_privkey_hash_to_humanT(TCHAR human[45], const unsigned char hash[20]);
-char* contact_get_id(HANDLE hContact, bool bNameOnError=true);
-__inline const char* contact_get_proto(HANDLE hContact);
-__inline const char* contact_get_account(HANDLE hContact);
-extern __inline const TCHAR* contact_get_nameT(HANDLE hContact);
+char* contact_get_id(HCONTACT hContact, bool bNameOnError=true);
+__inline const char* contact_get_proto(HCONTACT hContact);
+__inline const char* contact_get_account(HCONTACT hContact);
+extern __inline const TCHAR* contact_get_nameT(HCONTACT hContact);
-void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const HANDLE hContact = NULL);
+void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const HCONTACT hContact = NULL);
void ShowWarning(TCHAR* msg);
void ShowError(TCHAR* msg);
-void ShowPopupUtf(const char* line1, const char* line2, int timeout, const HANDLE hContact = NULL);
+void ShowPopupUtf(const char* line1, const char* line2, int timeout, const HCONTACT hContact = NULL);
void ShowWarningUtf(char* msg);
void ShowErrorUtf(char* msg);
-void ShowMessageInline(const HANDLE hContact, const TCHAR *msg);
-void ShowMessageInlineUtf(const HANDLE hContact, const char *msg);
+void ShowMessageInline(const HCONTACT hContact, const TCHAR *msg);
+void ShowMessageInlineUtf(const HCONTACT hContact, const char *msg);
-void ShowMessage(const HANDLE hContact, const TCHAR *msg);
-void ShowMessageUtf(const HANDLE hContact, const char *msg);
+void ShowMessage(const HCONTACT hContact, const TCHAR *msg);
+void ShowMessageUtf(const HCONTACT hContact, const char *msg);
void InitUtils();
void DeinitUtils();
|