summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-06-12 02:18:11 +0000
committersje <sje@4f64403b-2f21-0410-a795-97e2b3489a10>2007-06-12 02:18:11 +0000
commit408a0da710805ea5e762fe27a7e799fdf33b89b3 (patch)
tree77052cb9bb7fcfa21ec3195b924e0eba05b6a2e6
parentc8282e792539673d070b197d20e5e61c9dbe0b1d (diff)
added 'end session on window close' option
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@202 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r--otr/dllmain.cpp58
-rw-r--r--otr/options.cpp17
-rw-r--r--otr/options.h2
-rw-r--r--otr/otr.mdsp10
-rw-r--r--otr/otr_private.h4
-rw-r--r--otr/otr_private.rc172
-rw-r--r--otr/resource.h2
-rw-r--r--otr/resource.rc14
8 files changed, 96 insertions, 183 deletions
diff --git a/otr/dllmain.cpp b/otr/dllmain.cpp
index 878688e..d3aad33 100644
--- a/otr/dllmain.cpp
+++ b/otr/dllmain.cpp
@@ -546,6 +546,32 @@ int StatusModeChange(WPARAM wParam, LPARAM lParam) {
return 0;
}
+void FinishSession(HANDLE hContact) {
+ 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 - just bail
+
+ lib_cs_lock();
+ ConnContext *context = otrl_context_find(otr_user_state, uname, MODULE, proto, FALSE, 0, 0, 0);
+
+ if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
+ //otrl_message_disconnect(otr_user_state, &ops, hContact, MODULE, proto, uname);
+ //SetEncryptionStatus(hContact, false);
+
+ // 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];
+ //mir_snprintf(buff, 512, Translate("User '%s' ended encrypted session"), uname);
+ //ShowPopup(Translate("OTR Information"), buff, 0);
+
+ // opdata is hContact
+ }
+ lib_cs_unlock();
+}
+
int SettingChanged(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam;
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
@@ -561,30 +587,8 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) {
const char *proto = cws->szModule;
StatusModeChange((WPARAM)ID_STATUS_OFFLINE, (LPARAM)proto);
return 0;
- } else {
- char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- char *uname = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0);
- if(!proto || !uname) return 0; // error - just bail
-
- lib_cs_lock();
- ConnContext *context = otrl_context_find(otr_user_state, uname, MODULE, proto, FALSE, 0, 0, 0);
-
- if(context && context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
- //otrl_message_disconnect(otr_user_state, &ops, hContact, MODULE, proto, uname);
- //SetEncryptionStatus(hContact, false);
-
- // 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];
- //mir_snprintf(buff, 512, Translate("User '%s' ended encrypted session"), uname);
- //ShowPopup(Translate("OTR Information"), buff, 0);
-
- // opdata is hContact
- }
- lib_cs_unlock();
+ } else if(options.end_offline) {
+ FinishSession(hContact);
}
}
@@ -1092,6 +1096,12 @@ int StopOTR(WPARAM wParam, LPARAM lParam) {
int WindowEvent(WPARAM wParam, LPARAM lParam) {
MessageWindowEventData *mwd = (MessageWindowEventData *)lParam;
+
+ if(mwd->uType == MSG_WINDOW_EVT_CLOSE && options.end_window_close) {
+ FinishSession(mwd->hContact);
+ return 0;
+ }
+
if(mwd->uType != MSG_WINDOW_EVT_OPEN) return 0;
if(!ServiceExists(MS_MSG_MODIFYICON)) return 0;
diff --git a/otr/options.cpp b/otr/options.cpp
index cee195e..4334362 100644
--- a/otr/options.cpp
+++ b/otr/options.cpp
@@ -112,6 +112,9 @@ void LoadOptions() {
options.delete_history = (DBGetContactSettingByte(0, MODULE, "DeleteHistory", 1) == 1);
options.timeout_finished = (DBGetContactSettingByte(0, MODULE, "TimeoutFinished", 0) == 1);
+ options.end_offline = (DBGetContactSettingByte(0, MODULE, "EndOffline", 1) == 1);
+ options.end_window_close = (DBGetContactSettingByte(0, MODULE, "EndWindowClose", 0) == 1);
+
LoadFilenames();
}
@@ -129,6 +132,9 @@ void SaveOptions(ContactPolicyMap *contact_policies) {
DBWriteContactSettingByte(0, MODULE, "DeleteHistory", options.delete_history ? 1 : 0);
DBWriteContactSettingByte(0, MODULE, "TimeoutFinished", options.timeout_finished ? 1 : 0);
+
+ DBWriteContactSettingByte(0, MODULE, "EndOffline", options.end_offline ? 1 : 0);
+ DBWriteContactSettingByte(0, MODULE, "EndWindowClose", options.end_window_close ? 1 : 0);
}
ContactFingerprintMap strlist; // temp storage for fingerprint string pointers
@@ -234,7 +240,10 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
CheckDlgButton(hwndDlg, IDC_CHK_PREFIX, options.prefix_messages ? TRUE : FALSE);
CheckDlgButton(hwndDlg, IDC_CHK_MSGINLINE, options.msg_inline ? TRUE : FALSE);
CheckDlgButton(hwndDlg, IDC_CHK_TIMEFINISH, options.timeout_finished ? TRUE : FALSE);
-
+
+ CheckDlgButton(hwndDlg, IDC_CHK_ENDOFFLINE, options.end_offline ? TRUE : FALSE);
+ CheckDlgButton(hwndDlg, IDC_CHK_ENDCLOSE, options.end_window_close ? TRUE : FALSE);
+
SetDlgItemText(hwndDlg, IDC_ED_PREFIX, options.prefix);
return TRUE;
@@ -355,6 +364,8 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
case IDC_CHK_PREFIX:
case IDC_CHK_TIMEFINISH:
case IDC_CHK_MSGINLINE:
+ case IDC_CHK_ENDOFFLINE:
+ case IDC_CHK_ENDCLOSE:
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
return TRUE;
}
@@ -482,6 +493,10 @@ INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
options.prefix_messages = IsDlgButtonChecked(hwndDlg, IDC_CHK_PREFIX) ? true : false;
options.msg_inline = IsDlgButtonChecked(hwndDlg, IDC_CHK_MSGINLINE) ? true : false;
options.timeout_finished = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEFINISH) ? true : false;
+
+ options.end_offline = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDOFFLINE) ? true : false;
+ options.end_window_close = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDCLOSE) ? true : false;
+
GetDlgItemText(hwndDlg, IDC_ED_PREFIX, options.prefix, 64);
ContactPolicyMap *contact_policies = (ContactPolicyMap *)GetWindowLong(hwndDlg, GWL_USERDATA);
diff --git a/otr/options.h b/otr/options.h
index f4534c8..fbfcb9c 100644
--- a/otr/options.h
+++ b/otr/options.h
@@ -14,6 +14,8 @@ typedef struct {
bool delete_history;
bool timeout_finished;
+
+ bool end_offline, end_window_close;
} Options;
extern Options options;
diff --git a/otr/otr.mdsp b/otr/otr.mdsp
index 608a3cf..d23135d 100644
--- a/otr/otr.mdsp
+++ b/otr/otr.mdsp
@@ -128,11 +128,7 @@ extraResourceOptions=
29=..\..\include\m_metacontacts.h
30=..\..\include\m_updater.h
[History]
-options.cpp,8387
+otr_private.rc,874
+resource.rc,556
+dllmain.cpp,39372
otr_private.h,171
-options.h,256
-libotr\src\message.c,36762
-libotr\src\context.c,7959
-..\..\include\m_message.h,0
-otr_private.rc,74
-dllmain.cpp,14258
diff --git a/otr/otr_private.h b/otr/otr_private.h
index 7514b42..a2a18f5 100644
--- a/otr/otr_private.h
+++ b/otr/otr_private.h
@@ -4,8 +4,8 @@
/* VERSION DEFINITIONS */
#define VER_MAJOR 0
#define VER_MINOR 5
-#define VER_RELEASE 3
-#define VER_BUILD 3
+#define VER_RELEASE 4
+#define VER_BUILD 1
#define __STRINGIZE(x) #x
#define VER_STRING __STRINGIZE( VER_MAJOR.VER_MINOR.VER_RELEASE.VER_BUILD )
diff --git a/otr/otr_private.rc b/otr/otr_private.rc
index 0a51d41..1e7a66f 100644
--- a/otr/otr_private.rc
+++ b/otr/otr_private.rc
@@ -1,150 +1,36 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#define APSTUDIO_HIDDEN_SYMBOLS
-#include "windows.h"
-#undef APSTUDIO_HIDDEN_SYMBOLS
-#include "resource.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (Australia) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_START ICON "start.ico"
-IDI_STOP ICON "stop.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-IDD_OPT1 DIALOGEX 0, 0, 288, 217
-STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
-FONT 8, "MS Shell Dlg", 0, 0, 0x0
-BEGIN
- CONTROL "List1",IDC_CLIST,"SysListView32",LVS_REPORT | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,8,7,271,104
- GROUPBOX "Default Policy",IDC_STATIC,8,140,109,59
- CONTROL "Manual",IDC_RAD_MANUAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,16,150,95,10
- CONTROL "Opportunistic",IDC_RAD_OPP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,16,162,95,10
- CONTROL "Always",IDC_RAD_ALWAYS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,16,174,95,10
- CONTROL "Never",IDC_RAD_NEVER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,16,185,95,10
- LISTBOX IDC_LIST_PROTOS,127,114,152,60,WS_VSCROLL | WS_TABSTOP
- EDITTEXT IDC_ED_FINGERPRINT,127,175,152,12,ES_AUTOHSCROLL | ES_READONLY
- PUSHBUTTON "New Private Key",IDC_BUT_NEWKEY,127,190,152,10,WS_DISABLED
- CONTROL "Prefix:",IDC_CHK_PREFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,115,48,10
- CONTROL "Show start/stop inline",IDC_CHK_MSGINLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,127,110,10
- EDITTEXT IDC_ED_PREFIX,64,114,53,12,ES_AUTOHSCROLL
- CONTROL "Timeout finished sessions automatically (TAKE CARE!)",IDC_CHK_TIMEFINISH,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,35,203,217,10
-END
-
-IDD_GENKEYNOTIFY DIALOG 0, 0, 200, 80
-STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_POPUP | WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_GROUP
-CAPTION "OTR Generating Private Key"
-FONT 8, "MS Shell Dlg"
-BEGIN
- CTEXT "Generating new private key - please wait.",IDC_STATIC,10,35,180,10
-END
+/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
+/* DO NOT EDIT! */
+#include "otr_private.h"
+#include "resource.rc"
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resrc1.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
- "#include ""windows.h""\r\n"
- "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
- "#include ""resource.h""\r\n"
- "\0"
-END
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
//
-// Version
+// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS...
//
-
1 VERSIONINFO
- FILEVERSION 0,5,2,0
- PRODUCTVERSION 0,5,2,0
- FILEFLAGSMASK 0x0L
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x0L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "0C0904E4"
- BEGIN
- VALUE "FileVersion", "VER_MAJOR.VER_MINOR.VER_RELEASE.VER_BUILD"
- VALUE "FileDescription", "OTR (Off-the-Record) plugin for Miranda IM"
- VALUE "LegalCopyright", "© Scott Ellis 2005"
- VALUE "OriginalFilename", "otr.dll"
- VALUE "ProductName", "OTR (Off-the-Record) plugin for Miranda IM"
- VALUE "ProductVersion", "VER_MAJOR.VER_MINOR.VER_RELEASE.VER_BUILD"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0xc09, 1252
- END
-END
-
-#endif // English (Australia) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
+FILEVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD
+PRODUCTVERSION VER_MAJOR,VER_MINOR,VER_RELEASE,VER_BUILD
+FILETYPE VFT_DLL
+{
+ BLOCK "StringFileInfo"
+ {
+ BLOCK "0C0904E4"
+ {
+ VALUE "CompanyName", COMPANY_NAME
+ VALUE "FileVersion", FILE_VERSION
+ VALUE "FileDescription", FILE_DESCRIPTION
+ VALUE "InternalName", INTERNAL_NAME
+ VALUE "LegalCopyright", LEGAL_COPYRIGHT
+ VALUE "LegalTrademarks", LEGAL_TRADEMARKS
+ VALUE "OriginalFilename", ORIGINAL_FILENAME
+ VALUE "ProductName", PRODUCT_NAME
+ VALUE "ProductVersion", PRODUCT_VERSION
+ }
+ }
+ BLOCK "VarFileInfo"
+ {
+ VALUE "Translation", 0x0C09, 1252
+ }
+}
diff --git a/otr/resource.h b/otr/resource.h
index 8b4194c..1ae4cf5 100644
--- a/otr/resource.h
+++ b/otr/resource.h
@@ -12,6 +12,8 @@
#define IDC_CHK_MSGINLINE 1011
#define IDC_ED_PREFIX 1012
#define IDC_CHK_TIMEFINISH 1013
+#define IDC_CHK_ENDOFFLINE 1014
+#define IDC_CHK_ENDCLOSE 1015
#define IDD_GENKEYNOTIFY 102
diff --git a/otr/resource.rc b/otr/resource.rc
index 8e4ee65..170dd38 100644
--- a/otr/resource.rc
+++ b/otr/resource.rc
@@ -43,18 +43,20 @@ IDD_OPT1 DIALOGEX 0, 0, 288, 217
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- CONTROL "List1",IDC_CLIST,"SysListView32",LVS_REPORT | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,8,7,271,112
+ CONTROL "List1",IDC_CLIST,"SysListView32",LVS_REPORT | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,0,0,287,105
GROUPBOX "Default Policy",IDC_STATIC,8,150,109,59
CONTROL "Manual",IDC_RAD_MANUAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,16,160,95,10
CONTROL "Opportunistic",IDC_RAD_OPP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,16,172,95,10
CONTROL "Always",IDC_RAD_ALWAYS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,16,184,95,10
CONTROL "Never",IDC_RAD_NEVER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,16,195,95,10
- LISTBOX IDC_LIST_PROTOS,127,124,152,60,WS_VSCROLL | WS_TABSTOP
+ LISTBOX IDC_LIST_PROTOS,127,125,152,51,WS_VSCROLL | WS_TABSTOP
EDITTEXT IDC_ED_FINGERPRINT,127,185,152,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "New Private Key",IDC_BUT_NEWKEY,127,200,152,10,WS_DISABLED
- CONTROL "Prefix:",IDC_CHK_PREFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,125,48,10
- CONTROL "Show OTR messages inline",IDC_CHK_MSGINLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,137,110,10
- EDITTEXT IDC_ED_PREFIX,64,124,53,12,ES_AUTOHSCROLL
+ CONTROL "End Sessions on window close",IDC_CHK_ENDCLOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,112,117,10
+ CONTROL "End sessions when contacts go offline",IDC_CHK_ENDOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,112,136,10
+ CONTROL "Prefix:",IDC_CHK_PREFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,125,50,10
+ CONTROL "Show OTR messages inline",IDC_CHK_MSGINLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,137,110,10
+ EDITTEXT IDC_ED_PREFIX,61,124,57,12,ES_AUTOHSCROLL
END
IDD_GENKEYNOTIFY DIALOG 0, 0, 200, 80
@@ -74,7 +76,7 @@ END
1 TEXTINCLUDE
BEGIN
- "resrc1.h\0"
+ "resourcec.h\0"
END
2 TEXTINCLUDE