1 /////////////////////////////////////////////////////////////////////////////
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /////////////////////////////////////////////////////////////////////////////
18 * @file FileActionScript.h
20 * @brief Declaration file for FileActionScript and related classes
27 class ShellFileOperations;
30 * @brief Return values for FileActionScript functions.
32 enum CreateScriptReturn
34 SCRIPT_FAIL = 0, /**< The script failed. */
35 SCRIPT_SUCCESS, /**< The script succeeded. */
36 SCRIPT_USERCANCEL, /**< The user cancelled the action. */
37 SCRIPT_USERSKIP, /**< The user wanted to skip one or more items. */
41 * @brief FileAction presents one filesystem action we want to do.
43 * Action consists of source, destination and action type. This
44 * allows us to combine lots of different kind of actions into
50 * @brief the type of the action.
51 * These action types are low level actions for filesystem, not
52 * higher level actions user is doing (e.g. synchronizing).
56 ACT_COPY = 1, /**< Copy the item(s). */
57 ACT_MOVE, /**< Move the item(s). */
58 ACT_DEL, /**< Delete the item(s). */
59 ACT_RENAME, /**< Rename the item(s). */
62 String src; /**< Source for action */
63 String dest; /**< Destination action */
64 bool dirflag; /**< Is it directory? (TRUE means directory) */
65 ACT_TYPE atype; /**< Action's type */
69 * @brief FileActionItem presents one filesystem action from GUI perspective.
71 struct FileActionItem : public FileAction
74 * @brief UI result of the action done.
75 * These values present the change in the UI happening, due to lower
76 * level actions. E.g. delete operation may cause left item to be removed
81 UI_SYNC = 1, /**< Make items identical (synchronized). */
82 UI_DESYNC, /**< Make items different. */
83 UI_DEL, /**< Remove left item. */
84 UI_DONT_CARE, /**< Ignore the GUI change. */
85 UI_RENAME /**< Rename item. */
89 * Optional context value for the item.
90 * This is an arbitrary value that can be used to associate the item with
91 * other items. This can be e.g. indext of the item in the GUI.
94 int UIResult; /**< Resulting UI action */
95 int UIOrigin; /**< Original UI-side */
96 int UIDestination; /**< Destination UI-side */
100 * @brief FileActionScript holds list of fileactions and runs those actions.
102 * This class holds list of actions we want to make with filesystem. After
103 * whole list of actions (script) is composed we can run this sript with
106 class FileActionScript
113 void SetParentWindow(HWND hWnd);
114 void UseRecycleBin(BOOL bUseRecycleBin);
117 // Manipulate the FileActionList
118 size_t GetActionItemCount() const;
121 * Add new item to the action list.
122 * @param [in] item Item to add to the list.
124 void AddActionItem(FileActionItem & item) { m_actions.push_back(item); }
126 FileActionItem RemoveTailActionItem();
129 * Get first action item in the list.
130 * @return First item in the list.
132 FileActionItem GetHeadActionItem() const { return m_actions[0]; }
134 String m_destBase; /**< Base destination path for some operations */
137 int VCSCheckOut(const String &path, BOOL &bApplyToAll);
138 int CreateOperationsScripts();
139 bool RunOp(ShellFileOperations *oplist, bool & userCancelled);
142 std::vector<FileActionItem> m_actions; /**< List of all actions for this script. */
143 std::unique_ptr<ShellFileOperations> m_pCopyOperations; /**< Copy operations. */
144 BOOL m_bHasCopyOperations; /**< flag if we've put anything into m_pCopyOperations */
145 std::unique_ptr<ShellFileOperations> m_pMoveOperations; /**< Move operations. */
146 BOOL m_bHasMoveOperations; /**< flag if we've put anything into m_pMoveOperations */
147 std::unique_ptr<ShellFileOperations> m_pRenameOperations; /**< Rename operations. */
148 BOOL m_bHasRenameOperations; /**< flag if we've put anything into m_pRenameOperations */
149 std::unique_ptr<ShellFileOperations> m_pDelOperations; /**< Delete operations. */
150 BOOL m_bHasDelOperations; /**< flag if we've put anything into m_pDelOperations */
151 BOOL m_bUseRecycleBin; /**< Use recycle bin for script actions? */
152 HWND m_hParentWindow; /**< Parent window for showing messages */