diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-09-18 14:00:16 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-09-18 14:00:16 +0000 |
commit | 6b6f2b081bbc2aad2e8e7b4f858b86eeb5ce8f6a (patch) | |
tree | 0f4b085e20302f254d043cdc515229b15a883a23 /otr/dllmain.cpp | |
parent | cde7d73147a7eca584e8ab938b965e49bb2947df (diff) |
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
Diffstat (limited to 'otr/dllmain.cpp')
-rw-r--r-- | otr/dllmain.cpp | 36 |
1 files changed, 32 insertions, 4 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);
|