pax_global_header 0000666 0000000 0000000 00000000064 12722271506 0014516 g ustar 00root root 0000000 0000000 52 comment=1ea642b5cc2914b3d97d9d49c9285db4096218e5
actiona-3.9.2/ 0000775 0000000 0000000 00000000000 12722271506 0013147 5 ustar 00root root 0000000 0000000 actiona-3.9.2/.gitignore 0000664 0000000 0000000 00000000131 12722271506 0015132 0 ustar 00root root 0000000 0000000 *.exe
*.ilk
*.pdb
*.user
*.user.*
*.dll
*.exp
*.qm
*.lib
generated
*.so*
*.log*
*.cache*
actiona-3.9.2/CHANGELOG 0000664 0000000 0000000 00000032003 12722271506 0014357 0 ustar 00root root 0000000 0000000 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.9.2/LICENSE 0000664 0000000 0000000 00000077330 12722271506 0014166 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.9.2/README 0000664 0000000 0000000 00000000620 12722271506 0014025 0 ustar 00root root 0000000 0000000 ** Actiona **
Actiona is an application that allows you to execute many actions on your
computer such as emulating mouse clicks, key presses, showing message boxes,
editing text files, etc. Tasks can be created using a simple editor or using
the EcmaScript (JavaScript) programming language for more customization.
Actiona is cross-platform.
Please visit http://actiona.tools for more information.
actiona-3.9.2/actexecuter/ 0000775 0000000 0000000 00000000000 12722271506 0015463 5 ustar 00root root 0000000 0000000 actiona-3.9.2/actexecuter/actexecuter.pro 0000664 0000000 0000000 00000002522 12722271506 0020522 0 ustar 00root root 0000000 0000000 include(../common.pri)
unix:!mac:QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN -Wl,--rpath=$${PREFIX}/$${LIBDIR}/actiona
QT += xml \
network \
script \
scripttools
equals(QT_MAJOR_VERSION, 5) {
QT += widgets
}
TARGET = actexec
VERSION = $$ACTIONA_VERSION
DESTDIR = ..
SOURCES += main.cpp \
executer.cpp \
codeexecuter.cpp \
scriptexecuter.cpp \
mainclass.cpp
HEADERS += executer.h \
codeexecuter.h \
scriptexecuter.h \
mainclass.h \
global.h
INCLUDEPATH += . \
.. \
../tools \
../actiontools
FORMS +=
win32:LIBS += -luser32 \
-ladvapi32 \
-lole32
unix:LIBS += -lXtst
LIBS += -L.. \
-ltools \
-lactiontools \
-lexecuter
win32:RC_FILE = actexecuter.rc
TRANSLATIONS = ../locale/actexecuter_fr_FR.ts \
../locale/actexecuter_de_DE.ts
unix:!mac:CONFIG += link_pkgconfig
unix:!mac:PKGCONFIG += libnotify
win32 {
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 \
../locale/actexecuter_de_DE.qm
locales.CONFIG = no_check_exist
manfile.path = $${PREFIX}/share/man/man1
manfile.files = ../docs/actexec.1
INSTALLS += target locales manfile
}
actiona-3.9.2/actexecuter/actexecuter.rc 0000664 0000000 0000000 00000000113 12722271506 0020320 0 ustar 00root root 0000000 0000000 IDI_ICON1 ICON DISCARDABLE "../gui/icons/actiona.ico"
actiona-3.9.2/actexecuter/codeexecuter.cpp 0000664 0000000 0000000 00000012457 12722271506 0020657 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "codeexecuter.h"
#include "executer/codeinitializer.h"
#include "executer/scriptagent.h"
#include "actionfactory.h"
#include "actionpack.h"
#include "executer/codestdio.h"
#include "code/codetools.h"
#include "code/prettyprinting.h"
#include "executer/codeactiona.h"
#include "global.h"
#include "languages.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
CodeExecuter::CodeExecuter(QObject *parent) :
Executer(parent),
mScriptEngine(new QScriptEngine(this)),
mScriptAgent(new LibExecuter::ScriptAgent(mScriptEngine)),
mScriptEngineDebugger(new QScriptEngineDebugger(this)),
mDebuggerWindow(mScriptEngineDebugger->standardWindow())
{
connect(mScriptEngineDebugger, SIGNAL(evaluationResumed()), this, SLOT(onEvaluationResumed()));
connect(mScriptEngineDebugger, SIGNAL(evaluationSuspended()), this, SLOT(onEvaluationPaused()));
connect(mScriptAgent, SIGNAL(executionStopped()), this, SLOT(stopExecution()));
for(QString extension: mScriptEngine->availableExtensions())
mScriptEngine->importExtension(extension);
Code::setupPrettyPrinting(*mScriptEngine);
mScriptEngineDebugger->setAutoShowStandardWindow(false);
mScriptEngineDebugger->attachTo(mScriptEngine);
QScriptEngineAgent *debuggerAgent = mScriptEngine->agent();
mScriptEngine->setAgent(mScriptAgent);
mScriptAgent->setDebuggerAgent(debuggerAgent);
}
bool CodeExecuter::start(QIODevice *device, const QString &filename)
{
if(!Executer::start(device, filename))
return false;
QString code = device->readAll();
device->close();
mScriptAgent->setContext(LibExecuter::ScriptAgent::ActionInit);
LibExecuter::CodeInitializer::initialize(mScriptEngine, mScriptAgent, actionFactory(), filename);
Code::CodeTools::addClassToScriptEngine("Console", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::print, "print", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::println, "println", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printWarning, "printWarning", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printlnWarning, "printlnWarning", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printError, "printError", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printlnError, "printlnError", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::clear, "clear", mScriptEngine);
Code::CodeTools::addClassToScriptEngine("Actiona", mScriptEngine);
LibExecuter::CodeActiona::setActExec(true);
LibExecuter::CodeActiona::setActionaVersion(Global::ACTIONA_VERSION);
LibExecuter::CodeActiona::setScriptVersion(Global::SCRIPT_VERSION);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::version, "version", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::scriptVersion, "scriptVersion", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::isActExec, "isActExec", mScriptEngine);
Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actiona", &LibExecuter::CodeActiona::isActiona, "isActiona", mScriptEngine);
QString locale = Tools::locale();
for(int actionPackIndex = 0; actionPackIndex < actionFactory()->actionPackCount(); ++actionPackIndex)
{
ActionTools::ActionPack *actionPack = actionFactory()->actionPack(actionPackIndex);
Tools::installTranslator(QString("actionpack%1").arg(actionPack->id()), locale);
}
mScriptAgent->setContext(LibExecuter::ScriptAgent::Parameters);
QScriptValue result = mScriptEngine->evaluate(code, filename);
if(result.isError())
{
QTextStream stream(stdout);
stream << QObject::tr("Uncaught exception: ") << result.toString() << "\n";
stream << tr("Backtrace: ") << mScriptEngine->uncaughtExceptionBacktrace().join("\n") << "\n";
stream.flush();
}
QTimer::singleShot(0, qApp, SLOT(quit()));
return true;
}
void CodeExecuter::onEvaluationResumed()
{
mDebuggerWindow->hide();
}
void CodeExecuter::onEvaluationPaused()
{
mDebuggerWindow->show();
}
void CodeExecuter::stopExecution()
{
mScriptEngine->abortEvaluation();
}
actiona-3.9.2/actexecuter/codeexecuter.h 0000664 0000000 0000000 00000002516 12722271506 0020317 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef CODEEXECUTER_H
#define CODEEXECUTER_H
#include "executer.h"
namespace LibExecuter
{
class ScriptAgent;
}
class QScriptEngine;
class QScriptEngineDebugger;
class QMainWindow;
class CodeExecuter : public Executer
{
Q_OBJECT
public:
explicit CodeExecuter(QObject *parent = 0);
bool start(QIODevice *device, const QString &filename);
private slots:
void onEvaluationResumed();
void onEvaluationPaused();
void stopExecution();
private:
QScriptEngine *mScriptEngine;
LibExecuter::ScriptAgent *mScriptAgent;
QScriptEngineDebugger *mScriptEngineDebugger;
QMainWindow *mDebuggerWindow;
};
#endif // CODEEXECUTER_H
actiona-3.9.2/actexecuter/executer.cpp 0000664 0000000 0000000 00000003606 12722271506 0020020 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "executer.h"
#include "actionfactory.h"
#include
#include
#include
#include
#include
Executer::Executer(QObject *parent) :
QObject(parent),
mActionFactory(new ActionTools::ActionFactory(this)),
mActionLoadingFailed(false)
{
connect(mActionFactory, SIGNAL(actionPackLoadError(QString)), this, SLOT(actionPackLoadError(QString)));
}
Executer::~Executer()
{
}
bool Executer::start(QIODevice *device, const QString &filename)
{
Q_UNUSED(device)
Q_UNUSED(filename)
QSettings settings;
QString locale = settings.value("gui/locale", QLocale::system().name()).toString();
mActionFactory->loadActionPacks(QApplication::applicationDirPath() + "/actions/", locale);
#ifndef Q_OS_WIN
if(mActionFactory->actionPackCount() == 0)
mActionFactory->loadActionPacks(QString("%1/%2/actiona/actions/").arg(ACT_PREFIX).arg(ACT_LIBDIR), locale);
#endif
if(mActionLoadingFailed)
return false;
return true;
}
ActionTools::ActionFactory *Executer::actionFactory() const
{
return mActionFactory;
}
void Executer::actionPackLoadError(const QString &error)
{
mActionLoadingFailed = true;
std::wcerr << error.toStdWString() << std::endl;
}
actiona-3.9.2/actexecuter/executer.h 0000664 0000000 0000000 00000002351 12722271506 0017461 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef EXECUTER_H
#define EXECUTER_H
#include
class QIODevice;
namespace ActionTools
{
class ActionFactory;
}
class Executer : public QObject
{
Q_OBJECT
public:
explicit Executer(QObject *parent = 0);
virtual ~Executer();
virtual bool start(QIODevice *device, const QString &filename);
protected:
ActionTools::ActionFactory *actionFactory() const;
private slots:
void actionPackLoadError(const QString &error);
private:
ActionTools::ActionFactory *mActionFactory;
bool mActionLoadingFailed;
};
#endif // EXECUTER_H
actiona-3.9.2/actexecuter/global.h 0000664 0000000 0000000 00000002043 12722271506 0017073 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef GLOBAL_H
#define GLOBAL_H
#include "version.h"
namespace Global
{
const Tools::Version ACTIONA_VERSION = Tools::Version(VERSION_TO_STRING(ACT_VERSION));
const Tools::Version SCRIPT_VERSION = Tools::Version(VERSION_TO_STRING(ACT_SCRIPT_VERSION));
const QString CONNECTIVITY_URL = "http://actiona.tools/";
}
#endif // GLOBAL_H
actiona-3.9.2/actexecuter/main.cpp 0000664 0000000 0000000 00000027042 12722271506 0017120 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "globalshortcut/globalshortcutmanager.h"
#include "qxtcommandoptions/qxtcommandoptions.h"
#include "actioninstance.h"
#include "version.h"
#include "mainclass.h"
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include "qtsingleapplication/qtsingleapplication.h"
#else
#include "nativeeventfilteringapplication.h"
#endif
#include "global.h"
#include "settings.h"
#include "languages.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#include
#endif
#ifdef Q_OS_LINUX
#undef signals
#include
#define signals
#include "keysymhelper.h"
#endif
#ifdef Q_OS_WIN
#include
#include
#include
#include
#include
#include
#endif
static void cleanup()
{
ActionTools::GlobalShortcutManager::clear();
}
#ifdef Q_OS_WIN
static void pause()
{
system("pause");
}
static void createConsole()
{
AllocConsole();
HANDLE stdHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT);
*stdout = *_fdopen(conHandle, "w");
setvbuf(stdout, NULL, _IONBF, 0);
stdHandle = GetStdHandle(STD_INPUT_HANDLE);
conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT);
*stdin = *_fdopen(conHandle, "r");
setvbuf(stdin, NULL, _IONBF, 0);
stdHandle = GetStdHandle(STD_ERROR_HANDLE);
conHandle = _open_osfhandle(reinterpret_cast(stdHandle), _O_TEXT);
*stderr = *_fdopen(conHandle, "w");
setvbuf(stderr, NULL, _IONBF, 0);
}
#endif
int main(int argc, char **argv)
{
#if (QT_VERSION < 0x050200)
#error("You need Qt 5.2.0 or later to compile Actiona Executer");
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QtSingleApplication app("actiona-exec", argc, argv);
#else
ActionTools::NativeEventFilteringApplication app("actiona-exec", argc, argv);
#endif
app.setQuitOnLastWindowClosed(false);
qAddPostRoutine(cleanup);
qsrand(std::time(NULL));
#ifdef Q_OS_LINUX
notify_init("Actiona executer");
#endif
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
#endif
QxtCommandOptions preOptions;
preOptions.add("portable", QObject::tr("starts in portable mode, storing the settings in the executable folder"));
preOptions.alias("portable", "p");
preOptions.parse(QCoreApplication::arguments());
if(preOptions.count("portable") > 0)
{
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, QApplication::applicationDirPath() + "/userSettings");
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, QApplication::applicationDirPath() + "/systemSettings");
QSettings::setDefaultFormat(QSettings::IniFormat);
}
QString locale = Tools::locale();
Tools::installQtTranslator(locale);
Tools::installTranslator("tools", locale);
Tools::installTranslator("actiontools", locale);
Tools::installTranslator("executer", locale);
Tools::installTranslator("actexecuter", locale);
const QStringList &arguments = QCoreApplication::arguments();
QxtCommandOptions options;
options.setFlagStyle(QxtCommandOptions::DoubleDash);
options.setScreenWidth(0);
options.add("code", QObject::tr("switch to code mode, may not be used with -s"));
options.alias("code", "c");
options.add("script", QObject::tr("switch to script mode, may not be used with -c"));
options.alias("script", "s");
options.add("nocodeqt", QObject::tr("do not include the Qt library into the code"));
options.alias("nocodeqt", "Q");
options.add("portable", QObject::tr("starts in portable mode, storing the settings in the executable folder"));
options.alias("portable", "p");
options.add("proxy-mode", QObject::tr("sets the proxy mode, values are \"none\", \"system\" (default) or \"custom\""));
options.add("proxy-type", QObject::tr("sets the custom proxy type, values are \"http\" or \"socks\" (default)"));
options.add("proxy-host", QObject::tr("sets the custom proxy host"));
options.add("proxy-port", QObject::tr("sets the custom proxy port"));
options.add("proxy-user", QObject::tr("sets the custom proxy user"));
options.add("proxy-password", QObject::tr("sets the custom proxy password"));
#ifdef Q_OS_WIN
options.add("console", QObject::tr("create a console to see debug output"));
options.add("pause-at-end", QObject::tr("wait for user input at the end of the execution, used only with --console"));
#endif
options.add("version", QObject::tr("show the program version"));
options.alias("version", "v");
options.add("help", QObject::tr("show this help text"));
options.alias("help", "h");
options.parse(arguments);
#ifdef Q_OS_WIN
if(options.count("console"))
{
createConsole();
if(options.count("pause-at-end"))
qAddPostRoutine(pause);
}
#endif
qRegisterMetaType("ActionInstance");
qRegisterMetaType("Exception");
qRegisterMetaType("Parameter");
qRegisterMetaType("SubParameter");
qRegisterMetaType("Version");
qRegisterMetaTypeStreamOperators("ActionInstance");
qRegisterMetaTypeStreamOperators("Parameter");
qRegisterMetaTypeStreamOperators("SubParameter");
qRegisterMetaTypeStreamOperators("Version");
if(options.count("version"))
{
QTextStream stream(stdout);
stream << "Actiona Executer version " << Global::ACTIONA_VERSION.toString() << ", script version " << Global::SCRIPT_VERSION.toString() << "\n";
stream.flush();
return 0;
}
if(options.count("help") || options.showUnrecognizedWarning() || options.positional().count() < 1 || (options.count("code") && options.count("script")))
{
QTextStream stream(stdout);
stream << QObject::tr("usage: ") << QCoreApplication::arguments().at(0) << " " << QObject::tr("[parameters]") << " " << QObject::tr("filename") << "\n";
stream << QObject::tr("Parameters are:") << "\n";
stream << options.getUsage();
stream.flush();
return -1;
}
app.addLibraryPath(QApplication::applicationDirPath() + "/actions");
app.addLibraryPath(QApplication::applicationDirPath() + "/plugins");
if(!options.count("nocodeqt"))
app.addLibraryPath(QApplication::applicationDirPath() + "/code");
#ifdef Q_OS_LINUX
{
#ifdef ACT_PROFILE
Tools::HighResolutionTimer timer("Load key codes");
#endif
ActionTools::KeySymHelper::loadKeyCodes();
}
#endif
// Proxy settings
int proxyMode = ActionTools::Settings::PROXY_SYSTEM;
if(options.value("proxy-mode").toString() == "none")
proxyMode = ActionTools::Settings::PROXY_NONE;
else if(options.value("proxy-mode").toString() == "custom")
proxyMode = ActionTools::Settings::PROXY_CUSTOM;
else if(options.value("proxy-mode").toString() == "system")
proxyMode = ActionTools::Settings::PROXY_SYSTEM;
else if(!options.value("proxy-mode").toString().isEmpty())
{
QTextStream stream(stdout);
stream << QObject::tr("Unknown proxy mode, values are \"none\", \"system\" (default) or \"custom\"") << "\n";
stream.flush();
return -1;
}
QNetworkProxy proxy;
switch(proxyMode)
{
case ActionTools::Settings::PROXY_NONE:
proxy.setType(QNetworkProxy::NoProxy);
break;
case ActionTools::Settings::PROXY_SYSTEM:
{
QUrl url(Global::CONNECTIVITY_URL);
QNetworkProxyQuery networkProxyQuery(url);
QList listOfProxies = QNetworkProxyFactory::systemProxyForQuery(networkProxyQuery);
if(!listOfProxies.isEmpty())
proxy = listOfProxies.first();
else
proxy.setType(QNetworkProxy::NoProxy);
}
break;
case ActionTools::Settings::PROXY_CUSTOM:
{
int type = ActionTools::Settings::PROXY_TYPE_SOCKS5;
if(options.value("proxy-type").toString() == "http")
type = ActionTools::Settings::PROXY_TYPE_HTTP;
else if(options.value("proxy-type").toString() == "socks")
type = ActionTools::Settings::PROXY_TYPE_SOCKS5;
else if(!options.value("proxy-type").toString().isEmpty())
{
QTextStream stream(stdout);
stream << QObject::tr("Unknown proxy type, values are \"http\" or \"socks\" (default)") << "\n";
stream.flush();
return -1;
}
QNetworkProxy proxy;
if(type == ActionTools::Settings::PROXY_TYPE_HTTP)
proxy.setType(QNetworkProxy::HttpProxy);
else
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(options.value("proxy-host").toString());
proxy.setPort(options.value("proxy-port").toInt());
proxy.setUser(options.value("proxy-user").toString());
proxy.setPassword(options.value("proxy-password").toString());
}
break;
}
QNetworkProxy::setApplicationProxy(proxy);
QUrl protocolUrl = QUrl::fromEncoded(arguments.at(1).toUtf8());
if(protocolUrl.isValid() && protocolUrl.scheme() != "actiona")
protocolUrl = QUrl();
MainClass::ExecutionMode executionMode = MainClass::Unknown;
MainClass mainClass;
if(protocolUrl.isValid())
{
QString mode;
using QStringPair = QPair;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
for(const QStringPair &queryItem: QUrlQuery(protocolUrl.query()).queryItems())
#else
for(const QStringPair &queryItem: protocolUrl.queryItems())
#endif
{
if(queryItem.first == "mode")
{
mode = queryItem.second;
break;
}
}
if(mode == "code")
executionMode = MainClass::Code;
else if(mode == "script")
executionMode = MainClass::Script;
else
{
if(protocolUrl.path().endsWith(".ascr"))
executionMode = MainClass::Script;
else if(protocolUrl.path().endsWith(".acod"))
executionMode = MainClass::Code;
else
{
QTextStream stream(stdout);
stream << QObject::tr("Unknown execution mode, please specify mode=script or mode=code") << "\n";
stream.flush();
return -1;
}
}
if(!mainClass.start(executionMode, protocolUrl))
return -1;
}
else
{
QString filename = options.positional().at(0);
if(options.count("code"))
executionMode = MainClass::Code;
else if(options.count("script"))
executionMode = MainClass::Script;
else
{
if(filename.endsWith(".ascr"))
executionMode = MainClass::Script;
else if(filename.endsWith(".acod"))
executionMode = MainClass::Code;
else
{
QTextStream stream(stdout);
stream << QObject::tr("Unknown execution mode, please specify -s (script) or -c (code)") << "\n";
stream.flush();
return -1;
}
}
QFile file(filename);
if(!file.open(QIODevice::ReadOnly))
{
QTextStream stream(stdout);
stream << QObject::tr("Unable to read input file") << "\n";
stream.flush();
return -1;
}
if(!mainClass.start(executionMode, &file, file.fileName()))
{
file.close();
return -1;
}
}
return app.exec();
}
actiona-3.9.2/actexecuter/mainclass.cpp 0000664 0000000 0000000 00000004175 12722271506 0020150 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mainclass.h"
#include "codeexecuter.h"
#include "scriptexecuter.h"
#include
#include
#include
#include
#include
#include
MainClass::MainClass()
: QObject(0),
mExecuter(0),
mNetworkAccessManager(new QNetworkAccessManager(this))
{
}
bool MainClass::start(ExecutionMode executionMode, QIODevice *device, const QString &filename)
{
if(executionMode == Script)
mExecuter = new ScriptExecuter(this);
else
mExecuter = new CodeExecuter(this);
return mExecuter->start(device, filename);
}
bool MainClass::start(ExecutionMode executionMode, const QUrl &url)
{
mExecutionMode = executionMode;
mUrl = url;
mUrl.setScheme("http");
mNetworkReply = mNetworkAccessManager->get(QNetworkRequest(mUrl));
connect(mNetworkReply, SIGNAL(finished()), this, SLOT(downloadFinished()));
return true;
}
void MainClass::downloadFinished()
{
if(mNetworkReply->error() != QNetworkReply::NoError)
{
QTextStream stream(stdout);
stream << QObject::tr("Unable to download the requested file, \"%1\"").arg(mNetworkReply->errorString()) << "\n";
stream.flush();
QApplication::exit(-1);
}
else
{
QByteArray data = mNetworkReply->readAll();
QBuffer buffer(&data);
buffer.open(QIODevice::ReadOnly);
if(!start(mExecutionMode, &buffer, mUrl.toString()))
QApplication::exit(-1);
}
mNetworkReply->close();
mNetworkReply->deleteLater();
mNetworkReply = 0;
}
actiona-3.9.2/actexecuter/mainclass.h 0000664 0000000 0000000 00000002573 12722271506 0017615 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef MAINCLASS_H
#define MAINCLASS_H
#include "version.h"
#include
#include
class Executer;
class QIODevice;
class QNetworkAccessManager;
class QNetworkReply;
class QTemporaryFile;
class MainClass : public QObject
{
Q_OBJECT
public:
enum ExecutionMode
{
Unknown,
Code,
Script
};
MainClass();
bool start(ExecutionMode executionMode, QIODevice *device, const QString &filename);
bool start(ExecutionMode executionMode, const QUrl &url);
private slots:
void downloadFinished();
private:
Executer *mExecuter;
QNetworkAccessManager *mNetworkAccessManager;
QNetworkReply *mNetworkReply;
ExecutionMode mExecutionMode;
QUrl mUrl;
};
#endif // MAINCLASS_H
actiona-3.9.2/actexecuter/scriptexecuter.cpp 0000664 0000000 0000000 00000005474 12722271506 0021252 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "scriptexecuter.h"
#include "script.h"
#include "executer/executer.h"
#include "mainclass.h"
#include "global.h"
#include
#include
ScriptExecuter::ScriptExecuter(QObject *parent) :
Executer(parent),
mScript(new ActionTools::Script(actionFactory(), this)),
mExecuter(new LibExecuter::Executer(this))
{
connect(mExecuter, SIGNAL(executionStopped()), this, SLOT(executionStopped()));
connect(mExecuter, SIGNAL(scriptError(int,QString,QString)), this, SLOT(scriptError(int,QString,QString)));
}
bool ScriptExecuter::start(QIODevice *device, const QString &filename)
{
if(!Executer::start(device, filename))
return false;
ActionTools::Script::ReadResult result = mScript->read(device, Global::SCRIPT_VERSION);
switch(result)
{
case ActionTools::Script::ReadInternal:
{
QTextStream stream(stdout);
stream << QObject::tr("Reading script file failed due to an internal error") << "\n";
stream.flush();
}
return false;
case ActionTools::Script::ReadInvalidSchema:
{
QTextStream stream(stdout);
stream << QObject::tr("Input script file has an invalid script schema") << "\n";
stream.flush();
}
return false;
case ActionTools::Script::ReadInvalidScriptVersion:
{
QTextStream stream(stdout);
stream << QObject::tr("Input script file is too recent") << "\n";
stream.flush();
}
return false;
default:
break;
}
device->close();
mExecuter->setup(mScript, actionFactory(), false, 0, 0, false, 0, 0, mScript->pauseBefore(), mScript->pauseAfter(), Global::ACTIONA_VERSION, Global::SCRIPT_VERSION, true, 0);
if(!mExecuter->startExecution(false, 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.9.2/actexecuter/scriptexecuter.h 0000664 0000000 0000000 00000002365 12722271506 0020713 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef SCRIPTEXECUTER_H
#define SCRIPTEXECUTER_H
#include "executer.h"
namespace ActionTools
{
class Script;
}
namespace LibExecuter
{
class Executer;
}
class ScriptExecuter : public Executer
{
Q_OBJECT
public:
explicit ScriptExecuter(QObject *parent = 0);
bool start(QIODevice *device, const QString &filename);
public slots:
void executionStopped();
void scriptError(int actionIndex, const QString ¶meter, const QString &error);
private:
ActionTools::Script *mScript;
LibExecuter::Executer *mExecuter;
};
#endif // SCRIPTEXECUTER_H
actiona-3.9.2/actiona.desktop 0000664 0000000 0000000 00000000637 12722271506 0016166 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.9.2/actiona.pro 0000664 0000000 0000000 00000003577 12722271506 0015323 0 ustar 00root root 0000000 0000000 TEMPLATE = subdirs
CONFIG = ordered
unix:!mac {
!system(pkg-config --exists 'x11') {
error(Please install pkg-config) #Here whe assume that x11 is always present, so this is to check if pkg-config is installed
}
!system(pkg-config --exists 'libnotify') {
error(Please install libnotify-dev)
}
!system(pkg-config --exists 'xtst') {
error(Please install libxtst-dev)
}
!system(pkg-config --exists 'opencv') {
error(Please install libopencv-dev)
}
}
win32-g++:error(Mingw is currently not supported, please use the Microsoft compiler suite)
contains(DEFINES, ACT_NO_UPDATER){
message(** No updater will be built **)
}
contains(DEFINES, ACT_PROFILE){
message(** Profiling activated **)
}
unix:QMAKE_CLEAN += actions/*.so
win32:QMAKE_CLEAN += actions/*.dll
QMAKE_CLEAN += locale/*.qm
isEmpty(QMAKE_LRELEASE) {
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
locale_release.name = lrelease
locale_release.commands = \
$$QMAKE_LRELEASE tools/tools.pro && \
$$QMAKE_LRELEASE actiontools/actiontools.pro && \
$$QMAKE_LRELEASE executer/executer.pro && \
$$QMAKE_LRELEASE actexecuter/actexecuter.pro && \
$$QMAKE_LRELEASE gui/gui.pro && \
$$QMAKE_LRELEASE actions/actionpackinternal/actionpackinternal.pro && \
$$QMAKE_LRELEASE actions/actionpackwindows/actionpackwindows.pro && \
$$QMAKE_LRELEASE actions/actionpackdevice/actionpackdevice.pro && \
$$QMAKE_LRELEASE actions/actionpacksystem/actionpacksystem.pro && \
$$QMAKE_LRELEASE actions/actionpackdata/actionpackdata.pro
locale_release.CONFIG = no_link
QMAKE_EXTRA_TARGETS += locale_release
SUBDIRS += tools \
actiontools \
executer \
actexecuter \
gui \
actions/actionpackinternal \
actions/actionpackwindows \
actions/actionpackdevice \
actions/actionpacksystem \
actions/actionpackdata
actiona-3.9.2/actions/ 0000775 0000000 0000000 00000000000 12722271506 0014607 5 ustar 00root root 0000000 0000000 actiona-3.9.2/actions/actionpackdata/ 0000775 0000000 0000000 00000000000 12722271506 0017555 5 ustar 00root root 0000000 0000000 actiona-3.9.2/actions/actionpackdata/actionpackdata.h 0000664 0000000 0000000 00000010200 12722271506 0022665 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef ACTIONPACKDATA_H
#define ACTIONPACKDATA_H
#include "actionpack.h"
#include "actions/writetextfiledefinition.h"
#include "actions/readtextfiledefinition.h"
#include "actions/writeinifiledefinition.h"
#include "actions/readinifiledefinition.h"
#include "actions/readregistrydefinition.h"
#include "actions/writeregistrydefinition.h"
#include "actions/readclipboarddefinition.h"
#include "actions/writeclipboarddefinition.h"
#include "actions/readbinaryfiledefinition.h"
#include "actions/writebinaryfiledefinition.h"
#include "actions/readenvironmentdefinition.h"
#include "actions/copyfiledefinition.h"
#include "actions/webdownloaddefinition.h"
#include "actions/sendmaildefinition.h"
#include "code/file.h"
#include "code/clipboard.h"
#include "code/registry.h"
#include "code/inifile.h"
#include "code/udp.h"
#include "code/tcp.h"
#include "code/sql.h"
#include "code/tcpserver.h"
#include "code/web.h"
#include "code/mailattachment.h"
#include "code/mailmessage.h"
#include "code/mail.h"
#include
namespace ActionTools
{
class ActionDefinition;
}
class ActionPackData : public QObject, public ActionTools::ActionPack
{
Q_OBJECT
Q_INTERFACES(ActionTools::ActionPack)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
Q_PLUGIN_METADATA(IID "tools.actiona.ActionPack" FILE "data.json")
#endif
public:
ActionPackData() {}
void createDefinitions()
{
addActionDefinition(new Actions::WriteTextFileDefinition(this));
addActionDefinition(new Actions::ReadTextFileDefinition(this));
addActionDefinition(new Actions::WriteIniFileDefinition(this));
addActionDefinition(new Actions::ReadIniFileDefinition(this));
addActionDefinition(new Actions::ReadRegistryDefinition(this));
addActionDefinition(new Actions::WriteRegistryDefinition(this));
addActionDefinition(new Actions::ReadClipboardDefinition(this));
addActionDefinition(new Actions::WriteClipboardDefinition(this));
addActionDefinition(new Actions::ReadBinaryFileDefinition(this));
addActionDefinition(new Actions::WriteBinaryFileDefinition(this));
addActionDefinition(new Actions::ReadEnvironmentVariableDefinition(this));
addActionDefinition(new Actions::CopyFileDefinition(this));
addActionDefinition(new Actions::WebDownloadDefinition(this));
addActionDefinition(new Actions::SendMailDefinition(this));
}
QString id() const { return "data"; }
QString name() const { return tr("Data related actions"); }
Tools::Version version() const { return Tools::Version(0, 0, 1); }
void codeInit(QScriptEngine *scriptEngine) const
{
addCodeClass("File", scriptEngine);
Code::File::registerClass(scriptEngine);
addCodeClass("Clipboard", scriptEngine);
addCodeClass("Registry", scriptEngine);
addCodeClass("IniFile", scriptEngine);
addCodeClass("Udp", scriptEngine);
addCodeClass("Tcp", scriptEngine);
addCodeClass("Sql", scriptEngine);
Code::Sql::registerClass(scriptEngine);
addCodeClass("TcpServer", scriptEngine);
addCodeClass("Web", scriptEngine);
addCodeClass("MailAttachment", scriptEngine);
addCodeClass("MailMessage", scriptEngine);
addCodeClass("Mail", scriptEngine);
}
private:
Q_DISABLE_COPY(ActionPackData)
};
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
Q_EXPORT_PLUGIN2(ActionPackData, ActionPackData)
#endif
#endif // ACTIONPACKDATA_H
actiona-3.9.2/actions/actionpackdata/actionpackdata.pro 0000664 0000000 0000000 00000001274 12722271506 0023251 0 ustar 00root root 0000000 0000000 include(../common_actions.pri)
include(actions/actions.pri)
include(code/code.pri)
TARGET = ActionPackData
QT += script network sql
equals(QT_MAJOR_VERSION, 5) {
QT += widgets
OTHER_FILES += data.json
}
HEADERS += actionpackdata.h
win32:LIBS += -ladvapi32 \
-lshell32
win32:INCLUDEPATH += $${BOOST_INCLUDE}
TRANSLATIONS = ../../locale/actionpackdata_fr_FR.ts \
../../locale/actionpackdata_de_DE.ts
RESOURCES += \
actionpackdata.qrc
unix {
locales.path = $${PREFIX}/share/actiona/locale
locales.files = ../../locale/actionpackdata_fr_FR.qm \
../../locale/actionpackdata_de_DE.qm
locales.CONFIG = no_check_exist
INSTALLS += locales
}
actiona-3.9.2/actions/actionpackdata/actionpackdata.qrc 0000664 0000000 0000000 00000001214 12722271506 0023230 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.9.2/actions/actionpackdata/actions/ 0000775 0000000 0000000 00000000000 12722271506 0021215 5 ustar 00root root 0000000 0000000 actiona-3.9.2/actions/actionpackdata/actions/actions.pri 0000664 0000000 0000000 00000002463 12722271506 0023376 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.9.2/actions/actionpackdata/actions/copyfiledefinition.h 0000664 0000000 0000000 00000005352 12722271506 0025256 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef COPYFILEDEFINITION_H
#define COPYFILEDEFINITION_H
#include "actiondefinition.h"
#include "copyfileinstance.h"
#include "fileparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class CopyFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit CopyFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::FileParameterDefinition *source = new ActionTools::FileParameterDefinition(ActionTools::Name("source", tr("Source file")), this);
source->setTooltip(tr("The file to copy"));
source->setMode(ActionTools::FileEdit::FileOpen);
source->setCaption(tr("Choose the file"));
source->setFilter(tr("All files (*.*)"));
addElement(source);
ActionTools::FileParameterDefinition *destination = new ActionTools::FileParameterDefinition(ActionTools::Name("destination", tr("Destination")), this);
destination->setTooltip(tr("The destination file"));
destination->setMode(ActionTools::FileEdit::FileSave);
destination->setCaption(tr("Choose the destination file"));
destination->setFilter(tr("All files (*.*)"));
addElement(destination);
addException(CopyFileInstance::UnableToReadFileException, tr("Unable to read source file"));
addException(CopyFileInstance::UnableToWriteFileException, tr("Unable to write destination file"));
}
QString name() const { return QObject::tr("Copy file"); }
QString id() const { return "ActionCopyFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Copy a file"); }
ActionTools::ActionInstance *newActionInstance() const { return new CopyFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/copyfile.png"); }
private:
Q_DISABLE_COPY(CopyFileDefinition)
};
}
#endif // COPYFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/copyfileinstance.h 0000664 0000000 0000000 00000004351 12722271506 0024730 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef COPYFILEINSTANCE_H
#define COPYFILEINSTANCE_H
#include "datacopyactioninstance.h"
#include
namespace Actions
{
class CopyFileInstance : public ActionTools::DataCopyActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException,
UnableToWriteFileException
};
CopyFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::DataCopyActionInstance(definition, parent)
{
}
void startExecution()
{
bool ok = true;
QString sourceFile = evaluateString(ok, "source");
QString destinationFile = evaluateString(ok, "destination");
if(!ok)
return;
mSourceFile.setFileName(sourceFile);
mDestinationFile.setFileName(destinationFile);
if(!mSourceFile.open(QIODevice::ReadOnly))
{
setCurrentParameter("source");
emit executionException(UnableToReadFileException, tr("Unable to read the source file \"%1\"").arg(sourceFile));
return;
}
if(!mDestinationFile.open(QIODevice::WriteOnly))
{
mSourceFile.close();
setCurrentParameter("destination");
emit executionException(UnableToWriteFileException, tr("Unable to write to \"%1\"").arg(destinationFile));
return;
}
DataCopyActionInstance::startCopy(&mSourceFile, &mDestinationFile);
emit showProgressDialog("Copying file", 100);
emit updateProgressDialog("Copying in progress");
}
private:
QFile mSourceFile;
QFile mDestinationFile;
Q_DISABLE_COPY(CopyFileInstance)
};
}
#endif // COPYFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/readbinaryfiledefinition.h 0000664 0000000 0000000 00000005077 12722271506 0026430 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READBINARYFILEDEFINITION_H
#define READBINARYFILEDEFINITION_H
#include "actiondefinition.h"
#include "readbinaryfileinstance.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadBinaryFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadBinaryFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file to read from"));
file->setMode(ActionTools::FileEdit::FileOpen);
file->setCaption(tr("Choose the file"));
file->setFilter(tr("All files (*.*)"));
addElement(file);
ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
variable->setTooltip(tr("The variable where to store the data"));
addElement(variable);
addException(ReadBinaryFileInstance::UnableToReadFileException, tr("Unable to read file"));
}
QString name() const { return QObject::tr("Read binary file"); }
QString id() const { return "ActionReadBinaryFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Read a binary file"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadBinaryFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readbinary.png"); }
private:
Q_DISABLE_COPY(ReadBinaryFileDefinition)
};
}
#endif // READBINARYFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/readbinaryfileinstance.h 0000664 0000000 0000000 00000004235 12722271506 0026077 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READBINARYFILEINSTANCE_H
#define READBINARYFILEINSTANCE_H
#include "datacopyactioninstance.h"
#include "code/rawdata.h"
#include
#include
namespace Actions
{
class ReadBinaryFileInstance : public ActionTools::DataCopyActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException
};
ReadBinaryFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::DataCopyActionInstance(definition, parent)
{
}
void startExecution()
{
bool ok = true;
QString filename = evaluateString(ok, "file");
mVariable = evaluateVariable(ok, "variable");
if(!ok)
return;
mFile.setFileName(filename);
if(!DataCopyActionInstance::startCopy(&mFile, &mResult))
{
setCurrentParameter("file");
emit executionException(UnableToReadFileException, tr("Unable to read the file \"%1\"").arg(filename));
return;
}
emit showProgressDialog("Reading file", 100);
emit updateProgressDialog("Reading in progress");
}
private slots:
void done()
{
setVariable(mVariable, Code::RawData::constructor(mResult.buffer(), scriptEngine()));
DataCopyActionInstance::done();
}
private:
void clean()
{
DataCopyActionInstance::clean();
mResult.buffer().clear();
}
QFile mFile;
QBuffer mResult;
QString mVariable;
Q_DISABLE_COPY(ReadBinaryFileInstance)
};
}
#endif // READBINARYFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/readclipboarddefinition.h 0000664 0000000 0000000 00000004223 12722271506 0026233 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READCLIPBOARDDEFINITION_H
#define READCLIPBOARDDEFINITION_H
#include "actiondefinition.h"
#include "readclipboardinstance.h"
#include "textparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadClipboardDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadClipboardDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::VariableParameterDefinition *output = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
output->setTooltip(tr("The variable where to save the current clipboard value"));
addElement(output);
}
QString name() const { return QObject::tr("Read clipboard"); }
QString id() const { return "ActionReadClipboard"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Read the clipboard contents"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadClipboardInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readclipboard.png"); }
private:
Q_DISABLE_COPY(ReadClipboardDefinition)
};
}
#endif // READCLIPBOARDDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/readclipboardinstance.h 0000664 0000000 0000000 00000002731 12722271506 0025711 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READCLIPBOARDINSTANCE_H
#define READCLIPBOARDINSTANCE_H
#include "actioninstance.h"
#include "script.h"
#include
#include
namespace Actions
{
class ReadClipboardInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
ReadClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution()
{
bool ok = true;
QString variable = evaluateVariable(ok, "variable");
if(!ok)
return;
QClipboard *clipboard = QApplication::clipboard();
setVariable(variable, clipboard->text());
emit executionEnded();
}
private:
Q_DISABLE_COPY(ReadClipboardInstance)
};
}
#endif // READCLIPBOARDINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/readenvironmentdefinition.h 0000664 0000000 0000000 00000007032 12722271506 0026641 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READENVIRONMENTDEFINITION_H
#define READENVIRONMENTDEFINITION_H
#include "actiondefinition.h"
#include "readenvironmentinstance.h"
#include "variableparameterdefinition.h"
#include "listparameterdefinition.h"
#include "environmentvariableparameterdefinition.h"
#include "groupdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadEnvironmentVariableDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadEnvironmentVariableDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("ReadEnvironmentVariableInstance::modes", ReadEnvironmentVariableInstance::modes);
ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
variable->setTooltip(tr("The variable used to store the selected information from your system environment"));
addElement(variable);
ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this);
mode->setTooltip(tr("The environment read mode"));
mode->setItems(ReadEnvironmentVariableInstance::modes);
mode->setDefaultValue(ReadEnvironmentVariableInstance::modes.second.at(ReadEnvironmentVariableInstance::oneVariableMode));
addElement(mode);
ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this);
selectionMode->setMasterList(mode);
selectionMode->setMasterValues(QStringList() << ReadEnvironmentVariableInstance::modes.first.at(ReadEnvironmentVariableInstance::oneVariableMode));
ActionTools::EnvironmentVariableParameterDefinition *environmentVariableName = new ActionTools::EnvironmentVariableParameterDefinition(ActionTools::Name("environmentVariableName", tr("Environment Variable")), this);
environmentVariableName->setTooltip(tr("The specific environment variable to read"));
selectionMode->addMember(environmentVariableName);
addElement(selectionMode);
}
QString name() const { return QObject::tr("Read environment variable"); }
QString id() const { return "ActionReadEnvironmentVariable"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Read a single or multiple environment variables"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadEnvironmentVariableInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readenvironment.png"); }
private:
Q_DISABLE_COPY(ReadEnvironmentVariableDefinition)
};
}
#endif // READENVIRONMENTDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/readenvironmentinstance.cpp 0000664 0000000 0000000 00000004632 12722271506 0026653 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readenvironmentinstance.h"
#include
#include
#include
#include
#include
namespace Actions
{
ActionTools::StringListPair ReadEnvironmentVariableInstance::modes = qMakePair(
QStringList() << "allVariables" << "oneVariable",
QStringList() << QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read all") << QT_TRANSLATE_NOOP("ReadEnvironmentVariableInstance::modes", "Read one"));
void ReadEnvironmentVariableInstance::startExecution()
{
bool ok = true;
QString variable = evaluateVariable(ok, "variable");
Mode mode = evaluateListElement(ok, modes, "mode");
if(!ok)
return;
const QStringList &environment = QProcessEnvironment::systemEnvironment().toStringList();
QHash environmentHashVariableValue;
environmentHashVariableValue.reserve(environment.count()+2); //doc said ideally 'slightly more than the maximum nb of item'
for(QString environmentVariableAndValue: environment)
{
QStringList KeyValue = environmentVariableAndValue.split("=");
environmentHashVariableValue[KeyValue.at(0)] = KeyValue.at(1);
}
if(mode == oneVariableMode)
{
QString environmentVariable = evaluateString(ok, "environmentVariableName");
if (environmentHashVariableValue.contains(environmentVariable))
setVariable(variable, environmentHashVariableValue.value(environmentVariable));
else
{
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The specified variable cannot be found in the system environment"));
return;
}
}
else
setArrayKeyValue(variable, environmentHashVariableValue);
emit executionEnded();
}
}
actiona-3.9.2/actions/actionpackdata/actions/readenvironmentinstance.h 0000664 0000000 0000000 00000002547 12722271506 0026323 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READENVIRONMENTINSTANCE_H
#define READENVIRONMENTINSTANCE_H
#include "actioninstance.h"
#include "script.h"
namespace Actions
{
class ReadEnvironmentVariableInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
allVariablesMode,
oneVariableMode
};
ReadEnvironmentVariableInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
static ActionTools::StringListPair modes;
void startExecution();
private:
Q_DISABLE_COPY(ReadEnvironmentVariableInstance)
};
}
#endif // READENVIRONMENTINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/readinifiledefinition.h 0000664 0000000 0000000 00000010012 12722271506 0025704 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READINIFILEDEFINITION_H
#define READINIFILEDEFINITION_H
#include "actiondefinition.h"
#include "readinifileinstance.h"
#include "textparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
#include "listparameterdefinition.h"
#include "groupdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadIniFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadIniFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("ReadIniFileInstance::modes", ReadIniFileInstance::modes);
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file to read from"));
file->setMode(ActionTools::FileEdit::FileOpen);
file->setCaption(tr("Choose the INI file"));
file->setFilter(tr("INI files (*.ini);;All files (*.*)"));
addElement(file);
ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
variable->setTooltip(tr("The variable where to store the data"));
addElement(variable);
ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this);
mode->setTooltip(tr("The INI file read mode"));
mode->setItems(ReadIniFileInstance::modes);
mode->setDefaultValue(ReadIniFileInstance::modes.second.at(ReadIniFileInstance::SingleParameter));
addElement(mode);
ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this);
selectionMode->setMasterList(mode);
selectionMode->setMasterValues(QStringList() << ReadIniFileInstance::modes.first.at(ReadIniFileInstance::SingleParameter));
ActionTools::TextParameterDefinition *section = new ActionTools::TextParameterDefinition(ActionTools::Name("section", tr("Section")), this);
section->setTooltip(tr("The parameter section"));
selectionMode->addMember(section);
ActionTools::TextParameterDefinition *parameter = new ActionTools::TextParameterDefinition(ActionTools::Name("parameter", tr("Parameter")), this);
parameter->setTooltip(tr("The parameter name"));
selectionMode->addMember(parameter);
addElement(selectionMode);
addException(ReadIniFileInstance::UnableToReadFileException, tr("Unable to read file"));
addException(ReadIniFileInstance::UnableToFindSectionException, tr("Unable to find section"));
}
QString name() const { return QObject::tr("Read INI file"); }
QString id() const { return "ActionReadIniFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Read one or all the entries in an INI file"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadIniFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readini.png"); }
private:
Q_DISABLE_COPY(ReadIniFileDefinition)
};
}
#endif // READINIFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/readinifileinstance.cpp 0000664 0000000 0000000 00000006652 12722271506 0025732 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readinifileinstance.h"
#include "stringlistpair.h"
#include
#include
namespace Actions
{
ActionTools::StringListPair ReadIniFileInstance::modes = qMakePair(
QStringList() << "singleParameter" << "wholeFile",
QStringList() << QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read a single parameter") << QT_TRANSLATE_NOOP("ReadIniFileInstance::modes", "Read the entire file"));
void ReadIniFileInstance::startExecution()
{
bool ok = true;
QString filename = evaluateString(ok, "file");
QString variable = evaluateVariable(ok, "variable");
Mode mode = evaluateListElement(ok, modes, "mode");
if(!ok)
return;
if(filename.isEmpty())
{
emit executionException(UnableToReadFileException, tr("Unable to read the file"));
return;
}
boost::property_tree::ptree tree;
try
{
boost::property_tree::ini_parser::read_ini(filename.toStdString(), tree);
}
catch(const std::runtime_error &e)
{
setCurrentParameter("filename");
emit executionException(UnableToReadFileException, tr("Unable to read the file"));
return;
}
if(mode == WholeFile)
{
QHash fileContent;
for(const auto §ion: tree)
{
for(const auto ¶meter: section.second)
{
fileContent[QString::fromStdString(section.first + "/" + parameter.first)] = QString::fromStdString(parameter.second.get_value());
}
}
setArrayKeyValue(variable, fileContent);
}
else
{
QString section = evaluateString(ok, "section");
QString parameter = evaluateString(ok, "parameter");
if(!ok)
return;
auto sectionNode = tree.get_child_optional(section.toStdString());
if(!sectionNode)
{
setCurrentParameter("section");
emit executionException(UnableToFindSectionException, tr("Unable to find the section named \"%1\"").arg(section));
return;
}
try
{
setVariable(variable, QString::fromStdString((*sectionNode).get(parameter.toStdString())));
}
catch(const std::runtime_error &e)
{
setCurrentParameter("parameter");
emit executionException(UnableToFindSectionException, tr("Unable to find the parameter named \"%1\"").arg(parameter));
return;
}
}
emit executionEnded();
}
}
actiona-3.9.2/actions/actionpackdata/actions/readinifileinstance.h 0000664 0000000 0000000 00000002653 12722271506 0025374 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READINIFILEINSTANCE_H
#define READINIFILEINSTANCE_H
#include "actioninstance.h"
namespace Actions
{
class ReadIniFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
SingleParameter,
WholeFile
};
enum Exceptions
{
UnableToReadFileException = ActionTools::ActionException::UserException,
UnableToFindSectionException
};
ReadIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
static ActionTools::StringListPair modes;
void startExecution();
private:
Q_DISABLE_COPY(ReadIniFileInstance)
};
}
#endif // READINIFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/readregistrydefinition.h 0000664 0000000 0000000 00000006336 12722271506 0026153 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READREGISTRYDEFINITION_H
#define READREGISTRYDEFINITION_H
#include "actiondefinition.h"
#include "readregistryinstance.h"
#include "listparameterdefinition.h"
#include "textparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadRegistryDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadRegistryDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::ListParameterDefinition *key = new ActionTools::ListParameterDefinition(ActionTools::Name("key", tr("Key")), this);
key->setTooltip(tr("The registry key to read from"));
key->setItems(ReadRegistryInstance::keys);
key->setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser));
addElement(key);
ActionTools::TextParameterDefinition *subKey = new ActionTools::TextParameterDefinition(ActionTools::Name("subKey", tr("Subkey")), this);
subKey->setTooltip(tr("The registry subkey to read from"));
addElement(subKey);
ActionTools::TextParameterDefinition *value = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this);
value->setTooltip(tr("The value to read"));
addElement(value);
ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
variable->setTooltip(tr("The variable where to save the value read from the registry"));
addElement(variable);
addException(ReadRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey"));
addException(ReadRegistryInstance::CannotFindValueException, tr("Cannot find value"));
addException(ReadRegistryInstance::InvalidValueType, tr("Invalid value type"));
}
QString name() const { return QObject::tr("Read registry"); }
QString id() const { return "ActionReadRegistry"; }
ActionTools::Flag flags() const { return ActionTools::WorksOnWindows | ActionTools::Official; }
QString description() const { return QObject::tr("Read an entry from the registry"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadRegistryInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readregistry.png"); }
private:
Q_DISABLE_COPY(ReadRegistryDefinition)
};
}
#endif // READREGISTRYDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/readregistryinstance.cpp 0000664 0000000 0000000 00000004456 12722271506 0026163 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readregistryinstance.h"
#include
#ifdef Q_OS_WIN
#include
#endif
namespace Actions
{
ActionTools::StringListPair ReadRegistryInstance::keys = qMakePair(
QStringList() << "classesRoot" << "currentConfig" << "currentUser" << "users" << "localMachine",
QStringList() << "Classes root" << "Current config" << "Current user" << "Users" << "Local machine");
//Note : This is not translated, because this is not translated either in Regedit
void ReadRegistryInstance::startExecution()
{
#ifdef Q_OS_WIN
bool ok = true;
ActionTools::Registry::Key key = evaluateListElement(ok, keys, "key");
QString subKey = evaluateString(ok, "subKey");
QString value = evaluateString(ok, "value");
QString variable = evaluateVariable(ok, "variable");
if(!ok)
return;
QVariant resultValue;
switch(ActionTools::Registry::read(resultValue, key, subKey, value))
{
case ActionTools::Registry::ReadCannotFindSubKey:
setCurrentParameter("subKey");
emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey));
return;
case ActionTools::Registry::ReadCannotFindValue:
setCurrentParameter("value");
emit executionException(CannotFindValueException, tr("Cannot find value \"%1\"").arg(value));
return;
case ActionTools::Registry::ReadInvalidValueType:
setCurrentParameter("value");
emit executionException(CannotFindValueException, tr("Invalid value type"));
return;
default:
setVariable(variable, scriptEngine()->newVariant(resultValue));
break;
}
#endif
emit executionEnded();
}
}
actiona-3.9.2/actions/actionpackdata/actions/readregistryinstance.h 0000664 0000000 0000000 00000002623 12722271506 0025622 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READREGISTRYINSTANCE_H
#define READREGISTRYINSTANCE_H
#include "actioninstance.h"
#include "stringlistpair.h"
#include "registry.h"
namespace Actions
{
class ReadRegistryInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
CannotFindSubKeyException = ActionTools::ActionException::UserException,
CannotFindValueException,
InvalidValueType
};
ReadRegistryInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
static ActionTools::StringListPair keys;
void startExecution();
private:
Q_DISABLE_COPY(ReadRegistryInstance)
};
}
#endif // READREGISTRYINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/readtextfiledefinition.h 0000664 0000000 0000000 00000007715 12722271506 0026131 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READTEXTFILEDEFINITION_H
#define READTEXTFILEDEFINITION_H
#include "actiondefinition.h"
#include "readtextfileinstance.h"
#include "fileparameterdefinition.h"
#include "variableparameterdefinition.h"
#include "numberparameterdefinition.h"
#include "listparameterdefinition.h"
#include "groupdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class ReadTextFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit ReadTextFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("ReadTextFileInstance::modes", ReadTextFileInstance::modes);
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file you want to read"));
addElement(file);
ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
variable->setTooltip(tr("The variable where to save the text read from the file"));
addElement(variable);
ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this);
mode->setTooltip(tr("The file read mode"));
mode->setItems(ReadTextFileInstance::modes);
mode->setDefaultValue(ReadTextFileInstance::modes.second.at(ReadTextFileInstance::Full));
addElement(mode, 1);
ActionTools::GroupDefinition *selectionMode = new ActionTools::GroupDefinition(this);
selectionMode->setMasterList(mode);
selectionMode->setMasterValues(QStringList() << ReadTextFileInstance::modes.first.at(ReadTextFileInstance::Selection));
ActionTools::NumberParameterDefinition *firstline = new ActionTools::NumberParameterDefinition(ActionTools::Name("firstline", tr("First line")), this);
firstline->setTooltip(tr("The line where to start reading the file"));
firstline->setMinimum(1);
firstline->setDefaultValue(1);
selectionMode->addMember(firstline, 1);
ActionTools::NumberParameterDefinition *lastline = new ActionTools::NumberParameterDefinition(ActionTools::Name("lastline", tr("Last line")), this);
lastline->setTooltip(tr("The line where to stop reading the file"));
lastline->setMinimum(1);
lastline->setDefaultValue(1);
selectionMode->addMember(lastline, 1);
addElement(selectionMode, 1);
addException(ReadTextFileInstance::CannotOpenFileException, tr("Cannot read file"));
}
QString name() const { return QObject::tr("Read text file"); }
QString id() const { return "ActionReadTextFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Read a plain text file"); }
ActionTools::ActionInstance *newActionInstance() const { return new ReadTextFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/readtext.png"); }
QStringList tabs() const { return ActionDefinition::StandardTabs; }
private:
Q_DISABLE_COPY(ReadTextFileDefinition)
};
}
#endif // READTEXTFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/readtextfileinstance.cpp 0000664 0000000 0000000 00000005547 12722271506 0026141 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "readtextfileinstance.h"
#include
#include
namespace Actions
{
ActionTools::StringListPair ReadTextFileInstance::modes = qMakePair(
QStringList() << "full" << "selection",
QStringList() << QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read the entire file") << QT_TRANSLATE_NOOP("ReadTextFileInstance::modes", "Read only a selection"));
void ReadTextFileInstance::startExecution()
{
bool ok = true;
QString filepath = evaluateString(ok, "file");
QString variable = evaluateVariable(ok, "variable");
Mode mode = evaluateListElement(ok, modes, "mode");
int firstline = evaluateInteger(ok, "firstline");
int lastline = evaluateInteger(ok, "lastline");
if(!ok)
return;
if(mode == Selection)
{
if(firstline < 1)
{
setCurrentParameter("firstline");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid first line value : %1").arg(firstline));
return;
}
if(lastline < 1)
{
setCurrentParameter("lastline");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid last line value : %1").arg(lastline));
return;
}
if(lastline < firstline)
{
setCurrentParameter("firstline");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("The first line has to be smaller than the last line"));
return;
}
}
QFile file(filepath);
if(!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
setCurrentParameter("file");
emit executionException(CannotOpenFileException, tr("Cannot open file"));
return;
}
//Line counting starts at 1
--firstline;
--lastline;
QString result;
QTextStream stream(&file);
stream.setAutoDetectUnicode(true);
if(mode == Full)
result = stream.readAll();
else
{
for(int line = 0; !stream.atEnd(); ++line)
{
QString readLine = stream.readLine();
if(line >= firstline && line <= lastline)
{
if(!result.isEmpty())
result += '\n';
result += readLine;
}
if(line > lastline)
break;
}
}
setVariable(variable, result);
file.close();
emit executionEnded();
}
}
actiona-3.9.2/actions/actionpackdata/actions/readtextfileinstance.h 0000664 0000000 0000000 00000002605 12722271506 0025576 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef READTEXTFILEINSTANCE_H
#define READTEXTFILEINSTANCE_H
#include "actioninstance.h"
#include "stringlistpair.h"
namespace Actions
{
class ReadTextFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
Full,
Selection
};
enum Exceptions
{
CannotOpenFileException = ActionTools::ActionException::UserException
};
ReadTextFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
static ActionTools::StringListPair modes;
void startExecution();
private:
Q_DISABLE_COPY(ReadTextFileInstance)
};
}
#endif // READTEXTFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/sendmaildefinition.h 0000664 0000000 0000000 00000016706 12722271506 0025245 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef SENDMAILDEFINITION_H
#define SENDMAILDEFINITION_H
#include "actiondefinition.h"
#include "sendmailinstance.h"
#include "textparameterdefinition.h"
#include "booleanparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "listparameterdefinition.h"
#include "numberparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class SendMailDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit SendMailDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("SendMailInstance::attachmentContentTypes", SendMailInstance::attachmentContentTypes);
ActionTools::TextParameterDefinition *serverName = new ActionTools::TextParameterDefinition(ActionTools::Name("serverName", tr("Server name")), this);
serverName->setTooltip(tr("The name or IP of the SMTP server to use\nExample: mail.example.com"));
addElement(serverName);
ActionTools::BooleanParameterDefinition *secureConnection = new ActionTools::BooleanParameterDefinition(ActionTools::Name("secureConnection", tr("Secure connection")), this);
secureConnection->setTooltip(tr("Secure (encrypted) connection to the server"));
secureConnection->setDefaultValue(true);
addElement(secureConnection);
ActionTools::TextParameterDefinition *userName = new ActionTools::TextParameterDefinition(ActionTools::Name("userName", tr("User name")), this);
userName->setTooltip(tr("The user (or login) name to use\nMany SMTP servers use the e-mail address as user name"));
addElement(userName);
ActionTools::TextParameterDefinition *password = new ActionTools::TextParameterDefinition(ActionTools::Name("password", tr("Password")), this);
password->setTooltip(tr("The password to use"));
addElement(password);
ActionTools::TextParameterDefinition *sender = new ActionTools::TextParameterDefinition(ActionTools::Name("sender", tr("Sender")), this);
sender->setTooltip(tr("The sender's e-mail address"));
addElement(sender);
ActionTools::TextParameterDefinition *receivers = new ActionTools::TextParameterDefinition(ActionTools::Name("receivers", tr("Receivers")), this);
receivers->setTooltip(tr("The receiver's e-mail address\nCan contain multiple receivers separated with a comma"));
addElement(receivers);
ActionTools::TextParameterDefinition *subject = new ActionTools::TextParameterDefinition(ActionTools::Name("subject", tr("Subject")), this);
subject->setTooltip(tr("The e-mail's subject"));
addElement(subject);
ActionTools::TextParameterDefinition *body = new ActionTools::TextParameterDefinition(ActionTools::Name("body", tr("Body")), this);
body->setTooltip(tr("The e-mail's body"));
addElement(body);
ActionTools::TextParameterDefinition *attachmentName = new ActionTools::TextParameterDefinition(ActionTools::Name("attachmentName", tr("Attachment name")), this);
attachmentName->setTooltip(tr("The attachment name, an empty name means that there is no attachment"));
addElement(attachmentName, 1);
ActionTools::TextParameterDefinition *attachmentData = new ActionTools::TextParameterDefinition(ActionTools::Name("attachmentData", tr("Attachment data")), this);
attachmentData->setTooltip(tr("The data to attach to the e-mail"));
addElement(attachmentData, 1);
ActionTools::ListParameterDefinition *attachmentContentType = new ActionTools::ListParameterDefinition(ActionTools::Name("attachmentContentType", tr("Attachment content type")), this);
attachmentContentType->setTooltip(tr("The MIME content type of the attachment\nIf left empty, Actiona will try to deduce it from the data type"));
attachmentContentType->setItems(SendMailInstance::attachmentContentTypes);
attachmentContentType->setDefaultValue(SendMailInstance::attachmentContentTypes.second.at(SendMailInstance::AutoDetectAttachmentContentType));
addElement(attachmentContentType, 1);
ActionTools::TextParameterDefinition *carbonCopy = new ActionTools::TextParameterDefinition(ActionTools::Name("carbonCopy", tr("Carbon copy (Cc)")), this);
carbonCopy->setTooltip(tr("The carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma"));
addElement(carbonCopy, 2);
ActionTools::TextParameterDefinition *blindCarbonCopy = new ActionTools::TextParameterDefinition(ActionTools::Name("blindCarbonCopy", tr("Blind carbon copy (Bcc)")), this);
blindCarbonCopy->setTooltip(tr("The blind carbon copy receiver's e-mail address\nCan contain multiple receivers separated with a comma"));
addElement(blindCarbonCopy, 2);
ActionTools::NumberParameterDefinition *serverPort = new ActionTools::NumberParameterDefinition(ActionTools::Name("serverPort", tr("Server port")), this);
serverPort->setTooltip(tr("The server port"));
serverPort->setMinimum(0);
serverPort->setMaximum(65535);
serverPort->setDefaultValue(0);
serverPort->setSpecialValueText(tr("Default port"));
addElement(serverPort, 2);
ActionTools::TextParameterDefinition *extraHeaders = new ActionTools::TextParameterDefinition(ActionTools::Name("extraHeaders", tr("Extra headers")), this);
extraHeaders->setTooltip(tr("Extra headers to add to the e-mail\nShould contain one header per line"));
addElement(extraHeaders, 2);
addException(SendMailInstance::ConnectionErrorException, tr("Connection error"));
addException(SendMailInstance::ErrorWhileSendingEMailException, tr("Error while sending e-mail"));
}
QString name() const { return QObject::tr("Send e-mail"); }
QString id() const { return "ActionSendMail"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Sends an e-mail"); }
ActionTools::ActionInstance *newActionInstance() const { return new SendMailInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/sendmail.png"); }
QStringList tabs() const { return QStringList() << ActionDefinition::StandardTabs.at(0) << tr("Attachment") << ActionDefinition::StandardTabs.at(1); }
private:
Q_DISABLE_COPY(SendMailDefinition)
};
}
#endif // SENDMAILDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/sendmailinstance.cpp 0000664 0000000 0000000 00000033474 12722271506 0025255 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "sendmailinstance.h"
#include "code/rawdata.h"
#include "code/image.h"
#include "qxtsmtp/qxtsmtp.h"
#include "qxtsmtp/qxtmailmessage.h"
#include "qxtsmtp/qxtmailattachment.h"
#include
#include
#include
#include
#include
#include
#include
namespace Actions
{
ActionTools::StringListPair SendMailInstance::attachmentContentTypes = qMakePair(
QStringList() << "autoDetect" << "application/octet-stream" << "text/plain" << "image/jpeg" << "image/png",
QStringList() << QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Auto detect")
<< QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Binary")
<< QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Text")
<< QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Jpg image")
<< QT_TRANSLATE_NOOP("SendMailInstance::attachmentContentTypes", "Png image"));
SendMailInstance::SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent)
: ActionTools::ActionInstance(definition, parent),
mSmtp(nullptr),
mProgressDialog(new QProgressDialog)
{
connect(mProgressDialog, SIGNAL(canceled()), this, SLOT(canceled()));
}
SendMailInstance::~SendMailInstance()
{
delete mProgressDialog;
}
void SendMailInstance::startExecution()
{
bool ok = true;
QString serverName = evaluateString(ok, "serverName");
bool secureConnection = evaluateBoolean(ok, "secureConnection");
QString userName = evaluateString(ok, "userName");
QString password = evaluateString(ok, "password");
QString sender = evaluateString(ok, "sender");
QString receivers = evaluateString(ok, "receivers");
QString subject = evaluateString(ok, "subject");
QString body = evaluateString(ok, "body");
QString attachmentName = evaluateString(ok, "attachmentName");
QScriptValue attachmentData = evaluateValue(ok, "attachmentData");
QString attachmentContentType = evaluateEditableListElement(ok, attachmentContentTypes, "attachmentContentType");
QString carbonCopy = evaluateString(ok, "carbonCopy");
QString blindCarbonCopy = evaluateString(ok, "blindCarbonCopy");
int serverPort = evaluateInteger(ok, "serverPort");
QString extraHeaders = evaluateString(ok, "extraHeaders");
if(serverName.isEmpty() || sender.isEmpty() || receivers.isEmpty())
{
emit executionEnded();
return;
}
if(attachmentContentType == "autoDetect" && !attachmentName.isEmpty() && attachmentData.isValid())
{
bool foundAttachmentContentType = true;
if(QObject *scriptObject = attachmentData.toQObject())
{
if(qobject_cast(scriptObject))
attachmentContentType = "application/octet-stream";
else if(qobject_cast(scriptObject))
{
QString lowerAttachmentName = attachmentName.toLower();
if(lowerAttachmentName.endsWith(".jpg") || lowerAttachmentName.endsWith(".jpeg"))
attachmentContentType = "image/jpeg";
else
attachmentContentType = "image/png";
}
else
foundAttachmentContentType = false;
}
else if(attachmentData.isString())
attachmentContentType = "text/plain";
else
foundAttachmentContentType = false;
if(!foundAttachmentContentType)
{
setCurrentParameter("attachmentContentType");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Failed to auto detect the attachment content type"));
return;
}
}
validateParameterRange(ok, serverPort, "serverPort", tr("server port"), 0, 65535);
if(!ok)
return;
mSmtp = new QxtSmtp(this);
connect(mSmtp, SIGNAL(connectionFailed(QByteArray)), this, SLOT(connectionFailed(QByteArray)));
connect(mSmtp, SIGNAL(encryptionFailed(QByteArray)), this, SLOT(encryptionFailed(QByteArray)));
connect(mSmtp, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(authenticationFailed(QByteArray)));
connect(mSmtp, SIGNAL(authenticated()), this, SLOT(authenticated()));
connect(mSmtp, SIGNAL(senderRejected(int,QString,QByteArray)), this, SLOT(senderRejected(int,QString,QByteArray)));
connect(mSmtp, SIGNAL(recipientRejected(int,QString,QByteArray)), this, SLOT(recipientRejected(int,QString,QByteArray)));
connect(mSmtp, SIGNAL(mailFailed(int,int,QByteArray)), this, SLOT(mailFailed(int,int,QByteArray)));
connect(mSmtp, SIGNAL(mailSent(int)), this, SLOT(mailSent(int)));
connect(mSmtp, SIGNAL(disconnected()), this, SLOT(disconnected()));
mSmtp->setUsername(userName.toUtf8());
mSmtp->setPassword(password.toUtf8());
QxtMailMessage mailMessage;
mailMessage.setSender(sender);
mailMessage.setSubject(subject);
mailMessage.setBody(body);
mailMessage.setExtraHeader("Date", QDateTime::currentDateTime().toString(Qt::RFC2822Date));
for(QString receiver: receivers.split(QChar(','), QString::SkipEmptyParts))
mailMessage.addRecipient(receiver.trimmed());
for(QString carbonCopyReceiver: carbonCopy.split(QChar(','), QString::SkipEmptyParts))
mailMessage.addRecipient(carbonCopyReceiver.trimmed(), QxtMailMessage::Cc);
for(QString blindCarbonCopyReceiver: blindCarbonCopy.split(QChar(','), QString::SkipEmptyParts))
mailMessage.addRecipient(blindCarbonCopyReceiver.trimmed(), QxtMailMessage::Bcc);
for(QString extraHeader: extraHeaders.split(QChar('\n'), QString::SkipEmptyParts))
{
QStringList extraHeaderParts = extraHeader.split(QChar(':'), QString::SkipEmptyParts);
if(extraHeaderParts.size() != 2)
{
setCurrentParameter("extraHeaders");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Failed to parse an extra header: \"%1\" has to be in the form \"name: value\"").arg(extraHeader));
return;
}
mailMessage.setExtraHeader(extraHeaderParts[0].trimmed(), extraHeaderParts[1]);
}
if(!attachmentName.isEmpty())
{
if(!attachmentData.isValid())
{
setCurrentParameter("attachmentData");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid attachment data"));
return;
}
QByteArray attachmentDataByteArray;
if(QObject *scriptObject = attachmentData.toQObject())
{
if(Code::RawData *codeRawData = qobject_cast(scriptObject))
attachmentDataByteArray = codeRawData->byteArray();
else if(Code::Image *codeImage = qobject_cast(scriptObject))
{
QImage image = codeImage->image();
QString format;
if(attachmentContentType == "image/png")
format = "PNG";
else if(attachmentContentType == "image/jpeg")
format = "JPG";
else
{
setCurrentParameter("attachmentData");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Unknown image type; supported types are PNG and JPG"));
return;
}
QBuffer buffer;
buffer.open(QIODevice::WriteOnly);
if(!image.save(&buffer, format.toLatin1()))
{
setCurrentParameter("attachmentData");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid image data"));
return;
}
attachmentDataByteArray = buffer.buffer();
}
else
attachmentDataByteArray = attachmentData.toString().toUtf8();
}
else
{
if(attachmentContentType == "text/plain")
attachmentDataByteArray = attachmentData.toString().toUtf8();
else
attachmentDataByteArray = attachmentData.toVariant().toByteArray();
}
mailMessage.addAttachment(attachmentName, QxtMailAttachment(attachmentDataByteArray, attachmentContentType));
}
if(serverPort == 0)
{
if(secureConnection)
mSmtp->connectToSecureHost(serverName);
else
mSmtp->connectToHost(serverName);
}
else
{
if(secureConnection)
mSmtp->connectToSecureHost(serverName, serverPort);
else
mSmtp->connectToHost(serverName, serverPort);
}
mSmtp->send(mailMessage);
mProgressDialog->setModal(false);
mProgressDialog->setWindowTitle(tr("Sending e-mail"));
mProgressDialog->setLabelText(tr("Connecting..."));
mProgressDialog->setMaximum(2);
mProgressDialog->show();
}
void SendMailInstance::stopExecution()
{
cleanup();
}
void SendMailInstance::connectionFailed(const QByteArray &msg)
{
cleanup();
emit executionException(ConnectionErrorException, tr("Connection failed: %1").arg(QString::fromUtf8(msg)));
}
void SendMailInstance::encryptionFailed(const QByteArray &msg)
{
cleanup();
emit executionException(ConnectionErrorException, tr("Encryption failed: %1").arg(QString::fromUtf8(msg)));
}
void SendMailInstance::authenticationFailed(const QByteArray &msg)
{
cleanup();
emit executionException(ConnectionErrorException, tr("Authentication failed: %1").arg(QString::fromUtf8(msg)));
}
void SendMailInstance::authenticated()
{
mProgressDialog->setValue(1);
mProgressDialog->setLabelText(tr("Sending e-mail..."));
}
void SendMailInstance::senderRejected(int mailID, const QString &address, const QByteArray &msg)
{
Q_UNUSED(mailID)
cleanup();
emit executionException(ErrorWhileSendingEMailException, tr("Sender %1 has been rejected: %2").arg(address).arg(QString::fromUtf8(msg)));
}
void SendMailInstance::recipientRejected(int mailID, const QString &address, const QByteArray &msg)
{
Q_UNUSED(mailID)
cleanup();
emit executionException(ErrorWhileSendingEMailException, tr("Recipient %1 has been rejected: %2").arg(address).arg(QString::fromUtf8(msg)));
}
void SendMailInstance::mailFailed(int mailID, int errorCode, const QByteArray &msg)
{
Q_UNUSED(mailID)
cleanup();
QString errorString;
switch(errorCode)
{
case QxtSmtp::NoRecipients:
errorString = tr("No recipients");
break;
case QxtSmtp::CommandUnrecognized:
errorString = tr("Command unrecognized");
break;
case QxtSmtp::SyntaxError:
errorString = tr("Syntax error");
break;
case QxtSmtp::CommandNotImplemented:
errorString = tr("Command not implemented");
break;
case QxtSmtp::BadSequence:
errorString = tr("Bad sequence");
break;
case QxtSmtp::ParameterNotImplemented:
errorString = tr("Parameter not implemented");
break;
case QxtSmtp::MailboxUnavailable:
errorString = tr("Mailbox unavailable");
break;
case QxtSmtp::UserNotLocal:
errorString = tr("User not local");
break;
case QxtSmtp::MessageTooLarge:
errorString = tr("Message is too large");
break;
case QxtSmtp::InvalidMailboxName:
errorString = tr("Invalid mailbox name");
break;
case QxtSmtp::TransactionFailed:
errorString = tr("Transaction failed");
break;
default:
errorString = tr("Unknown error");
break;
}
emit executionException(ErrorWhileSendingEMailException, tr("Failed sending e-mail: %1 (%2)").arg(errorString).arg(QString::fromUtf8(msg)));
}
void SendMailInstance::mailSent(int mailID)
{
Q_UNUSED(mailID)
cleanup();
emit executionEnded();
}
void SendMailInstance::disconnected()
{
mSmtp->deleteLater();
}
void SendMailInstance::canceled()
{
cleanup();
emit executionEnded();
}
void SendMailInstance::cleanup()
{
mSmtp->disconnectFromHost();
mProgressDialog->close();
}
}
actiona-3.9.2/actions/actionpackdata/actions/sendmailinstance.h 0000664 0000000 0000000 00000004544 12722271506 0024716 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef SENDMAILINSTANCE_H
#define SENDMAILINSTANCE_H
#include "actioninstance.h"
#include "script.h"
#include "stringlistpair.h"
class QxtSmtp;
class QProgressDialog;
namespace Actions
{
class SendMailInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(AttachmentContentType)
public:
enum AttachmentContentType
{
AutoDetectAttachmentContentType,
BinaryAttachmentContentType,
TextAttachmentContentType,
JpgImageAttachmentContentType,
PngImageAttachmentContentType
};
enum Exceptions
{
ConnectionErrorException = ActionTools::ActionException::UserException,
ErrorWhileSendingEMailException
};
SendMailInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0);
~SendMailInstance();
static ActionTools::StringListPair attachmentContentTypes;
void startExecution();
void stopExecution();
private slots:
void connectionFailed(const QByteArray &msg);
void encryptionFailed(const QByteArray &msg);
void authenticationFailed(const QByteArray &msg);
void authenticated();
void senderRejected(int mailID, const QString &address, const QByteArray &msg);
void recipientRejected(int mailID, const QString &address, const QByteArray &msg);
void mailFailed(int mailID, int errorCode, const QByteArray &msg);
void mailSent(int mailID);
void disconnected();
void canceled();
private:
Q_DISABLE_COPY(SendMailInstance)
void cleanup();
QxtSmtp *mSmtp;
QProgressDialog *mProgressDialog;
};
}
#endif // SENDMAILINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/webdownloaddefinition.h 0000664 0000000 0000000 00000010752 12722271506 0025751 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WEBDOWNLOADDEFINITION_H
#define WEBDOWNLOADDEFINITION_H
#include "actiondefinition.h"
#include "webdownloadinstance.h"
#include "textparameterdefinition.h"
#include "listparameterdefinition.h"
#include "variableparameterdefinition.h"
#include "fileparameterdefinition.h"
#include "groupdefinition.h"
#include "booleanparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WebDownloadDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WebDownloadDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("WebDownloadInstance::destinations", WebDownloadInstance::destinations);
ActionTools::TextParameterDefinition *url = new ActionTools::TextParameterDefinition(ActionTools::Name("url", tr("URL")), this);
url->setTooltip(tr("The URL of the data to download"));
addElement(url);
ActionTools::ListParameterDefinition *destination = new ActionTools::ListParameterDefinition(ActionTools::Name("destination", tr("Destination")), this);
destination->setTooltip(tr("The destination where to write the downloaded data"));
destination->setItems(WebDownloadInstance::destinations);
destination->setDefaultValue(WebDownloadInstance::destinations.second.at(WebDownloadInstance::Variable));
addElement(destination);
ActionTools::GroupDefinition *variableMode = new ActionTools::GroupDefinition(this);
variableMode->setMasterList(destination);
variableMode->setMasterValues(QStringList() << WebDownloadInstance::destinations.first.at(WebDownloadInstance::Variable));
ActionTools::VariableParameterDefinition *variable = new ActionTools::VariableParameterDefinition(ActionTools::Name("variable", tr("Variable")), this);
variable->setTooltip(tr("The variable where to write the downloaded data"));
variableMode->addMember(variable);
addElement(variableMode);
ActionTools::GroupDefinition *fileMode = new ActionTools::GroupDefinition(this);
fileMode->setMasterList(destination);
fileMode->setMasterValues(QStringList() << WebDownloadInstance::destinations.first.at(WebDownloadInstance::File));
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file where to write the downloaded data"));
file->setMode(ActionTools::FileEdit::FileSave);
file->setCaption(tr("Choose the destination file"));
file->setFilter(tr("All files (*.*)"));
fileMode->addMember(file);
addElement(fileMode);
ActionTools::BooleanParameterDefinition *showProgress = new ActionTools::BooleanParameterDefinition(ActionTools::Name("showProgress", tr("Show progress")), this);
showProgress->setTooltip(tr("Should the download progress be shown"));
showProgress->setDefaultValue(true);
addElement(showProgress, 1);
addException(WebDownloadInstance::CannotOpenFileException, tr("Cannot write to file"));
addException(WebDownloadInstance::DownloadException, tr("Download error"));
}
QString name() const { return QObject::tr("Web download"); }
QString id() const { return "ActionWebDownload"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Downloads data from the Web"); }
ActionTools::ActionInstance *newActionInstance() const { return new WebDownloadInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/webdownload.png"); }
QStringList tabs() const { return ActionDefinition::StandardTabs; }
private:
Q_DISABLE_COPY(WebDownloadDefinition)
};
}
#endif // WEBDOWNLOADDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/webdownloadinstance.cpp 0000664 0000000 0000000 00000010016 12722271506 0025751 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "webdownloadinstance.h"
#include
#include
#include
#include
namespace Actions
{
ActionTools::StringListPair WebDownloadInstance::destinations = qMakePair(
QStringList() << "variable" << "file",
QStringList() << QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "Variable")
<< QT_TRANSLATE_NOOP("WebDownloadInstance::destinations", "File"));
WebDownloadInstance::WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent)
: ActionTools::ActionInstance(definition, parent),
mNetworkAccessManager(new QNetworkAccessManager(this)),
mReply(0),
mDestination(Variable),
mProgressDialog(new QProgressDialog)
{
connect(mProgressDialog, SIGNAL(canceled()), this, SLOT(canceled()));
}
WebDownloadInstance::~WebDownloadInstance()
{
delete mProgressDialog;
}
void WebDownloadInstance::startExecution()
{
bool ok = true;
QString urlString = evaluateString(ok, "url");
mDestination = evaluateListElement(ok, destinations, "destination");
mVariable = evaluateVariable(ok, "variable");
QString file = evaluateString(ok, "file");
if(!ok)
return;
QUrl url(urlString);
if(url.scheme() == QString())
url = QUrl("http://" + urlString, QUrl::TolerantMode);
if(!url.isValid())
{
setCurrentParameter("url");
emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid URL"));
return;
}
if(mDestination == File)
{
mFile.setFileName(file);
if(!mFile.open(QIODevice::WriteOnly))
{
setCurrentParameter("file");
emit executionException(CannotOpenFileException, tr("Cannot write to file"));
return;
}
}
mReply = mNetworkAccessManager->get(QNetworkRequest(url));
connect(mReply, SIGNAL(finished()), this, SLOT(finished()));
connect(mReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
connect(mReply, SIGNAL(readyRead()), this, SLOT(readyRead()));
mProgressDialog->setModal(false);
mProgressDialog->setWindowTitle(tr("Downloading"));
mProgressDialog->setLabelText(tr("Downloading..."));
mProgressDialog->setMaximum(100);
mProgressDialog->show();
}
void WebDownloadInstance::stopExecution()
{
if(mReply)
mReply->abort();
}
void WebDownloadInstance::finished()
{
mFile.close();
switch(mReply->error())
{
case QNetworkReply::NoError:
if(mDestination == Variable)
setVariable(mVariable, QString::fromUtf8(mReply->readAll()));
emit executionEnded();
break;
case QNetworkReply::OperationCanceledError:
if(mDestination == File)
mFile.remove();
emit executionEnded();
break;
default:
{
if(mDestination == File)
mFile.remove();
setCurrentParameter("url");
emit executionException(DownloadException, tr("Download error: %1").arg(mReply->errorString()));
}
break;
}
mProgressDialog->close();
mReply->deleteLater();
mReply = 0;
}
void WebDownloadInstance::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
if(bytesTotal > 0)
mProgressDialog->setValue((bytesReceived * 100) / bytesTotal);
}
void WebDownloadInstance::readyRead()
{
if(mDestination == File)
mFile.write(mReply->readAll());
}
void WebDownloadInstance::canceled()
{
if(mReply)
mReply->abort();
}
}
actiona-3.9.2/actions/actionpackdata/actions/webdownloadinstance.h 0000664 0000000 0000000 00000003504 12722271506 0025422 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WEBDOWNLOADINSTANCE_H
#define WEBDOWNLOADINSTANCE_H
#include "actioninstance.h"
#include "script.h"
#include "stringlistpair.h"
#include
class QNetworkAccessManager;
class QNetworkReply;
class QProgressDialog;
namespace Actions
{
class WebDownloadInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Destination)
public:
enum Destination
{
Variable,
File
};
enum Exceptions
{
CannotOpenFileException = ActionTools::ActionException::UserException,
DownloadException
};
WebDownloadInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0);
~WebDownloadInstance();
static ActionTools::StringListPair destinations;
void startExecution();
void stopExecution();
private slots:
void finished();
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
void readyRead();
void canceled();
private:
Q_DISABLE_COPY(WebDownloadInstance)
QNetworkAccessManager *mNetworkAccessManager;
QNetworkReply *mReply;
QString mVariable;
Destination mDestination;
QFile mFile;
QProgressDialog *mProgressDialog;
};
}
#endif // WEBDOWNLOADINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/writebinaryfiledefinition.h 0000664 0000000 0000000 00000005060 12722271506 0026637 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITEBINARYFILEDEFINITION_H
#define WRITEBINARYFILEDEFINITION_H
#include "actiondefinition.h"
#include "writebinaryfileinstance.h"
#include "fileparameterdefinition.h"
#include "textparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteBinaryFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteBinaryFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file to write to"));
file->setMode(ActionTools::FileEdit::FileSave);
file->setCaption(tr("Choose the file"));
file->setFilter(tr("All files (*.*)"));
addElement(file);
ActionTools::TextParameterDefinition *data = new ActionTools::TextParameterDefinition(ActionTools::Name("data", tr("Data")), this);
data->setTooltip(tr("The data to write to the file"));
addElement(data);
addException(WriteBinaryFileInstance::UnableToWriteFileException, tr("Unable to write to the file"));
}
QString name() const { return QObject::tr("Write binary file"); }
QString id() const { return "ActionWriteBinaryFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Write to a binary file"); }
ActionTools::ActionInstance *newActionInstance() const { return new WriteBinaryFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/writebinary.png"); }
private:
Q_DISABLE_COPY(WriteBinaryFileDefinition)
};
}
#endif // WRITEBINARYFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/writebinaryfileinstance.h 0000664 0000000 0000000 00000004127 12722271506 0026316 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITEBINARYFILEINSTANCE_H
#define WRITEBINARYFILEINSTANCE_H
#include "datacopyactioninstance.h"
#include
#include
namespace Actions
{
class WriteBinaryFileInstance : public ActionTools::DataCopyActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToWriteFileException = ActionTools::ActionException::UserException
};
WriteBinaryFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::DataCopyActionInstance(definition, parent)
{
}
void startExecution()
{
bool ok = true;
QString filename = evaluateString(ok, "file");
QScriptValue data = evaluateValue(ok, "data");
if(!ok)
return;
mData = data.toVariant().toByteArray();
mFile.setFileName(filename);
mDataBuffer.setBuffer(&mData);
if(!DataCopyActionInstance::startCopy(&mDataBuffer, &mFile))
{
setCurrentParameter("file");
emit executionException(UnableToWriteFileException, tr("Unable to write to the file \"%1\"").arg(filename));
return;
}
emit showProgressDialog("Writing file", 100);
emit updateProgressDialog("Writing in progress");
}
private:
void clean()
{
DataCopyActionInstance::clean();
mDataBuffer.buffer().clear();
}
QFile mFile;
QByteArray mData;
QBuffer mDataBuffer;
private:
Q_DISABLE_COPY(WriteBinaryFileInstance)
};
}
#endif // WRITEBINARYFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/writeclipboarddefinition.h 0000664 0000000 0000000 00000004155 12722271506 0026456 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITECLIPBOARDDEFINITION_H
#define WRITECLIPBOARDDEFINITION_H
#include "actiondefinition.h"
#include "writeclipboardinstance.h"
#include "textparameterdefinition.h"
#include "variableparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteClipboardDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteClipboardDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::TextParameterDefinition *input = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this);
input->setTooltip(tr("The new clipboard value"));
addElement(input);
}
QString name() const { return QObject::tr("Write clipboard"); }
QString id() const { return "ActionWriteClipboard"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Set the clipboard contents"); }
ActionTools::ActionInstance *newActionInstance() const { return new WriteClipboardInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/writeclipboard.png"); }
private:
Q_DISABLE_COPY(WriteClipboardDefinition)
};
}
#endif // WRITECLIPBOARDDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/writeclipboardinstance.h 0000664 0000000 0000000 00000002651 12722271506 0026131 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITECLIPBOARDINSTANCE_H
#define WRITECLIPBOARDINSTANCE_H
#include "actioninstance.h"
#include
#include
namespace Actions
{
class WriteClipboardInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
WriteClipboardInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution()
{
bool ok = true;
QString value = evaluateString(ok, "value");
if(!ok)
return;
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(value);
emit executionEnded();
}
private:
Q_DISABLE_COPY(WriteClipboardInstance)
};
}
#endif // WRITECLIPBOARDINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/writeinifiledefinition.h 0000664 0000000 0000000 00000005755 12722271506 0026145 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITEINIFILEDEFINITION_H
#define WRITEINIFILEDEFINITION_H
#include "actiondefinition.h"
#include "writeinifileinstance.h"
#include "textparameterdefinition.h"
#include "fileparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteIniFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteIniFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file to create or edit"));
file->setMode(ActionTools::FileEdit::FileSave);
file->setCaption(tr("Choose the INI file"));
file->setFilter(tr("INI files (*.ini);;All files (*.*)"));
addElement(file);
ActionTools::TextParameterDefinition *section = new ActionTools::TextParameterDefinition(ActionTools::Name("section", tr("Section")), this);
section->setTooltip(tr("The section name of the parameter"));
addElement(section);
ActionTools::TextParameterDefinition *parameter = new ActionTools::TextParameterDefinition(ActionTools::Name("parameter", tr("Parameter")), this);
parameter->setTooltip(tr("The parameter name"));
addElement(parameter);
ActionTools::TextParameterDefinition *value = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this);
value->setTooltip(tr("The new value"));
addElement(value);
addException(WriteIniFileInstance::UnableToWriteFileException, tr("Unable to write file"));
}
QString name() const { return QObject::tr("Write INI file"); }
QString id() const { return "ActionWriteIniFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Write an entry in an INI file"); }
ActionTools::ActionInstance *newActionInstance() const { return new WriteIniFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/writeini.png"); }
private:
Q_DISABLE_COPY(WriteIniFileDefinition)
};
}
#endif // WRITEINIFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/writeinifileinstance.h 0000664 0000000 0000000 00000006305 12722271506 0025611 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITEINIFILEINSTANCE_H
#define WRITEINIFILEINSTANCE_H
#include "actioninstance.h"
#include
#include
#include
namespace Actions
{
class WriteIniFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
UnableToWriteFileException = ActionTools::ActionException::UserException
};
WriteIniFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution()
{
bool ok = true;
QString filename = evaluateString(ok, "file");
QString section = evaluateString(ok, "section");
QString parameter = evaluateString(ok, "parameter");
QString value = evaluateString(ok, "value");
if(!ok)
return;
if(!write(filename, section, parameter, value))
return;
emit executionEnded();
}
private:
bool write(const QString &filename, QString section, const QString ¶meter, const QString &value)
{
try
{
boost::property_tree::ptree tree;
QFileInfo fileInfo(filename);
if(fileInfo.isReadable())
boost::property_tree::ini_parser::read_ini(filename.toStdString(), tree);
//Create/get the parameter and the value
boost::property_tree::ptree sectionTree;
if(tree.count(section.toStdString()) > 0)
sectionTree = tree.get_child(section.toStdString());
sectionTree.put(parameter.toStdString(), value.toStdString());
if(section.isEmpty())
{
setCurrentParameter("filename");
emit executionException(UnableToWriteFileException, tr("Unable to write to the file: the section name cannot be empty"));
return false;
}
//Create the section
tree.put_child(section.toStdString(), sectionTree);
boost::property_tree::ini_parser::write_ini(filename.toStdString(), tree);
}
catch(const std::runtime_error &e)
{
setCurrentParameter("filename");
emit executionException(UnableToWriteFileException, tr("Unable to write to the file: %1").arg(e.what()));
return false;
}
return true;
}
Q_DISABLE_COPY(WriteIniFileInstance)
};
}
#endif // WRITEINIFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/writeregistrydefinition.h 0000664 0000000 0000000 00000006117 12722271506 0026367 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITEREGISTRYDEFINITION_H
#define WRITEREGISTRYDEFINITION_H
#include "actiondefinition.h"
#include "writeregistryinstance.h"
#include "readregistryinstance.h"
#include "listparameterdefinition.h"
#include "textparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteRegistryDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteRegistryDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
ActionTools::ListParameterDefinition *key = new ActionTools::ListParameterDefinition(ActionTools::Name("key", tr("Key")), this);
key->setTooltip(tr("The registry key to write to"));
key->setItems(ReadRegistryInstance::keys);
key->setDefaultValue(ReadRegistryInstance::keys.second.at(ActionTools::Registry::CurrentUser));
addElement(key);
ActionTools::TextParameterDefinition *subKey = new ActionTools::TextParameterDefinition(ActionTools::Name("subKey", tr("Subkey")), this);
subKey->setTooltip(tr("The registry subkey to write to"));
addElement(subKey);
ActionTools::TextParameterDefinition *value = new ActionTools::TextParameterDefinition(ActionTools::Name("value", tr("Value")), this);
value->setTooltip(tr("The value to write to"));
addElement(value);
ActionTools::TextParameterDefinition *data = new ActionTools::TextParameterDefinition(ActionTools::Name("data", tr("Data")), this);
data->setTooltip(tr("The data to write"));
addElement(data);
addException(WriteRegistryInstance::CannotFindSubKeyException, tr("Cannot find subKey"));
addException(WriteRegistryInstance::CannotWriteValueException, tr("Cannot write value"));
}
QString name() const { return QObject::tr("Write registry"); }
QString id() const { return "ActionWriteRegistry"; }
ActionTools::Flag flags() const { return ActionTools::WorksOnWindows | ActionTools::Official; }
QString description() const { return QObject::tr("Writes an entry to the registry"); }
ActionTools::ActionInstance *newActionInstance() const { return new WriteRegistryInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/writeregistry.png"); }
private:
Q_DISABLE_COPY(WriteRegistryDefinition)
};
}
#endif // WRITEREGISTRYDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/writeregistryinstance.cpp 0000664 0000000 0000000 00000003345 12722271506 0026376 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "writeregistryinstance.h"
#include "readregistryinstance.h"
#ifdef Q_OS_WIN
#include
#endif
namespace Actions
{
void WriteRegistryInstance::startExecution()
{
#ifdef Q_OS_WIN
bool ok = true;
ActionTools::Registry::Key key = evaluateListElement(ok, ReadRegistryInstance::keys, "key");
QString subKey = evaluateString(ok, "subKey");
QString value = evaluateString(ok, "value");
QScriptValue data = evaluateValue(ok, "data");
if(!ok)
return;
switch(ActionTools::Registry::write(data.toVariant(), key, subKey, value))
{
case ActionTools::Registry::WriteCannotFindSubKey:
setCurrentParameter("subKey");
emit executionException(CannotFindSubKeyException, tr("Cannot find subKey \"%1\"").arg(subKey));
return;
case ActionTools::Registry::WriteCannotWriteValue:
setCurrentParameter("value");
emit executionException(CannotWriteValueException, tr("Cannot write value \"%1\"").arg(value));
return;
default:
break;
}
#endif
emit executionEnded();
}
}
actiona-3.9.2/actions/actionpackdata/actions/writeregistryinstance.h 0000664 0000000 0000000 00000002531 12722271506 0026037 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITEREGISTRYINSTANCE_H
#define WRITEREGISTRYINSTANCE_H
#include "actioninstance.h"
#include "stringlistpair.h"
#include "registry.h"
namespace Actions
{
class WriteRegistryInstance : public ActionTools::ActionInstance
{
Q_OBJECT
public:
enum Exceptions
{
CannotFindSubKeyException = ActionTools::ActionException::UserException,
CannotWriteValueException
};
WriteRegistryInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
void startExecution();
private:
Q_DISABLE_COPY(WriteRegistryInstance)
};
}
#endif // WRITEREGISTRYINSTANCE_H
actiona-3.9.2/actions/actionpackdata/actions/writetextfiledefinition.h 0000664 0000000 0000000 00000005664 12722271506 0026351 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITETEXTFILEDEFINITION_H
#define WRITETEXTFILEDEFINITION_H
#include "actiondefinition.h"
#include "writetextfileinstance.h"
#include "fileparameterdefinition.h"
#include "textparameterdefinition.h"
#include "listparameterdefinition.h"
namespace ActionTools
{
class ActionPack;
class ActionInstance;
}
namespace Actions
{
class WriteTextFileDefinition : public QObject, public ActionTools::ActionDefinition
{
Q_OBJECT
public:
explicit WriteTextFileDefinition(ActionTools::ActionPack *pack)
: ActionDefinition(pack)
{
translateItems("WriteTextFileInstance::modes", WriteTextFileInstance::modes);
ActionTools::FileParameterDefinition *file = new ActionTools::FileParameterDefinition(ActionTools::Name("file", tr("File")), this);
file->setTooltip(tr("The file you want to write"));
addElement(file);
ActionTools::TextParameterDefinition *text = new ActionTools::TextParameterDefinition(ActionTools::Name("text", tr("Text")), this);
text->setTooltip(tr("The text to write to the file"));
addElement(text);
ActionTools::ListParameterDefinition *mode = new ActionTools::ListParameterDefinition(ActionTools::Name("mode", tr("Mode")), this);
mode->setTooltip(tr("The file write mode"));
mode->setItems(WriteTextFileInstance::modes);
mode->setDefaultValue(WriteTextFileInstance::modes.second.at(WriteTextFileInstance::Truncate));
addElement(mode, 1);
addException(WriteTextFileInstance::CannotWriteFileException, tr("Cannot write file"));
}
QString name() const { return QObject::tr("Write text file"); }
QString id() const { return "ActionWriteTextFile"; }
ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; }
QString description() const { return QObject::tr("Write a plain text file"); }
ActionTools::ActionInstance *newActionInstance() const { return new WriteTextFileInstance(this); }
ActionTools::ActionCategory category() const { return ActionTools::Data; }
QPixmap icon() const { return QPixmap(":/icons/writetext.png"); }
QStringList tabs() const { return ActionDefinition::StandardTabs; }
private:
Q_DISABLE_COPY(WriteTextFileDefinition)
};
}
#endif // WRITETEXTFILEDEFINITION_H
actiona-3.9.2/actions/actionpackdata/actions/writetextfileinstance.cpp 0000664 0000000 0000000 00000003256 12722271506 0026353 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "writetextfileinstance.h"
#include
#include
namespace Actions
{
ActionTools::StringListPair WriteTextFileInstance::modes = qMakePair(
QStringList() << "truncate" << "append",
QStringList() << QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Overwrite any content") << QT_TRANSLATE_NOOP("WriteTextFileInstance::modes", "Append to the end"));
void WriteTextFileInstance::startExecution()
{
bool ok = true;
QString filepath = evaluateString(ok, "file");
QString text = evaluateString(ok, "text");
Mode mode = evaluateListElement(ok, modes, "mode");
if(!ok)
return;
QFile file(filepath);
if(!file.open(QIODevice::WriteOnly | QIODevice::Text | (mode == Truncate ? QIODevice::Truncate : QIODevice::Append)))
{
setCurrentParameter("file");
emit executionException(CannotWriteFileException, tr("Cannot open file"));
return;
}
QTextStream textStream(&file);
textStream << text;
file.close();
emit executionEnded();
}
}
actiona-3.9.2/actions/actionpackdata/actions/writetextfileinstance.h 0000664 0000000 0000000 00000002615 12722271506 0026016 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef WRITETEXTFILEINSTANCE_H
#define WRITETEXTFILEINSTANCE_H
#include "actioninstance.h"
#include "stringlistpair.h"
namespace Actions
{
class WriteTextFileInstance : public ActionTools::ActionInstance
{
Q_OBJECT
Q_ENUMS(Mode)
public:
enum Mode
{
Truncate,
Append
};
enum Exceptions
{
CannotWriteFileException = ActionTools::ActionException::UserException
};
WriteTextFileInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0)
: ActionTools::ActionInstance(definition, parent) {}
static ActionTools::StringListPair modes;
void startExecution();
private:
Q_DISABLE_COPY(WriteTextFileInstance)
};
}
#endif // WRITETEXTFILEINSTANCE_H
actiona-3.9.2/actions/actionpackdata/code/ 0000775 0000000 0000000 00000000000 12722271506 0020467 5 ustar 00root root 0000000 0000000 actiona-3.9.2/actions/actionpackdata/code/clipboard.cpp 0000664 0000000 0000000 00000006163 12722271506 0023140 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "clipboard.h"
#include "code/image.h"
#include
#include
#include
#include
namespace Code
{
QScriptValue Clipboard::constructor(QScriptContext *context, QScriptEngine *engine)
{
Clipboard *clipboard = new Clipboard;
if(context->argumentCount() > 0)
{
Mode mode = static_cast(context->argument(0).toInt32());
clipboard->setModePrivate(context, engine, mode);
}
return CodeClass::constructor(clipboard, context, engine);
}
Clipboard::Clipboard()
: CodeClass(),
mMode(QClipboard::Clipboard)
{
}
QString Clipboard::text() const
{
QClipboard *clipboard = QApplication::clipboard();
return clipboard->text(mMode);
}
QScriptValue Clipboard::image() const
{
QClipboard *clipboard = QApplication::clipboard();
return Image::constructor(clipboard->image(mMode), engine());
}
QScriptValue Clipboard::setMode(Mode mode)
{
setModePrivate(context(), engine(), mode);
return thisObject();
}
QScriptValue Clipboard::setText(const QString &value) const
{
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(value, mMode);
return thisObject();
}
QScriptValue Clipboard::setImage(const QScriptValue &data) const
{
QClipboard *clipboard = QApplication::clipboard();
QObject *object = data.toQObject();
if(Code::Image *image = qobject_cast(object))
clipboard->setImage(image->image(), mMode);
else
clipboard->setImage(data.toVariant().value(), mMode);
return thisObject();
}
Clipboard::DataType Clipboard::dataType() const
{
QClipboard *clipboard = QApplication::clipboard();
const QMimeData *mimeData = clipboard->mimeData(mMode);
if(mimeData->hasImage())
return Image;
else
return Text;
}
void Clipboard::setModePrivate(QScriptContext *context, QScriptEngine *engine, Mode mode)
{
switch(mode)
{
case Selection:
if(!QApplication::clipboard()->supportsSelection())
{
throwError(context, engine, "UnsupportedSelectionModeError", tr("Selection mode is not supported by your operating system"));
return;
}
break;
case FindBuffer:
if(!QApplication::clipboard()->supportsFindBuffer())
{
throwError(context, engine, "UnsupportedSelectionModeError", tr("Find buffer mode is not supported by your operating system"));
return;
}
break;
default:
break;
}
mMode = static_cast(mode);
}
}
actiona-3.9.2/actions/actionpackdata/code/clipboard.h 0000664 0000000 0000000 00000003672 12722271506 0022607 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef CLIPBOARD_H
#define CLIPBOARD_H
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class Clipboard : public CodeClass
{
Q_OBJECT
Q_ENUMS(Mode)
Q_ENUMS(DataType)
Q_PROPERTY(QString text READ text WRITE setText)
Q_PROPERTY(QScriptValue image READ image WRITE setImage)
public:
enum Mode
{
Standard = QClipboard::Clipboard,
Selection = QClipboard::Selection,
FindBuffer = QClipboard::FindBuffer
};
enum DataType
{
Text,
Image
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
Clipboard();
QString text() const;
QScriptValue image() const;
public slots:
QString toString() const { return "Clipboard"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue setMode(Mode mode);
QScriptValue setText(const QString &value) const;
QScriptValue setImage(const QScriptValue &data) const;
DataType dataType() const;
private:
void setModePrivate(QScriptContext *context, QScriptEngine *engine, Mode mode);
QClipboard::Mode mMode;
};
}
#endif // CLIPBOARD_H
actiona-3.9.2/actions/actionpackdata/code/code.pri 0000664 0000000 0000000 00000001021 12722271506 0022107 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.9.2/actions/actionpackdata/code/file.cpp 0000664 0000000 0000000 00000044715 12722271506 0022125 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "file.h"
#include "code/rawdata.h"
#include
#include
#include
#include
#ifdef Q_OS_WIN
#include
#include
#endif
namespace Code
{
QScriptValue File::constructor(QScriptContext *context, QScriptEngine *engine)
{
return CodeClass::constructor(new File, context, engine);
}
QScriptValue File::copy(QScriptContext *context, QScriptEngine *engine)
{
QString source, destination;
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
copyPrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
return engine->undefinedValue();
}
QScriptValue File::exists(QScriptContext *context, QScriptEngine *engine)
{
if(context->argumentCount() != 1)
{
throwError(context, engine, "ParameterCountError", tr("Incorrect parameter count"));
return false;
}
return QFile::exists(context->argument(0).toString());
}
QScriptValue File::move(QScriptContext *context, QScriptEngine *engine)
{
QString source, destination;
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
return engine->undefinedValue();
}
QScriptValue File::rename(QScriptContext *context, QScriptEngine *engine)
{
QString source, destination;
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(source, destination, context->argument(2), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine))
renamePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
return engine->undefinedValue();
}
QScriptValue File::remove(QScriptContext *context, QScriptEngine *engine)
{
QString filename;
if(context->argumentCount() < 1)
{
throwError(context, engine, "ParameterCountError", tr("Incorrect parameter count"));
return false;
}
filename = context->argument(0).toString();
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(context->argument(1), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
removePrivate(filename, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, context, engine);
return engine->undefinedValue();
}
void File::registerClass(QScriptEngine *scriptEngine)
{
CodeTools::addClassGlobalFunctionToScriptEngine(©, "copy", scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&move, "move", scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&rename, "rename", scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&remove, "remove", scriptEngine);
CodeTools::addClassGlobalFunctionToScriptEngine(&exists, "exists", scriptEngine);
}
QScriptValue File::open(const QString &filename, OpenMode mode)
{
mFile.setFileName(filename);
if(!mFile.open(static_cast(mode)))
throwError("CannotOpenFileError", tr("Unable to open file"));
return thisObject();
}
QScriptValue File::write(const QScriptValue &data)
{
QObject *object = data.toQObject();
if(RawData *rawData = qobject_cast(object))
{
if(mFile.write(rawData->byteArray()) == -1)
throwError("WriteFailedError", tr("Write failed"));
}
else
{
if(mFile.write(data.toVariant().toByteArray()) == -1)
throwError("WriteFailedError", tr("Write failed"));
}
return thisObject();
}
QScriptValue File::writeText(const QString &value, Encoding encoding)
{
if(mFile.write(toEncoding(value, encoding)) == -1)
throwError("WriteFailedError", tr("Write failed"));
return thisObject();
}
QScriptValue File::read()
{
return RawData::constructor(mFile.readAll(), engine());
}
QString File::readText(Encoding encoding)
{
return fromEncoding(mFile.readAll(), encoding);
}
QScriptValue File::close()
{
mFile.close();
return thisObject();
}
QScriptValue File::copy(const QString &destination, const QScriptValue &options) const
{
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return copyPrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
else
return false;
}
QScriptValue File::move(const QString &destination, const QScriptValue &options)
{
mFile.close();
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return movePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
else
return false;
}
QScriptValue File::rename(const QString &destination, const QScriptValue &options)
{
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return renamePrivate(mFile.fileName(), destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context(), engine());
else
return false;
}
QScriptValue File::remove(const QScriptValue &options)
{
mFile.close();
bool noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory;
if(getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory))
return removePrivate(mFile.fileName(), noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, context(), engine());
else
return false;
}
bool File::getParameters(QString &source, QString &destination, const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
if(context->argumentCount() < 2)
{
throwError(context, engine, "ParameterCountError", tr("Incorrect parameter count"));
return false;
}
source = context->argument(0).toString();
destination = context->argument(1).toString();
return getParameters(options, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory);
}
bool File::getParameters(const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory)
{
QScriptValueIterator it(options);
noErrorDialog = false;
noConfirmDialog = false;
noProgressDialog = false;
allowUndo = false;
createDestinationDirectory = true;
while(it.hasNext())
{
it.next();
if(it.name() == "noErrorDialog")
noErrorDialog = it.value().toBool();
else if(it.name() == "noConfirmDialog")
noConfirmDialog = it.value().toBool();
else if(it.name() == "noProgressDialog")
noProgressDialog = it.value().toBool();
else if(it.name() == "allowUndo")
allowUndo = it.value().toBool();
else if(it.name() == "createDestinationDirectory")
createDestinationDirectory = it.value().toBool();
}
return true;
}
QScriptValue File::copyPrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
#ifdef Q_OS_LINUX
Q_UNUSED(noErrorDialog)
Q_UNUSED(noConfirmDialog)
Q_UNUSED(noProgressDialog)
Q_UNUSED(allowUndo)
QDir destinationDir(destination);
QString sourceCopy(source);
QString destinationCopy(destination);
sourceCopy.replace(" ", "\\ ");
destinationCopy.replace(" ", "\\ ");
if(!destinationDir.exists())
{
if(createDestinationDirectory)
{
if(QProcess::execute("sh -c \"mkdir -p " + QFile::encodeName(destinationCopy) + "\""))
{
throwError(context, engine, "DirectoryCreationError", tr("Unable to create destination directory"));
return context->thisObject();
}
}
else
{
throwError(context, engine, "DirectoryDoesntExistError", tr("Destination directory doesn't exist"));
return context->thisObject();
}
}
QString command = "sh -c \"cp -fr";
command += " ";
command += QFile::encodeName(sourceCopy);
command += " ";
command += QFile::encodeName(destinationCopy);
command += "\"";
if(QProcess::execute(command))
{
throwError(context, engine, "CopyError", tr("Copy failed"));
return context->thisObject();
}
#endif
#ifdef Q_OS_WIN
Q_UNUSED(createDestinationDirectory)
QDir sourceDir(source);
QDir destinationDir(destination);
std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
wideSource += L'\0';
std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
wideDestination += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_COPY;
shFileOpStruct.pFrom = wideSource.c_str();
shFileOpStruct.pTo = wideDestination.c_str();
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, "CopyError", tr("Copy failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, "CopyAbortedError", tr("Copy failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QScriptValue File::movePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
#ifdef Q_OS_LINUX
Q_UNUSED(noErrorDialog)
Q_UNUSED(noConfirmDialog)
Q_UNUSED(noProgressDialog)
Q_UNUSED(allowUndo)
QDir destinationDir(destination);
QString sourceCopy(source);
QString destinationCopy(destination);
sourceCopy.replace(" ", "\\ ");
destinationCopy.replace(" ", "\\ ");
if(!destinationDir.exists())
{
if(createDestinationDirectory)
{
if(QProcess::execute("sh -c \"mkdir -p " + QFile::encodeName(destinationCopy) + "\""))
{
throwError(context, engine, "DirectoryCreationError", tr("Unable to create destination directory"));
return context->thisObject();
}
}
else
{
throwError(context, engine, "DirectoryDoesntExistError", tr("Destination directory doesn't exist"));
return context->thisObject();
}
}
QString command = "sh -c \"mv -f";
command += " ";
command += QFile::encodeName(sourceCopy);
command += " ";
command += QFile::encodeName(destinationCopy);
command += "\"";
if(QProcess::execute(command))
{
throwError(context, engine, "MoveRenameError", tr("Move/rename failed"));
return context->thisObject();
}
#endif
#ifdef Q_OS_WIN
Q_UNUSED(createDestinationDirectory)
QDir sourceDir(source);
QDir destinationDir(destination);
std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
wideSource += L'\0';
std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
wideDestination += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_MOVE;
shFileOpStruct.pFrom = wideSource.c_str();
shFileOpStruct.pTo = wideDestination.c_str();
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, "MoveError", tr("Move failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, "MoveAbortedError", tr("Move failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QScriptValue File::renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(engine)
#ifdef Q_OS_LINUX
movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine);
#endif
#ifdef Q_OS_WIN
Q_UNUSED(createDestinationDirectory)
QDir sourceDir(source);
QDir destinationDir(destination);
std::wstring wideSource = QDir::toNativeSeparators(sourceDir.absolutePath()).toStdWString();
wideSource += L'\0';
std::wstring wideDestination = QDir::toNativeSeparators(destinationDir.absolutePath()).toStdWString();
wideDestination += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_RENAME;
shFileOpStruct.pFrom = wideSource.c_str();
shFileOpStruct.pTo = wideDestination.c_str();
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, "RenameError", tr("Rename failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, "RenameAbortedError", tr("Rename failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QScriptValue File::removePrivate(const QString &filename, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, QScriptContext *context, QScriptEngine *engine)
{
#ifdef Q_OS_LINUX
Q_UNUSED(noErrorDialog)
Q_UNUSED(noConfirmDialog)
Q_UNUSED(noProgressDialog)
Q_UNUSED(allowUndo)
QString filenameCopy(filename);
filenameCopy.replace(" ", "\\ ");
QString command = "sh -c \"rm -fr";
command += " ";
command += QFile::encodeName(filenameCopy);
command += "\"";
if(QProcess::execute(command))
{
throwError(context, engine, "RemoveError", tr("Remove failed"));
return context->thisObject();
}
#endif
#ifdef Q_OS_WIN
QDir filenameDir(filename);
std::wstring wideFilename = QDir::toNativeSeparators(filenameDir.absolutePath()).toStdWString();
wideFilename += L'\0';
SHFILEOPSTRUCT shFileOpStruct;
shFileOpStruct.hwnd = 0;
shFileOpStruct.wFunc = FO_DELETE;
shFileOpStruct.pFrom = wideFilename.c_str();
shFileOpStruct.pTo = 0;
shFileOpStruct.fFlags = 0;
shFileOpStruct.fAnyOperationsAborted = false;
shFileOpStruct.lpszProgressTitle = 0;
shFileOpStruct.hNameMappings = 0;
if(noErrorDialog)
shFileOpStruct.fFlags |= FOF_NOERRORUI;
if(noConfirmDialog)
shFileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);
if(noProgressDialog)
shFileOpStruct.fFlags |= FOF_SILENT;
if(allowUndo)
shFileOpStruct.fFlags |= FOF_ALLOWUNDO;
int result = SHFileOperation(&shFileOpStruct);
if(result != 0)
{
throwError(context, engine, "RemoveError", tr("Remove failed: %1").arg(getErrorString(result)));
return context->thisObject();
}
if(shFileOpStruct.fAnyOperationsAborted)
{
throwError(context, engine, "RemoveAbortedError", tr("Remove failed: aborted"));
return context->thisObject();
}
#endif
return context->thisObject();
}
QString File::getErrorString(int error)
{
#ifdef Q_OS_LINUX
Q_UNUSED(error)
return QString();
#endif
#ifdef Q_OS_WIN
switch(error)
{
case ERROR_SUCCESS:
return QString();
case ERROR_FILE_NOT_FOUND:
return tr("File not found");
case ERROR_PATH_NOT_FOUND:
return tr("Path not found");
case ERROR_ACCESS_DENIED:
return tr("Access denied");
case ERROR_SHARING_VIOLATION:
return tr("This file is used by another process");
case ERROR_DISK_FULL:
return tr("The disk is full");
case ERROR_FILE_EXISTS:
case ERROR_ALREADY_EXISTS:
return tr("The file already exists");
case ERROR_INVALID_NAME:
return tr("Invalid name");
case ERROR_CANCELLED:
return tr("Canceled");
default:
return tr("Unknown error (%1)").arg(error);
}
#endif
}
}
actiona-3.9.2/actions/actionpackdata/code/file.h 0000664 0000000 0000000 00000010252 12722271506 0021557 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef FILE_H
#define FILE_H
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class File : public CodeClass
{
Q_OBJECT
Q_ENUMS(OpenMode)
Q_ENUMS(Encoding)
public:
enum OpenMode
{
ReadOnly = QIODevice::ReadOnly,
WriteOnly = QIODevice::WriteOnly,
ReadWrite = QIODevice::ReadWrite,
Append = QIODevice::Append,
Truncate = QIODevice::Truncate,
Text = QIODevice::Text,
Unbuffered = QIODevice::Unbuffered
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
static QScriptValue copy(QScriptContext *context, QScriptEngine *engine);
static QScriptValue exists(QScriptContext *context, QScriptEngine *engine);
static QScriptValue move(QScriptContext *context, QScriptEngine *engine);
static QScriptValue rename(QScriptContext *context, QScriptEngine *engine);
static QScriptValue remove(QScriptContext *context, QScriptEngine *engine);
static void registerClass(QScriptEngine *scriptEngine);
~File() { mFile.close(); }
QFile *file() { return &mFile; }
public slots:
QString toString() const { return "File"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue open(const QString &filename, OpenMode mode);
QScriptValue write(const QScriptValue &data);
QScriptValue writeText(const QString &value, Encoding encoding = Native);
QScriptValue read();
QString readText(Encoding encoding = Native);
QScriptValue close();
QScriptValue copy(const QString &destination, const QScriptValue &options = QScriptValue()) const;
QScriptValue move(const QString &destination, const QScriptValue &options = QScriptValue());
QScriptValue rename(const QString &destination, const QScriptValue &options = QScriptValue());
QScriptValue remove(const QScriptValue &options = QScriptValue());
private:
static bool getParameters(QString &source, QString &destination, const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static bool getParameters(const QScriptValue &options, bool &noErrorDialog, bool &noConfirmDialog, bool &noProgressDialog, bool &allowUndo, bool &createDestinationDirectory);
static QScriptValue copyPrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static QScriptValue movePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static QScriptValue renamePrivate(const QString &source, const QString &destination, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, bool createDestinationDirectory, QScriptContext *context, QScriptEngine *engine);
static QScriptValue removePrivate(const QString &filename, bool noErrorDialog, bool noConfirmDialog, bool noProgressDialog, bool allowUndo, QScriptContext *context, QScriptEngine *engine);
static QString getErrorString(int error);
QFile mFile;
};
}
#endif // FILE_H
actiona-3.9.2/actions/actionpackdata/code/inifile.cpp 0000664 0000000 0000000 00000013074 12722271506 0022617 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "inifile.h"
#include
#include
namespace Code
{
QScriptValue IniFile::constructor(QScriptContext *context, QScriptEngine *engine)
{
IniFile *iniFile = new IniFile;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "encoding")
iniFile->mEncoding = static_cast(it.value().toInt32());
}
return CodeClass::constructor(iniFile, context, engine);
}
IniFile::IniFile()
: CodeClass(),
mEncoding(Native)
{
}
QScriptValue IniFile::load(const QString &filename)
{
try
{
boost::property_tree::ini_parser::read_ini(toEncoding(filename, mEncoding).constData(), mTree);
}
catch(const std::runtime_error &e)
{
throwError("LoadFileError", tr("Cannot load the file"));
return thisObject();
}
mLatestFilename = filename;
return thisObject();
}
QScriptValue IniFile::save(const QString &filename)
{
QByteArray filenameByteArray = toEncoding(filename.isEmpty() ? mLatestFilename : filename, mEncoding);
try
{
boost::property_tree::ini_parser::write_ini(filenameByteArray.constData(), mTree);
}
catch(const std::runtime_error &e)
{
throwError("SaveFileError", tr("Cannot save the file"));
return thisObject();
}
return thisObject();
}
QScriptValue IniFile::clear()
{
mTree.clear();
return thisObject();
}
QScriptValue IniFile::setSection(const QString §ionName, bool create)
{
QByteArray sectionNameByteArray = toEncoding(sectionName, mEncoding);
if(mTree.count(sectionNameByteArray.constData()) == 0)
{
if(!create)
{
throwError("FindSectionError", tr("Cannot find the section named \"%1\"").arg(sectionName));
return thisObject();
}
mCurrentSection = mTree.add_child(sectionNameByteArray.constData(), {});
}
else
mCurrentSection = mTree.get_child(sectionNameByteArray.constData());
mCurrentSectionName = sectionNameByteArray;
return thisObject();
}
QScriptValue IniFile::setEncoding(Encoding encoding)
{
mEncoding = encoding;
return thisObject();
}
QString IniFile::sectionAt(int sectionIndex) const
{
if(sectionIndex < 0 || sectionIndex >= static_cast(mTree.size()))
{
throwError("FindSectionError", tr("Invalid section index"));
return QString();
}
auto it = mTree.begin();
std::advance(it, sectionIndex);
return QString::fromStdString(it->first);
}
QScriptValue IniFile::deleteSection(const QString §ionName)
{
QByteArray sectionNameByteArray = toEncoding(sectionName, mEncoding);
if(!mTree.erase(sectionNameByteArray.constData()))
{
throwError("FindSectionError", tr("Cannot delete section named \"%1\"").arg(sectionName));
return thisObject();
}
return thisObject();
}
int IniFile::sectionCount() const
{
return static_cast(mTree.size());
}
bool IniFile::keyExists(const QString &keyName) const
{
QByteArray keyNameByteArray = toEncoding(keyName, mEncoding);
return (mCurrentSection.count(keyNameByteArray.constData()) > 0);
}
QString IniFile::keyAt(int keyIndex) const
{
if(keyIndex < 0 || keyIndex >= static_cast(mCurrentSection.size()))
{
throwError("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("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("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.9.2/actions/actionpackdata/code/inifile.h 0000664 0000000 0000000 00000004216 12722271506 0022262 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef INIFILE_H
#define INIFILE_H
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class IniFile : public CodeClass
{
Q_OBJECT
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
IniFile();
public slots:
QString toString() const { return "IniFile"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue load(const QString &filename);
QScriptValue save(const QString &filename = QString());
QScriptValue clear();
QScriptValue setSection(const QString §ionName, bool create = true);
QScriptValue setEncoding(Encoding encoding);
QString sectionAt(int sectionIndex) const;
QScriptValue deleteSection(const QString §ionName);
int sectionCount() const;
bool keyExists(const QString &keyName) const;
QString keyAt(int keyIndex) const;
QString keyValue(const QString &keyName) const;
QScriptValue setKeyValue(const QString &keyName, const QString &value);
QScriptValue deleteKey(const QString &keyName);
int keyCount() const;
private:
Encoding mEncoding;
boost::property_tree::ptree mCurrentSection;
boost::property_tree::ptree mTree;
QByteArray mCurrentSectionName;
QString mLatestFilename;
};
}
#endif // INIFILE_H
actiona-3.9.2/actions/actionpackdata/code/mail.cpp 0000664 0000000 0000000 00000020235 12722271506 0022117 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mail.h"
#include "mailmessage.h"
#include "qxtcore/qxtsignalwaiter.h"
#include
#include
namespace Code
{
QScriptValue Mail::constructor(QScriptContext *context, QScriptEngine *engine)
{
Mail *mail = new Mail;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "username")
mail->setUsername(it.value().toString());
else if(it.name() == "password")
mail->setPassword(it.value().toString());
else if(it.name() == "onConnected")
mail->mOnConnected = it.value();
else if(it.name() == "onConnectionFailed")
mail->mOnConnectionFailed = it.value();
else if(it.name() == "onEncrypted")
mail->mOnEncrypted = it.value();
else if(it.name() == "onEncryptionFailed")
mail->mOnEncryptionFailed = it.value();
else if(it.name() == "onAuthenticated")
mail->mOnAuthenticated = it.value();
else if(it.name() == "onAuthenticationFailed")
mail->mOnAuthenticationFailed = it.value();
else if(it.name() == "onSenderRejected")
mail->mOnSenderRejected = it.value();
else if(it.name() == "onRecipientRejected")
mail->mOnRecipientRejected = it.value();
else if(it.name() == "onMailFailed")
mail->mOnMailFailed = it.value();
else if(it.name() == "onMailSent")
mail->mOnMailSent = it.value();
else if(it.name() == "onFinished")
mail->mOnFinished = it.value();
else if(it.name() == "onDisconnected")
mail->mOnDisconnected = it.value();
}
return CodeClass::constructor(mail, context, engine);
}
Mail::Mail()
: CodeClass()
{
connect(&mSmtp, SIGNAL(connected()), this, SLOT(connected()));
connect(&mSmtp, SIGNAL(connectionFailed(QByteArray)), this, SLOT(connectionFailed(QByteArray)));
connect(&mSmtp, SIGNAL(encrypted()), this, SLOT(encrypted()));
connect(&mSmtp, SIGNAL(encryptionFailed(QByteArray)), this, SLOT(encryptionFailed(QByteArray)));
connect(&mSmtp, SIGNAL(authenticated()), this, SLOT(authenticated()));
connect(&mSmtp, SIGNAL(authenticationFailed(QByteArray)), this, SLOT(authenticationFailed(QByteArray)));
connect(&mSmtp, SIGNAL(senderRejected(int,QString,QByteArray)), this, SLOT(senderRejected(int,QString,QByteArray)));
connect(&mSmtp, SIGNAL(recipientRejected(int,QString,QByteArray)), this, SLOT(recipientRejected(int,QString,QByteArray)));
connect(&mSmtp, SIGNAL(mailFailed(int,int,QByteArray)), this, SLOT(mailFailed(int,int,QByteArray)));
connect(&mSmtp, SIGNAL(mailSent(int)), this, SLOT(mailSent(int)));
connect(&mSmtp, SIGNAL(finished()), this, SLOT(finished()));
connect(&mSmtp, SIGNAL(disconnected()), this, SLOT(disconnected()));
}
QScriptValue Mail::connectToServer(const QString &serverName, int port)
{
mSmtp.connectToHost(serverName, port);
return thisObject();
}
QScriptValue Mail::connectToSecureServer(const QString &serverName, int port)
{
mSmtp.connectToSecureHost(serverName, port);
return thisObject();
}
int Mail::send(const QScriptValue &mail)
{
if(MailMessage *mailMessage = qobject_cast(mail.toQObject()))
{
QxtMailMessage &message = mailMessage->message();
if(!message.hasExtraHeader("Date"))
message.setExtraHeader("Date", QDateTime::currentDateTime().toString(Qt::RFC2822Date));
return mSmtp.send(message);
}
else
{
throwError("ParameterTypeError", tr("Incorrect parameter type: not a MailMessage"));
return -1;
}
}
QScriptValue Mail::waitForConnected(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(connected()));
if(!waiter.wait(waitTime))
throwError("ConnectionError", tr("Cannot establish a connection to the server"));
return thisObject();
}
QScriptValue Mail::waitForEncrypted(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(encrypted()));
if(!waiter.wait(waitTime))
throwError("EncryptionError", tr("Cannot encrypt the connection"));
return thisObject();
}
QScriptValue Mail::waitForAuthenticated(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(authenticated()));
if(!waiter.wait(waitTime))
throwError("AuthenticationError", tr("Cannot authenticate to the server"));
return thisObject();
}
QScriptValue Mail::waitForFinished(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(finished()));
if(!waiter.wait(waitTime))
throwError("WaitForFinishedError", tr("Wait for finished failed"));
return thisObject();
}
QScriptValue Mail::waitForDisconnected(int waitTime)
{
QxtSignalWaiter waiter(&mSmtp, SIGNAL(disconnected()));
if(!waiter.wait(waitTime))
throwError("WaitForDisconnectedError", tr("Wait for disconnected failed"));
return thisObject();
}
void Mail::connected()
{
if(mOnConnected.isValid())
mOnConnected.call(thisObject());
}
void Mail::connectionFailed(const QByteArray &msg)
{
if(mOnConnectionFailed.isValid())
mOnConnectionFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg));
}
void Mail::encrypted()
{
if(mOnEncrypted.isValid())
mOnEncrypted.call(thisObject());
}
void Mail::encryptionFailed(const QByteArray &msg)
{
if(mOnEncryptionFailed.isValid())
mOnEncryptionFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg));
}
void Mail::authenticated()
{
if(mOnAuthenticated.isValid())
mOnAuthenticated.call(thisObject());
}
void Mail::authenticationFailed(const QByteArray &msg)
{
if(mOnAuthenticationFailed.isValid())
mOnAuthenticationFailed.call(thisObject(), QScriptValueList() << QString::fromUtf8(msg));
}
void Mail::senderRejected(int mailID, const QString &address, const QByteArray &msg)
{
if(mOnSenderRejected.isValid())
mOnSenderRejected.call(thisObject(), QScriptValueList() << mailID << address << QString::fromUtf8(msg));
}
void Mail::recipientRejected(int mailID, const QString &address, const QByteArray &msg)
{
if(mOnRecipientRejected.isValid())
mOnRecipientRejected.call(thisObject(), QScriptValueList() << mailID << address << QString::fromUtf8(msg));
}
void Mail::mailFailed(int mailID, int errorCode, const QByteArray &msg)
{
if(mOnMailFailed.isValid())
mOnMailFailed.call(thisObject(), QScriptValueList() << mailID << errorCode << QString::fromUtf8(msg));
}
void Mail::mailSent(int mailID)
{
if(mOnMailSent.isValid())
mOnMailSent.call(thisObject(), QScriptValueList() << mailID);
}
void Mail::finished()
{
if(mOnFinished.isValid())
mOnFinished.call(thisObject());
}
void Mail::disconnected()
{
if(mOnDisconnected.isValid())
mOnDisconnected.call(thisObject());
}
}
actiona-3.9.2/actions/actionpackdata/code/mail.h 0000664 0000000 0000000 00000020510 12722271506 0021560 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef MAIL_H
#define MAIL_H
#include "code/codeclass.h"
#include "qxtsmtp/qxtsmtp.h"
#include
#include
#include
namespace Code
{
class Mail : public CodeClass
{
Q_OBJECT
Q_PROPERTY(QString username READ username WRITE setUsername)
Q_PROPERTY(QString password READ password WRITE setPassword)
Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected)
Q_PROPERTY(QScriptValue onConnectionFailed READ onConnectionFailed WRITE setOnConnectionFailed)
Q_PROPERTY(QScriptValue onEncrypted READ onEncrypted WRITE setOnEncrypted)
Q_PROPERTY(QScriptValue onEncryptionFailed READ onEncryptionFailed WRITE setOnEncryptionFailed)
Q_PROPERTY(QScriptValue onAuthenticated READ onAuthenticated WRITE setOnAuthenticated)
Q_PROPERTY(QScriptValue onAuthenticationFailed READ onAuthenticationFailed WRITE setOnAuthenticationFailed)
Q_PROPERTY(QScriptValue onSenderRejected READ onSenderRejected WRITE setOnSenderRejected)
Q_PROPERTY(QScriptValue onRecipientRejected READ onRecipientRejected WRITE setOnRecipientRejected)
Q_PROPERTY(QScriptValue onMailFailed READ onMailFailed WRITE setOnMailFailed)
Q_PROPERTY(QScriptValue onMailSent READ onMailSent WRITE setOnMailSent)
Q_PROPERTY(QScriptValue onFinished READ onFinished WRITE setOnFinished)
Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected)
Q_PROPERTY(int pendingMessageCount READ pendingMessageCount)
Q_PROPERTY(bool startTlsDisabled READ startTlsDisabled WRITE setStartTlsDisabled)
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
Mail();
QString username() const { return mSmtp.username(); }
void setUsername(const QString &username) { mSmtp.setUsername(username.toUtf8()); }
QString password() const { return mSmtp.password(); }
void setPassword(const QString &password) { mSmtp.setPassword(password.toUtf8()); }
void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; }
QScriptValue onConnected() const { return mOnConnected; }
void setOnConnectionFailed(const QScriptValue &onConnectionFailed) { mOnConnectionFailed = onConnectionFailed; }
QScriptValue onConnectionFailed() const { return mOnConnectionFailed; }
void setOnEncrypted(const QScriptValue &onEncrypted) { mOnEncrypted = onEncrypted; }
QScriptValue onEncrypted() const { return mOnEncrypted; }
void setOnEncryptionFailed(const QScriptValue &onEncryptionFailed) { mOnEncryptionFailed = onEncryptionFailed; }
QScriptValue onEncryptionFailed() const { return mOnEncryptionFailed; }
void setOnAuthenticated(const QScriptValue &onAuthenticated) { mOnAuthenticated = onAuthenticated; }
QScriptValue onAuthenticated() const { return mOnAuthenticated; }
void setOnAuthenticationFailed(const QScriptValue &onAuthenticationFailed) { mOnAuthenticationFailed = onAuthenticationFailed; }
QScriptValue onAuthenticationFailed() const { return mOnAuthenticationFailed; }
void setOnSenderRejected(const QScriptValue &onSenderRejected) { mOnSenderRejected = onSenderRejected; }
QScriptValue onSenderRejected() const { return mOnSenderRejected; }
void setOnRecipientRejected(const QScriptValue &onRecipientRejected) { mOnRecipientRejected = onRecipientRejected; }
QScriptValue onRecipientRejected() const { return mOnRecipientRejected; }
void setOnMailFailed(const QScriptValue &onMailFailed) { mOnMailFailed = onMailFailed; }
QScriptValue onMailFailed() const { return mOnMailFailed; }
void setOnMailSent(const QScriptValue &onMailSent) { mOnMailSent = onMailSent; }
QScriptValue onMailSent() const { return mOnMailSent; }
void setOnFinished(const QScriptValue &onFinished) { mOnFinished = onFinished; }
QScriptValue onFinished() const { return mOnFinished; }
void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; }
QScriptValue onDisconnected() const { return mOnDisconnected; }
int pendingMessageCount() const { return mSmtp.pendingMessages(); }
bool startTlsDisabled() const { return mSmtp.startTlsDisabled(); }
void setStartTlsDisabled(bool disable) { mSmtp.setStartTlsDisabled(disable); }
public slots:
QString toString() const { return "Mail"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue connectToServer(const QString &serverName, int port = 25);
QScriptValue connectToSecureServer(const QString &serverName, int port = 465);
int send(const QScriptValue &mail);
QScriptValue disconnectFromServer() { mSmtp.disconnectFromHost(); return thisObject(); }
bool hasExtension(const QString &extension) { return mSmtp.hasExtension(extension); }
QString extensionData(const QString &extension) { return mSmtp.extensionData(extension); }
QScriptValue waitForConnected(int waitTime = 30000);
QScriptValue waitForEncrypted(int waitTime = 30000);
QScriptValue waitForAuthenticated(int waitTime = 30000);
QScriptValue waitForFinished(int waitTime = 30000);
QScriptValue waitForDisconnected(int waitTime = 30000);
private slots:
void connected();
void connectionFailed(const QByteArray &msg);
void encrypted();
void encryptionFailed(const QByteArray &msg);
void authenticated();
void authenticationFailed(const QByteArray &msg);
void senderRejected(int mailID, const QString &address, const QByteArray &msg);
void recipientRejected(int mailID, const QString &address, const QByteArray &msg);
void mailFailed(int mailID, int errorCode, const QByteArray &msg);
void mailSent(int mailID);
void finished();
void disconnected();
private:
QxtSmtp mSmtp;
QScriptValue mOnConnected;
QScriptValue mOnConnectionFailed;
QScriptValue mOnEncrypted;
QScriptValue mOnEncryptionFailed;
QScriptValue mOnAuthenticated;
QScriptValue mOnAuthenticationFailed;
QScriptValue mOnSenderRejected;
QScriptValue mOnRecipientRejected;
QScriptValue mOnMailFailed;
QScriptValue mOnMailSent;
QScriptValue mOnFinished;
QScriptValue mOnDisconnected;
};
}
#endif // MAIL_H
actiona-3.9.2/actions/actionpackdata/code/mailattachment.cpp 0000664 0000000 0000000 00000004566 12722271506 0024201 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mailattachment.h"
#include "code/rawdata.h"
#include
namespace Code
{
QScriptValue MailAttachment::constructor(QScriptContext *context, QScriptEngine *engine)
{
MailAttachment *mailAttachment = new MailAttachment;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "contentType")
mailAttachment->setContentType(it.value().toString());
else if(it.name() == "content")
mailAttachment->setContent(it.value());
}
return CodeClass::constructor(mailAttachment, context, engine);
}
QScriptValue MailAttachment::constructor(const QxtMailAttachment &attachment, QScriptEngine* engine)
{
return CodeClass::constructor(new MailAttachment(attachment), engine);
}
MailAttachment::MailAttachment()
: CodeClass()
{
}
MailAttachment::MailAttachment(const QxtMailAttachment& attachment)
: CodeClass(),
mAttachment(attachment)
{
}
QScriptValue MailAttachment::content() const
{
return RawData::constructor(mContent, engine());
}
QScriptValue MailAttachment::setContent(const QScriptValue &content)
{
if(RawData *rawData = qobject_cast(content.toQObject()))
mContent = rawData->byteArray();
else
mContent = content.toVariant().toByteArray();
mAttachment.setContent(mContent);
return thisObject();
}
QScriptValue MailAttachment::clone() const
{
return constructor(mAttachment, engine());
}
}
actiona-3.9.2/actions/actionpackdata/code/mailattachment.h 0000664 0000000 0000000 00000005462 12722271506 0023642 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef MAILATTACHMENT_H
#define MAILATTACHMENT_H
#include "code/codeclass.h"
#include "qxtsmtp/qxtmailattachment.h"
#include
#include
#include
namespace Code
{
class MailAttachment : public CodeClass
{
Q_OBJECT
Q_PROPERTY(QString contentType READ contentType WRITE setContentType)
Q_PROPERTY(QScriptValue content READ content WRITE setContent)
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
static QScriptValue constructor(const QxtMailAttachment &attachment, QScriptEngine *engine);
MailAttachment();
MailAttachment(const QxtMailAttachment &attachment);
QString contentType() const { return mAttachment.contentType(); }
QScriptValue content() const;
void setContentType(const QString &contentType) { mAttachment.setContentType(contentType); }
QScriptValue setContent(const QScriptValue &content);
const QxtMailAttachment &attachment() const { return mAttachment; }
public slots:
QScriptValue clone() const;
QString toString() const { return "MailAttachment"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue setExtraHeader(const QString &name, const QString &value) { mAttachment.setExtraHeader(name, value); return thisObject(); }
QScriptValue removeExtraHeader(const QString &name) { mAttachment.removeExtraHeader(name); return thisObject(); }
bool hasExtraHeader(const QString &name) const { return mAttachment.hasExtraHeader(name); }
QString extraHeader(const QString &name) const { return mAttachment.extraHeader(name); }
private:
QxtMailAttachment mAttachment;
QByteArray mContent;
};
}
#endif // MAILATTACHMENT_H
actiona-3.9.2/actions/actionpackdata/code/mailmessage.cpp 0000664 0000000 0000000 00000006030 12722271506 0023461 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "mailmessage.h"
#include "mailattachment.h"
#include
namespace Code
{
QScriptValue MailMessage::constructor(QScriptContext *context, QScriptEngine *engine)
{
MailMessage *mailMessage = new MailMessage;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "sender")
mailMessage->mMessage.setSender(it.value().toString());
else if(it.name() == "subject")
mailMessage->mMessage.setSubject(it.value().toString());
else if(it.name() == "body")
mailMessage->mMessage.setBody(it.value().toString());
}
return CodeClass::constructor(mailMessage, context, engine);
}
MailMessage::MailMessage()
: CodeClass()
{
}
QScriptValue MailMessage::attachments() const
{
const QHash &attachments = mMessage.attachments();
QScriptValue back = engine()->newArray(attachments.size());
int index = 0;
for(QHash::ConstIterator it = attachments.constBegin(); it != attachments.constEnd(); ++it)
{
QScriptValue attachmentObject = engine()->newObject();
attachmentObject.setProperty("filename", it.key());
attachmentObject.setProperty("attachment", MailAttachment::constructor(it.value(), engine()));
back.setProperty(index, attachmentObject);
++index;
}
return back;
}
QScriptValue MailMessage::attachment(const QString &filename) const
{
return MailAttachment::constructor(mMessage.attachment(filename), engine());
}
QScriptValue MailMessage::addAttachment(const QString &filename, const QScriptValue &attachment)
{
if(MailAttachment *mailAttachment = qobject_cast(attachment.toQObject()))
mMessage.addAttachment(filename, mailAttachment->attachment());
else
throwError("ParameterTypeError", tr("Incorrect parameter type: not a MailAttachment"));
return thisObject();
}
QScriptValue MailMessage::removeAttachment(const QString &filename)
{
mMessage.removeAttachment(filename);
return thisObject();
}
}
actiona-3.9.2/actions/actionpackdata/code/mailmessage.h 0000664 0000000 0000000 00000007477 12722271506 0023146 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef MAILMESSAGE_H
#define MAILMESSAGE_H
#include "code/codeclass.h"
#include "qxtsmtp/qxtmailmessage.h"
#include
#include
#include
namespace Code
{
class MailMessage : public CodeClass
{
Q_OBJECT
Q_ENUMS(RecipientType)
Q_PROPERTY(QString sender READ sender WRITE setSender)
Q_PROPERTY(QString subject READ subject WRITE setSubject)
Q_PROPERTY(QString body READ body WRITE setBody)
public:
enum RecipientType
{
To,
Cc,
Bcc
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
MailMessage();
QString sender() const { return mMessage.sender(); }
void setSender(const QString &sender) { mMessage.setSender(sender); }
QString subject() const { return mMessage.subject(); }
void setSubject(const QString &subject) { mMessage.setSubject(subject); }
QString body() const { return mMessage.body(); }
void setBody(const QString &body) { mMessage.setBody(body); }
QxtMailMessage &message() { return mMessage; }
public slots:
QString toString() const { return "MailMessage"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue setExtraHeader(const QString &name, const QString &value) { mMessage.setExtraHeader(name, value); return thisObject(); }
QScriptValue removeExtraHeader(const QString &name) { mMessage.removeExtraHeader(name); return thisObject(); }
bool hasExtraHeader(const QString &name) const { return mMessage.hasExtraHeader(name); }
QString extraHeader(const QString &name) const { return mMessage.extraHeader(name); }
QStringList recipients(RecipientType type = To) const { return mMessage.recipients(static_cast(type)); }
QScriptValue addRecipient(const QString &recipient, RecipientType type = To){ mMessage.addRecipient(recipient, static_cast(type)); return thisObject(); }
QScriptValue removeRecipient(const QString &recipient) { mMessage.removeRecipient(recipient); return thisObject(); }
QScriptValue attachments() const;
QScriptValue attachment(const QString &filename) const;
QScriptValue addAttachment(const QString &filename, const QScriptValue &attachment);
QScriptValue removeAttachment(const QString &filename);
private:
QxtMailMessage mMessage;
};
}
#endif // MAILMESSAGE_H
actiona-3.9.2/actions/actionpackdata/code/registry.cpp 0000664 0000000 0000000 00000026375 12722271506 0023060 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "registry.h"
#include
#include
#ifdef Q_OS_WIN
#include
#endif
namespace Code
{
QScriptValue Registry::constructor(QScriptContext *context, QScriptEngine *engine)
{
return CodeClass::constructor(new Registry, context, engine);
}
Registry::Registry()
: CodeClass()
#ifdef Q_OS_WIN
, mHKey(0)
, mRootKey(ClassesRoot)
#endif
{
}
Registry::~Registry()
{
#ifdef Q_OS_WIN
RegCloseKey(mHKey);
#endif
}
QScriptValue Registry::openKey(Key key, const QString &subKey)
{
#ifdef Q_OS_WIN
HKEY hKey = enumToKey(key);
if(RegOpenKeyEx(hKey, subKey.toStdWString().c_str(), 0, KEY_ALL_ACCESS, &mHKey) != ERROR_SUCCESS)
throwError("OpenKeyError", tr("Unable to open the key"));
else
{
mRootKey = key;
mSubKey = subKey;
}
#else
Q_UNUSED(key)
Q_UNUSED(subKey)
#endif
return thisObject();
}
QScriptValue Registry::createKey(Key key, const QString &subKey)
{
#ifdef Q_OS_WIN
HKEY hKey = enumToKey(key);
if(RegCreateKeyEx(hKey, subKey.toStdWString().c_str(), 0, 0, 0, KEY_ALL_ACCESS, 0, &mHKey, 0) != ERROR_SUCCESS)
throwError("CreateKeyError", tr("Unable to create the key"));
else
{
mRootKey = key;
mSubKey = subKey;
}
#else
Q_UNUSED(key)
Q_UNUSED(subKey)
#endif
return thisObject();
}
QScriptValue Registry::setValue(const QString &value, const QVariant &data) const
{
#ifdef Q_OS_WIN
std::wstring wideValue = value.toStdWString();
switch(data.type())
{
case QVariant::Int:
case QVariant::UInt:
{
int intData = data.toInt();
if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_DWORD, reinterpret_cast(&intData), sizeof(int)) != ERROR_SUCCESS)
throwError("SetValueError", tr("Cannot set the value data"));
}
break;
case QVariant::LongLong:
case QVariant::ULongLong:
{
long long intData = data.toLongLong();
if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_QWORD, reinterpret_cast(&intData), sizeof(long long)) != ERROR_SUCCESS)
throwError("SetValueError", tr("Cannot set the value data"));
}
break;
case QVariant::StringList:
{
const QStringList &stringList = data.toStringList();
std::wstring wideData;
for(const QString &string: stringList)
{
wideData += string.toStdWString();
wideData += L'\0';
}
if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_MULTI_SZ, reinterpret_cast(const_cast(wideData.c_str())), static_cast(wideData.size() * sizeof(wchar_t))) != ERROR_SUCCESS)
throwError("SetValueError", tr("Cannot set the value data"));
}
break;
case QVariant::ByteArray:
{
QByteArray byteArray = data.toByteArray();
if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_BINARY, reinterpret_cast(byteArray.data()), static_cast(byteArray.size())) != ERROR_SUCCESS)
throwError("SetValueError", tr("Cannot set the value data"));
}
break;
default:
{
if(data.type() == QVariant::String || data.canConvert(QVariant::String))
{
std::wstring wideData = data.toString().toStdWString();
if(RegSetValueEx(mHKey, wideValue.c_str(), 0, REG_SZ, reinterpret_cast(const_cast(wideData.c_str())), static_cast(wideData.size() * sizeof(wchar_t))) != ERROR_SUCCESS)
throwError("SetValueError", tr("Cannot set the value data"));
}
else
throwError("SetValueError", tr("Cannot set the value data"));
}
break;
}
#else
Q_UNUSED(value)
Q_UNUSED(data)
#endif
return thisObject();
}
QVariant Registry::value(const QString &value) const
{
#ifdef Q_OS_WIN
DWORD size;
DWORD type;
std::wstring wideValue = value.toStdWString();
if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, &type, 0, &size) != ERROR_SUCCESS)
{
throwError("FindValueError", tr("Cannot find the value to read"));
return QVariant();
}
switch(type)
{
case REG_DWORD:
case REG_DWORD_BIG_ENDIAN:
{
qint32 value;
if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(&value), &size) != ERROR_SUCCESS)
{
throwError("FindValueError", tr("Cannot find the value to read"));
return QVariant();
}
if(type == REG_DWORD_BIG_ENDIAN)
value = qFromBigEndian(value);
return value;
}
break;
case REG_SZ:
case REG_EXPAND_SZ:
case REG_LINK:
case REG_MULTI_SZ:
{
wchar_t *buffer = new wchar_t[size];
if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(buffer), &size) != ERROR_SUCCESS)
{
throwError("FindValueError", tr("Cannot find the value to read"));
return QVariant();
}
if(type == REG_MULTI_SZ)
{
QStringList stringList = QString::fromWCharArray(buffer, size / 2).split(QChar(L'\0'), QString::SkipEmptyParts);
delete [] buffer;
if(stringList.last().isEmpty())
stringList.removeLast();
return stringList;
}
else
{
QString back = QString::fromWCharArray(buffer, size / 2);
delete [] buffer;
return back;
}
}
break;
case REG_BINARY:
{
char *buffer = new char[size];
if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(buffer), &size) != ERROR_SUCCESS)
{
throwError("FindValueError", tr("Cannot find the value to read"));
return QVariant();
}
QByteArray back = QByteArray::fromRawData(buffer, size);
delete [] buffer;
return back;
}
break;
case REG_QWORD:
{
qint64 value;
if(RegQueryValueEx(mHKey, wideValue.c_str(), 0, 0, reinterpret_cast(&value), &size) != ERROR_SUCCESS)
{
throwError("FindValueError", tr("Cannot find the value to read"));
return QVariant();
}
return value;
}
break;
case REG_NONE:
default:
throwError("InvalidValueError", tr("Invalid value type"));
return QVariant();
break;
}
#else
Q_UNUSED(value)
return QVariant();
#endif
}
QStringList Registry::valueNames() const
{
#ifdef Q_OS_WIN
int index = 0;
DWORD valueCount;
DWORD maxValueNameLength;
if(RegQueryInfoKey(mHKey, 0, 0, 0, 0, 0, 0, &valueCount, &maxValueNameLength, 0, 0, 0) != ERROR_SUCCESS)
{
throwError("InvalidKeyError", tr("Unable to query informations about this key"));
return QStringList();
}
if(valueCount == 0 || maxValueNameLength == 0)
return QStringList();
wchar_t *valueName = new wchar_t[maxValueNameLength + 1];
int result;
QStringList back;
for(;;++index)
{
DWORD valueNameSize = maxValueNameLength + 1;
result = RegEnumValue(mHKey, index, valueName, &valueNameSize, 0, 0, 0, 0);
if(result == ERROR_NO_MORE_ITEMS)
break;
if(valueNameSize == 0)
continue;//Skip the default value
back.append(QString::fromWCharArray(valueName, valueNameSize));
}
delete [] valueName;
return back;
#else
return QStringList();
#endif
}
QStringList Registry::keys() const
{
#ifdef Q_OS_WIN
int index = 0;
DWORD subKeyCount;
DWORD maxSubKeyNameLength;
if(RegQueryInfoKey(mHKey, 0, 0, 0, &subKeyCount, &maxSubKeyNameLength, 0, 0, 0, 0, 0, 0) != ERROR_SUCCESS)
{
throwError("InvalidKeyError", tr("Unable to query informations about this key"));
return QStringList();
}
if(subKeyCount == 0 || maxSubKeyNameLength == 0)
return QStringList();
wchar_t *subKeyName = new wchar_t[maxSubKeyNameLength + 1];
int result;
QStringList back;
for(;;++index)
{
DWORD subKeyNameSize = maxSubKeyNameLength + 1;
result = RegEnumKeyEx(mHKey, index, subKeyName, &subKeyNameSize, 0, 0, 0, 0);
if(result == ERROR_NO_MORE_ITEMS)
break;
back.append(QString::fromWCharArray(subKeyName, subKeyNameSize));
}
delete [] subKeyName;
return back;
#else
return QStringList();
#endif
}
QScriptValue Registry::deleteValue(const QString &value) const
{
#ifdef Q_OS_WIN
if(RegDeleteValue(mHKey, value.toStdWString().c_str()) != ERROR_SUCCESS)
throwError("InvalidKeyError", tr("Unable to delete the key"));
#else
Q_UNUSED(value)
#endif
return thisObject();
}
#ifdef Q_OS_WIN
BOOL RegDelnodeRecurse (HKEY hKeyRoot, LPTSTR lpSubKey)
{
LPTSTR lpEnd;
LONG lResult;
DWORD dwSize;
WCHAR szName[MAX_PATH];
HKEY hKey;
FILETIME ftWrite;
// First, see if we can delete the key without having
// to recurse.
lResult = RegDeleteKey(hKeyRoot, lpSubKey);
if (lResult == ERROR_SUCCESS)
return TRUE;
lResult = RegOpenKeyEx (hKeyRoot, lpSubKey, 0, KEY_READ, &hKey);
if (lResult != ERROR_SUCCESS)
{
if (lResult == ERROR_FILE_NOT_FOUND) {
printf("Key not found.\n");
return TRUE;
}
else {
printf("Error opening key.\n");
return FALSE;
}
}
// Check for an ending slash and add one if it is missing.
lpEnd = lpSubKey + lstrlen(lpSubKey);
if (*(lpEnd - 1) != TEXT('\\'))
{
*lpEnd = TEXT('\\');
lpEnd++;
*lpEnd = TEXT('\0');
}
// Enumerate the keys
dwSize = MAX_PATH;
lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
NULL, NULL, &ftWrite);
if (lResult == ERROR_SUCCESS)
{
do {
StringCchCopy (lpEnd, MAX_PATH*2, szName);
if (!RegDelnodeRecurse(hKeyRoot, lpSubKey)) {
break;
}
dwSize = MAX_PATH;
lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
NULL, NULL, &ftWrite);
} while (lResult == ERROR_SUCCESS);
}
lpEnd--;
*lpEnd = TEXT('\0');
RegCloseKey (hKey);
// Try again to delete the key.
lResult = RegDeleteKey(hKeyRoot, lpSubKey);
if (lResult == ERROR_SUCCESS)
return TRUE;
return FALSE;
}
BOOL RegDelnode (HKEY hKeyRoot, LPCTSTR lpSubKey)
{
WCHAR szDelKey[MAX_PATH*2];
StringCchCopy (szDelKey, MAX_PATH*2, lpSubKey);
return RegDelnodeRecurse(hKeyRoot, szDelKey);
}
#endif
QScriptValue Registry::deleteKey(Key key, const QString &subKey) const
{
#ifdef Q_OS_WIN
HKEY hKey = enumToKey(key);
if(!RegDelnode(hKey, subKey.toStdWString().c_str()))
throwError("InvalidKeyError", tr("Unable to delete the key"));
#else
Q_UNUSED(key)
Q_UNUSED(subKey)
#endif
return thisObject();
}
QScriptValue Registry::deleteKey() const
{
#ifdef Q_OS_WIN
RegCloseKey(mHKey);
deleteKey(mRootKey, mSubKey);
#endif
return thisObject();
}
QScriptValue Registry::closeKey() const
{
#ifdef Q_OS_WIN
RegCloseKey(mHKey);
#endif
return thisObject();
}
#ifdef Q_OS_WIN
HKEY Registry::enumToKey(Key key) const
{
switch(key)
{
case ClassesRoot:
return HKEY_CLASSES_ROOT;
case CurrentConfig:
return HKEY_CURRENT_CONFIG;
case CurrentUser:
return HKEY_CURRENT_USER;
case Users:
return HKEY_USERS;
case LocalMachine:
return HKEY_LOCAL_MACHINE;
default:
return HKEY_CURRENT_USER;
}
}
#endif
}
actiona-3.9.2/actions/actionpackdata/code/registry.h 0000664 0000000 0000000 00000004056 12722271506 0022515 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef REGISTRY_H
#define REGISTRY_H
#include "code/codeclass.h"
#include
#include
#include
#include
#ifdef Q_OS_WIN
#include
#endif
namespace Code
{
class Registry : public CodeClass
{
Q_OBJECT
Q_ENUMS(Key)
public:
enum Key
{
ClassesRoot,
CurrentConfig,
CurrentUser,
Users,
LocalMachine
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
Registry();
~Registry();
public slots:
QString toString() const { return "Registry"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue openKey(Key key, const QString &subKey);
QScriptValue createKey(Key key, const QString &subKey);
QScriptValue setValue(const QString &value, const QVariant &data) const;
QVariant value(const QString &value = QString()) const;
QStringList valueNames() const;
QStringList keys() const;
QScriptValue deleteValue(const QString &value = QString()) const;
QScriptValue deleteKey(Key key, const QString &subKey) const;
QScriptValue deleteKey() const;
QScriptValue closeKey() const;
private:
#ifdef Q_OS_WIN
HKEY enumToKey(Key key) const;
HKEY mHKey;
Key mRootKey;
QString mSubKey;
#endif
};
}
#endif // REGISTRY_H
actiona-3.9.2/actions/actionpackdata/code/sql.cpp 0000664 0000000 0000000 00000015116 12722271506 0021776 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "sql.h"
#include "code/codetools.h"
#include
#include
#include
#include
#include
#include
#include
namespace Code
{
QScriptValue Sql::constructor(QScriptContext *context, QScriptEngine *engine)
{
if(context->argumentCount() < 1)
{
throwError(context, engine, "NoDatabaseDriverError", tr("Please specify the database driver that should be used"));
return engine->undefinedValue();
}
Driver driver = static_cast(context->argument(0).toInt32());
return CodeClass::constructor(new Sql(driver), context, engine);
}
QScriptValue Sql::drivers(QScriptContext *context, QScriptEngine *engine)
{
Q_UNUSED(context)
QStringList driverNames = QSqlDatabase::drivers();
QSet driverList;
for(int index = 0; index < driverNames.size(); ++index)
{
const QString &driverNameToInclude = driverNames.at(index);
for(int driverIndex = 0; driverIndex < DriverCount; ++driverIndex)
{
if(driverName(static_cast(driverIndex)) == driverNameToInclude)
driverList.insert(static_cast(driverIndex));
}
}
QScriptValue back = engine->newArray(driverList.size());
int index = 0;
for(const Driver &driver: driverList)
{
back.setProperty(index, driver);
++index;
}
return back;
}
void Sql::registerClass(QScriptEngine *scriptEngine)
{
CodeTools::addClassGlobalFunctionToScriptEngine(&drivers, "drivers", scriptEngine);
}
Sql::Sql(Driver driver)
: CodeClass(),
mDatabase(new QSqlDatabase)
{
mDriverName = driverName(driver);
}
Sql::~Sql()
{
QString connectionName = mDatabase->connectionName();
mDatabase->close();
delete mDatabase;
QSqlDatabase::removeDatabase(connectionName);
}
QScriptValue Sql::connect(const QScriptValue ¶meters) const
{
mDatabase->close();
if(!QSqlDatabase::isDriverAvailable(mDriverName))
{
throwError("DatabaseDriverUnavailableError", tr("The requested database driver is not available"));
return thisObject();
}
*mDatabase = QSqlDatabase::addDatabase(mDriverName, QUuid::createUuid().toString());
if(!mDatabase->isValid())
{
throwError("DatabaseDriverUnavailableError", tr("The requested database driver is not available"));
return thisObject();
}
QScriptValueIterator it(parameters);
QString hostName;
int port = 0;
QString databaseName;
QString userName;
QString password;
QString options;
while(it.hasNext())
{
it.next();
if(it.name() == "hostName")
hostName = it.value().toString();
else if(it.name() == "port")
port = it.value().toInteger();
else if(it.name() == "databaseName")
databaseName = it.value().toString();
else if(it.name() == "userName")
userName = it.value().toString();
else if(it.name() == "password")
password = it.value().toString();
else if(it.name() == "options")
options = it.value().toString();
}
mDatabase->setHostName(hostName);
if(port != 0)
mDatabase->setPort(port);
mDatabase->setDatabaseName(databaseName);
mDatabase->setConnectOptions(options);
if(!mDatabase->open(userName, password))
{
throwError("ConnectionError", tr("Unable to establish a connection to the database"));
return thisObject();
}
return thisObject();
}
QScriptValue Sql::prepare(const QString &queryString, const QScriptValue ¶meters)
{
mQuery = QSqlQuery(*mDatabase);
mQuery.setForwardOnly(true);
if(!mQuery.prepare(queryString))
{
throwError("PrepareQueryError", tr("Failed to prepare the query"));
return thisObject();
}
QScriptValueIterator it(parameters);
while(it.hasNext())
{
it.next();
mQuery.bindValue(it.name(), it.value().toString());
}
return thisObject();
}
QScriptValue Sql::execute(const QString &queryString)
{
bool result = false;
if(queryString.isEmpty())
{
result = mQuery.exec();
}
else
{
mQuery = QSqlQuery(*mDatabase);
mQuery.setForwardOnly(true);
result = mQuery.exec(queryString);
}
if(!result)
{
QSqlError error = mQuery.lastError();
throwError("ExecuteQueryError", tr("Failed to execute the query : %1").arg(error.text()));
return thisObject();
}
return thisObject();
}
QScriptValue Sql::fetchResult(IndexStyle indexStyle)
{
if(!mQuery.isSelect())
{
throwError("FetchError", tr("Cannot fetch the result of a non-select query"));
return thisObject();
}
int size = mQuery.size();
if(size == -1)
size = 0;
QScriptValue back = engine()->newArray(size);
switch(indexStyle)
{
case IndexNumber:
{
QSqlRecord record = mQuery.record();
for(int index = 0; mQuery.next(); ++index)
{
QScriptValue row = engine()->newArray();
for(int columnIndex = 0; columnIndex < record.count(); ++columnIndex)
{
row.setProperty(columnIndex, engine()->newVariant(mQuery.value(columnIndex)));
}
back.setProperty(index, row);
}
}
break;
case IndexName:
{
for(int index = 0; mQuery.next(); ++index)
{
QSqlRecord record = mQuery.record();
QScriptValue row = engine()->newArray(record.count());
for(int columnIndex = 0; columnIndex < record.count(); ++columnIndex)
{
row.setProperty(record.fieldName(columnIndex), engine()->newVariant(record.value(columnIndex)));
}
back.setProperty(index, row);
}
}
break;
}
return back;
}
QScriptValue Sql::disconnect() const
{
mDatabase->close();
return thisObject();
}
QString Sql::driverName(Driver driver)
{
switch(driver)
{
case SQLite2:
return "QSQLITE2";
case SQLite:
return "QSQLITE";
case PostgreSQL:
return "QPSQL";
case MySQL:
return "QMYSQL";
case ODBC:
return "QODBC";
case InterBase:
return "QIBASE";
case OCI:
return "QOCI";
case TDS:
return "QTDS";
case DB2:
return "QDB2";
default:
return QString();
}
}
}
actiona-3.9.2/actions/actionpackdata/code/sql.h 0000664 0000000 0000000 00000004074 12722271506 0021444 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef SQL_H
#define SQL_H
#include "code/codeclass.h"
#include
#include
#include
#include
class QSqlDatabase;
namespace Code
{
class Sql : public CodeClass
{
Q_OBJECT
Q_ENUMS(Driver)
Q_ENUMS(IndexStyle)
public:
enum Driver
{
SQLite2,
SQLite,
PostgreSQL,
MySQL,
ODBC,
InterBase,
OCI,
TDS,
DB2,
DriverCount
};
enum IndexStyle
{
IndexNumber,
IndexName
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
static QScriptValue drivers(QScriptContext *context, QScriptEngine *engine);
static void registerClass(QScriptEngine *scriptEngine);
Sql(Driver driver);
~Sql();
public slots:
QString toString() const { return "Sql"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue connect(const QScriptValue ¶meters) const;
QScriptValue prepare(const QString &queryString, const QScriptValue ¶meters);
QScriptValue execute(const QString &queryString = QString());
QScriptValue fetchResult(IndexStyle indexStyle = IndexName);
QScriptValue disconnect() const;
private:
static QString driverName(Driver driver);
QString mDriverName;
QSqlDatabase *mDatabase;
QSqlQuery mQuery;
};
}
#endif // SQL_H
actiona-3.9.2/actions/actionpackdata/code/tcp.cpp 0000664 0000000 0000000 00000012312 12722271506 0021760 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "tcp.h"
#include "code/rawdata.h"
#include
namespace Code
{
QScriptValue Tcp::constructor(QScriptContext *context, QScriptEngine *engine)
{
Tcp *tcp = new Tcp;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "onConnected")
tcp->mOnConnected = it.value();
else if(it.name() == "onDisconnected")
tcp->mOnDisconnected = it.value();
else if(it.name() == "onReadyRead")
tcp->mOnReadyRead = it.value();
else if(it.name() == "onBytesWritten")
tcp->mOnBytesWritten = it.value();
else if(it.name() == "onError")
tcp->mOnError = it.value();
}
return CodeClass::constructor(tcp, context, engine);
}
QScriptValue Tcp::constructor(QTcpSocket *tcpSocket, QScriptEngine *engine)
{
return CodeClass::constructor(new Tcp(tcpSocket), engine);
}
Tcp::Tcp()
: CodeClass(),
mTcpSocket(new QTcpSocket(this))
{
QObject::connect(mTcpSocket, SIGNAL(connected()), this, SLOT(connected()));
QObject::connect(mTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnected()));
QObject::connect(mTcpSocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
QObject::connect(mTcpSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWritten(qint64)));
QObject::connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
}
Tcp::Tcp(QTcpSocket *tcpSocket)
: CodeClass(),
mTcpSocket(tcpSocket)
{
QObject::connect(mTcpSocket, SIGNAL(connected()), this, SLOT(connected()));
QObject::connect(mTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnected()));
QObject::connect(mTcpSocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
QObject::connect(mTcpSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWritten(qint64)));
QObject::connect(mTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
}
Tcp::~Tcp()
{
}
QScriptValue Tcp::connect(const QString &hostname, quint16 port, OpenMode openMode)
{
mTcpSocket->connectToHost(hostname, port, static_cast(openMode));
return thisObject();
}
QScriptValue Tcp::waitForConnected(int waitTime)
{
if(!mTcpSocket->waitForConnected(waitTime))
throwError("ConnectionError", tr("Cannot establish a connection to the host"));
return thisObject();
}
QScriptValue Tcp::waitForBytesWritten(int waitTime)
{
if(!mTcpSocket->waitForBytesWritten(waitTime))
throwError("BytesWrittenError", tr("Waiting for bytes written failed"));
return thisObject();
}
QScriptValue Tcp::waitForReadyRead(int waitTime)
{
if(!mTcpSocket->waitForReadyRead(waitTime))
throwError("ReadyReadError", tr("Waiting for ready read failed"));
return thisObject();
}
QScriptValue Tcp::waitForDisconnected(int waitTime)
{
if(!mTcpSocket->waitForDisconnected(waitTime))
throwError("DisconnectionError", tr("Waiting for disconnection failed"));
return thisObject();
}
QScriptValue Tcp::write(const QScriptValue &data)
{
QObject *object = data.toQObject();
if(RawData *rawData = qobject_cast(object))
{
if(mTcpSocket->write(rawData->byteArray()) == -1)
throwError("WriteError", tr("Write failed"));
}
else
{
if(mTcpSocket->write(data.toVariant().toByteArray()) == -1)
throwError("WriteError", tr("Write failed"));
}
return thisObject();
}
QScriptValue Tcp::writeText(const QString &data, Encoding encoding)
{
if(mTcpSocket->write(toEncoding(data, encoding)) == -1)
throwError("WriteError", tr("Write failed"));
return thisObject();
}
QScriptValue Tcp::read()
{
return RawData::constructor(mTcpSocket->readAll(), engine());
}
QString Tcp::readText(Encoding encoding)
{
return fromEncoding(mTcpSocket->readAll(), encoding);
}
QScriptValue Tcp::disconnect()
{
mTcpSocket->disconnectFromHost();
return thisObject();
}
void Tcp::connected()
{
if(mOnConnected.isValid())
mOnConnected.call(thisObject());
}
void Tcp::disconnected()
{
if(mOnDisconnected.isValid())
mOnDisconnected.call(thisObject());
}
void Tcp::readyRead()
{
if(mOnReadyRead.isValid())
mOnReadyRead.call(thisObject());
}
void Tcp::bytesWritten(qint64 bytes)
{
if(mOnBytesWritten.isValid())
mOnBytesWritten.call(thisObject(), QScriptValueList() << static_cast(bytes));
}
void Tcp::error(QAbstractSocket::SocketError socketError)
{
Q_UNUSED(socketError)
if(mOnError.isValid())
mOnError.call(thisObject(), QScriptValueList() << mTcpSocket->errorString());
}
}
actiona-3.9.2/actions/actionpackdata/code/tcp.h 0000664 0000000 0000000 00000007035 12722271506 0021433 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef TCP_H
#define TCP_H
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class Tcp : public CodeClass
{
Q_OBJECT
Q_ENUMS(OpenMode)
Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected)
Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected)
Q_PROPERTY(QScriptValue onReadyRead READ onReadyRead WRITE setOnReadyRead)
Q_PROPERTY(QScriptValue onBytesWritten READ onBytesWritten WRITE setOnBytesWritten)
Q_PROPERTY(QScriptValue onError READ onError WRITE setOnError)
public:
enum OpenMode
{
ReadOnly = QIODevice::ReadOnly,
WriteOnly = QIODevice::WriteOnly,
ReadWrite = QIODevice::ReadWrite
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
static QScriptValue constructor(QTcpSocket *tcpSocket, QScriptEngine *engine);
Tcp();
Tcp(QTcpSocket *tcpSocket);
~Tcp();
void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; }
void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; }
void setOnReadyRead(const QScriptValue &onReadyRead) { mOnReadyRead = onReadyRead; }
void setOnBytesWritten(const QScriptValue &onBytesWritten) { mOnBytesWritten = onBytesWritten; }
void setOnError(const QScriptValue &onError) { mOnError = onError; }
QScriptValue onConnected() const { return mOnConnected; }
QScriptValue onDisconnected() const { return mOnDisconnected; }
QScriptValue onReadyRead() const { return mOnReadyRead; }
QScriptValue onBytesWritten() const { return mOnBytesWritten; }
QScriptValue onError() const { return mOnError; }
public slots:
QString toString() const { return "Tcp"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue connect(const QString &hostname, quint16 port, OpenMode openMode = ReadWrite);
QScriptValue waitForConnected(int waitTime = 30000);
QScriptValue waitForBytesWritten(int waitTime = 30000);
QScriptValue waitForReadyRead(int waitTime = 30000);
QScriptValue waitForDisconnected(int waitTime = 30000);
QScriptValue write(const QScriptValue &data);
QScriptValue writeText(const QString &data, Encoding encoding = Native);
QScriptValue read();
QString readText(Encoding encoding = Native);
QScriptValue disconnect();
private slots:
void connected();
void disconnected();
void readyRead();
void bytesWritten(qint64 bytes);
void error(QAbstractSocket::SocketError socketError);
private:
QTcpSocket *mTcpSocket;
QScriptValue mOnConnected;
QScriptValue mOnDisconnected;
QScriptValue mOnReadyRead;
QScriptValue mOnBytesWritten;
QScriptValue mOnError;
};
}
#endif // TCP_H
actiona-3.9.2/actions/actionpackdata/code/tcpserver.cpp 0000664 0000000 0000000 00000004535 12722271506 0023217 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "tcpserver.h"
#include "tcp.h"
#include
namespace Code
{
QScriptValue TcpServer::constructor(QScriptContext *context, QScriptEngine *engine)
{
TcpServer *tcpServer = new TcpServer;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "onNewConnection")
tcpServer->mOnNewConnection = it.value();
}
return CodeClass::constructor(tcpServer, context, engine);
}
TcpServer::TcpServer()
: CodeClass()
{
connect(&mTcpServer, SIGNAL(newConnection()), this, SLOT(newConnection()));
}
TcpServer::~TcpServer()
{
mTcpServer.close();
}
QScriptValue TcpServer::listen(const QString &address, int port)
{
if(!mTcpServer.listen(QHostAddress(address), port))
throwError("ListenError", tr("Unable to start listening"));
return thisObject();
}
QScriptValue TcpServer::waitForNewConnection(int waitTime)
{
if(!mTcpServer.waitForNewConnection(waitTime))
throwError("WaitForNewConnectionError", tr("Waiting for new connection failed"));
return thisObject();
}
QScriptValue TcpServer::nextPendingConnection()
{
QTcpSocket *tcpSocket = mTcpServer.nextPendingConnection();
if(!tcpSocket)
{
throwError("NoPendingConnectionError", tr("There is no pending connection"));
return engine()->undefinedValue();
}
return Tcp::constructor(tcpSocket, engine());
}
QString TcpServer::address() const
{
return mTcpServer.serverAddress().toString();
}
int TcpServer::port() const
{
return mTcpServer.serverPort();
}
void TcpServer::newConnection()
{
if(mOnNewConnection.isValid())
mOnNewConnection.call(thisObject());
}
}
actiona-3.9.2/actions/actionpackdata/code/tcpserver.h 0000664 0000000 0000000 00000003634 12722271506 0022663 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef TCPSERVER_H
#define TCPSERVER_H
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class TcpServer : public CodeClass
{
Q_OBJECT
Q_PROPERTY(QScriptValue onNewConnection READ onNewConnection WRITE setOnNewConnection)
public:
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
TcpServer();
~TcpServer();
void setOnNewConnection(const QScriptValue &onNewConnection) { mOnNewConnection = onNewConnection; }
QScriptValue onNewConnection() const { return mOnNewConnection; }
public slots:
QString toString() const { return "TcpServer"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation(other); }
QScriptValue listen(const QString &address = QString(), int port = 0);
QScriptValue waitForNewConnection(int waitTime = 30000);
QScriptValue nextPendingConnection();
QString address() const;
int port() const;
private slots:
void newConnection();
private:
QTcpServer mTcpServer;
QScriptValue mOnNewConnection;
};
}
#endif // TCPSERVER_H
actiona-3.9.2/actions/actionpackdata/code/udp.cpp 0000664 0000000 0000000 00000007431 12722271506 0021770 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#include "udp.h"
#include "code/rawdata.h"
#include
namespace Code
{
QScriptValue Udp::constructor(QScriptContext *context, QScriptEngine *engine)
{
Udp *udp = new Udp;
QScriptValueIterator it(context->argument(0));
while(it.hasNext())
{
it.next();
if(it.name() == "onConnected")
udp->mOnConnected = it.value();
else if(it.name() == "onDisconnected")
udp->mOnDisconnected = it.value();
else if(it.name() == "onReadyRead")
udp->mOnReadyRead = it.value();
else if(it.name() == "onError")
udp->mOnError = it.value();
}
return CodeClass::constructor(udp, context, engine);
}
Udp::Udp()
: CodeClass(),
mUdpSocket(new QUdpSocket(this))
{
QObject::connect(mUdpSocket, SIGNAL(connected()), this, SLOT(connected()));
QObject::connect(mUdpSocket, SIGNAL(disconnected()), this, SLOT(disconnected()));
QObject::connect(mUdpSocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
QObject::connect(mUdpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(error(QAbstractSocket::SocketError)));
}
Udp::~Udp()
{
}
QScriptValue Udp::connect(const QString &hostname, quint16 port, OpenMode openMode)
{
mUdpSocket->connectToHost(hostname, port, static_cast(openMode));
return thisObject();
}
QScriptValue Udp::waitForConnected(int waitTime)
{
if(!mUdpSocket->waitForConnected(waitTime))
throwError("ConnectionError", tr("Cannot establish a connection to the host"));
return thisObject();
}
QScriptValue Udp::waitForReadyRead(int waitTime)
{
if(!mUdpSocket->waitForReadyRead(waitTime))
throwError("ReadyReadError", tr("Waiting for ready read failed"));
return thisObject();
}
QScriptValue Udp::write(const QScriptValue &data)
{
QObject *object = data.toQObject();
if(RawData *rawData = qobject_cast(object))
{
if(mUdpSocket->write(rawData->byteArray()) == -1)
throwError("WriteError", tr("Write failed"));
}
else
{
if(mUdpSocket->write(data.toVariant().toByteArray()) == -1)
throwError("WriteError", tr("Write failed"));
}
return thisObject();
}
QScriptValue Udp::writeText(const QString &data, Encoding encoding)
{
if(mUdpSocket->write(toEncoding(data, encoding)) == -1)
throwError("WriteError", tr("Write failed"));
return thisObject();
}
QScriptValue Udp::read()
{
return RawData::constructor(mUdpSocket->readAll(), engine());
}
QString Udp::readText(Encoding encoding)
{
return fromEncoding(mUdpSocket->readAll(), encoding);
}
QScriptValue Udp::disconnect()
{
mUdpSocket->disconnectFromHost();
return thisObject();
}
void Udp::connected()
{
if(mOnConnected.isValid())
mOnConnected.call(thisObject());
}
void Udp::disconnected()
{
if(mOnDisconnected.isValid())
mOnDisconnected.call(thisObject());
}
void Udp::readyRead()
{
if(mOnReadyRead.isValid())
mOnReadyRead.call(thisObject());
}
void Udp::error(QAbstractSocket::SocketError socketError)
{
Q_UNUSED(socketError)
if(mOnError.isValid())
mOnError.call(thisObject(), QScriptValueList() << mUdpSocket->errorString());
}
}
actiona-3.9.2/actions/actionpackdata/code/udp.h 0000664 0000000 0000000 00000006021 12722271506 0021427 0 ustar 00root root 0000000 0000000 /*
Actiona
Copyright (C) 2005-2016 Jonathan Mercier-Ganady
Actiona is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Actiona is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Contact : jmgr@jmgr.info
*/
#ifndef UDP_H
#define UDP_H
#include "code/codeclass.h"
#include
#include
#include
#include
namespace Code
{
class Udp : public CodeClass
{
Q_OBJECT
Q_ENUMS(OpenMode)
Q_PROPERTY(QScriptValue onConnected READ onConnected WRITE setOnConnected)
Q_PROPERTY(QScriptValue onDisconnected READ onDisconnected WRITE setOnDisconnected)
Q_PROPERTY(QScriptValue onReadyRead READ onReadyRead WRITE setOnReadyRead)
Q_PROPERTY(QScriptValue onError READ onError WRITE setOnError)
public:
enum OpenMode
{
ReadOnly = QIODevice::ReadOnly,
WriteOnly = QIODevice::WriteOnly,
ReadWrite = QIODevice::ReadWrite
};
static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine);
Udp();
~Udp();
void setOnConnected(const QScriptValue &onConnected) { mOnConnected = onConnected; }
void setOnDisconnected(const QScriptValue &onDisconnected) { mOnDisconnected = onDisconnected; }
void setOnReadyRead(const QScriptValue &onReadyRead) { mOnReadyRead = onReadyRead; }
void setOnError(const QScriptValue &onError) { mOnError = onError; }
QScriptValue onConnected() const { return mOnConnected; }
QScriptValue onDisconnected() const { return mOnDisconnected; }
QScriptValue onReadyRead() const { return mOnReadyRead; }
QScriptValue onError() const { return mOnError; }
public slots:
QString toString() const { return "Udp"; }
virtual bool equals(const QScriptValue &other) const { return defaultEqualsImplementation