Clone
ixen <ixen@copyhandler.com>
committed
on 22 Mar 14
Partial implementation of basic serialization mechanism (part 2) (CH-79).
LoggerImprovements + 5 more
src/ch/ClipboardMonitor.cpp (+24 -5)
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 26 #include "../libchcore/TTaskManager.h"
27 27 #include "../libchcore/TTask.h"
28 28 #include "CfgProperties.h"
29 29 #include "FolderDialog.h"
30 30 #include "ShutdownDlg.h"
31 31
  32 using namespace chcore;
  33
32 34 CClipboardMonitor CClipboardMonitor::S_ClipboardMonitor;
33 35
34 36 CClipboardMonitor::CClipboardMonitor()
35 37 {
36 38 }
37 39
38 40 CClipboardMonitor::~CClipboardMonitor()
39 41 {
40 42         Stop();
41 43 }
42 44
43 45 void CClipboardMonitor::StartMonitor(chcore::TTaskManager* pTasks)
44 46 {
45 47         CClipboardMonitor::S_ClipboardMonitor.Start(pTasks);
46 48 }
47 49
48 50 void CClipboardMonitor::StopMonitor()
49 51 {
50 52         return CClipboardMonitor::S_ClipboardMonitor.Stop();
51 53 }
 
164 166                         SetPropValue<PP_RECENTPATHS>(rConfig, dlg.m_bdData.cvRecent);
165 167
166 168                         SetPropValue<PP_FDEXTENDEDVIEW>(rConfig, dlg.m_bdData.bExtended);
167 169                         SetPropValue<PP_FDWIDTH>(rConfig, dlg.m_bdData.cx);
168 170                         SetPropValue<PP_FDHEIGHT>(rConfig, dlg.m_bdData.cy);
169 171                         SetPropValue<PP_FDSHORTCUTLISTSTYLE>(rConfig, dlg.m_bdData.iView);
170 172                         SetPropValue<PP_FDIGNORESHELLDIALOGS>(rConfig, dlg.m_bdData.bIgnoreDialogs);
171 173                         rConfig.Write();
172 174
173 175                         if(iResult == IDOK)
174 176                         {
175 177                                 // get dest path
176 178                                 CString strData;
177 179                                 dlg.GetPath(strData);
178 180                                 tTaskDefinition.SetDestinationPath(chcore::PathFromString(strData));
179 181
180 182                                 // load resource strings
181 183                                 chcore::SetTaskPropValue<chcore::eTO_AlternateFilenameFormatString_First>(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING));
182 184                                 chcore::SetTaskPropValue<chcore::eTO_AlternateFilenameFormatString_AfterFirst>(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING));
183 185
  186                                 CString strMessage;
  187                                 try
  188                                 {
184 189                                         chcore::TTaskPtr spTask = pData->m_pTasks->CreateTask(tTaskDefinition);
185 190
186 191                                         // write spTask to a file
187 192                                         spTask->Store();
188 193
189 194                                         // start processing
190 195                                         spTask->BeginProcessing();
191 196                                 }
  197                                 catch(const std::exception& e)
  198                                 {
  199                                         strMessage = e.what();
192 200                                 }
193 201
  202                                 if(!strMessage.IsEmpty())
  203                                 {
  204                                         ictranslate::CFormat fmt;
  205
  206                                         fmt.SetFormat(GetResManager().LoadString(IDS_TASK_CREATE_FAILED));
  207                                         fmt.SetParam(_T("%reason"), strMessage);
  208                                         AfxMessageBox(fmt, MB_OK | MB_ICONERROR);
  209                                 }
  210                         }
  211                 }
  212
194 213                 // do we need to check for turning computer off
195 214                 if(uiShutCounter == 0 && GetPropValue<PP_PSHUTDOWNAFTREFINISHED>(GetConfig()))
196 215                 {
197 216                         if(pData->m_pTasks->AreAllFinished())
198 217                         {
199 218                                 TRACE("Shut down windows\n");
200 219                                 bool bShutdown=true;
201 220                                 if (GetPropValue<PP_PTIMEBEFORESHUTDOWN>(GetConfig()) != 0)
202 221                                 {
203 222                                         CShutdownDlg dlg;
204 223                                         dlg.m_iOverallTime = GetPropValue<PP_PTIMEBEFORESHUTDOWN>(GetConfig());
205 224                                         if (dlg.m_iOverallTime < 0)
206 225                                                 dlg.m_iOverallTime=-dlg.m_iOverallTime;
207 226                                         bShutdown=(dlg.DoModal() != IDCANCEL);
208 227                                 }
209 228
210 229                                 SetPropValue<PP_PSHUTDOWNAFTREFINISHED>(GetConfig(), false);
211 230                                 GetConfig().Write();
212 231                                 if(bShutdown)
213 232                                 {