diff options
Diffstat (limited to 'otr/dllmain.cpp')
-rw-r--r-- | otr/dllmain.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
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);
|