OSDN Git Service

Add option "send mail after create patch" at formatpatch dialog
authorFrank Li <lznuaa@gmail.com>
Sat, 18 Apr 2009 14:46:34 +0000 (22:46 +0800)
committerFrank Li <lznuaa@gmail.com>
Sat, 18 Apr 2009 14:46:34 +0000 (22:46 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/Commands/FormatPatchCommand.cpp
src/TortoiseProc/Commands/SendMailCommand.cpp
src/TortoiseProc/FormatPatchDlg.cpp
src/TortoiseProc/FormatPatchDlg.h
src/TortoiseProc/ProgressDlg.cpp
src/TortoiseProc/ProgressDlg.h
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/resource.h

index 299d3d8..098d40c 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 0f676e7..e826845 100644 (file)
@@ -43,6 +43,8 @@
 #include "ResetDlg.h"\r
 #include "DeleteConflictDlg.h"\r
 #include "ChangedDlg.h"\r
+#include "SendMailDlg.h"\r
+#include "SVNProgressDlg.h"\r
 \r
 CAppUtils::CAppUtils(void)\r
 {\r
@@ -1940,4 +1942,43 @@ CString CAppUtils::ChooseRepository(CString *path)
                return CString();\r
        }\r
        \r
+}\r
+\r
+bool CAppUtils::SendPatchMail(CTGitPathList &list,bool autoclose)\r
+{\r
+       CSendMailDlg dlg;\r
+\r
+       dlg.m_PathList  = list;\r
+       \r
+       if(dlg.DoModal()==IDOK)\r
+       {\r
+               if(dlg.m_PathList.GetCount() == 0)\r
+                       return FALSE;\r
+       \r
+               CGitProgressDlg progDlg;\r
+               \r
+               theApp.m_pMainWnd = &progDlg;\r
+               progDlg.SetCommand(CGitProgressDlg::GitProgress_SendMail);\r
+                               \r
+               progDlg.SetAutoClose(autoclose);\r
+\r
+               progDlg.SetPathList(dlg.m_PathList);\r
+                               //ProjectProperties props;\r
+                               //props.ReadPropsPathList(dlg.m_pathList);\r
+                               //progDlg.SetProjectProperties(props);\r
+               progDlg.SetItemCount(dlg.m_PathList.GetCount());\r
+\r
+               DWORD flags =0;\r
+               if(dlg.m_bAttachment)\r
+                       flags |= SENDMAIL_ATTACHMENT;\r
+               if(dlg.m_bCombine)\r
+                       flags |= SENDMAIL_COMBINED;\r
+\r
+               progDlg.SetSendMailOption(dlg.m_To,dlg.m_CC,dlg.m_Subject,flags);\r
+               \r
+               progDlg.DoModal();              \r
+\r
+               return true;\r
+       }\r
+       return false;\r
 }
\ No newline at end of file
index 9df5e58..dbac9b3 100644 (file)
@@ -193,6 +193,8 @@ public:
 \r
        static CString GetClipboardLink();\r
        static CString ChooseRepository(CString *path);\r
+\r
+       static bool SendPatchMail(CTGitPathList &pathlist,bool autoclose=false);\r
        \r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
index cb1cf1e..f5e7cb2 100644 (file)
@@ -27,6 +27,7 @@
 #include "ShellUpdater.h"\r
 \r
 #include "ProgressDlg.h"\r
