diff options
-rwxr-xr-x | gpg_wrapper.h | 68 | ||||
-rwxr-xr-x | main.cpp | 156 | ||||
-rwxr-xr-x | new_gpg.rc | 31 | ||||
-rwxr-xr-x | options.cpp | 11 | ||||
-rwxr-xr-x | resource.h | 5 | ||||
-rwxr-xr-x | utilities.cpp | 33 |
6 files changed, 225 insertions, 79 deletions
diff --git a/gpg_wrapper.h b/gpg_wrapper.h index 87b5a55..5501297 100755 --- a/gpg_wrapper.h +++ b/gpg_wrapper.h @@ -13,38 +13,38 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -
-
-#ifndef GPG_WRAPPER_H
-#define GPG_WRAPPER_H
-typedef enum {
- pxSuccess,
- pxSuccessExitCodeInvalid,
- pxCreatePipeFailed,
- pxDuplicateHandleFailed,
- pxCloseHandleFailed,
- pxCreateProcessFailed,
- pxThreadWaitFailed,
- pxReadFileFailed,
- pxBufferOverflow,
- pxNotFound,
- pxNotConfigured
-}
-pxResult;
-
-pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result);
-
-struct gpg_execution_params
-{
- wstring *cmd;
- char *useless;
- string *out;
- LPDWORD code;
- pxResult *result;
- HANDLE hProcess;
- PROCESS_INFORMATION *proc;
-};
-
-void pxEexcute_thread(void *param);
-
+ + +#ifndef GPG_WRAPPER_H +#define GPG_WRAPPER_H +typedef enum { + pxSuccess, + pxSuccessExitCodeInvalid, + pxCreatePipeFailed, + pxDuplicateHandleFailed, + pxCloseHandleFailed, + pxCreateProcessFailed, + pxThreadWaitFailed, + pxReadFileFailed, + pxBufferOverflow, + pxNotFound, + pxNotConfigured +} +pxResult; + +pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result); + +struct gpg_execution_params +{ + wstring *cmd; + char *useless; + string *out; + LPDWORD code; + pxResult *result; + HANDLE hProcess; + PROCESS_INFORMATION *proc; +}; + +void pxEexcute_thread(void *param); + #endif
\ No newline at end of file @@ -148,7 +148,27 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM } } } - + { + SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)Translate("Default")); + int count = 0; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&count, &accounts); + for(int i = 0; i < count; i++) + { + if(StriStr(accounts[i]->szModuleName, "metacontacts")) + continue; + if(StriStr(accounts[i]->szModuleName, "weather")) + continue; + SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_ADDSTRING, 0, (LPARAM)accounts[i]->szModuleName); + } + SendMessageA(GetDlgItem(hwndDlg, IDC_ACCOUNT), CB_SELECTSTRING, 0, (LPARAM)Translate("Default"));
+ string keyinfo = Translate("key id");
+ keyinfo += ": ";
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set"); + mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); + } return TRUE; } @@ -201,10 +221,30 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM while((s = out.find("\r", s)) != string::npos) { out.erase(s, 1); + }
+ {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
+ if(!strcmp(buf, Translate("Default"))) + { + DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); + DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyMainName", name); + DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); + } + else + { + char setting[64]; + strcpy(setting, buf); + strcat(setting, "_GPGPubKey"); + DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str()); + strcpy(setting, buf); + strcat(setting, "_KeyMainName"); + DBWriteContactSettingTString(NULL, szGPGModuleName, setting, name); + strcpy(setting, buf); + strcat(setting, "_KeyID"); + DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp); + } } - DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); - DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyMainName", name); - DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); TCHAR passwd[64]; GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, passwd, 64); if(passwd[0]) @@ -217,7 +257,7 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM DBWriteContactSettingTString(NULL, szGPGModuleName, dbsetting.c_str(), passwd); } { - wstring keyinfo = TranslateT("Current private key id"); + wstring keyinfo = TranslateT("Default private key id"); keyinfo += _T(": "); keyinfo += (fp[0])?fp:_T("not set"); extern HWND hwndCurKey_p; @@ -371,13 +411,42 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM } if(result == pxNotFound) break; + }
+ {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63); + if(!strcmp(buf, Translate("Default"))) + { + DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail"); + DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType"); + } + else + { + char setting[64]; + strcpy(setting, buf); + strcat(setting, "_GPGPubKey"); + DBDeleteContactSetting(NULL, szGPGModuleName, setting); + strcpy(setting, buf); + strcat(setting, "_KeyMainName"); + DBDeleteContactSetting(NULL, szGPGModuleName, setting); + strcpy(setting, buf); + strcat(setting, "_KeyID"); + DBDeleteContactSetting(NULL, szGPGModuleName, setting); + strcpy(setting, buf); + strcat(setting, "_KeyComment"); + DBDeleteContactSetting(NULL, szGPGModuleName, setting); + strcpy(setting, buf); + strcat(setting, "_KeyMainEmail"); + DBDeleteContactSetting(NULL, szGPGModuleName, setting); + strcpy(setting, buf); + strcat(setting, "_KeyType"); + DBDeleteContactSetting(NULL, szGPGModuleName, setting); + } } - DBDeleteContactSetting(NULL, szGPGModuleName, "GPGPubKey"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyID"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyComment"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainName"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyMainEmail"); - DBDeleteContactSetting(NULL, szGPGModuleName, "KeyType"); ListView_DeleteItem(hwndList, itemnum); break; case IDC_GENERATE_RANDOM: @@ -479,15 +548,60 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM while((s = out.find("\r", s)) != string::npos) { out.erase(s, 1); + }
+ {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63); + if(!strcmp(buf, Translate("Default"))) + { + DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); + DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); + } + else + { + char setting[64]; + strcpy(setting, buf); + strcat(setting, "_GPGPubKey"); + DBWriteContactSettingString(NULL, szGPGModuleName, setting, out.c_str()); + strcpy(setting, buf); + strcat(setting, "_KeyID"); + DBWriteContactSettingTString(NULL, szGPGModuleName, setting, fp); + } } - DBWriteContactSettingString(NULL, szGPGModuleName, "GPGPubKey", out.c_str()); - DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", path.c_str()); extern HWND hwndCurKey_p; SetWindowText(hwndCurKey_p, path.c_str()); } } DestroyWindow(hwndDlg); break; + case IDC_ACCOUNT: + {
+ char buf[64];
+ GetDlgItemTextA(hwndDlg, IDC_ACCOUNT, buf, 63);
+ if(!strcmp(buf, Translate("Default")))
+ {
+ string keyinfo = Translate("key id");
+ keyinfo += ": ";
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
+ mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); + } + else + { + string keyinfo = Translate("key id");
+ keyinfo += ": ";
+ char setting[64];
+ strcpy(setting, buf);
+ strcat(setting, "_KeyID");
+ char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, "");
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
+ mir_free(keyid); + SetDlgItemTextA(hwndDlg, IDC_KEY_ID, keyinfo.c_str()); + } + } + break; + } break; } @@ -502,12 +616,16 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM itemnum = hdr->iItem; } } -// switch (((LPNMHDR)lParam)->code) - // { -// default: -// break; - -// } +/* switch(LOWORD(wParam)) + { + default: + break; + }; */ +/* switch (((LPNMHDR)lParam)->code) + { + default: + break; + } */ } break; case WM_CLOSE: @@ -63,21 +63,24 @@ BEGIN PUSHBUTTON "Import key from keyserver",IDC_IMPORT,140,152,188,14,WS_DISABLED
END
-IDD_FIRST_RUN DIALOGEX 0, 0, 291, 205
+IDD_FIRST_RUN DIALOGEX 0, 0, 291, 230
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Set own key"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "خت",ID_OK,12,184,50,14,WS_DISABLED
- CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,23,277,105
- PUSHBUTTON "Generate key",IDC_GENERATE_KEY,8,131,74,14
- LTEXT "Select key for use",IDC_STATIC,16,12,186,8
- EDITTEXT IDC_KEY_PASSWORD,94,147,77,14,ES_PASSWORD | ES_AUTOHSCROLL
- RTEXT "Key password:",IDC_STATIC,12,149,76,8
- PUSHBUTTON "Load other",IDC_OTHER,83,131,64,14
- PUSHBUTTON "Delete key",IDC_DELETE_KEY,149,131,70,14
- PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,99,163,118,14
- LTEXT "",IDC_GENERATING_KEY,82,186,174,8
+ DEFPUSHBUTTON "خت",ID_OK,12,209,50,14,WS_DISABLED
+ CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,44,277,105
+ PUSHBUTTON "Generate key",IDC_GENERATE_KEY,8,152,74,14
+ LTEXT "Select key for use",IDC_STATIC,16,33,186,8
+ EDITTEXT IDC_KEY_PASSWORD,94,168,77,14,ES_PASSWORD | ES_AUTOHSCROLL
+ RTEXT "Key password:",IDC_STATIC,12,170,76,8
+ PUSHBUTTON "Load other",IDC_OTHER,83,152,64,14
+ PUSHBUTTON "Delete key",IDC_DELETE_KEY,149,152,70,14
+ PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,99,184,118,14
+ LTEXT "",IDC_GENERATING_KEY,82,207,174,8
+ LTEXT "Account:",IDC_STATIC,15,12,42,8
+ LTEXT "key id: ",IDC_KEY_ID,178,12,99,8
+ COMBOBOX IDC_ACCOUNT,66,9,104,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
IDD_BIN_PATH DIALOGEX 0, 0, 354, 108
@@ -190,8 +193,10 @@ BEGIN BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 284
+ VERTGUIDE, 15
TOPMARGIN, 7
- BOTTOMMARGIN, 198
+ BOTTOMMARGIN, 223
+ HORZGUIDE, 20
END
IDD_BIN_PATH, DIALOG
@@ -323,7 +328,7 @@ 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 "Current key",IDC_CURRENT_KEY,12,196,110,8
+ LTEXT "Default key",IDC_CURRENT_KEY,12,196,110,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,163,137,111,10
PUSHBUTTON "Copy own key",IDC_COPY_KEY,127,193,74,14
diff --git a/options.cpp b/options.cpp index fb2da74..109d54c 100755 --- a/options.cpp +++ b/options.cpp @@ -199,10 +199,10 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_JABBER_API), bIsMiranda09);
EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), (bIsMiranda09 && bJabberAPI));
{
- string keyinfo = Translate("Current private key id");
+ string keyinfo = Translate("Default private key id");
keyinfo += ": ";
char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- keyinfo += (strlen(keyid) > 0)?keyid:"not set";
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
mir_free(keyid);
SetDlgItemTextA(hwndDlg, IDC_CURRENT_KEY, keyinfo.c_str());
}
@@ -792,7 +792,6 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP SetDlgItemText(hwndDlg, IDC_ENABLE_ENCRYPTION, TranslateW(_T("Turn on encryption")));
CheckDlgButton(hwndDlg, IDC_ENABLE_ENCRYPTION, 1);
}
-// RegisterHotKey(hwndDlg, 2, MOD_CONTROL | MOD_NOREPEAT, 0x41);
if(hcnt)
{
tmp = UniGetContactSettingUtf(hcnt, szGPGModuleName, "GPGPubKey", _T(""));
@@ -1374,12 +1373,6 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP DBWriteContactSettingDword(NULL, szGPGModuleName, "LoadKeyWindowY", load_key_rect.top);
}
break;
-/* case WM_HOTKEY:
- {
- if(wParam == 2)
- PostMessage(GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT), EM_SETSEL, 0, -1);
- } */
- break;
}
return FALSE;
@@ -80,6 +80,9 @@ #define IDC_PRESCENSE_SUBSCRIPTION 1068
#define IDC_GENERATING_KEY 1069
#define IDC_GENERATING_TEXT 1070
+#define IDC_KEY_ID 1071
+#define IDC_COMBO1 1072
+#define IDC_ACCOUNT 1072
// Next default values for new objects
//
@@ -87,7 +90,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 114
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1071
+#define _APS_NEXT_CONTROL_VALUE 1073
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/utilities.cpp b/utilities.cpp index 6b2261d..2207213 100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -195,8 +195,23 @@ int SendKey(WPARAM w, LPARAM l) HANDLE hContact = (HANDLE)w; if(metaIsProtoMetaContacts(hContact)) hContact = metaGetMostOnline(hContact); - char *szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); - if(strlen(szMessage) > 1) + char *szMessage; + { + char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char setting[64]; + if(proto) + { + strcpy(setting, proto); + strcat(setting, "_GPGPubKey"); + szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, ""); + } + if(!szMessage[0]) + { + mir_free(szMessage); + szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); + } + } + if(szMessage[0]) { BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -746,7 +761,19 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU DWORD code; wstring cmd; { - char *inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + char *inkeyid; + { + char *proto = ji->Sys()->GetModuleName(); + char setting[64]; + strcpy(setting, proto); + strcat(setting, "_KeyID"); + inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, ""); + if(!inkeyid[0]) + { + mir_free(inkeyid); + inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + } + } TCHAR *pass = NULL; if(inkeyid[0]) { |