1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef UPDATER_COMMAND_PROCESS_H 16 #define UPDATER_COMMAND_PROCESS_H 17 18 #include "applypatch/command.h" 19 #include "applypatch/command_function.h" 20 21 namespace Updater { 22 class AbortCommandFn : public CommandFunction { 23 public: AbortCommandFn()24 AbortCommandFn() {} ~AbortCommandFn()25 ~AbortCommandFn() override {} 26 CommandResult Execute(const Command ¶ms) override; 27 }; 28 29 class NewCommandFn : public CommandFunction { 30 public: NewCommandFn()31 NewCommandFn() {} ~NewCommandFn()32 ~NewCommandFn() override {} 33 CommandResult Execute(const Command ¶ms) override; 34 private: 35 int32_t StreamExecute(const Command ¶ms); 36 }; 37 38 class ZeroAndEraseCommandFn : public CommandFunction { 39 public: ZeroAndEraseCommandFn()40 ZeroAndEraseCommandFn() {} ~ZeroAndEraseCommandFn()41 ~ZeroAndEraseCommandFn() override {} 42 CommandResult Execute(const Command ¶ms) override; 43 }; 44 45 class FreeCommandFn : public CommandFunction { 46 public: FreeCommandFn()47 FreeCommandFn() {} ~FreeCommandFn()48 ~FreeCommandFn() override {} 49 CommandResult Execute(const Command ¶ms) override; 50 }; 51 52 class StashCommandFn : public CommandFunction { 53 public: StashCommandFn()54 StashCommandFn() {} ~StashCommandFn()55 ~StashCommandFn() override {} 56 CommandResult Execute(const Command ¶ms) override; 57 }; 58 59 class DiffAndMoveCommandFn : public CommandFunction { 60 public: DiffAndMoveCommandFn()61 DiffAndMoveCommandFn() {} ~DiffAndMoveCommandFn()62 ~DiffAndMoveCommandFn() override {} 63 CommandResult Execute(const Command ¶ms) override; 64 virtual int32_t WriteDiffToBlock(const Command ¶ms, std::vector<uint8_t> &srcBuffer, 65 uint8_t *patchBuffer, size_t patchLength, BlockSet &targetBlock); 66 virtual int32_t WriteFileToBlock(const Command ¶ms, std::vector<uint8_t> &srcBuffer, 67 size_t offset, size_t patchLength, BlockSet &targetBlock); 68 }; 69 } 70 #endif // UPDATER_COMMAND_PROCESS_H 71