diff options
author | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-06-01 12:58:06 +0000 |
---|---|---|
committer | sje <sje@4f64403b-2f21-0410-a795-97e2b3489a10> | 2007-06-01 12:58:06 +0000 |
commit | 0d47f648dfe4c38ba4405cfaddd124197336f9f6 (patch) | |
tree | d094de930222a6c87e7c3534d52d25faf01189cc /otr/dllmain.cpp | |
parent | 06025766fa8a3f7b2ba0c143c0abf633bde41120 (diff) |
added an option to reset FINISHED sessions back to plaintext automatically
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@194 4f64403b-2f21-0410-a795-97e2b3489a10
Diffstat (limited to 'otr/dllmain.cpp')
-rw-r--r-- | otr/dllmain.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/otr/dllmain.cpp b/otr/dllmain.cpp index eac42dc..708c4ae 100644 --- a/otr/dllmain.cpp +++ b/otr/dllmain.cpp @@ -31,6 +31,7 @@ char private_key_filename[MAX_PATH]; OtrlUserState otr_user_state = 0;
+#define TIMER_ID_CLEAR_FINISHED 0x101
// plugin stuff
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
@@ -493,6 +494,34 @@ void Disconnect(ConnContext *context) { /// Miranda filter plugin stuff
//////////////////////////////////////////////////
+void CALLBACK ClearFinishedSessions(HWND, UINT, UINT, DWORD) {
+ KillTimer(0, TIMER_ID_CLEAR_FINISHED);
+
+ HANDLE hContact;
+ ConnContext *context = otr_user_state->context_root;
+ while(context) {
+ if(context->msgstate == OTRL_MSGSTATE_FINISHED) {
+ hContact = context->app_data;
+
+ char *uproto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ char *uname = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0);
+ if(uproto && uname)
+ otrl_message_disconnect(otr_user_state, &ops, hContact, MODULE, uproto, uname);
+
+ //otrl_context_force_finished(context);
+
+ SetEncryptionStatus(hContact, false);
+
+ }
+ context = context->next;
+ }
+}
+
+void ResetFinishedTimer() {
+ KillTimer(0, TIMER_ID_CLEAR_FINISHED);
+ SetTimer(0, TIMER_ID_CLEAR_FINISHED, DBGetContactSettingDword(0, MODULE, "SessionTimeout", 10000), ClearFinishedSessions);
+}
+
// if it's a protocol going offline, attempt to send terminate session to all contacts of that protocol
// (this would be hooked as the ME_CLIST_STATUSMODECHANGE handler except that event is sent *after* the proto goes offline)
int StatusModeChange(WPARAM wParam, LPARAM lParam) {
@@ -557,6 +586,7 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) { // FINISHED is not 'unencrypted', for e.g. srmm icon (still need to be able to 'stop OTR')
otrl_context_force_finished(context);
+ if(options.timeout_finished) ResetFinishedTimer();
// removed - don't need a popup everytime an OTR user goes offline!
//char buff[512];
@@ -787,6 +817,8 @@ int RecvMessage(WPARAM wParam,LPARAM lParam){ else
ShowPopup(Translate("OTR Information"), buff, 0);
+ if(options.timeout_finished) ResetFinishedTimer();
+
return 1;
}
|