summaryrefslogtreecommitdiff
path: root/plugins/MirOTR
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-03-13 20:13:35 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-03-13 20:13:35 +0000
commit728d1db9e6f7c093047c2cb3ed63175d3433d66b (patch)
tree39692e505de9e01bb5b3039407356bc8d5638615 /plugins/MirOTR
parent05a22b41b1a4090b87fe427df9ec3edaaa1f86e7 (diff)
MirOTR:
- Removed option "Timeout FINISHED sessions back to PLAINTEXT (TAKE CARE!)" (too dangerous, didn't work anyways) (fixes #867) - Fixed option "End sessions when contacts go offline" (fixes #867) - Fixed hang on HTML stripping with some buggy clients like Pidgin (fixes #904, #456) - minor code cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@12397 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR')
-rw-r--r--plugins/MirOTR/MirOTR/res/resource.rc2
-rw-r--r--plugins/MirOTR/MirOTR/src/dbfilter.cpp2
-rw-r--r--plugins/MirOTR/MirOTR/src/language.h10
-rw-r--r--plugins/MirOTR/MirOTR/src/mirotrmenu.cpp10
-rw-r--r--plugins/MirOTR/MirOTR/src/options.cpp7
-rw-r--r--plugins/MirOTR/MirOTR/src/options.h2
-rw-r--r--plugins/MirOTR/MirOTR/src/resource.h1
-rw-r--r--plugins/MirOTR/MirOTR/src/striphtml.cpp17
-rw-r--r--plugins/MirOTR/MirOTR/src/svcs_proto.cpp324
9 files changed, 177 insertions, 198 deletions
diff --git a/plugins/MirOTR/MirOTR/res/resource.rc b/plugins/MirOTR/MirOTR/res/resource.rc
index 4ceb13e11a..d6cb4a330f 100644
--- a/plugins/MirOTR/MirOTR/res/resource.rc
+++ b/plugins/MirOTR/MirOTR/res/resource.rc
@@ -72,8 +72,6 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,130,265,10
CONTROL "Show OTR system messages as popup",IDC_CHK_MSGPOPUP,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,142,265,10
- CONTROL "Timeout FINISHED sessions back to PLAINTEXT (TAKE CARE!)",IDC_CHK_TIMEFINISH,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,154,265,10
CONTROL "Show verification dialog when receiving unverified fingerprint",IDC_CHK_AUTOSHOW_VERIFY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,166,265,10
END
diff --git a/plugins/MirOTR/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/MirOTR/src/dbfilter.cpp
index 4def70e5e8..81a5e00000 100644
--- a/plugins/MirOTR/MirOTR/src/dbfilter.cpp
+++ b/plugins/MirOTR/MirOTR/src/dbfilter.cpp
@@ -299,6 +299,8 @@ int StatusModeChange(WPARAM wParam, LPARAM lParam) {
int OnContactSettingChanged(WPARAM hContact, LPARAM lParam)
{
+ if (!options.end_offline)
+ return 0;
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
if (!lParam || strcmp(cws->szSetting, "Status") != 0) return 0;
int status=0;
diff --git a/plugins/MirOTR/MirOTR/src/language.h b/plugins/MirOTR/MirOTR/src/language.h
index 2dbcc117ae..cadf0b510d 100644
--- a/plugins/MirOTR/MirOTR/src/language.h
+++ b/plugins/MirOTR/MirOTR/src/language.h
@@ -12,11 +12,11 @@
#define LANG_STATUS_PRIVATE LPGEN("OTR Encryption: Private")
#define LANG_STATUS_FINISHED LPGEN("OTR Encryption: Finished")
-#define LANG_MENU_START LPGEN("&Start OTR session")
-#define LANG_MENU_REFRESH LPGEN("&Refresh OTR session")
-#define LANG_MENU_STOP LPGEN("Sto&p OTR session")
-#define LANG_MENU_VERIFY LPGEN("&Verify Fingerprint")
-#define LANG_MENU_TOGGLEHTML LPGEN("&Convert HTML (for Pidgin)")
+#define LANG_MENU_START LPGENT("&Start OTR session")
+#define LANG_MENU_REFRESH LPGENT("&Refresh OTR session")
+#define LANG_MENU_STOP LPGENT("Sto&p OTR session")
+#define LANG_MENU_VERIFY LPGENT("&Verify Fingerprint")
+#define LANG_MENU_TOGGLEHTML LPGENT("&Convert HTML (for Pidgin)")
#define LANG_SESSION_TERMINATED_OTR LPGEN("OTR encrypted session with '%s' has been terminated")
#define LANG_SESSION_REQUEST_OTR LPGEN("Requesting OTR encrypted session with '%s'")
diff --git a/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp
index d446e8b57f..99f7ba25ae 100644
--- a/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp
+++ b/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp
@@ -218,35 +218,35 @@ void InitMirOTRMenu(void)
hStatusInfoItem = (HGENMENU) AddMirOTRMenuItem(0, (LPARAM) &mi);
mi.flags = CMIF_TCHAR | CMIF_NOTPRIVATE | CMIF_NOTUNVERIFIED;
- mi.ptszName = _T(LANG_MENU_START);
+ mi.ptszName = LANG_MENU_START;
mi.position = 100001;
mi.pszService = MS_OTR_MENUSTART;
mi.icolibItem = GetIconHandle(ICON_UNVERIFIED);
AddMirOTRMenuItem(0, (LPARAM) &mi);
mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED;
- mi.ptszName = _T(LANG_MENU_REFRESH);
+ mi.ptszName = LANG_MENU_REFRESH;
mi.position = 100002;
mi.pszService = MS_OTR_MENUREFRESH;
mi.icolibItem = GetIconHandle(ICON_FINISHED);
AddMirOTRMenuItem(0, (LPARAM) &mi);
mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE;
- mi.ptszName = _T(LANG_MENU_STOP);
+ mi.ptszName = LANG_MENU_STOP;
mi.position = 100003;
mi.pszService = MS_OTR_MENUSTOP;
mi.icolibItem = GetIconHandle(ICON_NOT_PRIVATE);
AddMirOTRMenuItem(0, (LPARAM) &mi);
mi.flags = CMIF_TCHAR | CMIF_NOTNOTPRIVATE | CMIF_NOTFINISHED;
- mi.ptszName = _T(LANG_MENU_VERIFY);
+ mi.ptszName = LANG_MENU_VERIFY;
mi.position = 200001;
mi.pszService = MS_OTR_MENUVERIFY;
mi.icolibItem = GetIconHandle(ICON_PRIVATE);
AddMirOTRMenuItem(0, (LPARAM) &mi);
mi.flags = CMIF_TCHAR|CMIF_CHECKED;
- mi.ptszName = _T(LANG_MENU_TOGGLEHTML);
+ mi.ptszName = LANG_MENU_TOGGLEHTML;
mi.position = 300001;
mi.pszService = MS_OTR_MENUTOGGLEHTML;
hHTMLConvMenuItem = (HGENMENU) AddMirOTRMenuItem(0, (LPARAM) &mi);
diff --git a/plugins/MirOTR/MirOTR/src/options.cpp b/plugins/MirOTR/MirOTR/src/options.cpp
index 34550f9608..0fa2586d40 100644
--- a/plugins/MirOTR/MirOTR/src/options.cpp
+++ b/plugins/MirOTR/MirOTR/src/options.cpp
@@ -84,8 +84,6 @@ void LoadOptions() {
} else
strcpy(options.prefix, ("OTR: "));
- options.timeout_finished = (db_get_b(0, MODULENAME, "TimeoutFinished", 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);
@@ -149,8 +147,6 @@ void SaveOptions() {
db_set_utf(0, MODULENAME, "Prefix", options.prefix);
- db_set_b(0, MODULENAME, "TimeoutFinished", options.timeout_finished ? 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);
}
@@ -195,7 +191,6 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam,
CheckDlgButton(hwndDlg, IDC_CHK_PREFIX, options.prefix_messages ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_MSGINLINE, options.msg_inline ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_MSGPOPUP, options.msg_popup ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_TIMEFINISH, options.timeout_finished ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_PREVENTSAVE, options.delete_history ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_PREVENTSYSSAVE, options.delete_systeminfo ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_AUTOSHOW_VERIFY, options.autoshow_verify ? BST_CHECKED : BST_UNCHECKED);
@@ -220,7 +215,6 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case IDC_CHK_PREFIX:
case IDC_CHK_MSGINLINE:
case IDC_CHK_MSGPOPUP:
- case IDC_CHK_TIMEFINISH:
case IDC_CHK_PREVENTSAVE:
case IDC_CHK_AUTOSHOW_VERIFY:
case IDC_CHK_ENDOFFLINE:
@@ -252,7 +246,6 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam,
options.prefix_messages = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_PREFIX));
options.msg_inline = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_MSGINLINE));
options.msg_popup = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_MSGPOPUP));
- options.timeout_finished = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEFINISH));
options.delete_history = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_PREVENTSAVE));
options.delete_systeminfo = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_PREVENTSYSSAVE));
options.autoshow_verify = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_AUTOSHOW_VERIFY));
diff --git a/plugins/MirOTR/MirOTR/src/options.h b/plugins/MirOTR/MirOTR/src/options.h
index 6f85c382d8..772d0c5d45 100644
--- a/plugins/MirOTR/MirOTR/src/options.h
+++ b/plugins/MirOTR/MirOTR/src/options.h
@@ -20,8 +20,6 @@ typedef struct {
bool msg_inline;
bool msg_popup;
char prefix[OPTIONS_PREFIXLEN];
-
- bool timeout_finished;
bool delete_history;
bool delete_systeminfo;
diff --git a/plugins/MirOTR/MirOTR/src/resource.h b/plugins/MirOTR/MirOTR/src/resource.h
index 1d55dbec38..3b117f8699 100644
--- a/plugins/MirOTR/MirOTR/src/resource.h
+++ b/plugins/MirOTR/MirOTR/src/resource.h
@@ -23,7 +23,6 @@
#define IDC_CHK_MSGPOPUP 1059
#define IDC_CHK_PREVENTSAVE 1060
#define IDC_CHK_AUTOSHOW_VERIFY 1061
-#define IDC_CHK_TIMEFINISH 1062
#define IDC_CHK_ENDOFFLINE 1063
#define IDC_CHK_ENDCLOSE 1064
#define IDC_CHK_PREVENTSYSSAVE 1065
diff --git a/plugins/MirOTR/MirOTR/src/striphtml.cpp b/plugins/MirOTR/MirOTR/src/striphtml.cpp
index bcf0a4b894..c1dbb0cd55 100644
--- a/plugins/MirOTR/MirOTR/src/striphtml.cpp
+++ b/plugins/MirOTR/MirOTR/src/striphtml.cpp
@@ -7,15 +7,13 @@ void starttag_cb (void *cbdata, ekhtml_string_t *tag, ekhtml_attr_t *attrs) {
switch (*(tag->str)) {
case 'a':
case 'A':
- {
- ekhtml_attr_t *attr = attrs;
- while (attr) {
+ for(ekhtml_attr_t *attr=attrs; attr; attr=attr->next) {
if (_strnicmp(attr->name.str, "href", attr->name.len)==0) {
data->stack.push(strncpy((char*)mir_calloc(attr->val.len+1), attr->val.str, attr->val.len));
break;
}
}
- }break;
+ break;
case 'i':
case 'I':
data->buffer.append(" *");
@@ -31,14 +29,13 @@ void starttag_cb (void *cbdata, ekhtml_string_t *tag, ekhtml_attr_t *attrs) {
break;
case 3:
if (_strnicmp(tag->str, "img", 3) == 0) {
- ekhtml_attr_t *attr = attrs;
data->buffer.append("IMAGE [ ");
- while (attr) {
- if (_strnicmp(attr->name.str, "src", attr->name.len)==0) {
- data->buffer.append(attr->val.str, attr->val.len);
- break;
- }
+ for(ekhtml_attr_t *attr=attrs; attr; attr=attr->next) {
+ if (_strnicmp(attr->name.str, "src", attr->name.len)==0) {
+ data->buffer.append(attr->val.str, attr->val.len);
+ break;
}
+ }
data->buffer.append(" ] ");
}
break;
diff --git a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp
index 78fc63744e..99592f354b 100644
--- a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp
+++ b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp
@@ -18,8 +18,6 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
if (!proto || !ccs->hContact)
return 1; // error
- gcry_error_t err;
- char *newmessage = 0;
char *oldmessage = (char *)ccs->lParam;
char *oldmessage_utf = 0;
@@ -27,12 +25,14 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
if(ccs->wParam & PREF_UTF) {
oldmessage_utf = oldmessage;
- } else if(ccs->wParam & PREF_UNICODE) {
+ }
+ else if(ccs->wParam & PREF_UNICODE) {
//TODO: check if this is correct or oldmessage[strlen(oldmessage)+1] is needed
//oldmessage_utf = mir_utf8encodeW((wchar_t*)oldmessage);
//should be the thing with strlen
oldmessage_utf = mir_utf8encodeW((wchar_t*)&oldmessage[strlen(oldmessage)+1]);
- } else {
+ }
+ else {
oldmessage_utf = mir_utf8encode(oldmessage);
}
if (!oldmessage_utf) return 1;
@@ -40,67 +40,64 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
// don't filter OTR messages being sent (OTR messages should only happen *after* the otrl_message_sending call below)
if(strncmp(oldmessage_utf, "?OTR", 4) == 0) {
DEBUGOUT_T("OTR message without PREF_BYPASS_OTR")
- if (!(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf);
+ if (!(ccs->wParam & PREF_UTF))
+ mir_free(oldmessage_utf);
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
char *tmpencode = NULL;
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);
+ tmpencode = encode_html_entities_utf8(oldmessage_utf);
if (tmpencode != NULL) {
if (!(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf);
oldmessage_utf = tmpencode;
}
}
-
+
+ char *newmessage = 0;
char *username = contact_get_id(ccs->hContact);
- err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact,
+ gcry_error_t err = otrl_message_sending(otr_user_state, &ops, (void*)ccs->hContact,
proto, proto, username, oldmessage_utf, NULL, &newmessage,
add_appdata, (void*)ccs->hContact);
- if (tmpencode!= NULL || !(ccs->wParam & PREF_UTF)) mir_free(oldmessage_utf);
+ if (tmpencode!= NULL || !(ccs->wParam & PREF_UTF))
+ mir_free(oldmessage_utf);
oldmessage_utf = NULL;
mir_free(username);
- if (err && newmessage == NULL) {
- /* Be *sure* not to send out plaintext */
- ShowError(TranslateT(LANG_ENCRYPTION_ERROR));
- /* should not be needed
- char t[3] = {0, 0, 0};
- if(ccs->wParam & PREF_UNICODE) { //TODO!! mir_tstrlen(pre->szMessage)+1 ??
- if (strlen(oldmessage)) memcpy(oldmessage, t,3 );
- } else {
- if (strlen(oldmessage)) memcpy(oldmessage, t, 1);
- }
- */
- return 1;
- } else if (newmessage) {
- /* Fragment the message if necessary, and send all but the last
- * fragment over the network. We will send the last segment later */
+ if (err && newmessage == NULL) {
+ /* Be *sure* not to send out plaintext */
+ ShowError(TranslateT(LANG_ENCRYPTION_ERROR));
+ return 1;
+ }
+ else if (newmessage) {
+ /* Fragment the message if necessary, and send all but the last
+ * fragment over the network. We will send the last segment later */
- // oldmessage_utf is not used anymore, so use it as buffer
- err = otrl_message_fragment_and_send(&ops, (void*)ccs->hContact, context,
- newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &oldmessage_utf);
- // newmessage is not needed anymore
- otrl_message_free(newmessage);
- // move the last fragment to newmessage, oldmessage_utf will be buffer later
- newmessage = oldmessage_utf;
+ // oldmessage_utf is not used anymore, so use it as buffer
+ err = otrl_message_fragment_and_send(&ops, (void*)ccs->hContact, context,
+ newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &oldmessage_utf);
+ // newmessage is not needed anymore
+ otrl_message_free(newmessage);
+ // move the last fragment to newmessage, oldmessage_utf will be buffer later
+ newmessage = oldmessage_utf;
- WPARAM oldflags = ccs->wParam;
+ WPARAM oldflags = ccs->wParam;
if(ccs->wParam & PREF_UTF) {
ccs->lParam = (LPARAM)newmessage;
- } else if(ccs->wParam & PREF_UNICODE) {
+ }
+ else if(ccs->wParam & PREF_UNICODE) {
// just send UTF, hope that proto supports it.
// don't want to create the Unicode-Format
// oldmessage_utf = (char*)mir_utf8decodeW(newmessage);
ccs->lParam = (LPARAM)newmessage;
ccs->wParam &= ~PREF_UNICODE;
ccs->wParam |= PREF_UTF;
- } else {
+ }
+ else {
mir_utf8decode(newmessage, NULL);
ccs->lParam = (LPARAM)newmessage;
}
- if (otr_context_get_trust(context) >= TRUST_UNVERIFIED) ccs->wParam;
INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
#ifdef _DEBUG
@@ -112,17 +109,14 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
}
else
MessageBoxA(0, (char *)ccs->lParam, ("OTR - sending raw message"), MB_OK);
- #endif
+#endif
- // reset to original values
-
- ccs->lParam = (LPARAM)oldmessage;
+ // reset to original values
+ ccs->lParam = (LPARAM)oldmessage;
ccs->wParam = oldflags;
otrl_message_free(newmessage);
return ret;
-
}
-
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
@@ -158,7 +152,8 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){
else if(proto && strcmp(proto, META_PROTO) == 0) // bypass for metacontacts
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
- if (!ccs->hContact) return 1; //error
+ if (!ccs->hContact)
+ return 1; //error
char *oldmessage = pre->szMessage;
char *oldmessage_utf = NULL;
@@ -175,39 +170,34 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){
char *newmessage = NULL;
OtrlTLV *tlvs = NULL;
- OtrlTLV *tlv = NULL;
- BOOL ignore_msg;
- ConnContext *context;
- //NextExpectedSMP nextMsg;
char *uname = contact_get_id(ccs->hContact);
lib_cs_lock();
- ignore_msg = otrl_message_receiving(otr_user_state, &ops, (void*)ccs->hContact,
- proto, proto, uname, oldmessage_utf,
- &newmessage, &tlvs, add_appdata, (void*)ccs->hContact);
+ BOOL ignore_msg = otrl_message_receiving(otr_user_state, &ops, (void*)ccs->hContact,
+ proto, proto, uname, oldmessage_utf,
+ &newmessage, &tlvs, add_appdata, (void*)ccs->hContact);
lib_cs_unlock();
mir_free(uname);
- if ( !(pre->flags & PREF_UTF)) mir_free(oldmessage_utf);
+ if ( !(pre->flags & PREF_UTF))
+ mir_free(oldmessage_utf);
oldmessage_utf = NULL;
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
+ OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
if (tlv && !Miranda_Terminated()) {
/* Notify the user that the other side disconnected. */
TCHAR buff[256];
mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT(ccs->hContact));
//MessageBox(0, buff, Translate("OTR Information"), MB_OK);
ShowMessage(ccs->hContact, buff);
+ }
- //if(options.timeout_finished) ResetFinishedTimer();
- }
-
- lib_cs_lock();
- context = otrl_context_find_miranda(otr_user_state, ccs->hContact);
+ lib_cs_lock();
+ ConnContext *context = otrl_context_find_miranda(otr_user_state, ccs->hContact);
lib_cs_unlock();
/* Keep track of our current progress in the Socialist Millionaires'
- * Protocol. */
+ * Protocol. */
/*
if (context && ( (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) ||
@@ -223,82 +213,82 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){
*/
- if (context) {
- NextExpectedSMP nextMsg = context->smstate->nextExpected;
+ if (context) {
+ NextExpectedSMP nextMsg = context->smstate->nextExpected;
- if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
- otr_abort_smp(context);
- //otrg_dialog_update_smp(context, 0.0);
- SMPDialogUpdate(context, 0);
+ if (context->smstate->sm_prog_state == OTRL_SMP_PROG_CHEATED) {
+ otr_abort_smp(context);
+ //otrg_dialog_update_smp(context, 0.0);
+ SMPDialogUpdate(context, 0);
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ context->smstate->sm_prog_state = OTRL_SMP_PROG_OK;
+ }
+ else {
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1Q);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT1)
+ otr_abort_smp(context);
+ else {
+ char *question = (char *)tlv->data;
+ char *eoq = (char*)memchr(question, '\0', tlv->len);
+ if (eoq) {
+ SMPDialogReply(context, question);
+ }
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT1)
+ otr_abort_smp(context);
+ else {
+ SMPDialogReply(context, NULL);
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT2)
+ otr_abort_smp(context);
+ else {
+ context->smstate->nextExpected = OTRL_SMP_EXPECT4;
+ SMPDialogUpdate(context, 60);
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT3)
+ otr_abort_smp(context);
+ else {
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ SMPDialogUpdate(context, 100);
+ //otrg_dialog_update_smp(context, 1.0);
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
+ if (tlv) {
+ if (nextMsg != OTRL_SMP_EXPECT4)
+ otr_abort_smp(context);
+ else {
+ SMPDialogUpdate(context, 100);
+ //otrg_dialog_update_smp(context, 1.0);
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
- context->smstate->sm_prog_state = OTRL_SMP_PROG_OK;
- } else {
-
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1Q);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT1)
- otr_abort_smp(context);
- else {
- char *question = (char *)tlv->data;
- char *eoq = (char*)memchr(question, '\0', tlv->len);
- if (eoq) {
- SMPDialogReply(context, question);
- }
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP1);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT1)
- otr_abort_smp(context);
- else {
- SMPDialogReply(context, NULL);
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP2);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT2)
- otr_abort_smp(context);
- else {
- context->smstate->nextExpected = OTRL_SMP_EXPECT4;
- SMPDialogUpdate(context, 60);
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP3);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT3)
- otr_abort_smp(context);
- else {
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
- SMPDialogUpdate(context, 100);
- //otrg_dialog_update_smp(context, 1.0);
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP4);
- if (tlv) {
- if (nextMsg != OTRL_SMP_EXPECT4)
- otr_abort_smp(context);
- else {
- SMPDialogUpdate(context, 100);
- //otrg_dialog_update_smp(context, 1.0);
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
- }
- }
- tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
- if (tlv) {
- SMPDialogUpdate(context, 0);
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
- }
- }
- }
+ }
+ }
+ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
+ if (tlv) {
+ SMPDialogUpdate(context, 0);
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ }
+ }
+ }
otrl_tlv_free(tlvs);
/* If we're supposed to ignore this incoming message (because it's a
* protocol message), set it to NULL, so that other plugins that
* catch receiving-im-msg don't return 0, and cause it to be
* displayed anyway. */
- if (ignore_msg) {
- /* should not be required ;)
- char t[3] = {0, 0, 0};
+ if (ignore_msg) {
+ /* should not be required ;)
+ char t[3] = {0, 0, 0};
char t[3] = {0, 0, 0};
if(pre->flags & PREF_UNICODE) { //TODO!! mir_tstrlen(pre->szMessage)+1 ??
if (pre->szMessage && strlen(pre->szMessage)) memcpy(pre->szMessage, t,3 );
@@ -306,11 +296,13 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){
if (pre->szMessage && strlen(pre->szMessage)) memcpy(pre->szMessage, t, 1);
}
*/
- if (newmessage) otrl_message_free(newmessage);
- return 1;
- } else if (newmessage) {
- //bool free=false;
- DWORD flags = pre->flags;
+ if (newmessage)
+ otrl_message_free(newmessage);
+ return 1;
+ }
+ else if (newmessage) {
+ //bool free=false;
+ DWORD flags = pre->flags;
/* if(pre->flags & PREF_UTF) {
oldmessage_utf = newmessage;
} else if(pre->flags & PREF_UNICODE) { //TODO!! mir_tstrlen(pre->szMessage)+1 ??
@@ -321,45 +313,45 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){
oldmessage_utf = newmessage;
} */
- //pre->szMessage = oldmessage_utf;
- pre->flags &= ~PREF_UNICODE;
- pre->flags |= PREF_UTF; // just use UTF, so we do not have to recode the message
+ //pre->szMessage = oldmessage_utf;
+ pre->flags &= ~PREF_UNICODE;
+ pre->flags |= PREF_UTF; // just use UTF, so we do not have to recode the message
- bool is_miralloc = false;
- if (context) {
- TrustLevel level = otr_context_get_trust(context);
- if (level >= TRUST_UNVERIFIED) {
- char* premsg;
- if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0)) {
- premsg = striphtml(newmessage);
- otrl_message_free(newmessage);
- newmessage = premsg;
- is_miralloc = true;
- }
+ bool is_miralloc = false;
+ if (context) {
+ TrustLevel level = otr_context_get_trust(context);
+ if (level >= TRUST_UNVERIFIED) {
+ char *premsg;
+ if (db_get_b(ccs->hContact, MODULENAME, "HTMLConv", 0)) {
+ premsg = striphtml(newmessage);
+ otrl_message_free(newmessage);
+ newmessage = premsg;
+ is_miralloc = true;
+ }
- if (options.prefix_messages) {
- size_t len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char);
- premsg = (char*)mir_alloc( len );
- memset(premsg, 0, len);
- strcpy(premsg, options.prefix);
- strcat(premsg, newmessage);
- (is_miralloc) ? mir_free(newmessage) : otrl_message_free(newmessage);
- newmessage = premsg;
- is_miralloc = true;
- }
- }
- }
- pre->szMessage = newmessage;
- BOOL ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam);
- pre->flags = flags;
- pre->szMessage = oldmessage;
- if (is_miralloc)
- mir_free(newmessage);
- else
- otrl_message_free(newmessage);
+ if (options.prefix_messages) {
+ size_t len = (strlen(options.prefix)+strlen(newmessage)+1)*sizeof(char);
+ premsg = (char*)mir_alloc( len );
+ memset(premsg, 0, len);
+ strcpy(premsg, options.prefix);
+ strcat(premsg, newmessage);
+ (is_miralloc) ? mir_free(newmessage) : otrl_message_free(newmessage);
+ newmessage = premsg;
+ is_miralloc = true;
+ }
+ }
+ }
+ pre->szMessage = newmessage;
+ BOOL ret = CallService(MS_PROTO_CHAINRECV, wParam, lParam);
+ pre->flags = flags;
+ pre->szMessage = oldmessage;
+ if (is_miralloc)
+ mir_free(newmessage);
+ else
+ otrl_message_free(newmessage);
- // if (free) mir_free(oldmessage_utf);
- return ret;
+ // if (free) mir_free(oldmessage_utf);
+ return ret;
}
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);