+#include "AppUtils.h"\r
 \r
 bool FormatPatchCommand::Execute()\r
 {\r
@@ -62,6 +63,31 @@ bool FormatPatchCommand::Execute()
                CShellUpdater::Instance().AddPathForUpdate(CTGitPath(dlg.m_Dir));\r
                CShellUpdater::Instance().Flush();\r
                \r
+               if(!progress.m_GitStatus)\r
+               {\r
+                       if(dlg.m_bSendMail)\r
+                       {\r
+                               CTGitPathList list;\r
+                               CString log=progress.m_LogText;\r
+                               int start=log.Find(cmd);\r
+                               if(start >=0)\r
+                                       CString one=log.Tokenize(_T("\n"),start);\r
+\r
+                               while(start>=0)\r
+                               {\r
+                                       CString one=log.Tokenize(_T("\n"),start);\r
+                                       one=one.Trim();\r
+                                       if(one.IsEmpty())\r
+                                               continue;\r
+                                       one.Replace(_T('/'),_T('\\'));\r
+                                       CTGitPath path;\r
+                                       path.SetFromWin(one);\r
+                                       list.AddPath(path);\r
+                               }\r
+\r
+                               CAppUtils::SendPatchMail(list);\r
+                       }\r
+               }\r
                return !progress.m_GitStatus;\r
        }\r
        return FALSE;\r
index e7d7300..3b538a2 100644 (file)
@@ -2,43 +2,13 @@
 #include "SendMailCommand.h"\r
 #include "SendMailDlg.h"\r
 #include "SVNProgressDlg.h"\r
+#include "AppUtils.h"\r
 \r
 bool SendMailCommand::Execute()\r
 {\r
-       CSendMailDlg dlg;\r
+       bool autoclose=false;\r
+       if (parser.HasVal(_T("closeonend")))\r
+               autoclose=parser.GetLongVal(_T("closeonend"));\r
 \r
-       dlg.m_PathList  = orgPathList;\r
-       \r
-       if(dlg.DoModal()==IDOK)\r
-       {\r
-               if(dlg.m_PathList.GetCount() == 0)\r
-                       return FALSE;\r
-       \r
-               CGitProgressDlg progDlg;\r
-               \r
-               theApp.m_pMainWnd = &progDlg;\r
-               progDlg.SetCommand(CGitProgressDlg::GitProgress_SendMail);\r
-                               \r
-               if (parser.HasVal(_T("closeonend")))\r
-                               progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
-               \r
-               progDlg.SetPathList(dlg.m_PathList);\r
-                               //ProjectProperties props;\r
-                               //props.ReadPropsPathList(dlg.m_pathList);\r
-                               //progDlg.SetProjectProperties(props);\r
-               progDlg.SetItemCount(dlg.m_PathList.GetCount());\r
-\r
-               DWORD flags =0;\r
-               if(dlg.m_bAttachment)\r
-                       flags |= SENDMAIL_ATTACHMENT;\r
-               if(dlg.m_bCombine)\r
-                       flags |= SENDMAIL_COMBINED;\r
-\r
-               progDlg.SetSendMailOption(dlg.m_To,dlg.m_CC,dlg.m_Subject,flags);\r
-               \r
-               progDlg.DoModal();              \r
-\r
-               return true;\r
-       }\r
-       return false;\r
+       return CAppUtils::SendPatchMail(this->orgPathList,autoclose);\r
 }
\ No newline at end of file
index 50f4176..5b613fd 100644 (file)
 IMPLEMENT_DYNAMIC(CFormatPatchDlg, CResizableStandAloneDialog)\r
 \r
 CFormatPatchDlg::CFormatPatchDlg(CWnd* pParent /*=NULL*/)\r
-       : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent)\r
+       : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent),\r
+       m_regSendMail(_T("Software\\TortoiseGit\\TortoiseProc\\FormatPatch\\SendMail"),0)\r
 {\r
        m_Num=1;\r
+       this->m_bSendMail = m_regSendMail;\r
 }\r
 \r
 CFormatPatchDlg::~CFormatPatchDlg()\r
@@ -36,7 +38,7 @@ void CFormatPatchDlg::DoDataExchange(CDataExchange* pDX)
        DDX_Text(pDX, IDC_COMBOBOXEX_FROM,      m_From);\r
        DDX_Text(pDX, IDC_COMBOBOXEX_TO,        m_To);\r
        \r
