pax_global_header00006660000000000000000000000064136364574300014525gustar00rootroot0000000000000052 comment=11c913e8454dbed0a2a04ca4f25df6d85eae785b actiona-3.10.1/000077500000000000000000000000001363645743000132255ustar00rootroot00000000000000actiona-3.10.1/.gitignore000066400000000000000000000001771363645743000152220ustar00rootroot00000000000000*.exe *.ilk *.pdb *.user *.user.* *.dll *.exp *.qm *.lib generated *.so* *.log* *.cache* Makefile .qmake.stash actexec actiona actiona-3.10.1/CHANGELOG000066400000000000000000000366641363645743000144560ustar00rootroot000000000000003.10.1 (24/03/20) Global: - Unixes: fixed compilation using OpenCV 4 - Unixes: fixed compilation on unixes other than Linux - Fixed compilation using recent Qt versions - Windows: fixed compilation using MinGW Interface: - Unixes: fixed broken global shortcuts 3.10.0 (17/07/18) Global: - Added a keyboard key condition action that allows checking or waiting for a particular key combination to be pressed - Added a text to speech action that uses the operating system's voice synthesis capabilities - Click action: added an option to reset the cursor position to its former position after the action has finished executing - DataInput action: the output variable now contains an empty string if the user cancels the data input dialog Interface: - Added filters allowing to find an action within the script or within the list of available actions - Added an action heat map that allows viewing the execution count and time spent per action (available after the first script execution) - Improved program loading times - Fixed missing script line numbers (regression from previous version) - Fixed a slowdown when copy and pasting multiple actions within a big script - Fixed a possible bug on the console when running a script for longer than a day - Fixed a few minor bugs 3.9.4 (11/05/18) Global: - Fixed a slowdown occurring when editing an action within a big script - Fixed non-translated buttons - Fixed various memory leaks - Windows: now using Qt 5.6 to build official binaries => removed Webkit web browser, but reduced installer and SFX size Installer/Packages: - Windows installer: fixed missing .dll files used by SQL drivers (like MySQL) 3.9.3 (28/10/17) Global: - Windows: fixed compatibility with Windows 10 - SendMail action: fixed a bug where no exception was thrown when an error occured when sending the e-mail - Click action: fixed not specifying a position would move the mouse cursor to the upper-left screen position - Procedures: fixed a bug where actions were reset when a procedure ends - TimeCondition action: fixed the "if after" and "if before" labels not being intuitive (replaced by "if in the future" and "if in the past") - MultiDataInput action: fixed stretching occuring at the wrong place - DataInput action: fixed default value being capped at 99 - Windows: fixed Actiona still writing an entry into the registry when starting with the --portable parameter Interface: - Linux: added a warning when starting Actiona on a non-X11 session 3.9.2 (28/05/16) Global: - Windows: fixed mouse and keyboard simulation on some applications (started with admin privileges) Code: - fixed loadUI and include functions not using the current script or code filename directory as working directory - added the Execution.filename readonly property, containing the current script or code filename - ActionPackSystem, Debian/Ubuntu/...: fixed a crash when using the System object - ActionPackData: fixed crash when trying to read a non-existing key Installer/Packages: - Windows installer: fixed setup of PATH environment variable and removal when uninstalling 3.9.1 (04/11/15) Global: - Windows: fixed click simulation failures in some cases - fixed a crash when canceling a script execution while a key was being pressed - fixed SFX scripts not being run when a local installation of Actiona was required Interface: - Windows: fixed keyboard shortcuts not working - Debian/Ubuntu/...: fixed a bug preventing the main window to be displayed on recent distribution versions - fixed a crash when right-clicking a "go to a line" exception field - fixed a bug preventing the selection of a pixel on the screen when the Actiona window was on top of it - fixed a bug where the save script progress dialog would stay open when exporting an SFX script Code: - fixed not being able to display the value of an array variable in a text field - fixed console output by way of code not being displayed until after a call to sleep() or pause() - added "pretty printing" of Array and Object 3.9.0 (22/06/15) Global: - renamed Actionaz to Actiona (sounds better in French) - now using Qt5 instead of Qt4 (minimal version is 5.2) - ActionDataInput: added editor type (line, multiline or password) - added a SendMail action - Windows: added a "no unicode character" option to the WriteText action, should allow for a limited text writing in some applications like Remote Desktop - fixed DataInput & MultiDataInput not opening URLS in their question fields - fixed a crash when using the ChooseWindow button (fixes #31) - Linux: fixed missing F1-F35 keys in the KeyMapper - WriteIniFile: fixed a bug that prevented the creation of new ini files - Windows: fixed keyboard keys not being simulated on some applications (Remote Desktop for example) Note that this doesn't include simulating unicode text input, for which there is, afaik, no solution Interface: - enabled secure connections for checking Internet connectivity, fetching update information and downloading new versions - added a language change setting - now checking if the SFX files are available to enable/disable the export SFX feature - fixed a bug preventing saving the values of some settings (caused by the Qt5 migration): users will see those settings reset to their default values - fixed a bug in localized tab names in action dialogs - removed unused context help button on dialogs Code: - added a Mail object - added ProcessHandle::parentId() - added a MultilineText option to the InputDialog object - added Console.clear() - Image: added the pixels() and pixelData() methods to retreive the pixel values at once Internal: - replaced RudeConfig with boost::property_tree - replaced Qt's foreach by C++11's range-based for 3.8.0 (09/03/14) Global: - added in-script resources - added an Image parameter - added a percent positioning to the position parameter - set the positions as floating point - added the evaluation of text-mode variables as non-text if they are the only entry of a parameter - fixed some bugs in variable insertion in parameters - replaced input masks by validators in position and color parameters - fixed the default value in DateTime parameters - VariableCondition: added a Contains operation allowing to test for the presence of a string in a string list - VariableCondition: corrected the comparison of values, allowing for more intuitive comparisons - CursorPath: added a mouse button that can be pressed during the action execution Interface: - added a screen capture wizard - added the insertion of variables & resources in the code editor - added a progress bar to the loading and saving of scripts Code: - added Script.callProcedure - SQL: corrected a bug that ran a SQL request two times when using exec() with a non-prepared request 3.7.0 (28/06/13) Actions: - added a button to insert detected variables into parameter fields - added a more explicit error message when a list field is empty - fixed a bug when opening a script that had been created using a previous version of Actiona: new action parameters did not have default values - corrected a bug that prevented using the Code Error exception to skip the current action or go to a line of the script - Pixel Color: added an offset to the position to be checked - Read INI File: added reading the whole file at once - Read INI File: corrected a bug that froze the execution when trying to read a file with an empty filename - Find Image: added a field allowing to retreive the confidence value - Find Image: added a field to choose which matching method to use - Find Image: added a delay between two searches when waiting - Find Image: added two conditions actions "if found" and "if not found" - Find Image: removed the "Image not found" exception, previous scripts will be automatically upgraded to use the "if found" and "if not found" parameters - Find Image: search can now be done in multiple windows if they satisfy the search criterion - Find Image: renamed "Down pyramids" to "Downsampling" - Find Image: fixed a bug that prevented searching in some screens when using a multiple screen configuration - Find Image: fixed a bug that prevented using an absolute position when searching within a window Code: - Script: added the line attribute - Image: added the Image.takeScreenshotUsingScreenIndex function that allows taking screenshots using a screen index - Image: added a parameter to the findSubImage functions to choose which matching method to use - Image: fixed a bug that prevented searching in some screens when using a multiple screen configuration - Image: fixed a bug in the Image.takeScreenshot function that took only a screenshot of the main screen when using a multiple screen configuration 3.6.2 (04/05/13) - Actions: fixed a regression that caused a memory leak and a crash after a repeated use of the Find Image action - Code: fixed a bug that caused a memory leak and a crash after a repeated use of Image.findSubImage and similar 3.6.1 (04/03/13) - Actions: fixed a bug in the in-text variable insertions that prevented using backslashes 3.6.0 (03/03/13) - Actions: added a position offset in the Click, Move cursor and Cursor path - Actions: added an action to read environment variables - Gui: fixed a bug where pause before and after each action were not reset after creating a new script - Code: added the File.exists() function - Actions: upgraded the in-text variable insertions to allow inserting table elements - ActExec & Gui: fixed a bug that prevented the translation of the parameters usage - Actions: fixed a bug in the Command action that prevented getting the standard output and standard error texts - Actions: fixed a bug that prevented using Date objects in the Time Condition action - Actions: fixed a bug in the Find image action & code that could crash the program in certain cases 3.5.1 (28/12/12) - ActExec: fixed a bug that prevented the use of the pauseBefore and pauseAfter script parameters - Actions: fixed a bug that involved setVariable to create variables of type Object and not of the values type - Actions: fixed a bug preventing comparison of variables other than strings in the VariableCondition action 3.5.0 (08/12/12) - Actions: added a parameter to choose the key press amount in the Key action - Actions: added a parameter to trigger a pause between key presses to the Text action - Actions: setting the default value for "down pyramid count" to 1 in the Find Image action - Code: added a delay to the writeText function 3.4.2 (27/05/12) - Actions: corrected a bug in the Time Condition action - Code: corrected a bug preventing Mouse functions to work with other buttons than the left one - Code: corrected bugs in the waitForX Process functions - Code: corrected bugs in code classes using enums as function parameters 3.4.1 (10/04/12) - Executer: fixed a bug increasing the pause before and after an action - Gui: removed spaces at begin and end of imported scripts to prevent an XML import error - ActionTools: corrected a bug where a newer version of the script file schema could be seen as a corrupted script 3.4.0 (08/04/12) - Actions: added three actions allowing the use of procedures - Actions: added a new "If action" action allowing to call a procedure - Actions: deprecated the x-coodinate, y-coordinate, width and height parameters in the Window condition action - Actions: added position and size parameters in the Window condition action - Packaging: fixed Debian bug #667093 (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=667093) - Gui, Console: clicking on a log console item now selects the corresponding action - Gui: fixed a bug where the execute selection button was disabled after an execution even if an action was still selected - Gui: fixed a bug where clicking on a console item could select/open another action than the one concerned by the item - ActExec, Windows: added a program parameter to show a console - fixed some warnings due to useless & dangerous calls to deleteLater (close() auto-deletes QWidgets by default) 3.3.0 (29/03/12) - Actions: added a window title to the DataInput action - Actions: added new action MultiDataInput - Actions: added a text mode to the Messagebox action - fixed a bug crashing the application when canceling the execution when the debugger is open and a MessageBox action is shown 3.2.2 (29/01/12) - Code: fixed getter functions having the same name as properties - Packaging: removed compiler options to allow compilation on non-x86 platforms - removed 7z binaries from repository 3.2.1.1 (16/01/12) - Packaging: dependency on OpenCV is now done using Pkgconfig 3.2.1 (14/01/12) - Actions: added a tolerance value for the Pixel color action - Actions: fixed a bug preventing to enter no data in a number parameter - Actions: fixed a bug preventing to enter integer or decimal values below 0 or over 100 - Windows: fixed a bug during installation preventing the use of image formats other than PNG - fixed a bug corrupting the Actiona window when using the Exit Actiona action - fixed some memory leaks 3.2.0 (06/01/12) - Actions: added the FindImage action - Actions: added an option to use window borders to the Window action - Actions: added Point (position) and Color variable types to the Variable action - Actions: fixed a bug in the Window Condition action, blocking if "goto a line" was selected in "if false" - Gui: updated the settings dialog to show the last opened tab - Gui: fixed check for updates parameter not being hidden when updates are disabled - Gui: now hiding exceptions when no parameters are shown - Executer: fixed a bug crashing Actiona when using the Stop action 3.1.1 (30/12/11) - Code editor: added Ctrl+Return shortcut to close the code/text editor - Code editor: added Shift+Tab to unindent the selection in the code/text editor - Code editor: improved the Code syntax highlighter - Code: fixed a crash when using the Web object - Code: fixed Execution.sleep() and Execution.pause() not working under Linux - Code: fixed possible crash when using Execution.sleep() and Execution.pause() - Windows: fixed a bug in the installer preventing the use of SFX scripts 3.1.0 (21/12/11) - added edition of actions that are not compatible with the current OS - added modifier keys in the Key action 3.0.1 (11/12/11) - Gui: replaced GroupBoxes by invisible widgets (increased readability) - Code: fixed a bug that could cause crashes when using events - Code: added Image.findSubImage() - Code: added Stdio.println(), Stdio.printlnWarning() and Stdio.printlnError() - Gui, Linux: set window opacity only if the compositing manager is running - Code, Windows: improved the File object - Actions: fixed a bug in WriteIniFile where the INI file was overwritten on each edit 3.0.0 (13/11/11) - official stable release 0.1.3 (06/11/11) - ActExec: added proxy parameters - ActExec: using system proxy by default - fixed a bug with action parameter evaluation during execution - Code: added Window.foreground() 0.1.2 (08/10/11) - fixed a bug concerning the last opened script - fixed a bug when jumping to another line of the script - added a WebDownload action - added a Web code object - fixed a bug in the cursor path actions - added a field to the MessageBox and DataInput actions to specify the title icon to use - Sfx: added a "requires Actiona" option - Sfx: added a runner executable to warn about 64 bit compatibility issues 0.1.1 (24/09/11) - corrected a bug involving the "goto line" action when the tested pixel was not equal to the wanted value - added a new contributor to the about dialog - Windows: added a missing mediaservice dll used to play sound & videos - fixed a bug when validating a script file with non-ascii characters - ActionMessageBox: added a custom icon choice - Gui: added an option to use the system proxy actiona-3.10.1/LICENSE000066400000000000000000000773301363645743000142440ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS actiona-3.10.1/README.md000066400000000000000000000016571363645743000145150ustar00rootroot00000000000000[![AppVeyor](https://img.shields.io/appveyor/build/Jmgr/actiona?label=ubuntu-gcc-build&logo=appveyor)](https://ci.appveyor.com/project/Jmgr/actiona) [![AppVeyor](https://img.shields.io/appveyor/build/Jmgr/actiona-hhhwb?label=windows-msvc-build&logo=appveyor)](https://ci.appveyor.com/project/Jmgr/actiona-hhhwb) [![AppVeyor](https://img.shields.io/appveyor/build/Jmgr/actiona-9331s?label=windows-gcc-build&logo=appveyor)](https://ci.appveyor.com/project/Jmgr/actiona-9331s) ![License: GPLv3](https://img.shields.io/badge/license-GPLv3-blue) Actiona ====== Actiona is an application that allows you to execute many actions on your computer such as emulating mouse clicks, key presses, showing message boxes, editing text files, etc. Tasks can be created using a simple editor or using the EcmaScript (JavaScript) programming language for more customization. Actiona is cross-platform. Please visit http://actiona.tools for more information. actiona-3.10.1/actexecuter/000077500000000000000000000000001363645743000155415ustar00rootroot00000000000000actiona-3.10.1/actexecuter/actexecuter.pro000066400000000000000000000026611363645743000206040ustar00rootroot00000000000000include(../common.pri) unix:!mac:QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN -Wl,--rpath=$${PREFIX}/$${LIBDIR}/actiona QT += network \ script \ scripttools \ widgets TARGET = actexec VERSION = $$ACTIONA_VERSION DESTDIR = .. SOURCES += main.cpp \ executer.cpp \ codeexecuter.cpp \ scriptexecuter.cpp \ mainclass.cpp HEADERS += executer.h \ codeexecuter.h \ scriptexecuter.h \ mainclass.h \ global.h INCLUDEPATH += . \ .. \ ../tools \ ../actiontools FORMS += win32:LIBS += -luser32 \ -ladvapi32 \ -lole32 unix:LIBS += -lXtst LIBS += -L.. \ -ltools \ -lactiontools \ -lexecuter TRANSLATIONS = ../locale/actexecuter_fr_FR.ts unix:!mac:CONFIG += link_pkgconfig unix:!mac:PKGCONFIG += libnotify win32 { QMAKE_TARGET_COMPANY = "https://actiona.tools" QMAKE_TARGET_DESCRIPTION = "Actiona: Cross-Platform Automation Tool" QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2005 Jonathan Mercier-Ganady" QMAKE_TARGET_PRODUCT = "Actiona" RC_ICONS = "../gui/icons/actiona.ico" } win32-msvc* { CONFIG += embed_manifest_exe QMAKE_LFLAGS += $$quote( /MANIFESTUAC:\"level=\'asInvoker\' uiAccess=\'true\'\" ) } unix { target.path = $${PREFIX}/bin locales.path = $${PREFIX}/share/actiona/locale locales.files = ../locale/actexecuter_fr_FR.qm locales.CONFIG = no_check_exist manfile.path = $${PREFIX}/share/man/man1 manfile.files = ../docs/actexec.1 INSTALLS += target locales manfile } actiona-3.10.1/actexecuter/codeexecuter.cpp000066400000000000000000000134431363645743000207310ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "codeexecuter.h" #include "executer/codeinitializer.h" #include "executer/scriptagent.h" #include "actionfactory.h" #include "actionpack.h" #include "executer/codestdio.h" #include "code/codetools.h" #include "code/prettyprinting.h" #include "executer/codeactiona.h" #include "global.h" #include "languages.h" #include #include #include #include #include #include #include #include #include CodeExecuter::CodeExecuter(QObject *parent) : Executer(parent), mScriptEngine(new QScriptEngine(this)), mScriptAgent(new LibExecuter::ScriptAgent(mScriptEngine)), mScriptEngineDebugger(new QScriptEngineDebugger(this)), mDebuggerWindow(mScriptEngineDebugger->standardWindow()) { connect(mScriptEngineDebugger, &QScriptEngineDebugger::evaluationResumed, this, &CodeExecuter::onEvaluationResumed); connect(mScriptEngineDebugger, &QScriptEngineDebugger::evaluationSuspended, this, &CodeExecuter::onEvaluationPaused); connect(mScriptAgent, &LibExecuter::ScriptAgent::executionStopped, this, &CodeExecuter::stopExecution); for(QString extension: mScriptEngine->availableExtensions()) mScriptEngine->importExtension(extension); Code::setupPrettyPrinting(*mScriptEngine); mScriptEngineDebugger->setAutoShowStandardWindow(false); mScriptEngineDebugger->attachTo(mScriptEngine); QScriptEngineAgent *debuggerAgent = mScriptEngine->agent(); mScriptEngine->setAgent(mScriptAgent); mScriptAgent->setDebuggerAgent(debuggerAgent); } bool CodeExecuter::start(QIODevice *device, const QString &filename) { if(!Executer::start(device, filename)) return false; QString code = QString::fromUtf8(device->readAll()); device->close(); mScriptAgent->setContext(LibExecuter::ScriptAgent::ActionInit); LibExecuter::CodeInitializer::initialize(mScriptEngine, mScriptAgent, actionFactory(), filename); Code::CodeTools::addClassToScriptEngine(QStringLiteral("Console"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::print, QStringLiteral("print"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::println, QStringLiteral("println"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printWarning, QStringLiteral("printWarning"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printlnWarning, QStringLiteral("printlnWarning"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printError, QStringLiteral("printError"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printlnError, QStringLiteral("printlnError"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::clear, QStringLiteral("clear"), mScriptEngine); Code::CodeTools::addClassToScriptEngine(QStringLiteral("Actiona"), mScriptEngine); LibExecuter::CodeActiona::setActExec(true); LibExecuter::CodeActiona::setActionaVersion(Global::ACTIONA_VERSION); LibExecuter::CodeActiona::setScriptVersion(Global::SCRIPT_VERSION); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::version, QStringLiteral("version"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::scriptVersion, QStringLiteral("scriptVersion"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::isActExec, QStringLiteral("isActExec"), mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::isActiona, QStringLiteral("isActiona"), mScriptEngine); QString locale = Tools::Languages::locale(); for(int actionPackIndex = 0; actionPackIndex < actionFactory()->actionPackCount(); ++actionPackIndex) { ActionTools::ActionPack *actionPack = actionFactory()->actionPack(actionPackIndex); Tools::Languages::installTranslator(QStringLiteral("actionpack%1").arg(actionPack->id()), locale); } mScriptAgent->setContext(LibExecuter::ScriptAgent::Parameters); QScriptValue result = mScriptEngine->evaluate(code, filename); if(result.isError()) { QTextStream stream(stdout); stream << QObject::tr("Uncaught exception: ") << result.toString() << "\n"; stream << tr("Backtrace: ") << mScriptEngine->uncaughtExceptionBacktrace().join(QStringLiteral("\n")) << "\n"; stream.flush(); } QTimer::singleShot(0, qApp, SLOT(quit())); return true; } void CodeExecuter::onEvaluationResumed() { mDebuggerWindow->hide(); } void CodeExecuter::onEvaluationPaused() { mDebuggerWindow->show(); } void CodeExecuter::stopExecution() { mScriptEngine->abortEvaluation(); } actiona-3.10.1/actexecuter/codeexecuter.h000066400000000000000000000024361363645743000203760ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "executer.h" namespace LibExecuter { class ScriptAgent; } class QScriptEngine; class QScriptEngineDebugger; class QMainWindow; class CodeExecuter : public Executer { Q_OBJECT public: explicit CodeExecuter(QObject *parent = nullptr); bool start(QIODevice *device, const QString &filename) override; private slots: void onEvaluationResumed(); void onEvaluationPaused(); void stopExecution(); private: QScriptEngine *mScriptEngine; LibExecuter::ScriptAgent *mScriptAgent; QScriptEngineDebugger *mScriptEngineDebugger; QMainWindow *mDebuggerWindow; }; actiona-3.10.1/actexecuter/executer.cpp000066400000000000000000000036631363645743000201010ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "executer.h" #include "actionfactory.h" #include #include #include #include #include Executer::Executer(QObject *parent) : QObject(parent), mActionFactory(new ActionTools::ActionFactory(this)) { connect(mActionFactory, &ActionTools::ActionFactory::actionPackLoadError, this, &Executer::actionPackLoadError); } Executer::~Executer() = default; bool Executer::start(QIODevice *device, const QString &filename) { Q_UNUSED(device) Q_UNUSED(filename) QSettings settings; QString locale = settings.value(QStringLiteral("gui/locale"), QLocale::system().name()).toString(); mActionFactory->loadActionPacks(QApplication::applicationDirPath() + QStringLiteral("/actions/"), locale); #ifndef Q_OS_WIN if(mActionFactory->actionPackCount() == 0) mActionFactory->loadActionPacks(QStringLiteral("%1/%2/actiona/actions/").arg(QLatin1String(ACT_PREFIX)).arg(QLatin1String(ACT_LIBDIR)), locale); #endif if(mActionLoadingFailed) return false; return true; } ActionTools::ActionFactory *Executer::actionFactory() const { return mActionFactory; } void Executer::actionPackLoadError(const QString &error) { mActionLoadingFailed = true; std::wcerr << error.toStdWString() << std::endl; } actiona-3.10.1/actexecuter/executer.h000066400000000000000000000023041363645743000175350ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include class QIODevice; namespace ActionTools { class ActionFactory; } class Executer : public QObject { Q_OBJECT public: explicit Executer(QObject *parent = nullptr); ~Executer() override; virtual bool start(QIODevice *device, const QString &filename); protected: ActionTools::ActionFactory *actionFactory() const; private slots: void actionPackLoadError(const QString &error); private: ActionTools::ActionFactory *mActionFactory; bool mActionLoadingFailed{false}; }; actiona-3.10.1/actexecuter/global.h000066400000000000000000000024641363645743000171600ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "version.h" namespace Global { #if (QT_VERSION >= 0x050600) const Tools::Version ACTIONA_VERSION = QVersionNumber::fromString(QLatin1String(VERSION_TO_STRING(ACT_VERSION))); const Tools::Version SCRIPT_VERSION = QVersionNumber::fromString(QLatin1String(VERSION_TO_STRING(ACT_SCRIPT_VERSION))); #else const Tools::Version ACTIONA_VERSION = Tools::Version(QLatin1String(VERSION_TO_STRING(ACT_VERSION))); const Tools::Version SCRIPT_VERSION = Tools::Version(QLatin1String(VERSION_TO_STRING(ACT_SCRIPT_VERSION))); #endif const QString CONNECTIVITY_URL = QStringLiteral("http://actiona.tools/"); } actiona-3.10.1/actexecuter/main.cpp000066400000000000000000000266631363645743000172060ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "actioninstance.h" #include "version.h" #include "mainclass.h" #include "qtsingleapplication/qtsingleapplication.h" #include "global.h" #include "settings.h" #include "languages.h" #ifdef ACT_PROFILE #include "highresolutiontimer.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include #ifdef Q_OS_UNIX #undef signals #include #define signals #include "keysymhelper.h" #endif #ifdef Q_OS_WIN #include #include #include #include #include #include #endif static void cleanup() { #ifdef Q_OS_UNIX notify_uninit(); #endif } #ifdef Q_OS_WIN static void pause() { system("pause"); } static void createConsole() { AllocConsole(); HANDLE stdHandle = GetStdHandle(STD_OUTPUT_HANDLE); int conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT); *stdout = *_fdopen(conHandle, "w"); setvbuf(stdout, NULL, _IONBF, 0); stdHandle = GetStdHandle(STD_INPUT_HANDLE); conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT); *stdin = *_fdopen(conHandle, "r"); setvbuf(stdin, NULL, _IONBF, 0); stdHandle = GetStdHandle(STD_ERROR_HANDLE); conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT); *stderr = *_fdopen(conHandle, "w"); setvbuf(stderr, NULL, _IONBF, 0); } #endif int main(int argc, char **argv) { #if (QT_VERSION < 0x050400) #error("You need Qt 5.4.0 or later to compile Actiona Executer"); #endif QtSingleApplication app(QStringLiteral("actiona-exec"), argc, argv); app.setQuitOnLastWindowClosed(false); qAddPostRoutine(cleanup); qsrand(static_cast(std::time(nullptr))); #ifdef Q_OS_UNIX notify_init("Actiona executer"); #endif QCommandLineParser optionsParser; optionsParser.setApplicationDescription(QObject::tr("Emulates clics, key presses and other actions.")); optionsParser.addHelpOption(); optionsParser.addVersionOption(); optionsParser.addOption({{QStringLiteral("p"), QStringLiteral("portable")}, QObject::tr("Starts in portable mode, storing the settings in the executable folder.")}); optionsParser.parse(app.arguments()); if(optionsParser.isSet(QStringLiteral("portable"))) { QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationDirPath() + QStringLiteral("/userSettings")); QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QApplication::applicationDirPath() + QStringLiteral("/systemSettings")); QSettings::setDefaultFormat(QSettings::IniFormat); } QString locale = Tools::Languages::locale(); Tools::Languages::installTranslator(QStringLiteral("qtbase"), locale); Tools::Languages::installTranslator(QStringLiteral("qtlocation"), locale); Tools::Languages::installTranslator(QStringLiteral("qtmultimedia"), locale); Tools::Languages::installTranslator(QStringLiteral("qtscript"), locale); Tools::Languages::installTranslator(QStringLiteral("qtxmlpatterns"), locale); Tools::Languages::installTranslator(QStringLiteral("tools"), locale); Tools::Languages::installTranslator(QStringLiteral("actiontools"), locale); Tools::Languages::installTranslator(QStringLiteral("executer"), locale); Tools::Languages::installTranslator(QStringLiteral("actexecuter"), locale); optionsParser.addOptions( { {{QStringLiteral("c"), QStringLiteral("code")}, QObject::tr("Switch to code mode, may not be used with -s.")}, {{QStringLiteral("s"), QStringLiteral("script")}, QObject::tr("Switch to script mode, may not be used with -c.")}, {{QStringLiteral("Q"), QStringLiteral("nocodeqt")}, QObject::tr("Do not include the Qt library into the code.")}, {{QStringLiteral("proxy-mode")}, QObject::tr(R"(Sets the proxy mode, values are "none", "system" (default) or "custom".)")}, {{QStringLiteral("proxy-type")}, QObject::tr(R"(Sets the custom proxy type, values are "http" or "socks" (default).)")}, {{QStringLiteral("proxy-host")}, QObject::tr("Sets the custom proxy host.")}, {{QStringLiteral("proxy-port")}, QObject::tr("Sets the custom proxy port.")}, {{QStringLiteral("proxy-user")}, QObject::tr("Sets the custom proxy user.")}, {{QStringLiteral("proxy-password")}, QObject::tr("Sets the custom proxy password.")}, }); #ifdef Q_OS_WIN optionsParser.addOption({QStringLiteral("console"), QObject::tr("create a console to see debug output.")}); optionsParser.addOption({QStringLiteral("pause-at-end"), QObject::tr("wait for user input at the end of the execution, used only with --console.")}); #endif optionsParser.addPositionalArgument(QStringLiteral("filepath"), QObject::tr("The filepath of a script/code file to execute.")); optionsParser.process(app); #ifdef Q_OS_WIN if(optionsParser.isSet(QStringLiteral("console"))) { createConsole(); if(optionsParser.isSet(QStringLiteral("pause-at-end"))) qAddPostRoutine(pause); } #endif qRegisterMetaType("ActionInstance"); qRegisterMetaType("Exception"); qRegisterMetaType("Parameter"); qRegisterMetaType("SubParameter"); qRegisterMetaType("Version"); qRegisterMetaTypeStreamOperators("ActionInstance"); qRegisterMetaTypeStreamOperators("Parameter"); qRegisterMetaTypeStreamOperators("SubParameter"); qRegisterMetaTypeStreamOperators("Version"); const auto &positionalArguments = optionsParser.positionalArguments(); if(positionalArguments.count() < 1 || (optionsParser.isSet(QStringLiteral("code")) && optionsParser.isSet(QStringLiteral("script")))) optionsParser.showHelp(-1); app.addLibraryPath(QApplication::applicationDirPath() + QStringLiteral("/actions")); app.addLibraryPath(QApplication::applicationDirPath() + QStringLiteral("/plugins")); if(!optionsParser.isSet(QStringLiteral("nocodeqt"))) app.addLibraryPath(QApplication::applicationDirPath() + QStringLiteral("/code")); #ifdef Q_OS_UNIX { #ifdef ACT_PROFILE Tools::HighResolutionTimer timer("Load key codes"); #endif ActionTools::KeySymHelper::loadKeyCodes(); } #endif // Proxy settings int proxyMode = ActionTools::Settings::PROXY_SYSTEM; if(optionsParser.value(QStringLiteral("proxy-mode")) == QLatin1String("none")) proxyMode = ActionTools::Settings::PROXY_NONE; else if(optionsParser.value(QStringLiteral("proxy-mode")) == QLatin1String("custom")) proxyMode = ActionTools::Settings::PROXY_CUSTOM; else if(optionsParser.value(QStringLiteral("proxy-mode")) == QLatin1String("system")) proxyMode = ActionTools::Settings::PROXY_SYSTEM; else if(!optionsParser.value(QStringLiteral("proxy-mode")).isEmpty()) { QTextStream stream(stdout); stream << QObject::tr(R"(Unknown proxy mode, values are "none", "system" (default) or "custom")") << "\n"; stream.flush(); optionsParser.showHelp(-1); } QNetworkProxy proxy; switch(proxyMode) { case ActionTools::Settings::PROXY_NONE: proxy.setType(QNetworkProxy::NoProxy); break; case ActionTools::Settings::PROXY_SYSTEM: { QUrl url(Global::CONNECTIVITY_URL); QNetworkProxyQuery networkProxyQuery(url); QList listOfProxies = QNetworkProxyFactory::systemProxyForQuery(networkProxyQuery); if(!listOfProxies.isEmpty()) proxy = listOfProxies.first(); else proxy.setType(QNetworkProxy::NoProxy); } break; case ActionTools::Settings::PROXY_CUSTOM: { int type = ActionTools::Settings::PROXY_TYPE_SOCKS5; if(optionsParser.value(QStringLiteral("proxy-type")) == QLatin1String("http")) type = ActionTools::Settings::PROXY_TYPE_HTTP; else if(optionsParser.value(QStringLiteral("proxy-type")) == QLatin1String("socks")) type = ActionTools::Settings::PROXY_TYPE_SOCKS5; else if(!optionsParser.value(QStringLiteral("proxy-type")).isEmpty()) { QTextStream stream(stdout); stream << QObject::tr(R"(Unknown proxy type, values are "http" or "socks" (default))") << "\n"; stream.flush(); optionsParser.showHelp(-1); } QNetworkProxy proxy; if(type == ActionTools::Settings::PROXY_TYPE_HTTP) proxy.setType(QNetworkProxy::HttpProxy); else proxy.setType(QNetworkProxy::Socks5Proxy); proxy.setHostName(optionsParser.value(QStringLiteral("proxy-host"))); proxy.setPort(static_cast(optionsParser.value(QStringLiteral("proxy-port")).toUInt())); proxy.setUser(optionsParser.value(QStringLiteral("proxy-user"))); proxy.setPassword(optionsParser.value(QStringLiteral("proxy-password"))); } break; } QNetworkProxy::setApplicationProxy(proxy); QUrl protocolUrl = QUrl::fromEncoded(positionalArguments.first().toUtf8()); if(protocolUrl.isValid() && protocolUrl.scheme() != QLatin1String("actiona")) protocolUrl = QUrl(); MainClass::ExecutionMode executionMode = MainClass::Unknown; MainClass mainClass; if(protocolUrl.isValid()) { QString mode; for(const auto &queryItem: QUrlQuery(protocolUrl.query()).queryItems()) { if(queryItem.first == QLatin1String("mode")) { mode = queryItem.second; break; } } if(mode == QLatin1String("code")) executionMode = MainClass::Code; else if(mode == QLatin1String("script")) executionMode = MainClass::Script; else { if(protocolUrl.path().endsWith(QStringLiteral(".ascr"))) executionMode = MainClass::Script; else if(protocolUrl.path().endsWith(QStringLiteral(".acod"))) executionMode = MainClass::Code; else { QTextStream stream(stdout); stream << QObject::tr("Unknown execution mode, please specify mode=script or mode=code") << "\n"; stream.flush(); optionsParser.showHelp(-1); } } if(!mainClass.start(executionMode, protocolUrl)) return -1; } else { QString filename = positionalArguments.first(); if(optionsParser.isSet(QStringLiteral("code"))) executionMode = MainClass::Code; else if(optionsParser.isSet(QStringLiteral("script"))) executionMode = MainClass::Script; else { if(filename.endsWith(QStringLiteral(".ascr"))) executionMode = MainClass::Script; else if(filename.endsWith(QStringLiteral(".acod"))) executionMode = MainClass::Code; else { QTextStream stream(stdout); stream << QObject::tr("Unknown execution mode, please specify -s (script) or -c (code)") << "\n"; stream.flush(); optionsParser.showHelp(-1); } } QFile file(filename); if(!file.open(QIODevice::ReadOnly)) { QTextStream stream(stdout); stream << QObject::tr("Unable to read input file") << "\n"; stream.flush(); return -1; } if(!mainClass.start(executionMode, &file, file.fileName())) { file.close(); return -1; } } return app.exec(); } actiona-3.10.1/actexecuter/mainclass.cpp000066400000000000000000000042241363645743000202210ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "mainclass.h" #include "codeexecuter.h" #include "scriptexecuter.h" #include #include #include #include #include #include MainClass::MainClass() : QObject(nullptr), mNetworkAccessManager(new QNetworkAccessManager(this)) { } bool MainClass::start(ExecutionMode executionMode, QIODevice *device, const QString &filename) { if(executionMode == Script) mExecuter = new ScriptExecuter(this); else mExecuter = new CodeExecuter(this); return mExecuter->start(device, filename); } bool MainClass::start(ExecutionMode executionMode, const QUrl &url) { mExecutionMode = executionMode; mUrl = url; mUrl.setScheme(QStringLiteral("http")); mNetworkReply = mNetworkAccessManager->get(QNetworkRequest(mUrl)); connect(mNetworkReply, &QNetworkReply::finished, this, &MainClass::downloadFinished); return true; } void MainClass::downloadFinished() { if(mNetworkReply->error() != QNetworkReply::NoError) { QTextStream stream(stdout); stream << QObject::tr("Unable to download the requested file, \"%1\"").arg(mNetworkReply->errorString()) << "\n"; stream.flush(); QApplication::exit(-1); } else { QByteArray data = mNetworkReply->readAll(); QBuffer buffer(&data); buffer.open(QIODevice::ReadOnly); if(!start(mExecutionMode, &buffer, mUrl.toString())) QApplication::exit(-1); } mNetworkReply->close(); mNetworkReply->deleteLater(); mNetworkReply = nullptr; } actiona-3.10.1/actexecuter/mainclass.h000066400000000000000000000025161363645743000176700ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "version.h" #include #include class Executer; class QIODevice; class QNetworkAccessManager; class QNetworkReply; class QTemporaryFile; class MainClass : public QObject { Q_OBJECT public: enum ExecutionMode { Unknown, Code, Script }; MainClass(); bool start(ExecutionMode executionMode, QIODevice *device, const QString &filename); bool start(ExecutionMode executionMode, const QUrl &url); private slots: void downloadFinished(); private: Executer *mExecuter{nullptr}; QNetworkAccessManager *mNetworkAccessManager; QNetworkReply *mNetworkReply; ExecutionMode mExecutionMode; QUrl mUrl; }; actiona-3.10.1/actexecuter/scriptexecuter.cpp000066400000000000000000000055421363645743000213240ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "scriptexecuter.h" #include "script.h" #include "executer/executer.h" #include "mainclass.h" #include "global.h" #include #include #include ScriptExecuter::ScriptExecuter(QObject *parent) : Executer(parent), mScript(new ActionTools::Script(actionFactory(), this)), mExecuter(new LibExecuter::Executer(this)) { connect(mExecuter, &LibExecuter::Executer::executionStopped, this, &ScriptExecuter::executionStopped); connect(mExecuter, &LibExecuter::Executer::scriptError, this, &ScriptExecuter::scriptError); } bool ScriptExecuter::start(QIODevice *device, const QString &filename) { if(!Executer::start(device, filename)) return false; ActionTools::Script::ReadResult result = mScript->read(device, Global::SCRIPT_VERSION); switch(result) { case ActionTools::Script::ReadInternal: { QTextStream stream(stdout); stream << QObject::tr("Reading script file failed due to an internal error") << "\n"; stream.flush(); } return false; case ActionTools::Script::ReadInvalidSchema: { QTextStream stream(stdout); stream << QObject::tr("Input script file has an invalid script schema") << "\n"; stream.flush(); } return false; case ActionTools::Script::ReadInvalidScriptVersion: { QTextStream stream(stdout); stream << QObject::tr("Input script file is too recent") << "\n"; stream.flush(); } return false; default: break; } device->close(); mExecuter->setup(mScript, actionFactory(), false, 0, 0, false, 0, 0, mScript->pauseBefore(), mScript->pauseAfter(), Global::ACTIONA_VERSION, Global::SCRIPT_VERSION, true, nullptr); if(!mExecuter->startExecution(false, filename)) { QTextStream stream(stdout); stream << QObject::tr("Start execution failed") << "\n"; stream.flush(); return false; } return true; } void ScriptExecuter::executionStopped() { QApplication::quit(); } void ScriptExecuter::scriptError(int actionIndex, const QString ¶meter, const QString &error) { Q_UNUSED(actionIndex) Q_UNUSED(parameter) QTextStream stream(stdout); stream << QObject::tr("Execution error: ") << error << "\n"; stream.flush(); QApplication::quit(); } actiona-3.10.1/actexecuter/scriptexecuter.h000066400000000000000000000022771363645743000207730ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "executer.h" namespace ActionTools { class Script; } namespace LibExecuter { class Executer; } class ScriptExecuter : public Executer { Q_OBJECT public: explicit ScriptExecuter(QObject *parent = nullptr); bool start(QIODevice *device, const QString &filename) override; public slots: void executionStopped(); void scriptError(int actionIndex, const QString ¶meter, const QString &error); private: ActionTools::Script *mScript; LibExecuter::Executer *mExecuter; }; actiona-3.10.1/actiona.desktop000066400000000000000000000006371363645743000162440ustar00rootroot00000000000000[Desktop Entry] Name=Actiona GenericName=Automation Tool GenericName[fr]=Outil d'automatisation Comment=Automate tasks Comment[fr]=Automatise des tâches Exec=actiona %f Terminal=false Icon=actiona Type=Application Categories=Utility; Version=1.0 MimeType=application/actiona-script;application/actiona-code;application/actionaz-script;application/actionaz-code; Keywords=automate;bot;macro;script;action;asrc;acod;actiona-3.10.1/actiona.pro000066400000000000000000000025341363645743000153710ustar00rootroot00000000000000TEMPLATE = subdirs CONFIG = ordered contains(DEFINES, ACT_NO_UPDATER){ message(** No updater will be built **) } contains(DEFINES, ACT_PROFILE){ message(** Profiling activated **) } unix:QMAKE_CLEAN += actions/*.so win32:QMAKE_CLEAN += actions/*.dll QMAKE_CLEAN += locale/*.qm isEmpty(QMAKE_LRELEASE) { win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease } locale_release.name = lrelease locale_release.commands = \ $$QMAKE_LRELEASE tools/tools.pro && \ $$QMAKE_LRELEASE actiontools/actiontools.pro && \ $$QMAKE_LRELEASE executer/executer.pro && \ $$QMAKE_LRELEASE actexecuter/actexecuter.pro && \ $$QMAKE_LRELEASE gui/gui.pro && \ $$QMAKE_LRELEASE actions/actionpackinternal/actionpackinternal.pro && \ $$QMAKE_LRELEASE actions/actionpackwindows/actionpackwindows.pro && \ $$QMAKE_LRELEASE actions/actionpackdevice/actionpackdevice.pro && \ $$QMAKE_LRELEASE actions/actionpacksystem/actionpacksystem.pro && \ $$QMAKE_LRELEASE actions/actionpackdata/actionpackdata.pro locale_release.CONFIG = no_link QMAKE_EXTRA_TARGETS += locale_release SUBDIRS += tools \ actiontools \ executer \ gui \ actexecuter \ actions/actionpackinternal \ actions/actionpackwindows \ actions/actionpackdevice \ actions/actionpacksystem \ actions/actionpackdata actiona-3.10.1/actions/000077500000000000000000000000001363645743000146655ustar00rootroot00000000000000actiona-3.10.1/actions/actionpackdata/000077500000000000000000000000001363645743000176335ustar00rootroot00000000000000actiona-3.10.1/actions/actionpackdata/actionpackdata.h000066400000000000000000000102231363645743000227500ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actionpack.h" #include "actions/writetextfiledefinition.h" #include "actions/readtextfiledefinition.h" #include "actions/writeinifiledefinition.h" #include "actions/readinifiledefinition.h" #include "actions/readregistrydefinition.h" #include "actions/writeregistrydefinition.h" #include "actions/readclipboarddefinition.h" #include "actions/writeclipboarddefinition.h" #include "actions/readbinaryfiledefinition.h" #include "actions/writebinaryfiledefinition.h" #include "actions/readenvironmentdefinition.h" #include "actions/copyfiledefinition.h" #include "actions/webdownloaddefinition.h" #include "actions/sendmaildefinition.h" #include "code/file.h" #include "code/clipboard.h" #include "code/registry.h" #include "code/inifile.h" #include "code/udp.h" #include "code/tcp.h" #include "code/sql.h" #include "code/tcpserver.h" #include "code/web.h" #include "code/mailattachment.h" #include "code/mailmessage.h" #include "code/mail.h" #include namespace ActionTools { class ActionDefinition; } class ActionPackData : public QObject, public ActionTools::ActionPack { Q_OBJECT Q_INTERFACES(ActionTools::ActionPack) Q_PLUGIN_METADATA(IID "tools.actiona.ActionPack" FILE "data.json") public: ActionPackData() = default; void createDefinitions() override { addActionDefinition(new Actions::WriteTextFileDefinition(this)); addActionDefinition(new Actions::ReadTextFileDefinition(this)); addActionDefinition(new Actions::WriteIniFileDefinition(this)); addActionDefinition(new Actions::ReadIniFileDefinition(this)); addActionDefinition(new Actions::ReadRegistryDefinition(this)); addActionDefinition(new Actions::WriteRegistryDefinition(this)); addActionDefinition(new Actions::ReadClipboardDefinition(this)); addActionDefinition(new Actions::WriteClipboardDefinition(this)); addActionDefinition(new Actions::ReadBinaryFileDefinition(this)); addActionDefinition(new Actions::WriteBinaryFileDefinition(this)); addActionDefinition(new Actions::ReadEnvironmentVariableDefinition(this)); addActionDefinition(new Actions::CopyFileDefinition(this)); addActionDefinition(new Actions::WebDownloadDefinition(this)); addActionDefinition(new Actions::SendMailDefinition(this)); } QString id() const override { return QStringLiteral("data"); } QString name() const override { return tr("Data related actions"); } Tools::Version version() const override { return Tools::Version(0, 0, 1); } void codeInit(QScriptEngine *scriptEngine) const override { addCodeClass(QStringLiteral("File"), scriptEngine); Code::File::registerClass(scriptEngine); addCodeClass(QStringLiteral("Clipboard"), scriptEngine); addCodeClass(QStringLiteral("Registry"), scriptEngine); addCodeClass(QStringLiteral("IniFile"), scriptEngine); addCodeClass(QStringLiteral("Udp"), scriptEngine); addCodeClass(QStringLiteral("Tcp"), scriptEngine); addCodeClass(QStringLiteral("Sql"), scriptEngine); Code::Sql::registerClass(scriptEngine); addCodeClass(QStringLiteral("TcpServer"), scriptEngine); addCodeClass(QStringLiteral("Web"), scriptEngine); addCodeClass(QStringLiteral("MailAttachment"), scriptEngine); addCodeClass(QStringLiteral("MailMessage"), scriptEngine); addCodeClass(QStringLiteral("Mail"), scriptEngine); } private: Q_DISABLE_COPY(ActionPackData) }; actiona-3.10.1/actions/actionpackdata/actionpackdata.pro000066400000000000000000000010401363645743000233160ustar00rootroot00000000000000include(../common_actions.pri) include(actions/actions.pri) include(code/code.pri) TARGET = ActionPackData QT += script network sql widgets OTHER_FILES += data.json HEADERS += actionpackdata.h win32:LIBS += -ladvapi32 \ -lshell32 win32:INCLUDEPATH += $${BOOST_INCLUDE} TRANSLATIONS = ../../locale/actionpackdata_fr_FR.ts RESOURCES += \ actionpackdata.qrc unix { locales.path = $${PREFIX}/share/actiona/locale locales.files = ../../locale/actionpackdata_fr_FR.qm locales.CONFIG = no_check_exist INSTALLS += locales } actiona-3.10.1/actions/actionpackdata/actionpackdata.qrc000066400000000000000000000012141363645743000233060ustar00rootroot00000000000000 icons/copyfile.png icons/readbinary.png icons/readclipboard.png icons/readini.png icons/readregistry.png icons/readtext.png icons/writebinary.png icons/writeclipboard.png icons/writeini.png icons/writeregistry.png icons/writetext.png icons/webdownload.png icons/readenvironment.png icons/sendmail.png actiona-3.10.1/actions/actionpackdata/actions/000077500000000000000000000000001363645743000212735ustar00rootroot00000000000000actiona-3.10.1/actions/actionpackdata/actions/actions.pri000066400000000000000000000024631363645743000234540ustar00rootroot00000000000000HEADERS += actions/readtextfiledefinition.h \ actions/readtextfileinstance.h \ actions/writeinifiledefinition.h \ actions/writeinifileinstance.h \ actions/readinifiledefinition.h \ actions/readinifileinstance.h \ actions/readregistryinstance.h \ actions/readregistrydefinition.h \ actions/writeregistrydefinition.h \ actions/writeregistryinstance.h \ actions/readclipboarddefinition.h \ actions/readclipboardinstance.h \ actions/writeclipboarddefinition.h \ actions/writeclipboardinstance.h \ actions/readbinaryfileinstance.h \ actions/readbinaryfiledefinition.h \ actions/writebinaryfileinstance.h \ actions/writebinaryfiledefinition.h \ actions/copyfileinstance.h \ actions/copyfiledefinition.h \ actions/writetextfileinstance.h \ actions/writetextfiledefinition.h \ actions/webdownloaddefinition.h \ actions/webdownloadinstance.h \ actions/readenvironmentdefinition.h \ actions/readenvironmentinstance.h \ actions/sendmaildefinition.h \ actions/sendmailinstance.h SOURCES += actions/readtextfileinstance.cpp \ actions/readregistryinstance.cpp \ actions/writeregistryinstance.cpp \ actions/writetextfileinstance.cpp \ actions/webdownloadinstance.cpp \ actions/readenvironmentinstance.cpp \ actions/readinifileinstance.cpp \ actions/sendmailinstance.cpp actiona-3.10.1/actions/actionpackdata/actions/copyfiledefinition.h000066400000000000000000000052731363645743000253360ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "copyfileinstance.h" #include "fileparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class CopyFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit CopyFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &source = addParameter({QStringLiteral("source"), tr("Source file")}); source.setTooltip(tr("The file to copy")); source.setMode(ActionTools::FileEdit::FileOpen); source.setCaption(tr("Choose the file")); source.setFilter(tr("All files (*.*)")); auto &destination = addParameter({QStringLiteral("destination"), tr("Destination")}); destination.setTooltip(tr("The destination file")); destination.setMode(ActionTools::FileEdit::FileSave); destination.setCaption(tr("Choose the destination file")); destination.setFilter(tr("All files (*.*)")); addException(CopyFileInstance::UnableToReadFileException, tr("Unable to read source file")); addException(CopyFileInstance::UnableToWriteFileException, tr("Unable to write destination file")); } QString name() const override { return QObject::tr("Copy file"); } QString id() const override { return QStringLiteral("ActionCopyFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Copy a file"); } ActionTools::ActionInstance *newActionInstance() const override { return new CopyFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/copyfile.png")); } private: Q_DISABLE_COPY(CopyFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/copyfileinstance.h000066400000000000000000000043651363645743000250130ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "datacopyactioninstance.h" #include namespace Actions { class CopyFileInstance : public ActionTools::DataCopyActionInstance { Q_OBJECT public: enum Exceptions { UnableToReadFileException = ActionTools::ActionException::UserException, UnableToWriteFileException }; CopyFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::DataCopyActionInstance(definition, parent) { } void startExecution() override { bool ok = true; QString sourceFile = evaluateString(ok, QStringLiteral("source")); QString destinationFile = evaluateString(ok, QStringLiteral("destination")); if(!ok) return; mSourceFile.setFileName(sourceFile); mDestinationFile.setFileName(destinationFile); if(!mSourceFile.open(QIODevice::ReadOnly)) { setCurrentParameter(QStringLiteral("source")); emit executionException(UnableToReadFileException, tr("Unable to read the source file \"%1\"").arg(sourceFile)); return; } if(!mDestinationFile.open(QIODevice::WriteOnly)) { mSourceFile.close(); setCurrentParameter(QStringLiteral("destination")); emit executionException(UnableToWriteFileException, tr("Unable to write to \"%1\"").arg(destinationFile)); return; } DataCopyActionInstance::startCopy(&mSourceFile, &mDestinationFile); emit showProgressDialog(tr("Copying file"), 100); emit updateProgressDialog(tr("Copying in progress")); } private: QFile mSourceFile; QFile mDestinationFile; Q_DISABLE_COPY(CopyFileInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/readbinaryfiledefinition.h000066400000000000000000000047711363645743000265060ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "readbinaryfileinstance.h" #include "fileparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadBinaryFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadBinaryFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &file = addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file to read from")); file.setMode(ActionTools::FileEdit::FileOpen); file.setCaption(tr("Choose the file")); file.setFilter(tr("All files (*.*)")); auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")}); variable.setTooltip(tr("The variable where to store the data")); addException(ReadBinaryFileInstance::UnableToReadFileException, tr("Unable to read file")); } QString name() const override { return QObject::tr("Read binary file"); } QString id() const override { return QStringLiteral("ActionReadBinaryFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Read a binary file"); } ActionTools::ActionInstance *newActionInstance() const override { return new ReadBinaryFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readbinary.png")); } private: Q_DISABLE_COPY(ReadBinaryFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/readbinaryfileinstance.h000066400000000000000000000042311363645743000261510ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "datacopyactioninstance.h" #include "code/rawdata.h" #include #include namespace Actions { class ReadBinaryFileInstance : public ActionTools::DataCopyActionInstance { Q_OBJECT public: enum Exceptions { UnableToReadFileException = ActionTools::ActionException::UserException }; ReadBinaryFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::DataCopyActionInstance(definition, parent) { } void startExecution() override { bool ok = true; QString filename = evaluateString(ok, QStringLiteral("file")); mVariable = evaluateVariable(ok, QStringLiteral("variable")); if(!ok) return; mFile.setFileName(filename); if(!DataCopyActionInstance::startCopy(&mFile, &mResult)) { setCurrentParameter(QStringLiteral("file")); emit executionException(UnableToReadFileException, tr("Unable to read the file \"%1\"").arg(filename)); return; } emit showProgressDialog(tr("Reading file"), 100); emit updateProgressDialog(tr("Reading in progress")); } private slots: void done() override { setVariable(mVariable, Code::RawData::constructor(mResult.buffer(), scriptEngine())); DataCopyActionInstance::done(); } private: void clean() override { DataCopyActionInstance::clean(); mResult.buffer().clear(); } QFile mFile; QBuffer mResult; QString mVariable; Q_DISABLE_COPY(ReadBinaryFileInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/readclipboarddefinition.h000066400000000000000000000041331363645743000263110ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "readclipboardinstance.h" #include "textparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadClipboardDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadClipboardDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &output = addParameter({QStringLiteral("variable"), tr("Variable")}); output.setTooltip(tr("The variable where to save the current clipboard value")); } QString name() const override { return QObject::tr("Read clipboard"); } QString id() const override { return QStringLiteral("ActionReadClipboard"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Read the clipboard contents"); } ActionTools::ActionInstance *newActionInstance() const override { return new ReadClipboardInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readclipboard.png")); } private: Q_DISABLE_COPY(ReadClipboardDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/readclipboardinstance.h000066400000000000000000000026311363645743000257660ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "script.h" #include #include namespace Actions { class ReadClipboardInstance : public ActionTools::ActionInstance { Q_OBJECT public: ReadClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} void startExecution() override { bool ok = true; QString variable = evaluateVariable(ok, QStringLiteral("variable")); if(!ok) return; QClipboard *clipboard = QApplication::clipboard(); setVariable(variable, clipboard->text()); executionEnded(); } private: Q_DISABLE_COPY(ReadClipboardInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/readenvironmentdefinition.h000066400000000000000000000064311363645743000267210ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "readenvironmentinstance.h" #include "variableparameterdefinition.h" #include "listparameterdefinition.h" #include "environmentvariableparameterdefinition.h" #include "groupdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadEnvironmentVariableDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadEnvironmentVariableDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ReadEnvironmentVariableInstance::modes", ReadEnvironmentVariableInstance::modes); auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")}); variable.setTooltip(tr("The variable used to store the selected information from your system environment")); auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")}); mode.setTooltip(tr("The environment read mode")); mode.setItems(ReadEnvironmentVariableInstance::modes); mode.setDefaultValue(ReadEnvironmentVariableInstance::modes.second.at(ReadEnvironmentVariableInstance::oneVariableMode)); auto &selectionMode = addGroup(); selectionMode.setMasterList(mode); selectionMode.setMasterValues({ReadEnvironmentVariableInstance::modes.first.at(ReadEnvironmentVariableInstance::oneVariableMode)}); auto &environmentVariableName = selectionMode.addParameter({QStringLiteral("environmentVariableName"), tr("Environment Variable")}); environmentVariableName.setTooltip(tr("The specific environment variable to read")); } QString name() const override { return QObject::tr("Read environment variable"); } QString id() const override { return QStringLiteral("ActionReadEnvironmentVariable"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Read a single or multiple environment variables"); } ActionTools::ActionInstance *newActionInstance() const override { return new ReadEnvironmentVariableInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readenvironment.png")); } private: Q_DISABLE_COPY(ReadEnvironmentVariableDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/readenvironmentinstance.cpp000066400000000000000000000050601363645743000267250ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "readenvironmentinstance.h" #include #include #include #include #include namespace Actions { Tools::StringListPair ReadEnvironmentVariableInstance::modes = { { QStringLiteral("allVariables"), QStringLiteral("oneVariable") }, { QStringLiteral(QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read all")), QStringLiteral(QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read one")) } }; void ReadEnvironmentVariableInstance::startExecution() { bool ok = true; QString variable = evaluateVariable(ok, QStringLiteral("variable")); Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode")); if(!ok) return; const QStringList &environment = QProcessEnvironment::systemEnvironment().toStringList(); QHash environmentHashVariableValue; environmentHashVariableValue.reserve(environment.count()+2); //doc said ideally 'slightly more than the maximum nb of item' for(QString environmentVariableAndValue: environment) { QStringList KeyValue = environmentVariableAndValue.split(QStringLiteral("=")); environmentHashVariableValue[KeyValue.at(0)] = KeyValue.at(1); } if(mode == oneVariableMode) { QString environmentVariable = evaluateString(ok, QStringLiteral("environmentVariableName")); if (environmentHashVariableValue.contains(environmentVariable)) setVariable(variable, environmentHashVariableValue.value(environmentVariable)); else { emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The specified variable cannot be found in the system environment")); return; } } else setArrayKeyValue(variable, environmentHashVariableValue); executionEnded(); } } actiona-3.10.1/actions/actionpackdata/actions/readenvironmentinstance.h000066400000000000000000000024261363645743000263750ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "script.h" namespace Actions { class ReadEnvironmentVariableInstance : public ActionTools::ActionInstance { Q_OBJECT Q_ENUMS(Mode) public: enum Mode { allVariablesMode, oneVariableMode }; ReadEnvironmentVariableInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} static Tools::StringListPair modes; void startExecution() override; private: Q_DISABLE_COPY(ReadEnvironmentVariableInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/readinifiledefinition.h000066400000000000000000000073411363645743000257750ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "readinifileinstance.h" #include "textparameterdefinition.h" #include "fileparameterdefinition.h" #include "variableparameterdefinition.h" #include "listparameterdefinition.h" #include "groupdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadIniFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadIniFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ReadIniFileInstance::modes", ReadIniFileInstance::modes); auto &file = addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file to read from")); file.setMode(ActionTools::FileEdit::FileOpen); file.setCaption(tr("Choose the INI file")); file.setFilter(tr("INI files (*.ini);;All files (*.*)")); auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")}); variable.setTooltip(tr("The variable where to store the data")); auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")}); mode.setTooltip(tr("The INI file read mode")); mode.setItems(ReadIniFileInstance::modes); mode.setDefaultValue(ReadIniFileInstance::modes.second.at(ReadIniFileInstance::SingleParameter)); auto &selectionMode = addGroup(); selectionMode.setMasterList(mode); selectionMode.setMasterValues({ReadIniFileInstance::modes.first.at(ReadIniFileInstance::SingleParameter)}); auto §ion = selectionMode.addParameter({QStringLiteral("section"), tr("Section")}); section.setTooltip(tr("The parameter section")); auto ¶meter = selectionMode.addParameter({QStringLiteral("parameter"), tr("Parameter")}); parameter.setTooltip(tr("The parameter name")); addException(ReadIniFileInstance::UnableToReadFileException, tr("Unable to read file")); addException(ReadIniFileInstance::UnableToFindSectionException, tr("Unable to find section")); } QString name() const override { return QObject::tr("Read INI file"); } QString id() const override { return QStringLiteral("ActionReadIniFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Read one or all the entries in an INI file"); } ActionTools::ActionInstance *newActionInstance() const override { return new ReadIniFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readini.png")); } private: Q_DISABLE_COPY(ReadIniFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/readinifileinstance.cpp000066400000000000000000000070631363645743000260050ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "readinifileinstance.h" #include "stringlistpair.h" #include #include namespace Actions { Tools::StringListPair ReadIniFileInstance::modes = { { QStringLiteral("singleParameter"), QStringLiteral("wholeFile") }, { QStringLiteral(QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read a single parameter")), QStringLiteral(QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read the entire file")) } }; void ReadIniFileInstance::startExecution() { bool ok = true; QString filename = evaluateString(ok, QStringLiteral("file")); QString variable = evaluateVariable(ok, QStringLiteral("variable")); Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode")); if(!ok) return; if(filename.isEmpty()) { emit executionException(UnableToReadFileException, tr("Unable to read the file")); return; } boost::property_tree::ptree tree; try { boost::property_tree::ini_parser::read_ini(filename.toStdString(), tree); } catch(const std::runtime_error &) { setCurrentParameter(QStringLiteral("filename")); emit executionException(UnableToReadFileException, tr("Unable to read the file")); return; } if(mode == WholeFile) { QHash fileContent; for(const auto §ion: tree) { for(const auto ¶meter: section.second) { fileContent[QString::fromStdString(section.first + "/" + parameter.first)] = QString::fromStdString(parameter.second.get_value()); } } setArrayKeyValue(variable, fileContent); } else { QString section = evaluateString(ok, QStringLiteral("section")); QString parameter = evaluateString(ok, QStringLiteral("parameter")); if(!ok) return; auto sectionNode = tree.get_child_optional(section.toStdString()); if(!sectionNode) { setCurrentParameter(QStringLiteral("section")); emit executionException(UnableToFindSectionException, tr("Unable to find the section named \"%1\"").arg(section)); return; } try { setVariable(variable, QString::fromStdString((*sectionNode).get(parameter.toStdString()))); } catch(const std::runtime_error &) { setCurrentParameter(QStringLiteral("parameter")); emit executionException(UnableToFindSectionException, tr("Unable to find the parameter named \"%1\"").arg(parameter)); return; } } executionEnded(); } } actiona-3.10.1/actions/actionpackdata/actions/readinifileinstance.h000066400000000000000000000025461363645743000254530ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" namespace Actions { class ReadIniFileInstance : public ActionTools::ActionInstance { Q_OBJECT Q_ENUMS(Mode) public: enum Mode { SingleParameter, WholeFile }; enum Exceptions { UnableToReadFileException = ActionTools::ActionException::UserException, UnableToFindSectionException }; ReadIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} static Tools::StringListPair modes; void startExecution() override; private: Q_DISABLE_COPY(ReadIniFileInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/readregistrydefinition.h000066400000000000000000000061251363645743000262250ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "readregistryinstance.h" #include "listparameterdefinition.h" #include "textparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadRegistryDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadRegistryDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &key = addParameter({QStringLiteral("key"), tr("Key")}); key.setTooltip(tr("The registry key to read from")); key.setItems(ReadRegistryInstance::keys); key.setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser)); auto &subKey = addParameter({QStringLiteral("subKey"), tr("Subkey")}); subKey.setTooltip(tr("The registry subkey to read from")); auto &value = addParameter({QStringLiteral("value"), tr("Value")}); value.setTooltip(tr("The value to read")); auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")}); variable.setTooltip(tr("The variable where to save the value read from the registry")); addException(ReadRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey")); addException(ReadRegistryInstance::CannotFindValueException, tr("Cannot find value")); addException(ReadRegistryInstance::InvalidValueType, tr("Invalid value type")); } QString name() const override { return QObject::tr("Read registry"); } QString id() const override { return QStringLiteral("ActionReadRegistry"); } ActionTools::Flag flags() const override { return ActionTools::WorksOnWindows | ActionTools::Official; } QString description() const override { return QObject::tr("Read an entry from the registry"); } ActionTools::ActionInstance *newActionInstance() const override { return new ReadRegistryInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readregistry.png")); } private: Q_DISABLE_COPY(ReadRegistryDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/readregistryinstance.cpp000066400000000000000000000052311363645743000262310ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "readregistryinstance.h" #include #ifdef Q_OS_WIN #include #endif namespace Actions { Tools::StringListPair ReadRegistryInstance::keys = { { QStringLiteral("classesRoot"), QStringLiteral("currentConfig"), QStringLiteral("currentUser"), QStringLiteral("users"), QStringLiteral("localMachine") }, { QStringLiteral("Classes root"), QStringLiteral("Current config"), QStringLiteral("Current user"), QStringLiteral("Users"), QStringLiteral("Local machine") } }; //Note : This is not translated, because this is not translated either in Regedit void ReadRegistryInstance::startExecution() { #ifdef Q_OS_WIN bool ok = true; ActionTools::Registry::Key key = evaluateListElement(ok, keys, QStringLiteral("key")); QString subKey = evaluateString(ok, QStringLiteral("subKey")); QString value = evaluateString(ok, QStringLiteral("value")); QString variable = evaluateVariable(ok, QStringLiteral("variable")); if(!ok) return; QVariant resultValue; switch(ActionTools::Registry::read(resultValue, key, subKey, value)) { case ActionTools::Registry::ReadCannotFindSubKey: setCurrentParameter(QStringLiteral("subKey")); emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey)); return; case ActionTools::Registry::ReadCannotFindValue: setCurrentParameter(QStringLiteral("value")); emit executionException(CannotFindValueException, tr("Cannot find value \"%1\"").arg(value)); return; case ActionTools::Registry::ReadInvalidValueType: setCurrentParameter(QStringLiteral("value")); emit executionException(CannotFindValueException, tr("Invalid value type")); return; default: setVariable(variable, scriptEngine()->newVariant(resultValue)); break; } #endif executionEnded(); } } actiona-3.10.1/actions/actionpackdata/actions/readregistryinstance.h000066400000000000000000000025131363645743000256760ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "stringlistpair.h" #include "registry.h" namespace Actions { class ReadRegistryInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Exceptions { CannotFindSubKeyException = ActionTools::ActionException::UserException, CannotFindValueException, InvalidValueType }; ReadRegistryInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} static Tools::StringListPair keys; void startExecution() override; private: Q_DISABLE_COPY(ReadRegistryInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/readtextfiledefinition.h000066400000000000000000000074051363645743000262030ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "readtextfileinstance.h" #include "fileparameterdefinition.h" #include "variableparameterdefinition.h" #include "numberparameterdefinition.h" #include "listparameterdefinition.h" #include "groupdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadTextFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadTextFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ReadTextFileInstance::modes", ReadTextFileInstance::modes); auto &file = addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file you want to read")); auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")}); variable.setTooltip(tr("The variable where to save the text read from the file")); auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")}, 1); mode.setTooltip(tr("The file read mode")); mode.setItems(ReadTextFileInstance::modes); mode.setDefaultValue(ReadTextFileInstance::modes.second.at(ReadTextFileInstance::Full)); auto &selectionMode = addGroup(1); selectionMode.setMasterList(mode); selectionMode.setMasterValues({ReadTextFileInstance::modes.first.at(ReadTextFileInstance::Selection)}); auto &firstline = selectionMode.addParameter({QStringLiteral("firstline"), tr("First line")}, 1); firstline.setTooltip(tr("The line where to start reading the file")); firstline.setMinimum(1); firstline.setDefaultValue(QStringLiteral("1")); auto &lastline = selectionMode.addParameter({QStringLiteral("lastline"), tr("Last line")}, 1); lastline.setTooltip(tr("The line where to stop reading the file")); lastline.setMinimum(1); lastline.setDefaultValue(QStringLiteral("1")); addException(ReadTextFileInstance::CannotOpenFileException, tr("Cannot read file")); } QString name() const override { return QObject::tr("Read text file"); } QString id() const override { return QStringLiteral("ActionReadTextFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Read a plain text file"); } ActionTools::ActionInstance *newActionInstance() const override { return new ReadTextFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readtext.png")); } QStringList tabs() const override { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(ReadTextFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/readtextfileinstance.cpp000066400000000000000000000061131363645743000262050ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "readtextfileinstance.h" #include #include namespace Actions { Tools::StringListPair ReadTextFileInstance::modes = { { QStringLiteral("full"), QStringLiteral("selection") }, { QStringLiteral(QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read the entire file")), QStringLiteral(QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read only a selection")) } }; void ReadTextFileInstance::startExecution() { bool ok = true; QString filepath = evaluateString(ok, QStringLiteral("file")); QString variable = evaluateVariable(ok, QStringLiteral("variable")); Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode")); int firstline = evaluateInteger(ok, QStringLiteral("firstline")); int lastline = evaluateInteger(ok, QStringLiteral("lastline")); if(!ok) return; if(mode == Selection) { if(firstline < 1) { setCurrentParameter(QStringLiteral("firstline")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid first line value : %1").arg(firstline)); return; } if(lastline < 1) { setCurrentParameter(QStringLiteral("lastline")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid last line value : %1").arg(lastline)); return; } if(lastline < firstline) { setCurrentParameter(QStringLiteral("firstline")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The first line has to be smaller than the last line")); return; } } QFile file(filepath); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) { setCurrentParameter(QStringLiteral("file")); emit executionException(CannotOpenFileException, tr("Cannot open file")); return; } //Line counting starts at 1 --firstline; --lastline; QString result; QTextStream stream(&file); stream.setAutoDetectUnicode(true); if(mode == Full) result = stream.readAll(); else { for(int line = 0; !stream.atEnd(); ++line) { QString readLine = stream.readLine(); if(line >= firstline && line <= lastline) { if(!result.isEmpty()) result += QLatin1Char('\n'); result += readLine; } if(line > lastline) break; } } setVariable(variable, result); file.close(); executionEnded(); } } actiona-3.10.1/actions/actionpackdata/actions/readtextfileinstance.h000066400000000000000000000024751363645743000256610ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "stringlistpair.h" namespace Actions { class ReadTextFileInstance : public ActionTools::ActionInstance { Q_OBJECT Q_ENUMS(Mode) public: enum Mode { Full, Selection }; enum Exceptions { CannotOpenFileException = ActionTools::ActionException::UserException }; ReadTextFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} static Tools::StringListPair modes; void startExecution() override; private: Q_DISABLE_COPY(ReadTextFileInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/sendmaildefinition.h000066400000000000000000000146371363645743000253240ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "sendmailinstance.h" #include "textparameterdefinition.h" #include "booleanparameterdefinition.h" #include "fileparameterdefinition.h" #include "listparameterdefinition.h" #include "numberparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class SendMailDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit SendMailDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("SendMailInstance::attachmentContentTypes", SendMailInstance::attachmentContentTypes); auto &serverName = addParameter({QStringLiteral("serverName"), tr("Server name")}); serverName.setTooltip(tr("The name or IP of the SMTP server to use\nExample: mail.example.com")); auto &secureConnection = addParameter({QStringLiteral("secureConnection"), tr("Secure connection")}); secureConnection.setTooltip(tr("Secure (encrypted) connection to the server")); secureConnection.setDefaultValue(QStringLiteral("true")); auto &userName = addParameter({QStringLiteral("userName"), tr("User name")}); userName.setTooltip(tr("The user (or login) name to use\nMany SMTP servers use the e-mail address as user name")); auto &password = addParameter({QStringLiteral("password"), tr("Password")}); password.setTooltip(tr("The password to use")); auto &sender = addParameter({QStringLiteral("sender"), tr("Sender")}); sender.setTooltip(tr("The sender's e-mail address")); auto &receivers = addParameter({QStringLiteral("receivers"), tr("Receivers")}); receivers.setTooltip(tr("The receiver's e-mail address\nCan contain multiple receivers separated with a comma")); auto &subject = addParameter({QStringLiteral("subject"), tr("Subject")}); subject.setTooltip(tr("The e-mail's subject")); auto &body = addParameter({QStringLiteral("body"), tr("Body")}); body.setTooltip(tr("The e-mail's body")); auto &attachmentName = addParameter({QStringLiteral("attachmentName"), tr("Attachment name")}, 1); attachmentName.setTooltip(tr("The attachment name, an empty name means that there is no attachment")); auto &attachmentData = addParameter({QStringLiteral("attachmentData"), tr("Attachment data")}, 1); attachmentData.setTooltip(tr("The data to attach to the e-mail")); auto &attachmentContentType = addParameter({QStringLiteral("attachmentContentType"), tr("Attachment content type")}, 1); attachmentContentType.setTooltip(tr("The MIME content type of the attachment\nIf left empty, Actiona will try to deduce it from the data type")); attachmentContentType.setItems(SendMailInstance::attachmentContentTypes); attachmentContentType.setDefaultValue(SendMailInstance::attachmentContentTypes.second.at(SendMailInstance::AutoDetectAttachmentContentType)); auto &carbonCopy = addParameter({QStringLiteral("carbonCopy"), tr("Carbon copy (Cc)")}, 2); carbonCopy.setTooltip(tr("The carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma")); auto &blindCarbonCopy = addParameter({QStringLiteral("blindCarbonCopy"), tr("Blind carbon copy (Bcc)")}, 2); blindCarbonCopy.setTooltip(tr("The blind carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma")); auto &serverPort = addParameter({QStringLiteral("serverPort"), tr("Server port")}, 2); serverPort.setTooltip(tr("The server port")); serverPort.setMinimum(0); serverPort.setMaximum(65535); serverPort.setDefaultValue(QStringLiteral("0")); serverPort.setSpecialValueText(tr("Default port")); auto &extraHeaders = addParameter({QStringLiteral("extraHeaders"), tr("Extra headers")}, 2); extraHeaders.setTooltip(tr("Extra headers to add to the e-mail\nShould contain one header per line")); addException(SendMailInstance::ConnectionErrorException, tr("Connection error")); addException(SendMailInstance::ErrorWhileSendingEMailException, tr("Error while sending e-mail")); } QString name() const override { return QObject::tr("Send e-mail"); } QString id() const override { return QStringLiteral("ActionSendMail"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Sends an e-mail"); } ActionTools::ActionInstance *newActionInstance() const override { return new SendMailInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/sendmail.png")); } QStringList tabs() const override { return {ActionDefinition::StandardTabs.at(0), tr("Attachment"), ActionDefinition::StandardTabs.at(1)}; } private: Q_DISABLE_COPY(SendMailDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/sendmailinstance.cpp000066400000000000000000000347241363645743000253320ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "sendmailinstance.h" #include "code/rawdata.h" #include "code/image.h" #include "qxtsmtp/qxtsmtp.h" #include "qxtsmtp/qxtmailmessage.h" #include "qxtsmtp/qxtmailattachment.h" #include #include #include #include #include #include #include namespace Actions { Tools::StringListPair SendMailInstance::attachmentContentTypes = { { QStringLiteral("autoDetect"), QStringLiteral("application/octet-stream"), QStringLiteral("text/plain"), QStringLiteral("image/jpeg"), QStringLiteral("image/png") }, { QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Auto detect")), QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Binary")), QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Text")), QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Jpg image")), QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Png image")) } }; SendMailInstance::SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mSmtp(nullptr), mProgressDialog(new QProgressDialog) { } SendMailInstance::~SendMailInstance() { delete mProgressDialog; } void SendMailInstance::startExecution() { bool ok = true; QString serverName = evaluateString(ok, QStringLiteral("serverName")); bool secureConnection = evaluateBoolean(ok, QStringLiteral("secureConnection")); QString userName = evaluateString(ok, QStringLiteral("userName")); QString password = evaluateString(ok, QStringLiteral("password")); QString sender = evaluateString(ok, QStringLiteral("sender")); QString receivers = evaluateString(ok, QStringLiteral("receivers")); QString subject = evaluateString(ok, QStringLiteral("subject")); QString body = evaluateString(ok, QStringLiteral("body")); QString attachmentName = evaluateString(ok, QStringLiteral("attachmentName")); QScriptValue attachmentData = evaluateValue(ok, QStringLiteral("attachmentData")); QString attachmentContentType = evaluateEditableListElement(ok, attachmentContentTypes, QStringLiteral("attachmentContentType")); QString carbonCopy = evaluateString(ok, QStringLiteral("carbonCopy")); QString blindCarbonCopy = evaluateString(ok, QStringLiteral("blindCarbonCopy")); int serverPort = evaluateInteger(ok, QStringLiteral("serverPort")); QString extraHeaders = evaluateString(ok, QStringLiteral("extraHeaders")); if(serverName.isEmpty() || sender.isEmpty() || receivers.isEmpty()) { executionEnded(); return; } if(attachmentContentType == QLatin1String("autoDetect") && !attachmentName.isEmpty() && attachmentData.isValid()) { bool foundAttachmentContentType = true; if(QObject *scriptObject = attachmentData.toQObject()) { if(qobject_cast(scriptObject)) attachmentContentType = QStringLiteral("application/octet-stream"); else if(qobject_cast(scriptObject)) { QString lowerAttachmentName = attachmentName.toLower(); if(lowerAttachmentName.endsWith(QStringLiteral(".jpg")) || lowerAttachmentName.endsWith(QStringLiteral(".jpeg"))) attachmentContentType = QStringLiteral("image/jpeg"); else attachmentContentType = QStringLiteral("image/png"); } else foundAttachmentContentType = false; } else if(attachmentData.isString()) attachmentContentType = QStringLiteral("text/plain"); else foundAttachmentContentType = false; if(!foundAttachmentContentType) { setCurrentParameter(QStringLiteral("attachmentContentType")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Failed to auto detect the attachment content type")); return; } } validateParameterRange(ok, serverPort, QStringLiteral("serverPort"), tr("server port"), 0, 65535); if(!ok) return; mSmtp = new QxtSmtp(this); connect(mSmtp, static_cast(&QxtSmtp::connectionFailed), this, &SendMailInstance::connectionFailed); connect(mSmtp, static_cast(&QxtSmtp::encryptionFailed), this, &SendMailInstance::encryptionFailed); connect(mSmtp, static_cast(&QxtSmtp::authenticationFailed), this, &SendMailInstance::authenticationFailed); connect(mSmtp, &QxtSmtp::authenticated, this, &SendMailInstance::authenticated); connect(mSmtp, static_cast(&QxtSmtp::senderRejected), this, &SendMailInstance::senderRejected); connect(mSmtp, static_cast(&QxtSmtp::recipientRejected), this, &SendMailInstance::recipientRejected); connect(mSmtp, static_cast(&QxtSmtp::mailFailed), this, &SendMailInstance::mailFailed); connect(mSmtp, &QxtSmtp::mailSent, this, &SendMailInstance::mailSent); connect(mSmtp, &QxtSmtp::disconnected, this, &SendMailInstance::disconnected); connect(mProgressDialog, &QProgressDialog::canceled, this, &SendMailInstance::canceled); mSmtp->setUsername(userName.toUtf8()); mSmtp->setPassword(password.toUtf8()); QxtMailMessage mailMessage; mailMessage.setSender(sender); mailMessage.setSubject(subject); mailMessage.setBody(body); mailMessage.setExtraHeader(QStringLiteral("Date"), QDateTime::currentDateTime().toString(Qt::RFC2822Date)); for(QString receiver: receivers.split(QLatin1Char(','), QString::SkipEmptyParts)) mailMessage.addRecipient(receiver.trimmed()); for(QString carbonCopyReceiver: carbonCopy.split(QLatin1Char(','), QString::SkipEmptyParts)) mailMessage.addRecipient(carbonCopyReceiver.trimmed(), QxtMailMessage::Cc); for(QString blindCarbonCopyReceiver: blindCarbonCopy.split(QLatin1Char(','), QString::SkipEmptyParts)) mailMessage.addRecipient(blindCarbonCopyReceiver.trimmed(), QxtMailMessage::Bcc); for(QString extraHeader: extraHeaders.split(QLatin1Char('\n'), QString::SkipEmptyParts)) { QStringList extraHeaderParts = extraHeader.split(QLatin1Char(':'), QString::SkipEmptyParts); if(extraHeaderParts.size() != 2) { setCurrentParameter(QStringLiteral("extraHeaders")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr(R"(Failed to parse an extra header: "%1" has to be in the form "name: value")").arg(extraHeader)); return; } mailMessage.setExtraHeader(extraHeaderParts[0].trimmed(), extraHeaderParts[1]); } if(!attachmentName.isEmpty()) { if(!attachmentData.isValid()) { setCurrentParameter(QStringLiteral("attachmentData")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid attachment data")); return; } QByteArray attachmentDataByteArray; if(QObject *scriptObject = attachmentData.toQObject()) { if(auto codeRawData = qobject_cast(scriptObject)) attachmentDataByteArray = codeRawData->byteArray(); else if(auto codeImage = qobject_cast(scriptObject)) { QImage image = codeImage->image(); QString format; if(attachmentContentType == QLatin1String("image/png")) format = QStringLiteral("PNG"); else if(attachmentContentType == QLatin1String("image/jpeg")) format = QStringLiteral("JPG"); else { setCurrentParameter(QStringLiteral("attachmentData")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Unknown image type; supported types are PNG and JPG")); return; } QBuffer buffer; buffer.open(QIODevice::WriteOnly); if(!image.save(&buffer, format.toLatin1().constData())) { setCurrentParameter(QStringLiteral("attachmentData")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid image data")); return; } attachmentDataByteArray = buffer.buffer(); } else attachmentDataByteArray = attachmentData.toString().toUtf8(); } else { if(attachmentContentType == QLatin1String("text/plain")) attachmentDataByteArray = attachmentData.toString().toUtf8(); else attachmentDataByteArray = attachmentData.toVariant().toByteArray(); } mailMessage.addAttachment(attachmentName, QxtMailAttachment(attachmentDataByteArray, attachmentContentType)); } if(serverPort == 0) { if(secureConnection) mSmtp->connectToSecureHost(serverName); else mSmtp->connectToHost(serverName); } else { if(secureConnection) mSmtp->connectToSecureHost(serverName, serverPort); else mSmtp->connectToHost(serverName, serverPort); } mSmtp->send(mailMessage); mProgressDialog->setModal(false); mProgressDialog->setWindowTitle(tr("Sending e-mail")); mProgressDialog->setLabelText(tr("Connecting...")); mProgressDialog->setMaximum(2); mProgressDialog->show(); } void SendMailInstance::stopExecution() { cleanup(); } void SendMailInstance::connectionFailed(const QByteArray &msg) { cleanup(); emit executionException(ConnectionErrorException, tr("Connection failed: %1").arg(QString::fromUtf8(msg))); } void SendMailInstance::encryptionFailed(const QByteArray &msg) { cleanup(); emit executionException(ConnectionErrorException, tr("Encryption failed: %1").arg(QString::fromUtf8(msg))); } void SendMailInstance::authenticationFailed(const QByteArray &msg) { cleanup(); emit executionException(ConnectionErrorException, tr("Authentication failed: %1").arg(QString::fromUtf8(msg))); } void SendMailInstance::authenticated() { mProgressDialog->setValue(1); mProgressDialog->setLabelText(tr("Sending e-mail...")); } void SendMailInstance::senderRejected(int mailID, const QString &address, const QByteArray &msg) { Q_UNUSED(mailID) cleanup(); emit executionException(ErrorWhileSendingEMailException, tr("Sender %1 has been rejected: %2").arg(address).arg(QString::fromUtf8(msg))); } void SendMailInstance::recipientRejected(int mailID, const QString &address, const QByteArray &msg) { Q_UNUSED(mailID) cleanup(); emit executionException(ErrorWhileSendingEMailException, tr("Recipient %1 has been rejected: %2").arg(address).arg(QString::fromUtf8(msg))); } void SendMailInstance::mailFailed(int mailID, int errorCode, const QByteArray &msg) { Q_UNUSED(mailID) cleanup(); QString errorString; switch(errorCode) { case QxtSmtp::NoRecipients: errorString = tr("No recipients"); break; case QxtSmtp::CommandUnrecognized: errorString = tr("Command unrecognized"); break; case QxtSmtp::SyntaxError: errorString = tr("Syntax error"); break; case QxtSmtp::CommandNotImplemented: errorString = tr("Command not implemented"); break; case QxtSmtp::BadSequence: errorString = tr("Bad sequence"); break; case QxtSmtp::ParameterNotImplemented: errorString = tr("Parameter not implemented"); break; case QxtSmtp::MailboxUnavailable: errorString = tr("Mailbox unavailable"); break; case QxtSmtp::UserNotLocal: errorString = tr("User not local"); break; case QxtSmtp::MessageTooLarge: errorString = tr("Message is too large"); break; case QxtSmtp::InvalidMailboxName: errorString = tr("Invalid mailbox name"); break; case QxtSmtp::TransactionFailed: errorString = tr("Transaction failed"); break; default: errorString = tr("Unknown error"); break; } emit executionException(ErrorWhileSendingEMailException, tr("Failed sending e-mail: %1 (%2)").arg(errorString).arg(QString::fromUtf8(msg))); } void SendMailInstance::mailSent(int mailID) { Q_UNUSED(mailID) cleanup(); executionEnded(); } void SendMailInstance::disconnected() { mSmtp->deleteLater(); } void SendMailInstance::canceled() { cleanup(); executionEnded(); } void SendMailInstance::cleanup() { mSmtp->disconnect(); mSmtp->disconnectFromHost(); mProgressDialog->disconnect(); mProgressDialog->close(); } } actiona-3.10.1/actions/actionpackdata/actions/sendmailinstance.h000066400000000000000000000044641363645743000247750ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "script.h" #include "stringlistpair.h" class QxtSmtp; class QProgressDialog; namespace Actions { class SendMailInstance : public ActionTools::ActionInstance { Q_OBJECT Q_ENUMS(AttachmentContentType) public: enum AttachmentContentType { AutoDetectAttachmentContentType, BinaryAttachmentContentType, TextAttachmentContentType, JpgImageAttachmentContentType, PngImageAttachmentContentType }; enum Exceptions { ConnectionErrorException = ActionTools::ActionException::UserException, ErrorWhileSendingEMailException }; SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr); ~SendMailInstance() override; static Tools::StringListPair attachmentContentTypes; void startExecution() override; void stopExecution() override; private slots: void connectionFailed(const QByteArray &msg); void encryptionFailed(const QByteArray &msg); void authenticationFailed(const QByteArray &msg); void authenticated(); void senderRejected(int mailID, const QString &address, const QByteArray &msg); void recipientRejected(int mailID, const QString &address, const QByteArray &msg); void mailFailed(int mailID, int errorCode, const QByteArray &msg); void mailSent(int mailID); void disconnected(); void canceled(); private: Q_DISABLE_COPY(SendMailInstance) void cleanup(); QxtSmtp *mSmtp; QProgressDialog *mProgressDialog; }; } actiona-3.10.1/actions/actionpackdata/actions/webdownloaddefinition.h000066400000000000000000000103161363645743000260230ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "webdownloadinstance.h" #include "textparameterdefinition.h" #include "listparameterdefinition.h" #include "variableparameterdefinition.h" #include "fileparameterdefinition.h" #include "groupdefinition.h" #include "booleanparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WebDownloadDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit WebDownloadDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("WebDownloadInstance::destinations", WebDownloadInstance::destinations); auto &url = addParameter({QStringLiteral("url"), tr("URL")}); url.setTooltip(tr("The URL of the data to download")); auto &destination = addParameter({QStringLiteral("destination"), tr("Destination")}); destination.setTooltip(tr("The destination where to write the downloaded data")); destination.setItems(WebDownloadInstance::destinations); destination.setDefaultValue(WebDownloadInstance::destinations.second.at(WebDownloadInstance::Variable)); auto &variableMode = addGroup(); variableMode.setMasterList(destination); variableMode.setMasterValues({WebDownloadInstance::destinations.first.at(WebDownloadInstance::Variable)}); auto &variable = variableMode.addParameter({QStringLiteral("variable"), tr("Variable")}); variable.setTooltip(tr("The variable where to write the downloaded data")); auto &fileMode = addGroup(); fileMode.setMasterList(destination); fileMode.setMasterValues({WebDownloadInstance::destinations.first.at(WebDownloadInstance::File)}); auto &file = fileMode.addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file where to write the downloaded data")); file.setMode(ActionTools::FileEdit::FileSave); file.setCaption(tr("Choose the destination file")); file.setFilter(tr("All files (*.*)")); auto &showProgress = addParameter({QStringLiteral("showProgress"), tr("Show progress")}, 1); showProgress.setTooltip(tr("Should the download progress be shown")); showProgress.setDefaultValue(QStringLiteral("true")); addException(WebDownloadInstance::CannotOpenFileException, tr("Cannot write to file")); addException(WebDownloadInstance::DownloadException, tr("Download error")); } QString name() const override { return QObject::tr("Web download"); } QString id() const override { return QStringLiteral("ActionWebDownload"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Downloads data from the Web"); } ActionTools::ActionInstance *newActionInstance() const override { return new WebDownloadInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/webdownload.png")); } QStringList tabs() const override { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(WebDownloadDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/webdownloadinstance.cpp000066400000000000000000000105161363645743000260340ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "webdownloadinstance.h" #include #include #include #include namespace Actions { Tools::StringListPair WebDownloadInstance::destinations = { { QStringLiteral("variable"), QStringLiteral("file") }, { QStringLiteral(QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "Variable")), QStringLiteral(QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "File")) } }; WebDownloadInstance::WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mNetworkAccessManager(new QNetworkAccessManager(this)), mReply(nullptr), mDestination(Variable), mProgressDialog(new QProgressDialog) { connect(mProgressDialog, &QProgressDialog::canceled, this, &WebDownloadInstance::canceled); } WebDownloadInstance::~WebDownloadInstance() { delete mProgressDialog; } void WebDownloadInstance::startExecution() { bool ok = true; QString urlString = evaluateString(ok, QStringLiteral("url")); mDestination = evaluateListElement(ok, destinations, QStringLiteral("destination")); mVariable = evaluateVariable(ok, QStringLiteral("variable")); QString file = evaluateString(ok, QStringLiteral("file")); if(!ok) return; QUrl url(urlString); if(url.scheme() == QString()) url = QUrl(QStringLiteral("http://") + urlString, QUrl::TolerantMode); if(!url.isValid()) { setCurrentParameter(QStringLiteral("url")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid URL")); return; } if(mDestination == File) { mFile.setFileName(file); if(!mFile.open(QIODevice::WriteOnly)) { setCurrentParameter(QStringLiteral("file")); emit executionException(CannotOpenFileException, tr("Cannot write to file")); return; } } mReply = mNetworkAccessManager->get(QNetworkRequest(url)); connect(mReply, &QNetworkReply::finished, this, &WebDownloadInstance::finished); connect(mReply, &QNetworkReply::downloadProgress, this, &WebDownloadInstance::downloadProgress); connect(mReply, &QNetworkReply::readyRead, this, &WebDownloadInstance::readyRead); mProgressDialog->setModal(false); mProgressDialog->setWindowTitle(tr("Downloading")); mProgressDialog->setLabelText(tr("Downloading...")); mProgressDialog->setMaximum(100); mProgressDialog->show(); } void WebDownloadInstance::stopExecution() { if(mReply) mReply->abort(); } void WebDownloadInstance::finished() { mFile.close(); switch(mReply->error()) { case QNetworkReply::NoError: if(mDestination == Variable) setVariable(mVariable, QString::fromUtf8(mReply->readAll())); executionEnded(); break; case QNetworkReply::OperationCanceledError: if(mDestination == File) mFile.remove(); executionEnded(); break; default: { if(mDestination == File) mFile.remove(); setCurrentParameter(QStringLiteral("url")); emit executionException(DownloadException, tr("Download error: %1").arg(mReply->errorString())); } break; } mProgressDialog->close(); mReply->deleteLater(); mReply = nullptr; } void WebDownloadInstance::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { if(bytesTotal > 0) mProgressDialog->setValue((bytesReceived * 100) / bytesTotal); } void WebDownloadInstance::readyRead() { if(mDestination == File) mFile.write(mReply->readAll()); } void WebDownloadInstance::canceled() { if(mReply) mReply->abort(); } } actiona-3.10.1/actions/actionpackdata/actions/webdownloadinstance.h000066400000000000000000000034211363645743000254760ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "script.h" #include "stringlistpair.h" #include class QNetworkAccessManager; class QNetworkReply; class QProgressDialog; namespace Actions { class WebDownloadInstance : public ActionTools::ActionInstance { Q_OBJECT Q_ENUMS(Destination) public: enum Destination { Variable, File }; enum Exceptions { CannotOpenFileException = ActionTools::ActionException::UserException, DownloadException }; WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr); ~WebDownloadInstance() override; static Tools::StringListPair destinations; void startExecution() override; void stopExecution() override; private slots: void finished(); void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void readyRead(); void canceled(); private: Q_DISABLE_COPY(WebDownloadInstance) QNetworkAccessManager *mNetworkAccessManager; QNetworkReply *mReply; QString mVariable; Destination mDestination; QFile mFile; QProgressDialog *mProgressDialog; }; } actiona-3.10.1/actions/actionpackdata/actions/writebinaryfiledefinition.h000066400000000000000000000047351363645743000267250ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "writebinaryfileinstance.h" #include "fileparameterdefinition.h" #include "textparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteBinaryFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteBinaryFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &file = addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file to write to")); file.setMode(ActionTools::FileEdit::FileSave); file.setCaption(tr("Choose the file")); file.setFilter(tr("All files (*.*)")); auto &data = addParameter({QStringLiteral("data"), tr("Data")}); data.setTooltip(tr("The data to write to the file")); addException(WriteBinaryFileInstance::UnableToWriteFileException, tr("Unable to write to the file")); } QString name() const override { return QObject::tr("Write binary file"); } QString id() const override { return QStringLiteral("ActionWriteBinaryFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Write to a binary file"); } ActionTools::ActionInstance *newActionInstance() const override { return new WriteBinaryFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writebinary.png")); } private: Q_DISABLE_COPY(WriteBinaryFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/writebinaryfileinstance.h000066400000000000000000000040761363645743000263770ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "datacopyactioninstance.h" #include #include namespace Actions { class WriteBinaryFileInstance : public ActionTools::DataCopyActionInstance { Q_OBJECT public: enum Exceptions { UnableToWriteFileException = ActionTools::ActionException::UserException }; WriteBinaryFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::DataCopyActionInstance(definition, parent) { } void startExecution() override { bool ok = true; QString filename = evaluateString(ok, QStringLiteral("file")); QScriptValue data = evaluateValue(ok, QStringLiteral("data")); if(!ok) return; mData = data.toVariant().toByteArray(); mFile.setFileName(filename); mDataBuffer.setBuffer(&mData); if(!DataCopyActionInstance::startCopy(&mDataBuffer, &mFile)) { setCurrentParameter(QStringLiteral("file")); emit executionException(UnableToWriteFileException, tr("Unable to write to the file \"%1\"").arg(filename)); return; } emit showProgressDialog(tr("Writing file"), 100); emit updateProgressDialog(tr("Writing in progress")); } private: void clean() override { DataCopyActionInstance::clean(); mDataBuffer.buffer().clear(); } QFile mFile; QByteArray mData; QBuffer mDataBuffer; private: Q_DISABLE_COPY(WriteBinaryFileInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/writeclipboarddefinition.h000066400000000000000000000040561363645743000265340ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "writeclipboardinstance.h" #include "textparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteClipboardDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteClipboardDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &input = addParameter({QStringLiteral("value"), tr("Value")}); input.setTooltip(tr("The new clipboard value")); } QString name() const override { return QObject::tr("Write clipboard"); } QString id() const override { return QStringLiteral("ActionWriteClipboard"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Set the clipboard contents"); } ActionTools::ActionInstance *newActionInstance() const override { return new WriteClipboardInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writeclipboard.png")); } private: Q_DISABLE_COPY(WriteClipboardDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/writeclipboardinstance.h000066400000000000000000000025461363645743000262120ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include #include namespace Actions { class WriteClipboardInstance : public ActionTools::ActionInstance { Q_OBJECT public: WriteClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} void startExecution() override { bool ok = true; QString value = evaluateString(ok, QStringLiteral("value")); if(!ok) return; QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(value); executionEnded(); } private: Q_DISABLE_COPY(WriteClipboardInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/writeinifiledefinition.h000066400000000000000000000055061363645743000262150ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "writeinifileinstance.h" #include "textparameterdefinition.h" #include "fileparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteIniFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteIniFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &file = addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file to create or edit")); file.setMode(ActionTools::FileEdit::FileSave); file.setCaption(tr("Choose the INI file")); file.setFilter(tr("INI files (*.ini);;All files (*.*)")); auto §ion = addParameter({QStringLiteral("section"), tr("Section")}); section.setTooltip(tr("The section name of the parameter")); auto ¶meter = addParameter({QStringLiteral("parameter"), tr("Parameter")}); parameter.setTooltip(tr("The parameter name")); auto &value = addParameter({QStringLiteral("value"), tr("Value")}); value.setTooltip(tr("The new value")); addException(WriteIniFileInstance::UnableToWriteFileException, tr("Unable to write file")); } QString name() const override { return QObject::tr("Write INI file"); } QString id() const override { return QStringLiteral("ActionWriteIniFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Write an entry in an INI file"); } ActionTools::ActionInstance *newActionInstance() const override { return new WriteIniFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writeini.png")); } private: Q_DISABLE_COPY(WriteIniFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/writeinifileinstance.h000066400000000000000000000063041363645743000256660ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include #include #include namespace Actions { class WriteIniFileInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Exceptions { UnableToWriteFileException = ActionTools::ActionException::UserException }; WriteIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} void startExecution() override { bool ok = true; QString filename = evaluateString(ok, QStringLiteral("file")); QString section = evaluateString(ok, QStringLiteral("section")); QString parameter = evaluateString(ok, QStringLiteral("parameter")); QString value = evaluateString(ok, QStringLiteral("value")); if(!ok) return; if(!write(filename, section, parameter, value)) return; executionEnded(); } private: bool write(const QString &filename, QString section, const QString ¶meter, const QString &value) { try { boost::property_tree::ptree tree; QFileInfo fileInfo(filename); if(fileInfo.isReadable()) boost::property_tree::ini_parser::read_ini(filename.toStdString(), tree); //Create/get the parameter and the value boost::property_tree::ptree sectionTree; if(tree.count(section.toStdString()) > 0) sectionTree = tree.get_child(section.toStdString()); sectionTree.put(parameter.toStdString(), value.toStdString()); if(section.isEmpty()) { setCurrentParameter(QStringLiteral("filename")); emit executionException(UnableToWriteFileException, tr("Unable to write to the file: the section name cannot be empty")); return false; } //Create the section tree.put_child(section.toStdString(), sectionTree); boost::property_tree::ini_parser::write_ini(filename.toStdString(), tree); } catch(const std::runtime_error &e) { setCurrentParameter(QStringLiteral("filename")); emit executionException(UnableToWriteFileException, tr("Unable to write to the file: %1").arg(QString::fromUtf8(e.what()))); return false; } return true; } Q_DISABLE_COPY(WriteIniFileInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/writeregistrydefinition.h000066400000000000000000000056441363645743000264510ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "writeregistryinstance.h" #include "readregistryinstance.h" #include "listparameterdefinition.h" #include "textparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteRegistryDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteRegistryDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { auto &key = addParameter({QStringLiteral("key"), tr("Key")}); key.setTooltip(tr("The registry key to write to")); key.setItems(ReadRegistryInstance::keys); key.setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser)); auto &subKey = addParameter({QStringLiteral("subKey"), tr("Subkey")}); subKey.setTooltip(tr("The registry subkey to write to")); auto &value = addParameter({QStringLiteral("value"), tr("Value")}); value.setTooltip(tr("The value to write to")); auto &data = addParameter({QStringLiteral("data"), tr("Data")}); data.setTooltip(tr("The data to write")); addException(WriteRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey")); addException(WriteRegistryInstance::CannotWriteValueException, tr("Cannot write value")); } QString name() const override { return QObject::tr("Write registry"); } QString id() const override { return QStringLiteral("ActionWriteRegistry"); } ActionTools::Flag flags() const override { return ActionTools::WorksOnWindows | ActionTools::Official; } QString description() const override { return QObject::tr("Writes an entry to the registry"); } ActionTools::ActionInstance *newActionInstance() const override { return new WriteRegistryInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writeregistry.png")); } private: Q_DISABLE_COPY(WriteRegistryDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/writeregistryinstance.cpp000066400000000000000000000035371363645743000264570ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "writeregistryinstance.h" #include "readregistryinstance.h" #ifdef Q_OS_WIN #include #endif namespace Actions { void WriteRegistryInstance::startExecution() { #ifdef Q_OS_WIN bool ok = true; ActionTools::Registry::Key key = evaluateListElement(ok, ReadRegistryInstance::keys, QStringLiteral("key")); QString subKey = evaluateString(ok, QStringLiteral("subKey")); QString value = evaluateString(ok, QStringLiteral("value")); QScriptValue data = evaluateValue(ok, QStringLiteral("data")); if(!ok) return; switch(ActionTools::Registry::write(data.toVariant(), key, subKey, value)) { case ActionTools::Registry::WriteCannotFindSubKey: setCurrentParameter(QStringLiteral("subKey")); emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey)); return; case ActionTools::Registry::WriteCannotWriteValue: setCurrentParameter(QStringLiteral("value")); emit executionException(CannotWriteValueException, tr("Cannot write value \"%1\"").arg(value)); return; default: break; } #endif executionEnded(); } } actiona-3.10.1/actions/actionpackdata/actions/writeregistryinstance.h000066400000000000000000000024161363645743000261170ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "stringlistpair.h" #include "registry.h" namespace Actions { class WriteRegistryInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Exceptions { CannotFindSubKeyException = ActionTools::ActionException::UserException, CannotWriteValueException }; WriteRegistryInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} void startExecution() override; private: Q_DISABLE_COPY(WriteRegistryInstance) }; } actiona-3.10.1/actions/actionpackdata/actions/writetextfiledefinition.h000066400000000000000000000055071363645743000264230ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "writetextfileinstance.h" #include "fileparameterdefinition.h" #include "textparameterdefinition.h" #include "listparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteTextFileDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteTextFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("WriteTextFileInstance::modes", WriteTextFileInstance::modes); auto &file = addParameter({QStringLiteral("file"), tr("File")}); file.setTooltip(tr("The file you want to write")); auto &text = addParameter({QStringLiteral("text"), tr("Text")}); text.setTooltip(tr("The text to write to the file")); auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")}, 1); mode.setTooltip(tr("The file write mode")); mode.setItems(WriteTextFileInstance::modes); mode.setDefaultValue(WriteTextFileInstance::modes.second.at(WriteTextFileInstance::Truncate)); addException(WriteTextFileInstance::CannotWriteFileException, tr("Cannot write file")); } QString name() const override { return QObject::tr("Write text file"); } QString id() const override { return QStringLiteral("ActionWriteTextFile"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Write a plain text file"); } ActionTools::ActionInstance *newActionInstance() const override { return new WriteTextFileInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Data; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writetext.png")); } QStringList tabs() const override { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(WriteTextFileDefinition) }; } actiona-3.10.1/actions/actionpackdata/actions/writetextfileinstance.cpp000066400000000000000000000035011363645743000264220ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "writetextfileinstance.h" #include #include namespace Actions { Tools::StringListPair WriteTextFileInstance::modes = { { QStringLiteral("truncate"), QStringLiteral("append") }, { QStringLiteral(QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Overwrite any content")), QStringLiteral(QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Append to the end")) } }; void WriteTextFileInstance::startExecution() { bool ok = true; QString filepath = evaluateString(ok, QStringLiteral("file")); QString text = evaluateString(ok, QStringLiteral("text")); Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode")); if(!ok) return; QFile file(filepath); if(!file.open(QIODevice::WriteOnly | QIODevice::Text | (mode == Truncate ? QIODevice::Truncate : QIODevice::Append))) { setCurrentParameter(QStringLiteral("file")); emit executionException(CannotWriteFileException, tr("Cannot open file")); return; } QTextStream textStream(&file); textStream << text; file.close(); executionEnded(); } } actiona-3.10.1/actions/actionpackdata/actions/writetextfileinstance.h000066400000000000000000000025021363645743000260670ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "stringlistpair.h" namespace Actions { class WriteTextFileInstance : public ActionTools::ActionInstance { Q_OBJECT Q_ENUMS(Mode) public: enum Mode { Truncate, Append }; enum Exceptions { CannotWriteFileException = ActionTools::ActionException::UserException }; WriteTextFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} static Tools::StringListPair modes; void startExecution() override; private: Q_DISABLE_COPY(WriteTextFileInstance) }; } actiona-3.10.1/actions/actionpackdata/code/000077500000000000000000000000001363645743000205455ustar00rootroot00000000000000actiona-3.10.1/actions/actionpackdata/code/clipboard.cpp000066400000000000000000000061431363645743000232140ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "clipboard.h" #include "code/image.h" #include #include #include #include namespace Code { QScriptValue Clipboard::constructor(QScriptContext *context, QScriptEngine *engine) { auto clipboard = new Clipboard; if(context->argumentCount() > 0) { Mode mode = static_cast(context->argument(0).toInt32()); clipboard->setModePrivate(context, engine, mode); } return CodeClass::constructor(clipboard, context, engine); } Clipboard::Clipboard() : CodeClass() { } QString Clipboard::text() const { QClipboard *clipboard = QApplication::clipboard(); return clipboard->text(mMode); } QScriptValue Clipboard::image() const { QClipboard *clipboard = QApplication::clipboard(); return Image::constructor(clipboard->image(mMode), engine()); } QScriptValue Clipboard::setMode(Mode mode) { setModePrivate(context(), engine(), mode); return thisObject(); } QScriptValue Clipboard::setText(const QString &value) const { QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(value, mMode); return thisObject(); } QScriptValue Clipboard::setImage(const QScriptValue &data) const { QClipboard *clipboard = QApplication::clipboard(); QObject *object = data.toQObject(); if(auto image = qobject_cast(object)) clipboard->setImage(image->image(), mMode); else clipboard->setImage(data.toVariant().value(), mMode); return thisObject(); } Clipboard::DataType Clipboard::dataType() const { QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(mMode); if(mimeData->hasImage()) return Image; else return Text; } void Clipboard::setModePrivate(QScriptContext *context, QScriptEngine *engine, Mode mode) { switch(mode) { case Selection: if(!QApplication::clipboard()->supportsSelection()) { throwError(context, engine, QStringLiteral("UnsupportedSelectionModeError"), tr("Selection mode is not supported by your operating system")); return; } break; case FindBuffer: if(!QApplication::clipboard()->supportsFindBuffer()) { throwError(context, engine, QStringLiteral("UnsupportedSelectionModeError"), tr("Find buffer mode is not supported by your operating system")); return; } break; default: break; } mMode = static_cast(mode); } } actiona-3.10.1/actions/actionpackdata/code/clipboard.h000066400000000000000000000036571363645743000226700ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include namespace Code { class Clipboard : public CodeClass { Q_OBJECT Q_ENUMS(Mode) Q_ENUMS(DataType) Q_PROPERTY(QString text READ text WRITE setText) Q_PROPERTY(QScriptValue image READ image WRITE setImage) public: enum Mode { Standard = QClipboard::Clipboard, Selection = QClipboard::Selection, FindBuffer = QClipboard::FindBuffer }; enum DataType { Text, Image }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Clipboard(); QString text() const; QScriptValue image() const; public slots: QString toString() const override { return QStringLiteral("Clipboard"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue setMode(Mode mode); QScriptValue setText(const QString &value) const; QScriptValue setImage(const QScriptValue &data) const; DataType dataType() const; private: void setModePrivate(QScriptContext *context, QScriptEngine *engine, Mode mode); QClipboard::Mode mMode{QClipboard::Clipboard}; }; } actiona-3.10.1/actions/actionpackdata/code/code.pri000066400000000000000000000010211363645743000221650ustar00rootroot00000000000000HEADERS += code/file.h \ code/clipboard.h \ code/registry.h \ code/inifile.h \ code/udp.h \ code/tcp.h \ code/sql.h \ code/tcpserver.h \ code/web.h \ code/mail.h \ code/mailmessage.h \ code/mailattachment.h SOURCES += code/file.cpp \ code/clipboard.cpp \ code/registry.cpp \ code/inifile.cpp \ code/udp.cpp \ code/tcp.cpp \ code/sql.cpp \ code/tcpserver.cpp \ code/web.cpp \ code/mail.cpp \ code/mailmessage.cpp \ code/mailattachment.cpp actiona-3.10.1/actions/actionpackdata/code/file.cpp000066400000000000000000000467621363645743000222070ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "file.h" #include "code/rawdata.h" #include #include #include #include #ifdef Q_OS_WIN #include #include #endif namespace Code { QScriptValue File::constructor(QScriptContext *context, QScriptEngine *engine) { return CodeClass::constructor(new File, context, engine); } QScriptValue File::copy(QScriptContext *context, QScriptEngine *engine) { QString source, destination; bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine)) copyPrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine); return engine->undefinedValue(); } QScriptValue File::exists(QScriptContext *context, QScriptEngine *engine) { if(context->argumentCount() != 1) { throwError(context, engine, QStringLiteral("ParameterCountError"), tr("Incorrect parameter count")); return false; } return QFile::exists(context->argument(0).toString()); } QScriptValue File::move(QScriptContext *context, QScriptEngine *engine) { QString source, destination; bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine)) movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine); return engine->undefinedValue(); } QScriptValue File::rename(QScriptContext *context, QScriptEngine *engine) { QString source, destination; bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine)) renamePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine); return engine->undefinedValue(); } QScriptValue File::remove(QScriptContext *context, QScriptEngine *engine) { QString filename; if(context->argumentCount() < 1) { throwError(context, engine, QStringLiteral("ParameterCountError"), tr("Incorrect parameter count")); return false; } filename = context->argument(0).toString(); bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(context->argument(1), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory)) removePrivate(filename, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, context, engine); return engine->undefinedValue(); } void File::registerClass(QScriptEngine *scriptEngine) { CodeTools::addClassGlobalFunctionToScriptEngine(©, QStringLiteral("copy"), scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&move, QStringLiteral("move"), scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&rename, QStringLiteral("rename"), scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&remove, QStringLiteral("remove"), scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&exists, QStringLiteral("exists"), scriptEngine); } QScriptValue File::open(const QString &filename, OpenMode mode) { mFile.setFileName(filename); if(!mFile.open(static_cast(mode))) throwError(QStringLiteral("CannotOpenFileError"), tr("Unable to open file")); return thisObject(); } QScriptValue File::write(const QScriptValue &data) { QObject *object = data.toQObject(); if(auto rawData = qobject_cast(object)) { if(mFile.write(rawData->byteArray()) == -1) throwError(QStringLiteral("WriteFailedError"), tr("Write failed")); } else { if(mFile.write(data.toVariant().toByteArray()) == -1) throwError(QStringLiteral("WriteFailedError"), tr("Write failed")); } return thisObject(); } QScriptValue File::writeText(const QString &value, Encoding encoding) { if(mFile.write(toEncoding(value, encoding)) == -1) throwError(QStringLiteral("WriteFailedError"), tr("Write failed")); return thisObject(); } QScriptValue File::read() { return RawData::constructor(mFile.readAll(), engine()); } QString File::readText(Encoding encoding) { return fromEncoding(mFile.readAll(), encoding); } QScriptValue File::close() { mFile.close(); return thisObject(); } QScriptValue File::copy(const QString &destination, const QScriptValue &options) const { bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory)) return copyPrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine()); else return false; } QScriptValue File::move(const QString &destination, const QScriptValue &options) { mFile.close(); bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory)) return movePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine()); else return false; } QScriptValue File::rename(const QString &destination, const QScriptValue &options) { bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory)) return renamePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine()); else return false; } QScriptValue File::remove(const QScriptValue &options) { mFile.close(); bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory; if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory)) return removePrivate(mFile.fileName(), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, context(), engine()); else return false; } bool File::getParameters(QString &source, QString &destination, const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory, QScriptContext *context, QScriptEngine *engine) { if(context->argumentCount() < 2) { throwError(context, engine, QStringLiteral("ParameterCountError"), tr("Incorrect parameter count")); return false; } source = context->argument(0).toString(); destination = context->argument(1).toString(); return getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory); } bool File::getParameters(const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory) { QScriptValueIterator it(options); noErrorDialog = false; noConfirmDialog = false; noProgressDialog = false; allowUndo = false; createDestinationDirectory = true; while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("noErrorDialog")) noErrorDialog = it.value().toBool(); else if(it.name() == QLatin1String("noConfirmDialog")) noConfirmDialog = it.value().toBool(); else if(it.name() == QLatin1String("noProgressDialog")) noProgressDialog = it.value().toBool(); else if(it.name() == QLatin1String("allowUndo")) allowUndo = it.value().toBool(); else if(it.name() == QLatin1String("createDestinationDirectory")) createDestinationDirectory = it.value().toBool(); } return true; } QScriptValue File::copyPrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine) #ifdef Q_OS_UNIX Q_UNUSED(noErrorDialog) Q_UNUSED(noConfirmDialog) Q_UNUSED(noProgressDialog) Q_UNUSED(allowUndo) QDir destinationDir(destination); QString sourceCopy(source); QString destinationCopy(destination); sourceCopy.replace(QStringLiteral(" "), QStringLiteral("\\ ")); destinationCopy.replace(QStringLiteral(" "), QStringLiteral("\\ ")); if(!destinationDir.exists()) { if(createDestinationDirectory) { if(QProcess::execute(QStringLiteral("sh -c \"mkdir -p ") + QString::fromLocal8Bit(QFile::encodeName(destinationCopy)) + QStringLiteral("\""))) { throwError(context, engine, QStringLiteral("DirectoryCreationError"), tr("Unable to create destination directory")); return context->thisObject(); } } else { throwError(context, engine, QStringLiteral("DirectoryDoesntExistError"), tr("Destination directory doesn't exist")); return context->thisObject(); } } QString command = QStringLiteral("sh -c \"cp -fr"); command += QStringLiteral(" "); command += QString::fromLocal8Bit(QFile::encodeName(sourceCopy)); command += QStringLiteral(" "); command += QString::fromLocal8Bit(QFile::encodeName(destinationCopy)); command += QStringLiteral("\""); if(QProcess::execute(command)) { throwError(context, engine, QStringLiteral("CopyError"), tr("Copy failed")); return context->thisObject(); } #endif #ifdef Q_OS_WIN Q_UNUSED(createDestinationDirectory) QDir sourceDir(source); QDir destinationDir(destination); std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString(); wideSource += L'\0'; std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString(); wideDestination += L'\0'; SHFILEOPSTRUCT shFileOpStruct; shFileOpStruct.hwnd = 0; shFileOpStruct.wFunc = FO_COPY; shFileOpStruct.pFrom = wideSource.c_str(); shFileOpStruct.pTo = wideDestination.c_str(); shFileOpStruct.fFlags = 0; shFileOpStruct.fAnyOperationsAborted = false; shFileOpStruct.lpszProgressTitle = 0; shFileOpStruct.hNameMappings = 0; if(noErrorDialog) shFileOpStruct.fFlags |= FOF_NOERRORUI; if(noConfirmDialog) shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR); if(noProgressDialog) shFileOpStruct.fFlags |= FOF_SILENT; if(allowUndo) shFileOpStruct.fFlags |= FOF_ALLOWUNDO; int result = SHFileOperation(&shFileOpStruct); if(result != 0) { throwError(context, engine, QStringLiteral("CopyError"), tr("Copy failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, QStringLiteral("CopyAbortedError"), tr("Copy failed: aborted")); return context->thisObject(); } #endif return context->thisObject(); } QScriptValue File::movePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine) #ifdef Q_OS_UNIX Q_UNUSED(noErrorDialog) Q_UNUSED(noConfirmDialog) Q_UNUSED(noProgressDialog) Q_UNUSED(allowUndo) QDir destinationDir(destination); QString sourceCopy(source); QString destinationCopy(destination); sourceCopy.replace(QStringLiteral(" "), QStringLiteral("\\ ")); destinationCopy.replace(QStringLiteral(" "), QStringLiteral("\\ ")); if(!destinationDir.exists()) { if(createDestinationDirectory) { if(QProcess::execute(QStringLiteral("sh -c \"mkdir -p ") + QString::fromLocal8Bit(QFile::encodeName(destinationCopy)) + QStringLiteral("\""))) { throwError(context, engine, QStringLiteral("DirectoryCreationError"), tr("Unable to create destination directory")); return context->thisObject(); } } else { throwError(context, engine, QStringLiteral("DirectoryDoesntExistError"), tr("Destination directory doesn't exist")); return context->thisObject(); } } QString command = QStringLiteral("sh -c \"mv -f"); command += QStringLiteral(" "); command += QString::fromLocal8Bit(QFile::encodeName(sourceCopy)); command += QStringLiteral(" "); command += QString::fromLocal8Bit(QFile::encodeName(destinationCopy)); command += QStringLiteral("\""); if(QProcess::execute(command)) { throwError(context, engine, QStringLiteral("MoveRenameError"), tr("Move/rename failed")); return context->thisObject(); } #endif #ifdef Q_OS_WIN Q_UNUSED(createDestinationDirectory) QDir sourceDir(source); QDir destinationDir(destination); std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString(); wideSource += L'\0'; std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString(); wideDestination += L'\0'; SHFILEOPSTRUCT shFileOpStruct; shFileOpStruct.hwnd = 0; shFileOpStruct.wFunc = FO_MOVE; shFileOpStruct.pFrom = wideSource.c_str(); shFileOpStruct.pTo = wideDestination.c_str(); shFileOpStruct.fFlags = 0; shFileOpStruct.fAnyOperationsAborted = false; shFileOpStruct.lpszProgressTitle = 0; shFileOpStruct.hNameMappings = 0; if(noErrorDialog) shFileOpStruct.fFlags |= FOF_NOERRORUI; if(noConfirmDialog) shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR); if(noProgressDialog) shFileOpStruct.fFlags |= FOF_SILENT; if(allowUndo) shFileOpStruct.fFlags |= FOF_ALLOWUNDO; int result = SHFileOperation(&shFileOpStruct); if(result != 0) { throwError(context, engine, QStringLiteral("MoveError"), tr("Move failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, QStringLiteral("MoveAbortedError"), tr("Move failed: aborted")); return context->thisObject(); } #endif return context->thisObject(); } QScriptValue File::renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine) #ifdef Q_OS_UNIX movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine); #endif #ifdef Q_OS_WIN Q_UNUSED(createDestinationDirectory) QDir sourceDir(source); QDir destinationDir(destination); std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString(); wideSource += L'\0'; std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString(); wideDestination += L'\0'; SHFILEOPSTRUCT shFileOpStruct; shFileOpStruct.hwnd = 0; shFileOpStruct.wFunc = FO_RENAME; shFileOpStruct.pFrom = wideSource.c_str(); shFileOpStruct.pTo = wideDestination.c_str(); shFileOpStruct.fFlags = 0; shFileOpStruct.fAnyOperationsAborted = false; shFileOpStruct.lpszProgressTitle = 0; shFileOpStruct.hNameMappings = 0; if(noErrorDialog) shFileOpStruct.fFlags |= FOF_NOERRORUI; if(noConfirmDialog) shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR); if(noProgressDialog) shFileOpStruct.fFlags |= FOF_SILENT; if(allowUndo) shFileOpStruct.fFlags |= FOF_ALLOWUNDO; int result = SHFileOperation(&shFileOpStruct); if(result != 0) { throwError(context, engine, QStringLiteral("RenameError"), tr("Rename failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, QStringLiteral("RenameAbortedError"), tr("Rename failed: aborted")); return context->thisObject(); } #endif return context->thisObject(); } QScriptValue File::removePrivate(const QString &filename, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, QScriptContext *context, QScriptEngine *engine) { #ifdef Q_OS_UNIX Q_UNUSED(noErrorDialog) Q_UNUSED(noConfirmDialog) Q_UNUSED(noProgressDialog) Q_UNUSED(allowUndo) QString filenameCopy(filename); filenameCopy.replace(QStringLiteral(" "), QStringLiteral("\\ ")); QString command = QStringLiteral("sh -c \"rm -fr"); command += QStringLiteral(" "); command += QString::fromLocal8Bit(QFile::encodeName(filenameCopy)); command += QStringLiteral("\""); if(QProcess::execute(command)) { throwError(context, engine, QStringLiteral("RemoveError"), tr("Remove failed")); return context->thisObject(); } #endif #ifdef Q_OS_WIN QDir filenameDir(filename); std::wstring wideFilename = QDir::toNativeSeparators(filenameDir.absolutePath()).toStdWString(); wideFilename += L'\0'; SHFILEOPSTRUCT shFileOpStruct; shFileOpStruct.hwnd = 0; shFileOpStruct.wFunc = FO_DELETE; shFileOpStruct.pFrom = wideFilename.c_str(); shFileOpStruct.pTo = 0; shFileOpStruct.fFlags = 0; shFileOpStruct.fAnyOperationsAborted = false; shFileOpStruct.lpszProgressTitle = 0; shFileOpStruct.hNameMappings = 0; if(noErrorDialog) shFileOpStruct.fFlags |= FOF_NOERRORUI; if(noConfirmDialog) shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR); if(noProgressDialog) shFileOpStruct.fFlags |= FOF_SILENT; if(allowUndo) shFileOpStruct.fFlags |= FOF_ALLOWUNDO; int result = SHFileOperation(&shFileOpStruct); if(result != 0) { throwError(context, engine, QStringLiteral("RemoveError"), tr("Remove failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, QStringLiteral("RemoveAbortedError"), tr("Remove failed: aborted")); return context->thisObject(); } #endif return context->thisObject(); } QString File::getErrorString(int error) { #ifdef Q_OS_UNIX Q_UNUSED(error) return QString(); #endif #ifdef Q_OS_WIN switch(error) { case ERROR_SUCCESS: return QString(); case ERROR_FILE_NOT_FOUND: return tr("File not found"); case ERROR_PATH_NOT_FOUND: return tr("Path not found"); case ERROR_ACCESS_DENIED: return tr("Access denied"); case ERROR_SHARING_VIOLATION: return tr("This file is used by another process"); case ERROR_DISK_FULL: return tr("The disk is full"); case ERROR_FILE_EXISTS: case ERROR_ALREADY_EXISTS: return tr("The file already exists"); case ERROR_INVALID_NAME: return tr("Invalid name"); case ERROR_CANCELLED: return tr("Canceled"); default: return tr("Unknown error (%1)").arg(error); } #endif } } actiona-3.10.1/actions/actionpackdata/code/file.h000066400000000000000000000102401363645743000216320ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include namespace Code { class File : public CodeClass { Q_OBJECT Q_ENUMS(OpenMode) Q_ENUMS(Encoding) public: enum OpenMode { ReadOnly = QIODevice::ReadOnly, WriteOnly = QIODevice::WriteOnly, ReadWrite = QIODevice::ReadWrite, Append = QIODevice::Append, Truncate = QIODevice::Truncate, Text = QIODevice::Text, Unbuffered = QIODevice::Unbuffered }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); static QScriptValue copy(QScriptContext *context, QScriptEngine *engine); static QScriptValue exists(QScriptContext *context, QScriptEngine *engine); static QScriptValue move(QScriptContext *context, QScriptEngine *engine); static QScriptValue rename(QScriptContext *context, QScriptEngine *engine); static QScriptValue remove(QScriptContext *context, QScriptEngine *engine); static void registerClass(QScriptEngine *scriptEngine); ~File() override { mFile.close(); } QFile *file() { return &mFile; } public slots: QString toString() const override { return QStringLiteral("File"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue open(const QString &filename, OpenMode mode); QScriptValue write(const QScriptValue &data); QScriptValue writeText(const QString &value, Encoding encoding = Native); QScriptValue read(); QString readText(Encoding encoding = Native); QScriptValue close(); QScriptValue copy(const QString &destination, const QScriptValue &options = QScriptValue()) const; QScriptValue move(const QString &destination, const QScriptValue &options = QScriptValue()); QScriptValue rename(const QString &destination, const QScriptValue &options = QScriptValue()); QScriptValue remove(const QScriptValue &options = QScriptValue()); private: static bool getParameters(QString &source, QString &destination, const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory, QScriptContext *context, QScriptEngine *engine); static bool getParameters(const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory); static QScriptValue copyPrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine); static QScriptValue movePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine); static QScriptValue renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine); static QScriptValue removePrivate(const QString &filename, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, QScriptContext *context, QScriptEngine *engine); static QString getErrorString(int error); QFile mFile; }; } actiona-3.10.1/actions/actionpackdata/code/inifile.cpp000066400000000000000000000131541363645743000226740ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "inifile.h" #include #include namespace Code { QScriptValue IniFile::constructor(QScriptContext *context, QScriptEngine *engine) { auto iniFile = new IniFile; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("encoding")) iniFile->mEncoding = static_cast(it.value().toInt32()); } return CodeClass::constructor(iniFile, context, engine); } IniFile::IniFile() : CodeClass() { } QScriptValue IniFile::load(const QString &filename) { try { boost::property_tree::ini_parser::read_ini(toEncoding(filename, mEncoding).constData(), mTree); } catch(const std::runtime_error &) { throwError(QStringLiteral("LoadFileError"), tr("Cannot load the file")); return thisObject(); } mLatestFilename = filename; return thisObject(); } QScriptValue IniFile::save(const QString &filename) { QByteArray filenameByteArray = toEncoding(filename.isEmpty() ? mLatestFilename : filename, mEncoding); try { boost::property_tree::ini_parser::write_ini(filenameByteArray.constData(), mTree); } catch(const std::runtime_error &) { throwError(QStringLiteral("SaveFileError"), tr("Cannot save the file")); return thisObject(); } return thisObject(); } QScriptValue IniFile::clear() { mTree.clear(); return thisObject(); } QScriptValue IniFile::setSection(const QString §ionName, bool create) { QByteArray sectionNameByteArray = toEncoding(sectionName, mEncoding); if(mTree.count(sectionNameByteArray.constData()) == 0) { if(!create) { throwError(QStringLiteral("FindSectionError"), tr("Cannot find the section named \"%1\"").arg(sectionName)); return thisObject(); } mCurrentSection = mTree.add_child(sectionNameByteArray.constData(), {}); } else mCurrentSection = mTree.get_child(sectionNameByteArray.constData()); mCurrentSectionName = sectionNameByteArray; return thisObject(); } QScriptValue IniFile::setEncoding(Encoding encoding) { mEncoding = encoding; return thisObject(); } QString IniFile::sectionAt(int sectionIndex) const { if(sectionIndex < 0 || sectionIndex >= static_cast(mTree.size())) { throwError(QStringLiteral("FindSectionError"), tr("Invalid section index")); return QString(); } auto it = mTree.begin(); std::advance(it, sectionIndex); return QString::fromStdString(it->first); } QScriptValue IniFile::deleteSection(const QString §ionName) { QByteArray sectionNameByteArray = toEncoding(sectionName, mEncoding); if(!mTree.erase(sectionNameByteArray.constData())) { throwError(QStringLiteral("FindSectionError"), tr("Cannot delete section named \"%1\"").arg(sectionName)); return thisObject(); } return thisObject(); } int IniFile::sectionCount() const { return static_cast(mTree.size()); } bool IniFile::keyExists(const QString &keyName) const { QByteArray keyNameByteArray = toEncoding(keyName, mEncoding); return (mCurrentSection.count(keyNameByteArray.constData()) > 0); } QString IniFile::keyAt(int keyIndex) const { if(keyIndex < 0 || keyIndex >= static_cast(mCurrentSection.size())) { throwError(QStringLiteral("KeyError"), tr("Invalid key index")); return QString(); } auto it = mCurrentSection.begin(); std::advance(it, keyIndex); return QString::fromStdString(it->first); } QString IniFile::keyValue(const QString &keyName) const { if(!keyExists(keyName)) { throwError(QStringLiteral("KeyError"), tr("Cannot find any key named \"%1\"").arg(keyName)); return QString(); } return QString::fromStdString(mCurrentSection.get(toEncoding(keyName, mEncoding).constData())); } QScriptValue IniFile::setKeyValue(const QString &keyName, const QString &value) { mCurrentSection.put(toEncoding(keyName, mEncoding).constData(), toEncoding(value, mEncoding).constData()); mTree.put_child(mCurrentSectionName.constData(), mCurrentSection); return thisObject(); } QScriptValue IniFile::deleteKey(const QString &keyName) { QByteArray keyNameByteArray = toEncoding(keyName, mEncoding); if(!mCurrentSection.erase(keyNameByteArray.constData())) { throwError(QStringLiteral("KeyError"), tr("Cannot delete key named \"%1\"").arg(keyName)); return thisObject(); } mTree.put_child(mCurrentSectionName.constData(), mCurrentSection); return thisObject(); } int IniFile::keyCount() const { return static_cast(mCurrentSection.size()); } } actiona-3.10.1/actions/actionpackdata/code/inifile.h000066400000000000000000000041721363645743000223410ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include namespace Code { class IniFile : public CodeClass { Q_OBJECT public: static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); IniFile(); public slots: QString toString() const override { return QStringLiteral("IniFile"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue load(const QString &filename); QScriptValue save(const QString &filename = QString()); QScriptValue clear(); QScriptValue setSection(const QString §ionName, bool create = true); QScriptValue setEncoding(Encoding encoding); QString sectionAt(int sectionIndex) const; QScriptValue deleteSection(const QString §ionName); int sectionCount() const; bool keyExists(const QString &keyName) const; QString keyAt(int keyIndex) const; QString keyValue(const QString &keyName) const; QScriptValue setKeyValue(const QString &keyName, const QString &value); QScriptValue deleteKey(const QString &keyName); int keyCount() const; private: Encoding mEncoding{Native}; boost::property_tree::ptree mCurrentSection; boost::property_tree::ptree mTree; QByteArray mCurrentSectionName; QString mLatestFilename; }; } actiona-3.10.1/actions/actionpackdata/code/mail.cpp000066400000000000000000000207421363645743000222000ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "mail.h" #include "mailmessage.h" #include "qxtcore/qxtsignalwaiter.h" #include #include namespace Code { QScriptValue Mail::constructor(QScriptContext *context, QScriptEngine *engine) { Mail *mail = new Mail; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("username")) mail->setUsername(it.value().toString()); else if(it.name() == QLatin1String("password")) mail->setPassword(it.value().toString()); else if(it.name() == QLatin1String("onConnected")) mail->mOnConnected = it.value(); else if(it.name() == QLatin1String("onConnectionFailed")) mail->mOnConnectionFailed = it.value(); else if(it.name() == QLatin1String("onEncrypted")) mail->mOnEncrypted = it.value(); else if(it.name() == QLatin1String("onEncryptionFailed")) mail->mOnEncryptionFailed = it.value(); else if(it.name() == QLatin1String("onAuthenticated")) mail->mOnAuthenticated = it.value(); else if(it.name() == QLatin1String("onAuthenticationFailed")) mail->mOnAuthenticationFailed = it.value(); else if(it.name() == QLatin1String("onSenderRejected")) mail->mOnSenderRejected = it.value(); else if(it.name() == QLatin1String("onRecipientRejected")) mail->mOnRecipientRejected = it.value(); else if(it.name() == QLatin1String("onMailFailed")) mail->mOnMailFailed = it.value(); else if(it.name() == QLatin1String("onMailSent")) mail->mOnMailSent = it.value(); else if(it.name() == QLatin1String("onFinished")) mail->mOnFinished = it.value(); else if(it.name() == QLatin1String("onDisconnected")) mail->mOnDisconnected = it.value(); } return CodeClass::constructor(mail, context, engine); } Mail::Mail() : CodeClass() { connect(&mSmtp, &QxtSmtp::connected, this, &Mail::connected); connect(&mSmtp, static_cast(&QxtSmtp::connectionFailed), this, &Mail::connectionFailed); connect(&mSmtp, &QxtSmtp::encrypted, this, &Mail::encrypted); connect(&mSmtp, static_cast(&QxtSmtp::encryptionFailed), this, &Mail::encryptionFailed); connect(&mSmtp, &QxtSmtp::authenticated, this, &Mail::authenticated); connect(&mSmtp, static_cast(&QxtSmtp::authenticationFailed), this, &Mail::authenticationFailed); connect(&mSmtp, static_cast(&QxtSmtp::senderRejected), this, &Mail::senderRejected); connect(&mSmtp, static_cast(&QxtSmtp::recipientRejected), this, &Mail::recipientRejected); connect(&mSmtp, static_cast(&QxtSmtp::mailFailed), this, &Mail::mailFailed); connect(&mSmtp, static_cast(&QxtSmtp::mailSent), this, &Mail::mailSent); connect(&mSmtp, &QxtSmtp::finished, this, &Mail::finished); connect(&mSmtp, &QxtSmtp::disconnected, this, &Mail::disconnected); } QScriptValue Mail::connectToServer(const QString &serverName, int port) { mSmtp.connectToHost(serverName, port); return thisObject(); } QScriptValue Mail::connectToSecureServer(const QString &serverName, int port) { mSmtp.connectToSecureHost(serverName, port); return thisObject(); } int Mail::send(const QScriptValue &mail) { if(auto mailMessage = qobject_cast(mail.toQObject())) { QxtMailMessage &message = mailMessage->message(); if(!message.hasExtraHeader(QStringLiteral("Date"))) message.setExtraHeader(QStringLiteral("Date"), QDateTime::currentDateTime().toString(Qt::RFC2822Date)); return mSmtp.send(message); } else { throwError(QStringLiteral("ParameterTypeError"), tr("Incorrect parameter type: not a MailMessage")); return -1; } } QScriptValue Mail::waitForConnected(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(connected())); if(!waiter.wait(waitTime)) throwError(QStringLiteral("ConnectionError"), tr("Cannot establish a connection to the server")); return thisObject(); } QScriptValue Mail::waitForEncrypted(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(encrypted())); if(!waiter.wait(waitTime)) throwError(QStringLiteral("EncryptionError"), tr("Cannot encrypt the connection")); return thisObject(); } QScriptValue Mail::waitForAuthenticated(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(authenticated())); if(!waiter.wait(waitTime)) throwError(QStringLiteral("AuthenticationError"), tr("Cannot authenticate to the server")); return thisObject(); } QScriptValue Mail::waitForFinished(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(finished())); if(!waiter.wait(waitTime)) throwError(QStringLiteral("WaitForFinishedError"), tr("Wait for finished failed")); return thisObject(); } QScriptValue Mail::waitForDisconnected(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(disconnected())); if(!waiter.wait(waitTime)) throwError(QStringLiteral("WaitForDisconnectedError"), tr("Wait for disconnected failed")); return thisObject(); } void Mail::connected() { if(mOnConnected.isValid()) mOnConnected.call(thisObject()); } void Mail::connectionFailed(const QByteArray &msg) { if(mOnConnectionFailed.isValid()) mOnConnectionFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg)); } void Mail::encrypted() { if(mOnEncrypted.isValid()) mOnEncrypted.call(thisObject()); } void Mail::encryptionFailed(const QByteArray &msg) { if(mOnEncryptionFailed.isValid()) mOnEncryptionFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg)); } void Mail::authenticated() { if(mOnAuthenticated.isValid()) mOnAuthenticated.call(thisObject()); } void Mail::authenticationFailed(const QByteArray &msg) { if(mOnAuthenticationFailed.isValid()) mOnAuthenticationFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg)); } void Mail::senderRejected(int mailID, const QString &address, const QByteArray &msg) { if(mOnSenderRejected.isValid()) mOnSenderRejected.call(thisObject(), QScriptValueList() << mailID << address << QString::fromUtf8(msg)); } void Mail::recipientRejected(int mailID, const QString &address, const QByteArray &msg) { if(mOnRecipientRejected.isValid()) mOnRecipientRejected.call(thisObject(), QScriptValueList() << mailID << address << QString::fromUtf8(msg)); } void Mail::mailFailed(int mailID, int errorCode, const QByteArray &msg) { if(mOnMailFailed.isValid()) mOnMailFailed.call(thisObject(), QScriptValueList() << mailID << errorCode << QString::fromUtf8(msg)); } void Mail::mailSent(int mailID) { if(mOnMailSent.isValid()) mOnMailSent.call(thisObject(), QScriptValueList() << mailID); } void Mail::finished() { if(mOnFinished.isValid()) mOnFinished.call(thisObject()); } void Mail::disconnected() { if(mOnDisconnected.isValid()) mOnDisconnected.call(thisObject()); } } actiona-3.10.1/actions/actionpackdata/code/mail.h000066400000000000000000000205171363645743000216450ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include "qxtsmtp/qxtsmtp.h" #include #include #include namespace Code { class Mail : public CodeClass { Q_OBJECT Q_PROPERTY(QString username READ username WRITE setUsername) Q_PROPERTY(QString password READ password WRITE setPassword) Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected) Q_PROPERTY(QScriptValue onConnectionFailed READ onConnectionFailed WRITE setOnConnectionFailed) Q_PROPERTY(QScriptValue onEncrypted READ onEncrypted WRITE setOnEncrypted) Q_PROPERTY(QScriptValue onEncryptionFailed READ onEncryptionFailed WRITE setOnEncryptionFailed) Q_PROPERTY(QScriptValue onAuthenticated READ onAuthenticated WRITE setOnAuthenticated) Q_PROPERTY(QScriptValue onAuthenticationFailed READ onAuthenticationFailed WRITE setOnAuthenticationFailed) Q_PROPERTY(QScriptValue onSenderRejected READ onSenderRejected WRITE setOnSenderRejected) Q_PROPERTY(QScriptValue onRecipientRejected READ onRecipientRejected WRITE setOnRecipientRejected) Q_PROPERTY(QScriptValue onMailFailed READ onMailFailed WRITE setOnMailFailed) Q_PROPERTY(QScriptValue onMailSent READ onMailSent WRITE setOnMailSent) Q_PROPERTY(QScriptValue onFinished READ onFinished WRITE setOnFinished) Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected) Q_PROPERTY(int pendingMessageCount READ pendingMessageCount) Q_PROPERTY(bool startTlsDisabled READ startTlsDisabled WRITE setStartTlsDisabled) public: static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Mail(); QString username() const { return QString::fromUtf8(mSmtp.username()); } void setUsername(const QString &username) { mSmtp.setUsername(username.toUtf8()); } QString password() const { return QString::fromUtf8(mSmtp.password()); } void setPassword(const QString &password) { mSmtp.setPassword(password.toUtf8()); } void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; } QScriptValue onConnected() const { return mOnConnected; } void setOnConnectionFailed(const QScriptValue &onConnectionFailed) { mOnConnectionFailed = onConnectionFailed; } QScriptValue onConnectionFailed() const { return mOnConnectionFailed; } void setOnEncrypted(const QScriptValue &onEncrypted) { mOnEncrypted = onEncrypted; } QScriptValue onEncrypted() const { return mOnEncrypted; } void setOnEncryptionFailed(const QScriptValue &onEncryptionFailed) { mOnEncryptionFailed = onEncryptionFailed; } QScriptValue onEncryptionFailed() const { return mOnEncryptionFailed; } void setOnAuthenticated(const QScriptValue &onAuthenticated) { mOnAuthenticated = onAuthenticated; } QScriptValue onAuthenticated() const { return mOnAuthenticated; } void setOnAuthenticationFailed(const QScriptValue &onAuthenticationFailed) { mOnAuthenticationFailed = onAuthenticationFailed; } QScriptValue onAuthenticationFailed() const { return mOnAuthenticationFailed; } void setOnSenderRejected(const QScriptValue &onSenderRejected) { mOnSenderRejected = onSenderRejected; } QScriptValue onSenderRejected() const { return mOnSenderRejected; } void setOnRecipientRejected(const QScriptValue &onRecipientRejected) { mOnRecipientRejected = onRecipientRejected; } QScriptValue onRecipientRejected() const { return mOnRecipientRejected; } void setOnMailFailed(const QScriptValue &onMailFailed) { mOnMailFailed = onMailFailed; } QScriptValue onMailFailed() const { return mOnMailFailed; } void setOnMailSent(const QScriptValue &onMailSent) { mOnMailSent = onMailSent; } QScriptValue onMailSent() const { return mOnMailSent; } void setOnFinished(const QScriptValue &onFinished) { mOnFinished = onFinished; } QScriptValue onFinished() const { return mOnFinished; } void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; } QScriptValue onDisconnected() const { return mOnDisconnected; } int pendingMessageCount() const { return mSmtp.pendingMessages(); } bool startTlsDisabled() const { return mSmtp.startTlsDisabled(); } void setStartTlsDisabled(bool disable) { mSmtp.setStartTlsDisabled(disable); } public slots: QString toString() const override { return QStringLiteral("Mail"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue connectToServer(const QString &serverName, int port = 25); QScriptValue connectToSecureServer(const QString &serverName, int port = 465); int send(const QScriptValue &mail); QScriptValue disconnectFromServer() { mSmtp.disconnectFromHost(); return thisObject(); } bool hasExtension(const QString &extension) { return mSmtp.hasExtension(extension); } QString extensionData(const QString &extension) { return mSmtp.extensionData(extension); } QScriptValue waitForConnected(int waitTime = 30000); QScriptValue waitForEncrypted(int waitTime = 30000); QScriptValue waitForAuthenticated(int waitTime = 30000); QScriptValue waitForFinished(int waitTime = 30000); QScriptValue waitForDisconnected(int waitTime = 30000); private slots: void connected(); void connectionFailed(const QByteArray &msg); void encrypted(); void encryptionFailed(const QByteArray &msg); void authenticated(); void authenticationFailed(const QByteArray &msg); void senderRejected(int mailID, const QString &address, const QByteArray &msg); void recipientRejected(int mailID, const QString &address, const QByteArray &msg); void mailFailed(int mailID, int errorCode, const QByteArray &msg); void mailSent(int mailID); void finished(); void disconnected(); private: QxtSmtp mSmtp; QScriptValue mOnConnected; QScriptValue mOnConnectionFailed; QScriptValue mOnEncrypted; QScriptValue mOnEncryptionFailed; QScriptValue mOnAuthenticated; QScriptValue mOnAuthenticationFailed; QScriptValue mOnSenderRejected; QScriptValue mOnRecipientRejected; QScriptValue mOnMailFailed; QScriptValue mOnMailSent; QScriptValue mOnFinished; QScriptValue mOnDisconnected; }; } actiona-3.10.1/actions/actionpackdata/code/mailattachment.cpp000066400000000000000000000045561363645743000242560ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "mailattachment.h" #include "code/rawdata.h" #include namespace Code { QScriptValue MailAttachment::constructor(QScriptContext *context, QScriptEngine *engine) { auto mailAttachment = new MailAttachment; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("contentType")) mailAttachment->setContentType(it.value().toString()); else if(it.name() == QLatin1String("content")) mailAttachment->setContent(it.value()); } return CodeClass::constructor(mailAttachment, context, engine); } QScriptValue MailAttachment::constructor(const QxtMailAttachment &attachment, QScriptEngine* engine) { return CodeClass::constructor(new MailAttachment(attachment), engine); } MailAttachment::MailAttachment() : CodeClass() { } MailAttachment::MailAttachment(const QxtMailAttachment& attachment) : CodeClass(), mAttachment(attachment) { } QScriptValue MailAttachment::content() const { return RawData::constructor(mContent, engine()); } QScriptValue MailAttachment::setContent(const QScriptValue &content) { if(auto rawData = qobject_cast(content.toQObject())) mContent = rawData->byteArray(); else mContent = content.toVariant().toByteArray(); mAttachment.setContent(mContent); return thisObject(); } QScriptValue MailAttachment::clone() const { return constructor(mAttachment, engine()); } } actiona-3.10.1/actions/actionpackdata/code/mailattachment.h000066400000000000000000000054011363645743000237110ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include "qxtsmtp/qxtmailattachment.h" #include #include #include namespace Code { class MailAttachment : public CodeClass { Q_OBJECT Q_PROPERTY(QString contentType READ contentType WRITE setContentType) Q_PROPERTY(QScriptValue content READ content WRITE setContent) public: static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); static QScriptValue constructor(const QxtMailAttachment &attachment, QScriptEngine *engine); MailAttachment(); MailAttachment(const QxtMailAttachment &attachment); QString contentType() const { return mAttachment.contentType(); } QScriptValue content() const; void setContentType(const QString &contentType) { mAttachment.setContentType(contentType); } QScriptValue setContent(const QScriptValue &content); const QxtMailAttachment &attachment() const { return mAttachment; } public slots: QScriptValue clone() const; QString toString() const override { return QStringLiteral("MailAttachment"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue setExtraHeader(const QString &name, const QString &value) { mAttachment.setExtraHeader(name, value); return thisObject(); } QScriptValue removeExtraHeader(const QString &name) { mAttachment.removeExtraHeader(name); return thisObject(); } bool hasExtraHeader(const QString &name) const { return mAttachment.hasExtraHeader(name); } QString extraHeader(const QString &name) const { return mAttachment.extraHeader(name); } private: QxtMailAttachment mAttachment; QByteArray mContent; }; } actiona-3.10.1/actions/actionpackdata/code/mailmessage.cpp000066400000000000000000000060471363645743000235470ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "mailmessage.h" #include "mailattachment.h" #include namespace Code { QScriptValue MailMessage::constructor(QScriptContext *context, QScriptEngine *engine) { auto mailMessage = new MailMessage; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("sender")) mailMessage->mMessage.setSender(it.value().toString()); else if(it.name() == QLatin1String("subject")) mailMessage->mMessage.setSubject(it.value().toString()); else if(it.name() == QLatin1String("body")) mailMessage->mMessage.setBody(it.value().toString()); } return CodeClass::constructor(mailMessage, context, engine); } MailMessage::MailMessage() : CodeClass() { } QScriptValue MailMessage::attachments() const { const QHash &attachments = mMessage.attachments(); QScriptValue back = engine()->newArray(attachments.size()); int index = 0; for(QHash::ConstIterator it = attachments.constBegin(); it != attachments.constEnd(); ++it) { QScriptValue attachmentObject = engine()->newObject(); attachmentObject.setProperty(QStringLiteral("filename"), it.key()); attachmentObject.setProperty(QStringLiteral("attachment"), MailAttachment::constructor(it.value(), engine())); back.setProperty(index, attachmentObject); ++index; } return back; } QScriptValue MailMessage::attachment(const QString &filename) const { return MailAttachment::constructor(mMessage.attachment(filename), engine()); } QScriptValue MailMessage::addAttachment(const QString &filename, const QScriptValue &attachment) { if(auto mailAttachment = qobject_cast(attachment.toQObject())) mMessage.addAttachment(filename, mailAttachment->attachment()); else throwError(QStringLiteral("ParameterTypeError"), tr("Incorrect parameter type: not a MailAttachment")); return thisObject(); } QScriptValue MailMessage::removeAttachment(const QString &filename) { mMessage.removeAttachment(filename); return thisObject(); } } actiona-3.10.1/actions/actionpackdata/code/mailmessage.h000066400000000000000000000074271363645743000232170ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include "qxtsmtp/qxtmailmessage.h" #include #include #include namespace Code { class MailMessage : public CodeClass { Q_OBJECT Q_ENUMS(RecipientType) Q_PROPERTY(QString sender READ sender WRITE setSender) Q_PROPERTY(QString subject READ subject WRITE setSubject) Q_PROPERTY(QString body READ body WRITE setBody) public: enum RecipientType { To, Cc, Bcc }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); MailMessage(); QString sender() const { return mMessage.sender(); } void setSender(const QString &sender) { mMessage.setSender(sender); } QString subject() const { return mMessage.subject(); } void setSubject(const QString &subject) { mMessage.setSubject(subject); } QString body() const { return mMessage.body(); } void setBody(const QString &body) { mMessage.setBody(body); } QxtMailMessage &message() { return mMessage; } public slots: QString toString() const override { return QStringLiteral("MailMessage"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue setExtraHeader(const QString &name, const QString &value) { mMessage.setExtraHeader(name, value); return thisObject(); } QScriptValue removeExtraHeader(const QString &name) { mMessage.removeExtraHeader(name); return thisObject(); } bool hasExtraHeader(const QString &name) const { return mMessage.hasExtraHeader(name); } QString extraHeader(const QString &name) const { return mMessage.extraHeader(name); } QStringList recipients(RecipientType type = To) const { return mMessage.recipients(static_cast(type)); } QScriptValue addRecipient(const QString &recipient, RecipientType type = To){ mMessage.addRecipient(recipient, static_cast(type)); return thisObject(); } QScriptValue removeRecipient(const QString &recipient) { mMessage.removeRecipient(recipient); return thisObject(); } QScriptValue attachments() const; QScriptValue attachment(const QString &filename) const; QScriptValue addAttachment(const QString &filename, const QScriptValue &attachment); QScriptValue removeAttachment(const QString &filename); private: QxtMailMessage mMessage; }; } actiona-3.10.1/actions/actionpackdata/code/registry.cpp000066400000000000000000000274451363645743000231350ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "registry.h" #include #include #ifdef Q_OS_WIN #include #endif namespace Code { QScriptValue Registry::constructor(QScriptContext *context, QScriptEngine *engine) { return CodeClass::constructor(new Registry, context, engine); } Registry::Registry() : CodeClass() #ifdef Q_OS_WIN , mHKey(0) , mRootKey(ClassesRoot) #endif { } Registry::~Registry() { #ifdef Q_OS_WIN RegCloseKey(mHKey); #endif } QScriptValue Registry::openKey(Key key, const QString &subKey) { #ifdef Q_OS_WIN HKEY hKey = enumToKey(key); if(RegOpenKeyEx(hKey, subKey.toStdWString().c_str(), 0, KEY_ALL_ACCESS, &mHKey) != ERROR_SUCCESS) throwError(QStringLiteral("OpenKeyError"), tr("Unable to open the key")); else { mRootKey = key; mSubKey = subKey; } #else Q_UNUSED(key) Q_UNUSED(subKey) #endif return thisObject(); } QScriptValue Registry::createKey(Key key, const QString &subKey) { #ifdef Q_OS_WIN HKEY hKey = enumToKey(key); if(RegCreateKeyEx(hKey, subKey.toStdWString().c_str(), 0, 0, 0, KEY_ALL_ACCESS, 0, &mHKey, 0) != ERROR_SUCCESS) throwError(QStringLiteral("CreateKeyError"), tr("Unable to create the key")); else { mRootKey = key; mSubKey = subKey; } #else Q_UNUSED(key) Q_UNUSED(subKey) #endif return thisObject(); } QScriptValue Registry::setValue(const QString &value, const QVariant &data) const { #ifdef Q_OS_WIN std::wstring wideValue = value.toStdWString(); switch(data.type()) { case QVariant::Int: case QVariant::UInt: { int intData = data.toInt(); if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_DWORD, reinterpret_cast(&intData), sizeof(int)) != ERROR_SUCCESS) throwError(QStringLiteral("SetValueError"), tr("Cannot set the value data")); } break; case QVariant::LongLong: case QVariant::ULongLong: { long long intData = data.toLongLong(); if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_QWORD, reinterpret_cast(&intData), sizeof(long long)) != ERROR_SUCCESS) throwError(QStringLiteral("SetValueError"), tr("Cannot set the value data")); } break; case QVariant::StringList: { const QStringList &stringList = data.toStringList(); std::wstring wideData; for(const QString &string: stringList) { wideData += string.toStdWString(); wideData += L'\0'; } if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_MULTI_SZ, reinterpret_cast(const_cast(wideData.c_str())), static_cast(wideData.size() * sizeof(wchar_t))) != ERROR_SUCCESS) throwError(QStringLiteral("SetValueError"), tr("Cannot set the value data")); } break; case QVariant::ByteArray: { QByteArray byteArray = data.toByteArray(); if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_BINARY, reinterpret_cast(byteArray.data()), static_cast(byteArray.size())) != ERROR_SUCCESS) throwError(QStringLiteral("SetValueError"), tr("Cannot set the value data")); } break; default: { if(data.type() == QVariant::String || data.canConvert(QVariant::String)) { std::wstring wideData = data.toString().toStdWString(); if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_SZ, reinterpret_cast(const_cast(wideData.c_str())), static_cast(wideData.size() * sizeof(wchar_t))) != ERROR_SUCCESS) throwError(QStringLiteral("SetValueError"), tr("Cannot set the value data")); } else throwError(QStringLiteral("SetValueError"), tr("Cannot set the value data")); } break; } #else Q_UNUSED(value) Q_UNUSED(data) #endif return thisObject(); } QVariant Registry::value(const QString &value) const { #ifdef Q_OS_WIN DWORD size; DWORD type; std::wstring wideValue = value.toStdWString(); if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, &type, 0, &size) != ERROR_SUCCESS) { throwError(QStringLiteral("FindValueError"), tr("Cannot find the value to read")); return {}; } switch(type) { case REG_DWORD: case REG_DWORD_BIG_ENDIAN: { qint32 value; if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(&value), &size) != ERROR_SUCCESS) { throwError(QStringLiteral("FindValueError"), tr("Cannot find the value to read")); return {}; } if(type == REG_DWORD_BIG_ENDIAN) value = qFromBigEndian(value); return value; } break; case REG_SZ: case REG_EXPAND_SZ: case REG_LINK: case REG_MULTI_SZ: { std::vector buffer(size); if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(buffer.data()), &size) != ERROR_SUCCESS) { throwError(QStringLiteral("FindValueError"), tr("Cannot find the value to read")); return {}; } if(type == REG_MULTI_SZ) { QStringList stringList = QString::fromWCharArray(buffer.data(), size / 2).split(QChar(L'\0'), QString::SkipEmptyParts); if(stringList.last().isEmpty()) stringList.removeLast(); return stringList; } else return QString::fromWCharArray(buffer.data(), size / 2); } break; case REG_BINARY: { std::vector buffer(size); if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(buffer.data()), &size) != ERROR_SUCCESS) { throwError(QStringLiteral("FindValueError"), tr("Cannot find the value to read")); return {}; } QByteArray back = QByteArray::fromRawData(buffer.data(), size); return back; } break; case REG_QWORD: { qint64 value; if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(&value), &size) != ERROR_SUCCESS) { throwError(QStringLiteral("FindValueError"), tr("Cannot find the value to read")); return {}; } return value; } break; case REG_NONE: default: throwError(QStringLiteral("InvalidValueError"), tr("Invalid value type")); return {}; break; } #else Q_UNUSED(value) return QVariant(); #endif } QStringList Registry::valueNames() const { #ifdef Q_OS_WIN int index = 0; DWORD valueCount; DWORD maxValueNameLength; if(RegQueryInfoKey(mHKey, 0, 0, 0, 0, 0, 0, &valueCount, &maxValueNameLength, 0, 0, 0) != ERROR_SUCCESS) { throwError(QStringLiteral("InvalidKeyError"), tr("Unable to query informations about this key")); return {}; } if(valueCount == 0 || maxValueNameLength == 0) return {}; std::vector valueName(maxValueNameLength + 1); int result; QStringList back; for(;;++index) { DWORD valueNameSize = maxValueNameLength + 1; result = RegEnumValue(mHKey, index, valueName.data(), &valueNameSize, 0, 0, 0, 0); if(result == ERROR_NO_MORE_ITEMS) break; if(valueNameSize == 0) continue;//Skip the default value back.append(QString::fromWCharArray(valueName.data(), valueNameSize)); } return back; #else return {}; #endif } QStringList Registry::keys() const { #ifdef Q_OS_WIN int index = 0; DWORD subKeyCount; DWORD maxSubKeyNameLength; if(RegQueryInfoKey(mHKey, 0, 0, 0, &subKeyCount, &maxSubKeyNameLength, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS) { throwError(QStringLiteral("InvalidKeyError"), tr("Unable to query informations about this key")); return {}; } if(subKeyCount == 0 || maxSubKeyNameLength == 0) return {}; std::vector subKeyName(maxSubKeyNameLength + 1); int result; QStringList back; for(;;++index) { DWORD subKeyNameSize = maxSubKeyNameLength + 1; result = RegEnumKeyEx(mHKey, index, subKeyName.data(), &subKeyNameSize, 0, 0, 0, 0); if(result == ERROR_NO_MORE_ITEMS) break; back.append(QString::fromWCharArray(subKeyName.data(), subKeyNameSize)); } return back; #else return {}; #endif } QScriptValue Registry::deleteValue(const QString &value) const { #ifdef Q_OS_WIN if(RegDeleteValue(mHKey, value.toStdWString().c_str()) != ERROR_SUCCESS) throwError(QStringLiteral("InvalidKeyError"), tr("Unable to delete the key")); #else Q_UNUSED(value) #endif return thisObject(); } #ifdef Q_OS_WIN BOOL RegDelnodeRecurse (HKEY hKeyRoot, LPTSTR lpSubKey) { LPTSTR lpEnd; LONG lResult; DWORD dwSize; WCHAR szName[MAX_PATH]; HKEY hKey; FILETIME ftWrite; // First, see if we can delete the key without having // to recurse. lResult = RegDeleteKey(hKeyRoot, lpSubKey); if (lResult == ERROR_SUCCESS) return TRUE; lResult = RegOpenKeyEx (hKeyRoot, lpSubKey, 0, KEY_READ, &hKey); if (lResult != ERROR_SUCCESS) { if (lResult == ERROR_FILE_NOT_FOUND) { printf("Key not found.\n"); return TRUE; } else { printf("Error opening key.\n"); return FALSE; } } // Check for an ending slash and add one if it is missing. lpEnd = lpSubKey + lstrlen(lpSubKey); if (*(lpEnd - 1) != TEXT('\\')) { *lpEnd = TEXT('\\'); lpEnd++; *lpEnd = TEXT('\0'); } // Enumerate the keys dwSize = MAX_PATH; lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, NULL, NULL, &ftWrite); if (lResult == ERROR_SUCCESS) { do { StringCchCopy (lpEnd, MAX_PATH*2, szName); if (!RegDelnodeRecurse(hKeyRoot, lpSubKey)) { break; } dwSize = MAX_PATH; lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL, NULL, NULL, &ftWrite); } while (lResult == ERROR_SUCCESS); } lpEnd--; *lpEnd = TEXT('\0'); RegCloseKey (hKey); // Try again to delete the key. lResult = RegDeleteKey(hKeyRoot, lpSubKey); if (lResult == ERROR_SUCCESS) return TRUE; return FALSE; } BOOL RegDelnode (HKEY hKeyRoot, LPCTSTR lpSubKey) { WCHAR szDelKey[MAX_PATH*2]; StringCchCopy (szDelKey, MAX_PATH*2, lpSubKey); return RegDelnodeRecurse(hKeyRoot, szDelKey); } #endif QScriptValue Registry::deleteKey(Key key, const QString &subKey) const { #ifdef Q_OS_WIN HKEY hKey = enumToKey(key); if(!RegDelnode(hKey, subKey.toStdWString().c_str())) throwError(QStringLiteral("InvalidKeyError"), tr("Unable to delete the key")); #else Q_UNUSED(key) Q_UNUSED(subKey) #endif return thisObject(); } QScriptValue Registry::deleteKey() const { #ifdef Q_OS_WIN RegCloseKey(mHKey); deleteKey(mRootKey, mSubKey); #endif return thisObject(); } QScriptValue Registry::closeKey() const { #ifdef Q_OS_WIN RegCloseKey(mHKey); #endif return thisObject(); } #ifdef Q_OS_WIN HKEY Registry::enumToKey(Key key) const { switch(key) { case ClassesRoot: return HKEY_CLASSES_ROOT; case CurrentConfig: return HKEY_CURRENT_CONFIG; case CurrentUser: return HKEY_CURRENT_USER; case Users: return HKEY_USERS; case LocalMachine: return HKEY_LOCAL_MACHINE; default: return HKEY_CURRENT_USER; } } #endif } actiona-3.10.1/actions/actionpackdata/code/registry.h000066400000000000000000000040301363645743000225630ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include #ifdef Q_OS_WIN #include #endif namespace Code { class Registry : public CodeClass { Q_OBJECT Q_ENUMS(Key) public: enum Key { ClassesRoot, CurrentConfig, CurrentUser, Users, LocalMachine }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Registry(); ~Registry() override; public slots: QString toString() const override { return QStringLiteral("Registry"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue openKey(Key key, const QString &subKey); QScriptValue createKey(Key key, const QString &subKey); QScriptValue setValue(const QString &value, const QVariant &data) const; QVariant value(const QString &value = QString()) const; QStringList valueNames() const; QStringList keys() const; QScriptValue deleteValue(const QString &value = QString()) const; QScriptValue deleteKey(Key key, const QString &subKey) const; QScriptValue deleteKey() const; QScriptValue closeKey() const; private: #ifdef Q_OS_WIN HKEY enumToKey(Key key) const; HKEY mHKey; Key mRootKey; QString mSubKey; #endif }; } actiona-3.10.1/actions/actionpackdata/code/sql.cpp000066400000000000000000000156631363645743000220630ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "sql.h" #include "code/codetools.h" #include #include #include #include #include #include #include namespace Code { QScriptValue Sql::constructor(QScriptContext *context, QScriptEngine *engine) { if(context->argumentCount() < 1) { throwError(context, engine, QStringLiteral("NoDatabaseDriverError"), tr("Please specify the database driver that should be used")); return engine->undefinedValue(); } Driver driver = static_cast(context->argument(0).toInt32()); return CodeClass::constructor(new Sql(driver), context, engine); } QScriptValue Sql::drivers(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(context) QStringList driverNames = QSqlDatabase::drivers(); QSet driverList; for(int index = 0; index < driverNames.size(); ++index) { const QString &driverNameToInclude = driverNames.at(index); for(int driverIndex = 0; driverIndex < DriverCount; ++driverIndex) { if(driverName(static_cast(driverIndex)) == driverNameToInclude) driverList.insert(static_cast(driverIndex)); } } QScriptValue back = engine->newArray(driverList.size()); int index = 0; for(const Driver &driver: driverList) { back.setProperty(index, driver); ++index; } return back; } void Sql::registerClass(QScriptEngine *scriptEngine) { CodeTools::addClassGlobalFunctionToScriptEngine(&drivers, QStringLiteral("drivers"), scriptEngine); } Sql::Sql(Driver driver) : CodeClass(), mDatabase(new QSqlDatabase) { mDriverName = driverName(driver); } Sql::~Sql() { QString connectionName = mDatabase->connectionName(); mDatabase->close(); delete mDatabase; QSqlDatabase::removeDatabase(connectionName); } QScriptValue Sql::connect(const QScriptValue ¶meters) const { mDatabase->close(); if(!QSqlDatabase::isDriverAvailable(mDriverName)) { throwError(QStringLiteral("DatabaseDriverUnavailableError"), tr("The requested database driver is not available")); return thisObject(); } *mDatabase = QSqlDatabase::addDatabase(mDriverName, QUuid::createUuid().toString()); if(!mDatabase->isValid()) { throwError(QStringLiteral("DatabaseDriverUnavailableError"), tr("The requested database driver is not available")); return thisObject(); } QScriptValueIterator it(parameters); QString hostName; int port = 0; QString databaseName; QString userName; QString password; QString options; while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("hostName")) hostName = it.value().toString(); else if(it.name() == QLatin1String("port")) port = it.value().toInteger(); else if(it.name() == QLatin1String("databaseName")) databaseName = it.value().toString(); else if(it.name() == QLatin1String("userName")) userName = it.value().toString(); else if(it.name() == QLatin1String("password")) password = it.value().toString(); else if(it.name() == QLatin1String("options")) options = it.value().toString(); } mDatabase->setHostName(hostName); if(port != 0) mDatabase->setPort(port); mDatabase->setDatabaseName(databaseName); mDatabase->setConnectOptions(options); if(!mDatabase->open(userName, password)) { throwError(QStringLiteral("ConnectionError"), tr("Unable to establish a connection to the database")); return thisObject(); } return thisObject(); } QScriptValue Sql::prepare(const QString &queryString, const QScriptValue ¶meters) { mQuery = QSqlQuery(*mDatabase); mQuery.setForwardOnly(true); if(!mQuery.prepare(queryString)) { throwError(QStringLiteral("PrepareQueryError"), tr("Failed to prepare the query")); return thisObject(); } QScriptValueIterator it(parameters); while(it.hasNext()) { it.next(); mQuery.bindValue(it.name(), it.value().toString()); } return thisObject(); } QScriptValue Sql::execute(const QString &queryString) { bool result = false; if(queryString.isEmpty()) { result = mQuery.exec(); } else { mQuery = QSqlQuery(*mDatabase); mQuery.setForwardOnly(true); result = mQuery.exec(queryString); } if(!result) { QSqlError error = mQuery.lastError(); throwError(QStringLiteral("ExecuteQueryError"), tr("Failed to execute the query : %1").arg(error.text())); return thisObject(); } return thisObject(); } QScriptValue Sql::fetchResult(IndexStyle indexStyle) { if(!mQuery.isSelect()) { throwError(QStringLiteral("FetchError"), tr("Cannot fetch the result of a non-select query")); return thisObject(); } int size = mQuery.size(); if(size == -1) size = 0; QScriptValue back = engine()->newArray(size); switch(indexStyle) { case IndexNumber: { QSqlRecord record = mQuery.record(); for(int index = 0; mQuery.next(); ++index) { QScriptValue row = engine()->newArray(); for(int columnIndex = 0; columnIndex < record.count(); ++columnIndex) { row.setProperty(columnIndex, engine()->newVariant(mQuery.value(columnIndex))); } back.setProperty(index, row); } } break; case IndexName: { for(int index = 0; mQuery.next(); ++index) { QSqlRecord record = mQuery.record(); QScriptValue row = engine()->newArray(record.count()); for(int columnIndex = 0; columnIndex < record.count(); ++columnIndex) { row.setProperty(record.fieldName(columnIndex), engine()->newVariant(record.value(columnIndex))); } back.setProperty(index, row); } } break; } return back; } QScriptValue Sql::disconnect() const { mDatabase->close(); return thisObject(); } QString Sql::driverName(Driver driver) { switch(driver) { case SQLite2: return QStringLiteral("QSQLITE2"); case SQLite: return QStringLiteral("QSQLITE"); case PostgreSQL: return QStringLiteral("QPSQL"); case MySQL: return QStringLiteral("QMYSQL"); case ODBC: return QStringLiteral("QODBC"); case InterBase: return QStringLiteral("QIBASE"); case OCI: return QStringLiteral("QOCI"); case TDS: return QStringLiteral("QTDS"); case DB2: return QStringLiteral("QDB2"); default: return QString(); } } } actiona-3.10.1/actions/actionpackdata/code/sql.h000066400000000000000000000040651363645743000215220ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include class QSqlDatabase; namespace Code { class Sql : public CodeClass { Q_OBJECT Q_ENUMS(Driver) Q_ENUMS(IndexStyle) public: enum Driver { SQLite2, SQLite, PostgreSQL, MySQL, ODBC, InterBase, OCI, TDS, DB2, DriverCount }; enum IndexStyle { IndexNumber, IndexName }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); static QScriptValue drivers(QScriptContext *context, QScriptEngine *engine); static void registerClass(QScriptEngine *scriptEngine); Sql(Driver driver); ~Sql() override; public slots: QString toString() const override { return QStringLiteral("Sql"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue connect(const QScriptValue ¶meters) const; QScriptValue prepare(const QString &queryString, const QScriptValue ¶meters); QScriptValue execute(const QString &queryString = QString()); QScriptValue fetchResult(IndexStyle indexStyle = IndexName); QScriptValue disconnect() const; private: static QString driverName(Driver driver); QString mDriverName; QSqlDatabase *mDatabase; QSqlQuery mQuery; }; } actiona-3.10.1/actions/actionpackdata/code/tcp.cpp000066400000000000000000000126761363645743000220530ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "tcp.h" #include "code/rawdata.h" #include namespace Code { QScriptValue Tcp::constructor(QScriptContext *context, QScriptEngine *engine) { Tcp *tcp = new Tcp; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("onConnected")) tcp->mOnConnected = it.value(); else if(it.name() == QLatin1String("onDisconnected")) tcp->mOnDisconnected = it.value(); else if(it.name() == QLatin1String("onReadyRead")) tcp->mOnReadyRead = it.value(); else if(it.name() == QLatin1String("onBytesWritten")) tcp->mOnBytesWritten = it.value(); else if(it.name() == QLatin1String("onError")) tcp->mOnError = it.value(); } return CodeClass::constructor(tcp, context, engine); } QScriptValue Tcp::constructor(QTcpSocket *tcpSocket, QScriptEngine *engine) { return CodeClass::constructor(new Tcp(tcpSocket), engine); } Tcp::Tcp() : CodeClass(), mTcpSocket(new QTcpSocket(this)) { QObject::connect(mTcpSocket, &QTcpSocket::connected, this, &Tcp::connected); QObject::connect(mTcpSocket, &QTcpSocket::disconnected, this, &Tcp::disconnected); QObject::connect(mTcpSocket, &QTcpSocket::readyRead, this, &Tcp::readyRead); QObject::connect(mTcpSocket, &QTcpSocket::bytesWritten, this, &Tcp::bytesWritten); QObject::connect(mTcpSocket, static_cast(&QTcpSocket::error), this, &Tcp::error); } Tcp::Tcp(QTcpSocket *tcpSocket) : CodeClass(), mTcpSocket(tcpSocket) { QObject::connect(mTcpSocket, &QTcpSocket::connected, this, &Tcp::connected); QObject::connect(mTcpSocket, &QTcpSocket::disconnected, this, &Tcp::disconnected); QObject::connect(mTcpSocket, &QTcpSocket::readyRead, this, &Tcp::readyRead); QObject::connect(mTcpSocket, &QTcpSocket::bytesWritten, this, &Tcp::bytesWritten); QObject::connect(mTcpSocket, static_cast(&QTcpSocket::error), this, &Tcp::error); } Tcp::~Tcp() = default; QScriptValue Tcp::connect(const QString &hostname, quint16 port, OpenMode openMode) { mTcpSocket->connectToHost(hostname, port, static_cast(openMode)); return thisObject(); } QScriptValue Tcp::waitForConnected(int waitTime) { if(!mTcpSocket->waitForConnected(waitTime)) throwError(QStringLiteral("ConnectionError"), tr("Cannot establish a connection to the host")); return thisObject(); } QScriptValue Tcp::waitForBytesWritten(int waitTime) { if(!mTcpSocket->waitForBytesWritten(waitTime)) throwError(QStringLiteral("BytesWrittenError"), tr("Waiting for bytes written failed")); return thisObject(); } QScriptValue Tcp::waitForReadyRead(int waitTime) { if(!mTcpSocket->waitForReadyRead(waitTime)) throwError(QStringLiteral("ReadyReadError"), tr("Waiting for ready read failed")); return thisObject(); } QScriptValue Tcp::waitForDisconnected(int waitTime) { if(!mTcpSocket->waitForDisconnected(waitTime)) throwError(QStringLiteral("DisconnectionError"), tr("Waiting for disconnection failed")); return thisObject(); } QScriptValue Tcp::write(const QScriptValue &data) { QObject *object = data.toQObject(); if(auto rawData = qobject_cast(object)) { if(mTcpSocket->write(rawData->byteArray()) == -1) throwError(QStringLiteral("WriteError"), tr("Write failed")); } else { if(mTcpSocket->write(data.toVariant().toByteArray()) == -1) throwError(QStringLiteral("WriteError"), tr("Write failed")); } return thisObject(); } QScriptValue Tcp::writeText(const QString &data, Encoding encoding) { if(mTcpSocket->write(toEncoding(data, encoding)) == -1) throwError(QStringLiteral("WriteError"), tr("Write failed")); return thisObject(); } QScriptValue Tcp::read() { return RawData::constructor(mTcpSocket->readAll(), engine()); } QString Tcp::readText(Encoding encoding) { return fromEncoding(mTcpSocket->readAll(), encoding); } QScriptValue Tcp::disconnect() { mTcpSocket->disconnectFromHost(); return thisObject(); } void Tcp::connected() { if(mOnConnected.isValid()) mOnConnected.call(thisObject()); } void Tcp::disconnected() { if(mOnDisconnected.isValid()) mOnDisconnected.call(thisObject()); } void Tcp::readyRead() { if(mOnReadyRead.isValid()) mOnReadyRead.call(thisObject()); } void Tcp::bytesWritten(qint64 bytes) { if(mOnBytesWritten.isValid()) mOnBytesWritten.call(thisObject(), QScriptValueList() << static_cast(bytes)); } void Tcp::error(QAbstractSocket::SocketError socketError) { Q_UNUSED(socketError) if(mOnError.isValid()) mOnError.call(thisObject(), QScriptValueList() << mTcpSocket->errorString()); } } actiona-3.10.1/actions/actionpackdata/code/tcp.h000066400000000000000000000070341363645743000215100ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include namespace Code { class Tcp : public CodeClass { Q_OBJECT Q_ENUMS(OpenMode) Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected) Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected) Q_PROPERTY(QScriptValue onReadyRead READ onReadyRead WRITE setOnReadyRead) Q_PROPERTY(QScriptValue onBytesWritten READ onBytesWritten WRITE setOnBytesWritten) Q_PROPERTY(QScriptValue onError READ onError WRITE setOnError) public: enum OpenMode { ReadOnly = QIODevice::ReadOnly, WriteOnly = QIODevice::WriteOnly, ReadWrite = QIODevice::ReadWrite }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); static QScriptValue constructor(QTcpSocket *tcpSocket, QScriptEngine *engine); Tcp(); Tcp(QTcpSocket *tcpSocket); ~Tcp() override; void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; } void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; } void setOnReadyRead(const QScriptValue &onReadyRead) { mOnReadyRead = onReadyRead; } void setOnBytesWritten(const QScriptValue &onBytesWritten) { mOnBytesWritten = onBytesWritten; } void setOnError(const QScriptValue &onError) { mOnError = onError; } QScriptValue onConnected() const { return mOnConnected; } QScriptValue onDisconnected() const { return mOnDisconnected; } QScriptValue onReadyRead() const { return mOnReadyRead; } QScriptValue onBytesWritten() const { return mOnBytesWritten; } QScriptValue onError() const { return mOnError; } public slots: QString toString() const override { return QStringLiteral("Tcp"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue connect(const QString &hostname, quint16 port, OpenMode openMode = ReadWrite); QScriptValue waitForConnected(int waitTime = 30000); QScriptValue waitForBytesWritten(int waitTime = 30000); QScriptValue waitForReadyRead(int waitTime = 30000); QScriptValue waitForDisconnected(int waitTime = 30000); QScriptValue write(const QScriptValue &data); QScriptValue writeText(const QString &data, Encoding encoding = Native); QScriptValue read(); QString readText(Encoding encoding = Native); QScriptValue disconnect(); private slots: void connected(); void disconnected(); void readyRead(); void bytesWritten(qint64 bytes); void error(QAbstractSocket::SocketError socketError); private: QTcpSocket *mTcpSocket; QScriptValue mOnConnected; QScriptValue mOnDisconnected; QScriptValue mOnReadyRead; QScriptValue mOnBytesWritten; QScriptValue mOnError; }; } actiona-3.10.1/actions/actionpackdata/code/tcpserver.cpp000066400000000000000000000046361363645743000232770ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "tcpserver.h" #include "tcp.h" #include namespace Code { QScriptValue TcpServer::constructor(QScriptContext *context, QScriptEngine *engine) { auto tcpServer = new TcpServer; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("onNewConnection")) tcpServer->mOnNewConnection = it.value(); } return CodeClass::constructor(tcpServer, context, engine); } TcpServer::TcpServer() : CodeClass() { connect(&mTcpServer, &QTcpServer::newConnection, this, &TcpServer::newConnection); } TcpServer::~TcpServer() { mTcpServer.close(); } QScriptValue TcpServer::listen(const QString &address, int port) { if(!mTcpServer.listen(QHostAddress(address), port)) throwError(QStringLiteral("ListenError"), tr("Unable to start listening")); return thisObject(); } QScriptValue TcpServer::waitForNewConnection(int waitTime) { if(!mTcpServer.waitForNewConnection(waitTime)) throwError(QStringLiteral("WaitForNewConnectionError"), tr("Waiting for new connection failed")); return thisObject(); } QScriptValue TcpServer::nextPendingConnection() { QTcpSocket *tcpSocket = mTcpServer.nextPendingConnection(); if(!tcpSocket) { throwError(QStringLiteral("NoPendingConnectionError"), tr("There is no pending connection")); return engine()->undefinedValue(); } return Tcp::constructor(tcpSocket, engine()); } QString TcpServer::address() const { return mTcpServer.serverAddress().toString(); } int TcpServer::port() const { return mTcpServer.serverPort(); } void TcpServer::newConnection() { if(mOnNewConnection.isValid()) mOnNewConnection.call(thisObject()); } } actiona-3.10.1/actions/actionpackdata/code/tcpserver.h000066400000000000000000000036031363645743000227350ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include namespace Code { class TcpServer : public CodeClass { Q_OBJECT Q_PROPERTY(QScriptValue onNewConnection READ onNewConnection WRITE setOnNewConnection) public: static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); TcpServer(); ~TcpServer() override; void setOnNewConnection(const QScriptValue &onNewConnection) { mOnNewConnection = onNewConnection; } QScriptValue onNewConnection() const { return mOnNewConnection; } public slots: QString toString() const override { return QStringLiteral("TcpServer"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue listen(const QString &address = QString(), int port = 0); QScriptValue waitForNewConnection(int waitTime = 30000); QScriptValue nextPendingConnection(); QString address() const; int port() const; private slots: void newConnection(); private: QTcpServer mTcpServer; QScriptValue mOnNewConnection; }; } actiona-3.10.1/actions/actionpackdata/code/udp.cpp000066400000000000000000000077031363645743000220500ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "udp.h" #include "code/rawdata.h" #include namespace Code { QScriptValue Udp::constructor(QScriptContext *context, QScriptEngine *engine) { Udp *udp = new Udp; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("onConnected")) udp->mOnConnected = it.value(); else if(it.name() == QLatin1String("onDisconnected")) udp->mOnDisconnected = it.value(); else if(it.name() == QLatin1String("onReadyRead")) udp->mOnReadyRead = it.value(); else if(it.name() == QLatin1String("onError")) udp->mOnError = it.value(); } return CodeClass::constructor(udp, context, engine); } Udp::Udp() : CodeClass(), mUdpSocket(new QUdpSocket(this)) { QObject::connect(mUdpSocket, &QUdpSocket::connected, this, &Udp::connected); QObject::connect(mUdpSocket, &QUdpSocket::disconnected, this, &Udp::disconnected); QObject::connect(mUdpSocket, &QUdpSocket::readyRead, this, &Udp::readyRead); QObject::connect(mUdpSocket, static_cast(&QUdpSocket::error), this, &Udp::error); } Udp::~Udp() = default; QScriptValue Udp::connect(const QString &hostname, quint16 port, OpenMode openMode) { mUdpSocket->connectToHost(hostname, port, static_cast(openMode)); return thisObject(); } QScriptValue Udp::waitForConnected(int waitTime) { if(!mUdpSocket->waitForConnected(waitTime)) throwError(QStringLiteral("ConnectionError"), tr("Cannot establish a connection to the host")); return thisObject(); } QScriptValue Udp::waitForReadyRead(int waitTime) { if(!mUdpSocket->waitForReadyRead(waitTime)) throwError(QStringLiteral("ReadyReadError"), tr("Waiting for ready read failed")); return thisObject(); } QScriptValue Udp::write(const QScriptValue &data) { QObject *object = data.toQObject(); if(auto rawData = qobject_cast(object)) { if(mUdpSocket->write(rawData->byteArray()) == -1) throwError(QStringLiteral("WriteError"), tr("Write failed")); } else { if(mUdpSocket->write(data.toVariant().toByteArray()) == -1) throwError(QStringLiteral("WriteError"), tr("Write failed")); } return thisObject(); } QScriptValue Udp::writeText(const QString &data, Encoding encoding) { if(mUdpSocket->write(toEncoding(data, encoding)) == -1) throwError(QStringLiteral("WriteError"), tr("Write failed")); return thisObject(); } QScriptValue Udp::read() { return RawData::constructor(mUdpSocket->readAll(), engine()); } QString Udp::readText(Encoding encoding) { return fromEncoding(mUdpSocket->readAll(), encoding); } QScriptValue Udp::disconnect() { mUdpSocket->disconnectFromHost(); return thisObject(); } void Udp::connected() { if(mOnConnected.isValid()) mOnConnected.call(thisObject()); } void Udp::disconnected() { if(mOnDisconnected.isValid()) mOnDisconnected.call(thisObject()); } void Udp::readyRead() { if(mOnReadyRead.isValid()) mOnReadyRead.call(thisObject()); } void Udp::error(QAbstractSocket::SocketError socketError) { Q_UNUSED(socketError) if(mOnError.isValid()) mOnError.call(thisObject(), QScriptValueList() << mUdpSocket->errorString()); } } actiona-3.10.1/actions/actionpackdata/code/udp.h000066400000000000000000000060121363645743000215050ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include #include #include namespace Code { class Udp : public CodeClass { Q_OBJECT Q_ENUMS(OpenMode) Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected) Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected) Q_PROPERTY(QScriptValue onReadyRead READ onReadyRead WRITE setOnReadyRead) Q_PROPERTY(QScriptValue onError READ onError WRITE setOnError) public: enum OpenMode { ReadOnly = QIODevice::ReadOnly, WriteOnly = QIODevice::WriteOnly, ReadWrite = QIODevice::ReadWrite }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Udp(); ~Udp() override; void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; } void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; } void setOnReadyRead(const QScriptValue &onReadyRead) { mOnReadyRead = onReadyRead; } void setOnError(const QScriptValue &onError) { mOnError = onError; } QScriptValue onConnected() const { return mOnConnected; } QScriptValue onDisconnected() const { return mOnDisconnected; } QScriptValue onReadyRead() const { return mOnReadyRead; } QScriptValue onError() const { return mOnError; } public slots: QString toString() const override { return QStringLiteral("Udp"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue connect(const QString &hostname, quint16 port, OpenMode openMode = ReadWrite); QScriptValue waitForConnected(int waitTime = 30000); QScriptValue waitForReadyRead(int waitTime = 30000); QScriptValue write(const QScriptValue &data); QScriptValue writeText(const QString &data, Encoding encoding = Native); QScriptValue read(); QString readText(Encoding encoding = Native); QScriptValue disconnect(); private slots: void connected(); void disconnected(); void readyRead(); void error(QAbstractSocket::SocketError socketError); private: QUdpSocket *mUdpSocket; QScriptValue mOnConnected; QScriptValue mOnDisconnected; QScriptValue mOnReadyRead; QScriptValue mOnError; }; } actiona-3.10.1/actions/actionpackdata/code/web.cpp000066400000000000000000000145351363645743000220360ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "web.h" #include "code/image.h" #include "code/rawdata.h" #include "file.h" #include #include #include #include #include #include #include #include namespace Code { QScriptValue Web::constructor(QScriptContext *context, QScriptEngine *engine) { Web *web = new Web; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("onFinished")) web->mOnFinished = it.value(); else if(it.name() == QLatin1String("onDownloadProgress")) web->mOnDownloadProgress = it.value(); else if(it.name() == QLatin1String("onError")) web->mOnError = it.value(); else if(it.name() == QLatin1String("file")) web->mFileValue = it.value(); } return CodeClass::constructor(web, context, engine); } Web::Web() : CodeClass(), mNetworkAccessManager(new QNetworkAccessManager(this)) { QObject::connect(mNetworkAccessManager, &QNetworkAccessManager::authenticationRequired, this, &Web::authenticationRequired); } Web::~Web() = default; QScriptValue Web::download(const QString &urlString, const QScriptValue &options) { mData.clear(); if(mFileValue.isValid()) { if(auto file = qobject_cast(mFileValue.toQObject())) mFile = file->file(); else mFile = new QFile(mFileValue.toString(), this); mCloseFile = false; if(!mFile->isOpen()) { if(!mFile->open(QIODevice::WriteOnly)) { throwError(QStringLiteral("OpenFileError"), tr("Unable to open the destination file")); return thisObject(); } mCloseFile = true; } } QUrl url(urlString); if(url.scheme() == QString()) url = QUrl(QStringLiteral("http://") + urlString, QUrl::TolerantMode); QUrlQuery urlQuery; QNetworkRequest request; QScriptValueIterator it(options); Method method = Get; QByteArray postData; while(it.hasNext()) { it.next(); if(it.name() == QLatin1String("rawHeaders")) { QScriptValueIterator headerIt(it.value()); while(headerIt.hasNext()) { headerIt.next(); request.setRawHeader(headerIt.name().toUtf8(), headerIt.value().toString().toUtf8()); } } else if(it.name() == QLatin1String("method")) { method = static_cast(it.value().toInt32()); } else if(it.name() == QLatin1String("postData")) { QScriptValueIterator postDataIt(it.value()); QUrlQuery postDataParameters; while(postDataIt.hasNext()) { postDataIt.next(); postDataParameters.addQueryItem(postDataIt.name(), postDataIt.value().toString()); } postData = postDataParameters.toString(QUrl::FullyEncoded).toLatin1(); } else if(it.name() == QLatin1String("query")) { QScriptValueIterator queryIt(it.value()); while(queryIt.hasNext()) { queryIt.next(); urlQuery.addQueryItem(queryIt.name(), queryIt.value().toString()); } } else if(it.name() == QLatin1String("user")) { mUser = it.value().toString(); } else if(it.name() == QLatin1String("password")) { mPassword = it.value().toString(); } } url.setQuery(urlQuery); request.setUrl(url); switch(method) { case Post: mNetworkReply = mNetworkAccessManager->post(request, postData); break; case Get: default: mNetworkReply = mNetworkAccessManager->get(request); break; } QObject::connect(mNetworkReply, &QNetworkReply::finished, this, &Web::finished); QObject::connect(mNetworkReply, &QNetworkReply::downloadProgress, this, &Web::downloadProgress); QObject::connect(mNetworkReply, static_cast(&QNetworkReply::error), this, &Web::error); QObject::connect(mNetworkReply, &QNetworkReply::readyRead, this, &Web::readyRead); mIsDownloading = true; return thisObject(); } bool Web::isDownloading() const { return mIsDownloading; } QScriptValue Web::toImage() const { return Image::constructor(QImage::fromData(mData), engine()); } QScriptValue Web::toText(Encoding encoding) const { return fromEncoding(mData, encoding); } QScriptValue Web::toRawData() const { return RawData::constructor(mData, engine()); } QScriptValue Web::cancel() { if(!mNetworkReply) return thisObject(); mNetworkReply->abort(); return thisObject(); } void Web::finished() { if(!mNetworkReply) return; if(mFileValue.isValid() && mFile) { if(mCloseFile) { mFile->close(); mFile->deleteLater(); } mFile = nullptr; } else mData = mNetworkReply->readAll(); if(mOnFinished.isValid()) mOnFinished.call(thisObject()); mNetworkReply->deleteLater(); mNetworkReply = nullptr; mIsDownloading = false; } void Web::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { if(bytesTotal == -1) return; if(mOnDownloadProgress.isValid()) mOnDownloadProgress.call(thisObject(), QScriptValueList() << static_cast(bytesReceived) << static_cast(bytesTotal)); } void Web::error() { if(!mNetworkReply) return; if(mNetworkReply->error() == QNetworkReply::OperationCanceledError) return; if(mOnError.isValid()) mOnError.call(thisObject(), QScriptValueList() << mNetworkReply->errorString()); } void Web::authenticationRequired(QNetworkReply *, QAuthenticator *authenticator) { authenticator->setUser(mUser); authenticator->setPassword(mPassword); } void Web::readyRead() { if(mFileValue.isValid() && mFile) mFile->write(mNetworkReply->readAll()); } } actiona-3.10.1/actions/actionpackdata/code/web.h000066400000000000000000000056211363645743000214770ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "code/codeclass.h" #include #include class QNetworkAccessManager; class QNetworkReply; class QAuthenticator; class QFile; namespace Code { class Web : public CodeClass { Q_OBJECT Q_ENUMS(Method) Q_PROPERTY(QScriptValue onFinished READ onFinished WRITE setOnFinished) Q_PROPERTY(QScriptValue onDownloadProgress READ onDownloadProgress WRITE setOnDownloadProgress) Q_PROPERTY(QScriptValue onError READ onError WRITE setOnError) public: enum Method { Get, Post }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Web(); ~Web() override; void setOnFinished(const QScriptValue &onFinished) { mOnFinished = onFinished; } void setOnDownloadProgress(const QScriptValue &onDownloadProgress) { mOnDownloadProgress = onDownloadProgress; } void setOnError(const QScriptValue &onError) { mOnError = onError; } QScriptValue onFinished() const { return mOnFinished; } QScriptValue onDownloadProgress() const { return mOnDownloadProgress; } QScriptValue onError() const { return mOnError; } public slots: QString toString() const override { return QStringLiteral("Web"); } bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); } QScriptValue download(const QString &urlString, const QScriptValue &options = QScriptValue()); bool isDownloading() const; QScriptValue toImage() const; QScriptValue toText(Encoding encoding = Native) const; QScriptValue toRawData() const; QScriptValue cancel(); private slots: void finished(); void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void error(); void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator); void readyRead(); private: QNetworkAccessManager *mNetworkAccessManager; QNetworkReply *mNetworkReply{nullptr}; QScriptValue mOnFinished; QScriptValue mOnDownloadProgress; QScriptValue mOnError; QScriptValue mFileValue; QFile *mFile{nullptr}; bool mCloseFile{false}; QByteArray mData; bool mIsDownloading{false}; QString mUser; QString mPassword; }; } actiona-3.10.1/actions/actionpackdata/data.json000066400000000000000000000000301363645743000214300ustar00rootroot00000000000000{ "Keys": [ "data" ] } actiona-3.10.1/actions/actionpackdata/icons/000077500000000000000000000000001363645743000207465ustar00rootroot00000000000000actiona-3.10.1/actions/actionpackdata/icons/copyfile.png000066400000000000000000000013131363645743000232640ustar00rootroot00000000000000PNG  IHDR sgAMA asRGB cHRMz&u0`:pQ<bKGD̿ pHYs  IDATH͔NAEO-!~:sDH؁CV"#t8#`$V3]`{W"6ytݾuz_|Q4жWOq^e<w 7yM@.4 Bt(=ќ-  $@vteϚRЂ@@Q$i\ګ|ZhL`OIo &JIuSyqU09axs΂Ҍc\\ 2jj=s-w n唹BA2 uebaC*Th%4sԛYvIAiDD2su}]7O>f]ywVi> N.i 1.7n"*=Y\Xę3g mbIO.}9LSul"@#l=KBX\9 u]TU]sG/O6sP!hMQ9B& LBg;uR 2t<r9 \pa 2'n;MhVQ3$ [͟q5 ]grl/rlBwB( URi}Nq&oaZ&e|ض-0 rD20_yCFF :GsME* EQ5Mp]4`9>:9XY˱ʏhnn=uT 149mmtvuba4,=KO^+蚎n466baexl9RJWiԓ@dcxB4ŝP!/;/(؊躎a,2)AT|Tο?reզE_qЌc쬮bsfTCCSUjlݲyhaTVUtt]G44MCR\[ƟNvp*_ 9AFz:- sM,^G#kNJYTng~t.vUB*na)VHx<r21,ⵯ}DzĶ-p^{KT E!Jʋ J>Yi0MrAgc:!FYtK^KN0B_󟇽4mX4999J FO<,X%|=;G[&4~>,2𓓕k$c(@ff&h1<'P"4tLi4;9ȸWan~z)%H+W077!k>Lz0ؿ?pKZvU.A)(.d7/Rfff\7T F;i Cx18!eyek npwASS]J&)qE!TG) -DwZ^7j-QOZ(X}|;Sp 4:%tEXtdate:create2015-08-25T22:44:35+02:00؊%tEXtdate:modify2015-08-25T22:44:35+02:006IENDB`actiona-3.10.1/actions/actionpackdata/icons/readclipboard.png000066400000000000000000000042601363645743000242510ustar00rootroot00000000000000PNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGD pHYs  IDATXå[^Uk}wozh)R AD&LE|0!`bh>A1jcmNKAvZڡәn|:vF;NN9φ1◹.?LA?O=m֧jvlSo|8rm[nXSWBZOvܸnSdc⍋/fJ\p V׾׏/֭^vS_-ͻ@rHfnm]=wN0YD\`êko^?n޴^nYmUkvCةN6(ʲUo@2Ivyg&=FKrzK'tN%OV&H!ZlYKst4w(D)^ޮUvǎ:2~`΃dcœꪉ '?~ۤv!G=pׯ1w f*>C039?_l ãHq<>tk][>Ns`ݎ%iAT!,:/+!?r?E(P ,h"b(m}x$WkQ$٥Oי /fpdtLc(KV$*t:«,"-"x2+zŵa}zed4MP)BPBD^`kǎڝ\Bv6GL1EVu eUDWZJՀ87Mrϵ'F?&L7vm:3s⏮]ZA^oL*l JԌ/vA GnW|~ll. Zk7MjOL^=ꖬ5䁘GBB$(1fEE<#,pEb"\ܺHy̒;;x?w>s+CzW/lh +TcUEU !J [aGb 1$ҤMQ#My3?6NF+^BY<2 -]!Iz_")}#c*QQ#8A"!WKk~܋]"EcQ1ٻ| :4h`{FٿG~; 7,y4e ?[oF%$8!rYrmC[O\5M8Zl;+`8>_~ QwU{޷*"(J ѹ.sPpdIoXglCA+7xrypn]\_ wpJJ#Q^ۡyDf@V͌䆪bnҖ6mZyGp` *n-Wq7 +)= Apd~i8.d^R!D IVJzXtyѕ"1d݃.dU1A1jcmNKAvZڡәn|:vF;NN9φ1◹.?LA?O=m֧jvlSo|8rm[nXSWBZOvܸnSdc⍋/fJ\p V׾׏/֭^vS_-ͻ@rHfnm]=wN0YD\`êko^?n޴^nYmUkvCةN6(ʲUo@2Ivyg&=FKrzK'tN%OV&H!ZlYKst4w(D)^ޮUvǎ:2~`΃dcœꪉ '?~ۤv!G=pׯ1w f*>C039?_l ãHq<>tk][>Ns`ݎ%iAT!,:/+!?r?E(P ,h"b(m}x$WkQ$٥Oי /fpdtLc(KV$*t:«,"-"x2+zŵa}zed4MP)BPBD^`kǎڝ\Bv6GL1EVu eUDWZJՀ87Mrϵ'F?&L7vm:3s⏮]ZA^oL*l JԌ/vA GnW|~ll. Zk7MjOL^=ꖬ5䁘GBB$(1fEE<#,pEb"\ܺHy̒;;x?w>s+CzW/lh +TcUEU !J [aGb 1$ҤMQ#My3?6NF+^BY<2 -]!Iz_")}#c*QQ#8A"!WKk~܋]"EcQ1ٻ| :4h`{FٿG~; 7,y4e ?[oF%$8!rYrmC[O\5M8Zl;+`8>_~ QwU{޷*"(J ѹ.sPpdIoXglCA+7xrypn]\_ wpJJ#Q^ۡyDf@V͌䆪bnҖ6mZyGp` *n-Wq7 +)= Apd~i8.d^R!D IVJzXtyѕ"1d݃.dU1cS_h{6,q…ÇRJ!"Z "s%w _ Z`ۆG_zټJR߿"!R}/xt47o183ȝ``Æ8ӏ<3"ȇK[@DȲ R癚bQVX$L'-˙^snsW~ **pN^gZsWPoNrEaj?ۗA$J]?ͺx8Yc%hՏ)Gfttup_8KFk6&V1xQO8q5Kpf>Gj+dA#ŧ ?,gGyqSKg˹kr|mN '&RMiOb2a?fr6ZMp4?N\?ظn $ǸؓV*:<ǎØ,<KN{ӷNūpɩI6wm(s4ƻImJ6fC l بɂs{D. Y_؛n0@$qz(&ow?g O"A'?l;wg83:8A &.㿃w:[ѣGoڵ};:o'vD@JulbIɿrCs~9022={V>ڷb,hq&Ft $T4[V,W9MPOBJ]dy(qaYVv@ĀBFAaqh<k % Q 4[Jh?W] J)LLH@ \5(X;+jXXy+%-@ 32CIhrѶ{VaM=E$"ͯR1Sd4zM,thgKJrr 2DDj0Pzz`"QhPd SHlAMjSR,d4|FYK5hg}S/H(FSHANN#oPή-UĪwvSVԨ5(T* A%eFBunBH%EPZiI.]JesT6L20@II$(T*j* 9ZؽiBB@fo+Œ*r!xY+YT[ۯ+} /p{%tEXtdate:create2015-08-25T22:44:35+02:00؊%tEXtdate:modify2015-08-25T22:44:35+02:006IENDB`actiona-3.10.1/actions/actionpackdata/icons/readregistry.png000066400000000000000000000062011363645743000241570ustar00rootroot00000000000000PNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGD pHYs   vIDATXÕYlysmvr Iqdmdɶ$+XEa[čQH^H+iPM{EjAdɑcjE5DDr!䐜(nܝs/1FGǚ,Zn[nd6OmSBpS 5Mt}b}O_ \,_\鯩ECQE,J%͉͘IP ˃g{{~vWv>P0x]`ϸr2cӲ~mؿX,NY.Fb5 tzFdf6-7---XU ˱:9Ùr(PömtegrRtUE).繖_t&]L33}l|RU 1s۳ì&Z pkaW=+߸X_gz;'`p?H }ࡃfnΦMTPaֈaNXMov "(v@0ty˦-_p7bV-̲m[Xe.cY6yw %$4W5_𥇩VƸ;:FZ&jĴm,ӢX.µk[kjkˏάtwwޘHP**3J&?@R  t:yx(BUocrj`#c86HAz:-ɼN *@\2]_Yq}FFY /O hj*H)Q)7p{pjd[v< fD+Oo- CJbp_cY&XO+bu|"p]ڋȱmRJ"HE*RJ | t<έOQx4bmkBPDrE,ߤ%N*B_GH@)R6HTH<Ïtb(RW;##$zk[: u=nF04]h(J4ME1TԀDhQPQkUza<>@mUXSy4ޟ AX("ml|E()A')$*b /P<[&0~<ɛé2t o ]yx! w&wPP! 4. =~'c*%4C*8W=ɕ+Ca@6oQ[g?87GO捏7ٳc/p  hVs-RU4׮|ӽuΜ+ŻSoOemN18x{駞faaBOW+ ˩>!5HDhxQ8z $wؾu]cyi>&L$Ͷ녾+,-d>4ąϮ0|k|o 52Խ sY f٤ZT)Iߟ/'+q̪G-3/0wta=gdl?'I&iGJ /ѕL|>|ŹV* Mٽ-򛳿%h`rb>,MMq3E]<X`iii1P?:> ~WbdS'O1;?OcZY*-#TZQC([>%rY\Ld;Ǐ}]λ?gds5e5\ǨVM._(#)Ɗ#\G(e\钑EOX[ 9b51y}}k4r.&&:/e;ߩ}/^/Hccwxg-||rWA엉(-H$yd2Ic]#.\7M/ťe{n6NUUUrǞ?u|t$hk7R |zq;|:"5ajkc(qAM"JOzZʑ]G/~ɯ?OzXe9S='ذa=흌߻OzD{'N\Rf< `5@˭TU~I;O#su~;}z O:)Х/.`[{Q |Ou!"?~}&IR AҏK'DJ $Fi^}D9Q`\igUV+Ul(", ^es5J)֝ka7RD˟pk!nMs{*zJ́JaKu]n58;+ljNыZF=EyZtA).f>( 1<)vh^9|\|bl!r;/XY)̐HB+ ReW0X"ed~FPZRԥ1c-F*?ǥɏ-C( ]xB楝Õ"qhc8LŒ=//*jח1_Y`0JZˣ2TcZS<*Gi)GB9r܄rC(-9ty4o OSg`?ˏwI` AiUVYUL';?>krp]l'-7?w?:*(P Q;񃀜ׅV m4XŞ07]| _0e5VPV`Pv{0kqZ9s'NVÓ'Ov}Fs|m=]$h mKntr\SC1;wnja|Jv X KވMe} C&v)XCKQr]Ѯ 6;|Cӫ^G ( V߭=L0110Xa Um LJ jJ]M ao[6) B hhX 2HRUm#(vwdq\ev+4P!!^2A~ LqrQg*E1E{MZzPɸ1t LLLvW3Y~Jna& =ipph[=>tdC43h2II\B$dCz[b`n~ab]nrPS1h.eEjR>U?IDATXŗo3Kr]rI⒢i@ܒ@ 9$& `/FsQ8AK$R$/9]>ræsŽ$իt'BiV;rʕjU}.0֭?][P93#MSD"³"CUI}$".SǣGu) x/ XDp1.`llXMy ÇLOO333a6j,,\%!p0YUP(E,HF"$gkIv7lfxr,0:6O8c*{sy:㘍 FX^^& ~h&$ W*\*ޡY*233ɗza˻wjkS-*ssKkO)0$`eުR,YYYNڤds?5Pow7<}I2ӥs, ]T ˾{(di%&J%j>T3fJyǯ '7n2p`!Ó#(&MvkzGo>VFjJ-Gޝ&a& 8΁Ó6jQS.OR{{+a=䭻jR/q^zjV7S##`vR5Njw:6Q.BgRtoZmDIN뫗2uX'afzUfb?vF=>xzm)N`&gwf[6/+"O^9GG $>xr7חݤ470o0Q@UIfRDyrrL@uNCpbX\; l2߯BwL$z=ӫ =0qBD`< Ӌ|n8ɔgjD{gK0o3;;; 8E@/ ?NH.!{wZƅH:z/6=AP˓t=/ {Kxyy٩?(7$=z+{gs' 3ApmtK/, p$I_Żu 09Zm7ZNv}&^{e 33 bFOۅxg-?9F lrDyk/f϶PT] rhJ1I0ް/<EzO!NbP]I)D^ tpu{^gJٵ[UsB D"U3A~R>x^ȶ;yA NJQ<%Io{<"jW}>%tEXtcreate-date2009-11-28T17:18:28-07:001,%tEXtdate:create2015-08-25T22:44:35+02:00؊%tEXtdate:modify2015-08-25T22:44:35+02:0065tEXtLicensehttp://creativecommons.org/licenses/LGPL/2.1/;%tEXtmodify-date2009-11-28T14:33:24-07:00ƀtEXtSourceCrystal Project'tEXtSource_URLhttp://everaldo.com/crystal/[IENDB`actiona-3.10.1/actions/actionpackdata/icons/webdownload.png000077500000000000000000000054021363645743000237650ustar00rootroot00000000000000PNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGD pHYsHHFk> IDATXŗitU}ι9InJ*KXHQՊhK]ZkE]8A+: "uC$d"Mn;?N[AwZZ{ix@ ^I+RTs%6Ls6Z#oNDu"i:k͂prn6g2!'˙0 5mKrS43=Th!'od? )r'C=k⫗]8src\vZyN3h}c0P<ִí}'qOb4Ǐwy 0K"p7Hi4$xyI{5W{-!'`Ú> XQ&`T;ԧw~0s^p= qR4tBQ8 c@n& Žc&lDۣb=g=_~1Ԭ55mRǐ,PN;P 2r4X DBH [i՞ǚ<,JHhFU-.$%8 |*'%)CzNP*{xTWpޫK[]4L04{kBWbb`d0Yך 8(A|/qXtEJ|,?"ˏ٩ ;$@1cVf-3d BP> p (ˆbx.qB8e1aqQЋ¡ h#'?Hhb_vwC|N^la BG.~WO.iMSDuU340dA}m~.\\dUޘ9ٖ9Dqd#pe~N!&8xP֍BW#VBG{JQ6ACBWEHÒ :~X SF-%-PqQʇp'_ X9 4)gRH&Db<1v n4v559bѹ8A8^F(aP4޺<. ꁤfKsOe8Ndcye'^SI yG~O]Q.!NHuF[3CJ}sꅞH \)H .'^In2`&yAZpTu[,;SLZ 7]uо0)$,=]Ȓ0o 0S6\ #ZI.h;P=v0WA~.] q%$RV-:'~8m)f@y1B Q# G C:(t2$<gHx< `zX0 X1@C+NVIhN@" _ 8 (*RAv7Q=-VlQᛃpyc28Ƙ\#GzV,Ko2R۷STTDii)va{BLa՜9sfą^Ԙ Ço>vލ11 XBJϝӧ#GX~#jkkI&̟?`YB!߿x ƯuA>+Vr<5uXn:s0az89~/]ӮlvLc#/]ٹskRiض}7[hM&F)=41BݻG4q]$wxرcG6+Ų%KH `\PLk,@81A?ϟylOciR}>B&aB;~ 1?Yӧ'?jmqP ?e|PY{֬ɲ&@~|9 z$-OWǽ[)l!`˗IMBmʄ+WDJMM,Y׋~N$H a>!(~g֮];Re I$ݻywjSVȲKI\)N?ϱQ[W8u&188ȡC2=::*)cfu~_KJ'׵%̧g ` 'FNyߞ33{y"hFkuq~Y*QĈДǎ?❥_9fh4#\bWn|:| o4 '!w^K OROW&fhBC.]<ǽGvAJjIayn"B!DaS|\=5zy4`yWiOkÝ6w,K42u݋cD:A(Fj{f%*,f5U:0m-, kѾY ݽ=)i3> n*$;vbpdR l1"d)p " Qޞȴ !, wnۆjKK\F\F$M1s2D.Ifb@fV .H00 I$IЛ$ 2b‡=$Hеf>҃(\@3sseis@,BD(xOqÇndS/b ) qh)$)Dd13"*B_:AHZ nV0W0U;tm] .wZ\[Uɲ)| u%e+NulqY 3zV dSI ،AIrJ EN!f)FZC[=!ރ,Fc=UY{Z/ܹ_xpxSOݥcG$>0?XJZ./2fD`rv1L_+3+Ǜ0.lߵ ;k:lM0p6-GS#{G[_'~~q+1/-M#CK]k!yX` z_0`&0[1<@>?ϜծkzoF;;Omk^9;t@^CU$`3K r9@*yq}ܾ{j}A& EE~̥{7%5SZ l"눍K,5&4j$z ;sJCQ |L2$i0$|ֆ0/ ňNUE&DDU$Ngv "<4199ٿ'"đVTF88XIс5.rc1k-/^VDQD]-/cuLn Ia' uNkKBP(4u>? xyHƄ>}5RxRq5bW9 ۾s`uSbĚR q@n0Ҹ' y33Ԓ)RyN4=y_!؎Eu0_|m<f[0a+* @.\m؍Z$T.?*-!h i[6Q@$ypq8:8H__Msn+2ld5-yRYϞ?W -FhsYkY%WiҥKw?FԬnC@4lx`-bx/{NJPd\߾^ֈRЫ|@[Zy=o f}*lc1& Y MZ X8~Oϝ張;օ*ٽ72zm-zB.8zv󕋟~k*5k/כ8 R;?VioF&XkhױJ3gϦՐWֈIo/;q/?׃ ly37wS_>xQ`660AV*VA4 !y&I#?lC2͛?ïx9۷zHz.yd}=qP赮XFQڞ36lvF (GqԮIx襗IP;> XK!"Jak5뢌yhPOR.34\._h sP4;KR"I*3_(h%*L߸Z[q(0+I$$lDaj$A@옦.FUP Z pt2IߡCGSXqgc`v6f=y)LFU0>DES*JV*x` F'O !E"dWVFcLT#Eh&c,J g闧@T c#[]Ek ΁!^oS8gqJb@c&\k8a%TxOAxxhko_,)J!4PT: @J8@&2t aqg,h{6r@Gq֒[ɑHa4x IN` tE`qƁ3kN9Gb"M-EU0999'4h JJF-U#QDVjYo>1hCUQJ-ZQ 8C> utyBXsk+DZCd (XYXqȬ%1DR3#F>g*ZV: /p$qBW!H/%R"B* )<PC*I+x* M|5NdΞ e3 6%/CHR(BD)Sb! x2F}c#ׯ]ܾE2 8Wt%8opUgh\O*CD pknҁt)~li^)6=:x Gɩɩ R47Fn<'>A]ʕ # <rǣ1Q~?aprvw\Ds~B<q"S[Z{nݻs9Ɩi${v3;:FggW@2 J+\~_H66/UqO V#=geqq- d,FLɷ=R-0:2ݏVϞ4:\zƆ؆lv9ު_76pȣ|rPX,<:mwPV׺_>}uÐ24|D@@g~eIK+a(<> ѿZ.G:!8374JaXg2  Z/!-ʹuv+*$z{{y09@W~o}k[5_ĎtX-) d!RF( cxATT͍ 67`h|j=rv%K/B566zL&sg >8W" FFAMMtڴSulJ&Oi޲mlmmakK3X|Ľw M>䉧9~K3hhh(_|Q  rjj湽{g|Og_]H'[@H<_;YKL)ʵT9f7n6|];wWƇ\yرcW>\þ"588o9}v091ƻ*}jifS]aA $Ur9 wY6S?Ϟ];\G_|_>}kmVXks.)hrʾ_yO;zNGx=}oŋ.-έ8BKJEW4%L!?ϝct|5[Z>wRʴ6'zWkW'޾R& 2+ B '$h=~ z_6].}ٟ:u&0 , L&_?qgFF' &E$—aSdw>2[os]6ţGϝ{o{ uohz߸?mkk{RlaPdTD gIHf&*s`Ϟzꋷ{{{I)GY` (n &Dh:Z'=7;::9??:^+#Pq%w(۷ܼ3=&8xZJihfn@ؼJ 4:6 Vo…GjΉ3ό:sfB2@v 2#ܘp\@g 9'|׀*@. pxP]%tEXtdate:create2015-08-25T22:44:35+02:00؊%tEXtdate:modify2015-08-25T22:44:35+02:006IENDB`actiona-3.10.1/actions/actionpackdata/icons/writetext.png000066400000000000000000000035441363645743000235210ustar00rootroot00000000000000PNG  IHDR szzgAMA asRGB cHRMz&u0`:pQ<bKGD pHYs  YIDATXåmoޙ`7x͓ !j"A@ X]<{bS(kH͜{s9aڥ~)ˑYO̗/\vIB*:+(J}9s~O ^X4֢EsP+ 1Zs\to̾8΃dEhqS553e146l`xVsXkskY_9nqhj Sc]\"(3fa9 QJaE)[7Ɍ潙: y"޿y+ʼ>Z- ?RBDXhP qIoa[ΡGb C w}zI6C~nɥX###8ĖۏZr`qN6tT$,,kqv _gg9zs咥|evhD?)P- ,8_**9L)r.XsjUJ7cl% .ME. Contact : jmgr@jmgr.info */ #pragma once #include "actionpack.h" #include "actions/textdefinition.h" #include "actions/clickdefinition.h" #include "actions/wheeldefinition.h" #include "actions/keydefinition.h" #include "actions/movecursordefinition.h" #include "actions/cursorpathdefinition.h" #include "actions/keyboardkeyconditiondefinition.h" #include "code/mouse.h" #include "code/keyboard.h" #include namespace ActionTools { class ActionDefinition; } class ActionPackDevice : public QObject, public ActionTools::ActionPack { Q_OBJECT Q_INTERFACES(ActionTools::ActionPack) Q_PLUGIN_METADATA(IID "tools.actiona.ActionPack" FILE "device.json") public: ActionPackDevice() = default; void createDefinitions() override { addActionDefinition(new Actions::TextDefinition(this)); addActionDefinition(new Actions::ClickDefinition(this)); addActionDefinition(new Actions::WheelDefinition(this)); addActionDefinition(new Actions::KeyDefinition(this)); addActionDefinition(new Actions::MoveCursorDefinition(this)); addActionDefinition(new Actions::CursorPathDefinition(this)); addActionDefinition(new Actions::KeyboardKeyConditionDefinition(this)); } QString id() const override { return QStringLiteral("device"); } QString name() const override { return tr("Actions dealing with devices like the keyboard or the mouse"); } Tools::Version version() const override { return Tools::Version(0, 0, 1); } void codeInit(QScriptEngine *scriptEngine) const override { addCodeClass(QStringLiteral("Mouse"), scriptEngine); addCodeClass(QStringLiteral("Keyboard"), scriptEngine); } private: Q_DISABLE_COPY(ActionPackDevice) }; actiona-3.10.1/actions/actionpackdevice/actionpackdevice.pro000066400000000000000000000011511363645743000241750ustar00rootroot00000000000000include(../common_actions.pri) include(actions/actions.pri) include(code/code.pri) TARGET = ActionPackDevice QT += script widgets unix:QT += x11extras OTHER_FILES += device.json HEADERS += actionpackdevice.h \ mousedevice.h \ keyboarddevice.h RESOURCES += actionpackdevice.qrc unix:LIBS += -lXtst win32:LIBS += -luser32 TRANSLATIONS = ../../locale/actionpackdevice_fr_FR.ts SOURCES += mousedevice.cpp \ keyboarddevice.cpp unix { locales.path = $${PREFIX}/share/actiona/locale locales.files = ../../locale/actionpackdevice_fr_FR.qm locales.CONFIG = no_check_exist INSTALLS += locales } actiona-3.10.1/actions/actionpackdevice/actionpackdevice.qrc000066400000000000000000000004471363645743000241710ustar00rootroot00000000000000 icons/click.png icons/key.png icons/text.png icons/wheel.png icons/movecursor.png icons/keycondition.png actiona-3.10.1/actions/actionpackdevice/actions/000077500000000000000000000000001363645743000216215ustar00rootroot00000000000000actiona-3.10.1/actions/actionpackdevice/actions/actions.pri000066400000000000000000000012121363645743000237710ustar00rootroot00000000000000HEADERS += actions/wheeldefinition.h \ actions/wheelinstance.h \ actions/keydefinition.h \ actions/keyinstance.h \ actions/movecursorinstance.h \ actions/movecursordefinition.h \ actions/textdefinition.h \ actions/textinstance.h \ actions/clickdefinition.h \ actions/clickinstance.h \ actions/cursorpathdefinition.h \ actions/cursorpathinstance.h \ $$PWD/keyboardkeyconditiondefinition.h \ $$PWD/keyboardkeyconditioninstance.h SOURCES += actions/textinstance.cpp \ actions/keyinstance.cpp \ actions/clickinstance.cpp \ actions/cursorpathinstance.cpp \ $$PWD/keyboardkeyconditioninstance.cpp actiona-3.10.1/actions/actionpackdevice/actions/clickdefinition.h000066400000000000000000000105701363645743000251330ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "clickinstance.h" #include "listparameterdefinition.h" #include "numberparameterdefinition.h" #include "positionparameterdefinition.h" #include "booleanparameterdefinition.h" #include "groupdefinition.h" #include namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ClickDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit ClickDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ClickInstance::buttons", ClickInstance::buttons); translateItems("ClickInstance::actions", ClickInstance::actions); auto &action = addParameter({QStringLiteral("action"), tr("Action")}); action.setTooltip(tr("The action to simulate")); action.setItems(ClickInstance::actions); action.setDefaultValue(ClickInstance::actions.second.at(ClickInstance::ClickAction)); auto &button = addParameter({QStringLiteral("button"), tr("Button")}); button.setTooltip(tr("The button to simulate")); button.setItems(ClickInstance::buttons); button.setDefaultValue(ClickInstance::buttons.second.at(MouseDevice::LeftButton)); auto &position = addParameter({QStringLiteral("position"), tr("Position")}); position.setTooltip(tr("The screen position where to simulate a mouse click")); auto &restoreCursorPosition = addParameter({QStringLiteral("restoreCursorPosition"), tr("Restore cursor position")}); restoreCursorPosition.setTooltip(tr("Restore the cursor position after the action is finished")); auto &clickGroup = addGroup(); clickGroup.setMasterList(action); clickGroup.setMasterValues({ClickInstance::actions.first.at(ClickInstance::ClickAction)}); auto &amount = clickGroup.addParameter({QStringLiteral("amount"), tr("Amount")}); amount.setTooltip(tr("The amount of clicks to simulate")); amount.setMinimum(1); amount.setMaximum(std::numeric_limits::max()); amount.setDefaultValue(QStringLiteral("1")); auto &positionOffset = addParameter({QStringLiteral("positionOffset"), tr("Offset")}, 1); positionOffset.setTooltip(tr("The offset to apply to the click position")); addException(ClickInstance::FailedToSendInputException, tr("Send input failure")); addException(ClickInstance::InvalidActionException, tr("Invalid action")); } QString name() const override { return QObject::tr("Click"); } QString id() const override { return QStringLiteral("ActionClick"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Emulates a mouse click"); } ActionTools::ActionInstance *newActionInstance() const override { return new ClickInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Device; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/actions/icons/click.png")); } bool requirementCheck(QStringList &missingRequirements) const override { return requirementCheckXTest(missingRequirements); } QStringList tabs() const override { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(ClickDefinition) }; } actiona-3.10.1/actions/actionpackdevice/actions/clickinstance.cpp000066400000000000000000000072231363645743000251430ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "clickinstance.h" #include "consolewidget.h" #include #include namespace Actions { Tools::StringListPair ClickInstance::buttons = { { QStringLiteral("left"), QStringLiteral("middle"), QStringLiteral("right") }, { QStringLiteral(QT_TRANSLATE_NOOP("ClickInstance::buttons", "Left")), QStringLiteral(QT_TRANSLATE_NOOP("ClickInstance::buttons", "Middle")), QStringLiteral(QT_TRANSLATE_NOOP("ClickInstance::buttons", "Right")) } }; Tools::StringListPair ClickInstance::actions = { { QStringLiteral("pressRelease"), QStringLiteral("press"), QStringLiteral("release") }, { QStringLiteral(QT_TRANSLATE_NOOP("ClickInstance::actions", "Click (press and release)")), QStringLiteral(QT_TRANSLATE_NOOP("ClickInstance::actions", "Press")), QStringLiteral(QT_TRANSLATE_NOOP("ClickInstance::actions", "Release")) } }; void ClickInstance::startExecution() { bool ok = true; bool isPositionEmpty = false; auto action = evaluateListElement(ok, actions, QStringLiteral("action"), QStringLiteral("value")); auto button = evaluateListElement(ok, buttons, QStringLiteral("button"), QStringLiteral("value")); QPoint position = evaluatePoint(ok, QStringLiteral("position"), QStringLiteral("value"), &isPositionEmpty); QPoint positionOffset = evaluatePoint(ok, QStringLiteral("positionOffset")); int amount = evaluateInteger(ok, QStringLiteral("amount")); bool restoreCursorPosition = evaluateBoolean(ok, QStringLiteral("restoreCursorPosition")); if(!ok) return; if(action != ClickAction) amount = 1; if(amount <= 0) { setCurrentParameter(QStringLiteral("amount")); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid click amount")); return; } QPoint previousPosition = mMouseDevice.cursorPosition(); if(!isPositionEmpty) { position += positionOffset; mMouseDevice.setCursorPosition(position); } for(int i = 0; i < amount; ++i) { if(action == ClickAction || action == PressAction) { if(!mMouseDevice.pressButton(button)) { emit executionException(FailedToSendInputException, tr("Unable to emulate click: button event failed")); return; } } if(action == ClickAction || action == ReleaseAction) { if(!mMouseDevice.releaseButton(button)) { emit executionException(FailedToSendInputException, tr("Unable to emulate click: button event failed")); return; } } } if(!isPositionEmpty && restoreCursorPosition) { mMouseDevice.setCursorPosition(previousPosition); } QTimer::singleShot(1, this, [this] { executionEnded(); }); } void ClickInstance::stopLongTermExecution() { mMouseDevice.reset(); } } actiona-3.10.1/actions/actionpackdevice/actions/clickinstance.h000066400000000000000000000027511363645743000246110ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "../mousedevice.h" #include "stringlistpair.h" namespace Actions { class ClickInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Action { ClickAction, PressAction, ReleaseAction }; enum Exceptions { FailedToSendInputException = ActionTools::ActionException::UserException, InvalidActionException }; ClickInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent) {} static Tools::StringListPair buttons; static Tools::StringListPair actions; void startExecution() override; void stopLongTermExecution() override; private: MouseDevice mMouseDevice; Q_DISABLE_COPY(ClickInstance) }; } actiona-3.10.1/actions/actionpackdevice/actions/cursorpathdefinition.h000066400000000000000000000056501363645743000262430ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actiondefinition.h" #include "cursorpathinstance.h" #include "pointlistparameterdefinition.h" #include "listparameterdefinition.h" #include "positionparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class CursorPathDefinition : public ActionTools::ActionDefinition { Q_OBJECT public: explicit CursorPathDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("CursorPathInstance::buttons", CursorPathInstance::buttons); auto &path = addParameter({QStringLiteral("path"), tr("Path")}); path.setTooltip(tr("The path to follow")); auto &button = addParameter({QStringLiteral("button"), tr("Button")}); button.setTooltip(tr("The button to simulate")); button.setItems(CursorPathInstance::buttons); button.setDefaultValue(CursorPathInstance::buttons.second.at(CursorPathInstance::NoButton)); auto &positionOffset = addParameter({QStringLiteral("positionOffset"), tr("Offset")}, 1); positionOffset.setTooltip(tr("The offset to apply to the path")); } QString name() const override { return QObject::tr("Cursor path"); } QString id() const override { return QStringLiteral("ActionCursorPath"); } ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; } QString description() const override { return QObject::tr("Move the mouse cursor on a path"); } ActionTools::ActionInstance *newActionInstance() const override { return new CursorPathInstance(this); } ActionTools::ActionCategory category() const override { return ActionTools::Device; } QPixmap icon() const override { return QPixmap(QStringLiteral(":/actions/icons/movecursor.png")); } bool requirementCheck(QStringList &missingRequirements) const override { return requirementCheckXTest(missingRequirements); } QStringList tabs() const override { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(CursorPathDefinition) }; } actiona-3.10.1/actions/actionpackdevice/actions/cursorpathinstance.cpp000066400000000000000000000025631363645743000262520ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "cursorpathinstance.h" namespace Actions { Tools::StringListPair CursorPathInstance::buttons = { { QStringLiteral("none"), QStringLiteral("left"), QStringLiteral("middle"), QStringLiteral("right") }, { QStringLiteral(QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "None")), QStringLiteral(QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "Left")), QStringLiteral(QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "Middle")), QStringLiteral(QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "Right")) } }; } actiona-3.10.1/actions/actionpackdevice/actions/cursorpathinstance.h000066400000000000000000000067401363645743000257200ustar00rootroot00000000000000/* Actiona Copyright (C) 2005 Jonathan Mercier-Ganady Actiona is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actiona is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #pragma once #include "actioninstance.h" #include "../mousedevice.h" #include #include namespace Actions { class CursorPathInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Button { NoButton, LeftButton, MiddleButton, RightButton }; CursorPathInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr) : ActionTools::ActionInstance(definition, parent), mCurrentPoint(0), mButton(NoButton) { connect(&mMoveTimer, &QTimer::timeout, this, &CursorPathInstance::moveToNextPosition); } static Tools::StringListPair buttons; void startExecution() override { bool ok = true; mPositionOffset = evaluatePoint(ok, QStringLiteral("positionOffset")); mButton = evaluateListElement