pax_global_header 0000666 0000000 0000000 00000000064 13636457430 0014525 g ustar 00root root 0000000 0000000 52 comment=11c913e8454dbed0a2a04ca4f25df6d85eae785b
actiona-3.10.1/ 0000775 0000000 0000000 00000000000 13636457430 0013225 5 ustar 00root root 0000000 0000000 actiona-3.10.1/.gitignore 0000664 0000000 0000000 00000000177 13636457430 0015222 0 ustar 00root root 0000000 0000000 *.exe
*.ilk
*.pdb
*.user
*.user.*
*.dll
*.exp
*.qm
*.lib
generated
*.so*
*.log*
*.cache*
Makefile
.qmake.stash
actexec
actiona
actiona-3.10.1/CHANGELOG 0000664 0000000 0000000 00000036664 13636457430 0014456 0 ustar 00root root 0000000 0000000 3.10.1 (24/03/20)
Global:
- Unixes: fixed compilation using OpenCV 4
- Unixes: fixed compilation on unixes other than Linux
- Fixed compilation using recent Qt versions
- Windows: fixed compilation using MinGW
Interface:
- Unixes: fixed broken global shortcuts
3.10.0 (17/07/18)
Global:
- Added a keyboard key condition action that allows checking or waiting for a particular key combination to be pressed
- Added a text to speech action that uses the operating system's voice synthesis capabilities
- Click action: added an option to reset the cursor position to its former position after the action has finished executing
- DataInput action: the output variable now contains an empty string if the user cancels the data input dialog
Interface:
- Added filters allowing to find an action within the script or within the list of available actions
- Added an action heat map that allows viewing the execution count and time spent per action (available after the first script execution)
- Improved program loading times
- Fixed missing script line numbers (regression from previous version)
- Fixed a slowdown when copy and pasting multiple actions within a big script
- Fixed a possible bug on the console when running a script for longer than a day
- Fixed a few minor bugs
3.9.4 (11/05/18)
Global:
- Fixed a slowdown occurring when editing an action within a big script
- Fixed non-translated buttons
- Fixed various memory leaks
- Windows: now using Qt 5.6 to build official binaries => removed Webkit web browser, but reduced installer and SFX size
Installer/Packages:
- Windows installer: fixed missing .dll files used by SQL drivers (like MySQL)
3.9.3 (28/10/17)
Global:
- Windows: fixed compatibility with Windows 10
- SendMail action: fixed a bug where no exception was thrown when an error occured when sending the e-mail
- Click action: fixed not specifying a position would move the mouse cursor to the upper-left screen position
- Procedures: fixed a bug where actions were reset when a procedure ends
- TimeCondition action: fixed the "if after" and "if before" labels not being intuitive (replaced by "if in the future" and "if in the past")
- MultiDataInput action: fixed stretching occuring at the wrong place
- DataInput action: fixed default value being capped at 99
- Windows: fixed Actiona still writing an entry into the registry when starting with the --portable parameter
Interface:
- Linux: added a warning when starting Actiona on a non-X11 session
3.9.2 (28/05/16)
Global:
- Windows: fixed mouse and keyboard simulation on some applications (started with admin privileges)
Code:
- fixed loadUI and include functions not using the current script or code filename directory as working directory
- added the Execution.filename readonly property, containing the current script or code filename
- ActionPackSystem, Debian/Ubuntu/...: fixed a crash when using the System object
- ActionPackData: fixed crash when trying to read a non-existing key
Installer/Packages:
- Windows installer: fixed setup of PATH environment variable and removal when uninstalling
3.9.1 (04/11/15)
Global:
- Windows: fixed click simulation failures in some cases
- fixed a crash when canceling a script execution while a key was being pressed
- fixed SFX scripts not being run when a local installation of Actiona was required
Interface:
- Windows: fixed keyboard shortcuts not working
- Debian/Ubuntu/...: fixed a bug preventing the main window to be displayed on recent distribution versions
- fixed a crash when right-clicking a "go to a line" exception field
- fixed a bug preventing the selection of a pixel on the screen when the Actiona window was on top of it
- fixed a bug where the save script progress dialog would stay open when exporting an SFX script
Code:
- fixed not being able to display the value of an array variable in a text field
- fixed console output by way of code not being displayed until after a call to sleep() or pause()
- added "pretty printing" of Array and Object
3.9.0 (22/06/15)
Global:
- renamed Actionaz to Actiona (sounds better in French)
- now using Qt5 instead of Qt4 (minimal version is 5.2)
- ActionDataInput: added editor type (line, multiline or password)
- added a SendMail action
- Windows: added a "no unicode character" option to the WriteText action, should allow for a limited text writing in some applications like Remote Desktop
- fixed DataInput & MultiDataInput not opening URLS in their question fields
- fixed a crash when using the ChooseWindow button (fixes #31)
- Linux: fixed missing F1-F35 keys in the KeyMapper
- WriteIniFile: fixed a bug that prevented the creation of new ini files
- Windows: fixed keyboard keys not being simulated on some applications (Remote Desktop for example) Note that this doesn't include simulating unicode text input, for which there is, afaik, no solution
Interface:
- enabled secure connections for checking Internet connectivity, fetching update information and downloading new versions
- added a language change setting
- now checking if the SFX files are available to enable/disable the export SFX feature
- fixed a bug preventing saving the values of some settings (caused by the Qt5 migration): users will see those settings reset to their default values
- fixed a bug in localized tab names in action dialogs
- removed unused context help button on dialogs
Code:
- added a Mail object
- added ProcessHandle::parentId()
- added a MultilineText option to the InputDialog object
- added Console.clear()
- Image: added the pixels() and pixelData() methods to retreive the pixel values at once
Internal:
- replaced RudeConfig with boost::property_tree
- replaced Qt's foreach by C++11's range-based for
3.8.0 (09/03/14)
Global:
- added in-script resources
- added an Image parameter
- added a percent positioning to the position parameter
- set the positions as floating point
- added the evaluation of text-mode variables as non-text if they are the only entry of a parameter
- fixed some bugs in variable insertion in parameters
- replaced input masks by validators in position and color parameters
- fixed the default value in DateTime parameters
- VariableCondition: added a Contains operation allowing to test for the presence of a string in a string list
- VariableCondition: corrected the comparison of values, allowing for more intuitive comparisons
- CursorPath: added a mouse button that can be pressed during the action execution
Interface:
- added a screen capture wizard
- added the insertion of variables & resources in the code editor
- added a progress bar to the loading and saving of scripts
Code:
- added Script.callProcedure
- SQL: corrected a bug that ran a SQL request two times when using exec() with a non-prepared request
3.7.0 (28/06/13)
Actions:
- added a button to insert detected variables into parameter fields
- added a more explicit error message when a list field is empty
- fixed a bug when opening a script that had been created using a previous version of Actiona: new action parameters did not have default values
- corrected a bug that prevented using the Code Error exception to skip the current action or go to a line of the script
- Pixel Color: added an offset to the position to be checked
- Read INI File: added reading the whole file at once
- Read INI File: corrected a bug that froze the execution when trying to read a file with an empty filename
- Find Image: added a field allowing to retreive the confidence value
- Find Image: added a field to choose which matching method to use
- Find Image: added a delay between two searches when waiting
- Find Image: added two conditions actions "if found" and "if not found"
- Find Image: removed the "Image not found" exception, previous scripts will be automatically upgraded to use the "if found" and "if not found" parameters
- Find Image: search can now be done in multiple windows if they satisfy the search criterion
- Find Image: renamed "Down pyramids" to "Downsampling"
- Find Image: fixed a bug that prevented searching in some screens when using a multiple screen configuration
- Find Image: fixed a bug that prevented using an absolute position when searching within a window
Code:
- Script: added the line attribute
- Image: added the Image.takeScreenshotUsingScreenIndex function that allows taking screenshots using a screen index
- Image: added a parameter to the findSubImage functions to choose which matching method to use
- Image: fixed a bug that prevented searching in some screens when using a multiple screen configuration
- Image: fixed a bug in the Image.takeScreenshot function that took only a screenshot of the main screen when using a multiple screen configuration
3.6.2 (04/05/13)
- Actions: fixed a regression that caused a memory leak and a crash after a repeated use of the Find Image action
- Code: fixed a bug that caused a memory leak and a crash after a repeated use of Image.findSubImage and similar
3.6.1 (04/03/13)
- Actions: fixed a bug in the in-text variable insertions that prevented using backslashes
3.6.0 (03/03/13)
- Actions: added a position offset in the Click, Move cursor and Cursor path
- Actions: added an action to read environment variables
- Gui: fixed a bug where pause before and after each action were not reset after creating a new script
- Code: added the File.exists() function
- Actions: upgraded the in-text variable insertions to allow inserting table elements
- ActExec & Gui: fixed a bug that prevented the translation of the parameters usage
- Actions: fixed a bug in the Command action that prevented getting the standard output and standard error texts
- Actions: fixed a bug that prevented using Date objects in the Time Condition action
- Actions: fixed a bug in the Find image action & code that could crash the program in certain cases
3.5.1 (28/12/12)
- ActExec: fixed a bug that prevented the use of the pauseBefore and pauseAfter script parameters
- Actions: fixed a bug that involved setVariable to create variables of type Object and not of the values type
- Actions: fixed a bug preventing comparison of variables other than strings in the VariableCondition action
3.5.0 (08/12/12)
- Actions: added a parameter to choose the key press amount in the Key action
- Actions: added a parameter to trigger a pause between key presses to the Text action
- Actions: setting the default value for "down pyramid count" to 1 in the Find Image action
- Code: added a delay to the writeText function
3.4.2 (27/05/12)
- Actions: corrected a bug in the Time Condition action
- Code: corrected a bug preventing Mouse functions to work with other buttons than the left one
- Code: corrected bugs in the waitForX Process functions
- Code: corrected bugs in code classes using enums as function parameters
3.4.1 (10/04/12)
- Executer: fixed a bug increasing the pause before and after an action
- Gui: removed spaces at begin and end of imported scripts to prevent an XML import error
- ActionTools: corrected a bug where a newer version of the script file schema could be seen as a corrupted script
3.4.0 (08/04/12)
- Actions: added three actions allowing the use of procedures
- Actions: added a new "If action" action allowing to call a procedure
- Actions: deprecated the x-coodinate, y-coordinate, width and height parameters in the Window condition action
- Actions: added position and size parameters in the Window condition action
- Packaging: fixed Debian bug #667093 (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=667093)
- Gui, Console: clicking on a log console item now selects the corresponding action
- Gui: fixed a bug where the execute selection button was disabled after an execution even if an action was still selected
- Gui: fixed a bug where clicking on a console item could select/open another action than the one concerned by the item
- ActExec, Windows: added a program parameter to show a console
- fixed some warnings due to useless & dangerous calls to deleteLater (close() auto-deletes QWidgets by default)
3.3.0 (29/03/12)
- Actions: added a window title to the DataInput action
- Actions: added new action MultiDataInput
- Actions: added a text mode to the Messagebox action
- fixed a bug crashing the application when canceling the execution when the debugger is open and a MessageBox action is shown
3.2.2 (29/01/12)
- Code: fixed getter functions having the same name as properties
- Packaging: removed compiler options to allow compilation on non-x86 platforms
- removed 7z binaries from repository
3.2.1.1 (16/01/12)
- Packaging: dependency on OpenCV is now done using Pkgconfig
3.2.1 (14/01/12)
- Actions: added a tolerance value for the Pixel color action
- Actions: fixed a bug preventing to enter no data in a number parameter
- Actions: fixed a bug preventing to enter integer or decimal values below 0 or over 100
- Windows: fixed a bug during installation preventing the use of image formats other than PNG
- fixed a bug corrupting the Actiona window when using the Exit Actiona action
- fixed some memory leaks
3.2.0 (06/01/12)
- Actions: added the FindImage action
- Actions: added an option to use window borders to the Window action
- Actions: added Point (position) and Color variable types to the Variable action
- Actions: fixed a bug in the Window Condition action, blocking if "goto a line" was selected in "if false"
- Gui: updated the settings dialog to show the last opened tab
- Gui: fixed check for updates parameter not being hidden when updates are disabled
- Gui: now hiding exceptions when no parameters are shown
- Executer: fixed a bug crashing Actiona when using the Stop action
3.1.1 (30/12/11)
- Code editor: added Ctrl+Return shortcut to close the code/text editor
- Code editor: added Shift+Tab to unindent the selection in the code/text editor
- Code editor: improved the Code syntax highlighter
- Code: fixed a crash when using the Web object
- Code: fixed Execution.sleep() and Execution.pause() not working under Linux
- Code: fixed possible crash when using Execution.sleep() and Execution.pause()
- Windows: fixed a bug in the installer preventing the use of SFX scripts
3.1.0 (21/12/11)
- added edition of actions that are not compatible with the current OS
- added modifier keys in the Key action
3.0.1 (11/12/11)
- Gui: replaced GroupBoxes by invisible widgets (increased readability)
- Code: fixed a bug that could cause crashes when using events
- Code: added Image.findSubImage()
- Code: added Stdio.println(), Stdio.printlnWarning() and Stdio.printlnError()
- Gui, Linux: set window opacity only if the compositing manager is running
- Code, Windows: improved the File object
- Actions: fixed a bug in WriteIniFile where the INI file was overwritten on each edit
3.0.0 (13/11/11)
- official stable release
0.1.3 (06/11/11)
- ActExec: added proxy parameters
- ActExec: using system proxy by default
- fixed a bug with action parameter evaluation during execution
- Code: added Window.foreground()
0.1.2 (08/10/11)
- fixed a bug concerning the last opened script
- fixed a bug when jumping to another line of the script
- added a WebDownload action
- added a Web code object
- fixed a bug in the cursor path actions
- added a field to the MessageBox and DataInput actions to specify the title icon to use
- Sfx: added a "requires Actiona" option
- Sfx: added a runner executable to warn about 64 bit compatibility issues
0.1.1 (24/09/11)
- corrected a bug involving the "goto line" action when the tested pixel was not equal to the wanted value
- added a new contributor to the about dialog
- Windows: added a missing mediaservice dll used to play sound & videos
- fixed a bug when validating a script file with non-ascii characters
- ActionMessageBox: added a custom icon choice
- Gui: added an option to use the system proxy
actiona-3.10.1/LICENSE 0000664 0000000 0000000 00000077330 13636457430 0014244 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
actiona-3.10.1/README.md 0000664 0000000 0000000 00000001657 13636457430 0014515 0 ustar 00root root 0000000 0000000 [](https://ci.appveyor.com/project/Jmgr/actiona)
[](https://ci.appveyor.com/project/Jmgr/actiona-hhhwb)
[](https://ci.appveyor.com/project/Jmgr/actiona-9331s)

Actiona
======
Actiona is an application that allows you to execute many actions on your
computer such as emulating mouse clicks, key presses, showing message boxes,
editing text files, etc. Tasks can be created using a simple editor or using
the EcmaScript (JavaScript) programming language for more customization.
Actiona is cross-platform.
Please visit http://actiona.tools for more information.
actiona-3.10.1/actexecuter/ 0000775 0000000 0000000 00000000000 13636457430 0015541 5 ustar 00root root 0000000 0000000 actiona-3.10.1/actexecuter/actexecuter.pro 0000664 0000000 0000000 00000002661 13636457430 0020604 0 ustar 00root root 0000000 0000000 include(../common.pri)
unix:!mac:QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN -Wl,--rpath=$${PREFIX}/$${LIBDIR}/actiona
QT += network \
script \
scripttools \
widgets
TARGET = actexec
VERSION = $$ACTIONA_VERSION
DESTDIR = ..
SOURCES += main.cpp \
executer.cpp \
codeexecuter.cpp \
scriptexecuter.cpp \
mainclass.cpp
HEADERS += executer.h \
codeexecuter.h \
scriptexecuter.h \
mainclass.h \
global.h
INCLUDEPATH += . \
.. \
../tools \
../actiontools
FORMS +=
win32:LIBS += -luser32 \
-ladvapi32 \
-lole32
unix:LIBS += -lXtst
LIBS += -L.. \
-ltools \
-lactiontools \
-lexecuter
TRANSLATIONS = ../locale/actexecuter_fr_FR.ts
unix:!mac:CONFIG += link_pkgconfig
unix:!mac:PKGCONFIG += libnotify
win32 {
QMAKE_TARGET_COMPANY = "https://actiona.tools"
QMAKE_TARGET_DESCRIPTION = "Actiona: Cross-Platform Automation Tool"
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2005 Jonathan Mercier-Ganady"
QMAKE_TARGET_PRODUCT = "Actiona"
RC_ICONS = "../gui/icons/actiona.ico"
}
win32-msvc* {
CONFIG += embed_manifest_exe
QMAKE_LFLAGS += $$quote( /MANIFESTUAC:\"level=\'asInvoker\' uiAccess=\'true\'\" )
}
unix {
target.path = $${PREFIX}/bin
locales.path = $${PREFIX}/share/actiona/locale
locales.files = ../locale/actexecuter_fr_FR.qm
locales.CONFIG = no_check_exist
manfile.path = $${PREFIX}/share/man/man1
manfile.files = ../docs/actexec.1
INSTALLS += target locales manfile
}
actiona-3.10.1/actexecuter/codeexecuter.cpp 0000664 0000000 0000000 00000013443 13636457430 0020731 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "codeexecuter.h"
#include "executer/codeinitializer.h"
#include "executer/scriptagent.h"
#include "actionfactory.h"
#include "actionpack.h"
#include "executer/codestdio.h"
#include "code/codetools.h"
#include "code/prettyprinting.h"
#include "executer/codeactiona.h"
#include "global.h"
#include "languages.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
CodeExecuter::CodeExecuter(QObject *parent) :
Executer(parent),
mScriptEngine(new QScriptEngine(this)),
mScriptAgent(new LibExecuter::ScriptAgent(mScriptEngine)),
mScriptEngineDebugger(new QScriptEngineDebugger(this)),
mDebuggerWindow(mScriptEngineDebugger->standardWindow())
{
connect(mScriptEngineDebugger, &QScriptEngineDebugger::evaluationResumed, this, &CodeExecuter::onEvaluationResumed);
connect(mScriptEngineDebugger, &QScriptEngineDebugger::evaluationSuspended, this, &CodeExecuter::onEvaluationPaused);
connect(mScriptAgent, &LibExecuter::ScriptAgent::executionStopped, this, &CodeExecuter::stopExecution);
for(QString extension: mScriptEngine->availableExtensions())
mScriptEngine->importExtension(extension);
Code::setupPrettyPrinting(*mScriptEngine);
mScriptEngineDebugger->setAutoShowStandardWindow(false);
mScriptEngineDebugger->attachTo(mScriptEngine);
QScriptEngineAgent *debuggerAgent = mScriptEngine->agent();
mScriptEngine->setAgent(mScriptAgent);
mScriptAgent->setDebuggerAgent(debuggerAgent);
}
bool CodeExecuter::start(QIODevice *device, const QString &filename)
{
if(!Executer::start(device, filename))
return false;
QString code = QString::fromUtf8(device->readAll());
device->close();
mScriptAgent->setContext(LibExecuter::ScriptAgent::ActionInit);
LibExecuter::CodeInitializer::initialize(mScriptEngine, mScriptAgent, actionFactory(), filename);
Code::CodeTools::addClassToScriptEngine(QStringLiteral("Console"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::print, QStringLiteral("print"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::println, QStringLiteral("println"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printWarning, QStringLiteral("printWarning"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printlnWarning, QStringLiteral("printlnWarning"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printError, QStringLiteral("printError"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::printlnError, QStringLiteral("printlnError"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Console"), &LibExecuter::CodeStdio::clear, QStringLiteral("clear"), mScriptEngine);
Code::CodeTools::addClassToScriptEngine(QStringLiteral("Actiona"), mScriptEngine);
LibExecuter::CodeActiona::setActExec(true);
LibExecuter::CodeActiona::setActionaVersion(Global::ACTIONA_VERSION);
LibExecuter::CodeActiona::setScriptVersion(Global::SCRIPT_VERSION);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::version, QStringLiteral("version"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::scriptVersion, QStringLiteral("scriptVersion"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::isActExec, QStringLiteral("isActExec"), mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine(QStringLiteral("Actiona"), &LibExecuter::CodeActiona::isActiona, QStringLiteral("isActiona"), mScriptEngine);
QString locale = Tools::Languages::locale();
for(int actionPackIndex = 0; actionPackIndex < actionFactory()->actionPackCount(); ++actionPackIndex)
{
ActionTools::ActionPack *actionPack = actionFactory()->actionPack(actionPackIndex);
Tools::Languages::installTranslator(QStringLiteral("actionpack%1").arg(actionPack->id()), locale);
}
mScriptAgent->setContext(LibExecuter::ScriptAgent::Parameters);
QScriptValue result = mScriptEngine->evaluate(code, filename);
if(result.isError())
{
QTextStream stream(stdout);
stream << QObject::tr("Uncaught exception: ") << result.toString() << "\n";
stream << tr("Backtrace: ") << mScriptEngine->uncaughtExceptionBacktrace().join(QStringLiteral("\n")) << "\n";
stream.flush();
}
QTimer::singleShot(0, qApp, SLOT(quit()));
return true;
}
void CodeExecuter::onEvaluationResumed()
{
mDebuggerWindow->hide();
}
void CodeExecuter::onEvaluationPaused()
{
mDebuggerWindow->show();
}
void CodeExecuter::stopExecution()
{
mScriptEngine->abortEvaluation();
}
actiona-3.10.1/actexecuter/codeexecuter.h 0000664 0000000 0000000 00000002436 13636457430 0020376 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "executer.h"
namespace LibExecuter
{
class ScriptAgent;
}
class QScriptEngine;
class QScriptEngineDebugger;
class QMainWindow;
class CodeExecuter : public Executer
{
Q_OBJECT
public:
explicit CodeExecuter(QObject *parent = nullptr);
bool start(QIODevice *device, const QString &filename) override;
private slots:
void onEvaluationResumed();
void onEvaluationPaused();
void stopExecution();
private:
QScriptEngine *mScriptEngine;
LibExecuter::ScriptAgent *mScriptAgent;
QScriptEngineDebugger *mScriptEngineDebugger;
QMainWindow *mDebuggerWindow;
};
actiona-3.10.1/actexecuter/executer.cpp 0000664 0000000 0000000 00000003663 13636457430 0020101 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "executer.h"
#include "actionfactory.h"
#include
#include
#include
#include
#include
Executer::Executer(QObject *parent) :
QObject(parent),
mActionFactory(new ActionTools::ActionFactory(this))
{
connect(mActionFactory, &ActionTools::ActionFactory::actionPackLoadError, this, &Executer::actionPackLoadError);
}
Executer::~Executer() = default;
bool Executer::start(QIODevice *device, const QString &filename)
{
Q_UNUSED(device)
Q_UNUSED(filename)
QSettings settings;
QString locale = settings.value(QStringLiteral("gui/locale"), QLocale::system().name()).toString();
mActionFactory->loadActionPacks(QApplication::applicationDirPath() + QStringLiteral("/actions/"), locale);
#ifndef Q_OS_WIN
if(mActionFactory->actionPackCount() == 0)
mActionFactory->loadActionPacks(QStringLiteral("%1/%2/actiona/actions/").arg(QLatin1String(ACT_PREFIX)).arg(QLatin1String(ACT_LIBDIR)), locale);
#endif
if(mActionLoadingFailed)
return false;
return true;
}
ActionTools::ActionFactory *Executer::actionFactory() const
{
return mActionFactory;
}
void Executer::actionPackLoadError(const QString &error)
{
mActionLoadingFailed = true;
std::wcerr << error.toStdWString() << std::endl;
}
actiona-3.10.1/actexecuter/executer.h 0000664 0000000 0000000 00000002304 13636457430 0017535 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include
class QIODevice;
namespace ActionTools
{
class ActionFactory;
}
class Executer : public QObject
{
Q_OBJECT
public:
explicit Executer(QObject *parent = nullptr);
~Executer() override;
virtual bool start(QIODevice *device, const QString &filename);
protected:
ActionTools::ActionFactory *actionFactory() const;
private slots:
void actionPackLoadError(const QString &error);
private:
ActionTools::ActionFactory *mActionFactory;
bool mActionLoadingFailed{false};
};
actiona-3.10.1/actexecuter/global.h 0000664 0000000 0000000 00000002464 13636457430 0017160 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "version.h"
namespace Global
{
#if (QT_VERSION >= 0x050600)
const Tools::Version ACTIONA_VERSION = QVersionNumber::fromString(QLatin1String(VERSION_TO_STRING(ACT_VERSION)));
const Tools::Version SCRIPT_VERSION = QVersionNumber::fromString(QLatin1String(VERSION_TO_STRING(ACT_SCRIPT_VERSION)));
#else
const Tools::Version ACTIONA_VERSION = Tools::Version(QLatin1String(VERSION_TO_STRING(ACT_VERSION)));
const Tools::Version SCRIPT_VERSION = Tools::Version(QLatin1String(VERSION_TO_STRING(ACT_SCRIPT_VERSION)));
#endif
const QString CONNECTIVITY_URL = QStringLiteral("http://actiona.tools/");
}
actiona-3.10.1/actexecuter/main.cpp 0000664 0000000 0000000 00000026663 13636457430 0017206 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "actioninstance.h"
#include "version.h"
#include "mainclass.h"
#include "qtsingleapplication/qtsingleapplication.h"
#include "global.h"
#include "settings.h"
#include "languages.h"
#ifdef ACT_PROFILE
#include "highresolutiontimer.h"
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifdef Q_OS_UNIX
#undef signals
#include
#define signals
#include "keysymhelper.h"
#endif
#ifdef Q_OS_WIN
#include
#include
#include
#include
#include
#include
#endif
static void cleanup()
{
#ifdef Q_OS_UNIX
notify_uninit();
#endif
}
#ifdef Q_OS_WIN
static void pause()
{
system("pause");
}
static void createConsole()
{
AllocConsole();
HANDLE stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT);
*stdout = *_fdopen(conHandle, "w");
setvbuf(stdout, NULL, _IONBF, 0);
stdHandle = GetStdHandle(STD_INPUT_HANDLE);
conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT);
*stdin = *_fdopen(conHandle, "r");
setvbuf(stdin, NULL, _IONBF, 0);
stdHandle = GetStdHandle(STD_ERROR_HANDLE);
conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT);
*stderr = *_fdopen(conHandle, "w");
setvbuf(stderr, NULL, _IONBF, 0);
}
#endif
int main(int argc, char **argv)
{
#if (QT_VERSION < 0x050400)
#error("You need Qt 5.4.0 or later to compile Actiona Executer");
#endif
QtSingleApplication app(QStringLiteral("actiona-exec"), argc, argv);
app.setQuitOnLastWindowClosed(false);
qAddPostRoutine(cleanup);
qsrand(static_cast(std::time(nullptr)));
#ifdef Q_OS_UNIX
notify_init("Actiona executer");
#endif
QCommandLineParser optionsParser;
optionsParser.setApplicationDescription(QObject::tr("Emulates clics, key presses and other actions."));
optionsParser.addHelpOption();
optionsParser.addVersionOption();
optionsParser.addOption({{QStringLiteral("p"), QStringLiteral("portable")}, QObject::tr("Starts in portable mode, storing the settings in the executable folder.")});
optionsParser.parse(app.arguments());
if(optionsParser.isSet(QStringLiteral("portable")))
{
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationDirPath() + QStringLiteral("/userSettings"));
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QApplication::applicationDirPath() + QStringLiteral("/systemSettings"));
QSettings::setDefaultFormat(QSettings::IniFormat);
}
QString locale = Tools::Languages::locale();
Tools::Languages::installTranslator(QStringLiteral("qtbase"), locale);
Tools::Languages::installTranslator(QStringLiteral("qtlocation"), locale);
Tools::Languages::installTranslator(QStringLiteral("qtmultimedia"), locale);
Tools::Languages::installTranslator(QStringLiteral("qtscript"), locale);
Tools::Languages::installTranslator(QStringLiteral("qtxmlpatterns"), locale);
Tools::Languages::installTranslator(QStringLiteral("tools"), locale);
Tools::Languages::installTranslator(QStringLiteral("actiontools"), locale);
Tools::Languages::installTranslator(QStringLiteral("executer"), locale);
Tools::Languages::installTranslator(QStringLiteral("actexecuter"), locale);
optionsParser.addOptions(
{
{{QStringLiteral("c"), QStringLiteral("code")}, QObject::tr("Switch to code mode, may not be used with -s.")},
{{QStringLiteral("s"), QStringLiteral("script")}, QObject::tr("Switch to script mode, may not be used with -c.")},
{{QStringLiteral("Q"), QStringLiteral("nocodeqt")}, QObject::tr("Do not include the Qt library into the code.")},
{{QStringLiteral("proxy-mode")}, QObject::tr(R"(Sets the proxy mode, values are "none", "system" (default) or "custom".)")},
{{QStringLiteral("proxy-type")}, QObject::tr(R"(Sets the custom proxy type, values are "http" or "socks" (default).)")},
{{QStringLiteral("proxy-host")}, QObject::tr("Sets the custom proxy host.")},
{{QStringLiteral("proxy-port")}, QObject::tr("Sets the custom proxy port.")},
{{QStringLiteral("proxy-user")}, QObject::tr("Sets the custom proxy user.")},
{{QStringLiteral("proxy-password")}, QObject::tr("Sets the custom proxy password.")},
});
#ifdef Q_OS_WIN
optionsParser.addOption({QStringLiteral("console"), QObject::tr("create a console to see debug output.")});
optionsParser.addOption({QStringLiteral("pause-at-end"), QObject::tr("wait for user input at the end of the execution, used only with --console.")});
#endif
optionsParser.addPositionalArgument(QStringLiteral("filepath"), QObject::tr("The filepath of a script/code file to execute."));
optionsParser.process(app);
#ifdef Q_OS_WIN
if(optionsParser.isSet(QStringLiteral("console")))
{
createConsole();
if(optionsParser.isSet(QStringLiteral("pause-at-end")))
qAddPostRoutine(pause);
}
#endif
qRegisterMetaType("ActionInstance");
qRegisterMetaType("Exception");
qRegisterMetaType("Parameter");
qRegisterMetaType("SubParameter");
qRegisterMetaType("Version");
qRegisterMetaTypeStreamOperators("ActionInstance");
qRegisterMetaTypeStreamOperators("Parameter");
qRegisterMetaTypeStreamOperators("SubParameter");
qRegisterMetaTypeStreamOperators("Version");
const auto &positionalArguments = optionsParser.positionalArguments();
if(positionalArguments.count() < 1 || (optionsParser.isSet(QStringLiteral("code")) && optionsParser.isSet(QStringLiteral("script"))))
optionsParser.showHelp(-1);
app.addLibraryPath(QApplication::applicationDirPath() + QStringLiteral("/actions"));
app.addLibraryPath(QApplication::applicationDirPath() + QStringLiteral("/plugins"));
if(!optionsParser.isSet(QStringLiteral("nocodeqt")))
app.addLibraryPath(QApplication::applicationDirPath() + QStringLiteral("/code"));
#ifdef Q_OS_UNIX
{
#ifdef ACT_PROFILE
Tools::HighResolutionTimer timer("Load key codes");
#endif
ActionTools::KeySymHelper::loadKeyCodes();
}
#endif
// Proxy settings
int proxyMode = ActionTools::Settings::PROXY_SYSTEM;
if(optionsParser.value(QStringLiteral("proxy-mode")) == QLatin1String("none"))
proxyMode = ActionTools::Settings::PROXY_NONE;
else if(optionsParser.value(QStringLiteral("proxy-mode")) == QLatin1String("custom"))
proxyMode = ActionTools::Settings::PROXY_CUSTOM;
else if(optionsParser.value(QStringLiteral("proxy-mode")) == QLatin1String("system"))
proxyMode = ActionTools::Settings::PROXY_SYSTEM;
else if(!optionsParser.value(QStringLiteral("proxy-mode")).isEmpty())
{
QTextStream stream(stdout);
stream << QObject::tr(R"(Unknown proxy mode, values are "none", "system" (default) or "custom")") << "\n";
stream.flush();
optionsParser.showHelp(-1);
}
QNetworkProxy proxy;
switch(proxyMode)
{
case ActionTools::Settings::PROXY_NONE:
proxy.setType(QNetworkProxy::NoProxy);
break;
case ActionTools::Settings::PROXY_SYSTEM:
{
QUrl url(Global::CONNECTIVITY_URL);
QNetworkProxyQuery networkProxyQuery(url);
QList listOfProxies = QNetworkProxyFactory::systemProxyForQuery(networkProxyQuery);
if(!listOfProxies.isEmpty())
proxy = listOfProxies.first();
else
proxy.setType(QNetworkProxy::NoProxy);
}
break;
case ActionTools::Settings::PROXY_CUSTOM:
{
int type = ActionTools::Settings::PROXY_TYPE_SOCKS5;
if(optionsParser.value(QStringLiteral("proxy-type")) == QLatin1String("http"))
type = ActionTools::Settings::PROXY_TYPE_HTTP;
else if(optionsParser.value(QStringLiteral("proxy-type")) == QLatin1String("socks"))
type = ActionTools::Settings::PROXY_TYPE_SOCKS5;
else if(!optionsParser.value(QStringLiteral("proxy-type")).isEmpty())
{
QTextStream stream(stdout);
stream << QObject::tr(R"(Unknown proxy type, values are "http" or "socks" (default))") << "\n";
stream.flush();
optionsParser.showHelp(-1);
}
QNetworkProxy proxy;
if(type == ActionTools::Settings::PROXY_TYPE_HTTP)
proxy.setType(QNetworkProxy::HttpProxy);
else
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(optionsParser.value(QStringLiteral("proxy-host")));
proxy.setPort(static_cast(optionsParser.value(QStringLiteral("proxy-port")).toUInt()));
proxy.setUser(optionsParser.value(QStringLiteral("proxy-user")));
proxy.setPassword(optionsParser.value(QStringLiteral("proxy-password")));
}
break;
}
QNetworkProxy::setApplicationProxy(proxy);
QUrl protocolUrl = QUrl::fromEncoded(positionalArguments.first().toUtf8());
if(protocolUrl.isValid() && protocolUrl.scheme() != QLatin1String("actiona"))
protocolUrl = QUrl();
MainClass::ExecutionMode executionMode = MainClass::Unknown;
MainClass mainClass;
if(protocolUrl.isValid())
{
QString mode;
for(const auto &queryItem: QUrlQuery(protocolUrl.query()).queryItems())
{
if(queryItem.first == QLatin1String("mode"))
{
mode = queryItem.second;
break;
}
}
if(mode == QLatin1String("code"))
executionMode = MainClass::Code;
else if(mode == QLatin1String("script"))
executionMode = MainClass::Script;
else
{
if(protocolUrl.path().endsWith(QStringLiteral(".ascr")))
executionMode = MainClass::Script;
else if(protocolUrl.path().endsWith(QStringLiteral(".acod")))
executionMode = MainClass::Code;
else
{
QTextStream stream(stdout);
stream << QObject::tr("Unknown execution mode, please specify mode=script or mode=code") << "\n";
stream.flush();
optionsParser.showHelp(-1);
}
}
if(!mainClass.start(executionMode, protocolUrl))
return -1;
}
else
{
QString filename = positionalArguments.first();
if(optionsParser.isSet(QStringLiteral("code")))
executionMode = MainClass::Code;
else if(optionsParser.isSet(QStringLiteral("script")))
executionMode = MainClass::Script;
else
{
if(filename.endsWith(QStringLiteral(".ascr")))
executionMode = MainClass::Script;
else if(filename.endsWith(QStringLiteral(".acod")))
executionMode = MainClass::Code;
else
{
QTextStream stream(stdout);
stream << QObject::tr("Unknown execution mode, please specify -s (script) or -c (code)") << "\n";
stream.flush();
optionsParser.showHelp(-1);
}
}
QFile file(filename);
if(!file.open(QIODevice::ReadOnly))
{
QTextStream stream(stdout);
stream << QObject::tr("Unable to read input file") << "\n";
stream.flush();
return -1;
}
if(!mainClass.start(executionMode, &file, file.fileName()))
{
file.close();
return -1;
}
}
return app.exec();
}
actiona-3.10.1/actexecuter/mainclass.cpp 0000664 0000000 0000000 00000004224 13636457430 0020221 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mainclass.h"
#include "codeexecuter.h"
#include "scriptexecuter.h"
#include
#include
#include
#include
#include
#include
MainClass::MainClass()
: QObject(nullptr),
mNetworkAccessManager(new QNetworkAccessManager(this))
{
}
bool MainClass::start(ExecutionMode executionMode, QIODevice *device, const QString &filename)
{
if(executionMode == Script)
mExecuter = new ScriptExecuter(this);
else
mExecuter = new CodeExecuter(this);
return mExecuter->start(device, filename);
}
bool MainClass::start(ExecutionMode executionMode, const QUrl &url)
{
mExecutionMode = executionMode;
mUrl = url;
mUrl.setScheme(QStringLiteral("http"));
mNetworkReply = mNetworkAccessManager->get(QNetworkRequest(mUrl));
connect(mNetworkReply, &QNetworkReply::finished, this, &MainClass::downloadFinished);
return true;
}
void MainClass::downloadFinished()
{
if(mNetworkReply->error() != QNetworkReply::NoError)
{
QTextStream stream(stdout);
stream << QObject::tr("Unable to download the requested file, \"%1\"").arg(mNetworkReply->errorString()) << "\n";
stream.flush();
QApplication::exit(-1);
}
else
{
QByteArray data = mNetworkReply->readAll();
QBuffer buffer(&data);
buffer.open(QIODevice::ReadOnly);
if(!start(mExecutionMode, &buffer, mUrl.toString()))
QApplication::exit(-1);
}
mNetworkReply->close();
mNetworkReply->deleteLater();
mNetworkReply = nullptr;
}
actiona-3.10.1/actexecuter/mainclass.h 0000664 0000000 0000000 00000002516 13636457430 0017670 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "version.h"
#include
#include
class Executer;
class QIODevice;
class QNetworkAccessManager;
class QNetworkReply;
class QTemporaryFile;
class MainClass : public QObject
{
Q_OBJECT
public:
enum ExecutionMode
{
Unknown,
Code,
Script
};
MainClass();
bool start(ExecutionMode executionMode, QIODevice *device, const QString &filename);
bool start(ExecutionMode executionMode, const QUrl &url);
private slots:
void downloadFinished();
private:
Executer *mExecuter{nullptr};
QNetworkAccessManager *mNetworkAccessManager;
QNetworkReply *mNetworkReply;
ExecutionMode mExecutionMode;
QUrl mUrl;
};
actiona-3.10.1/actexecuter/scriptexecuter.cpp 0000664 0000000 0000000 00000005542 13636457430 0021324 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "scriptexecuter.h"
#include "script.h"
#include "executer/executer.h"
#include "mainclass.h"
#include "global.h"
#include
#include
#include
ScriptExecuter::ScriptExecuter(QObject *parent) :
Executer(parent),
mScript(new ActionTools::Script(actionFactory(), this)),
mExecuter(new LibExecuter::Executer(this))
{
connect(mExecuter, &LibExecuter::Executer::executionStopped, this, &ScriptExecuter::executionStopped);
connect(mExecuter, &LibExecuter::Executer::scriptError, this, &ScriptExecuter::scriptError);
}
bool ScriptExecuter::start(QIODevice *device, const QString &filename)
{
if(!Executer::start(device, filename))
return false;
ActionTools::Script::ReadResult result = mScript->read(device, Global::SCRIPT_VERSION);
switch(result)
{
case ActionTools::Script::ReadInternal:
{
QTextStream stream(stdout);
stream << QObject::tr("Reading script file failed due to an internal error") << "\n";
stream.flush();
}
return false;
case ActionTools::Script::ReadInvalidSchema:
{
QTextStream stream(stdout);
stream << QObject::tr("Input script file has an invalid script schema") << "\n";
stream.flush();
}
return false;
case ActionTools::Script::ReadInvalidScriptVersion:
{
QTextStream stream(stdout);
stream << QObject::tr("Input script file is too recent") << "\n";
stream.flush();
}
return false;
default:
break;
}
device->close();
mExecuter->setup(mScript, actionFactory(), false, 0, 0, false, 0, 0, mScript->pauseBefore(), mScript->pauseAfter(), Global::ACTIONA_VERSION, Global::SCRIPT_VERSION, true, nullptr);
if(!mExecuter->startExecution(false, filename))
{
QTextStream stream(stdout);
stream << QObject::tr("Start execution failed") << "\n";
stream.flush();
return false;
}
return true;
}
void ScriptExecuter::executionStopped()
{
QApplication::quit();
}
void ScriptExecuter::scriptError(int actionIndex, const QString ¶meter, const QString &error)
{
Q_UNUSED(actionIndex)
Q_UNUSED(parameter)
QTextStream stream(stdout);
stream << QObject::tr("Execution error: ") << error << "\n";
stream.flush();
QApplication::quit();
}
actiona-3.10.1/actexecuter/scriptexecuter.h 0000664 0000000 0000000 00000002277 13636457430 0020773 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "executer.h"
namespace ActionTools
{
class Script;
}
namespace LibExecuter
{
class Executer;
}
class ScriptExecuter : public Executer
{
Q_OBJECT
public:
explicit ScriptExecuter(QObject *parent = nullptr);
bool start(QIODevice *device, const QString &filename) override;
public slots:
void executionStopped();
void scriptError(int actionIndex, const QString ¶meter, const QString &error);
private:
ActionTools::Script *mScript;
LibExecuter::Executer *mExecuter;
};
actiona-3.10.1/actiona.desktop 0000664 0000000 0000000 00000000637 13636457430 0016244 0 ustar 00root root 0000000 0000000 [Desktop Entry]
Name=Actiona
GenericName=Automation Tool
GenericName[fr]=Outil d'automatisation
Comment=Automate tasks
Comment[fr]=Automatise des tâches
Exec=actiona %f
Terminal=false
Icon=actiona
Type=Application
Categories=Utility;
Version=1.0
MimeType=application/actiona-script;application/actiona-code;application/actionaz-script;application/actionaz-code;
Keywords=automate;bot;macro;script;action;asrc;acod; actiona-3.10.1/actiona.pro 0000664 0000000 0000000 00000002534 13636457430 0015371 0 ustar 00root root 0000000 0000000 TEMPLATE = subdirs
CONFIG = ordered
contains(DEFINES, ACT_NO_UPDATER){
message(** No updater will be built **)
}
contains(DEFINES, ACT_PROFILE){
message(** Profiling activated **)
}
unix:QMAKE_CLEAN += actions/*.so
win32:QMAKE_CLEAN += actions/*.dll
QMAKE_CLEAN += locale/*.qm
isEmpty(QMAKE_LRELEASE) {
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
locale_release.name = lrelease
locale_release.commands = \
$$QMAKE_LRELEASE tools/tools.pro && \
$$QMAKE_LRELEASE actiontools/actiontools.pro && \
$$QMAKE_LRELEASE executer/executer.pro && \
$$QMAKE_LRELEASE actexecuter/actexecuter.pro && \
$$QMAKE_LRELEASE gui/gui.pro && \
$$QMAKE_LRELEASE actions/actionpackinternal/actionpackinternal.pro && \
$$QMAKE_LRELEASE actions/actionpackwindows/actionpackwindows.pro && \
$$QMAKE_LRELEASE actions/actionpackdevice/actionpackdevice.pro && \
$$QMAKE_LRELEASE actions/actionpacksystem/actionpacksystem.pro && \
$$QMAKE_LRELEASE actions/actionpackdata/actionpackdata.pro
locale_release.CONFIG = no_link
QMAKE_EXTRA_TARGETS += locale_release
SUBDIRS += tools \
actiontools \
executer \
gui \
actexecuter \
actions/actionpackinternal \
actions/actionpackwindows \
actions/actionpackdevice \
actions/actionpacksystem \
actions/actionpackdata
actiona-3.10.1/actions/ 0000775 0000000 0000000 00000000000 13636457430 0014665 5 ustar 00root root 0000000 0000000 actiona-3.10.1/actions/actionpackdata/ 0000775 0000000 0000000 00000000000 13636457430 0017633 5 ustar 00root root 0000000 0000000 actiona-3.10.1/actions/actionpackdata/actionpackdata.h 0000664 0000000 0000000 00000010223 13636457430 0022750 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actionpack.h"
#include "actions/writetextfiledefinition.h"
#include "actions/readtextfiledefinition.h"
#include "actions/writeinifiledefinition.h"
#include "actions/readinifiledefinition.h"
#include "actions/readregistrydefinition.h"
#include "actions/writeregistrydefinition.h"
#include "actions/readclipboarddefinition.h"
#include "actions/writeclipboarddefinition.h"
#include "actions/readbinaryfiledefinition.h"
#include "actions/writebinaryfiledefinition.h"
#include "actions/readenvironmentdefinition.h"
#include "actions/copyfiledefinition.h"
#include "actions/webdownloaddefinition.h"
#include "actions/sendmaildefinition.h"
#include "code/file.h"
#include "code/clipboard.h"
#include "code/registry.h"
#include "code/inifile.h"
#include "code/udp.h"
#include "code/tcp.h"
#include "code/sql.h"
#include "code/tcpserver.h"
#include "code/web.h"
#include "code/mailattachment.h"
#include "code/mailmessage.h"
#include "code/mail.h"
#include
namespace ActionTools
{
class ActionDefinition;
}
class ActionPackData : public QObject, public ActionTools::ActionPack
{
Q_OBJECT
Q_INTERFACES(ActionTools::ActionPack)
Q_PLUGIN_METADATA(IID "tools.actiona.ActionPack" FILE "data.json")
public:
ActionPackData() = default;
void createDefinitions() override
{
addActionDefinition(new Actions::WriteTextFileDefinition(this));
addActionDefinition(new Actions::ReadTextFileDefinition(this));
addActionDefinition(new Actions::WriteIniFileDefinition(this));
addActionDefinition(new Actions::ReadIniFileDefinition(this));
addActionDefinition(new Actions::ReadRegistryDefinition(this));
addActionDefinition(new Actions::WriteRegistryDefinition(this));
addActionDefinition(new Actions::ReadClipboardDefinition(this));
addActionDefinition(new Actions::WriteClipboardDefinition(this));
addActionDefinition(new Actions::ReadBinaryFileDefinition(this));
addActionDefinition(new Actions::WriteBinaryFileDefinition(this));
addActionDefinition(new Actions::ReadEnvironmentVariableDefinition(this));
addActionDefinition(new Actions::CopyFileDefinition(this));
addActionDefinition(new Actions::WebDownloadDefinition(this));
addActionDefinition(new Actions::SendMailDefinition(this));
}
QString id() const override { return QStringLiteral("data"); }
QString name() const override { return tr("Data related actions"); }
Tools::Version version() const override { return Tools::Version(0, 0, 1); }
void codeInit(QScriptEngine *scriptEngine) const override
{
addCodeClass(QStringLiteral("File"), scriptEngine);
Code::File::registerClass(scriptEngine);
addCodeClass(QStringLiteral("Clipboard"), scriptEngine);
addCodeClass(QStringLiteral("Registry"), scriptEngine);
addCodeClass(QStringLiteral("IniFile"), scriptEngine);
addCodeClass(QStringLiteral("Udp"), scriptEngine);
addCodeClass(QStringLiteral("Tcp"), scriptEngine);
addCodeClass(QStringLiteral("Sql"), scriptEngine);
Code::Sql::registerClass(scriptEngine);
addCodeClass(QStringLiteral("TcpServer"), scriptEngine);
addCodeClass(QStringLiteral("Web"), scriptEngine);
addCodeClass(QStringLiteral("MailAttachment"), scriptEngine);
addCodeClass(QStringLiteral("MailMessage"), scriptEngine);
addCodeClass(QStringLiteral("Mail"), scriptEngine);
}
private:
Q_DISABLE_COPY(ActionPackData)
};
actiona-3.10.1/actions/actionpackdata/actionpackdata.pro 0000664 0000000 0000000 00000001040 13636457430 0023316 0 ustar 00root root 0000000 0000000 include(../common_actions.pri)
include(actions/actions.pri)
include(code/code.pri)
TARGET = ActionPackData
QT += script network sql widgets
OTHER_FILES += data.json
HEADERS += actionpackdata.h
win32:LIBS += -ladvapi32 \
-lshell32
win32:INCLUDEPATH += $${BOOST_INCLUDE}
TRANSLATIONS = ../../locale/actionpackdata_fr_FR.ts
RESOURCES += \
actionpackdata.qrc
unix {
locales.path = $${PREFIX}/share/actiona/locale
locales.files = ../../locale/actionpackdata_fr_FR.qm
locales.CONFIG = no_check_exist
INSTALLS += locales
}
actiona-3.10.1/actions/actionpackdata/actionpackdata.qrc 0000664 0000000 0000000 00000001214 13636457430 0023306 0 ustar 00root root 0000000 0000000
icons/copyfile.png
icons/readbinary.png
icons/readclipboard.png
icons/readini.png
icons/readregistry.png
icons/readtext.png
icons/writebinary.png
icons/writeclipboard.png
icons/writeini.png
icons/writeregistry.png
icons/writetext.png
icons/webdownload.png
icons/readenvironment.png
icons/sendmail.png
actiona-3.10.1/actions/actionpackdata/actions/ 0000775 0000000 0000000 00000000000 13636457430 0021273 5 ustar 00root root 0000000 0000000 actiona-3.10.1/actions/actionpackdata/actions/actions.pri 0000664 0000000 0000000 00000002463 13636457430 0023454 0 ustar 00root root 0000000 0000000 HEADERS += actions/readtextfiledefinition.h \
actions/readtextfileinstance.h \
actions/writeinifiledefinition.h \
actions/writeinifileinstance.h \
actions/readinifiledefinition.h \
actions/readinifileinstance.h \
actions/readregistryinstance.h \
actions/readregistrydefinition.h \
actions/writeregistrydefinition.h \
actions/writeregistryinstance.h \
actions/readclipboarddefinition.h \
actions/readclipboardinstance.h \
actions/writeclipboarddefinition.h \
actions/writeclipboardinstance.h \
actions/readbinaryfileinstance.h \
actions/readbinaryfiledefinition.h \
actions/writebinaryfileinstance.h \
actions/writebinaryfiledefinition.h \
actions/copyfileinstance.h \
actions/copyfiledefinition.h \
actions/writetextfileinstance.h \
actions/writetextfiledefinition.h \
actions/webdownloaddefinition.h \
actions/webdownloadinstance.h \
actions/readenvironmentdefinition.h \
actions/readenvironmentinstance.h \
actions/sendmaildefinition.h \
actions/sendmailinstance.h
SOURCES += actions/readtextfileinstance.cpp \
actions/readregistryinstance.cpp \
actions/writeregistryinstance.cpp \
actions/writetextfileinstance.cpp \
actions/webdownloadinstance.cpp \
actions/readenvironmentinstance.cpp \
actions/readinifileinstance.cpp \
actions/sendmailinstance.cpp
actiona-3.10.1/actions/actionpackdata/actions/copyfiledefinition.h 0000664 0000000 0000000 00000005273 13636457430 0025336 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "copyfileinstance.h"
#include "fileparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class CopyFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit CopyFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &source = addParameter({QStringLiteral("source"), tr("Source file")});
source.setTooltip(tr("The file to copy"));
source.setMode(ActionTools::FileEdit::FileOpen);
source.setCaption(tr("Choose the file"));
source.setFilter(tr("All files (*.*)"));
auto &destination = addParameter({QStringLiteral("destination"), tr("Destination")});
destination.setTooltip(tr("The destination file"));
destination.setMode(ActionTools::FileEdit::FileSave);
destination.setCaption(tr("Choose the destination file"));
destination.setFilter(tr("All files (*.*)"));
addException(CopyFileInstance::UnableToReadFileException, tr("Unable to read source file"));
addException(CopyFileInstance::UnableToWriteFileException, tr("Unable to write destination file"));
}
QString name() const override { return QObject::tr("Copy file"); }
QString id() const override { return QStringLiteral("ActionCopyFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Copy a file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new CopyFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/copyfile.png")); }
private:
Q_DISABLE_COPY(CopyFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/copyfileinstance.h 0000664 0000000 0000000 00000004365 13636457430 0025013 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "datacopyactioninstance.h"
#include
namespace Actions
{
class CopyFileInstance : public ActionTools::DataCopyActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException,
UnableToWriteFileException
};
CopyFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::DataCopyActionInstance(definition, parent)
{
}
void startExecution() override
{
bool ok = true;
QString sourceFile = evaluateString(ok, QStringLiteral("source"));
QString destinationFile = evaluateString(ok, QStringLiteral("destination"));
if(!ok)
return;
mSourceFile.setFileName(sourceFile);
mDestinationFile.setFileName(destinationFile);
if(!mSourceFile.open(QIODevice::ReadOnly))
{
setCurrentParameter(QStringLiteral("source"));
emit executionException(UnableToReadFileException, tr("Unable to read the source file \"%1\"").arg(sourceFile));
return;
}
if(!mDestinationFile.open(QIODevice::WriteOnly))
{
mSourceFile.close();
setCurrentParameter(QStringLiteral("destination"));
emit executionException(UnableToWriteFileException, tr("Unable to write to \"%1\"").arg(destinationFile));
return;
}
DataCopyActionInstance::startCopy(&mSourceFile, &mDestinationFile);
emit showProgressDialog(tr("Copying file"), 100);
emit updateProgressDialog(tr("Copying in progress"));
}
private:
QFile mSourceFile;
QFile mDestinationFile;
Q_DISABLE_COPY(CopyFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readbinaryfiledefinition.h 0000664 0000000 0000000 00000004771 13636457430 0026506 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "readbinaryfileinstance.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadBinaryFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadBinaryFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &file = addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file to read from"));
file.setMode(ActionTools::FileEdit::FileOpen);
file.setCaption(tr("Choose the file"));
file.setFilter(tr("All files (*.*)"));
auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")});
variable.setTooltip(tr("The variable where to store the data"));
addException(ReadBinaryFileInstance::UnableToReadFileException, tr("Unable to read file"));
}
QString name() const override { return QObject::tr("Read binary file"); }
QString id() const override { return QStringLiteral("ActionReadBinaryFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Read a binary file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new ReadBinaryFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readbinary.png")); }
private:
Q_DISABLE_COPY(ReadBinaryFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readbinaryfileinstance.h 0000664 0000000 0000000 00000004231 13636457430 0026151 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "datacopyactioninstance.h"
#include "code/rawdata.h"
#include
#include
namespace Actions
{
class ReadBinaryFileInstance : public ActionTools::DataCopyActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException
};
ReadBinaryFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::DataCopyActionInstance(definition, parent)
{
}
void startExecution() override
{
bool ok = true;
QString filename = evaluateString(ok, QStringLiteral("file"));
mVariable = evaluateVariable(ok, QStringLiteral("variable"));
if(!ok)
return;
mFile.setFileName(filename);
if(!DataCopyActionInstance::startCopy(&mFile, &mResult))
{
setCurrentParameter(QStringLiteral("file"));
emit executionException(UnableToReadFileException, tr("Unable to read the file \"%1\"").arg(filename));
return;
}
emit showProgressDialog(tr("Reading file"), 100);
emit updateProgressDialog(tr("Reading in progress"));
}
private slots:
void done() override
{
setVariable(mVariable, Code::RawData::constructor(mResult.buffer(), scriptEngine()));
DataCopyActionInstance::done();
}
private:
void clean() override
{
DataCopyActionInstance::clean();
mResult.buffer().clear();
}
QFile mFile;
QBuffer mResult;
QString mVariable;
Q_DISABLE_COPY(ReadBinaryFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readclipboarddefinition.h 0000664 0000000 0000000 00000004133 13636457430 0026311 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "readclipboardinstance.h"
#include "textparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadClipboardDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadClipboardDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &output = addParameter({QStringLiteral("variable"), tr("Variable")});
output.setTooltip(tr("The variable where to save the current clipboard value"));
}
QString name() const override { return QObject::tr("Read clipboard"); }
QString id() const override { return QStringLiteral("ActionReadClipboard"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Read the clipboard contents"); }
ActionTools::ActionInstance *newActionInstance() const override { return new ReadClipboardInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readclipboard.png")); }
private:
Q_DISABLE_COPY(ReadClipboardDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readclipboardinstance.h 0000664 0000000 0000000 00000002631 13636457430 0025766 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "script.h"
#include
#include
namespace Actions
{
class ReadClipboardInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
ReadClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution() override
{
bool ok = true;
QString variable = evaluateVariable(ok, QStringLiteral("variable"));
if(!ok)
return;
QClipboard *clipboard = QApplication::clipboard();
setVariable(variable, clipboard->text());
executionEnded();
}
private:
Q_DISABLE_COPY(ReadClipboardInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readenvironmentdefinition.h 0000664 0000000 0000000 00000006431 13636457430 0026721 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "readenvironmentinstance.h"
#include "variableparameterdefinition.h"
#include "listparameterdefinition.h"
#include "environmentvariableparameterdefinition.h"
#include "groupdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadEnvironmentVariableDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadEnvironmentVariableDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("ReadEnvironmentVariableInstance::modes", ReadEnvironmentVariableInstance::modes);
auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")});
variable.setTooltip(tr("The variable used to store the selected information from your system environment"));
auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")});
mode.setTooltip(tr("The environment read mode"));
mode.setItems(ReadEnvironmentVariableInstance::modes);
mode.setDefaultValue(ReadEnvironmentVariableInstance::modes.second.at(ReadEnvironmentVariableInstance::oneVariableMode));
auto &selectionMode = addGroup();
selectionMode.setMasterList(mode);
selectionMode.setMasterValues({ReadEnvironmentVariableInstance::modes.first.at(ReadEnvironmentVariableInstance::oneVariableMode)});
auto &environmentVariableName = selectionMode.addParameter({QStringLiteral("environmentVariableName"), tr("Environment Variable")});
environmentVariableName.setTooltip(tr("The specific environment variable to read"));
}
QString name() const override { return QObject::tr("Read environment variable"); }
QString id() const override { return QStringLiteral("ActionReadEnvironmentVariable"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Read a single or multiple environment variables"); }
ActionTools::ActionInstance *newActionInstance() const override { return new ReadEnvironmentVariableInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readenvironment.png")); }
private:
Q_DISABLE_COPY(ReadEnvironmentVariableDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readenvironmentinstance.cpp 0000664 0000000 0000000 00000005060 13636457430 0026725 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readenvironmentinstance.h"
#include
#include
#include
#include
#include
namespace Actions
{
Tools::StringListPair ReadEnvironmentVariableInstance::modes =
{
{
QStringLiteral("allVariables"),
QStringLiteral("oneVariable")
},
{
QStringLiteral(QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read all")),
QStringLiteral(QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read one"))
}
};
void ReadEnvironmentVariableInstance::startExecution()
{
bool ok = true;
QString variable = evaluateVariable(ok, QStringLiteral("variable"));
Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode"));
if(!ok)
return;
const QStringList &environment = QProcessEnvironment::systemEnvironment().toStringList();
QHash environmentHashVariableValue;
environmentHashVariableValue.reserve(environment.count()+2); //doc said ideally 'slightly more than the maximum nb of item'
for(QString environmentVariableAndValue: environment)
{
QStringList KeyValue = environmentVariableAndValue.split(QStringLiteral("="));
environmentHashVariableValue[KeyValue.at(0)] = KeyValue.at(1);
}
if(mode == oneVariableMode)
{
QString environmentVariable = evaluateString(ok, QStringLiteral("environmentVariableName"));
if (environmentHashVariableValue.contains(environmentVariable))
setVariable(variable, environmentHashVariableValue.value(environmentVariable));
else
{
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The specified variable cannot be found in the system environment"));
return;
}
}
else
setArrayKeyValue(variable, environmentHashVariableValue);
executionEnded();
}
}
actiona-3.10.1/actions/actionpackdata/actions/readenvironmentinstance.h 0000664 0000000 0000000 00000002426 13636457430 0026375 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "script.h"
namespace Actions
{
class ReadEnvironmentVariableInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
allVariablesMode,
oneVariableMode
};
ReadEnvironmentVariableInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
static Tools::StringListPair modes;
void startExecution() override;
private:
Q_DISABLE_COPY(ReadEnvironmentVariableInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readinifiledefinition.h 0000664 0000000 0000000 00000007341 13636457430 0025775 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "readinifileinstance.h"
#include "textparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
#include "listparameterdefinition.h"
#include "groupdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadIniFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadIniFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("ReadIniFileInstance::modes", ReadIniFileInstance::modes);
auto &file = addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file to read from"));
file.setMode(ActionTools::FileEdit::FileOpen);
file.setCaption(tr("Choose the INI file"));
file.setFilter(tr("INI files (*.ini);;All files (*.*)"));
auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")});
variable.setTooltip(tr("The variable where to store the data"));
auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")});
mode.setTooltip(tr("The INI file read mode"));
mode.setItems(ReadIniFileInstance::modes);
mode.setDefaultValue(ReadIniFileInstance::modes.second.at(ReadIniFileInstance::SingleParameter));
auto &selectionMode = addGroup();
selectionMode.setMasterList(mode);
selectionMode.setMasterValues({ReadIniFileInstance::modes.first.at(ReadIniFileInstance::SingleParameter)});
auto §ion = selectionMode.addParameter({QStringLiteral("section"), tr("Section")});
section.setTooltip(tr("The parameter section"));
auto ¶meter = selectionMode.addParameter({QStringLiteral("parameter"), tr("Parameter")});
parameter.setTooltip(tr("The parameter name"));
addException(ReadIniFileInstance::UnableToReadFileException, tr("Unable to read file"));
addException(ReadIniFileInstance::UnableToFindSectionException, tr("Unable to find section"));
}
QString name() const override { return QObject::tr("Read INI file"); }
QString id() const override { return QStringLiteral("ActionReadIniFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Read one or all the entries in an INI file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new ReadIniFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readini.png")); }
private:
Q_DISABLE_COPY(ReadIniFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readinifileinstance.cpp 0000664 0000000 0000000 00000007063 13636457430 0026005 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readinifileinstance.h"
#include "stringlistpair.h"
#include
#include
namespace Actions
{
Tools::StringListPair ReadIniFileInstance::modes =
{
{
QStringLiteral("singleParameter"),
QStringLiteral("wholeFile")
},
{
QStringLiteral(QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read a single parameter")),
QStringLiteral(QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read the entire file"))
}
};
void ReadIniFileInstance::startExecution()
{
bool ok = true;
QString filename = evaluateString(ok, QStringLiteral("file"));
QString variable = evaluateVariable(ok, QStringLiteral("variable"));
Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode"));
if(!ok)
return;
if(filename.isEmpty())
{
emit executionException(UnableToReadFileException, tr("Unable to read the file"));
return;
}
boost::property_tree::ptree tree;
try
{
boost::property_tree::ini_parser::read_ini(filename.toStdString(), tree);
}
catch(const std::runtime_error &)
{
setCurrentParameter(QStringLiteral("filename"));
emit executionException(UnableToReadFileException, tr("Unable to read the file"));
return;
}
if(mode == WholeFile)
{
QHash fileContent;
for(const auto §ion: tree)
{
for(const auto ¶meter: section.second)
{
fileContent[QString::fromStdString(section.first + "/" + parameter.first)] = QString::fromStdString(parameter.second.get_value());
}
}
setArrayKeyValue(variable, fileContent);
}
else
{
QString section = evaluateString(ok, QStringLiteral("section"));
QString parameter = evaluateString(ok, QStringLiteral("parameter"));
if(!ok)
return;
auto sectionNode = tree.get_child_optional(section.toStdString());
if(!sectionNode)
{
setCurrentParameter(QStringLiteral("section"));
emit executionException(UnableToFindSectionException, tr("Unable to find the section named \"%1\"").arg(section));
return;
}
try
{
setVariable(variable, QString::fromStdString((*sectionNode).get(parameter.toStdString())));
}
catch(const std::runtime_error &)
{
setCurrentParameter(QStringLiteral("parameter"));
emit executionException(UnableToFindSectionException, tr("Unable to find the parameter named \"%1\"").arg(parameter));
return;
}
}
executionEnded();
}
}
actiona-3.10.1/actions/actionpackdata/actions/readinifileinstance.h 0000664 0000000 0000000 00000002546 13636457430 0025453 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
namespace Actions
{
class ReadIniFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
SingleParameter,
WholeFile
};
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException,
UnableToFindSectionException
};
ReadIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
static Tools::StringListPair modes;
void startExecution() override;
private:
Q_DISABLE_COPY(ReadIniFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readregistrydefinition.h 0000664 0000000 0000000 00000006125 13636457430 0026225 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "readregistryinstance.h"
#include "listparameterdefinition.h"
#include "textparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadRegistryDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadRegistryDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &key = addParameter({QStringLiteral("key"), tr("Key")});
key.setTooltip(tr("The registry key to read from"));
key.setItems(ReadRegistryInstance::keys);
key.setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser));
auto &subKey = addParameter({QStringLiteral("subKey"), tr("Subkey")});
subKey.setTooltip(tr("The registry subkey to read from"));
auto &value = addParameter({QStringLiteral("value"), tr("Value")});
value.setTooltip(tr("The value to read"));
auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")});
variable.setTooltip(tr("The variable where to save the value read from the registry"));
addException(ReadRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey"));
addException(ReadRegistryInstance::CannotFindValueException, tr("Cannot find value"));
addException(ReadRegistryInstance::InvalidValueType, tr("Invalid value type"));
}
QString name() const override { return QObject::tr("Read registry"); }
QString id() const override { return QStringLiteral("ActionReadRegistry"); }
ActionTools::Flag flags() const override { return ActionTools::WorksOnWindows | ActionTools::Official; }
QString description() const override { return QObject::tr("Read an entry from the registry"); }
ActionTools::ActionInstance *newActionInstance() const override { return new ReadRegistryInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readregistry.png")); }
private:
Q_DISABLE_COPY(ReadRegistryDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readregistryinstance.cpp 0000664 0000000 0000000 00000005231 13636457430 0026231 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readregistryinstance.h"
#include
#ifdef Q_OS_WIN
#include
#endif
namespace Actions
{
Tools::StringListPair ReadRegistryInstance::keys =
{
{
QStringLiteral("classesRoot"),
QStringLiteral("currentConfig"),
QStringLiteral("currentUser"),
QStringLiteral("users"),
QStringLiteral("localMachine")
},
{
QStringLiteral("Classes root"),
QStringLiteral("Current config"),
QStringLiteral("Current user"),
QStringLiteral("Users"),
QStringLiteral("Local machine")
}
};
//Note : This is not translated, because this is not translated either in Regedit
void ReadRegistryInstance::startExecution()
{
#ifdef Q_OS_WIN
bool ok = true;
ActionTools::Registry::Key key = evaluateListElement(ok, keys, QStringLiteral("key"));
QString subKey = evaluateString(ok, QStringLiteral("subKey"));
QString value = evaluateString(ok, QStringLiteral("value"));
QString variable = evaluateVariable(ok, QStringLiteral("variable"));
if(!ok)
return;
QVariant resultValue;
switch(ActionTools::Registry::read(resultValue, key, subKey, value))
{
case ActionTools::Registry::ReadCannotFindSubKey:
setCurrentParameter(QStringLiteral("subKey"));
emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey));
return;
case ActionTools::Registry::ReadCannotFindValue:
setCurrentParameter(QStringLiteral("value"));
emit executionException(CannotFindValueException, tr("Cannot find value \"%1\"").arg(value));
return;
case ActionTools::Registry::ReadInvalidValueType:
setCurrentParameter(QStringLiteral("value"));
emit executionException(CannotFindValueException, tr("Invalid value type"));
return;
default:
setVariable(variable, scriptEngine()->newVariant(resultValue));
break;
}
#endif
executionEnded();
}
}
actiona-3.10.1/actions/actionpackdata/actions/readregistryinstance.h 0000664 0000000 0000000 00000002513 13636457430 0025676 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "stringlistpair.h"
#include "registry.h"
namespace Actions
{
class ReadRegistryInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
CannotFindSubKeyException = ActionTools::ActionException::UserException,
CannotFindValueException,
InvalidValueType
};
ReadRegistryInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
static Tools::StringListPair keys;
void startExecution() override;
private:
Q_DISABLE_COPY(ReadRegistryInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readtextfiledefinition.h 0000664 0000000 0000000 00000007405 13636457430 0026203 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "readtextfileinstance.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
#include "numberparameterdefinition.h"
#include "listparameterdefinition.h"
#include "groupdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadTextFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadTextFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("ReadTextFileInstance::modes", ReadTextFileInstance::modes);
auto &file = addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file you want to read"));
auto &variable = addParameter({QStringLiteral("variable"), tr("Variable")});
variable.setTooltip(tr("The variable where to save the text read from the file"));
auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")}, 1);
mode.setTooltip(tr("The file read mode"));
mode.setItems(ReadTextFileInstance::modes);
mode.setDefaultValue(ReadTextFileInstance::modes.second.at(ReadTextFileInstance::Full));
auto &selectionMode = addGroup(1);
selectionMode.setMasterList(mode);
selectionMode.setMasterValues({ReadTextFileInstance::modes.first.at(ReadTextFileInstance::Selection)});
auto &firstline = selectionMode.addParameter({QStringLiteral("firstline"), tr("First line")}, 1);
firstline.setTooltip(tr("The line where to start reading the file"));
firstline.setMinimum(1);
firstline.setDefaultValue(QStringLiteral("1"));
auto &lastline = selectionMode.addParameter({QStringLiteral("lastline"), tr("Last line")}, 1);
lastline.setTooltip(tr("The line where to stop reading the file"));
lastline.setMinimum(1);
lastline.setDefaultValue(QStringLiteral("1"));
addException(ReadTextFileInstance::CannotOpenFileException, tr("Cannot read file"));
}
QString name() const override { return QObject::tr("Read text file"); }
QString id() const override { return QStringLiteral("ActionReadTextFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Read a plain text file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new ReadTextFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/readtext.png")); }
QStringList tabs() const override { return ActionDefinition::StandardTabs; }
private:
Q_DISABLE_COPY(ReadTextFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/readtextfileinstance.cpp 0000664 0000000 0000000 00000006113 13636457430 0026205 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readtextfileinstance.h"
#include
#include
namespace Actions
{
Tools::StringListPair ReadTextFileInstance::modes =
{
{
QStringLiteral("full"), QStringLiteral("selection")
},
{
QStringLiteral(QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read the entire file")), QStringLiteral(QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read only a selection"))
}
};
void ReadTextFileInstance::startExecution()
{
bool ok = true;
QString filepath = evaluateString(ok, QStringLiteral("file"));
QString variable = evaluateVariable(ok, QStringLiteral("variable"));
Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode"));
int firstline = evaluateInteger(ok, QStringLiteral("firstline"));
int lastline = evaluateInteger(ok, QStringLiteral("lastline"));
if(!ok)
return;
if(mode == Selection)
{
if(firstline < 1)
{
setCurrentParameter(QStringLiteral("firstline"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid first line value : %1").arg(firstline));
return;
}
if(lastline < 1)
{
setCurrentParameter(QStringLiteral("lastline"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid last line value : %1").arg(lastline));
return;
}
if(lastline < firstline)
{
setCurrentParameter(QStringLiteral("firstline"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The first line has to be smaller than the last line"));
return;
}
}
QFile file(filepath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
setCurrentParameter(QStringLiteral("file"));
emit executionException(CannotOpenFileException, tr("Cannot open file"));
return;
}
//Line counting starts at 1
--firstline;
--lastline;
QString result;
QTextStream stream(&file);
stream.setAutoDetectUnicode(true);
if(mode == Full)
result = stream.readAll();
else
{
for(int line = 0; !stream.atEnd(); ++line)
{
QString readLine = stream.readLine();
if(line >= firstline && line <= lastline)
{
if(!result.isEmpty())
result += QLatin1Char('\n');
result += readLine;
}
if(line > lastline)
break;
}
}
setVariable(variable, result);
file.close();
executionEnded();
}
}
actiona-3.10.1/actions/actionpackdata/actions/readtextfileinstance.h 0000664 0000000 0000000 00000002475 13636457430 0025661 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "stringlistpair.h"
namespace Actions
{
class ReadTextFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
Full,
Selection
};
enum Exceptions
{
CannotOpenFileException = ActionTools::ActionException::UserException
};
ReadTextFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
static Tools::StringListPair modes;
void startExecution() override;
private:
Q_DISABLE_COPY(ReadTextFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/sendmaildefinition.h 0000664 0000000 0000000 00000014637 13636457430 0025324 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "sendmailinstance.h"
#include "textparameterdefinition.h"
#include "booleanparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "listparameterdefinition.h"
#include "numberparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class SendMailDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit SendMailDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("SendMailInstance::attachmentContentTypes", SendMailInstance::attachmentContentTypes);
auto &serverName = addParameter({QStringLiteral("serverName"), tr("Server name")});
serverName.setTooltip(tr("The name or IP of the SMTP server to use\nExample: mail.example.com"));
auto &secureConnection = addParameter({QStringLiteral("secureConnection"), tr("Secure connection")});
secureConnection.setTooltip(tr("Secure (encrypted) connection to the server"));
secureConnection.setDefaultValue(QStringLiteral("true"));
auto &userName = addParameter({QStringLiteral("userName"), tr("User name")});
userName.setTooltip(tr("The user (or login) name to use\nMany SMTP servers use the e-mail address as user name"));
auto &password = addParameter({QStringLiteral("password"), tr("Password")});
password.setTooltip(tr("The password to use"));
auto &sender = addParameter({QStringLiteral("sender"), tr("Sender")});
sender.setTooltip(tr("The sender's e-mail address"));
auto &receivers = addParameter({QStringLiteral("receivers"), tr("Receivers")});
receivers.setTooltip(tr("The receiver's e-mail address\nCan contain multiple receivers separated with a comma"));
auto &subject = addParameter({QStringLiteral("subject"), tr("Subject")});
subject.setTooltip(tr("The e-mail's subject"));
auto &body = addParameter({QStringLiteral("body"), tr("Body")});
body.setTooltip(tr("The e-mail's body"));
auto &attachmentName = addParameter({QStringLiteral("attachmentName"), tr("Attachment name")}, 1);
attachmentName.setTooltip(tr("The attachment name, an empty name means that there is no attachment"));
auto &attachmentData = addParameter({QStringLiteral("attachmentData"), tr("Attachment data")}, 1);
attachmentData.setTooltip(tr("The data to attach to the e-mail"));
auto &attachmentContentType = addParameter({QStringLiteral("attachmentContentType"), tr("Attachment content type")}, 1);
attachmentContentType.setTooltip(tr("The MIME content type of the attachment\nIf left empty, Actiona will try to deduce it from the data type"));
attachmentContentType.setItems(SendMailInstance::attachmentContentTypes);
attachmentContentType.setDefaultValue(SendMailInstance::attachmentContentTypes.second.at(SendMailInstance::AutoDetectAttachmentContentType));
auto &carbonCopy = addParameter({QStringLiteral("carbonCopy"), tr("Carbon copy (Cc)")}, 2);
carbonCopy.setTooltip(tr("The carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma"));
auto &blindCarbonCopy = addParameter({QStringLiteral("blindCarbonCopy"), tr("Blind carbon copy (Bcc)")}, 2);
blindCarbonCopy.setTooltip(tr("The blind carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma"));
auto &serverPort = addParameter({QStringLiteral("serverPort"), tr("Server port")}, 2);
serverPort.setTooltip(tr("The server port"));
serverPort.setMinimum(0);
serverPort.setMaximum(65535);
serverPort.setDefaultValue(QStringLiteral("0"));
serverPort.setSpecialValueText(tr("Default port"));
auto &extraHeaders = addParameter({QStringLiteral("extraHeaders"), tr("Extra headers")}, 2);
extraHeaders.setTooltip(tr("Extra headers to add to the e-mail\nShould contain one header per line"));
addException(SendMailInstance::ConnectionErrorException, tr("Connection error"));
addException(SendMailInstance::ErrorWhileSendingEMailException, tr("Error while sending e-mail"));
}
QString name() const override { return QObject::tr("Send e-mail"); }
QString id() const override { return QStringLiteral("ActionSendMail"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Sends an e-mail"); }
ActionTools::ActionInstance *newActionInstance() const override { return new SendMailInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/sendmail.png")); }
QStringList tabs() const override { return {ActionDefinition::StandardTabs.at(0), tr("Attachment"), ActionDefinition::StandardTabs.at(1)}; }
private:
Q_DISABLE_COPY(SendMailDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/sendmailinstance.cpp 0000664 0000000 0000000 00000034724 13636457430 0025332 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "sendmailinstance.h"
#include "code/rawdata.h"
#include "code/image.h"
#include "qxtsmtp/qxtsmtp.h"
#include "qxtsmtp/qxtmailmessage.h"
#include "qxtsmtp/qxtmailattachment.h"
#include
#include
#include
#include
#include
#include
#include
namespace Actions
{
Tools::StringListPair SendMailInstance::attachmentContentTypes =
{
{
QStringLiteral("autoDetect"),
QStringLiteral("application/octet-stream"),
QStringLiteral("text/plain"),
QStringLiteral("image/jpeg"),
QStringLiteral("image/png")
},
{
QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Auto detect")),
QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Binary")),
QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Text")),
QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Jpg image")),
QStringLiteral(QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Png image"))
}
};
SendMailInstance::SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent)
: ActionTools::ActionInstance(definition, parent),
mSmtp(nullptr),
mProgressDialog(new QProgressDialog)
{
}
SendMailInstance::~SendMailInstance()
{
delete mProgressDialog;
}
void SendMailInstance::startExecution()
{
bool ok = true;
QString serverName = evaluateString(ok, QStringLiteral("serverName"));
bool secureConnection = evaluateBoolean(ok, QStringLiteral("secureConnection"));
QString userName = evaluateString(ok, QStringLiteral("userName"));
QString password = evaluateString(ok, QStringLiteral("password"));
QString sender = evaluateString(ok, QStringLiteral("sender"));
QString receivers = evaluateString(ok, QStringLiteral("receivers"));
QString subject = evaluateString(ok, QStringLiteral("subject"));
QString body = evaluateString(ok, QStringLiteral("body"));
QString attachmentName = evaluateString(ok, QStringLiteral("attachmentName"));
QScriptValue attachmentData = evaluateValue(ok, QStringLiteral("attachmentData"));
QString attachmentContentType = evaluateEditableListElement(ok, attachmentContentTypes, QStringLiteral("attachmentContentType"));
QString carbonCopy = evaluateString(ok, QStringLiteral("carbonCopy"));
QString blindCarbonCopy = evaluateString(ok, QStringLiteral("blindCarbonCopy"));
int serverPort = evaluateInteger(ok, QStringLiteral("serverPort"));
QString extraHeaders = evaluateString(ok, QStringLiteral("extraHeaders"));
if(serverName.isEmpty() || sender.isEmpty() || receivers.isEmpty())
{
executionEnded();
return;
}
if(attachmentContentType == QLatin1String("autoDetect") && !attachmentName.isEmpty() && attachmentData.isValid())
{
bool foundAttachmentContentType = true;
if(QObject *scriptObject = attachmentData.toQObject())
{
if(qobject_cast(scriptObject))
attachmentContentType = QStringLiteral("application/octet-stream");
else if(qobject_cast(scriptObject))
{
QString lowerAttachmentName = attachmentName.toLower();
if(lowerAttachmentName.endsWith(QStringLiteral(".jpg")) || lowerAttachmentName.endsWith(QStringLiteral(".jpeg")))
attachmentContentType = QStringLiteral("image/jpeg");
else
attachmentContentType = QStringLiteral("image/png");
}
else
foundAttachmentContentType = false;
}
else if(attachmentData.isString())
attachmentContentType = QStringLiteral("text/plain");
else
foundAttachmentContentType = false;
if(!foundAttachmentContentType)
{
setCurrentParameter(QStringLiteral("attachmentContentType"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Failed to auto detect the attachment content type"));
return;
}
}
validateParameterRange(ok, serverPort, QStringLiteral("serverPort"), tr("server port"), 0, 65535);
if(!ok)
return;
mSmtp = new QxtSmtp(this);
connect(mSmtp, static_cast(&QxtSmtp::connectionFailed), this, &SendMailInstance::connectionFailed);
connect(mSmtp, static_cast(&QxtSmtp::encryptionFailed), this, &SendMailInstance::encryptionFailed);
connect(mSmtp, static_cast(&QxtSmtp::authenticationFailed), this, &SendMailInstance::authenticationFailed);
connect(mSmtp, &QxtSmtp::authenticated, this, &SendMailInstance::authenticated);
connect(mSmtp, static_cast(&QxtSmtp::senderRejected), this, &SendMailInstance::senderRejected);
connect(mSmtp, static_cast(&QxtSmtp::recipientRejected), this, &SendMailInstance::recipientRejected);
connect(mSmtp, static_cast(&QxtSmtp::mailFailed), this, &SendMailInstance::mailFailed);
connect(mSmtp, &QxtSmtp::mailSent, this, &SendMailInstance::mailSent);
connect(mSmtp, &QxtSmtp::disconnected, this, &SendMailInstance::disconnected);
connect(mProgressDialog, &QProgressDialog::canceled, this, &SendMailInstance::canceled);
mSmtp->setUsername(userName.toUtf8());
mSmtp->setPassword(password.toUtf8());
QxtMailMessage mailMessage;
mailMessage.setSender(sender);
mailMessage.setSubject(subject);
mailMessage.setBody(body);
mailMessage.setExtraHeader(QStringLiteral("Date"), QDateTime::currentDateTime().toString(Qt::RFC2822Date));
for(QString receiver: receivers.split(QLatin1Char(','), QString::SkipEmptyParts))
mailMessage.addRecipient(receiver.trimmed());
for(QString carbonCopyReceiver: carbonCopy.split(QLatin1Char(','), QString::SkipEmptyParts))
mailMessage.addRecipient(carbonCopyReceiver.trimmed(), QxtMailMessage::Cc);
for(QString blindCarbonCopyReceiver: blindCarbonCopy.split(QLatin1Char(','), QString::SkipEmptyParts))
mailMessage.addRecipient(blindCarbonCopyReceiver.trimmed(), QxtMailMessage::Bcc);
for(QString extraHeader: extraHeaders.split(QLatin1Char('\n'), QString::SkipEmptyParts))
{
QStringList extraHeaderParts = extraHeader.split(QLatin1Char(':'), QString::SkipEmptyParts);
if(extraHeaderParts.size() != 2)
{
setCurrentParameter(QStringLiteral("extraHeaders"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr(R"(Failed to parse an extra header: "%1" has to be in the form "name: value")").arg(extraHeader));
return;
}
mailMessage.setExtraHeader(extraHeaderParts[0].trimmed(), extraHeaderParts[1]);
}
if(!attachmentName.isEmpty())
{
if(!attachmentData.isValid())
{
setCurrentParameter(QStringLiteral("attachmentData"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid attachment data"));
return;
}
QByteArray attachmentDataByteArray;
if(QObject *scriptObject = attachmentData.toQObject())
{
if(auto codeRawData = qobject_cast(scriptObject))
attachmentDataByteArray = codeRawData->byteArray();
else if(auto codeImage = qobject_cast(scriptObject))
{
QImage image = codeImage->image();
QString format;
if(attachmentContentType == QLatin1String("image/png"))
format = QStringLiteral("PNG");
else if(attachmentContentType == QLatin1String("image/jpeg"))
format = QStringLiteral("JPG");
else
{
setCurrentParameter(QStringLiteral("attachmentData"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Unknown image type; supported types are PNG and JPG"));
return;
}
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
if(!image.save(&buffer, format.toLatin1().constData()))
{
setCurrentParameter(QStringLiteral("attachmentData"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid image data"));
return;
}
attachmentDataByteArray = buffer.buffer();
}
else
attachmentDataByteArray = attachmentData.toString().toUtf8();
}
else
{
if(attachmentContentType == QLatin1String("text/plain"))
attachmentDataByteArray = attachmentData.toString().toUtf8();
else
attachmentDataByteArray = attachmentData.toVariant().toByteArray();
}
mailMessage.addAttachment(attachmentName, QxtMailAttachment(attachmentDataByteArray, attachmentContentType));
}
if(serverPort == 0)
{
if(secureConnection)
mSmtp->connectToSecureHost(serverName);
else
mSmtp->connectToHost(serverName);
}
else
{
if(secureConnection)
mSmtp->connectToSecureHost(serverName, serverPort);
else
mSmtp->connectToHost(serverName, serverPort);
}
mSmtp->send(mailMessage);
mProgressDialog->setModal(false);
mProgressDialog->setWindowTitle(tr("Sending e-mail"));
mProgressDialog->setLabelText(tr("Connecting..."));
mProgressDialog->setMaximum(2);
mProgressDialog->show();
}
void SendMailInstance::stopExecution()
{
cleanup();
}
void SendMailInstance::connectionFailed(const QByteArray &msg)
{
cleanup();
emit executionException(ConnectionErrorException, tr("Connection failed: %1").arg(QString::fromUtf8(msg)));
}
void SendMailInstance::encryptionFailed(const QByteArray &msg)
{
cleanup();
emit executionException(ConnectionErrorException, tr("Encryption failed: %1").arg(QString::fromUtf8(msg)));
}
void SendMailInstance::authenticationFailed(const QByteArray &msg)
{
cleanup();
emit executionException(ConnectionErrorException, tr("Authentication failed: %1").arg(QString::fromUtf8(msg)));
}
void SendMailInstance::authenticated()
{
mProgressDialog->setValue(1);
mProgressDialog->setLabelText(tr("Sending e-mail..."));
}
void SendMailInstance::senderRejected(int mailID, const QString &address, const QByteArray &msg)
{
Q_UNUSED(mailID)
cleanup();
emit executionException(ErrorWhileSendingEMailException, tr("Sender %1 has been rejected: %2").arg(address).arg(QString::fromUtf8(msg)));
}
void SendMailInstance::recipientRejected(int mailID, const QString &address, const QByteArray &msg)
{
Q_UNUSED(mailID)
cleanup();
emit executionException(ErrorWhileSendingEMailException, tr("Recipient %1 has been rejected: %2").arg(address).arg(QString::fromUtf8(msg)));
}
void SendMailInstance::mailFailed(int mailID, int errorCode, const QByteArray &msg)
{
Q_UNUSED(mailID)
cleanup();
QString errorString;
switch(errorCode)
{
case QxtSmtp::NoRecipients:
errorString = tr("No recipients");
break;
case QxtSmtp::CommandUnrecognized:
errorString = tr("Command unrecognized");
break;
case QxtSmtp::SyntaxError:
errorString = tr("Syntax error");
break;
case QxtSmtp::CommandNotImplemented:
errorString = tr("Command not implemented");
break;
case QxtSmtp::BadSequence:
errorString = tr("Bad sequence");
break;
case QxtSmtp::ParameterNotImplemented:
errorString = tr("Parameter not implemented");
break;
case QxtSmtp::MailboxUnavailable:
errorString = tr("Mailbox unavailable");
break;
case QxtSmtp::UserNotLocal:
errorString = tr("User not local");
break;
case QxtSmtp::MessageTooLarge:
errorString = tr("Message is too large");
break;
case QxtSmtp::InvalidMailboxName:
errorString = tr("Invalid mailbox name");
break;
case QxtSmtp::TransactionFailed:
errorString = tr("Transaction failed");
break;
default:
errorString = tr("Unknown error");
break;
}
emit executionException(ErrorWhileSendingEMailException, tr("Failed sending e-mail: %1 (%2)").arg(errorString).arg(QString::fromUtf8(msg)));
}
void SendMailInstance::mailSent(int mailID)
{
Q_UNUSED(mailID)
cleanup();
executionEnded();
}
void SendMailInstance::disconnected()
{
mSmtp->deleteLater();
}
void SendMailInstance::canceled()
{
cleanup();
executionEnded();
}
void SendMailInstance::cleanup()
{
mSmtp->disconnect();
mSmtp->disconnectFromHost();
mProgressDialog->disconnect();
mProgressDialog->close();
}
}
actiona-3.10.1/actions/actionpackdata/actions/sendmailinstance.h 0000664 0000000 0000000 00000004464 13636457430 0024775 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "script.h"
#include "stringlistpair.h"
class QxtSmtp;
class QProgressDialog;
namespace Actions
{
class SendMailInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(AttachmentContentType)
public:
enum AttachmentContentType
{
AutoDetectAttachmentContentType,
BinaryAttachmentContentType,
TextAttachmentContentType,
JpgImageAttachmentContentType,
PngImageAttachmentContentType
};
enum Exceptions
{
ConnectionErrorException = ActionTools::ActionException::UserException,
ErrorWhileSendingEMailException
};
SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr);
~SendMailInstance() override;
static Tools::StringListPair attachmentContentTypes;
void startExecution() override;
void stopExecution() override;
private slots:
void connectionFailed(const QByteArray &msg);
void encryptionFailed(const QByteArray &msg);
void authenticationFailed(const QByteArray &msg);
void authenticated();
void senderRejected(int mailID, const QString &address, const QByteArray &msg);
void recipientRejected(int mailID, const QString &address, const QByteArray &msg);
void mailFailed(int mailID, int errorCode, const QByteArray &msg);
void mailSent(int mailID);
void disconnected();
void canceled();
private:
Q_DISABLE_COPY(SendMailInstance)
void cleanup();
QxtSmtp *mSmtp;
QProgressDialog *mProgressDialog;
};
}
actiona-3.10.1/actions/actionpackdata/actions/webdownloaddefinition.h 0000664 0000000 0000000 00000010316 13636457430 0026023 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "webdownloadinstance.h"
#include "textparameterdefinition.h"
#include "listparameterdefinition.h"
#include "variableparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "groupdefinition.h"
#include "booleanparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WebDownloadDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WebDownloadDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("WebDownloadInstance::destinations", WebDownloadInstance::destinations);
auto &url = addParameter({QStringLiteral("url"), tr("URL")});
url.setTooltip(tr("The URL of the data to download"));
auto &destination = addParameter({QStringLiteral("destination"), tr("Destination")});
destination.setTooltip(tr("The destination where to write the downloaded data"));
destination.setItems(WebDownloadInstance::destinations);
destination.setDefaultValue(WebDownloadInstance::destinations.second.at(WebDownloadInstance::Variable));
auto &variableMode = addGroup();
variableMode.setMasterList(destination);
variableMode.setMasterValues({WebDownloadInstance::destinations.first.at(WebDownloadInstance::Variable)});
auto &variable = variableMode.addParameter({QStringLiteral("variable"), tr("Variable")});
variable.setTooltip(tr("The variable where to write the downloaded data"));
auto &fileMode = addGroup();
fileMode.setMasterList(destination);
fileMode.setMasterValues({WebDownloadInstance::destinations.first.at(WebDownloadInstance::File)});
auto &file = fileMode.addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file where to write the downloaded data"));
file.setMode(ActionTools::FileEdit::FileSave);
file.setCaption(tr("Choose the destination file"));
file.setFilter(tr("All files (*.*)"));
auto &showProgress = addParameter({QStringLiteral("showProgress"), tr("Show progress")}, 1);
showProgress.setTooltip(tr("Should the download progress be shown"));
showProgress.setDefaultValue(QStringLiteral("true"));
addException(WebDownloadInstance::CannotOpenFileException, tr("Cannot write to file"));
addException(WebDownloadInstance::DownloadException, tr("Download error"));
}
QString name() const override { return QObject::tr("Web download"); }
QString id() const override { return QStringLiteral("ActionWebDownload"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Downloads data from the Web"); }
ActionTools::ActionInstance *newActionInstance() const override { return new WebDownloadInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/webdownload.png")); }
QStringList tabs() const override { return ActionDefinition::StandardTabs; }
private:
Q_DISABLE_COPY(WebDownloadDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/webdownloadinstance.cpp 0000664 0000000 0000000 00000010516 13636457430 0026034 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "webdownloadinstance.h"
#include
#include
#include
#include
namespace Actions
{
Tools::StringListPair WebDownloadInstance::destinations =
{
{
QStringLiteral("variable"),
QStringLiteral("file")
},
{
QStringLiteral(QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "Variable")),
QStringLiteral(QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "File"))
}
};
WebDownloadInstance::WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent)
: ActionTools::ActionInstance(definition, parent),
mNetworkAccessManager(new QNetworkAccessManager(this)),
mReply(nullptr),
mDestination(Variable),
mProgressDialog(new QProgressDialog)
{
connect(mProgressDialog, &QProgressDialog::canceled, this, &WebDownloadInstance::canceled);
}
WebDownloadInstance::~WebDownloadInstance()
{
delete mProgressDialog;
}
void WebDownloadInstance::startExecution()
{
bool ok = true;
QString urlString = evaluateString(ok, QStringLiteral("url"));
mDestination = evaluateListElement(ok, destinations, QStringLiteral("destination"));
mVariable = evaluateVariable(ok, QStringLiteral("variable"));
QString file = evaluateString(ok, QStringLiteral("file"));
if(!ok)
return;
QUrl url(urlString);
if(url.scheme() == QString())
url = QUrl(QStringLiteral("http://") + urlString, QUrl::TolerantMode);
if(!url.isValid())
{
setCurrentParameter(QStringLiteral("url"));
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid URL"));
return;
}
if(mDestination == File)
{
mFile.setFileName(file);
if(!mFile.open(QIODevice::WriteOnly))
{
setCurrentParameter(QStringLiteral("file"));
emit executionException(CannotOpenFileException, tr("Cannot write to file"));
return;
}
}
mReply = mNetworkAccessManager->get(QNetworkRequest(url));
connect(mReply, &QNetworkReply::finished, this, &WebDownloadInstance::finished);
connect(mReply, &QNetworkReply::downloadProgress, this, &WebDownloadInstance::downloadProgress);
connect(mReply, &QNetworkReply::readyRead, this, &WebDownloadInstance::readyRead);
mProgressDialog->setModal(false);
mProgressDialog->setWindowTitle(tr("Downloading"));
mProgressDialog->setLabelText(tr("Downloading..."));
mProgressDialog->setMaximum(100);
mProgressDialog->show();
}
void WebDownloadInstance::stopExecution()
{
if(mReply)
mReply->abort();
}
void WebDownloadInstance::finished()
{
mFile.close();
switch(mReply->error())
{
case QNetworkReply::NoError:
if(mDestination == Variable)
setVariable(mVariable, QString::fromUtf8(mReply->readAll()));
executionEnded();
break;
case QNetworkReply::OperationCanceledError:
if(mDestination == File)
mFile.remove();
executionEnded();
break;
default:
{
if(mDestination == File)
mFile.remove();
setCurrentParameter(QStringLiteral("url"));
emit executionException(DownloadException, tr("Download error: %1").arg(mReply->errorString()));
}
break;
}
mProgressDialog->close();
mReply->deleteLater();
mReply = nullptr;
}
void WebDownloadInstance::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
if(bytesTotal > 0)
mProgressDialog->setValue((bytesReceived * 100) / bytesTotal);
}
void WebDownloadInstance::readyRead()
{
if(mDestination == File)
mFile.write(mReply->readAll());
}
void WebDownloadInstance::canceled()
{
if(mReply)
mReply->abort();
}
}
actiona-3.10.1/actions/actionpackdata/actions/webdownloadinstance.h 0000664 0000000 0000000 00000003421 13636457430 0025476 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "script.h"
#include "stringlistpair.h"
#include
class QNetworkAccessManager;
class QNetworkReply;
class QProgressDialog;
namespace Actions
{
class WebDownloadInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Destination)
public:
enum Destination
{
Variable,
File
};
enum Exceptions
{
CannotOpenFileException = ActionTools::ActionException::UserException,
DownloadException
};
WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr);
~WebDownloadInstance() override;
static Tools::StringListPair destinations;
void startExecution() override;
void stopExecution() override;
private slots:
void finished();
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void readyRead();
void canceled();
private:
Q_DISABLE_COPY(WebDownloadInstance)
QNetworkAccessManager *mNetworkAccessManager;
QNetworkReply *mReply;
QString mVariable;
Destination mDestination;
QFile mFile;
QProgressDialog *mProgressDialog;
};
}
actiona-3.10.1/actions/actionpackdata/actions/writebinaryfiledefinition.h 0000664 0000000 0000000 00000004735 13636457430 0026725 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "writebinaryfileinstance.h"
#include "fileparameterdefinition.h"
#include "textparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteBinaryFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteBinaryFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &file = addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file to write to"));
file.setMode(ActionTools::FileEdit::FileSave);
file.setCaption(tr("Choose the file"));
file.setFilter(tr("All files (*.*)"));
auto &data = addParameter({QStringLiteral("data"), tr("Data")});
data.setTooltip(tr("The data to write to the file"));
addException(WriteBinaryFileInstance::UnableToWriteFileException, tr("Unable to write to the file"));
}
QString name() const override { return QObject::tr("Write binary file"); }
QString id() const override { return QStringLiteral("ActionWriteBinaryFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Write to a binary file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new WriteBinaryFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writebinary.png")); }
private:
Q_DISABLE_COPY(WriteBinaryFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writebinaryfileinstance.h 0000664 0000000 0000000 00000004076 13636457430 0026377 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "datacopyactioninstance.h"
#include
#include
namespace Actions
{
class WriteBinaryFileInstance : public ActionTools::DataCopyActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToWriteFileException = ActionTools::ActionException::UserException
};
WriteBinaryFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::DataCopyActionInstance(definition, parent)
{
}
void startExecution() override
{
bool ok = true;
QString filename = evaluateString(ok, QStringLiteral("file"));
QScriptValue data = evaluateValue(ok, QStringLiteral("data"));
if(!ok)
return;
mData = data.toVariant().toByteArray();
mFile.setFileName(filename);
mDataBuffer.setBuffer(&mData);
if(!DataCopyActionInstance::startCopy(&mDataBuffer, &mFile))
{
setCurrentParameter(QStringLiteral("file"));
emit executionException(UnableToWriteFileException, tr("Unable to write to the file \"%1\"").arg(filename));
return;
}
emit showProgressDialog(tr("Writing file"), 100);
emit updateProgressDialog(tr("Writing in progress"));
}
private:
void clean() override
{
DataCopyActionInstance::clean();
mDataBuffer.buffer().clear();
}
QFile mFile;
QByteArray mData;
QBuffer mDataBuffer;
private:
Q_DISABLE_COPY(WriteBinaryFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writeclipboarddefinition.h 0000664 0000000 0000000 00000004056 13636457430 0026534 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "writeclipboardinstance.h"
#include "textparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteClipboardDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteClipboardDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &input = addParameter({QStringLiteral("value"), tr("Value")});
input.setTooltip(tr("The new clipboard value"));
}
QString name() const override { return QObject::tr("Write clipboard"); }
QString id() const override { return QStringLiteral("ActionWriteClipboard"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Set the clipboard contents"); }
ActionTools::ActionInstance *newActionInstance() const override { return new WriteClipboardInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writeclipboard.png")); }
private:
Q_DISABLE_COPY(WriteClipboardDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writeclipboardinstance.h 0000664 0000000 0000000 00000002546 13636457430 0026212 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include
#include
namespace Actions
{
class WriteClipboardInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
WriteClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution() override
{
bool ok = true;
QString value = evaluateString(ok, QStringLiteral("value"));
if(!ok)
return;
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(value);
executionEnded();
}
private:
Q_DISABLE_COPY(WriteClipboardInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writeinifiledefinition.h 0000664 0000000 0000000 00000005506 13636457430 0026215 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "writeinifileinstance.h"
#include "textparameterdefinition.h"
#include "fileparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteIniFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteIniFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &file = addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file to create or edit"));
file.setMode(ActionTools::FileEdit::FileSave);
file.setCaption(tr("Choose the INI file"));
file.setFilter(tr("INI files (*.ini);;All files (*.*)"));
auto §ion = addParameter({QStringLiteral("section"), tr("Section")});
section.setTooltip(tr("The section name of the parameter"));
auto ¶meter = addParameter({QStringLiteral("parameter"), tr("Parameter")});
parameter.setTooltip(tr("The parameter name"));
auto &value = addParameter({QStringLiteral("value"), tr("Value")});
value.setTooltip(tr("The new value"));
addException(WriteIniFileInstance::UnableToWriteFileException, tr("Unable to write file"));
}
QString name() const override { return QObject::tr("Write INI file"); }
QString id() const override { return QStringLiteral("ActionWriteIniFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Write an entry in an INI file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new WriteIniFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writeini.png")); }
private:
Q_DISABLE_COPY(WriteIniFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writeinifileinstance.h 0000664 0000000 0000000 00000006304 13636457430 0025666 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include
#include
#include
namespace Actions
{
class WriteIniFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToWriteFileException = ActionTools::ActionException::UserException
};
WriteIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution() override
{
bool ok = true;
QString filename = evaluateString(ok, QStringLiteral("file"));
QString section = evaluateString(ok, QStringLiteral("section"));
QString parameter = evaluateString(ok, QStringLiteral("parameter"));
QString value = evaluateString(ok, QStringLiteral("value"));
if(!ok)
return;
if(!write(filename, section, parameter, value))
return;
executionEnded();
}
private:
bool write(const QString &filename, QString section, const QString ¶meter, const QString &value)
{
try
{
boost::property_tree::ptree tree;
QFileInfo fileInfo(filename);
if(fileInfo.isReadable())
boost::property_tree::ini_parser::read_ini(filename.toStdString(), tree);
//Create/get the parameter and the value
boost::property_tree::ptree sectionTree;
if(tree.count(section.toStdString()) > 0)
sectionTree = tree.get_child(section.toStdString());
sectionTree.put(parameter.toStdString(), value.toStdString());
if(section.isEmpty())
{
setCurrentParameter(QStringLiteral("filename"));
emit executionException(UnableToWriteFileException, tr("Unable to write to the file: the section name cannot be empty"));
return false;
}
//Create the section
tree.put_child(section.toStdString(), sectionTree);
boost::property_tree::ini_parser::write_ini(filename.toStdString(), tree);
}
catch(const std::runtime_error &e)
{
setCurrentParameter(QStringLiteral("filename"));
emit executionException(UnableToWriteFileException, tr("Unable to write to the file: %1").arg(QString::fromUtf8(e.what())));
return false;
}
return true;
}
Q_DISABLE_COPY(WriteIniFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writeregistrydefinition.h 0000664 0000000 0000000 00000005644 13636457430 0026451 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "writeregistryinstance.h"
#include "readregistryinstance.h"
#include "listparameterdefinition.h"
#include "textparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteRegistryDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteRegistryDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
auto &key = addParameter({QStringLiteral("key"), tr("Key")});
key.setTooltip(tr("The registry key to write to"));
key.setItems(ReadRegistryInstance::keys);
key.setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser));
auto &subKey = addParameter({QStringLiteral("subKey"), tr("Subkey")});
subKey.setTooltip(tr("The registry subkey to write to"));
auto &value = addParameter({QStringLiteral("value"), tr("Value")});
value.setTooltip(tr("The value to write to"));
auto &data = addParameter({QStringLiteral("data"), tr("Data")});
data.setTooltip(tr("The data to write"));
addException(WriteRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey"));
addException(WriteRegistryInstance::CannotWriteValueException, tr("Cannot write value"));
}
QString name() const override { return QObject::tr("Write registry"); }
QString id() const override { return QStringLiteral("ActionWriteRegistry"); }
ActionTools::Flag flags() const override { return ActionTools::WorksOnWindows | ActionTools::Official; }
QString description() const override { return QObject::tr("Writes an entry to the registry"); }
ActionTools::ActionInstance *newActionInstance() const override { return new WriteRegistryInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writeregistry.png")); }
private:
Q_DISABLE_COPY(WriteRegistryDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writeregistryinstance.cpp 0000664 0000000 0000000 00000003537 13636457430 0026457 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "writeregistryinstance.h"
#include "readregistryinstance.h"
#ifdef Q_OS_WIN
#include
#endif
namespace Actions
{
void WriteRegistryInstance::startExecution()
{
#ifdef Q_OS_WIN
bool ok = true;
ActionTools::Registry::Key key = evaluateListElement(ok, ReadRegistryInstance::keys, QStringLiteral("key"));
QString subKey = evaluateString(ok, QStringLiteral("subKey"));
QString value = evaluateString(ok, QStringLiteral("value"));
QScriptValue data = evaluateValue(ok, QStringLiteral("data"));
if(!ok)
return;
switch(ActionTools::Registry::write(data.toVariant(), key, subKey, value))
{
case ActionTools::Registry::WriteCannotFindSubKey:
setCurrentParameter(QStringLiteral("subKey"));
emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey));
return;
case ActionTools::Registry::WriteCannotWriteValue:
setCurrentParameter(QStringLiteral("value"));
emit executionException(CannotWriteValueException, tr("Cannot write value \"%1\"").arg(value));
return;
default:
break;
}
#endif
executionEnded();
}
}
actiona-3.10.1/actions/actionpackdata/actions/writeregistryinstance.h 0000664 0000000 0000000 00000002416 13636457430 0026117 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "stringlistpair.h"
#include "registry.h"
namespace Actions
{
class WriteRegistryInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
CannotFindSubKeyException = ActionTools::ActionException::UserException,
CannotWriteValueException
};
WriteRegistryInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution() override;
private:
Q_DISABLE_COPY(WriteRegistryInstance)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writetextfiledefinition.h 0000664 0000000 0000000 00000005507 13636457430 0026423 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actiondefinition.h"
#include "writetextfileinstance.h"
#include "fileparameterdefinition.h"
#include "textparameterdefinition.h"
#include "listparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteTextFileDefinition : public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteTextFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("WriteTextFileInstance::modes", WriteTextFileInstance::modes);
auto &file = addParameter({QStringLiteral("file"), tr("File")});
file.setTooltip(tr("The file you want to write"));
auto &text = addParameter({QStringLiteral("text"), tr("Text")});
text.setTooltip(tr("The text to write to the file"));
auto &mode = addParameter({QStringLiteral("mode"), tr("Mode")}, 1);
mode.setTooltip(tr("The file write mode"));
mode.setItems(WriteTextFileInstance::modes);
mode.setDefaultValue(WriteTextFileInstance::modes.second.at(WriteTextFileInstance::Truncate));
addException(WriteTextFileInstance::CannotWriteFileException, tr("Cannot write file"));
}
QString name() const override { return QObject::tr("Write text file"); }
QString id() const override { return QStringLiteral("ActionWriteTextFile"); }
ActionTools::Flag flags() const override { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const override { return QObject::tr("Write a plain text file"); }
ActionTools::ActionInstance *newActionInstance() const override { return new WriteTextFileInstance(this); }
ActionTools::ActionCategory category() const override { return ActionTools::Data; }
QPixmap icon() const override { return QPixmap(QStringLiteral(":/icons/writetext.png")); }
QStringList tabs() const override { return ActionDefinition::StandardTabs; }
private:
Q_DISABLE_COPY(WriteTextFileDefinition)
};
}
actiona-3.10.1/actions/actionpackdata/actions/writetextfileinstance.cpp 0000664 0000000 0000000 00000003501 13636457430 0026422 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "writetextfileinstance.h"
#include
#include
namespace Actions
{
Tools::StringListPair WriteTextFileInstance::modes =
{
{
QStringLiteral("truncate"), QStringLiteral("append")
},
{
QStringLiteral(QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Overwrite any content")),
QStringLiteral(QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Append to the end"))
}
};
void WriteTextFileInstance::startExecution()
{
bool ok = true;
QString filepath = evaluateString(ok, QStringLiteral("file"));
QString text = evaluateString(ok, QStringLiteral("text"));
Mode mode = evaluateListElement(ok, modes, QStringLiteral("mode"));
if(!ok)
return;
QFile file(filepath);
if(!file.open(QIODevice::WriteOnly | QIODevice::Text | (mode == Truncate ? QIODevice::Truncate : QIODevice::Append)))
{
setCurrentParameter(QStringLiteral("file"));
emit executionException(CannotWriteFileException, tr("Cannot open file"));
return;
}
QTextStream textStream(&file);
textStream << text;
file.close();
executionEnded();
}
}
actiona-3.10.1/actions/actionpackdata/actions/writetextfileinstance.h 0000664 0000000 0000000 00000002502 13636457430 0026067 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "actioninstance.h"
#include "stringlistpair.h"
namespace Actions
{
class WriteTextFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
Truncate,
Append
};
enum Exceptions
{
CannotWriteFileException = ActionTools::ActionException::UserException
};
WriteTextFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = nullptr)
: ActionTools::ActionInstance(definition, parent) {}
static Tools::StringListPair modes;
void startExecution() override;
private:
Q_DISABLE_COPY(WriteTextFileInstance)
};
}
actiona-3.10.1/actions/actionpackdata/code/ 0000775 0000000 0000000 00000000000 13636457430 0020545 5 ustar 00root root 0000000 0000000 actiona-3.10.1/actions/actionpackdata/code/clipboard.cpp 0000664 0000000 0000000 00000006143 13636457430 0023214 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "clipboard.h"
#include "code/image.h"
#include
#include
#include
#include
namespace Code
{
QScriptValue Clipboard::constructor(QScriptContext *context, QScriptEngine *engine)
{
auto clipboard = new Clipboard;
if(context->argumentCount() > 0)
{
Mode mode = static_cast(context->argument(0).toInt32());
clipboard->setModePrivate(context, engine, mode);
}
return CodeClass::constructor(clipboard, context, engine);
}
Clipboard::Clipboard()
: CodeClass()
{
}
QString Clipboard::text() const
{
QClipboard *clipboard = QApplication::clipboard();
return clipboard->text(mMode);
}
QScriptValue Clipboard::image() const
{
QClipboard *clipboard = QApplication::clipboard();
return Image::constructor(clipboard->image(mMode), engine());
}
QScriptValue Clipboard::setMode(Mode mode)
{
setModePrivate(context(), engine(), mode);
return thisObject();
}
QScriptValue Clipboard::setText(const QString &value) const
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(value, mMode);
return thisObject();
}
QScriptValue Clipboard::setImage(const QScriptValue &data) const
{
QClipboard *clipboard = QApplication::clipboard();
QObject *object = data.toQObject();
if(auto image = qobject_cast(object))
clipboard->setImage(image->image(), mMode);
else
clipboard->setImage(data.toVariant().value(), mMode);
return thisObject();
}
Clipboard::DataType Clipboard::dataType() const
{
QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData(mMode);
if(mimeData->hasImage())
return Image;
else
return Text;
}
void Clipboard::setModePrivate(QScriptContext *context, QScriptEngine *engine, Mode mode)
{
switch(mode)
{
case Selection:
if(!QApplication::clipboard()->supportsSelection())
{
throwError(context, engine, QStringLiteral("UnsupportedSelectionModeError"), tr("Selection mode is not supported by your operating system"));
return;
}
break;
case FindBuffer:
if(!QApplication::clipboard()->supportsFindBuffer())
{
throwError(context, engine, QStringLiteral("UnsupportedSelectionModeError"), tr("Find buffer mode is not supported by your operating system"));
return;
}
break;
default:
break;
}
mMode = static_cast(mode);
}
}
actiona-3.10.1/actions/actionpackdata/code/clipboard.h 0000664 0000000 0000000 00000003657 13636457430 0022670 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class Clipboard : public CodeClass
{
Q_OBJECT
Q_ENUMS(Mode)
Q_ENUMS(DataType)
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY(QScriptValue image READ image WRITE setImage)
public:
enum Mode
{
Standard = QClipboard::Clipboard,
Selection = QClipboard::Selection,
FindBuffer = QClipboard::FindBuffer
};
enum DataType
{
Text,
Image
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
Clipboard();
QString text() const;
QScriptValue image() const;
public slots:
QString toString() const override { return QStringLiteral("Clipboard"); }
bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); }
QScriptValue setMode(Mode mode);
QScriptValue setText(const QString &value) const;
QScriptValue setImage(const QScriptValue &data) const;
DataType dataType() const;
private:
void setModePrivate(QScriptContext *context, QScriptEngine *engine, Mode mode);
QClipboard::Mode mMode{QClipboard::Clipboard};
};
}
actiona-3.10.1/actions/actionpackdata/code/code.pri 0000664 0000000 0000000 00000001021 13636457430 0022165 0 ustar 00root root 0000000 0000000 HEADERS += code/file.h \
code/clipboard.h \
code/registry.h \
code/inifile.h \
code/udp.h \
code/tcp.h \
code/sql.h \
code/tcpserver.h \
code/web.h \
code/mail.h \
code/mailmessage.h \
code/mailattachment.h
SOURCES += code/file.cpp \
code/clipboard.cpp \
code/registry.cpp \
code/inifile.cpp \
code/udp.cpp \
code/tcp.cpp \
code/sql.cpp \
code/tcpserver.cpp \
code/web.cpp \
code/mail.cpp \
code/mailmessage.cpp \
code/mailattachment.cpp
actiona-3.10.1/actions/actionpackdata/code/file.cpp 0000664 0000000 0000000 00000046762 13636457430 0022207 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "file.h"
#include "code/rawdata.h"
#include
#include
#include
#include
#ifdef Q_OS_WIN
#include
#include
#endif
namespace Code
{
QScriptValue File::constructor(QScriptContext *context, QScriptEngine *engine)
{
return CodeClass::constructor(new File, context, engine);
}
QScriptValue File::copy(QScriptContext *context, QScriptEngine *engine)
{
QString source, destination;
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
copyPrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
return engine->undefinedValue();
}
QScriptValue File::exists(QScriptContext *context, QScriptEngine *engine)
{
if(context->argumentCount() != 1)
{
throwError(context, engine, QStringLiteral("ParameterCountError"), tr("Incorrect parameter count"));
return false;
}
return QFile::exists(context->argument(0).toString());
}
QScriptValue File::move(QScriptContext *context, QScriptEngine *engine)
{
QString source, destination;
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
return engine->undefinedValue();
}
QScriptValue File::rename(QScriptContext *context, QScriptEngine *engine)
{
QString source, destination;
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
renamePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
return engine->undefinedValue();
}
QScriptValue File::remove(QScriptContext *context, QScriptEngine *engine)
{
QString filename;
if(context->argumentCount() < 1)
{
throwError(context, engine, QStringLiteral("ParameterCountError"), tr("Incorrect parameter count"));
return false;
}
filename = context->argument(0).toString();
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(context->argument(1), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
removePrivate(filename, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, context, engine);
return engine->undefinedValue();
}
void File::registerClass(QScriptEngine *scriptEngine)
{
CodeTools::addClassGlobalFunctionToScriptEngine(©, QStringLiteral("copy"), scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&move, QStringLiteral("move"), scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&rename, QStringLiteral("rename"), scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&remove, QStringLiteral("remove"), scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&exists, QStringLiteral("exists"), scriptEngine);
}
QScriptValue File::open(const QString &filename, OpenMode mode)
{
mFile.setFileName(filename);
if(!mFile.open(static_cast(mode)))
throwError(QStringLiteral("CannotOpenFileError"), tr("Unable to open file"));
return thisObject();
}
QScriptValue File::write(const QScriptValue &data)
{
QObject *object = data.toQObject();
if(auto rawData = qobject_cast(object))
{
if(mFile.write(rawData->byteArray()) == -1)
throwError(QStringLiteral("WriteFailedError"), tr("Write failed"));
}
else
{
if(mFile.write(data.toVariant().toByteArray()) == -1)
throwError(QStringLiteral("WriteFailedError"), tr("Write failed"));
}
return thisObject();
}
QScriptValue File::writeText(const QString &value, Encoding encoding)
{
if(mFile.write(toEncoding(value, encoding)) == -1)
throwError(QStringLiteral("WriteFailedError"), tr("Write failed"));
return thisObject();
}
QScriptValue File::read()
{
return RawData::constructor(mFile.readAll(), engine());
}
QString File::readText(Encoding encoding)
{
return fromEncoding(mFile.readAll(), encoding);
}
QScriptValue File::close()
{
mFile.close();
return thisObject();
}
QScriptValue File::copy(const QString &destination, const QScriptValue &options) const
{
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return copyPrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
else
return false;
}
QScriptValue File::move(const QString &destination, const QScriptValue &options)
{
mFile.close();
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return movePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
else
return false;
}
QScriptValue File::rename(const QString &destination, const QScriptValue &options)
{
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return renamePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
else
return false;
}
QScriptValue File::remove(const QScriptValue &options)
{
mFile.close();
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return removePrivate(mFile.fileName(), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, context(), engine());
else
return false;
}
bool File::getParameters(QString &source, QString &destination, const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
if(context->argumentCount() < 2)
{
throwError(context, engine, QStringLiteral("ParameterCountError"), tr("Incorrect parameter count"));
return false;
}
source = context->argument(0).toString();
destination = context->argument(1).toString();
return getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory);
}
bool File::getParameters(const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory)
{
QScriptValueIterator it(options);
noErrorDialog = false;
noConfirmDialog = false;
noProgressDialog = false;
allowUndo = false;
createDestinationDirectory = true;
while(it.hasNext())
{
it.next();
if(it.name() == QLatin1String("noErrorDialog"))
noErrorDialog = it.value().toBool();
else if(it.name() == QLatin1String("noConfirmDialog"))
noConfirmDialog = it.value().toBool();
else if(it.name() == QLatin1String("noProgressDialog"))
noProgressDialog = it.value().toBool();
else if(it.name() == QLatin1String("allowUndo"))
allowUndo = it.value().toBool();
else if(it.name() == QLatin1String("createDestinationDirectory"))
createDestinationDirectory = it.value().toBool();
}
return true;
}
QScriptValue File::copyPrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
#ifdef Q_OS_UNIX
Q_UNUSED(noErrorDialog)
Q_UNUSED(noConfirmDialog)
Q_UNUSED(noProgressDialog)
Q_UNUSED(allowUndo)
QDir destinationDir(destination);
QString sourceCopy(source);
QString destinationCopy(destination);
sourceCopy.replace(QStringLiteral(" "), QStringLiteral("\\ "));
destinationCopy.replace(QStringLiteral(" "), QStringLiteral("\\ "));
if(!destinationDir.exists())
{
if(createDestinationDirectory)
{
if(QProcess::execute(QStringLiteral("sh -c \"mkdir -p ") + QString::fromLocal8Bit(QFile::encodeName(destinationCopy)) + QStringLiteral("\"")))
{
throwError(context, engine, QStringLiteral("DirectoryCreationError"), tr("Unable to create destination directory"));
return context->thisObject();
}
}
else
{
throwError(context, engine, QStringLiteral("DirectoryDoesntExistError"), tr("Destination directory doesn't exist"));
return context->thisObject();
}
}
QString command = QStringLiteral("sh -c \"cp -fr");
command += QStringLiteral(" ");
command += QString::fromLocal8Bit(QFile::encodeName(sourceCopy));
command += QStringLiteral(" ");
command += QString::fromLocal8Bit(QFile::encodeName(destinationCopy));
command += QStringLiteral("\"");
if(QProcess::execute(command))
{
throwError(context, engine, QStringLiteral("CopyError"), tr("Copy failed"));
return context->thisObject();
}
#endif
#ifdef Q_OS_WIN
Q_UNUSED(createDestinationDirectory)
QDir sourceDir(source);
QDir destinationDir(destination);
std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
wideSource += L'\0';
std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
wideDestination += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_COPY;
shFileOpStruct.pFrom = wideSource.c_str();
shFileOpStruct.pTo = wideDestination.c_str();
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, QStringLiteral("CopyError"), tr("Copy failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, QStringLiteral("CopyAbortedError"), tr("Copy failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QScriptValue File::movePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
#ifdef Q_OS_UNIX
Q_UNUSED(noErrorDialog)
Q_UNUSED(noConfirmDialog)
Q_UNUSED(noProgressDialog)
Q_UNUSED(allowUndo)
QDir destinationDir(destination);
QString sourceCopy(source);
QString destinationCopy(destination);
sourceCopy.replace(QStringLiteral(" "), QStringLiteral("\\ "));
destinationCopy.replace(QStringLiteral(" "), QStringLiteral("\\ "));
if(!destinationDir.exists())
{
if(createDestinationDirectory)
{
if(QProcess::execute(QStringLiteral("sh -c \"mkdir -p ") + QString::fromLocal8Bit(QFile::encodeName(destinationCopy)) + QStringLiteral("\"")))
{
throwError(context, engine, QStringLiteral("DirectoryCreationError"), tr("Unable to create destination directory"));
return context->thisObject();
}
}
else
{
throwError(context, engine, QStringLiteral("DirectoryDoesntExistError"), tr("Destination directory doesn't exist"));
return context->thisObject();
}
}
QString command = QStringLiteral("sh -c \"mv -f");
command += QStringLiteral(" ");
command += QString::fromLocal8Bit(QFile::encodeName(sourceCopy));
command += QStringLiteral(" ");
command += QString::fromLocal8Bit(QFile::encodeName(destinationCopy));
command += QStringLiteral("\"");
if(QProcess::execute(command))
{
throwError(context, engine, QStringLiteral("MoveRenameError"), tr("Move/rename failed"));
return context->thisObject();
}
#endif
#ifdef Q_OS_WIN
Q_UNUSED(createDestinationDirectory)
QDir sourceDir(source);
QDir destinationDir(destination);
std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
wideSource += L'\0';
std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
wideDestination += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_MOVE;
shFileOpStruct.pFrom = wideSource.c_str();
shFileOpStruct.pTo = wideDestination.c_str();
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, QStringLiteral("MoveError"), tr("Move failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, QStringLiteral("MoveAbortedError"), tr("Move failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QScriptValue File::renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
#ifdef Q_OS_UNIX
movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
#endif
#ifdef Q_OS_WIN
Q_UNUSED(createDestinationDirectory)
QDir sourceDir(source);
QDir destinationDir(destination);
std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
wideSource += L'\0';
std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
wideDestination += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_RENAME;
shFileOpStruct.pFrom = wideSource.c_str();
shFileOpStruct.pTo = wideDestination.c_str();
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, QStringLiteral("RenameError"), tr("Rename failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, QStringLiteral("RenameAbortedError"), tr("Rename failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QScriptValue File::removePrivate(const QString &filename, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, QScriptContext *context, QScriptEngine *engine)
{
#ifdef Q_OS_UNIX
Q_UNUSED(noErrorDialog)
Q_UNUSED(noConfirmDialog)
Q_UNUSED(noProgressDialog)
Q_UNUSED(allowUndo)
QString filenameCopy(filename);
filenameCopy.replace(QStringLiteral(" "), QStringLiteral("\\ "));
QString command = QStringLiteral("sh -c \"rm -fr");
command += QStringLiteral(" ");
command += QString::fromLocal8Bit(QFile::encodeName(filenameCopy));
command += QStringLiteral("\"");
if(QProcess::execute(command))
{
throwError(context, engine, QStringLiteral("RemoveError"), tr("Remove failed"));
return context->thisObject();
}
#endif
#ifdef Q_OS_WIN
QDir filenameDir(filename);
std::wstring wideFilename = QDir::toNativeSeparators(filenameDir.absolutePath()).toStdWString();
wideFilename += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_DELETE;
shFileOpStruct.pFrom = wideFilename.c_str();
shFileOpStruct.pTo = 0;
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, QStringLiteral("RemoveError"), tr("Remove failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, QStringLiteral("RemoveAbortedError"), tr("Remove failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QString File::getErrorString(int error)
{
#ifdef Q_OS_UNIX
Q_UNUSED(error)
return QString();
#endif
#ifdef Q_OS_WIN
switch(error)
{
case ERROR_SUCCESS:
return QString();
case ERROR_FILE_NOT_FOUND:
return tr("File not found");
case ERROR_PATH_NOT_FOUND:
return tr("Path not found");
case ERROR_ACCESS_DENIED:
return tr("Access denied");
case ERROR_SHARING_VIOLATION:
return tr("This file is used by another process");
case ERROR_DISK_FULL:
return tr("The disk is full");
case ERROR_FILE_EXISTS:
case ERROR_ALREADY_EXISTS:
return tr("The file already exists");
case ERROR_INVALID_NAME:
return tr("Invalid name");
case ERROR_CANCELLED:
return tr("Canceled");
default:
return tr("Unknown error (%1)").arg(error);
}
#endif
}
}
actiona-3.10.1/actions/actionpackdata/code/file.h 0000664 0000000 0000000 00000010240 13636457430 0021632 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class File : public CodeClass
{
Q_OBJECT
Q_ENUMS(OpenMode)
Q_ENUMS(Encoding)
public:
enum OpenMode
{
ReadOnly = QIODevice::ReadOnly,
WriteOnly = QIODevice::WriteOnly,
ReadWrite = QIODevice::ReadWrite,
Append = QIODevice::Append,
Truncate = QIODevice::Truncate,
Text = QIODevice::Text,
Unbuffered = QIODevice::Unbuffered
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
static QScriptValue copy(QScriptContext *context, QScriptEngine *engine);
static QScriptValue exists(QScriptContext *context, QScriptEngine *engine);
static QScriptValue move(QScriptContext *context, QScriptEngine *engine);
static QScriptValue rename(QScriptContext *context, QScriptEngine *engine);
static QScriptValue remove(QScriptContext *context, QScriptEngine *engine);
static void registerClass(QScriptEngine *scriptEngine);
~File() override { mFile.close(); }
QFile *file() { return &mFile; }
public slots:
QString toString() const override { return QStringLiteral("File"); }
bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); }
QScriptValue open(const QString &filename, OpenMode mode);
QScriptValue write(const QScriptValue &data);
QScriptValue writeText(const QString &value, Encoding encoding = Native);
QScriptValue read();
QString readText(Encoding encoding = Native);
QScriptValue close();
QScriptValue copy(const QString &destination, const QScriptValue &options = QScriptValue()) const;
QScriptValue move(const QString &destination, const QScriptValue &options = QScriptValue());
QScriptValue rename(const QString &destination, const QScriptValue &options = QScriptValue());
QScriptValue remove(const QScriptValue &options = QScriptValue());
private:
static bool getParameters(QString &source, QString &destination, const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static bool getParameters(const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory);
static QScriptValue copyPrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static QScriptValue movePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static QScriptValue renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static QScriptValue removePrivate(const QString &filename, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, QScriptContext *context, QScriptEngine *engine);
static QString getErrorString(int error);
QFile mFile;
};
}
actiona-3.10.1/actions/actionpackdata/code/inifile.cpp 0000664 0000000 0000000 00000013154 13636457430 0022674 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "inifile.h"
#include
#include
namespace Code
{
QScriptValue IniFile::constructor(QScriptContext *context, QScriptEngine *engine)
{
auto iniFile = new IniFile;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == QLatin1String("encoding"))
iniFile->mEncoding = static_cast(it.value().toInt32());
}
return CodeClass::constructor(iniFile, context, engine);
}
IniFile::IniFile()
: CodeClass()
{
}
QScriptValue IniFile::load(const QString &filename)
{
try
{
boost::property_tree::ini_parser::read_ini(toEncoding(filename, mEncoding).constData(), mTree);
}
catch(const std::runtime_error &)
{
throwError(QStringLiteral("LoadFileError"), tr("Cannot load the file"));
return thisObject();
}
mLatestFilename = filename;
return thisObject();
}
QScriptValue IniFile::save(const QString &filename)
{
QByteArray filenameByteArray = toEncoding(filename.isEmpty() ? mLatestFilename : filename, mEncoding);
try
{
boost::property_tree::ini_parser::write_ini(filenameByteArray.constData(), mTree);
}
catch(const std::runtime_error &)
{
throwError(QStringLiteral("SaveFileError"), tr("Cannot save the file"));
return thisObject();
}
return thisObject();
}
QScriptValue IniFile::clear()
{
mTree.clear();
return thisObject();
}
QScriptValue IniFile::setSection(const QString §ionName, bool create)
{
QByteArray sectionNameByteArray = toEncoding(sectionName, mEncoding);
if(mTree.count(sectionNameByteArray.constData()) == 0)
{
if(!create)
{
throwError(QStringLiteral("FindSectionError"), tr("Cannot find the section named \"%1\"").arg(sectionName));
return thisObject();
}
mCurrentSection = mTree.add_child(sectionNameByteArray.constData(), {});
}
else
mCurrentSection = mTree.get_child(sectionNameByteArray.constData());
mCurrentSectionName = sectionNameByteArray;
return thisObject();
}
QScriptValue IniFile::setEncoding(Encoding encoding)
{
mEncoding = encoding;
return thisObject();
}
QString IniFile::sectionAt(int sectionIndex) const
{
if(sectionIndex < 0 || sectionIndex >= static_cast(mTree.size()))
{
throwError(QStringLiteral("FindSectionError"), tr("Invalid section index"));
return QString();
}
auto it = mTree.begin();
std::advance(it, sectionIndex);
return QString::fromStdString(it->first);
}
QScriptValue IniFile::deleteSection(const QString §ionName)
{
QByteArray sectionNameByteArray = toEncoding(sectionName, mEncoding);
if(!mTree.erase(sectionNameByteArray.constData()))
{
throwError(QStringLiteral("FindSectionError"), tr("Cannot delete section named \"%1\"").arg(sectionName));
return thisObject();
}
return thisObject();
}
int IniFile::sectionCount() const
{
return static_cast(mTree.size());
}
bool IniFile::keyExists(const QString &keyName) const
{
QByteArray keyNameByteArray = toEncoding(keyName, mEncoding);
return (mCurrentSection.count(keyNameByteArray.constData()) > 0);
}
QString IniFile::keyAt(int keyIndex) const
{
if(keyIndex < 0 || keyIndex >= static_cast(mCurrentSection.size()))
{
throwError(QStringLiteral("KeyError"), tr("Invalid key index"));
return QString();
}
auto it = mCurrentSection.begin();
std::advance(it, keyIndex);
return QString::fromStdString(it->first);
}
QString IniFile::keyValue(const QString &keyName) const
{
if(!keyExists(keyName))
{
throwError(QStringLiteral("KeyError"), tr("Cannot find any key named \"%1\"").arg(keyName));
return QString();
}
return QString::fromStdString(mCurrentSection.get(toEncoding(keyName, mEncoding).constData()));
}
QScriptValue IniFile::setKeyValue(const QString &keyName, const QString &value)
{
mCurrentSection.put(toEncoding(keyName, mEncoding).constData(), toEncoding(value, mEncoding).constData());
mTree.put_child(mCurrentSectionName.constData(), mCurrentSection);
return thisObject();
}
QScriptValue IniFile::deleteKey(const QString &keyName)
{
QByteArray keyNameByteArray = toEncoding(keyName, mEncoding);
if(!mCurrentSection.erase(keyNameByteArray.constData()))
{
throwError(QStringLiteral("KeyError"), tr("Cannot delete key named \"%1\"").arg(keyName));
return thisObject();
}
mTree.put_child(mCurrentSectionName.constData(), mCurrentSection);
return thisObject();
}
int IniFile::keyCount() const
{
return static_cast(mCurrentSection.size());
}
}
actiona-3.10.1/actions/actionpackdata/code/inifile.h 0000664 0000000 0000000 00000004172 13636457430 0022341 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class IniFile : public CodeClass
{
Q_OBJECT
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
IniFile();
public slots:
QString toString() const override { return QStringLiteral("IniFile"); }
bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); }
QScriptValue load(const QString &filename);
QScriptValue save(const QString &filename = QString());
QScriptValue clear();
QScriptValue setSection(const QString §ionName, bool create = true);
QScriptValue setEncoding(Encoding encoding);
QString sectionAt(int sectionIndex) const;
QScriptValue deleteSection(const QString §ionName);
int sectionCount() const;
bool keyExists(const QString &keyName) const;
QString keyAt(int keyIndex) const;
QString keyValue(const QString &keyName) const;
QScriptValue setKeyValue(const QString &keyName, const QString &value);
QScriptValue deleteKey(const QString &keyName);
int keyCount() const;
private:
Encoding mEncoding{Native};
boost::property_tree::ptree mCurrentSection;
boost::property_tree::ptree mTree;
QByteArray mCurrentSectionName;
QString mLatestFilename;
};
}
actiona-3.10.1/actions/actionpackdata/code/mail.cpp 0000664 0000000 0000000 00000020742 13636457430 0022200 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mail.h"
#include "mailmessage.h"
#include "qxtcore/qxtsignalwaiter.h"
#include
#include
namespace Code
{
QScriptValue Mail::constructor(QScriptContext *context, QScriptEngine *engine)
{
Mail *mail = new Mail;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == QLatin1String("username"))
mail->setUsername(it.value().toString());
else if(it.name() == QLatin1String("password"))
mail->setPassword(it.value().toString());
else if(it.name() == QLatin1String("onConnected"))
mail->mOnConnected = it.value();
else if(it.name() == QLatin1String("onConnectionFailed"))
mail->mOnConnectionFailed = it.value();
else if(it.name() == QLatin1String("onEncrypted"))
mail->mOnEncrypted = it.value();
else if(it.name() == QLatin1String("onEncryptionFailed"))
mail->mOnEncryptionFailed = it.value();
else if(it.name() == QLatin1String("onAuthenticated"))
mail->mOnAuthenticated = it.value();
else if(it.name() == QLatin1String("onAuthenticationFailed"))
mail->mOnAuthenticationFailed = it.value();
else if(it.name() == QLatin1String("onSenderRejected"))
mail->mOnSenderRejected = it.value();
else if(it.name() == QLatin1String("onRecipientRejected"))
mail->mOnRecipientRejected = it.value();
else if(it.name() == QLatin1String("onMailFailed"))
mail->mOnMailFailed = it.value();
else if(it.name() == QLatin1String("onMailSent"))
mail->mOnMailSent = it.value();
else if(it.name() == QLatin1String("onFinished"))
mail->mOnFinished = it.value();
else if(it.name() == QLatin1String("onDisconnected"))
mail->mOnDisconnected = it.value();
}
return CodeClass::constructor(mail, context, engine);
}
Mail::Mail()
: CodeClass()
{
connect(&mSmtp, &QxtSmtp::connected, this, &Mail::connected);
connect(&mSmtp, static_cast(&QxtSmtp::connectionFailed), this, &Mail::connectionFailed);
connect(&mSmtp, &QxtSmtp::encrypted, this, &Mail::encrypted);
connect(&mSmtp, static_cast(&QxtSmtp::encryptionFailed), this, &Mail::encryptionFailed);
connect(&mSmtp, &QxtSmtp::authenticated, this, &Mail::authenticated);
connect(&mSmtp, static_cast(&QxtSmtp::authenticationFailed), this, &Mail::authenticationFailed);
connect(&mSmtp, static_cast(&QxtSmtp::senderRejected), this, &Mail::senderRejected);
connect(&mSmtp, static_cast(&QxtSmtp::recipientRejected), this, &Mail::recipientRejected);
connect(&mSmtp, static_cast(&QxtSmtp::mailFailed), this, &Mail::mailFailed);
connect(&mSmtp, static_cast(&QxtSmtp::mailSent), this, &Mail::mailSent);
connect(&mSmtp, &QxtSmtp::finished, this, &Mail::finished);
connect(&mSmtp, &QxtSmtp::disconnected, this, &Mail::disconnected);
}
QScriptValue Mail::connectToServer(const QString &serverName, int port)
{
mSmtp.connectToHost(serverName, port);
return thisObject();
}
QScriptValue Mail::connectToSecureServer(const QString &serverName, int port)
{
mSmtp.connectToSecureHost(serverName, port);
return thisObject();
}
int Mail::send(const QScriptValue &mail)
{
if(auto mailMessage = qobject_cast(mail.toQObject()))
{
QxtMailMessage &message = mailMessage->message();
if(!message.hasExtraHeader(QStringLiteral("Date")))
message.setExtraHeader(QStringLiteral("Date"), QDateTime::currentDateTime().toString(Qt::RFC2822Date));
return mSmtp.send(message);
}
else
{
throwError(QStringLiteral("ParameterTypeError"), tr("Incorrect parameter type: not a MailMessage"));
return -1;
}
}
QScriptValue Mail::waitForConnected(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(connected()));
if(!waiter.wait(waitTime))
throwError(QStringLiteral("ConnectionError"), tr("Cannot establish a connection to the server"));
return thisObject();
}
QScriptValue Mail::waitForEncrypted(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(encrypted()));
if(!waiter.wait(waitTime))
throwError(QStringLiteral("EncryptionError"), tr("Cannot encrypt the connection"));
return thisObject();
}
QScriptValue Mail::waitForAuthenticated(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(authenticated()));
if(!waiter.wait(waitTime))
throwError(QStringLiteral("AuthenticationError"), tr("Cannot authenticate to the server"));
return thisObject();
}
QScriptValue Mail::waitForFinished(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(finished()));
if(!waiter.wait(waitTime))
throwError(QStringLiteral("WaitForFinishedError"), tr("Wait for finished failed"));
return thisObject();
}
QScriptValue Mail::waitForDisconnected(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(disconnected()));
if(!waiter.wait(waitTime))
throwError(QStringLiteral("WaitForDisconnectedError"), tr("Wait for disconnected failed"));
return thisObject();
}
void Mail::connected()
{
if(mOnConnected.isValid())
mOnConnected.call(thisObject());
}
void Mail::connectionFailed(const QByteArray &msg)
{
if(mOnConnectionFailed.isValid())
mOnConnectionFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg));
}
void Mail::encrypted()
{
if(mOnEncrypted.isValid())
mOnEncrypted.call(thisObject());
}
void Mail::encryptionFailed(const QByteArray &msg)
{
if(mOnEncryptionFailed.isValid())
mOnEncryptionFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg));
}
void Mail::authenticated()
{
if(mOnAuthenticated.isValid())
mOnAuthenticated.call(thisObject());
}
void Mail::authenticationFailed(const QByteArray &msg)
{
if(mOnAuthenticationFailed.isValid())
mOnAuthenticationFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg));
}
void Mail::senderRejected(int mailID, const QString &address, const QByteArray &msg)
{
if(mOnSenderRejected.isValid())
mOnSenderRejected.call(thisObject(), QScriptValueList() << mailID << address << QString::fromUtf8(msg));
}
void Mail::recipientRejected(int mailID, const QString &address, const QByteArray &msg)
{
if(mOnRecipientRejected.isValid())
mOnRecipientRejected.call(thisObject(), QScriptValueList() << mailID << address << QString::fromUtf8(msg));
}
void Mail::mailFailed(int mailID, int errorCode, const QByteArray &msg)
{
if(mOnMailFailed.isValid())
mOnMailFailed.call(thisObject(), QScriptValueList() << mailID << errorCode << QString::fromUtf8(msg));
}
void Mail::mailSent(int mailID)
{
if(mOnMailSent.isValid())
mOnMailSent.call(thisObject(), QScriptValueList() << mailID);
}
void Mail::finished()
{
if(mOnFinished.isValid())
mOnFinished.call(thisObject());
}
void Mail::disconnected()
{
if(mOnDisconnected.isValid())
mOnDisconnected.call(thisObject());
}
}
actiona-3.10.1/actions/actionpackdata/code/mail.h 0000664 0000000 0000000 00000020517 13636457430 0021645 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "code/codeclass.h"
#include "qxtsmtp/qxtsmtp.h"
#include
#include
#include
namespace Code
{
class Mail : public CodeClass
{
Q_OBJECT
Q_PROPERTY(QString username READ username WRITE setUsername)
Q_PROPERTY(QString password READ password WRITE setPassword)
Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected)
Q_PROPERTY(QScriptValue onConnectionFailed READ onConnectionFailed WRITE setOnConnectionFailed)
Q_PROPERTY(QScriptValue onEncrypted READ onEncrypted WRITE setOnEncrypted)
Q_PROPERTY(QScriptValue onEncryptionFailed READ onEncryptionFailed WRITE setOnEncryptionFailed)
Q_PROPERTY(QScriptValue onAuthenticated READ onAuthenticated WRITE setOnAuthenticated)
Q_PROPERTY(QScriptValue onAuthenticationFailed READ onAuthenticationFailed WRITE setOnAuthenticationFailed)
Q_PROPERTY(QScriptValue onSenderRejected READ onSenderRejected WRITE setOnSenderRejected)
Q_PROPERTY(QScriptValue onRecipientRejected READ onRecipientRejected WRITE setOnRecipientRejected)
Q_PROPERTY(QScriptValue onMailFailed READ onMailFailed WRITE setOnMailFailed)
Q_PROPERTY(QScriptValue onMailSent READ onMailSent WRITE setOnMailSent)
Q_PROPERTY(QScriptValue onFinished READ onFinished WRITE setOnFinished)
Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected)
Q_PROPERTY(int pendingMessageCount READ pendingMessageCount)
Q_PROPERTY(bool startTlsDisabled READ startTlsDisabled WRITE setStartTlsDisabled)
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
Mail();
QString username() const { return QString::fromUtf8(mSmtp.username()); }
void setUsername(const QString &username) { mSmtp.setUsername(username.toUtf8()); }
QString password() const { return QString::fromUtf8(mSmtp.password()); }
void setPassword(const QString &password) { mSmtp.setPassword(password.toUtf8()); }
void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; }
QScriptValue onConnected() const { return mOnConnected; }
void setOnConnectionFailed(const QScriptValue &onConnectionFailed) { mOnConnectionFailed = onConnectionFailed; }
QScriptValue onConnectionFailed() const { return mOnConnectionFailed; }
void setOnEncrypted(const QScriptValue &onEncrypted) { mOnEncrypted = onEncrypted; }
QScriptValue onEncrypted() const { return mOnEncrypted; }
void setOnEncryptionFailed(const QScriptValue &onEncryptionFailed) { mOnEncryptionFailed = onEncryptionFailed; }
QScriptValue onEncryptionFailed() const { return mOnEncryptionFailed; }
void setOnAuthenticated(const QScriptValue &onAuthenticated) { mOnAuthenticated = onAuthenticated; }
QScriptValue onAuthenticated() const { return mOnAuthenticated; }
void setOnAuthenticationFailed(const QScriptValue &onAuthenticationFailed) { mOnAuthenticationFailed = onAuthenticationFailed; }
QScriptValue onAuthenticationFailed() const { return mOnAuthenticationFailed; }
void setOnSenderRejected(const QScriptValue &onSenderRejected) { mOnSenderRejected = onSenderRejected; }
QScriptValue onSenderRejected() const { return mOnSenderRejected; }
void setOnRecipientRejected(const QScriptValue &onRecipientRejected) { mOnRecipientRejected = onRecipientRejected; }
QScriptValue onRecipientRejected() const { return mOnRecipientRejected; }
void setOnMailFailed(const QScriptValue &onMailFailed) { mOnMailFailed = onMailFailed; }
QScriptValue onMailFailed() const { return mOnMailFailed; }
void setOnMailSent(const QScriptValue &onMailSent) { mOnMailSent = onMailSent; }
QScriptValue onMailSent() const { return mOnMailSent; }
void setOnFinished(const QScriptValue &onFinished) { mOnFinished = onFinished; }
QScriptValue onFinished() const { return mOnFinished; }
void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; }
QScriptValue onDisconnected() const { return mOnDisconnected; }
int pendingMessageCount() const { return mSmtp.pendingMessages(); }
bool startTlsDisabled() const { return mSmtp.startTlsDisabled(); }
void setStartTlsDisabled(bool disable) { mSmtp.setStartTlsDisabled(disable); }
public slots:
QString toString() const override { return QStringLiteral("Mail"); }
bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); }
QScriptValue connectToServer(const QString &serverName, int port = 25);
QScriptValue connectToSecureServer(const QString &serverName, int port = 465);
int send(const QScriptValue &mail);
QScriptValue disconnectFromServer() { mSmtp.disconnectFromHost(); return thisObject(); }
bool hasExtension(const QString &extension) { return mSmtp.hasExtension(extension); }
QString extensionData(const QString &extension) { return mSmtp.extensionData(extension); }
QScriptValue waitForConnected(int waitTime = 30000);
QScriptValue waitForEncrypted(int waitTime = 30000);
QScriptValue waitForAuthenticated(int waitTime = 30000);
QScriptValue waitForFinished(int waitTime = 30000);
QScriptValue waitForDisconnected(int waitTime = 30000);
private slots:
void connected();
void connectionFailed(const QByteArray &msg);
void encrypted();
void encryptionFailed(const QByteArray &msg);
void authenticated();
void authenticationFailed(const QByteArray &msg);
void senderRejected(int mailID, const QString &address, const QByteArray &msg);
void recipientRejected(int mailID, const QString &address, const QByteArray &msg);
void mailFailed(int mailID, int errorCode, const QByteArray &msg);
void mailSent(int mailID);
void finished();
void disconnected();
private:
QxtSmtp mSmtp;
QScriptValue mOnConnected;
QScriptValue mOnConnectionFailed;
QScriptValue mOnEncrypted;
QScriptValue mOnEncryptionFailed;
QScriptValue mOnAuthenticated;
QScriptValue mOnAuthenticationFailed;
QScriptValue mOnSenderRejected;
QScriptValue mOnRecipientRejected;
QScriptValue mOnMailFailed;
QScriptValue mOnMailSent;
QScriptValue mOnFinished;
QScriptValue mOnDisconnected;
};
}
actiona-3.10.1/actions/actionpackdata/code/mailattachment.cpp 0000664 0000000 0000000 00000004556 13636457430 0024256 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mailattachment.h"
#include "code/rawdata.h"
#include
namespace Code
{
QScriptValue MailAttachment::constructor(QScriptContext *context, QScriptEngine *engine)
{
auto mailAttachment = new MailAttachment;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == QLatin1String("contentType"))
mailAttachment->setContentType(it.value().toString());
else if(it.name() == QLatin1String("content"))
mailAttachment->setContent(it.value());
}
return CodeClass::constructor(mailAttachment, context, engine);
}
QScriptValue MailAttachment::constructor(const QxtMailAttachment &attachment, QScriptEngine* engine)
{
return CodeClass::constructor(new MailAttachment(attachment), engine);
}
MailAttachment::MailAttachment()
: CodeClass()
{
}
MailAttachment::MailAttachment(const QxtMailAttachment& attachment)
: CodeClass(),
mAttachment(attachment)
{
}
QScriptValue MailAttachment::content() const
{
return RawData::constructor(mContent, engine());
}
QScriptValue MailAttachment::setContent(const QScriptValue &content)
{
if(auto rawData = qobject_cast(content.toQObject()))
mContent = rawData->byteArray();
else
mContent = content.toVariant().toByteArray();
mAttachment.setContent(mContent);
return thisObject();
}
QScriptValue MailAttachment::clone() const
{
return constructor(mAttachment, engine());
}
}
actiona-3.10.1/actions/actionpackdata/code/mailattachment.h 0000664 0000000 0000000 00000005401 13636457430 0023711 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#pragma once
#include "code/codeclass.h"
#include "qxtsmtp/qxtmailattachment.h"
#include
#include
#include
namespace Code
{
class MailAttachment : public CodeClass
{
Q_OBJECT
Q_PROPERTY(QString contentType READ contentType WRITE setContentType)
Q_PROPERTY(QScriptValue content READ content WRITE setContent)
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
static QScriptValue constructor(const QxtMailAttachment &attachment, QScriptEngine *engine);
MailAttachment();
MailAttachment(const QxtMailAttachment &attachment);
QString contentType() const { return mAttachment.contentType(); }
QScriptValue content() const;
void setContentType(const QString &contentType) { mAttachment.setContentType(contentType); }
QScriptValue setContent(const QScriptValue &content);
const QxtMailAttachment &attachment() const { return mAttachment; }
public slots:
QScriptValue clone() const;
QString toString() const override { return QStringLiteral("MailAttachment"); }
bool equals(const QScriptValue &other) const override { return defaultEqualsImplementation(other); }
QScriptValue setExtraHeader(const QString &name, const QString &value) { mAttachment.setExtraHeader(name, value); return thisObject(); }
QScriptValue removeExtraHeader(const QString &name) { mAttachment.removeExtraHeader(name); return thisObject(); }
bool hasExtraHeader(const QString &name) const { return mAttachment.hasExtraHeader(name); }
QString extraHeader(const QString &name) const { return mAttachment.extraHeader(name); }
private:
QxtMailAttachment mAttachment;
QByteArray mContent;
};
}
actiona-3.10.1/actions/actionpackdata/code/mailmessage.cpp 0000664 0000000 0000000 00000006047 13636457430 0023547 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see