Merge pull request #4676 from jmarshallnz/dont_set_scraper_on_tvshow_on_nfo
[vuplus_xbmc] / xbmc / utils / AsyncFileCopy.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #include "threads/Thread.h"
24 #include "filesystem/File.h"
25
26 class CAsyncFileCopy : public CThread, public XFILE::IFileCallback
27 {
28 public:
29   CAsyncFileCopy();
30   virtual ~CAsyncFileCopy();
31
32   /// \brief  Main routine to copy files from one source to another.
33   /// \return true if successful, and false if it failed or was cancelled.
34   bool Copy(const CStdString &from, const CStdString &to, const CStdString &heading);
35
36   /// \brief callback from CFile::Cache()
37   virtual bool OnFileCallback(void *pContext, int ipercent, float avgSpeed);
38
39 protected:
40   virtual void Process();
41
42 private:
43   /// volatile variables as we access these from both threads
44   volatile int m_percent;      ///< current percentage (0..100)
45   volatile float m_speed;      ///< current speed (in bytes per second)
46   volatile bool m_cancelled;   ///< whether or not we cancelled the operation
47   volatile bool m_running;     ///< whether or not the copy operation is still in progress
48   
49   bool m_succeeded;  ///< whether or not the copy operation was successful
50   CStdString m_from; ///< source URL to copy from
51   CStdString m_to;   ///< destination URL to copy to
52   CEvent m_event;    ///< event to set to force an update
53 };