From 6b6f2b081bbc2aad2e8e7b4f858b86eeb5ce8f6a Mon Sep 17 00:00:00 2001 From: sje Date: Tue, 18 Sep 2007 14:00:16 +0000 Subject: implemented message fragmentation (now works on IRC! woohoo!) git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@335 4f64403b-2f21-0410-a795-97e2b3489a10 --- otr/dllmain.cpp | 36 ++++++++++++++++++++++++---- otr/otr.mdsp | 72 +++++++++++++++++++++++++++---------------------------- otr/otr_private.h | 6 ++--- 3 files changed, 70 insertions(+), 44 deletions(-) diff --git a/otr/dllmain.cpp b/otr/dllmain.cpp index c3f39b3..26a348e 100644 --- a/otr/dllmain.cpp +++ b/otr/dllmain.cpp @@ -474,6 +474,19 @@ extern "C" void otr_gui_log_message(void *opdata, const char *message) { //ShowMessageInline((HANDLE)opdata, message); } +extern "C" int max_message_size(void *opdata, ConnContext *context) { + int s = CallProtoService(context->protocol, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, 0); + return s; +} + +extern "C" const char *account_name(void *opdata, const char *account, const char *protocol) { + return protocol; +} + +extern "C" void account_name_free(void *opdata, const char *account_name) { +} + + OtrlMessageAppOps ops = { otr_gui_policy, otr_gui_create_privkey, @@ -489,7 +502,10 @@ OtrlMessageAppOps ops = { otr_gui_gone_secure, otr_gui_gone_insecure, otr_gui_still_secure, - otr_gui_log_message + otr_gui_log_message, + max_message_size, + account_name, + account_name_free }; void Disconnect(ConnContext *context) { @@ -697,10 +713,22 @@ int OTRSendMessage(WPARAM wParam,LPARAM lParam){ } if(newmessage) { + char *remaining = 0; + ConnContext *context = otrl_context_find(otr_user_state, username, MODULE, proto, FALSE, 0, 0, 0); + + if(context) + otrl_message_fragment_and_send(&ops, ccs->hContact, context, newmessage, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &remaining); + else + remaining = newmessage; + int ret; if(ccs->wParam & PREF_UTF) { - ccs->lParam = (LPARAM)newmessage; + ccs->lParam = (LPARAM)remaining; ret = CallService(MS_PROTO_CHAINSEND, wParam, lParam); + + lib_cs_lock(); + otrl_message_free(newmessage); + lib_cs_unlock(); } else { //MessageBox(0, "Send message - message encoded - decoding UTF-8", "msg", MB_OK); // decode utf8 into unicode message @@ -708,10 +736,10 @@ int OTRSendMessage(WPARAM wParam,LPARAM lParam){ char *text; // forward message - int size = MultiByteToWideChar(CP_UTF8, 0, (const char *)newmessage, -1, 0, 0); + int size = MultiByteToWideChar(CP_UTF8, 0, (const char *)remaining, -1, 0, 0); temp = (wchar_t *)malloc(size * sizeof(wchar_t)); if(!temp) return 1; - MultiByteToWideChar(CP_UTF8, 0, (const char *)newmessage, -1, temp, size); + MultiByteToWideChar(CP_UTF8, 0, (const char *)remaining, -1, temp, size); size = WideCharToMultiByte(code_page, 0, temp, -1, 0, 0, 0, 0); text = (char *)malloc(size); diff --git a/otr/otr.mdsp b/otr/otr.mdsp index 2f7d52e..ce6662e 100644 --- a/otr/otr.mdsp +++ b/otr/otr.mdsp @@ -12,7 +12,7 @@ intermediateFilesDirectory=Debug outputFilesDirectory=Debug compilerPreprocessor=BUILDING_DLL extraCompilerOptions= -compilerIncludeDirectory=c:\msys\local\include\libotr,..\..\include +compilerIncludeDirectory=C:\msys\local\include\libotr,..\..\include noWarning=0 defaultWarning=0 allWarning=1 @@ -50,7 +50,7 @@ intermediateFilesDirectory=Release outputFilesDirectory=Release compilerPreprocessor=BUILDING_DLL extraCompilerOptions= -compilerIncludeDirectory=c:\msys\local\include\libotr,..\..\include +compilerIncludeDirectory=C:\msys\local\include\libotr,..\..\include noWarning=0 defaultWarning=0 allWarning=1 @@ -97,40 +97,38 @@ extraResourceOptions= 1=otr_private.rc 2=resource.rc [Other] -1=libotr\src\auth.c -2=libotr\src\auth.h -3=libotr\src\b64.c -4=libotr\src\b64.h -5=libotr\src\context.c -6=libotr\src\context.h -7=libotr\src\dh.c -8=libotr\src\dh.h -9=libotr\src\mem.c -10=libotr\src\mem.h -11=libotr\src\message.c -12=libotr\src\message.h -13=libotr\src\privkey-t.h -14=libotr\src\privkey.c -15=libotr\src\privkey.h -16=libotr\src\proto.c -17=libotr\src\proto.h -18=libotr\src\serial.h -19=libotr\src\tests.c -20=libotr\src\tlv.c -21=libotr\src\tlv.h -22=libotr\src\userstate.c -23=libotr\src\userstate.h -24=libotr\src\version.h -25=..\..\include\m_protocols.h -26=..\..\include\m_protosvc.h -27=..\..\include\m_message.h -28=..\..\include\m_popup.h -29=..\..\include\m_metacontacts.h -30=..\..\include\m_updater.h -31=..\..\include\m_database.h +1=..\..\..\..\..\..\..\msys\home\sje\libotr\src\auth.c +2=..\..\..\..\..\..\..\msys\home\sje\libotr\src\auth.h +3=..\..\..\..\..\..\..\msys\home\sje\libotr\src\b64.c +4=..\..\..\..\..\..\..\msys\home\sje\libotr\src\b64.h +5=..\..\..\..\..\..\..\msys\home\sje\libotr\src\context.c +6=..\..\..\..\..\..\..\msys\home\sje\libotr\src\context.h +7=..\..\..\..\..\..\..\msys\home\sje\libotr\src\dh.c +8=..\..\..\..\..\..\..\msys\home\sje\libotr\src\dh.h +9=..\..\..\..\..\..\..\msys\home\sje\libotr\src\mem.c +10=..\..\..\..\..\..\..\msys\home\sje\libotr\src\mem.h +11=..\..\..\..\..\..\..\msys\home\sje\libotr\src\message.c +12=..\..\..\..\..\..\..\msys\home\sje\libotr\src\message.h +13=..\..\..\..\..\..\..\msys\home\sje\libotr\src\privkey-t.h +14=..\..\..\..\..\..\..\msys\home\sje\libotr\src\privkey.c +15=..\..\..\..\..\..\..\msys\home\sje\libotr\src\privkey.h +16=..\..\..\..\..\..\..\msys\home\sje\libotr\src\proto.c +17=..\..\..\..\..\..\..\msys\home\sje\libotr\src\proto.h +18=..\..\..\..\..\..\..\msys\home\sje\libotr\src\serial.h +19=..\..\..\..\..\..\..\msys\home\sje\libotr\src\sm.c +20=..\..\..\..\..\..\..\msys\home\sje\libotr\src\sm.h +21=..\..\..\..\..\..\..\msys\home\sje\libotr\src\tests.c +22=..\..\..\..\..\..\..\msys\home\sje\libotr\src\tlv.c +23=..\..\..\..\..\..\..\msys\home\sje\libotr\src\tlv.h +24=..\..\..\..\..\..\..\msys\home\sje\libotr\src\userstate.c +25=..\..\..\..\..\..\..\msys\home\sje\libotr\src\userstate.h +26=..\..\..\..\..\..\..\msys\home\sje\libotr\src\version.h [History] -dllmain.cpp,18082 -options.cpp,2758 -..\..\..\..\..\..\..\msys\home\sje\libotr\src\message.h,9228 -..\..\..\..\..\..\..\msys\home\sje\libotr\src\context.h,1683 +..\..\..\..\..\..\..\msys\home\sje\libotr\src\context.h,1839 +..\..\..\..\..\..\..\msys\home\sje\libotr\src\version.h,0 otr_private.h,171 +..\..\..\..\..\..\..\msys\home\sje\libotr\src\proto.c,1518 +common.h,844 +..\..\..\..\..\..\..\msys\home\sje\libotr\src\proto.h,2 +..\..\..\..\..\..\..\msys\home\sje\libotr\src\message.h,9228 +dllmain.cpp,25215 diff --git a/otr/otr_private.h b/otr/otr_private.h index d0cd189..a25bc82 100644 --- a/otr/otr_private.h +++ b/otr/otr_private.h @@ -3,9 +3,9 @@ /* VERSION DEFINITIONS */ #define VER_MAJOR 0 -#define VER_MINOR 5 -#define VER_RELEASE 8 -#define VER_BUILD 1 +#define VER_MINOR 6 +#define VER_RELEASE 0 +#define VER_BUILD 0 #define __STRINGIZE(x) #x #define VER_STRING __STRINGIZE( VER_MAJOR.VER_MINOR.VER_RELEASE.VER_BUILD ) -- cgit v1.2.3