From 30d7e221818b5646e018489342fa577073e42948 Mon Sep 17 00:00:00 2001 From: sje Date: Mon, 18 Jun 2007 12:19:29 +0000 Subject: 'end session on window close' option really ends session, rather than changing to finished state git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@204 4f64403b-2f21-0410-a795-97e2b3489a10 --- otr/dllmain.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'otr/dllmain.cpp') diff --git a/otr/dllmain.cpp b/otr/dllmain.cpp index d3aad33..bddefee 100644 --- a/otr/dllmain.cpp +++ b/otr/dllmain.cpp @@ -572,6 +572,21 @@ void FinishSession(HANDLE hContact) { lib_cs_unlock(); } +void EndSession(HANDLE hContact) { + HANDLE hSub; + if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) { + hContact = hSub; + } + + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *uname = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0); + if(!proto || !uname) return; // error + + lib_cs_lock(); + otrl_message_disconnect(otr_user_state, &ops, hContact, MODULE, proto, uname); + lib_cs_unlock(); +} + int SettingChanged(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; @@ -1060,25 +1075,15 @@ int StartOTR(WPARAM wParam, LPARAM lParam) { } int StopOTR(WPARAM wParam, LPARAM lParam) { - - // prevent this filter from acting on injeceted messages for metas, when they are passed though the subcontact's proto send chain - HANDLE hContact = (HANDLE)wParam, hSub; - if(ServiceExists(MS_MC_GETMOSTONLINECONTACT) && (hSub = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) != 0) { - hContact = hSub; - } + HANDLE hContact = (HANDLE)wParam; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); - char *uname = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0); - if(!proto || !uname) return 1; // error - - lib_cs_lock(); - otrl_message_disconnect(otr_user_state, &ops, hContact, MODULE, proto, uname); - lib_cs_unlock(); + // prevent this filter from acting on injeceted messages for metas, when they are passed though the subcontact's proto send chain + EndSession(hContact); SetEncryptionStatus(hContact, false); char buff[256]; - mir_snprintf(buff, 256, Translate("OTR session terminated"), uname); + mir_snprintf(buff, 256, Translate("OTR session terminated"), (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0)); //MessageBox(0, buff, Translate("OTR Information"), MB_OK); if(options.msg_inline) ShowMessageInline(hContact, buff); -- cgit v1.2.3