ReactOS  0.4.14-dev-358-gbef841c
CZipPassword.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Zip Shell Extension
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Ask the user for a password
5  * COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
10 class CZipPassword : public CDialogImpl<CZipPassword>
11 {
12 private:
15 public:
18  {
19  if (filename != NULL)
21  }
22 
24  {
26 
27  /* No filename, so this is the question before starting to extract */
28  if (m_Filename.IsEmpty())
29  {
33  }
34  else
35  {
36  /* Our CString does not support FormatMessage yet */
39 
40  DWORD_PTR args[2] =
41  {
43  NULL
44  };
45 
47  message, 0, 0, (LPSTR)&formatted, 0, (va_list*)args);
48 
50  }
51  return TRUE;
52  }
53 
54  LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
55  {
56  if (wID == IDOK)
57  {
62  }
63  EndDialog(wID);
64  return 0;
65  }
66 
67 public:
68  enum { IDD = IDD_PASSWORD };
69 
75  END_MSG_MAP()
76 };
77 
79 {
80  if (filename)
83  INT_PTR Result = password.DoModal(hDlg);
84  switch (Result)
85  {
86  case IDOK: return eAccept;
87  case IDSKIP: return eSkip;
88  default:
89  case IDCANCEL: return eAbort;
90  }
91 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
BOOL EndDialog(_In_ int nRetCode)
Definition: atlwin.h:1450
CStringA * m_pPassword
#define DWORD_PTR
Definition: treelist.c:76
eZipPasswordResponse _CZipAskPassword(HWND hDlg, const char *filename, CStringA &Password)
CStringA m_Filename
#define SW_HIDE
Definition: winuser.h:762
LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
BOOL WINAPI SetDlgItemTextA(_In_ HWND, _In_ int, _In_ LPCSTR)
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
DWORD WINAPI FormatMessageA(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:483
GLenum GLuint GLenum GLsizei const GLchar * message
Definition: glext.h:5579
#define IDC_MESSAGE
Definition: resource.h:22
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:62
char * LPSTR
Definition: xmlstorage.h:182
const char * filename
Definition: ioapi.h:135
Definition: match.c:390
WPARAM wParam
Definition: combotst.c:138
CZipPassword(const char *filename, CStringA *Password)
#define IDS_PASSWORD_ZIP_TEXT
Definition: resource.h:52
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
Definition: precomp.h:63
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG_PTR LPARAM
Definition: windef.h:208
char * va_list
Definition: acmsvcex.h:78
#define COMMAND_ID_HANDLER(id, func)
Definition: atlwin.h:1825
HWND GetDlgItem(int nID)
Definition: atlwin.h:571
int WINAPI GetWindowTextLengthA(_In_ HWND)
#define END_MSG_MAP()
Definition: atlwin.h:1789
PCXSTR GetString() const
Definition: atlsimpstr.h:361
BOOL CenterWindow(HWND hWndCenter=NULL)
Definition: atlwin.h:309
unsigned short WORD
Definition: ntddk_ex.h:93
T1_FIELD_DICT_PRIVATE password
Definition: t1tokens.h:64
GLenum GLsizei len
Definition: glext.h:6722
HWND m_hWnd
Definition: atlwin.h:268
LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
uint32_t DWORD_PTR
Definition: typedefs.h:63
UINT WINAPI GetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount)
Definition: dialog.c:2244
#define IDS_PASSWORD_FILE_TEXT
Definition: resource.h:51
bool IsEmpty() const
Definition: atlsimpstr.h:379
#define IDSKIP
Definition: resource.h:25
static ATOM item
Definition: dde.c:856
BOOL ShowWindow(int nCmdShow)
Definition: atlwin.h:1265
unsigned int UINT
Definition: ndis.h:50
eZipPasswordResponse
Definition: precomp.h:60
#define BEGIN_MSG_MAP(theClass)
Definition: atlwin.h:1770
#define MESSAGE_HANDLER(msg, func)
Definition: atlwin.h:1798
Definition: precomp.h:62
CWindow GetParent() const
Definition: atlwin.h:654
LPSTR WINAPI PathFindFileNameA(LPCSTR lpszPath)
Definition: path.c:368
#define IDCANCEL
Definition: winuser.h:825
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define IDC_PASSWORD
Definition: resource.h:12
#define IDD_PASSWORD
Definition: resource.h:24