-\r
+       DDX_Check(pDX, IDC_CHECK_SENDMAIL, m_bSendMail);\r
 }\r
 \r
 \r
@@ -68,6 +70,10 @@ BOOL CFormatPatchDlg::OnInitDialog()
 \r
        AddAnchor(IDC_BUTTON_FROM,  TOP_RIGHT);\r
        AddAnchor(IDC_BUTTON_TO,        TOP_RIGHT);\r
+       AddAnchor(IDC_CHECK_SENDMAIL,BOTTOM_LEFT);\r
+       AddAnchor(IDOK,BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
+\r
        this->AddOthersToAnchor();\r
 \r
        m_cDir.SetPathHistory(TRUE);\r
@@ -127,6 +133,8 @@ void CFormatPatchDlg::OnBnClickedOk()
        m_cTo.SaveHistory();\r
        this->UpdateData(TRUE);\r
        this->m_Radio=GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
+\r
+       m_regSendMail=this->m_bSendMail;\r
        OnOK();\r
 }\r
 \r
index 8f12238..e008749 100644 (file)
@@ -2,6 +2,7 @@
 \r
 #include "StandAloneDlg.h"\r
 #include "HistoryCombo.h"\r
+#include "Registry.h"\r
 \r
 // CFormatPatchDlg dialog\r
 \r
@@ -25,6 +26,7 @@ protected:
        CHistoryCombo m_cFrom;\r
        CHistoryCombo m_cTo;\r
        CEdit             m_cNum;\r
+       CRegDWORD       m_regSendMail;\r
 \r
        DECLARE_MESSAGE_MAP()\r
 public:\r
@@ -34,6 +36,7 @@ public:
        CString m_To;\r
        CString m_Since;\r
        int m_Radio;\r
+    BOOL m_bSendMail;\r
 \r
        afx_msg void OnBnClickedButtonDir();\r
        afx_msg void OnBnClickedButtonFrom();\r
index e1a86dd..a0c65f8 100644 (file)
@@ -36,6 +36,7 @@ void CProgressDlg::DoDataExchange(CDataExchange* pDX)
 \r
 BEGIN_MESSAGE_MAP(CProgressDlg, CResizableStandAloneDialog)\r
        ON_MESSAGE(MSG_PROGRESSDLG_UPDATE_UI, OnProgressUpdateUI)\r
+       ON_BN_CLICKED(IDOK, &CProgressDlg::OnBnClickedOk)\r
 END_MESSAGE_MAP()\r
 \r
 BOOL CProgressDlg::OnInitDialog()\r
@@ -229,3 +230,10 @@ void CProgressDlg::RemoveLastLine(CString &str)
        return;\r
 }\r
 // CProgressDlg message handlers\r
+\r
+void CProgressDlg::OnBnClickedOk()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       m_Log.GetWindowText(this->m_LogText);\r
+       OnOK();\r
+}\r
index ffedb50..4b89b7e 100644 (file)
@@ -34,6 +34,7 @@ public:
        DWORD                     m_GitStatus;\r
        BOOL              m_bShowCommand;       // whether to display the command in the log window (default true)\r
        CString           m_PreText;            // optional text to show in log window before running command\r
+       CString           m_LogText;\r
 protected:\r
        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
        static UINT ProgressThreadEntry(LPVOID pVoid);\r
@@ -45,6 +46,8 @@ protected:
 \r
        LRESULT CProgressDlg::OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);\r
 \r
-       CString         m_LogText;\r
+       \r
        DECLARE_MESSAGE_MAP()\r
+public:\r
+       afx_msg void OnBnClickedOk();\r
 };\r
index 5c94fe9..1e25935 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\copy.ico"\r
+                               RelativePath=".\copy.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\copy.ico"\r
+                               RelativePath="..\Resources\copy.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\refresh.ico"\r
+                               RelativePath=".\refresh.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\refresh.ico"\r
+                               RelativePath="..\Resources\refresh.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
index e295fc9..5d7c368 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