Clone
ixen <ixen@copyhandler.com>
committed
on 07 Nov 11
Moved CTask and CTaskArray classes to the libchcore library.
LoggerImprovements + 5 more
src/ch/ClipboardMonitor.cpp (+4 -5)
6 6 //   it under the terms of the GNU Library General Public License
7 7 //   (version 2) as published by the Free Software Foundation;
8 8 //
9 9 //   This program is distributed in the hope that it will be useful,
10 10 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12 //   GNU General Public License for more details.
13 13 //
14 14 //   You should have received a copy of the GNU Library General Public
15 15 //   License along with this program; if not, write to the
16 16 //   Free Software Foundation, Inc.,
17 17 //   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 18 //
19 19 /// @file ClipboardMonitor.cpp
20 20 /// @brief Contains the implementation of clipboard monitor package.
21 21 //******************************************************************************
22 22 #include "stdafx.h"
23 23 #include "../libchcore/TWorkerThreadController.h"
24 24 #include "ClipboardMonitor.h"
25 25 #include "ch.h"
26   #include "task.h"
  26 #include "../libchcore/task.h"
27 27 #include "CfgProperties.h"
28 28 #include "FolderDialog.h"
29   #include "task.h"
30 29 #include "ShutdownDlg.h"
31 30
32 31 CClipboardMonitor CClipboardMonitor::S_ClipboardMonitor;
33 32
34 33 CClipboardMonitor::CClipboardMonitor()
35 34 {
36 35 }
37 36
38 37 CClipboardMonitor::~CClipboardMonitor()
39 38 {
40 39         Stop();
41 40 }
42 41
43   void CClipboardMonitor::StartMonitor(CTaskArray* pTasks)
  42 void CClipboardMonitor::StartMonitor(chcore::CTaskArray* pTasks)
44 43 {
45 44         CClipboardMonitor::S_ClipboardMonitor.Start(pTasks);
46 45 }
47 46
48 47 void CClipboardMonitor::StopMonitor()
49 48 {
50 49         return CClipboardMonitor::S_ClipboardMonitor.Stop();
51 50 }
52 51
53   void CClipboardMonitor::Start(CTaskArray* pTasks)
  52 void CClipboardMonitor::Start(chcore::CTaskArray* pTasks)
54 53 {
55 54         m_pTasks = pTasks;
56 55
57 56         m_threadWorker.StartThread(&CClipboardMonitor::ClipboardMonitorProc, this);
58 57 }
59 58
60 59 void CClipboardMonitor::Stop()
61 60 {
62 61         m_threadWorker.StopThread();
63 62 }
64 63
65 64 DWORD WINAPI CClipboardMonitor::ClipboardMonitorProc(LPVOID pParam)
66 65 {
67 66         CClipboardMonitor* pData = (CClipboardMonitor*)pParam;
68 67
69 68         // bufor
70 69         TCHAR path[_MAX_PATH];
71 70
72 71         // register clipboard format
73 72         UINT nFormat=RegisterClipboardFormat(_T("Preferred DropEffect"));
 
164 163                         SetPropValue<PP_RECENTPATHS>(rConfig, dlg.m_bdData.cvRecent);
165 164
166 165                         SetPropValue<PP_FDEXTENDEDVIEW>(rConfig, dlg.m_bdData.bExtended);
167 166                         SetPropValue<PP_FDWIDTH>(rConfig, dlg.m_bdData.cx);
168 167                         SetPropValue<PP_FDHEIGHT>(rConfig, dlg.m_bdData.cy);
169 168                         SetPropValue<PP_FDSHORTCUTLISTSTYLE>(rConfig, dlg.m_bdData.iView);
170 169                         SetPropValue<PP_FDIGNORESHELLDIALOGS>(rConfig, dlg.m_bdData.bIgnoreDialogs);
171 170                         rConfig.Write();
172 171
173 172                         if(iResult == IDOK)
174 173                         {
175 174                                 // get dest path
176 175                                 CString strData;
177 176                                 dlg.GetPath(strData);
178 177                                 tTaskDefinition.SetDestinationPath(chcore::PathFromString(strData));
179 178
180 179                                 // load resource strings
181 180                                 chcore::SetTaskPropValue<chcore::eTO_AlternateFilenameFormatString_First>(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING));
182 181                                 chcore::SetTaskPropValue<chcore::eTO_AlternateFilenameFormatString_AfterFirst>(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING));
183 182
184                                   CTaskPtr spTask = pData->m_pTasks->CreateTask(tTaskDefinition);
  183                                 chcore::CTaskPtr spTask = pData->m_pTasks->CreateTask(tTaskDefinition);
185 184
186 185                                 // write spTask to a file
187 186                                 spTask->Store();
188 187
189 188                                 // start processing
190 189                                 spTask->BeginProcessing();
191 190                         }
192 191                 }
193 192
194 193                 // do we need to check for turning computer off
195 194                 if(uiShutCounter == 0 && GetPropValue<PP_PSHUTDOWNAFTREFINISHED>(GetConfig()))
196 195                 {
197 196                         if(pData->m_pTasks->AreAllFinished())
198 197                         {
199 198                                 TRACE("Shut down windows\n");
200 199                                 bool bShutdown=true;
201 200                                 if (GetPropValue<PP_PTIMEBEFORESHUTDOWN>(GetConfig()) != 0)
202 201                                 {
203 202                                         CShutdownDlg dlg;
204 203                                         dlg.m_iOverallTime = GetPropValue<PP_PTIMEBEFORESHUTDOWN>(GetConfig());