diff options
Diffstat (limited to 'MirOTR/svcs_proto.cpp')
-rw-r--r-- | MirOTR/svcs_proto.cpp | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/MirOTR/svcs_proto.cpp b/MirOTR/svcs_proto.cpp index d1991fb..c4b193c 100644 --- a/MirOTR/svcs_proto.cpp +++ b/MirOTR/svcs_proto.cpp @@ -2,6 +2,10 @@ #include "svcs_proto.h"
#include "striphtml.h"
#include "entities.h"
+#include <winuser.h>
+#include <sys\stat.h>
+#include <ole.h>
+#include <wtypes.h>
//TODO: Social-Millionaire-Dialoge
INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){
@@ -16,7 +20,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0);
if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) // bypass for metacontacts
- return CallService(MS_PROTO_CHAINSEND, wParam, lParam); + return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
if(!proto || !ccs->hContact) return 1; // error
gcry_error_t err;
@@ -67,7 +71,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ /* Be *sure* not to send out plaintext */
ShowError(TranslateT(LANG_ENCRYPTION_ERROR));
/* should not be needed
- char t[3] = {0, 0, 0}; + char t[3] = {0, 0, 0};
if(ccs->wParam & PREF_UNICODE) { //TODO!! lstrlen(pre->szMessage)+1 ??
if (strlen(oldmessage)) memcpy(oldmessage, t,3 );
} else {
@@ -87,7 +91,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ // 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) {
@@ -102,22 +106,23 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ ccs->lParam = (LPARAM)newmessage;
}
if (otr_context_get_trust(context) >= TRUST_UNVERIFIED) ccs->wParam;
- INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); + INT_PTR ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam);
-/*#ifdef _DEBUG
+#ifdef _DEBUG
if(ccs->wParam & PREF_UNICODE)
- MessageBox(0, (wchar_t *)ccs->lParam, _T("OTR - sending raw message"), MB_OK);
+ MessageBox(0, (const char *)ccs->lParam, _T("OTR - sending raw message"), MB_OK);
else
- MessageBoxA(0, (char *)ccs->lParam, ("OTR - sending raw message"), MB_OK);
- #endif*/
+ MessageBoxA(0, (char *)ccs->lParam, ("OTR - sending raw message"), MB_OK);
+ #endif
// reset to original values
+
ccs->lParam = (LPARAM)oldmessage;
ccs->wParam = oldflags;
otrl_message_free(newmessage);
- return ret; - - }
+ return ret;
+
+ }
return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
@@ -144,7 +149,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ #ifdef _DEBUG
if(pre->flags & PREF_UNICODE)
- MessageBox(0, (wchar_t *)pre->szMessage, _T("OTR - receiving message"), MB_OK);
+ MessageBox(0, (const char *)pre->szMessage, _T("OTR - receiving message"), MB_OK);
else
MessageBoxA(0, (char *)pre->szMessage, ("OTR - receiving message"), MB_OK);
#endif
@@ -195,7 +200,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
if (tlv) {
- /* Notify the user that the other side disconnected. */ + /* Notify the user that the other side disconnected. */
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);
@@ -279,7 +284,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ if (nextMsg != OTRL_SMP_EXPECT4)
otr_abort_smp(context);
else {
- SMPDialogUpdate(context, 100);
+ SMPDialogUpdate(context, 100);
//otrg_dialog_update_smp(context, 1.0);
context->smstate->nextExpected = OTRL_SMP_EXPECT1;
}
@@ -287,7 +292,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ tlv = otrl_tlv_find(tlvs, OTRL_TLV_SMP_ABORT);
if (tlv) {
SMPDialogUpdate(context, 0);
- context->smstate->nextExpected = OTRL_SMP_EXPECT1;
+ context->smstate->nextExpected = OTRL_SMP_EXPECT1;
}
}
}
@@ -295,23 +300,23 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ /* 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
+ * 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}; - char t[3] = {0, 0, 0}; + char t[3] = {0, 0, 0};
+ char t[3] = {0, 0, 0};
if(pre->flags & PREF_UNICODE) { //TODO!! lstrlen(pre->szMessage)+1 ??
if (pre->szMessage && strlen(pre->szMessage)) memcpy(pre->szMessage, t,3 );
} else {
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; + DWORD flags = pre->flags;
/* if(pre->flags & PREF_UTF) {
oldmessage_utf = newmessage;
} else if(pre->flags & PREF_UNICODE) { //TODO!! lstrlen(pre->szMessage)+1 ??
@@ -320,8 +325,8 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ } else {
mir_utf8decode(newmessage, NULL);
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
@@ -360,7 +365,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ otrl_message_free(newmessage);
// if (free) mir_free(oldmessage_utf);
- return ret; + return ret;
}
return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
@@ -370,7 +375,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ * are received. */
void otr_abort_smp(ConnContext *context)
{
- otrl_message_abort_smp(otr_user_state, &ops, context->app_data, context);
+ otrl_message_abort_smp(otr_user_state, &ops, context->app_data, context);
}
/* Start the Socialist Millionaires' Protocol over the current connection,
@@ -379,8 +384,8 @@ void otr_abort_smp(ConnContext *context) void otr_start_smp(ConnContext *context, const char *question,
const unsigned char *secret, size_t secretlen)
{
- otrl_message_initiate_smp_q(otr_user_state, &ops, context->app_data,
- context, question, secret, secretlen);
+ otrl_message_initiate_smp_q(otr_user_state, &ops, context->app_data,
+ context, question, secret, secretlen);
}
/* Continue the Socialist Millionaires' Protocol over the current connection,
@@ -389,5 +394,5 @@ void otr_continue_smp(ConnContext *context, const unsigned char *secret, size_t secretlen)
{
otrl_message_respond_smp(otr_user_state, &ops, context->app_data,
- context, secret, secretlen); + context, secret, secretlen);
}
\ No newline at end of file |