summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-27 07:46:37 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-27 07:46:37 +0300
commit1f4c1f489f05bb135c8df93d40db9bb624be969d (patch)
treebd214f55f5932a60217a848868b9b4cb6fcd9df1
parentc7417593521a2a96442e97508354e32f502bd931 (diff)
key autoexchange implementation started
-rw-r--r--commonheaders.h1
-rw-r--r--init.cpp2
-rw-r--r--main.cpp10
-rw-r--r--new_gpg.rc18
-rw-r--r--options.cpp4
-rw-r--r--resource.h4
-rw-r--r--utilities.cpp12
7 files changed, 42 insertions, 9 deletions
diff --git a/commonheaders.h b/commonheaders.h
index 3670a86..57ba0af 100644
--- a/commonheaders.h
+++ b/commonheaders.h
@@ -65,6 +65,7 @@ using std::fstream;
#include <m_protosvc.h>
#include <m_netlib.h>
#include <m_jabber.h>
+#include <m_icqplus.h>
#include <m_message.h>
#include <m_cluiframes.h>
#include <m_icolib.h>
diff --git a/init.cpp b/init.cpp
index a8fcaf1..f71ebe6 100644
--- a/init.cpp
+++ b/init.cpp
@@ -17,7 +17,7 @@
#include "commonheaders.h"
//global variables
-bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false;
+bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false, bAutoExchange = false;
TCHAR *inopentag = NULL, *inclosetag = NULL, *outopentag = NULL, *outclosetag = NULL, *password = NULL;
list <JabberAccount*> Accounts;
diff --git a/main.cpp b/main.cpp
index 898b672..df6bee9 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1528,6 +1528,16 @@ void InitCheck()
if(MessageBoxA(0, question.c_str(), "Own secret key warning", MB_YESNO) == IDYES)
ShowFirstRunDialog();
}
+ extern bool bAutoExchange;
+ if(bAutoExchange && (ServiceExists(PS_ICQ_ADDCAPABILITY)))
+ {
+ ICQ_CUSTOMCAP cap;
+ cap.cbSize = sizeof(ICQ_CUSTOMCAP);
+ cap.hIcon = 0;
+ strcpy(cap.name, "GPG Key AutoExchange");
+ strcpy(cap.caps, "GPG AutoExchange");
+ CallService(PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap);
+ }
}
void ImportKey()
diff --git a/new_gpg.rc b/new_gpg.rc
index 77e7c52..bd4efbe 100644
--- a/new_gpg.rc
+++ b/new_gpg.rc
@@ -320,8 +320,9 @@ BEGIN
PUSHBUTTON "Browse",IDC_LOG_FILE_SET,119,156,50,14
CONTROL "Use jabber api on Miranda IM >= 0.9 (recomended)",IDC_JABBER_API,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,175,251,10
- LTEXT "Статический",IDC_CURRENT_KEY,48,196,116,8
+ LTEXT "Current key",IDC_CURRENT_KEY,48,196,116,8
CONTROL "Encrypt file transfers",IDC_FILE_TRANSFERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,185,137,10
+ CONTROL "Automatic key exchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,157,137,117,10
END
IDD_OPT_GPG_BIN DIALOGEX 0, 0, 282, 214
@@ -354,6 +355,21 @@ BEGIN
RTEXT "Close:",IDC_STATIC,127,49,23,8
END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_OPT_GPG, DIALOG
+ BEGIN
+ END
+END
+#endif // APSTUDIO_INVOKED
+
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/options.cpp b/options.cpp
index babaad1..948e5ac 100644
--- a/options.cpp
+++ b/options.cpp
@@ -188,6 +188,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
if(bIsMiranda09)
CheckStateLoadDB(hwndDlg, IDC_JABBER_API, "bJabberAPI", 1);
CheckStateLoadDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers", 1);
+ CheckStateLoadDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange", 0);
return TRUE;
}
@@ -389,12 +390,13 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case PSN_APPLY:
{
- extern bool bDebugLog, bJabberAPI, bFileTransfers;
+ extern bool bDebugLog, bJabberAPI, bFileTransfers, bAutoExchange;
bDebugLog = CheckStateStoreDB(hwndDlg, IDC_DEBUG_LOG, "bDebugLog");
if(bDebugLog)
debuglog.init();
bJabberAPI = CheckStateStoreDB(hwndDlg, IDC_JABBER_API, "bJabberAPI");
bFileTransfers = CheckStateStoreDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers");
+ bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange");
{
TCHAR tmp[512];
GetDlgItemText(hwndDlg, IDC_LOG_FILE_EDIT, tmp, 512);
diff --git a/resource.h b/resource.h
index ffe4d05..9bdc8d7 100644
--- a/resource.h
+++ b/resource.h
@@ -70,6 +70,8 @@
#define IDC_FILE_TRANSFERS 1061
#define IDC_REMOVE_FILTERS 1062
#define IDC_GENERATE_RANDOM 1063
+#define IDC_CHECK1 1064
+#define IDC_AUTO_EXCHANGE 1064
// Next default values for new objects
//
@@ -77,7 +79,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1064
+#define _APS_NEXT_CONTROL_VALUE 1065
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/utilities.cpp b/utilities.cpp
index 8b52ce2..4a9fadc 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -282,6 +282,8 @@ int onProtoAck(WPARAM w, LPARAM l)
PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*) ack->lParam;
if(!f)
f = (PROTOFILETRANSFERSTATUS*) ack->hProcess;
+ if(!f)
+ return 0;
switch(ack->result)
{
@@ -289,12 +291,10 @@ int onProtoAck(WPARAM w, LPARAM l)
break;
case ACKRESULT_SUCCESS:
{
- if(sizeof(*f) != sizeof(PROTOFILETRANSFERSTATUS))
- break;
TCHAR *filename = NULL;
- if(f->szCurrentFile)
+ if(f->szCurrentFile && f->szCurrentFile[0])
filename = mir_utf8decodeW(f->szCurrentFile);
- else if(f->tszCurrentFile)
+ else if(f->tszCurrentFile && f->tszCurrentFile[0])
filename = mir_wstrdup(f->tszCurrentFile);
if(!filename)
break;
@@ -811,7 +811,9 @@ void AddHandlers()
{
(*p)->setPrescenseHandler((*p)->getJabberInterface()->Net()->AddPresenceHandler((JABBER_HANDLER_FUNC)PrescenseHandler));
}
-
+ extern bool bAutoExchange;
+ if(bAutoExchange)
+ (*p)->getJabberInterface()->Net()->RegisterFeature(_T("GPG Key Auto Exchange"), _T("Indicates that gpg installed and configured to public key auto exchange (currently implemented in new_gpg Miranda IM plugin)"));
}
}