1 // 2 // Copyright RIME Developers 3 // Distributed under the BSD License 4 // 5 // 2012-02-10 GONG Chen <chen.sst@gmail.com> 6 // 7 #ifndef RIME_DEPLOYMENT_TASKS_H_ 8 #define RIME_DEPLOYMENT_TASKS_H_ 9 10 #include <rime/common.h> 11 #include <rime/deployer.h> 12 13 namespace rime { 14 15 // detects changes in either user configuration or upgraded shared data 16 class DetectModifications : public DeploymentTask { 17 public: 18 DetectModifications(TaskInitializer arg = TaskInitializer()); 19 // Unlike other tasks, its return value indicates whether modifications 20 // has been detected and workspace needs update. 21 bool Run(Deployer* deployer); 22 protected: 23 vector<string> data_dirs_; 24 }; 25 26 // initialize/update installation.yaml 27 class InstallationUpdate : public DeploymentTask { 28 public: 29 InstallationUpdate(TaskInitializer arg = TaskInitializer()) {} 30 bool Run(Deployer* deployer); 31 }; 32 33 // update distributed config files and preset schemas 34 class WorkspaceUpdate : public DeploymentTask { 35 public: 36 WorkspaceUpdate(TaskInitializer arg = TaskInitializer()) {} 37 bool Run(Deployer* deployer); 38 39 protected: 40 string GetSchemaPath(Deployer* deployer, 41 const string& schema_id, 42 bool prefer_shared_copy); 43 }; 44 45 // update a specific schema, build corresponding dictionary 46 class SchemaUpdate : public DeploymentTask { 47 public: SchemaUpdate(const string & schema_file)48 explicit SchemaUpdate(const string& schema_file) 49 : schema_file_(schema_file) {} 50 SchemaUpdate(TaskInitializer arg); 51 bool Run(Deployer* deployer); set_verbose(bool verbose)52 void set_verbose(bool verbose) { verbose_ = verbose; } 53 54 protected: 55 string schema_file_; 56 bool verbose_ = false; 57 }; 58 59 // update a specific config file 60 class ConfigFileUpdate : public DeploymentTask { 61 public: ConfigFileUpdate(const string & file_name,const string & version_key)62 ConfigFileUpdate(const string& file_name, 63 const string& version_key) 64 : file_name_(file_name), version_key_(version_key) {} 65 ConfigFileUpdate(TaskInitializer arg); 66 bool Run(Deployer* deployer); 67 68 protected: 69 string file_name_; 70 string version_key_; 71 }; 72 73 // for installer 74 class PrebuildAllSchemas : public DeploymentTask { 75 public: 76 PrebuildAllSchemas(TaskInitializer arg = TaskInitializer()) {} 77 bool Run(Deployer* deployer); 78 }; 79 80 // create symlinks to prebuilt dictionaries in user directory 81 class SymlinkingPrebuiltDictionaries : public DeploymentTask { 82 public: 83 SymlinkingPrebuiltDictionaries(TaskInitializer arg = TaskInitializer()) {} 84 bool Run(Deployer* deployer); 85 }; 86 87 // upgrade user dictionaries 88 class UserDictUpgrade : public DeploymentTask { 89 public: 90 UserDictUpgrade(TaskInitializer arg = TaskInitializer()) {} 91 bool Run(Deployer* deployer); 92 }; 93 94 class UserDictSync : public DeploymentTask { 95 public: 96 UserDictSync(TaskInitializer arg = TaskInitializer()) {} 97 bool Run(Deployer* deployer); 98 }; 99 100 class BackupConfigFiles : public DeploymentTask { 101 public: 102 BackupConfigFiles(TaskInitializer arg = TaskInitializer()) {} 103 bool Run(Deployer* deployer); 104 }; 105 106 class CleanupTrash : public DeploymentTask { 107 public: 108 CleanupTrash(TaskInitializer arg = TaskInitializer()) {} 109 bool Run(Deployer* deployer); 110 }; 111 112 class CleanOldLogFiles : public DeploymentTask { 113 public: 114 CleanOldLogFiles(TaskInitializer arg = TaskInitializer()) {} 115 bool Run(Deployer* deployer); 116 }; 117 118 } // namespace rime 119 120 #endif // RIME_DEPLOYMENT_TASKS_H_ 121