1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license that can
* be found in the License.html file in the root of the source tree.
*/
#ifndef WORKERFILES_H
#define WORKERFILES_H
#include <map>
#include <vector>
#include <string>
#include <QThread>
#include <QMutex>
class QTimer;
namespace MediaConch {
class FileRegistered;
class MainWindow;
class DatabaseUi;
class WorkerFiles : public QThread
{
Q_OBJECT
public:
explicit WorkerFiles(MainWindow* m);
virtual ~WorkerFiles();
// Thread
void run();
// Configuration
void fill_registered_files_from_db();
void set_database(DatabaseUi* database);
// functions
int add_file_to_list(const std::string& file, const std::string& path, int policy, int display,
int verbosity, bool fixer, bool force, bool, const std::vector<std::string>&, std::string& err);
int add_file_to_list(long id, const std::string& file, const std::string&, const std::string&, std::string& err);
int add_attachment_to_list(const std::string& file, int policy, int display, int verbosity,
const std::vector<std::string>& options, std::string& err);
void clear_files();
FileRegistered* get_file_registered_from_file(const std::string& file);
FileRegistered* get_file_registered_from_id(long id);
void remove_file_registered_from_id(long file_id);
void remove_all_files_registered();
void get_registered_files(std::map<std::string, FileRegistered*>& files);
long get_id_from_registered_file(const std::string& file);
std::string get_filename_from_registered_file_id(long file_id);
int update_policy_of_file_registered_from_file(long file_id, long policy, std::string& error);
private:
void add_registered_file_to_db(const FileRegistered* file);
void add_registered_files_to_db(const std::vector<FileRegistered*>& files);
void update_registered_file_in_db(const FileRegistered* file);
void update_registered_files_in_db(const std::vector<FileRegistered*>& files);
void get_registered_file_from_db(FileRegistered* file);
void remove_registered_file_from_db(const FileRegistered* file);
void remove_registered_files_from_db(const std::vector<FileRegistered*>& files);
void remove_all_registered_file_from_db();
void update_unfinished_files();
void update_add_files_registered();
void update_delete_files_registered();
void update_update_files_registered();
private Q_SLOTS:
void update_files_registered();
private:
MainWindow *mainwindow;
DatabaseUi *db;
QTimer *timer;
size_t file_index;
std::map<std::string, FileRegistered*> working_files;
QMutex working_files_mutex;
std::map<std::string, FileRegistered*> to_delete_files;
QMutex to_delete_files_mutex;
std::map<std::string, FileRegistered*> to_add_files;
QMutex to_add_files_mutex;
std::map<std::string, FileRegistered*> to_update_files;
QMutex to_update_files_mutex;
std::vector<std::string> unfinished_files;
QMutex unfinished_files_mutex;
};
}
#endif // WORKERFILES_H
|