pax_global_header00006660000000000000000000000064126164512400014513gustar00rootroot0000000000000052 comment=e549108d6418e99d0f427bef073e2b1b2c9702a7 actiona-3.9.1/000077500000000000000000000000001261645124000131435ustar00rootroot00000000000000actiona-3.9.1/.gitignore000066400000000000000000000001311261645124000151260ustar00rootroot00000000000000*.exe *.ilk *.pdb *.user *.user.* *.dll *.exp *.qm *.lib generated *.so* *.log* *.cache* actiona-3.9.1/CHANGELOG000066400000000000000000000307031261645124000143600ustar00rootroot000000000000003.9.1 (04/11/15) Global: - Windows: fixed click simulation failures in some cases - fixed a crash when cancelling 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 - added ProgressDialog.close() 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.9.1/LICENSE000066400000000000000000000773301261645124000141620ustar00rootroot00000000000000 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.9.1/README000066400000000000000000000006201261645124000140210ustar00rootroot00000000000000** 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.9.1/actexecuter/000077500000000000000000000000001261645124000154575ustar00rootroot00000000000000actiona-3.9.1/actexecuter/actexecuter.pro000066400000000000000000000023201261645124000205120ustar00rootroot00000000000000include(../common.pri) unix:!mac:QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN -Wl,--rpath=$${PREFIX}/$${LIBDIR}/actiona QT += xml \ network \ script \ scripttools equals(QT_MAJOR_VERSION, 5) { QT += 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 win32:RC_FILE = actexecuter.rc TRANSLATIONS = ../locale/actexecuter_fr_FR.ts \ ../locale/actexecuter_de_DE.ts unix:!mac:CONFIG += link_pkgconfig unix:!mac:PKGCONFIG += libnotify unix { target.path = $${PREFIX}/bin locales.path = $${PREFIX}/share/actiona/locale locales.files = ../locale/actexecuter_fr_FR.qm \ ../locale/actexecuter_de_DE.qm locales.CONFIG = no_check_exist manfile.path = $${PREFIX}/share/man/man1 manfile.files = ../docs/actexec.1 INSTALLS += target locales manfile } actiona-3.9.1/actexecuter/actexecuter.rc000066400000000000000000000001131261645124000203140ustar00rootroot00000000000000IDI_ICON1 ICON DISCARDABLE "../gui/icons/actiona.ico" actiona-3.9.1/actexecuter/codeexecuter.cpp000066400000000000000000000124421261645124000206450ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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, SIGNAL(evaluationResumed()), this, SLOT(onEvaluationResumed())); connect(mScriptEngineDebugger, SIGNAL(evaluationSuspended()), this, SLOT(onEvaluationPaused())); connect(mScriptAgent, SIGNAL(executionStopped()), this, SLOT(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 = device->readAll(); device->close(); mScriptAgent->setContext(LibExecuter::ScriptAgent::ActionInit); LibExecuter::CodeInitializer::initialize(mScriptEngine, mScriptAgent, actionFactory()); Code::CodeTools::addClassToScriptEngine("Console", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::print, "print", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::println, "println", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printWarning, "printWarning", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printlnWarning, "printlnWarning", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printError, "printError", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printlnError, "printlnError", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::clear, "clear", mScriptEngine); Code::CodeTools::addClassToScriptEngine("Actiona", mScriptEngine); LibExecuter::CodeActiona::setActExec(true); LibExecuter::CodeActiona::setActionaVersion(Global::ACTIONA_VERSION); LibExecuter::CodeActiona::setScriptVersion(Global::SCRIPT_VERSION); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::version, "version", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::scriptVersion, "scriptVersion", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::isActExec, "isActExec", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::isActiona, "isActiona", mScriptEngine); QString locale = Tools::locale(); for(int actionPackIndex = 0; actionPackIndex < actionFactory()->actionPackCount(); ++actionPackIndex) { ActionTools::ActionPack *actionPack = actionFactory()->actionPack(actionPackIndex); Tools::installTranslator(QString("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("\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.9.1/actexecuter/codeexecuter.h000066400000000000000000000025161261645124000203130ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef CODEEXECUTER_H #define CODEEXECUTER_H #include "executer.h" namespace LibExecuter { class ScriptAgent; } class QScriptEngine; class QScriptEngineDebugger; class QMainWindow; class CodeExecuter : public Executer { Q_OBJECT public: explicit CodeExecuter(QObject *parent = 0); bool start(QIODevice *device, const QString &filename); private slots: void onEvaluationResumed(); void onEvaluationPaused(); void stopExecution(); private: QScriptEngine *mScriptEngine; LibExecuter::ScriptAgent *mScriptAgent; QScriptEngineDebugger *mScriptEngineDebugger; QMainWindow *mDebuggerWindow; }; #endif // CODEEXECUTER_H actiona-3.9.1/actexecuter/executer.cpp000066400000000000000000000036061261645124000200140ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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)), mActionLoadingFailed(false) { connect(mActionFactory, SIGNAL(actionPackLoadError(QString)), this, SLOT(actionPackLoadError(QString))); } Executer::~Executer() { } bool Executer::start(QIODevice *device, const QString &filename) { Q_UNUSED(device) Q_UNUSED(filename) QSettings settings; QString locale = settings.value("gui/locale", QLocale::system().name()).toString(); mActionFactory->loadActionPacks(QApplication::applicationDirPath() + "/actions/", locale); #ifndef Q_OS_WIN if(mActionFactory->actionPackCount() == 0) mActionFactory->loadActionPacks(QString("%1/%2/actiona/actions/").arg(ACT_PREFIX).arg(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.9.1/actexecuter/executer.h000066400000000000000000000023511261645124000174550ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef EXECUTER_H #define EXECUTER_H #include class QIODevice; namespace ActionTools { class ActionFactory; } class Executer : public QObject { Q_OBJECT public: explicit Executer(QObject *parent = 0); virtual ~Executer(); 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; }; #endif // EXECUTER_H actiona-3.9.1/actexecuter/global.h000066400000000000000000000020431261645124000170670ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef GLOBAL_H #define GLOBAL_H #include "version.h" namespace Global { const Tools::Version ACTIONA_VERSION = Tools::Version(VERSION_TO_STRING(ACT_VERSION)); const Tools::Version SCRIPT_VERSION = Tools::Version(VERSION_TO_STRING(ACT_SCRIPT_VERSION)); const QString CONNECTIVITY_URL = "http://actiona.tools/"; } #endif // GLOBAL_H actiona-3.9.1/actexecuter/main.cpp000066400000000000000000000270421261645124000171140ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 "globalshortcut/globalshortcutmanager.h" #include "qxtcommandoptions/qxtcommandoptions.h" #include "actioninstance.h" #include "version.h" #include "mainclass.h" #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include "qtsingleapplication/qtsingleapplication.h" #else #include "nativeeventfilteringapplication.h" #endif #include "global.h" #include "settings.h" #include "languages.h" #include #include #include #include #include #include #include #include #include #include #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include #endif #ifdef Q_OS_LINUX #undef signals #include #define signals #include "keysymhelper.h" #endif #ifdef Q_OS_WIN #include #include #include #include #include #include #endif static void cleanup() { ActionTools::GlobalShortcutManager::clear(); } #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 < 0x050200) #error("You need Qt 5.2.0 or later to compile Actiona Executer"); #endif #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QtSingleApplication app("actiona-exec", argc, argv); #else ActionTools::NativeEventFilteringApplication app("actiona-exec", argc, argv); #endif app.setQuitOnLastWindowClosed(false); qAddPostRoutine(cleanup); qsrand(std::time(NULL)); #ifdef Q_OS_LINUX notify_init("Actiona executer"); #endif #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); #endif QxtCommandOptions preOptions; preOptions.add("portable", QObject::tr("starts in portable mode, storing the settings in the executable folder")); preOptions.alias("portable", "p"); preOptions.parse(QCoreApplication::arguments()); if(preOptions.count("portable") > 0) { QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationDirPath() + "/userSettings"); QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QApplication::applicationDirPath() + "/systemSettings"); QSettings::setDefaultFormat(QSettings::IniFormat); } QString locale = Tools::locale(); Tools::installQtTranslator(locale); Tools::installTranslator("tools", locale); Tools::installTranslator("actiontools", locale); Tools::installTranslator("executer", locale); Tools::installTranslator("actexecuter", locale); const QStringList &arguments = QCoreApplication::arguments(); QxtCommandOptions options; options.setFlagStyle(QxtCommandOptions::DoubleDash); options.setScreenWidth(0); options.add("code", QObject::tr("switch to code mode, may not be used with -s")); options.alias("code", "c"); options.add("script", QObject::tr("switch to script mode, may not be used with -c")); options.alias("script", "s"); options.add("nocodeqt", QObject::tr("do not include the Qt library into the code")); options.alias("nocodeqt", "Q"); options.add("portable", QObject::tr("starts in portable mode, storing the settings in the executable folder")); options.alias("portable", "p"); options.add("proxy-mode", QObject::tr("sets the proxy mode, values are \"none\", \"system\" (default) or \"custom\"")); options.add("proxy-type", QObject::tr("sets the custom proxy type, values are \"http\" or \"socks\" (default)")); options.add("proxy-host", QObject::tr("sets the custom proxy host")); options.add("proxy-port", QObject::tr("sets the custom proxy port")); options.add("proxy-user", QObject::tr("sets the custom proxy user")); options.add("proxy-password", QObject::tr("sets the custom proxy password")); #ifdef Q_OS_WIN options.add("console", QObject::tr("create a console to see debug output")); options.add("pause-at-end", QObject::tr("wait for user input at the end of the execution, used only with --console")); #endif options.add("version", QObject::tr("show the program version")); options.alias("version", "v"); options.add("help", QObject::tr("show this help text")); options.alias("help", "h"); options.parse(arguments); #ifdef Q_OS_WIN if(options.count("console")) { createConsole(); if(options.count("pause-at-end")) qAddPostRoutine(pause); } #endif qRegisterMetaType("ActionInstance"); qRegisterMetaType("Exception"); qRegisterMetaType("Parameter"); qRegisterMetaType("SubParameter"); qRegisterMetaType("Version"); qRegisterMetaTypeStreamOperators("ActionInstance"); qRegisterMetaTypeStreamOperators("Parameter"); qRegisterMetaTypeStreamOperators("SubParameter"); qRegisterMetaTypeStreamOperators("Version"); if(options.count("version")) { QTextStream stream(stdout); stream << "Actiona Executer version " << Global::ACTIONA_VERSION.toString() << ", script version " << Global::SCRIPT_VERSION.toString() << "\n"; stream.flush(); return 0; } if(options.count("help") || options.showUnrecognizedWarning() || options.positional().count() < 1 || (options.count("code") && options.count("script"))) { QTextStream stream(stdout); stream << QObject::tr("usage: ") << QCoreApplication::arguments().at(0) << " " << QObject::tr("[parameters]") << " " << QObject::tr("filename") << "\n"; stream << QObject::tr("Parameters are:") << "\n"; stream << options.getUsage(); stream.flush(); return -1; } app.addLibraryPath(QApplication::applicationDirPath() + "/actions"); app.addLibraryPath(QApplication::applicationDirPath() + "/plugins"); if(!options.count("nocodeqt")) app.addLibraryPath(QApplication::applicationDirPath() + "/code"); #ifdef Q_OS_LINUX { #ifdef ACT_PROFILE Tools::HighResolutionTimer timer("Load key codes"); #endif ActionTools::KeySymHelper::loadKeyCodes(); } #endif // Proxy settings int proxyMode = ActionTools::Settings::PROXY_SYSTEM; if(options.value("proxy-mode").toString() == "none") proxyMode = ActionTools::Settings::PROXY_NONE; else if(options.value("proxy-mode").toString() == "custom") proxyMode = ActionTools::Settings::PROXY_CUSTOM; else if(options.value("proxy-mode").toString() == "system") proxyMode = ActionTools::Settings::PROXY_SYSTEM; else if(!options.value("proxy-mode").toString().isEmpty()) { QTextStream stream(stdout); stream << QObject::tr("Unknown proxy mode, values are \"none\", \"system\" (default) or \"custom\"") << "\n"; stream.flush(); return -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(options.value("proxy-type").toString() == "http") type = ActionTools::Settings::PROXY_TYPE_HTTP; else if(options.value("proxy-type").toString() == "socks") type = ActionTools::Settings::PROXY_TYPE_SOCKS5; else if(!options.value("proxy-type").toString().isEmpty()) { QTextStream stream(stdout); stream << QObject::tr("Unknown proxy type, values are \"http\" or \"socks\" (default)") << "\n"; stream.flush(); return -1; } QNetworkProxy proxy; if(type == ActionTools::Settings::PROXY_TYPE_HTTP) proxy.setType(QNetworkProxy::HttpProxy); else proxy.setType(QNetworkProxy::Socks5Proxy); proxy.setHostName(options.value("proxy-host").toString()); proxy.setPort(options.value("proxy-port").toInt()); proxy.setUser(options.value("proxy-user").toString()); proxy.setPassword(options.value("proxy-password").toString()); } break; } QNetworkProxy::setApplicationProxy(proxy); QUrl protocolUrl = QUrl::fromEncoded(arguments.at(1).toUtf8()); if(protocolUrl.isValid() && protocolUrl.scheme() != "actiona") protocolUrl = QUrl(); MainClass::ExecutionMode executionMode = MainClass::Unknown; MainClass mainClass; if(protocolUrl.isValid()) { QString mode; using QStringPair = QPair; #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) for(const QStringPair &queryItem: QUrlQuery(protocolUrl.query()).queryItems()) #else for(const QStringPair &queryItem: protocolUrl.queryItems()) #endif { if(queryItem.first == "mode") { mode = queryItem.second; break; } } if(mode == "code") executionMode = MainClass::Code; else if(mode == "script") executionMode = MainClass::Script; else { if(protocolUrl.path().endsWith(".ascr")) executionMode = MainClass::Script; else if(protocolUrl.path().endsWith(".acod")) executionMode = MainClass::Code; else { QTextStream stream(stdout); stream << QObject::tr("Unknown execution mode, please specify mode=script or mode=code") << "\n"; stream.flush(); return -1; } } if(!mainClass.start(executionMode, protocolUrl)) return -1; } else { QString filename = options.positional().at(0); if(options.count("code")) executionMode = MainClass::Code; else if(options.count("script")) executionMode = MainClass::Script; else { if(filename.endsWith(".ascr")) executionMode = MainClass::Script; else if(filename.endsWith(".acod")) executionMode = MainClass::Code; else { QTextStream stream(stdout); stream << QObject::tr("Unknown execution mode, please specify -s (script) or -c (code)") << "\n"; stream.flush(); return -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.9.1/actexecuter/mainclass.cpp000066400000000000000000000041751261645124000201440ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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(0), mExecuter(0), 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("http"); mNetworkReply = mNetworkAccessManager->get(QNetworkRequest(mUrl)); connect(mNetworkReply, SIGNAL(finished()), this, SLOT(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 = 0; } actiona-3.9.1/actexecuter/mainclass.h000066400000000000000000000025731261645124000176110ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef MAINCLASS_H #define MAINCLASS_H #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; QNetworkAccessManager *mNetworkAccessManager; QNetworkReply *mNetworkReply; ExecutionMode mExecutionMode; QUrl mUrl; }; #endif // MAINCLASS_H actiona-3.9.1/actexecuter/scriptexecuter.cpp000066400000000000000000000054571261645124000212470ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 ScriptExecuter::ScriptExecuter(QObject *parent) : Executer(parent), mScript(new ActionTools::Script(actionFactory(), this)), mExecuter(new LibExecuter::Executer(this)) { connect(mExecuter, SIGNAL(executionStopped()), this, SLOT(executionStopped())); connect(mExecuter, SIGNAL(scriptError(int,QString,QString)), this, SLOT(scriptError(int,QString,QString))); } 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, 0); if(!mExecuter->startExecution(false)) { 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.9.1/actexecuter/scriptexecuter.h000066400000000000000000000023651261645124000207070ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef SCRIPTEXECUTER_H #define SCRIPTEXECUTER_H #include "executer.h" namespace ActionTools { class Script; } namespace LibExecuter { class Executer; } class ScriptExecuter : public Executer { Q_OBJECT public: explicit ScriptExecuter(QObject *parent = 0); bool start(QIODevice *device, const QString &filename); public slots: void executionStopped(); void scriptError(int actionIndex, const QString ¶meter, const QString &error); private: ActionTools::Script *mScript; LibExecuter::Executer *mExecuter; }; #endif // SCRIPTEXECUTER_H actiona-3.9.1/actiona.desktop000066400000000000000000000006371261645124000161620ustar00rootroot00000000000000[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.9.1/actiona.pro000066400000000000000000000035771261645124000153170ustar00rootroot00000000000000TEMPLATE = subdirs CONFIG = ordered unix:!mac { !system(pkg-config --exists 'x11') { error(Please install pkg-config) #Here whe assume that x11 is always present, so this is to check if pkg-config is installed } !system(pkg-config --exists 'libnotify') { error(Please install libnotify-dev) } !system(pkg-config --exists 'xtst') { error(Please install libxtst-dev) } !system(pkg-config --exists 'opencv') { error(Please install libopencv-dev) } } win32-g++:error(Mingw is currently not supported, please use the Microsoft compiler suite) 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 \ actexecuter \ gui \ actions/actionpackinternal \ actions/actionpackwindows \ actions/actionpackdevice \ actions/actionpacksystem \ actions/actionpackdata actiona-3.9.1/actions/000077500000000000000000000000001261645124000146035ustar00rootroot00000000000000actiona-3.9.1/actions/actionpackdata/000077500000000000000000000000001261645124000175515ustar00rootroot00000000000000actiona-3.9.1/actions/actionpackdata/actionpackdata.h000066400000000000000000000102001261645124000226610ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef ACTIONPACKDATA_H #define ACTIONPACKDATA_H #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) #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) Q_PLUGIN_METADATA(IID "tools.actiona.ActionPack" FILE "data.json") #endif public: ActionPackData() {} void createDefinitions() { 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 { return "data"; } QString name() const { return tr("Data related actions"); } Tools::Version version() const { return Tools::Version(0, 0, 1); } void codeInit(QScriptEngine *scriptEngine) const { addCodeClass("File", scriptEngine); Code::File::registerClass(scriptEngine); addCodeClass("Clipboard", scriptEngine); addCodeClass("Registry", scriptEngine); addCodeClass("IniFile", scriptEngine); addCodeClass("Udp", scriptEngine); addCodeClass("Tcp", scriptEngine); addCodeClass("Sql", scriptEngine); Code::Sql::registerClass(scriptEngine); addCodeClass("TcpServer", scriptEngine); addCodeClass("Web", scriptEngine); addCodeClass("MailAttachment", scriptEngine); addCodeClass("MailMessage", scriptEngine); addCodeClass("Mail", scriptEngine); } private: Q_DISABLE_COPY(ActionPackData) }; #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) Q_EXPORT_PLUGIN2(ActionPackData, ActionPackData) #endif #endif // ACTIONPACKDATA_H actiona-3.9.1/actions/actionpackdata/actionpackdata.pro000066400000000000000000000012741261645124000232450ustar00rootroot00000000000000include(../common_actions.pri) include(actions/actions.pri) include(code/code.pri) TARGET = ActionPackData QT += script network sql equals(QT_MAJOR_VERSION, 5) { QT += widgets OTHER_FILES += data.json } HEADERS += actionpackdata.h win32:LIBS += -ladvapi32 \ -lshell32 win32:INCLUDEPATH += $${BOOST_INCLUDE} TRANSLATIONS = ../../locale/actionpackdata_fr_FR.ts \ ../../locale/actionpackdata_de_DE.ts RESOURCES += \ actionpackdata.qrc unix { locales.path = $${PREFIX}/share/actiona/locale locales.files = ../../locale/actionpackdata_fr_FR.qm \ ../../locale/actionpackdata_de_DE.qm locales.CONFIG = no_check_exist INSTALLS += locales } actiona-3.9.1/actions/actionpackdata/actionpackdata.qrc000066400000000000000000000012141261645124000232240ustar00rootroot00000000000000 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.9.1/actions/actionpackdata/actions/000077500000000000000000000000001261645124000212115ustar00rootroot00000000000000actiona-3.9.1/actions/actionpackdata/actions/actions.pri000066400000000000000000000024631261645124000233720ustar00rootroot00000000000000HEADERS += 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.9.1/actions/actionpackdata/actions/copyfiledefinition.h000066400000000000000000000053521261645124000252520ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef COPYFILEDEFINITION_H #define COPYFILEDEFINITION_H #include "actiondefinition.h" #include "copyfileinstance.h" #include "fileparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class CopyFileDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit CopyFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::FileParameterDefinition *source = new ActionTools::FileParameterDefinition(ActionTools::Name("source", tr("Source file")), this); source->setTooltip(tr("The file to copy")); source->setMode(ActionTools::FileEdit::FileOpen); source->setCaption(tr("Choose the file")); source->setFilter(tr("All files (*.*)")); addElement(source); ActionTools::FileParameterDefinition *destination = new ActionTools::FileParameterDefinition(ActionTools::Name("destination", tr("Destination")), this); destination->setTooltip(tr("The destination file")); destination->setMode(ActionTools::FileEdit::FileSave); destination->setCaption(tr("Choose the destination file")); destination->setFilter(tr("All files (*.*)")); addElement(destination); addException(CopyFileInstance::UnableToReadFileException, tr("Unable to read source file")); addException(CopyFileInstance::UnableToWriteFileException, tr("Unable to write destination file")); } QString name() const { return QObject::tr("Copy file"); } QString id() const { return "ActionCopyFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Copy a file"); } ActionTools::ActionInstance *newActionInstance() const { return new CopyFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/copyfile.png"); } private: Q_DISABLE_COPY(CopyFileDefinition) }; } #endif // COPYFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/copyfileinstance.h000066400000000000000000000043511261645124000247240ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef COPYFILEINSTANCE_H #define COPYFILEINSTANCE_H #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 = 0) : ActionTools::DataCopyActionInstance(definition, parent) { } void startExecution() { bool ok = true; QString sourceFile = evaluateString(ok, "source"); QString destinationFile = evaluateString(ok, "destination"); if(!ok) return; mSourceFile.setFileName(sourceFile); mDestinationFile.setFileName(destinationFile); if(!mSourceFile.open(QIODevice::ReadOnly)) { setCurrentParameter("source"); emit executionException(UnableToReadFileException, tr("Unable to read the source file \"%1\"").arg(sourceFile)); return; } if(!mDestinationFile.open(QIODevice::WriteOnly)) { mSourceFile.close(); setCurrentParameter("destination"); emit executionException(UnableToWriteFileException, tr("Unable to write to \"%1\"").arg(destinationFile)); return; } DataCopyActionInstance::startCopy(&mSourceFile, &mDestinationFile); emit showProgressDialog("Copying file", 100); emit updateProgressDialog("Copying in progress"); } private: QFile mSourceFile; QFile mDestinationFile; Q_DISABLE_COPY(CopyFileInstance) }; } #endif // COPYFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/readbinaryfiledefinition.h000066400000000000000000000050771261645124000264240ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READBINARYFILEDEFINITION_H #define READBINARYFILEDEFINITION_H #include "actiondefinition.h" #include "readbinaryfileinstance.h" #include "fileparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadBinaryFileDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadBinaryFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); file->setTooltip(tr("The file to read from")); file->setMode(ActionTools::FileEdit::FileOpen); file->setCaption(tr("Choose the file")); file->setFilter(tr("All files (*.*)")); addElement(file); ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); variable->setTooltip(tr("The variable where to store the data")); addElement(variable); addException(ReadBinaryFileInstance::UnableToReadFileException, tr("Unable to read file")); } QString name() const { return QObject::tr("Read binary file"); } QString id() const { return "ActionReadBinaryFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Read a binary file"); } ActionTools::ActionInstance *newActionInstance() const { return new ReadBinaryFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/readbinary.png"); } private: Q_DISABLE_COPY(ReadBinaryFileDefinition) }; } #endif // READBINARYFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/readbinaryfileinstance.h000066400000000000000000000042351261645124000260730ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READBINARYFILEINSTANCE_H #define READBINARYFILEINSTANCE_H #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 = 0) : ActionTools::DataCopyActionInstance(definition, parent) { } void startExecution() { bool ok = true; QString filename = evaluateString(ok, "file"); mVariable = evaluateVariable(ok, "variable"); if(!ok) return; mFile.setFileName(filename); if(!DataCopyActionInstance::startCopy(&mFile, &mResult)) { setCurrentParameter("file"); emit executionException(UnableToReadFileException, tr("Unable to read the file \"%1\"").arg(filename)); return; } emit showProgressDialog("Reading file", 100); emit updateProgressDialog("Reading in progress"); } private slots: void done() { setVariable(mVariable, Code::RawData::constructor(mResult.buffer(), scriptEngine())); DataCopyActionInstance::done(); } private: void clean() { DataCopyActionInstance::clean(); mResult.buffer().clear(); } QFile mFile; QBuffer mResult; QString mVariable; Q_DISABLE_COPY(ReadBinaryFileInstance) }; } #endif // READBINARYFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/readclipboarddefinition.h000066400000000000000000000042231261645124000262270ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READCLIPBOARDDEFINITION_H #define READCLIPBOARDDEFINITION_H #include "actiondefinition.h" #include "readclipboardinstance.h" #include "textparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ReadClipboardDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadClipboardDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::VariableParameterDefinition *output = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); output->setTooltip(tr("The variable where to save the current clipboard value")); addElement(output); } QString name() const { return QObject::tr("Read clipboard"); } QString id() const { return "ActionReadClipboard"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Read the clipboard contents"); } ActionTools::ActionInstance *newActionInstance() const { return new ReadClipboardInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/readclipboard.png"); } private: Q_DISABLE_COPY(ReadClipboardDefinition) }; } #endif // READCLIPBOARDDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/readclipboardinstance.h000066400000000000000000000027311261645124000257050ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READCLIPBOARDINSTANCE_H #define READCLIPBOARDINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} void startExecution() { bool ok = true; QString variable = evaluateVariable(ok, "variable"); if(!ok) return; QClipboard *clipboard = QApplication::clipboard(); setVariable(variable, clipboard->text()); emit executionEnded(); } private: Q_DISABLE_COPY(ReadClipboardInstance) }; } #endif // READCLIPBOARDINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/readenvironmentdefinition.h000066400000000000000000000070321261645124000266350ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READENVIRONMENTDEFINITION_H #define READENVIRONMENTDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadEnvironmentVariableDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ReadEnvironmentVariableInstance::modes", ReadEnvironmentVariableInstance::modes); ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); variable->setTooltip(tr("The variable used to store the selected information from your system environment")); addElement(variable); ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this); mode->setTooltip(tr("The environment read mode")); mode->setItems(ReadEnvironmentVariableInstance::modes); mode->setDefaultValue(ReadEnvironmentVariableInstance::modes.second.at(ReadEnvironmentVariableInstance::oneVariableMode)); addElement(mode); ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this); selectionMode->setMasterList(mode); selectionMode->setMasterValues(QStringList() << ReadEnvironmentVariableInstance::modes.first.at(ReadEnvironmentVariableInstance::oneVariableMode)); ActionTools::EnvironmentVariableParameterDefinition *environmentVariableName = new ActionTools::EnvironmentVariableParameterDefinition(ActionTools::Name("environmentVariableName", tr("Environment Variable")), this); environmentVariableName->setTooltip(tr("The specific environment variable to read")); selectionMode->addMember(environmentVariableName); addElement(selectionMode); } QString name() const { return QObject::tr("Read environment variable"); } QString id() const { return "ActionReadEnvironmentVariable"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Read a single or multiple environment variables"); } ActionTools::ActionInstance *newActionInstance() const { return new ReadEnvironmentVariableInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/readenvironment.png"); } private: Q_DISABLE_COPY(ReadEnvironmentVariableDefinition) }; } #endif // READENVIRONMENTDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/readenvironmentinstance.cpp000066400000000000000000000046321261645124000266470ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair ReadEnvironmentVariableInstance::modes = qMakePair( QStringList() << "allVariables" << "oneVariable", QStringList() << QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read all") << QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read one")); void ReadEnvironmentVariableInstance::startExecution() { bool ok = true; QString variable = evaluateVariable(ok, "variable"); Mode mode = evaluateListElement(ok, modes, "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("="); environmentHashVariableValue[KeyValue.at(0)] = KeyValue.at(1); } if(mode == oneVariableMode) { QString environmentVariable = evaluateString(ok, "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); emit executionEnded(); } } actiona-3.9.1/actions/actionpackdata/actions/readenvironmentinstance.h000066400000000000000000000025471261645124000263170ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READENVIRONMENTINSTANCE_H #define READENVIRONMENTINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair modes; void startExecution(); private: Q_DISABLE_COPY(ReadEnvironmentVariableInstance) }; } #endif // READENVIRONMENTINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/readinifiledefinition.h000066400000000000000000000100121261645124000257000ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READINIFILEDEFINITION_H #define READINIFILEDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadIniFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ReadIniFileInstance::modes", ReadIniFileInstance::modes); ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); 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 (*.*)")); addElement(file); ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); variable->setTooltip(tr("The variable where to store the data")); addElement(variable); ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this); mode->setTooltip(tr("The INI file read mode")); mode->setItems(ReadIniFileInstance::modes); mode->setDefaultValue(ReadIniFileInstance::modes.second.at(ReadIniFileInstance::SingleParameter)); addElement(mode); ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this); selectionMode->setMasterList(mode); selectionMode->setMasterValues(QStringList() << ReadIniFileInstance::modes.first.at(ReadIniFileInstance::SingleParameter)); ActionTools::TextParameterDefinition *section = new ActionTools::TextParameterDefinition(ActionTools::Name("section", tr("Section")), this); section->setTooltip(tr("The parameter section")); selectionMode->addMember(section); ActionTools::TextParameterDefinition *parameter = new ActionTools::TextParameterDefinition(ActionTools::Name("parameter", tr("Parameter")), this); parameter->setTooltip(tr("The parameter name")); selectionMode->addMember(parameter); addElement(selectionMode); addException(ReadIniFileInstance::UnableToReadFileException, tr("Unable to read file")); addException(ReadIniFileInstance::UnableToFindSectionException, tr("Unable to find section")); } QString name() const { return QObject::tr("Read INI file"); } QString id() const { return "ActionReadIniFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Read one or all the entries in an INI file"); } ActionTools::ActionInstance *newActionInstance() const { return new ReadIniFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/readini.png"); } private: Q_DISABLE_COPY(ReadIniFileDefinition) }; } #endif // READINIFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/readinifileinstance.cpp000066400000000000000000000066521261645124000257260ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair ReadIniFileInstance::modes = qMakePair( QStringList() << "singleParameter" << "wholeFile", QStringList() << QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read a single parameter") << QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read the entire file")); void ReadIniFileInstance::startExecution() { bool ok = true; QString filename = evaluateString(ok, "file"); QString variable = evaluateVariable(ok, "variable"); Mode mode = evaluateListElement(ok, modes, "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 &e) { setCurrentParameter("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, "section"); QString parameter = evaluateString(ok, "parameter"); if(!ok) return; auto sectionNode = tree.get_child_optional(section.toStdString()); if(!sectionNode) { setCurrentParameter("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 &e) { setCurrentParameter("parameter"); emit executionException(UnableToFindSectionException, tr("Unable to find the parameter named \"%1\"").arg(parameter)); return; } } emit executionEnded(); } } actiona-3.9.1/actions/actionpackdata/actions/readinifileinstance.h000066400000000000000000000026531261645124000253700ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READINIFILEINSTANCE_H #define READINIFILEINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair modes; void startExecution(); private: Q_DISABLE_COPY(ReadIniFileInstance) }; } #endif // READINIFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/readregistrydefinition.h000066400000000000000000000063361261645124000261470ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READREGISTRYDEFINITION_H #define READREGISTRYDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadRegistryDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::ListParameterDefinition *key = new ActionTools::ListParameterDefinition(ActionTools::Name("key", tr("Key")), this); key->setTooltip(tr("The registry key to read from")); key->setItems(ReadRegistryInstance::keys); key->setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser)); addElement(key); ActionTools::TextParameterDefinition *subKey = new ActionTools::TextParameterDefinition(ActionTools::Name("subKey", tr("Subkey")), this); subKey->setTooltip(tr("The registry subkey to read from")); addElement(subKey); ActionTools::TextParameterDefinition *value = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this); value->setTooltip(tr("The value to read")); addElement(value); ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); variable->setTooltip(tr("The variable where to save the value read from the registry")); addElement(variable); addException(ReadRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey")); addException(ReadRegistryInstance::CannotFindValueException, tr("Cannot find value")); addException(ReadRegistryInstance::InvalidValueType, tr("Invalid value type")); } QString name() const { return QObject::tr("Read registry"); } QString id() const { return "ActionReadRegistry"; } ActionTools::Flag flags() const { return ActionTools::WorksOnWindows | ActionTools::Official; } QString description() const { return QObject::tr("Read an entry from the registry"); } ActionTools::ActionInstance *newActionInstance() const { return new ReadRegistryInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/readregistry.png"); } private: Q_DISABLE_COPY(ReadRegistryDefinition) }; } #endif // READREGISTRYDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/readregistryinstance.cpp000066400000000000000000000044561261645124000261570ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair ReadRegistryInstance::keys = qMakePair( QStringList() << "classesRoot" << "currentConfig" << "currentUser" << "users" << "localMachine", QStringList() << "Classes root" << "Current config" << "Current user" << "Users" << "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, "key"); QString subKey = evaluateString(ok, "subKey"); QString value = evaluateString(ok, "value"); QString variable = evaluateVariable(ok, "variable"); if(!ok) return; QVariant resultValue; switch(ActionTools::Registry::read(resultValue, key, subKey, value)) { case ActionTools::Registry::ReadCannotFindSubKey: setCurrentParameter("subKey"); emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey)); return; case ActionTools::Registry::ReadCannotFindValue: setCurrentParameter("value"); emit executionException(CannotFindValueException, tr("Cannot find value \"%1\"").arg(value)); return; case ActionTools::Registry::ReadInvalidValueType: setCurrentParameter("value"); emit executionException(CannotFindValueException, tr("Invalid value type")); return; default: setVariable(variable, scriptEngine()->newVariant(resultValue)); break; } #endif emit executionEnded(); } } actiona-3.9.1/actions/actionpackdata/actions/readregistryinstance.h000066400000000000000000000026231261645124000256160ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READREGISTRYINSTANCE_H #define READREGISTRYINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair keys; void startExecution(); private: Q_DISABLE_COPY(ReadRegistryInstance) }; } #endif // READREGISTRYINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/readtextfiledefinition.h000066400000000000000000000077151261645124000261250ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READTEXTFILEDEFINITION_H #define READTEXTFILEDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ReadTextFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ReadTextFileInstance::modes", ReadTextFileInstance::modes); ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); file->setTooltip(tr("The file you want to read")); addElement(file); ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); variable->setTooltip(tr("The variable where to save the text read from the file")); addElement(variable); ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this); mode->setTooltip(tr("The file read mode")); mode->setItems(ReadTextFileInstance::modes); mode->setDefaultValue(ReadTextFileInstance::modes.second.at(ReadTextFileInstance::Full)); addElement(mode, 1); ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this); selectionMode->setMasterList(mode); selectionMode->setMasterValues(QStringList() << ReadTextFileInstance::modes.first.at(ReadTextFileInstance::Selection)); ActionTools::NumberParameterDefinition *firstline = new ActionTools::NumberParameterDefinition(ActionTools::Name("firstline", tr("First line")), this); firstline->setTooltip(tr("The line where to start reading the file")); firstline->setMinimum(1); firstline->setDefaultValue(1); selectionMode->addMember(firstline, 1); ActionTools::NumberParameterDefinition *lastline = new ActionTools::NumberParameterDefinition(ActionTools::Name("lastline", tr("Last line")), this); lastline->setTooltip(tr("The line where to stop reading the file")); lastline->setMinimum(1); lastline->setDefaultValue(1); selectionMode->addMember(lastline, 1); addElement(selectionMode, 1); addException(ReadTextFileInstance::CannotOpenFileException, tr("Cannot read file")); } QString name() const { return QObject::tr("Read text file"); } QString id() const { return "ActionReadTextFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Read a plain text file"); } ActionTools::ActionInstance *newActionInstance() const { return new ReadTextFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/readtext.png"); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(ReadTextFileDefinition) }; } #endif // READTEXTFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/readtextfileinstance.cpp000066400000000000000000000055471261645124000261350ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair ReadTextFileInstance::modes = qMakePair( QStringList() << "full" << "selection", QStringList() << QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read the entire file") << QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read only a selection")); void ReadTextFileInstance::startExecution() { bool ok = true; QString filepath = evaluateString(ok, "file"); QString variable = evaluateVariable(ok, "variable"); Mode mode = evaluateListElement(ok, modes, "mode"); int firstline = evaluateInteger(ok, "firstline"); int lastline = evaluateInteger(ok, "lastline"); if(!ok) return; if(mode == Selection) { if(firstline < 1) { setCurrentParameter("firstline"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid first line value : %1").arg(firstline)); return; } if(lastline < 1) { setCurrentParameter("lastline"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid last line value : %1").arg(lastline)); return; } if(lastline < firstline) { setCurrentParameter("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("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 += '\n'; result += readLine; } if(line > lastline) break; } } setVariable(variable, result); file.close(); emit executionEnded(); } } actiona-3.9.1/actions/actionpackdata/actions/readtextfileinstance.h000066400000000000000000000026051261645124000255720ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef READTEXTFILEINSTANCE_H #define READTEXTFILEINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair modes; void startExecution(); private: Q_DISABLE_COPY(ReadTextFileInstance) }; } #endif // READTEXTFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/sendmaildefinition.h000066400000000000000000000167061261645124000252410ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef SENDMAILDEFINITION_H #define SENDMAILDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit SendMailDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("SendMailInstance::attachmentContentTypes", SendMailInstance::attachmentContentTypes); ActionTools::TextParameterDefinition *serverName = new ActionTools::TextParameterDefinition(ActionTools::Name("serverName", tr("Server name")), this); serverName->setTooltip(tr("The name or IP of the SMTP server to use\nExample: mail.example.com")); addElement(serverName); ActionTools::BooleanParameterDefinition *secureConnection = new ActionTools::BooleanParameterDefinition(ActionTools::Name("secureConnection", tr("Secure connection")), this); secureConnection->setTooltip(tr("Secure (encrypted) connection to the server")); secureConnection->setDefaultValue(true); addElement(secureConnection); ActionTools::TextParameterDefinition *userName = new ActionTools::TextParameterDefinition(ActionTools::Name("userName", tr("User name")), this); userName->setTooltip(tr("The user (or login) name to use\nMany SMTP servers use the e-mail address as user name")); addElement(userName); ActionTools::TextParameterDefinition *password = new ActionTools::TextParameterDefinition(ActionTools::Name("password", tr("Password")), this); password->setTooltip(tr("The password to use")); addElement(password); ActionTools::TextParameterDefinition *sender = new ActionTools::TextParameterDefinition(ActionTools::Name("sender", tr("Sender")), this); sender->setTooltip(tr("The sender's e-mail address")); addElement(sender); ActionTools::TextParameterDefinition *receivers = new ActionTools::TextParameterDefinition(ActionTools::Name("receivers", tr("Receivers")), this); receivers->setTooltip(tr("The receiver's e-mail address\nCan contain multiple receivers separated with a comma")); addElement(receivers); ActionTools::TextParameterDefinition *subject = new ActionTools::TextParameterDefinition(ActionTools::Name("subject", tr("Subject")), this); subject->setTooltip(tr("The e-mail's subject")); addElement(subject); ActionTools::TextParameterDefinition *body = new ActionTools::TextParameterDefinition(ActionTools::Name("body", tr("Body")), this); body->setTooltip(tr("The e-mail's body")); addElement(body); ActionTools::TextParameterDefinition *attachmentName = new ActionTools::TextParameterDefinition(ActionTools::Name("attachmentName", tr("Attachment name")), this); attachmentName->setTooltip(tr("The attachment name, an empty name means that there is no attachment")); addElement(attachmentName, 1); ActionTools::TextParameterDefinition *attachmentData = new ActionTools::TextParameterDefinition(ActionTools::Name("attachmentData", tr("Attachment data")), this); attachmentData->setTooltip(tr("The data to attach to the e-mail")); addElement(attachmentData, 1); ActionTools::ListParameterDefinition *attachmentContentType = new ActionTools::ListParameterDefinition(ActionTools::Name("attachmentContentType", tr("Attachment content type")), this); 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)); addElement(attachmentContentType, 1); ActionTools::TextParameterDefinition *carbonCopy = new ActionTools::TextParameterDefinition(ActionTools::Name("carbonCopy", tr("Carbon copy (Cc)")), this); carbonCopy->setTooltip(tr("The carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma")); addElement(carbonCopy, 2); ActionTools::TextParameterDefinition *blindCarbonCopy = new ActionTools::TextParameterDefinition(ActionTools::Name("blindCarbonCopy", tr("Blind carbon copy (Bcc)")), this); blindCarbonCopy->setTooltip(tr("The blind carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma")); addElement(blindCarbonCopy, 2); ActionTools::NumberParameterDefinition *serverPort = new ActionTools::NumberParameterDefinition(ActionTools::Name("serverPort", tr("Server port")), this); serverPort->setTooltip(tr("The server port")); serverPort->setMinimum(0); serverPort->setMaximum(65535); serverPort->setDefaultValue(0); serverPort->setSpecialValueText(tr("Default port")); addElement(serverPort, 2); ActionTools::TextParameterDefinition *extraHeaders = new ActionTools::TextParameterDefinition(ActionTools::Name("extraHeaders", tr("Extra headers")), this); extraHeaders->setTooltip(tr("Extra headers to add to the e-mail\nShould contain one header per line")); addElement(extraHeaders, 2); addException(SendMailInstance::ConnectionErrorException, tr("Connection error")); addException(SendMailInstance::ErrorWhileSendingEMailException, tr("Error while sending e-mail")); } QString name() const { return QObject::tr("Send e-mail"); } QString id() const { return "ActionSendMail"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Sends an e-mail"); } ActionTools::ActionInstance *newActionInstance() const { return new SendMailInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/sendmail.png"); } QStringList tabs() const { return QStringList() << ActionDefinition::StandardTabs.at(0) << tr("Attachment") << ActionDefinition::StandardTabs.at(1); } private: Q_DISABLE_COPY(SendMailDefinition) }; } #endif // SENDMAILDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/sendmailinstance.cpp000066400000000000000000000334741261645124000252510ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair SendMailInstance::attachmentContentTypes = qMakePair( QStringList() << "autoDetect" << "application/octet-stream" << "text/plain" << "image/jpeg" << "image/png", QStringList() << QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Auto detect") << QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Binary") << QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Text") << QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Jpg image") << QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Png image")); SendMailInstance::SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mSmtp(nullptr), mProgressDialog(new QProgressDialog) { connect(mProgressDialog, SIGNAL(canceled()), this, SLOT(canceled())); } SendMailInstance::~SendMailInstance() { delete mProgressDialog; } void SendMailInstance::startExecution() { bool ok = true; QString serverName = evaluateString(ok, "serverName"); bool secureConnection = evaluateBoolean(ok, "secureConnection"); QString userName = evaluateString(ok, "userName"); QString password = evaluateString(ok, "password"); QString sender = evaluateString(ok, "sender"); QString receivers = evaluateString(ok, "receivers"); QString subject = evaluateString(ok, "subject"); QString body = evaluateString(ok, "body"); QString attachmentName = evaluateString(ok, "attachmentName"); QScriptValue attachmentData = evaluateValue(ok, "attachmentData"); QString attachmentContentType = evaluateEditableListElement(ok, attachmentContentTypes, "attachmentContentType"); QString carbonCopy = evaluateString(ok, "carbonCopy"); QString blindCarbonCopy = evaluateString(ok, "blindCarbonCopy"); int serverPort = evaluateInteger(ok, "serverPort"); QString extraHeaders = evaluateString(ok, "extraHeaders"); if(serverName.isEmpty() || sender.isEmpty() || receivers.isEmpty()) { emit executionEnded(); return; } if(attachmentContentType == "autoDetect" && !attachmentName.isEmpty() && attachmentData.isValid()) { bool foundAttachmentContentType = true; if(QObject *scriptObject = attachmentData.toQObject()) { if(qobject_cast(scriptObject)) attachmentContentType = "application/octet-stream"; else if(qobject_cast(scriptObject)) { QString lowerAttachmentName = attachmentName.toLower(); if(lowerAttachmentName.endsWith(".jpg") || lowerAttachmentName.endsWith(".jpeg")) attachmentContentType = "image/jpeg"; else attachmentContentType = "image/png"; } else foundAttachmentContentType = false; } else if(attachmentData.isString()) attachmentContentType = "text/plain"; else foundAttachmentContentType = false; if(!foundAttachmentContentType) { setCurrentParameter("attachmentContentType"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Failed to auto detect the attachment content type")); return; } } validateParameterRange(ok, serverPort, "serverPort", tr("server port"), 0, 65535); if(!ok) return; mSmtp = new QxtSmtp(this); connect(mSmtp, SIGNAL(connectionFailed(QByteArray)), this, SLOT(connectionFailed(QByteArray))); connect(mSmtp, SIGNAL(encryptionFailed(QByteArray)), this, SLOT(encryptionFailed(QByteArray))); connect(mSmtp, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(authenticationFailed(QByteArray))); connect(mSmtp, SIGNAL(authenticated()), this, SLOT(authenticated())); connect(mSmtp, SIGNAL(senderRejected(int,QString,QByteArray)), this, SLOT(senderRejected(int,QString,QByteArray))); connect(mSmtp, SIGNAL(recipientRejected(int,QString,QByteArray)), this, SLOT(recipientRejected(int,QString,QByteArray))); connect(mSmtp, SIGNAL(mailFailed(int,int,QByteArray)), this, SLOT(mailFailed(int,int,QByteArray))); connect(mSmtp, SIGNAL(mailSent(int)), this, SLOT(mailSent(int))); connect(mSmtp, SIGNAL(disconnected()), this, SLOT(disconnected())); mSmtp->setUsername(userName.toUtf8()); mSmtp->setPassword(password.toUtf8()); QxtMailMessage mailMessage; mailMessage.setSender(sender); mailMessage.setSubject(subject); mailMessage.setBody(body); mailMessage.setExtraHeader("Date", QDateTime::currentDateTime().toString(Qt::RFC2822Date)); for(QString receiver: receivers.split(QChar(','), QString::SkipEmptyParts)) mailMessage.addRecipient(receiver.trimmed()); for(QString carbonCopyReceiver: carbonCopy.split(QChar(','), QString::SkipEmptyParts)) mailMessage.addRecipient(carbonCopyReceiver.trimmed(), QxtMailMessage::Cc); for(QString blindCarbonCopyReceiver: blindCarbonCopy.split(QChar(','), QString::SkipEmptyParts)) mailMessage.addRecipient(blindCarbonCopyReceiver.trimmed(), QxtMailMessage::Bcc); for(QString extraHeader: extraHeaders.split(QChar('\n'), QString::SkipEmptyParts)) { QStringList extraHeaderParts = extraHeader.split(QChar(':'), QString::SkipEmptyParts); if(extraHeaderParts.size() != 2) { setCurrentParameter("extraHeaders"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("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("attachmentData"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid attachment data")); return; } QByteArray attachmentDataByteArray; if(QObject *scriptObject = attachmentData.toQObject()) { if(Code::RawData *codeRawData = qobject_cast(scriptObject)) attachmentDataByteArray = codeRawData->byteArray(); else if(Code::Image *codeImage = qobject_cast(scriptObject)) { QImage image = codeImage->image(); QString format; if(attachmentContentType == "image/png") format = "PNG"; else if(attachmentContentType == "image/jpeg") format = "JPG"; else { setCurrentParameter("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())) { setCurrentParameter("attachmentData"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid image data")); return; } attachmentDataByteArray = buffer.buffer(); } else attachmentDataByteArray = attachmentData.toString().toUtf8(); } else { if(attachmentContentType == "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(); emit executionEnded(); } void SendMailInstance::disconnected() { mSmtp->deleteLater(); } void SendMailInstance::canceled() { cleanup(); emit executionEnded(); } void SendMailInstance::cleanup() { mSmtp->disconnectFromHost(); mProgressDialog->close(); } } actiona-3.9.1/actions/actionpackdata/actions/sendmailinstance.h000066400000000000000000000045441261645124000247120ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef SENDMAILINSTANCE_H #define SENDMAILINSTANCE_H #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 = 0); ~SendMailInstance(); static ActionTools::StringListPair attachmentContentTypes; void startExecution(); void stopExecution(); 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; }; } #endif // SENDMAILINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/webdownloaddefinition.h000066400000000000000000000107521261645124000257450ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WEBDOWNLOADDEFINITION_H #define WEBDOWNLOADDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WebDownloadDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("WebDownloadInstance::destinations", WebDownloadInstance::destinations); ActionTools::TextParameterDefinition *url = new ActionTools::TextParameterDefinition(ActionTools::Name("url", tr("URL")), this); url->setTooltip(tr("The URL of the data to download")); addElement(url); ActionTools::ListParameterDefinition *destination = new ActionTools::ListParameterDefinition(ActionTools::Name("destination", tr("Destination")), this); destination->setTooltip(tr("The destination where to write the downloaded data")); destination->setItems(WebDownloadInstance::destinations); destination->setDefaultValue(WebDownloadInstance::destinations.second.at(WebDownloadInstance::Variable)); addElement(destination); ActionTools::GroupDefinition *variableMode = new ActionTools::GroupDefinition(this); variableMode->setMasterList(destination); variableMode->setMasterValues(QStringList() << WebDownloadInstance::destinations.first.at(WebDownloadInstance::Variable)); ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this); variable->setTooltip(tr("The variable where to write the downloaded data")); variableMode->addMember(variable); addElement(variableMode); ActionTools::GroupDefinition *fileMode = new ActionTools::GroupDefinition(this); fileMode->setMasterList(destination); fileMode->setMasterValues(QStringList() << WebDownloadInstance::destinations.first.at(WebDownloadInstance::File)); ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); 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 (*.*)")); fileMode->addMember(file); addElement(fileMode); ActionTools::BooleanParameterDefinition *showProgress = new ActionTools::BooleanParameterDefinition(ActionTools::Name("showProgress", tr("Show progress")), this); showProgress->setTooltip(tr("Should the download progress be shown")); showProgress->setDefaultValue(true); addElement(showProgress, 1); addException(WebDownloadInstance::CannotOpenFileException, tr("Cannot write to file")); addException(WebDownloadInstance::DownloadException, tr("Download error")); } QString name() const { return QObject::tr("Web download"); } QString id() const { return "ActionWebDownload"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Downloads data from the Web"); } ActionTools::ActionInstance *newActionInstance() const { return new WebDownloadInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/webdownload.png"); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(WebDownloadDefinition) }; } #endif // WEBDOWNLOADDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/webdownloadinstance.cpp000066400000000000000000000100161261645124000257450ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair WebDownloadInstance::destinations = qMakePair( QStringList() << "variable" << "file", QStringList() << QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "Variable") << QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "File")); WebDownloadInstance::WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mNetworkAccessManager(new QNetworkAccessManager(this)), mReply(0), mDestination(Variable), mProgressDialog(new QProgressDialog) { connect(mProgressDialog, SIGNAL(canceled()), this, SLOT(canceled())); } WebDownloadInstance::~WebDownloadInstance() { delete mProgressDialog; } void WebDownloadInstance::startExecution() { bool ok = true; QString urlString = evaluateString(ok, "url"); mDestination = evaluateListElement(ok, destinations, "destination"); mVariable = evaluateVariable(ok, "variable"); QString file = evaluateString(ok, "file"); if(!ok) return; QUrl url(urlString); if(url.scheme() == QString()) url = QUrl("http://" + urlString, QUrl::TolerantMode); if(!url.isValid()) { setCurrentParameter("url"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid URL")); return; } if(mDestination == File) { mFile.setFileName(file); if(!mFile.open(QIODevice::WriteOnly)) { setCurrentParameter("file"); emit executionException(CannotOpenFileException, tr("Cannot write to file")); return; } } mReply = mNetworkAccessManager->get(QNetworkRequest(url)); connect(mReply, SIGNAL(finished()), this, SLOT(finished())); connect(mReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); connect(mReply, SIGNAL(readyRead()), this, SLOT(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())); emit executionEnded(); break; case QNetworkReply::OperationCanceledError: if(mDestination == File) mFile.remove(); emit executionEnded(); break; default: { if(mDestination == File) mFile.remove(); setCurrentParameter("url"); emit executionException(DownloadException, tr("Download error: %1").arg(mReply->errorString())); } break; } mProgressDialog->close(); mReply->deleteLater(); mReply = 0; } 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.9.1/actions/actionpackdata/actions/webdownloadinstance.h000066400000000000000000000035041261645124000254160ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WEBDOWNLOADINSTANCE_H #define WEBDOWNLOADINSTANCE_H #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 = 0); ~WebDownloadInstance(); static ActionTools::StringListPair destinations; void startExecution(); void stopExecution(); 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; }; } #endif // WEBDOWNLOADINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/writebinaryfiledefinition.h000066400000000000000000000050601261645124000266330ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITEBINARYFILEDEFINITION_H #define WRITEBINARYFILEDEFINITION_H #include "actiondefinition.h" #include "writebinaryfileinstance.h" #include "fileparameterdefinition.h" #include "textparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteBinaryFileDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteBinaryFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); file->setTooltip(tr("The file to write to")); file->setMode(ActionTools::FileEdit::FileSave); file->setCaption(tr("Choose the file")); file->setFilter(tr("All files (*.*)")); addElement(file); ActionTools::TextParameterDefinition *data = new ActionTools::TextParameterDefinition(ActionTools::Name("data", tr("Data")), this); data->setTooltip(tr("The data to write to the file")); addElement(data); addException(WriteBinaryFileInstance::UnableToWriteFileException, tr("Unable to write to the file")); } QString name() const { return QObject::tr("Write binary file"); } QString id() const { return "ActionWriteBinaryFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Write to a binary file"); } ActionTools::ActionInstance *newActionInstance() const { return new WriteBinaryFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/writebinary.png"); } private: Q_DISABLE_COPY(WriteBinaryFileDefinition) }; } #endif // WRITEBINARYFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/writebinaryfileinstance.h000066400000000000000000000041271261645124000263120ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITEBINARYFILEINSTANCE_H #define WRITEBINARYFILEINSTANCE_H #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 = 0) : ActionTools::DataCopyActionInstance(definition, parent) { } void startExecution() { bool ok = true; QString filename = evaluateString(ok, "file"); QScriptValue data = evaluateValue(ok, "data"); if(!ok) return; mData = data.toVariant().toByteArray(); mFile.setFileName(filename); mDataBuffer.setBuffer(&mData); if(!DataCopyActionInstance::startCopy(&mDataBuffer, &mFile)) { setCurrentParameter("file"); emit executionException(UnableToWriteFileException, tr("Unable to write to the file \"%1\"").arg(filename)); return; } emit showProgressDialog("Writing file", 100); emit updateProgressDialog("Writing in progress"); } private: void clean() { DataCopyActionInstance::clean(); mDataBuffer.buffer().clear(); } QFile mFile; QByteArray mData; QBuffer mDataBuffer; private: Q_DISABLE_COPY(WriteBinaryFileInstance) }; } #endif // WRITEBINARYFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/writeclipboarddefinition.h000066400000000000000000000041551261645124000264520ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITECLIPBOARDDEFINITION_H #define WRITECLIPBOARDDEFINITION_H #include "actiondefinition.h" #include "writeclipboardinstance.h" #include "textparameterdefinition.h" #include "variableparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteClipboardDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteClipboardDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::TextParameterDefinition *input = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this); input->setTooltip(tr("The new clipboard value")); addElement(input); } QString name() const { return QObject::tr("Write clipboard"); } QString id() const { return "ActionWriteClipboard"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Set the clipboard contents"); } ActionTools::ActionInstance *newActionInstance() const { return new WriteClipboardInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/writeclipboard.png"); } private: Q_DISABLE_COPY(WriteClipboardDefinition) }; } #endif // WRITECLIPBOARDDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/writeclipboardinstance.h000066400000000000000000000026511261645124000261250ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITECLIPBOARDINSTANCE_H #define WRITECLIPBOARDINSTANCE_H #include "actioninstance.h" #include #include namespace Actions { class WriteClipboardInstance : public ActionTools::ActionInstance { Q_OBJECT public: WriteClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0) : ActionTools::ActionInstance(definition, parent) {} void startExecution() { bool ok = true; QString value = evaluateString(ok, "value"); if(!ok) return; QClipboard *clipboard = QApplication::clipboard(); clipboard->setText(value); emit executionEnded(); } private: Q_DISABLE_COPY(WriteClipboardInstance) }; } #endif // WRITECLIPBOARDINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/writeinifiledefinition.h000066400000000000000000000057551261645124000261410ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITEINIFILEDEFINITION_H #define WRITEINIFILEDEFINITION_H #include "actiondefinition.h" #include "writeinifileinstance.h" #include "textparameterdefinition.h" #include "fileparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WriteIniFileDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteIniFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); 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 (*.*)")); addElement(file); ActionTools::TextParameterDefinition *section = new ActionTools::TextParameterDefinition(ActionTools::Name("section", tr("Section")), this); section->setTooltip(tr("The section name of the parameter")); addElement(section); ActionTools::TextParameterDefinition *parameter = new ActionTools::TextParameterDefinition(ActionTools::Name("parameter", tr("Parameter")), this); parameter->setTooltip(tr("The parameter name")); addElement(parameter); ActionTools::TextParameterDefinition *value = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this); value->setTooltip(tr("The new value")); addElement(value); addException(WriteIniFileInstance::UnableToWriteFileException, tr("Unable to write file")); } QString name() const { return QObject::tr("Write INI file"); } QString id() const { return "ActionWriteIniFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Write an entry in an INI file"); } ActionTools::ActionInstance *newActionInstance() const { return new WriteIniFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/writeini.png"); } private: Q_DISABLE_COPY(WriteIniFileDefinition) }; } #endif // WRITEINIFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/writeinifileinstance.h000066400000000000000000000063051261645124000256050ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITEINIFILEINSTANCE_H #define WRITEINIFILEINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} void startExecution() { bool ok = true; QString filename = evaluateString(ok, "file"); QString section = evaluateString(ok, "section"); QString parameter = evaluateString(ok, "parameter"); QString value = evaluateString(ok, "value"); if(!ok) return; if(!write(filename, section, parameter, value)) return; emit 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("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("filename"); emit executionException(UnableToWriteFileException, tr("Unable to write to the file: %1").arg(e.what())); return false; } return true; } Q_DISABLE_COPY(WriteIniFileInstance) }; } #endif // WRITEINIFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/writeregistrydefinition.h000066400000000000000000000061171261645124000263630ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITEREGISTRYDEFINITION_H #define WRITEREGISTRYDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteRegistryDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::ListParameterDefinition *key = new ActionTools::ListParameterDefinition(ActionTools::Name("key", tr("Key")), this); key->setTooltip(tr("The registry key to write to")); key->setItems(ReadRegistryInstance::keys); key->setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser)); addElement(key); ActionTools::TextParameterDefinition *subKey = new ActionTools::TextParameterDefinition(ActionTools::Name("subKey", tr("Subkey")), this); subKey->setTooltip(tr("The registry subkey to write to")); addElement(subKey); ActionTools::TextParameterDefinition *value = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this); value->setTooltip(tr("The value to write to")); addElement(value); ActionTools::TextParameterDefinition *data = new ActionTools::TextParameterDefinition(ActionTools::Name("data", tr("Data")), this); data->setTooltip(tr("The data to write")); addElement(data); addException(WriteRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey")); addException(WriteRegistryInstance::CannotWriteValueException, tr("Cannot write value")); } QString name() const { return QObject::tr("Write registry"); } QString id() const { return "ActionWriteRegistry"; } ActionTools::Flag flags() const { return ActionTools::WorksOnWindows | ActionTools::Official; } QString description() const { return QObject::tr("Writes an entry to the registry"); } ActionTools::ActionInstance *newActionInstance() const { return new WriteRegistryInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/writeregistry.png"); } private: Q_DISABLE_COPY(WriteRegistryDefinition) }; } #endif // WRITEREGISTRYDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/writeregistryinstance.cpp000066400000000000000000000033451261645124000263720ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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, "key"); QString subKey = evaluateString(ok, "subKey"); QString value = evaluateString(ok, "value"); QScriptValue data = evaluateValue(ok, "data"); if(!ok) return; switch(ActionTools::Registry::write(data.toVariant(), key, subKey, value)) { case ActionTools::Registry::WriteCannotFindSubKey: setCurrentParameter("subKey"); emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey)); return; case ActionTools::Registry::WriteCannotWriteValue: setCurrentParameter("value"); emit executionException(CannotWriteValueException, tr("Cannot write value \"%1\"").arg(value)); return; default: break; } #endif emit executionEnded(); } } actiona-3.9.1/actions/actionpackdata/actions/writeregistryinstance.h000066400000000000000000000025311261645124000260330ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITEREGISTRYINSTANCE_H #define WRITEREGISTRYINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} void startExecution(); private: Q_DISABLE_COPY(WriteRegistryInstance) }; } #endif // WRITEREGISTRYINSTANCE_H actiona-3.9.1/actions/actionpackdata/actions/writetextfiledefinition.h000066400000000000000000000056641261645124000263450ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITETEXTFILEDEFINITION_H #define WRITETEXTFILEDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WriteTextFileDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("WriteTextFileInstance::modes", WriteTextFileInstance::modes); ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this); file->setTooltip(tr("The file you want to write")); addElement(file); ActionTools::TextParameterDefinition *text = new ActionTools::TextParameterDefinition(ActionTools::Name("text", tr("Text")), this); text->setTooltip(tr("The text to write to the file")); addElement(text); ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this); mode->setTooltip(tr("The file write mode")); mode->setItems(WriteTextFileInstance::modes); mode->setDefaultValue(WriteTextFileInstance::modes.second.at(WriteTextFileInstance::Truncate)); addElement(mode, 1); addException(WriteTextFileInstance::CannotWriteFileException, tr("Cannot write file")); } QString name() const { return QObject::tr("Write text file"); } QString id() const { return "ActionWriteTextFile"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Write a plain text file"); } ActionTools::ActionInstance *newActionInstance() const { return new WriteTextFileInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Data; } QPixmap icon() const { return QPixmap(":/icons/writetext.png"); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(WriteTextFileDefinition) }; } #endif // WRITETEXTFILEDEFINITION_H actiona-3.9.1/actions/actionpackdata/actions/writetextfileinstance.cpp000066400000000000000000000032561261645124000263470ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair WriteTextFileInstance::modes = qMakePair( QStringList() << "truncate" << "append", QStringList() << QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Overwrite any content") << QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Append to the end")); void WriteTextFileInstance::startExecution() { bool ok = true; QString filepath = evaluateString(ok, "file"); QString text = evaluateString(ok, "text"); Mode mode = evaluateListElement(ok, modes, "mode"); if(!ok) return; QFile file(filepath); if(!file.open(QIODevice::WriteOnly | QIODevice::Text | (mode == Truncate ? QIODevice::Truncate : QIODevice::Append))) { setCurrentParameter("file"); emit executionException(CannotWriteFileException, tr("Cannot open file")); return; } QTextStream textStream(&file); textStream << text; file.close(); emit executionEnded(); } } actiona-3.9.1/actions/actionpackdata/actions/writetextfileinstance.h000066400000000000000000000026151261645124000260120ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WRITETEXTFILEINSTANCE_H #define WRITETEXTFILEINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair modes; void startExecution(); private: Q_DISABLE_COPY(WriteTextFileInstance) }; } #endif // WRITETEXTFILEINSTANCE_H actiona-3.9.1/actions/actionpackdata/code/000077500000000000000000000000001261645124000204635ustar00rootroot00000000000000actiona-3.9.1/actions/actionpackdata/code/clipboard.cpp000066400000000000000000000061631261645124000231340ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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) { Clipboard *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(), mMode(QClipboard::Clipboard) { } 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(Code::Image *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, "UnsupportedSelectionModeError", tr("Selection mode is not supported by your operating system")); return; } break; case FindBuffer: if(!QApplication::clipboard()->supportsFindBuffer()) { throwError(context, engine, "UnsupportedSelectionModeError", tr("Find buffer mode is not supported by your operating system")); return; } break; default: break; } mMode = static_cast(mode); } } actiona-3.9.1/actions/actionpackdata/code/clipboard.h000066400000000000000000000036721261645124000226030ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef CLIPBOARD_H #define CLIPBOARD_H #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 { return "Clipboard"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // CLIPBOARD_H actiona-3.9.1/actions/actionpackdata/code/code.pri000066400000000000000000000010211261645124000221030ustar00rootroot00000000000000HEADERS += 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.9.1/actions/actionpackdata/code/file.cpp000066400000000000000000000447151261645124000221210ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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, "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, "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(©, "copy", scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&move, "move", scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&rename, "rename", scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&remove, "remove", scriptEngine); CodeTools::addClassGlobalFunctionToScriptEngine(&exists, "exists", scriptEngine); } QScriptValue File::open(const QString &filename, OpenMode mode) { mFile.setFileName(filename); if(!mFile.open(static_cast(mode))) throwError("CannotOpenFileError", tr("Unable to open file")); return thisObject(); } QScriptValue File::write(const QScriptValue &data) { QObject *object = data.toQObject(); if(RawData *rawData = qobject_cast(object)) { if(mFile.write(rawData->byteArray()) == -1) throwError("WriteFailedError", tr("Write failed")); } else { if(mFile.write(data.toVariant().toByteArray()) == -1) throwError("WriteFailedError", tr("Write failed")); } return thisObject(); } QScriptValue File::writeText(const QString &value, Encoding encoding) { if(mFile.write(toEncoding(value, encoding)) == -1) throwError("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, "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() == "noErrorDialog") noErrorDialog = it.value().toBool(); else if(it.name() == "noConfirmDialog") noConfirmDialog = it.value().toBool(); else if(it.name() == "noProgressDialog") noProgressDialog = it.value().toBool(); else if(it.name() == "allowUndo") allowUndo = it.value().toBool(); else if(it.name() == "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_LINUX Q_UNUSED(noErrorDialog) Q_UNUSED(noConfirmDialog) Q_UNUSED(noProgressDialog) Q_UNUSED(allowUndo) QDir destinationDir(destination); QString sourceCopy(source); QString destinationCopy(destination); sourceCopy.replace(" ", "\\ "); destinationCopy.replace(" ", "\\ "); if(!destinationDir.exists()) { if(createDestinationDirectory) { if(QProcess::execute("sh -c \"mkdir -p " + QFile::encodeName(destinationCopy) + "\"")) { throwError(context, engine, "DirectoryCreationError", tr("Unable to create destination directory")); return context->thisObject(); } } else { throwError(context, engine, "DirectoryDoesntExistError", tr("Destination directory doesn't exist")); return context->thisObject(); } } QString command = "sh -c \"cp -fr"; command += " "; command += QFile::encodeName(sourceCopy); command += " "; command += QFile::encodeName(destinationCopy); command += "\""; if(QProcess::execute(command)) { throwError(context, engine, "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, "CopyError", tr("Copy failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, "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_LINUX Q_UNUSED(noErrorDialog) Q_UNUSED(noConfirmDialog) Q_UNUSED(noProgressDialog) Q_UNUSED(allowUndo) QDir destinationDir(destination); QString sourceCopy(source); QString destinationCopy(destination); sourceCopy.replace(" ", "\\ "); destinationCopy.replace(" ", "\\ "); if(!destinationDir.exists()) { if(createDestinationDirectory) { if(QProcess::execute("sh -c \"mkdir -p " + QFile::encodeName(destinationCopy) + "\"")) { throwError(context, engine, "DirectoryCreationError", tr("Unable to create destination directory")); return context->thisObject(); } } else { throwError(context, engine, "DirectoryDoesntExistError", tr("Destination directory doesn't exist")); return context->thisObject(); } } QString command = "sh -c \"mv -f"; command += " "; command += QFile::encodeName(sourceCopy); command += " "; command += QFile::encodeName(destinationCopy); command += "\""; if(QProcess::execute(command)) { throwError(context, engine, "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, "MoveError", tr("Move failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, "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_LINUX 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, "RenameError", tr("Rename failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, "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_LINUX Q_UNUSED(noErrorDialog) Q_UNUSED(noConfirmDialog) Q_UNUSED(noProgressDialog) Q_UNUSED(allowUndo) QString filenameCopy(filename); filenameCopy.replace(" ", "\\ "); QString command = "sh -c \"rm -fr"; command += " "; command += QFile::encodeName(filenameCopy); command += "\""; if(QProcess::execute(command)) { throwError(context, engine, "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, "RemoveError", tr("Remove failed: %1").arg(getErrorString(result))); return context->thisObject(); } if(shFileOpStruct.fAnyOperationsAborted) { throwError(context, engine, "RemoveAbortedError", tr("Remove failed: aborted")); return context->thisObject(); } #endif return context->thisObject(); } QString File::getErrorString(int error) { #ifdef Q_OS_LINUX 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.9.1/actions/actionpackdata/code/file.h000066400000000000000000000102521261645124000215530ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef FILE_H #define FILE_H #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() { mFile.close(); } QFile *file() { return &mFile; } public slots: QString toString() const { return "File"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // FILE_H actiona-3.9.1/actions/actionpackdata/code/inifile.cpp000066400000000000000000000126271261645124000226160ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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) { IniFile *iniFile = new IniFile; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "encoding") iniFile->mEncoding = static_cast(it.value().toInt32()); } return CodeClass::constructor(iniFile, context, engine); } IniFile::IniFile() : CodeClass(), mEncoding(Native) { } QScriptValue IniFile::load(const QString &filename) { try { boost::property_tree::ini_parser::read_ini(toEncoding(filename, mEncoding).constData(), mTree); } catch(const std::runtime_error &e) { throwError("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 &e) { throwError("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("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("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("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("FindSectionError", 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 { 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("FindSectionError", 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.9.1/actions/actionpackdata/code/inifile.h000066400000000000000000000042161261645124000222560ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef INIFILE_H #define INIFILE_H #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 { return "IniFile"; } virtual bool equals(const QScriptValue &other) const { 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; boost::property_tree::ptree mCurrentSection; boost::property_tree::ptree mTree; QByteArray mCurrentSectionName; QString mLatestFilename; }; } #endif // INIFILE_H actiona-3.9.1/actions/actionpackdata/code/mail.cpp000066400000000000000000000202351261645124000221130ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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() == "username") mail->setUsername(it.value().toString()); else if(it.name() == "password") mail->setPassword(it.value().toString()); else if(it.name() == "onConnected") mail->mOnConnected = it.value(); else if(it.name() == "onConnectionFailed") mail->mOnConnectionFailed = it.value(); else if(it.name() == "onEncrypted") mail->mOnEncrypted = it.value(); else if(it.name() == "onEncryptionFailed") mail->mOnEncryptionFailed = it.value(); else if(it.name() == "onAuthenticated") mail->mOnAuthenticated = it.value(); else if(it.name() == "onAuthenticationFailed") mail->mOnAuthenticationFailed = it.value(); else if(it.name() == "onSenderRejected") mail->mOnSenderRejected = it.value(); else if(it.name() == "onRecipientRejected") mail->mOnRecipientRejected = it.value(); else if(it.name() == "onMailFailed") mail->mOnMailFailed = it.value(); else if(it.name() == "onMailSent") mail->mOnMailSent = it.value(); else if(it.name() == "onFinished") mail->mOnFinished = it.value(); else if(it.name() == "onDisconnected") mail->mOnDisconnected = it.value(); } return CodeClass::constructor(mail, context, engine); } Mail::Mail() : CodeClass() { connect(&mSmtp, SIGNAL(connected()), this, SLOT(connected())); connect(&mSmtp, SIGNAL(connectionFailed(QByteArray)), this, SLOT(connectionFailed(QByteArray))); connect(&mSmtp, SIGNAL(encrypted()), this, SLOT(encrypted())); connect(&mSmtp, SIGNAL(encryptionFailed(QByteArray)), this, SLOT(encryptionFailed(QByteArray))); connect(&mSmtp, SIGNAL(authenticated()), this, SLOT(authenticated())); connect(&mSmtp, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(authenticationFailed(QByteArray))); connect(&mSmtp, SIGNAL(senderRejected(int,QString,QByteArray)), this, SLOT(senderRejected(int,QString,QByteArray))); connect(&mSmtp, SIGNAL(recipientRejected(int,QString,QByteArray)), this, SLOT(recipientRejected(int,QString,QByteArray))); connect(&mSmtp, SIGNAL(mailFailed(int,int,QByteArray)), this, SLOT(mailFailed(int,int,QByteArray))); connect(&mSmtp, SIGNAL(mailSent(int)), this, SLOT(mailSent(int))); connect(&mSmtp, SIGNAL(finished()), this, SLOT(finished())); connect(&mSmtp, SIGNAL(disconnected()), this, SLOT(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(MailMessage *mailMessage = qobject_cast(mail.toQObject())) { QxtMailMessage &message = mailMessage->message(); if(!message.hasExtraHeader("Date")) message.setExtraHeader("Date", QDateTime::currentDateTime().toString(Qt::RFC2822Date)); return mSmtp.send(message); } else { throwError("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("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("EncryptionError", tr("Cannot encrypt the connection")); return thisObject(); } QScriptValue Mail::waitForAuthenticated(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(authenticated())); if(!waiter.wait(waitTime)) throwError("AuthenticationError", tr("Cannot authenticate to the server")); return thisObject(); } QScriptValue Mail::waitForFinished(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(finished())); if(!waiter.wait(waitTime)) throwError("WaitForFinishedError", tr("Wait for finished failed")); return thisObject(); } QScriptValue Mail::waitForDisconnected(int waitTime) { QxtSignalWaiter waiter(&mSmtp, SIGNAL(disconnected())); if(!waiter.wait(waitTime)) throwError("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.9.1/actions/actionpackdata/code/mail.h000066400000000000000000000205101261645124000215540ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef MAIL_H #define MAIL_H #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 mSmtp.username(); } void setUsername(const QString &username) { mSmtp.setUsername(username.toUtf8()); } QString password() const { return 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 { return "Mail"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // MAIL_H actiona-3.9.1/actions/actionpackdata/code/mailattachment.cpp000066400000000000000000000045661261645124000241750ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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) { MailAttachment *mailAttachment = new MailAttachment; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "contentType") mailAttachment->setContentType(it.value().toString()); else if(it.name() == "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(RawData *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.9.1/actions/actionpackdata/code/mailattachment.h000066400000000000000000000054621261645124000236360ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef MAILATTACHMENT_H #define MAILATTACHMENT_H #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 { return "MailAttachment"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // MAILATTACHMENT_H actiona-3.9.1/actions/actionpackdata/code/mailmessage.cpp000066400000000000000000000060301261645124000234550ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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) { MailMessage *mailMessage = new MailMessage; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "sender") mailMessage->mMessage.setSender(it.value().toString()); else if(it.name() == "subject") mailMessage->mMessage.setSubject(it.value().toString()); else if(it.name() == "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("filename", it.key()); attachmentObject.setProperty("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(MailAttachment *mailAttachment = qobject_cast(attachment.toQObject())) mMessage.addAttachment(filename, mailAttachment->attachment()); else throwError("ParameterTypeError", tr("Incorrect parameter type: not a MailAttachment")); return thisObject(); } QScriptValue MailMessage::removeAttachment(const QString &filename) { mMessage.removeAttachment(filename); return thisObject(); } } actiona-3.9.1/actions/actionpackdata/code/mailmessage.h000066400000000000000000000074771261645124000231420ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef MAILMESSAGE_H #define MAILMESSAGE_H #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 { return "MailMessage"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // MAILMESSAGE_H actiona-3.9.1/actions/actionpackdata/code/registry.cpp000066400000000000000000000263751261645124000230540ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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("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("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("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("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("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("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("SetValueError", tr("Cannot set the value data")); } else throwError("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("FindValueError", tr("Cannot find the value to read")); return QVariant(); } 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("FindValueError", tr("Cannot find the value to read")); return QVariant(); } 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: { wchar_t *buffer = new wchar_t[size]; if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(buffer), &size) != ERROR_SUCCESS) { throwError("FindValueError", tr("Cannot find the value to read")); return QVariant(); } if(type == REG_MULTI_SZ) { QStringList stringList = QString::fromWCharArray(buffer, size / 2).split(QChar(L'\0'), QString::SkipEmptyParts); delete [] buffer; if(stringList.last().isEmpty()) stringList.removeLast(); return stringList; } else { QString back = QString::fromWCharArray(buffer, size / 2); delete [] buffer; return back; } } break; case REG_BINARY: { char *buffer = new char[size]; if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(buffer), &size) != ERROR_SUCCESS) { throwError("FindValueError", tr("Cannot find the value to read")); return QVariant(); } QByteArray back = QByteArray::fromRawData(buffer, size); delete [] buffer; return back; } break; case REG_QWORD: { qint64 value; if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(&value), &size) != ERROR_SUCCESS) { throwError("FindValueError", tr("Cannot find the value to read")); return QVariant(); } return value; } break; case REG_NONE: default: throwError("InvalidValueError", tr("Invalid value type")); return QVariant(); 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("InvalidKeyError", tr("Unable to query informations about this key")); return QStringList(); } if(valueCount == 0 || maxValueNameLength == 0) return QStringList(); wchar_t *valueName = new wchar_t[maxValueNameLength + 1]; int result; QStringList back; for(;;++index) { DWORD valueNameSize = maxValueNameLength + 1; result = RegEnumValue(mHKey, index, valueName, &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, valueNameSize)); } delete [] valueName; return back; #else return QStringList(); #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("InvalidKeyError", tr("Unable to query informations about this key")); return QStringList(); } if(subKeyCount == 0 || maxSubKeyNameLength == 0) return QStringList(); wchar_t *subKeyName = new wchar_t[maxSubKeyNameLength + 1]; int result; QStringList back; for(;;++index) { DWORD subKeyNameSize = maxSubKeyNameLength + 1; result = RegEnumKeyEx(mHKey, index, subKeyName, &subKeyNameSize, 0, 0, 0, 0); if(result == ERROR_NO_MORE_ITEMS) break; back.append(QString::fromWCharArray(subKeyName, subKeyNameSize)); } delete [] subKeyName; return back; #else return QStringList(); #endif } QScriptValue Registry::deleteValue(const QString &value) const { #ifdef Q_OS_WIN if(RegDeleteValue(mHKey, value.toStdWString().c_str()) != ERROR_SUCCESS) throwError("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("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.9.1/actions/actionpackdata/code/registry.h000066400000000000000000000040561261645124000225110ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef REGISTRY_H #define REGISTRY_H #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(); public slots: QString toString() const { return "Registry"; } virtual bool equals(const QScriptValue &other) const { 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 }; } #endif // REGISTRY_H actiona-3.9.1/actions/actionpackdata/code/sql.cpp000066400000000000000000000151161261645124000217720ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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, "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, "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("DatabaseDriverUnavailableError", tr("The requested database driver is not available")); return thisObject(); } *mDatabase = QSqlDatabase::addDatabase(mDriverName, QUuid::createUuid().toString()); if(!mDatabase->isValid()) { throwError("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() == "hostName") hostName = it.value().toString(); else if(it.name() == "port") port = it.value().toInteger(); else if(it.name() == "databaseName") databaseName = it.value().toString(); else if(it.name() == "userName") userName = it.value().toString(); else if(it.name() == "password") password = it.value().toString(); else if(it.name() == "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("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("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("ExecuteQueryError", tr("Failed to execute the query : %1").arg(error.text())); return thisObject(); } return thisObject(); } QScriptValue Sql::fetchResult(IndexStyle indexStyle) { if(!mQuery.isSelect()) { throwError("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 "QSQLITE2"; case SQLite: return "QSQLITE"; case PostgreSQL: return "QPSQL"; case MySQL: return "QMYSQL"; case ODBC: return "QODBC"; case InterBase: return "QIBASE"; case OCI: return "QOCI"; case TDS: return "QTDS"; case DB2: return "QDB2"; default: return QString(); } } } actiona-3.9.1/actions/actionpackdata/code/sql.h000066400000000000000000000040741261645124000214400ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef SQL_H #define SQL_H #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(); public slots: QString toString() const { return "Sql"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // SQL_H actiona-3.9.1/actions/actionpackdata/code/tcp.cpp000066400000000000000000000123121261645124000217540ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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() == "onConnected") tcp->mOnConnected = it.value(); else if(it.name() == "onDisconnected") tcp->mOnDisconnected = it.value(); else if(it.name() == "onReadyRead") tcp->mOnReadyRead = it.value(); else if(it.name() == "onBytesWritten") tcp->mOnBytesWritten = it.value(); else if(it.name() == "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, SIGNAL(connected()), this, SLOT(connected())); QObject::connect(mTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnected())); QObject::connect(mTcpSocket, SIGNAL(readyRead()), this, SLOT(readyRead())); QObject::connect(mTcpSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWritten(qint64))); QObject::connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError))); } Tcp::Tcp(QTcpSocket *tcpSocket) : CodeClass(), mTcpSocket(tcpSocket) { QObject::connect(mTcpSocket, SIGNAL(connected()), this, SLOT(connected())); QObject::connect(mTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnected())); QObject::connect(mTcpSocket, SIGNAL(readyRead()), this, SLOT(readyRead())); QObject::connect(mTcpSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWritten(qint64))); QObject::connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError))); } Tcp::~Tcp() { } 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("ConnectionError", tr("Cannot establish a connection to the host")); return thisObject(); } QScriptValue Tcp::waitForBytesWritten(int waitTime) { if(!mTcpSocket->waitForBytesWritten(waitTime)) throwError("BytesWrittenError", tr("Waiting for bytes written failed")); return thisObject(); } QScriptValue Tcp::waitForReadyRead(int waitTime) { if(!mTcpSocket->waitForReadyRead(waitTime)) throwError("ReadyReadError", tr("Waiting for ready read failed")); return thisObject(); } QScriptValue Tcp::waitForDisconnected(int waitTime) { if(!mTcpSocket->waitForDisconnected(waitTime)) throwError("DisconnectionError", tr("Waiting for disconnection failed")); return thisObject(); } QScriptValue Tcp::write(const QScriptValue &data) { QObject *object = data.toQObject(); if(RawData *rawData = qobject_cast(object)) { if(mTcpSocket->write(rawData->byteArray()) == -1) throwError("WriteError", tr("Write failed")); } else { if(mTcpSocket->write(data.toVariant().toByteArray()) == -1) throwError("WriteError", tr("Write failed")); } return thisObject(); } QScriptValue Tcp::writeText(const QString &data, Encoding encoding) { if(mTcpSocket->write(toEncoding(data, encoding)) == -1) throwError("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.9.1/actions/actionpackdata/code/tcp.h000066400000000000000000000070351261645124000214270ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef TCP_H #define TCP_H #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(); 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 { return "Tcp"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // TCP_H actiona-3.9.1/actions/actionpackdata/code/tcpserver.cpp000066400000000000000000000045351261645124000232130ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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) { TcpServer *tcpServer = new TcpServer; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "onNewConnection") tcpServer->mOnNewConnection = it.value(); } return CodeClass::constructor(tcpServer, context, engine); } TcpServer::TcpServer() : CodeClass() { connect(&mTcpServer, SIGNAL(newConnection()), this, SLOT(newConnection())); } TcpServer::~TcpServer() { mTcpServer.close(); } QScriptValue TcpServer::listen(const QString &address, int port) { if(!mTcpServer.listen(QHostAddress(address), port)) throwError("ListenError", tr("Unable to start listening")); return thisObject(); } QScriptValue TcpServer::waitForNewConnection(int waitTime) { if(!mTcpServer.waitForNewConnection(waitTime)) throwError("WaitForNewConnectionError", tr("Waiting for new connection failed")); return thisObject(); } QScriptValue TcpServer::nextPendingConnection() { QTcpSocket *tcpSocket = mTcpServer.nextPendingConnection(); if(!tcpSocket) { throwError("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.9.1/actions/actionpackdata/code/tcpserver.h000066400000000000000000000036341261645124000226570ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef TCPSERVER_H #define TCPSERVER_H #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(); void setOnNewConnection(const QScriptValue &onNewConnection) { mOnNewConnection = onNewConnection; } QScriptValue onNewConnection() const { return mOnNewConnection; } public slots: QString toString() const { return "TcpServer"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // TCPSERVER_H actiona-3.9.1/actions/actionpackdata/code/udp.cpp000066400000000000000000000074311261645124000217640ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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() == "onConnected") udp->mOnConnected = it.value(); else if(it.name() == "onDisconnected") udp->mOnDisconnected = it.value(); else if(it.name() == "onReadyRead") udp->mOnReadyRead = it.value(); else if(it.name() == "onError") udp->mOnError = it.value(); } return CodeClass::constructor(udp, context, engine); } Udp::Udp() : CodeClass(), mUdpSocket(new QUdpSocket(this)) { QObject::connect(mUdpSocket, SIGNAL(connected()), this, SLOT(connected())); QObject::connect(mUdpSocket, SIGNAL(disconnected()), this, SLOT(disconnected())); QObject::connect(mUdpSocket, SIGNAL(readyRead()), this, SLOT(readyRead())); QObject::connect(mUdpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError))); } Udp::~Udp() { } 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("ConnectionError", tr("Cannot establish a connection to the host")); return thisObject(); } QScriptValue Udp::waitForReadyRead(int waitTime) { if(!mUdpSocket->waitForReadyRead(waitTime)) throwError("ReadyReadError", tr("Waiting for ready read failed")); return thisObject(); } QScriptValue Udp::write(const QScriptValue &data) { QObject *object = data.toQObject(); if(RawData *rawData = qobject_cast(object)) { if(mUdpSocket->write(rawData->byteArray()) == -1) throwError("WriteError", tr("Write failed")); } else { if(mUdpSocket->write(data.toVariant().toByteArray()) == -1) throwError("WriteError", tr("Write failed")); } return thisObject(); } QScriptValue Udp::writeText(const QString &data, Encoding encoding) { if(mUdpSocket->write(toEncoding(data, encoding)) == -1) throwError("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.9.1/actions/actionpackdata/code/udp.h000066400000000000000000000060211261645124000214230ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef UDP_H #define UDP_H #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(); 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 { return "Udp"; } virtual bool equals(const QScriptValue &other) const { 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; }; } #endif // UDP_H actiona-3.9.1/actions/actionpackdata/code/web.cpp000066400000000000000000000157171261645124000217570ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) #include #endif 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() == "onFinished") web->mOnFinished = it.value(); else if(it.name() == "onDownloadProgress") web->mOnDownloadProgress = it.value(); else if(it.name() == "onError") web->mOnError = it.value(); else if(it.name() == "file") web->mFileValue = it.value(); } return CodeClass::constructor(web, context, engine); } Web::Web() : CodeClass(), mNetworkAccessManager(new QNetworkAccessManager(this)), mNetworkReply(0), mFile(0), mCloseFile(false), mIsDownloading(false) { QObject::connect(mNetworkAccessManager, SIGNAL(authenticationRequired(QNetworkReply *, QAuthenticator *)), this, SLOT(authenticationRequired(QNetworkReply *, QAuthenticator *))); } Web::~Web() { } QScriptValue Web::download(const QString &urlString, const QScriptValue &options) { mData.clear(); if(mFileValue.isValid()) { if(Code::File *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("OpenFileError", tr("Unable to open the destination file")); return thisObject(); } mCloseFile = true; } } QUrl url(urlString); if(url.scheme() == QString()) url = QUrl("http://" + urlString, QUrl::TolerantMode); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QUrlQuery urlQuery; #endif QNetworkRequest request; QScriptValueIterator it(options); Method method = Get; QByteArray postData; while(it.hasNext()) { it.next(); if(it.name() == "rawHeaders") { QScriptValueIterator headerIt(it.value()); while(headerIt.hasNext()) { headerIt.next(); request.setRawHeader(headerIt.name().toUtf8(), headerIt.value().toString().toUtf8()); } } else if(it.name() == "method") { method = static_cast(it.value().toInt32()); } else if(it.name() == "postData") { #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) 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 QScriptValueIterator postDataIt(it.value()); QUrl postDataParameters; while(postDataIt.hasNext()) { postDataIt.next(); postDataParameters.addQueryItem(postDataIt.name(), postDataIt.value().toString()); } postData = postDataParameters.encodedQuery(); #endif } else if(it.name() == "query") { QScriptValueIterator queryIt(it.value()); while(queryIt.hasNext()) { queryIt.next(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) urlQuery.addQueryItem(queryIt.name(), queryIt.value().toString()); #else url.addQueryItem(queryIt.name(), queryIt.value().toString()); #endif } } else if(it.name() == "user") { mUser = it.value().toString(); } else if(it.name() == "password") { mPassword = it.value().toString(); } } #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) url.setQuery(urlQuery); #endif request.setUrl(url); switch(method) { case Post: mNetworkReply = mNetworkAccessManager->post(request, postData); break; case Get: default: mNetworkReply = mNetworkAccessManager->get(request); break; } QObject::connect(mNetworkReply, SIGNAL(finished()), this, SLOT(finished())); QObject::connect(mNetworkReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); QObject::connect(mNetworkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error())); QObject::connect(mNetworkReply, SIGNAL(readyRead()), this, SLOT(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 = 0; } else mData = mNetworkReply->readAll(); if(mOnFinished.isValid()) mOnFinished.call(thisObject()); mNetworkReply->deleteLater(); mNetworkReply = 0; 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.9.1/actions/actionpackdata/code/web.h000066400000000000000000000055701261645124000214200ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef WEB_H #define WEB_H #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(); 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 { return "Web"; } virtual bool equals(const QScriptValue &other) const { 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; QScriptValue mOnFinished; QScriptValue mOnDownloadProgress; QScriptValue mOnError; QScriptValue mFileValue; QFile *mFile; bool mCloseFile; QByteArray mData; bool mIsDownloading; QString mUser; QString mPassword; }; } #endif // WEB_H actiona-3.9.1/actions/actionpackdata/data.json000066400000000000000000000000301261645124000213460ustar00rootroot00000000000000{ "Keys": [ "data" ] } actiona-3.9.1/actions/actionpackdata/icons/000077500000000000000000000000001261645124000206645ustar00rootroot00000000000000actiona-3.9.1/actions/actionpackdata/icons/copyfile.png000066400000000000000000000013131261645124000232020ustar00rootroot00000000000000PNG  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.9.1/actions/actionpackdata/icons/readclipboard.png000066400000000000000000000042601261645124000241670ustar00rootroot00000000000000PNG  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.9.1/actions/actionpackdata/icons/readregistry.png000066400000000000000000000062011261645124000240750ustar00rootroot00000000000000PNG  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.9.1/actions/actionpackdata/icons/webdownload.png000077500000000000000000000054021261645124000237030ustar00rootroot00000000000000PNG  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.9.1/actions/actionpackdata/icons/writetext.png000066400000000000000000000035441261645124000234370ustar00rootroot00000000000000PNG  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 */ #ifndef ACTIONPACKDEVICE_H #define ACTIONPACKDEVICE_H #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 "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) #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) Q_PLUGIN_METADATA(IID "tools.actiona.ActionPack" FILE "device.json") #endif public: ActionPackDevice() {} void createDefinitions() { 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)); } QString id() const { return "device"; } QString name() const { return tr("Actions dealing with devices like the keyboard or the mouse"); } Tools::Version version() const { return Tools::Version(0, 0, 1); } void codeInit(QScriptEngine *scriptEngine) const { addCodeClass("Mouse", scriptEngine); addCodeClass("Keyboard", scriptEngine); } private: Q_DISABLE_COPY(ActionPackDevice) }; #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) Q_EXPORT_PLUGIN2(ActionPackDevice, ActionPackDevice) #endif #endif // ACTIONPACKDEVICE_H actiona-3.9.1/actions/actionpackdevice/actionpackdevice.pro000066400000000000000000000014111261645124000241120ustar00rootroot00000000000000include(../common_actions.pri) include(actions/actions.pri) include(code/code.pri) TARGET = ActionPackDevice QT += script equals(QT_MAJOR_VERSION, 5) { unix:QT += x11extras QT += widgets 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 \ ../../locale/actionpackdevice_de_DE.ts SOURCES += mousedevice.cpp \ keyboarddevice.cpp unix { locales.path = $${PREFIX}/share/actiona/locale locales.files = ../../locale/actionpackdevice_fr_FR.qm \ ../../locale/actionpackdevice_de_DE.qm locales.CONFIG = no_check_exist INSTALLS += locales } actiona-3.9.1/actions/actionpackdevice/actionpackdevice.qrc000066400000000000000000000003731261645124000241050ustar00rootroot00000000000000 icons/click.png icons/key.png icons/text.png icons/wheel.png icons/movecursor.png actiona-3.9.1/actions/actionpackdevice/actions/000077500000000000000000000000001261645124000215375ustar00rootroot00000000000000actiona-3.9.1/actions/actionpackdevice/actions/actions.pri000066400000000000000000000010051261645124000237070ustar00rootroot00000000000000HEADERS += 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 SOURCES += actions/textinstance.cpp \ actions/keyinstance.cpp \ actions/clickinstance.cpp \ actions/cursorpathinstance.cpp actiona-3.9.1/actions/actionpackdevice/actions/clickdefinition.h000066400000000000000000000103401261645124000250440ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef CLICKDEFINITION_H #define CLICKDEFINITION_H #include "actiondefinition.h" #include "clickinstance.h" #include "listparameterdefinition.h" #include "numberparameterdefinition.h" #include "positionparameterdefinition.h" #include "groupdefinition.h" #include namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ClickDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ClickDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ClickInstance::buttons", ClickInstance::buttons); translateItems("ClickInstance::actions", ClickInstance::actions); ActionTools::ListParameterDefinition *action = new ActionTools::ListParameterDefinition(ActionTools::Name("action", tr("Action")), this); action->setTooltip(tr("The action to simulate")); action->setItems(ClickInstance::actions); action->setDefaultValue(ClickInstance::actions.second.at(ClickInstance::ClickAction)); addElement(action); ActionTools::ListParameterDefinition *button = new ActionTools::ListParameterDefinition(ActionTools::Name("button", tr("Button")), this); button->setTooltip(tr("The button to simulate")); button->setItems(ClickInstance::buttons); button->setDefaultValue(ClickInstance::buttons.second.at(MouseDevice::LeftButton)); addElement(button); ActionTools::PositionParameterDefinition *position = new ActionTools::PositionParameterDefinition(ActionTools::Name("position", tr("Position")), this); position->setTooltip(tr("The screen position where to simulate a mouse click")); addElement(position); ActionTools::GroupDefinition *clickGroup = new ActionTools::GroupDefinition(this); clickGroup->setMasterList(action); clickGroup->setMasterValues(QStringList() << ClickInstance::actions.first.at(ClickInstance::ClickAction)); ActionTools::NumberParameterDefinition *amount = new ActionTools::NumberParameterDefinition(ActionTools::Name("amount", tr("Amount")), this); amount->setTooltip(tr("The amount of clicks to simulate")); amount->setMinimum(1); amount->setMaximum(std::numeric_limits::max()); amount->setDefaultValue(1); clickGroup->addMember(amount); addElement(clickGroup); ActionTools::PositionParameterDefinition *positionOffset = new ActionTools::PositionParameterDefinition(ActionTools::Name("positionOffset", tr("Offset")), this); positionOffset->setTooltip(tr("The offset to apply to the click position")); addElement(positionOffset, 1); addException(ClickInstance::FailedToSendInputException, tr("Send input failure")); addException(ClickInstance::InvalidActionException, tr("Invalid action")); } QString name() const { return QObject::tr("Click"); } QString id() const { return "ActionClick"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Emulates a mouse click"); } ActionTools::ActionInstance *newActionInstance() const { return new ClickInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/click.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(ClickDefinition) }; } #endif // CLICKDEFINITION_H actiona-3.9.1/actions/actionpackdevice/actions/clickinstance.cpp000066400000000000000000000054631261645124000250650ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair ClickInstance::buttons = qMakePair( QStringList() << "left" << "middle" << "right", QStringList() << QT_TRANSLATE_NOOP("ClickInstance::buttons", "Left") << QT_TRANSLATE_NOOP("ClickInstance::buttons", "Middle") << QT_TRANSLATE_NOOP("ClickInstance::buttons", "Right")); ActionTools::StringListPair ClickInstance::actions = qMakePair( QStringList() << "pressRelease" << "press" << "release", QStringList() << QT_TRANSLATE_NOOP("ClickInstance::actions", "Click (press and release)") << QT_TRANSLATE_NOOP("ClickInstance::actions", "Press") << QT_TRANSLATE_NOOP("ClickInstance::actions", "Release")); void ClickInstance::startExecution() { bool ok = true; Action action = evaluateListElement(ok, actions, "action", "value"); MouseDevice::Button button = evaluateListElement(ok, buttons, "button", "value"); QPoint position = evaluatePoint(ok, "position"); QPoint positionOffset = evaluatePoint(ok, "positionOffset"); int amount = evaluateInteger(ok, "amount"); if(!ok) return; if(action != ClickAction) amount = 1; if(amount <= 0) { setCurrentParameter("amount"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid click amount")); return; } 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; } } } QTimer::singleShot(1, this, SIGNAL(executionEnded())); } void ClickInstance::stopLongTermExecution() { mMouseDevice.reset(); } } actiona-3.9.1/actions/actionpackdevice/actions/clickinstance.h000066400000000000000000000030231261645124000245200ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef CLICKINSTANCE_H #define CLICKINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair buttons; static ActionTools::StringListPair actions; void startExecution(); void stopLongTermExecution(); private: MouseDevice mMouseDevice; Q_DISABLE_COPY(ClickInstance) }; } #endif // CLICKINSTANCE_H actiona-3.9.1/actions/actionpackdevice/actions/cursorpathdefinition.h000066400000000000000000000061051261645124000261550ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef CURSORPATHDEFINITION_H #define CURSORPATHDEFINITION_H #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 QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit CursorPathDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("CursorPathInstance::buttons", CursorPathInstance::buttons); ActionTools::PointListParameterDefinition *path = new ActionTools::PointListParameterDefinition(ActionTools::Name("path", tr("Path")), this); path->setTooltip(tr("The path to follow")); addElement(path); ActionTools::ListParameterDefinition *button = new ActionTools::ListParameterDefinition(ActionTools::Name("button", tr("Button")), this); button->setTooltip(tr("The button to simulate")); button->setItems(CursorPathInstance::buttons); button->setDefaultValue(CursorPathInstance::buttons.second.at(CursorPathInstance::NoButton)); addElement(button); ActionTools::PositionParameterDefinition *positionOffset = new ActionTools::PositionParameterDefinition(ActionTools::Name("positionOffset", tr("Offset")), this); positionOffset->setTooltip(tr("The offset to apply to the path")); addElement(positionOffset, 1); } QString name() const { return QObject::tr("Cursor path"); } QString id() const { return "ActionCursorPath"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Move the mouse cursor on a path"); } ActionTools::ActionInstance *newActionInstance() const { return new CursorPathInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/movecursor.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(CursorPathDefinition) }; } #endif // CURSORPATHDEFINITION_H actiona-3.9.1/actions/actionpackdevice/actions/cursorpathinstance.cpp000066400000000000000000000022741261645124000261670ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 { ActionTools::StringListPair CursorPathInstance::buttons = qMakePair( QStringList() << "none" << "left" << "middle" << "right", QStringList() << QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "None") << QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "Left") << QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "Middle") << QT_TRANSLATE_NOOP("CursorPathInstance::buttons", "Right")); } actiona-3.9.1/actions/actionpackdevice/actions/cursorpathinstance.h000066400000000000000000000067371261645124000256440ustar00rootroot00000000000000/* Actiona Copyright (C) 2008-2015 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 */ #ifndef CURSORPATHINSTANCE_H #define CURSORPATHINSTANCE_H #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 = 0) : ActionTools::ActionInstance(definition, parent), mCurrentPoint(0), mButton(NoButton) { connect(&mMoveTimer, SIGNAL(timeout()), this, SLOT(moveToNextPosition())); } static ActionTools::StringListPair buttons; void startExecution() { bool ok = true; mPositionOffset = evaluatePoint(ok, "positionOffset"); mButton = evaluateListElement