pax_global_header00006660000000000000000000000064121631306340014511gustar00rootroot0000000000000052 comment=ef67f99eac1fb64eca58be1a15533fc4447403e3 actionaz-3.7.0/000077500000000000000000000000001216313063400133305ustar00rootroot00000000000000actionaz-3.7.0/.gitignore000066400000000000000000000001311216313063400153130ustar00rootroot00000000000000*.exe *.ilk *.pdb *.user *.user.* *.dll *.exp *.qm *.lib generated *.so* *.log* *.cache* actionaz-3.7.0/3rdparty/000077500000000000000000000000001216313063400151005ustar00rootroot00000000000000actionaz-3.7.0/3rdparty/3rdparty.pro000066400000000000000000000000771216313063400173760ustar00rootroot00000000000000TEMPLATE = subdirs CONFIG = ordered SUBDIRS += rudeconfig actionaz-3.7.0/3rdparty/rudeconfig/000077500000000000000000000000001216313063400172255ustar00rootroot00000000000000actionaz-3.7.0/3rdparty/rudeconfig/AUTHORS000066400000000000000000000021551216313063400203000ustar00rootroot00000000000000Authors of RudeConfig C++ Library For correspondence specific to the rudeconfig library, please use the email address RudeConfig was written by Matt Flood RudeConfig is currently maintained by Matt Flood In the US: Matt Flood Unit 114 4820 Thunderbird Circle Boulder, CO 80303 (+1) (720) 284-1208 http://www.rudeserver.com/ Copyright (C) 2005 Matthew Flood This file is part of RudeConfig. RudeConfig is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. RudeConfig is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with RudeConfig; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. actionaz-3.7.0/3rdparty/rudeconfig/AbstractData.cpp000066400000000000000000000022111216313063400222620ustar00rootroot00000000000000// AbstractData.cc // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "AbstractData.h" namespace rude{ namespace config{ AbstractData::AbstractData() { } AbstractData::~AbstractData() { } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/AbstractData.h000066400000000000000000000025641216313063400217420ustar00rootroot00000000000000// AbstractData.h // Acts as the base Element that accepts visitors in the Visitor design pattern // // This file is part of RudeConfig. // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_AbstractData_H #define INCLUDED_AbstractData_H namespace rude{ namespace config{ class AbstractWriter; class AbstractData{ protected: AbstractData(); public: virtual ~AbstractData(); virtual void acceptWriter(AbstractWriter& writer) const = 0; }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/AbstractOrganiser.cpp000066400000000000000000000022511216313063400233460ustar00rootroot00000000000000// AbstractOrganiser.cc // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "AbstractOrganiser.h" namespace rude{ namespace config{ AbstractOrganiser::AbstractOrganiser() { } AbstractOrganiser::~AbstractOrganiser() { } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/AbstractOrganiser.h000066400000000000000000000027701216313063400230210ustar00rootroot00000000000000// AbstractOrganiser.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_AbstractOrganiser_h #define INCLUDED_AbstractOrganiser_h namespace rude{ namespace config{ class AbstractOrganiser { public: AbstractOrganiser(); virtual ~AbstractOrganiser(); virtual void foundSection(const char *sectionName, const char *comment) = 0; virtual void foundComment(const char *comment) = 0; virtual void foundWhiteSpace(const char *whitespace) = 0; virtual void foundData(const char *key, const char *value, const char *comment) = 0; }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/AbstractParser.cpp000066400000000000000000000033571216313063400226610ustar00rootroot00000000000000// AbstractParser.cc // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "AbstractParser.h" using namespace rude::config; using namespace std; namespace rude{ namespace config{ AbstractParser::AbstractParser() { d_error = ""; d_errorcode = ""; d_commentchar = '#'; d_delimiter = '='; } AbstractParser::~AbstractParser() { } void AbstractParser::setCommentCharacter(char c) { d_commentchar = c; } void AbstractParser::setDelimiter(char c) { d_delimiter = c; } const char *AbstractParser::getErrorCode() const { return d_errorcode.c_str(); } const char *AbstractParser::getError() const { return d_error.c_str(); } void AbstractParser::setError(const char *code, const char *message) { d_errorcode = code ? code : ""; d_error = message ? message : ""; } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/AbstractParser.h000066400000000000000000000034351216313063400223230ustar00rootroot00000000000000// AbstractParser.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INPUT_AbstractParser_h #define INPUT_AbstractParser_h #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif namespace rude{ namespace config{ class ConfigInput; class AbstractOrganiser; class AbstractParser { std::string d_error; std::string d_errorcode; protected: char d_commentchar; char d_delimiter; void setError(const char *code, const char *message); public: AbstractParser(); virtual ~AbstractParser(); void setCommentCharacter(char c); void setDelimiter(char c); const char *getErrorCode() const; const char *getError() const; virtual bool parse(std::istream& inputstream, AbstractOrganiser& organiser) = 0; }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/AbstractWriter.cpp000066400000000000000000000036021216313063400226720ustar00rootroot00000000000000// AbstractWriter.cc // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "AbstractWriter.h" #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif namespace rude{ namespace config{ AbstractWriter::AbstractWriter() { d_commentchar = '#'; d_delimiter = '='; d_preservedeleted = false; d_preservecomments = true; d_preservewhitespace = true; d_outputstream = &std::cout; } AbstractWriter::~AbstractWriter() { } void AbstractWriter::setOutputStream( std::ostream& stream) { d_outputstream = &stream; } void AbstractWriter::setCommentChar(char c) { d_commentchar = c; } void AbstractWriter::setDelimiter(char c) { d_delimiter = c; } void AbstractWriter::preserveDeleted(bool doit) { d_preservedeleted = doit; } void AbstractWriter::preserveComments(bool doit) { d_preservecomments = doit; } void AbstractWriter::preserveWhiteSpace(bool doit) { d_preservewhitespace = doit; } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/AbstractWriter.h000066400000000000000000000041001216313063400223310ustar00rootroot00000000000000// AbstractWriter.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_AbstractWriter_H #define INCLUDED_AbstractWriter_H #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif namespace rude{ namespace config{ class File; class Section; class KeyValue; class Comment; class WhiteSpace; class AbstractWriter{ protected: char d_commentchar; char d_delimiter; bool d_preservedeleted; bool d_preservecomments; bool d_preservewhitespace; std::ostream *d_outputstream; AbstractWriter(); public: virtual void visitFile(const File& configfile) const = 0; virtual void visitSection(const Section& configsection) const = 0; virtual void visitKeyValue(const KeyValue& dataline) const = 0; virtual void visitComment(const Comment& comment) const = 0; virtual void visitWhiteSpace(const WhiteSpace& whitespace) const = 0; void setOutputStream( std::ostream& stream); void setCommentChar(char); void setDelimiter(char); void preserveDeleted(bool doit); void preserveComments(bool doit); void preserveWhiteSpace(bool doit); virtual ~AbstractWriter(); }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/Base64Encoder.cpp000066400000000000000000000153371216313063400222660ustar00rootroot00000000000000// Base64Encoder.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "Base64Encoder.h" #ifndef INCLUDED_CSTRING #include #define INCLUDED_CSTRING #endif namespace rude{ namespace config{ // translates a 6 bit char into a base-64 character // inline char Base64Encoder::c_encode(char uc) { if (uc < 26) { return 'A'+uc; } if (uc < 52) { return 'a'+(uc-26); } if (uc < 62) { return '0'+(uc-52); } if (uc == 62) { return '+'; } return '/'; } // translates one base-64 character into a six-bit pattern // inline unsigned char Base64Encoder::c_decode(char c) { if (c >= 'A' && c <= 'Z') { return c - 'A'; } if (c >= 'a' && c <= 'z') { return c - 'a' + 26; } if (c >= '0' && c <= '9') { return c - '0' + 52; } if (c == '+') { return 62; }; return 63; } char * Base64Encoder::encode(const char *data, size_t datalength, int &outlength) { int linelength=0; outlength=0; if (data == (char*) 0 || datalength == 0) { return (char*) 0; }; char *retval=new char[datalength * 2]; const char *crlf="\n"; size_t crlflength=strlen(crlf); int maxlinelength=76; for (size_t i=0; i>2; by5 = ((by1 & 0x3)<<4)|( by2>>4 ); by6 = ((by2 & 0xf)<<2)|( by3>>6 ); by7 = by3 & 0x3f; retval[outlength++] = c_encode(by4); linelength++; retval[outlength++] = c_encode(by5); linelength++; if (i+1 < datalength) { retval[outlength++]= c_encode(by6); linelength++; } else { retval[outlength++]= '='; linelength++; } if (i+2 0 // if (maxlinelength != 0 && linelength >= maxlinelength) { for(size_t y=0; y< crlflength; y++) { retval[outlength++]= crlf[y]; } // we just created a line - reset current linelength // linelength=0; } }; retval[outlength]=(char) NULL; return retval; } char * Base64Encoder::decode(const char *data, size_t datalength, int &outlength) { // Error if incoming data is NULL // Error if nothing to decode // if(data == (char *) 0 || datalength == 0) { return (char*) 0; } outlength=0; // rawlength is the length of the encoded data excluding // any non-base64 characters // int rawlength=0; // create return buffer // char *outbuffer=new char[datalength]; // copy all base64 characters into outbuffer, // in other words, strip away CRLF's and non-b64 characters... // for (size_t j=0;j < datalength; j++) { if (IsBase64(data[j])) { outbuffer[rawlength++]= data[j]; } } // there's no base64 characters to decode // if (rawlength == 0 || datalength == 0) { delete [] outbuffer; return (char*) NULL; } for (int i=0; i>4) ); outlength++; if (c3 != '=') { outbuffer[outlength]=( ((by2&0xf)<<4)|(by3>>2) ); outlength++; } if (c4 != '=') { outbuffer[outlength]=( ((by3&0x3)<<6)|by4 ); outlength++; }; }; // NULL terminate decoded data // in case caller ignores outlength // for text data // outbuffer[outlength]=(char) 0; return outbuffer; } //The last helper function returns true is a character is a valid //base-64 character and false otherwise. inline bool Base64Encoder::IsBase64(char c) { if (c >= 'A' && c <= 'Z') { return true; } if (c >= 'a' && c <= 'z') { return true; } if (c >= '0' && c <= '9') { return true; } if (c == '+') { return true; }; if (c == '/') { return true; }; if (c == '=') { return true; }; return false; } }} actionaz-3.7.0/3rdparty/rudeconfig/Base64Encoder.h000066400000000000000000000040531216313063400217240ustar00rootroot00000000000000// Base64Encoder.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_BASE64ENCODER_H #define INCLUDED_BASE64ENCODER_H #include namespace rude{ namespace config{ class Base64Encoder{ private: static char c_encode(char uc); static unsigned char c_decode(char c); static bool IsBase64(char c); public: // datalength does not need to include the NULL terminator for strings // // a NULL terminator is appended to result to make it string friendly // but outlength does not include the // appended NULL terminator in length calculation // // CALLER RESPONSIBLE FOR DELETING RETURNED char * if it is not NULL. // static char * encode(const char *data, size_t datalength, int &outlength); // datalength does not need to include the NULL terminator for strings // NULL Terminator is appended to result, but outlength does not include the // appended NULL terminator in length calculation // // CALLER RESPONSIBLE FOR DELETING RETURNED char * if it is not NULL. // static char * decode(const char *data, size_t datalength, int &outlength); }; }} #endif actionaz-3.7.0/3rdparty/rudeconfig/COPYING000066400000000000000000000431221216313063400202620ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) 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 this service 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 make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. 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. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), 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 distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the 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 a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE 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. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. actionaz-3.7.0/3rdparty/rudeconfig/Comment.cpp000066400000000000000000000027521216313063400213410ustar00rootroot00000000000000// Comment.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "Comment.h" #ifndef INCLUDED_AbstractWriter_H #include "AbstractWriter.h" #endif #ifndef INCLUDED_CSTDIO #include #define INCLUDED_CSTDIO #endif using namespace std; namespace rude{ namespace config{ Comment::Comment(const char *comment) { d_comment = comment ? comment : ""; } void Comment::acceptWriter(AbstractWriter& writer) const { writer.visitComment(*this); } const char *Comment::getComment() const { return d_comment.c_str(); } }} // end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/Comment.h000066400000000000000000000026741216313063400210110ustar00rootroot00000000000000// Comment.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_Comment_H #define INCLUDED_Comment_H #ifndef INCLUDED_DataLine_H #include "DataLine.h" #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif namespace rude{ namespace config{ class Comment: public DataLine{ std::string d_comment; public: Comment(const char *comment); void acceptWriter(AbstractWriter& writer) const; const char *getComment() const; }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/ConfigImpl.cpp000066400000000000000000000265431216313063400217720ustar00rootroot00000000000000// configimpl.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ /* Edited on 19/08/2010 by Jonathan Mercier-Ganady for Actionaz */ #include "ConfigImpl.h" #ifndef INCLUDED_Section_H #include "Section.h" #endif #ifndef INCLUDED_File_H #include "File.h" #endif #ifndef INCLUDED_Writer_H #include "Writer.h" #endif #ifndef INPUT_RealOrganiser_h #include "RealOrganiser.h" #endif #ifndef INPUT_ParserJuly2004_h #include "ParserJuly2004.h" #endif #ifndef INCLUDED_BASE64ENCODER_H #include "Base64Encoder.h" #endif #ifndef INCLUDED_CSTDIO #include #define INCLUDED_CSTDIO #endif #ifndef INCLUDED_CSTDLIB #include #define INCLUDED_CSTDLIB #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_FSTREAM #include #define INCLUDED_FSTREAM #endif #ifndef INCLUDED_CSTRING #include #define INCLUDED_CSTRING #endif using namespace std; namespace rude{ namespace config{ // STATIC DATA // std::string ConfigImpl::s_defaultConfigFile = "default.ini"; char ConfigImpl::s_defaultCommentChar = '#'; char ConfigImpl::s_defaultDelimiter = '='; bool ConfigImpl::s_defaultPreserveDeleted = false; bool ConfigImpl::s_defaultAllowDuplicate = false; bool ConfigImpl::s_defaultIgnoreCase = false; std::string ConfigImpl::s_returnValue=""; ////////////////////////////////////// // STATIC METHODS ////////////////////////////////////// const char *ConfigImpl::version() { return "0"; } void ConfigImpl::setDefaultConfigFile(const char *filepath) { s_defaultConfigFile = filepath ? filepath : "default.ini"; } const char *ConfigImpl::getDefaultConfigFile() { return s_defaultConfigFile.c_str(); } void ConfigImpl::setDefaultCommentCharacter(char c) { s_defaultCommentChar = c; } char ConfigImpl::getDefaultCommentCharacter() { return s_defaultCommentChar; } void ConfigImpl::setDefaultDelimiter(char c) { s_defaultDelimiter = c; } char ConfigImpl::getDefaultDelimiter() { return s_defaultDelimiter; } void ConfigImpl::setDefaultPreserveDeleted(bool shouldPreserve) { s_defaultPreserveDeleted = shouldPreserve; } bool ConfigImpl::getDefaultPreserveDeleted() { return s_defaultPreserveDeleted; } void ConfigImpl::setDefaultIgnoreCase(bool shouldIgnore) { s_defaultIgnoreCase = shouldIgnore; } void ConfigImpl::setDefaultAllowDuplicateKeys(bool shouldAllow) { s_defaultAllowDuplicate = shouldAllow; } // STATIC DATA CONVERSION // bool ConfigImpl::stringToBool(const char *value) { if(value) { // Values that mean true: // yes, on, true, 1 // [yY]*, [oO][nN]*, O*, [Tt]*, 1 // Values that mean false: // no, off, false, 0 switch(value[0]) { case 't': return true; case 'T': return true; case 'y': return true; case 'Y': return true; case '1': return true; case 'o': if(value[1] == 'n' || value[1] == 'N') { // since value[0] was not null, we can rest assured that there is a value[1] - // it is at least the null string terminator! return true; } break; case 'O': if(value[1] == 'n' || value[1] == 'N') { return true; } break; default: return false; } } return false; } const char *ConfigImpl::boolToString(bool value) { return (value ? "true" : "false"); } int ConfigImpl::stringToInt(const char *string) { if(string) { return atoi(string); } return 0; } const char *ConfigImpl::intToString(int value) { char myint[25]; sprintf(myint, "%i", value); s_returnValue = myint; return s_returnValue.c_str(); } double ConfigImpl::stringToDouble(const char *string) { if(string) { return atof(string); } return 0; } const char *ConfigImpl::doubleToString(double value) { char mydouble[25]; sprintf(mydouble, "%g", value); s_returnValue = mydouble; return s_returnValue.c_str(); } char * ConfigImpl::stringToBinary(const char *value, int &outlength) { // Base64Encoder USAGE: // static char * decode(const char *data, int datalength, int &outlength); if(value) { size_t datalength=std::strlen(value); return Base64Encoder::decode(value, datalength, outlength); } outlength=0; return 0; } const char *ConfigImpl::binaryToString(const char *value, int length) { // Base64Encoder USAGE: // static char * encode(const char *data, int datalength, int &outlength); if(value) { int outlength; s_returnValue = Base64Encoder::encode(value, length, outlength); } else { s_returnValue = ""; } return s_returnValue.c_str(); } ////////////////////////////////////// // INSTANCE METHODS ////////////////////////////////////// /////////////////////////// // CONSTRUCTOR & DESTRUCTOR /////////////////////////// ConfigImpl::ConfigImpl() { d_file = new File(); // Create the appropriate Objects here, // all other methods interact with // the base class interfaces // d_writer = new Writer(); d_parser = new ParserJuly2004(); d_error=""; d_errorcode=""; d_commentcharacter = s_defaultCommentChar; d_delimiter = s_defaultDelimiter; d_configfile = s_defaultConfigFile; d_preserveDeleted = s_defaultPreserveDeleted; d_allowDuplicate = s_defaultAllowDuplicate; d_ignoreCase = s_defaultIgnoreCase; } ConfigImpl::~ConfigImpl() { delete d_writer; delete d_parser; delete d_file; } //////////// // STATUS //////////// void ConfigImpl::setError(const char *errorcode, const char *errorstring) { d_errorcode = errorcode ? errorcode : ""; d_error = errorstring ? errorstring : ""; } const char *ConfigImpl::getError() const { return d_error.c_str(); } const char *ConfigImpl::getErrorCode() const { return d_errorcode.c_str(); } ////////////////////// // INSTANCE BEHAVIOR ////////////////////// void ConfigImpl::setConfigFile(const char *filepath) { d_configfile = filepath ? filepath : s_defaultConfigFile.c_str(); } const char * ConfigImpl::getConfigFile() { return d_configfile.c_str(); } void ConfigImpl::setCommentCharacter(char c) { d_commentcharacter = c; } void ConfigImpl::setDelimiter(char c) { d_delimiter = c; } void ConfigImpl::preserveDeletedData(bool shouldPreserve) { d_preserveDeleted = shouldPreserve; } void ConfigImpl::ignoreCase(bool shouldIgnore) { d_ignoreCase = shouldIgnore; } void ConfigImpl::allowDuplicateKeys(bool shouldAllow) { d_allowDuplicate = shouldAllow; } ////////////////////////////// // LOADING & SAVING & CLEARING ////////////////////////////// bool ConfigImpl::load() { // forward to load(filepath) // return load(d_configfile.c_str()); } bool ConfigImpl::load(const char *filepath) { if(filepath && filepath[0]) { d_configfile=filepath; std::ifstream infile(filepath); if(infile) { // forward to load(std::istream&) bool retval = load(infile); infile.close(); return retval; } else { setError("2001", "Error opening config file for reading"); return false; } } else { return load(std::cin); } } bool ConfigImpl::load(std::istream& inputstream) { d_parser->setCommentCharacter(d_commentcharacter); d_parser->setDelimiter(d_delimiter); RealOrganiser organiser(d_file); if(d_parser->parse(inputstream, organiser)) { setSection(""); return true; } else { setSection(""); setError(d_parser->getErrorCode(), d_parser->getError()); return false; } } bool ConfigImpl::save() { // forward to save(filepath) // return save(d_configfile.c_str()); } bool ConfigImpl::save(const char *filepath) { if(filepath && filepath[0] != 0) { ofstream outstream(filepath); if(outstream) { // forward to save(std::ostream&) // bool retval = save(outstream); outstream.close(); return retval; } else { setError("2002", "Error opening config file for writing"); return false; } } else { return save(std::cout); } } bool ConfigImpl::save(std::ostream& outstream) { d_writer->setOutputStream(outstream); d_writer->setCommentChar(d_commentcharacter); d_writer->setDelimiter(d_delimiter); d_writer->preserveDeleted(d_preserveDeleted); d_file->acceptWriter(*d_writer); return true; } void ConfigImpl::clear() { d_file->clear(); } ////////////////// // SECTION METHODS ////////////////// int ConfigImpl::getNumSections() const { return d_file->getNumSections(); } const char *ConfigImpl::getSectionNameAt(int index) const { return d_file->getSectionNameAt(index); } bool ConfigImpl::setSection(const char *sectionname, bool shouldCreate) { return d_file->setSection(sectionname, shouldCreate); } bool ConfigImpl::setSection(const char *sectionname) { return d_file->setSection(sectionname, true); } bool ConfigImpl::deleteSection(const char *sectionname) { return d_file->deleteSection(sectionname); } //////////////// // DATA METHODS //////////////// size_t ConfigImpl::getNumDataMembers() const { return d_file->getNumDataMembers(); } const char *ConfigImpl::getDataNameAt(int index) const { return d_file->getDataNameAt(index); } const char *ConfigImpl::getDataValueAt(int index) const { return d_file->getDataValueAt(index); } bool ConfigImpl::exists(const char *name) const { return d_file->exists(name); } const char * ConfigImpl::getStringValue(const char *name) const { return d_file->getStringValue(name); } void ConfigImpl::setStringValue(const char *name, const char *value) { d_file->setStringValue(name, value); } bool ConfigImpl::deleteData(const char *name) { return d_file->deleteData(name); } /////////////////////////////// // Working with Duplicate Keys // NOT IMPLEMENTED YET /////////////////////////////// size_t ConfigImpl::getNumDataMembers(const char *key) const { if(exists(key)) { return 1; } else { return 0; } } const char * ConfigImpl::getStringValue(const char *name, int /*index*/) const { return d_file->getStringValue(name); } void ConfigImpl::addStringValue(const char *name, const char *value) { d_file->setStringValue(name, value); } bool ConfigImpl::deleteData(const char *name, int /*index*/) { return d_file->deleteData(name); } }}// end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/ConfigImpl.h000066400000000000000000000115251216313063400214310ustar00rootroot00000000000000// ConfigImpl.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_RUDE_CONFIGIMPL_H #define INCLUDED_RUDE_CONFIGIMPL_H #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif namespace rude{ namespace config{ class Section; class File; class AbstractWriter; class AbstractParser; class AbstractOrganiser; class ConfigImpl{ static std::string s_defaultConfigFile; static char s_defaultCommentChar; static char s_defaultDelimiter; static bool s_defaultPreserveDeleted; static bool s_defaultAllowDuplicate; static bool s_defaultIgnoreCase; static std::string s_returnValue; AbstractWriter *d_writer; AbstractOrganiser *d_organiser; AbstractParser *d_parser; File *d_file; std::string d_error; std::string d_errorcode; std::string d_configfile; char d_commentcharacter; char d_delimiter; bool d_preserveDeleted; bool d_allowDuplicate; bool d_ignoreCase; protected: void setError(const char *errorcode, const char *errorstring); public: ////////////////////////////////////// // STATIC METHODS ////////////////////////////////////// static const char *version(); // DEFAULT BEHAVIOR // static void setDefaultConfigFile(const char *filepath); static const char *getDefaultConfigFile(); static void setDefaultCommentCharacter(char c); static char getDefaultCommentCharacter(); static void setDefaultDelimiter(char c); static char getDefaultDelimiter(); static void setDefaultPreserveDeleted(bool shouldPreserve); static bool getDefaultPreserveDeleted(); // The internals are on the drawing board!! // static void setDefaultIgnoreCase(bool shouldIgnore); static void setDefaultAllowDuplicateKeys(bool shouldAllow); // DATA CONVERSION // static bool stringToBool(const char *string); static const char *boolToString(bool value); static int stringToInt(const char *string); static const char *intToString(int value); static double stringToDouble(const char *string); static const char *doubleToString(double value); static char * stringToBinary(const char *value, int &outlength); static const char *binaryToString(const char *value, int length); ////////////////////////////////////// // INSTANCE METHODS ////////////////////////////////////// // CONSTRUCTOR & DESTRUCTOR // ConfigImpl(); ~ConfigImpl(); // STATUS // const char *getError() const; const char *getErrorCode() const; // INSTANCE BEHAVIOR // void setConfigFile(const char *filepath); const char *getConfigFile(); void setCommentCharacter(char c); void setDelimiter(char c); void preserveDeletedData(bool shouldPreserve); void ignoreCase(bool shouldIgnore); void allowDuplicateKeys(bool shouldAllow); // LOADING & SAVING & CLEARING // bool load(); bool load(const char *filepath); bool load(std::istream&); bool save(); bool save(const char *filepath); bool save(std::ostream&); void clear(); // SECTION METHODS // int getNumSections() const; const char *getSectionNameAt(int index) const; bool setSection(const char *sectionname, bool shouldCreate); bool setSection(const char *sectionname); bool deleteSection(const char *sectionname); // DATA METHODS // size_t getNumDataMembers() const; const char *getDataNameAt(int index) const; const char *getDataValueAt(int index) const; bool exists(const char *name) const; const char * getStringValue(const char *name) const; void setStringValue(const char *name, const char *value); bool deleteData(const char *name); // Working with Duplicate Keys // size_t getNumDataMembers(const char *key) const; const char * getStringValue(const char *name, int index) const; void addStringValue(const char *name, const char *value); bool deleteData(const char *name, int index); }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/DataLine.cpp000066400000000000000000000024221216313063400214120ustar00rootroot00000000000000// DataLine.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "DataLine.h" namespace rude{ namespace config{ DataLine::DataLine() { d_isDeleted = false; } bool DataLine::isDeleted() const { return d_isDeleted; } void DataLine::isDeleted(bool isit) { d_isDeleted = isit; } DataLine::~DataLine() { } }} // end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/DataLine.h000066400000000000000000000030561216313063400210630ustar00rootroot00000000000000// DataLine.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_DataLine_H #define INCLUDED_DataLine_H #ifndef INCLUDED_AbstractData_H #include "AbstractData.h" #endif namespace rude{ namespace config{ class DataLine: public AbstractData{ bool d_isDeleted; protected: DataLine(); public: void acceptWriter(AbstractWriter& writer) const = 0; //= // Returns true if the data member has been deleted //= bool isDeleted() const; //= // Sets / unsets the deleted status of the data member //= void isDeleted(bool isit); virtual ~DataLine(); }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/File.cpp000066400000000000000000000134131216313063400206120ustar00rootroot00000000000000// File.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "File.h" #ifndef INCLUDED_Section_H #include "Section.h" #endif #ifndef INCLUDED_AbstractWriter_H #include "AbstractWriter.h" #endif using namespace std; namespace rude{ namespace config{ File::File() { d_currentSection = new Section("", 0); d_sections.push_back(d_currentSection); std::string empty = ""; d_sectionmap[empty] = d_currentSection; } File::~File() { std::vector::iterator iter; for(iter = d_sections.begin(); iter != d_sections.end(); iter++) { delete (*iter); } } void File::acceptWriter(AbstractWriter& writer) const { writer.visitFile(*this); // All the data members are responsible for printing themselves out. // They are also responsible for knowing what to do when they are // marked as deleted and when commentchar / delimiter are 0 // std::vector::iterator iter; for(iter = d_sections.begin(); iter != d_sections.end(); iter++) { (*iter)->acceptWriter(writer); } } void File::clear() { std::vector::iterator iter; for(iter = d_sections.begin(); iter != d_sections.end(); iter++) { delete (*iter); } d_sections.clear(); d_sectionmap.clear(); // We create one to begin with, swo that we always // have a valid d_currentSection to work with. d_currentSection = new Section("", 0); d_sections.push_back(d_currentSection); std::string empty = ""; d_sectionmap[empty] = d_currentSection; } const char * File::getStringValue(const char *name) const { if(d_currentSection) { return d_currentSection->getValue(name); } return 0; } bool File::deleteData(const char *name) { if(d_currentSection) { return d_currentSection->deleteData(name); } return false; } void File::setStringValue(const char *name, const char *value) { if(d_currentSection) { d_currentSection->setValue(name, value); } } size_t File::getNumDataMembers() const { if(d_currentSection) { return d_currentSection->getNumDataMembers(); } return 0; } const char *File::getDataNameAt(int index) const { if(d_currentSection) { return d_currentSection->getDataNameAt(index); } return 0; } const char *File::getDataValueAt(int index) const { if(d_currentSection) { return d_currentSection->getDataValueAt(index); } return 0; } bool File::exists(const char *name) const { if(d_currentSection) { return d_currentSection->exists(name); } return 0; } int File::getNumSections() const { size_t len = d_sections.size(); int count = 0; for(size_t x=0; x< len; x++) { Section *theSection = d_sections[x]; if(!theSection->isDeleted()) { count++; } } return count; } const char *File::getSectionNameAt(int index) const { size_t len = d_sections.size(); int position = 0; for(size_t x=0; x< len; x++) { Section *theSection = d_sections[x]; if(!theSection->isDeleted()) { if(position == index) { return theSection->getSectionName(); } position++; } } return 0; } bool File::setSection(const char *sectionname, bool shouldCreate) { if(sectionname) { std::string name=sectionname; Section *thesection = d_sectionmap[name]; if(thesection) { if(!thesection->isDeleted()) { d_currentSection = thesection; return true; } else { if(shouldCreate) { // revive the deleted section // thesection->isDeleted(false); d_currentSection = thesection; return true; } return false; } } else { // The section could not be found..... // if(shouldCreate) { d_currentSection = new Section(sectionname, 0); std::string stringname = sectionname; d_sections.push_back(d_currentSection); d_sectionmap[stringname] = d_currentSection; return true; } } } return false; } Section *File::getSection(const char *sectionname) { setSection(sectionname, true); return d_currentSection; } bool File::deleteSection(const char *sectionname) { if(sectionname) { std::string name=sectionname; Section *thesection = d_sectionmap[name]; if(thesection) { thesection->isDeleted(true); // Here is the interesting part, // By deleting the current section, we have effectively // deleted all of its data members... // but if we are deleting the current section, // then we need to change the current section to // the default one - the "" section, // and make sure that that section is undeleted.... // because we always need a current section. if(thesection == d_currentSection) { return setSection("", true); } return true; } // The section could not be found..... } return false; } }} // end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/File.h000066400000000000000000000044021216313063400202550ustar00rootroot00000000000000// File.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_File_H #define INCLUDED_File_H #ifndef INCLUDED_AbstractData_H #include "AbstractData.h" #endif #ifndef INCLUDED_VECTOR #include #define INCLUDED_VECTOR #endif #ifndef INCLUDED_MAP #include #define INCLUDED_MAP #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif using namespace rude::config; namespace rude{ namespace config{ class Section; class File: public AbstractData{ private: Section *d_currentSection; mutable std::vector d_sections; mutable std::map d_sectionmap; public: File(); ~File(); void acceptWriter(AbstractWriter& writer) const; void clear(); const char * getStringValue(const char *name) const; bool deleteData(const char *name); void setStringValue(const char *name, const char *value); size_t getNumDataMembers() const; const char *getDataNameAt(int index) const; const char *getDataValueAt(int index) const; bool exists(const char *name) const; int getNumSections() const; const char *getSectionNameAt(int index) const; bool setSection(const char *sectionname, bool shouldCreate); bool deleteSection(const char *sectionname); Section *getSection(const char *sectionname); }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/KeyValue.cpp000066400000000000000000000041241216313063400214570ustar00rootroot00000000000000// KeyValue.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "KeyValue.h" #ifndef INCLUDED_AbstractWriter_H #include "AbstractWriter.h" #endif #ifndef INCLUDED_CSTDIO #include #define INCLUDED_CSTDIO #endif using namespace std; namespace rude{ namespace config{ KeyValue::KeyValue() { d_name = ""; d_value = ""; d_comment = ""; } KeyValue::KeyValue(const char *name, const char *value, const char *comment) { d_name = name ? name : ""; d_value = value ? value : ""; d_comment = comment ? comment : ""; } void KeyValue::acceptWriter(AbstractWriter& writer) const { writer.visitKeyValue(*this); } const char *KeyValue::getName() const { return d_name.c_str(); } const char *KeyValue::getValue() const { return d_value.c_str(); } const char *KeyValue::getComment() const { return d_comment.c_str(); } void KeyValue::setName(const char *name) { d_name = name ? name : ""; } void KeyValue::setValue(const char *value) { d_value = value ? value : ""; } void KeyValue::setComment(const char *comment) { d_comment = comment ? comment : ""; } KeyValue::~KeyValue() { } }} // end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/KeyValue.h000066400000000000000000000072471216313063400211350ustar00rootroot00000000000000// KeyValue.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_KeyValue_H #define INCLUDED_KeyValue_H #ifndef INCLUDED_DataLine_H #include "DataLine.h" #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif namespace rude{ namespace config{ //= // KeyValue represents a single line/entry in a configuration file. // It can represent whitespace, a comment, or key=value data. // // Current Limitations //
    //
  • Data Names: it is assumed that the names for entries are valid. Invalid names are not detected. // A name containing the delimiter or comment character is invalid. // A name containing newline information is invalid. // Future releases should either detect and reject invalid names, or use an escape mechanism such as backslashing // to allow invalid characters to appear within a name. // //
  • Data Values: Same as data names. (see above) //
//= class KeyValue: public DataLine{ std::string d_name; std::string d_value; std::string d_comment; public: // default constructor KeyValue(); KeyValue(const char *name, const char *value, const char *comment); void acceptWriter(AbstractWriter& writer) const; //= // Returns the name of the data member // Will return the name even if the data member is flagged as being deleted or a comment // Always returns at least the empty string, will never return null. //= const char *getName() const; //= // Returns the string value of the data member // Will return the value even if the data member is flagged as being deleted or a comment // Always returns at least the empty string, will never return null. //= const char *getValue() const; //= // Returns the comment associated with the data member // Will return the comment even if the data member is flagged as being deleted // Always returns at least the empty string, will never return null. //= const char *getComment() const; //= // Sets the name of the data member // Will set the name even if the data member is flagged as being deleted or a comment // Accepts null //= void setName(const char *name); //= // Sets the string value of the data member // Will set the value even if the data member is flagged as being deleted or a comment // Accepts null //= void setValue(const char *value); // un-deletes if previously deleted..... //= // Sets the comment associated with the data member // Will set the comment even if the data member is flagged as being deleted // Accepts null //= void setComment(const char *comment); ~KeyValue(); }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/NEWS000066400000000000000000000111061216313063400177230ustar00rootroot00000000000000RudeConfig NEWS - User visible changes. See ChangeLog for more detailed information on internal changes See the end for copying conditions. _______________________________________________________________________________ Release 5.0.5-1 - Matthew Flood 2007-02-01 - Renamed header include guards in config.h from INCLUDED_CONFIG_H to INCLUDED_RUDE_CONFIG_H The new guards are less generic and safer to use overall. _______________________________________________________________________________ Release 5.0.4-3 - Matthew Flood 2007-02-01 - Minor amendments to build-related scripts _______________________________________________________________________________ Release 5.0.4-2 - Matthew Flood 2007-02-01 - Minor amendments to build-related scripts _______________________________________________________________________________ Release 5.0.4-1 - Matthew Flood 2007-01-19 - Created rudeconfig.3 MAN page * To access the rudeconfig manual from your linux command prompt, use the man command: $>man rudeconfig OR $>man 3 rudeconfig _______________________________________________________________________________ Release 5.0.3-1 - Matthew Flood 2006-07-31 - Changed versioning system again. - Minor changes to facilitate Windows builds * changed #include's of to * added .c_str() to a string object to correct shorthand if statement ( a ? x : y ) _______________________________________________________________________________ Release 5.0.2-1 - Matthew Flood 2006-04-08 ** Changed package versioning: now using the LIBRARY_VERSION - RELEASE_VERSION RELEASE_VERSION will be set to 1 for each new LIBRARY_VERSION ** Rolled the package into binary and source RPMs _______________________________________________________________________________ Version 3.2 - Matthew Flood 2005-06-02 ** The following instance method has been added, allowing you to discover the current filepath of the config object. The name 'getConfigFile' was chosen to pair up with the already existing method - setConfigFile(const char *filepath) const char *getConfigFile(); _______________________________________________________________________________ Version 3.1 - Matthew Flood 2005-05-18 ** The following static methods have been added, allowing you to alter the default behavior of config objects before they are created. static void Config::setDefaultConfigFile(const char *filepath); static const char *Config::getDefaultConfigFile(); static void Config::setDefaultCommentCharacter(char c); static char Config::getDefaultCommentCharacter(); static void Config::setDefaultDelimiter(char c); static char Config::getDefaultDelimiter(); static void Config::setDefaultPreserveDeleted(bool shouldPreserve); static bool Config::getDefaultPreserveDeleted(); ** When the method [ void load(const char *filename) ] is invoked, the filename passed in as a parameter is now remembered - it becomes the default filename for the instance. This means that [ bool save(void) ] will always save to the file that was load()'ed. Previously, the only way to alter the default filename for an object was to call [ void setConfigFile( const char* filepath ) ]. ** setStringValue() and getStringValue() are now deprecated. Use getValue() and setValue() instead. _______________________________________________________________________________ Version 3.0 - Matthew Flood 2005-05-05 ** RudeConfig became open source and is distributed under the GNU Public License. Commercial licenses are available for a fee, and allow the holder to use the library in commercial applications. To obtain further details, see the AUTHORS file for contact information. _______________________________________________________________________________ Copyright (C) 2005 Matthew Flood See file AUTHORS for contact information This file is part of RudeConfig. RudeConfig is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. RudeConfig is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with RudeConfig; (see COPYING) if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. actionaz-3.7.0/3rdparty/rudeconfig/ParserJuly2004.cpp000066400000000000000000000337421216313063400223500ustar00rootroot00000000000000// ParserJuly2004.cc // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ /* Edited on 19/08/2010 by Jonathan Mercier-Ganady for Actionaz */ #include "ParserJuly2004.h" #ifndef INCLUDED_AbstractOrganiser_h #include "AbstractOrganiser.h" #endif #ifndef INCLUDED_CCTYPE #include #define INCLUDED_CCTYPE #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_CSTDLIB #include #define INCLUDED_CSTDLIB #endif #ifndef INCLUDED_CSTDIO #include #define INCLUDED_CSTDIO #endif #ifndef INCLUDED_LOCALE #include #define INCLUDED_LOCALE #endif using namespace rude::config; using namespace std; namespace rude{ namespace config{ enum SectionState{ STARTSECTION, SECTIONID, ESCAPEID, ENDSECTIONID, SECTIONCOMMENT, FOUNDIDONLY, FOUNDIDCOMMENT, SECTIONERROR, ENDSECTION }; enum KeyValueState{ KEY, KEYESCAPE, STARTVALUE, COMMENT, FINDCOMMENT, KVERROR, ENDKV, VALUE, QUOTEVALUE, NONQUOTEVALUE, QUOTEESCAPE, NONQUOTEESCAPE, ENDKEYVALUE}; void ParserJuly2004::stripTrailing(std::string& buffer) { int bufferLength = static_cast(buffer.size()); locale loc; for (int x = bufferLength - 1; x >= 0; x--) { char c = buffer[x]; if (isspace(c, loc)) { buffer.erase(x); } else { break; } } } bool ParserJuly2004::isEOL(char c) { return (c == '\r' || c == '\f' || c == '\n'); } bool ParserJuly2004::chompEOL(std::istream& inputstream) { char c = inputstream.peek(); if(isEOL(c)) { inputstream.get(); char next_c = inputstream.peek(); if( (c != next_c) && isEOL(next_c) ) { inputstream.get(); } } return true; } bool ParserJuly2004::parse(std::istream& infile, AbstractOrganiser& organiser) { locale loc; if (d_delimiter == '\\' || isEOL(d_delimiter) || d_delimiter == d_commentchar || d_delimiter == '[') { setError("110", "Illegal delimiter."); return false; } if (d_commentchar == '\\' || d_commentchar == '"' || isspace(d_commentchar, loc)) { setError("111", "Illegal comment character."); return false; } register char c; // eof only gets set when error_flag is set on previous operation // as such, you need to peek() at the end ot the while loop // in order for eof to happen when you want it to!! // one peek() triggers infile.eof(), but it does not reveal it!!!! // you gotta call peek() twice. // while( (c = infile.peek()) != EOF) { // We're looking for: // '[' beggining of section // '#' (d_commentchar) comment character // any non-whitespace character if(isspace(c, loc)) { std::string whitespace = ""; while(c != EOF && isspace(c, loc)) { whitespace += infile.get(); c = infile.peek(); } organiser.foundWhiteSpace(whitespace.c_str()); } else if(c == '[') { // discard '[' character // infile.get(); register SectionState sectionState = STARTSECTION; std::string sectionID = ""; std::string comment = ""; while (sectionState != ENDSECTION) { switch (sectionState) { case STARTSECTION: { c = infile.peek(); if(c == EOF) { setError("102", "End of stream found before section ID"); sectionState = SECTIONERROR; } else if(isEOL(c)) { setError("101", "End of line found before section ID"); sectionState = SECTIONERROR; } else if(c == ' ' || c == '\t') { // discard whitespace // infile.get(); // LOOP } else if(c == ']') { // discard ']' // infile.get(); sectionState = ENDSECTIONID; } else { sectionState = SECTIONID; } break; } case SECTIONID: { c = infile.peek(); if(c == EOF) { setError("104", "End of stream found before end-of-section marker"); sectionState = SECTIONERROR; } else if(isEOL(c)) { setError("103", "End of line found before end-of-section marker"); sectionState = SECTIONERROR; } else if(c == '\\') { // discard backslash // infile.get(); sectionState = ESCAPEID; } else if(c == ']') { // discard ']' // infile.get(); // Strip Trailing Whitespace from ID // stripTrailing(sectionID); sectionState = ENDSECTIONID; } else { sectionID += infile.get(); // LOOP } break; } case ESCAPEID: { c = infile.peek(); if(c == EOF) { setError("107", "End of stream found after un-escaped backslash"); sectionState = SECTIONERROR; } else if(isEOL(c)) { setError("108", "Escaped new-line is not allowed in section ID or key"); sectionState = SECTIONERROR; } else { sectionID += infile.get(); sectionState = SECTIONID; } break; } case ENDSECTIONID: { c = infile.peek(); if(c == EOF || isEOL(c)) { sectionState = FOUNDIDONLY; } else if(d_commentchar != 0 && c == d_commentchar) { // discard '#' // infile.get(); sectionState = SECTIONCOMMENT; } else if(c == ' ' || c == '\t') { // discard whitespace // infile.get(); // LOOP } else { setError("105", "Illegal character found after end-of-section marker"); sectionState = SECTIONERROR; } break; } case SECTIONCOMMENT: { c = infile.peek(); if(c == EOF || isEOL(c)) { sectionState = FOUNDIDCOMMENT; stripTrailing(comment); } else { // append to comment // comment += infile.get(); // LOOP } break; } case SECTIONERROR: { return false; } case FOUNDIDONLY: { organiser.foundSection(sectionID.c_str(), 0); chompEOL(infile); sectionState = ENDSECTION; break; } case FOUNDIDCOMMENT: { organiser.foundSection(sectionID.c_str(), comment.c_str()); chompEOL(infile); sectionState = ENDSECTION; break; } default: break; } } } else if(c == d_commentchar) { // found a comment line // discard the comment character // infile.get(); // put the rest of the line into a string // std::string line=""; while(infile.good()) { c=infile.get(); if( isEOL(c)) { break; } line += c; } chompEOL(infile); // PROCESS THE COMMENT LINE // stripTrailing(line); organiser.foundComment(line.c_str()); } else { register KeyValueState kvState = KEY; std::string key = ""; std::string value = ""; std::string comment = ""; while (kvState != ENDKEYVALUE) { switch (kvState) { case KEY: { char c = infile.peek(); if(c == EOF || isEOL(c)) { kvState = ENDKV; } else if(d_delimiter && c == d_delimiter) { // discard '=' // infile.get(); kvState = STARTVALUE; } else if(!d_delimiter && (c == ' ' || c == '\t')) { // discard whitespace // infile.get(); kvState = STARTVALUE; } else if(d_commentchar != 0 && c == d_commentchar) { // discard '#' // infile.get(); kvState = COMMENT; } else if(c == '\\') { // discard '\\' // infile.get(); kvState = KEYESCAPE; } else { // append to key // key += infile.get(); // LOOP } break; } case KEYESCAPE: { char c = infile.peek(); if(c == EOF) { setError("107", "End of stream found after un-escaped backslash"); kvState = KVERROR; } else if(isEOL(c)) { setError("108", "Escaped new-line is not allowed in key"); kvState = KVERROR; } else { // append to key // key += infile.get(); kvState = KEY; } break; } case STARTVALUE: { char c = infile.peek(); if(c == EOF || isEOL(c)) { kvState = ENDKV; } else if(d_commentchar != 0 && c == d_commentchar) { // discard '#' // infile.get(); kvState = COMMENT; } else if(c == ' ' || c == '\t') { // discard whitespace // infile.get(); // LOOP } else { kvState = VALUE; } break; } case KVERROR: { return false; } case FINDCOMMENT: { char c = infile.peek(); if(c == EOF || isEOL(c)) { kvState = ENDKV; } else if(d_commentchar != 0 && c == d_commentchar) { // discard '#' // infile.get(); kvState = COMMENT; } else if(c == ' ' || c == '\t') { // discard whitespace // infile.get(); // LOOP } else { setError("109", "Illegal Character Found after quoted value."); kvState = KVERROR; } break; } case COMMENT: { char c = infile.peek(); if(c == EOF || isEOL(c)) { stripTrailing(comment); kvState = ENDKV; } else { // Append to comment // comment += infile.get(); // LOOP } break; } case VALUE: { char c = infile.peek(); if(c == '"') { // discard '"' // infile.get(); kvState = QUOTEVALUE; } else { kvState = NONQUOTEVALUE; } break; } case QUOTEVALUE: { char c = infile.peek(); if(c == EOF) { setError("106", "End of stream found before final quote (\") in value"); kvState = KVERROR; } else if(c == '"') { // discard '"' // infile.get(); kvState = FINDCOMMENT; } else if(c == '\\') { // discard backslash // infile.get(); kvState = QUOTEESCAPE; } else { // append to value // value += infile.get(); // LOOP } break; } case QUOTEESCAPE: { char c = infile.peek(); if(c == EOF) { setError("107", "End of stream found after un-escaped backslash"); kvState = KVERROR; } else { // append to value // value += infile.get(); kvState = QUOTEVALUE; } break; } case NONQUOTEVALUE: { char c = infile.peek(); if(c == EOF || isEOL(c)) { stripTrailing(value); kvState = ENDKV; } else if(d_commentchar != 0 && c == d_commentchar) { // discard '#' // infile.get(); stripTrailing(value); kvState = COMMENT; } else if(c == '\\') { // discard backslash // infile.get(); kvState = NONQUOTEESCAPE; } else { // append to value // value += infile.get(); // LOOP } break; } case NONQUOTEESCAPE: { char c = infile.peek(); if(c == EOF) { setError("107", "End of stream found after un-escaped backslash"); kvState = KVERROR; } else { // append to value // c = infile.get(); value += c; // SPECIAL CASE FOR ESCAPED CRLFs: // // if c is newline and next character is also newline, // we keep both of them if they are different forms of newline // char next_c = infile.peek(); if(isEOL(c) && isEOL(next_c) && (c != next_c)) { value += infile.get(); } kvState = NONQUOTEVALUE; } break; } case ENDKV: { chompEOL(infile); stripTrailing(key); organiser.foundData(key.c_str(), value.c_str(), comment.c_str()); kvState = ENDKEYVALUE; break; } default: break; } // end switch } // end while } } return true; } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/ParserJuly2004.h000066400000000000000000000031421216313063400220040ustar00rootroot00000000000000// ParserJuly2004.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INPUT_ParserJuly2004_h #define INPUT_ParserJuly2004_h #ifndef INPUT_AbstractParser_h #include "AbstractParser.h" #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif namespace rude{ namespace config{ class ParserJuly2004: public AbstractParser { protected: void stripTrailing(std::string&); inline bool isEOL(char c); inline bool chompEOL(std::istream& inputstream); public: bool parse(std::istream& inputstream, AbstractOrganiser& organiser); }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/README000066400000000000000000000042161216313063400201100ustar00rootroot00000000000000README for RudeConfig See the end of file for copying conditions This file contains the following sections, please glance through them all before installing RudeConfig. * Introduction * Bug Reporting * Copying *** INTRODUCTION *** RudeConfig is a library that allows applications to (painlessly) read, modify, and create config / .ini files. Documentation, discussions, and new releases are available at http://www.rudeserver.com/ See file `COPYING' for copying conditions. See file `INSTALL' for compilation and installation instructions. See file `NEWS' for a list of major changes in the current release. See file `THANKS' for a list of contributors. See file 'AUTHORS' for contact information *** BUG REPORTING *** Please Send bug reports to . A bug report should contain an adequate description of the problem, your input, what you expected, what you got, and why this is wrong. Where applicable, please submit actual data files with your report. Your feedback will help us to make a better and more portable package. Consider documentation errors as bugs, and report them as such. If you develop anything pertaining to RudeConfig or have suggestions, let us know and share your findings by writing to or by visiting the discussion forum accessable from the RudeServer website at http://www.rudeserver.com/ *** COPYING *** Copyright (C) 2005 Matthew Flood See file AUTHORS for contact information This file is part of RudeConfig. RudeConfig is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. RudeConfig is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with RudeConfig; (see COPYING) if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. actionaz-3.7.0/3rdparty/rudeconfig/RealOrganiser.cpp000066400000000000000000000034711216313063400224730ustar00rootroot00000000000000// RealOrganiser.cc // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "RealOrganiser.h" #ifndef INCLUDED_File_H #include "File.h" #endif #ifndef INCLUDED_Section_H #include "Section.h" #endif using namespace std; namespace rude{ namespace config{ RealOrganiser::RealOrganiser(File *file) { d_file = file; d_section = d_file->getSection(""); } void RealOrganiser::foundSection(const char *sectionName, const char *comment) { d_section = d_file->getSection(sectionName); d_section->setSectionComment(comment); } void RealOrganiser::foundComment(const char *comment) { d_section->addComment(comment); } void RealOrganiser::foundWhiteSpace(const char *whitespace) { d_section->addWhiteSpace(whitespace); } void RealOrganiser::foundData(const char *key, const char *value, const char *comment) { d_section->setValue(key, value, comment); } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/RealOrganiser.h000066400000000000000000000031261216313063400221350ustar00rootroot00000000000000// RealOrganiser.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INPUT_RealOrganiser_h #define INPUT_RealOrganiser_h #include "AbstractOrganiser.h" #include namespace rude{ namespace config{ class File; class Section; class RealOrganiser: public AbstractOrganiser { File *d_file; Section *d_section; public: RealOrganiser(File*); virtual void foundSection(const char *sectionName, const char *comment); virtual void foundComment(const char *comment); virtual void foundWhiteSpace(const char *whitespace); virtual void foundData(const char *key, const char *value, const char *comment); }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/Section.cpp000066400000000000000000000141661216313063400213450ustar00rootroot00000000000000// Section.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "Section.h" #ifndef INCLUDED_RUDE_DataLine_H #include "DataLine.h" #endif #ifndef INCLUDED_KeyValue_H #include "KeyValue.h" #endif #ifndef INCLUDED_WhiteSpace_H #include "WhiteSpace.h" #endif #ifndef INCLUDED_Comment_H #include "Comment.h" #endif #ifndef INCLUDED_AbstractWriter_H #include "AbstractWriter.h" #endif using namespace rude::config; namespace rude{ namespace config{ Section::Section(const char *sectionname, const char *sectioncomment) { d_isDeleted = false; d_sectionname = sectionname ? sectionname: ""; d_sectioncomment = sectioncomment ? sectioncomment: ""; } Section::~Section() { std::vector::iterator iter; for(iter = d_allDataVector.begin(); iter != d_allDataVector.end(); iter++) { delete (*iter); } } void Section::acceptWriter(AbstractWriter& writer) const { writer.visitSection(*this); // Send the writer to all the children. // The writer will know what to do. // std::vector::iterator iter; for(iter = d_allDataVector.begin(); iter != d_allDataVector.end(); iter++) { (*iter)->acceptWriter(writer); } } const char *Section::getSectionName() const { return d_sectionname.c_str(); } const char *Section::getSectionComment() const { return d_sectioncomment.c_str(); } void Section::setSectionComment(const char * newcomment) { d_sectioncomment = newcomment ? newcomment : ""; } bool Section::isDeleted() const { return d_isDeleted; } void Section::isDeleted(bool is_it_or_not) { d_isDeleted = is_it_or_not; if(d_isDeleted) { // Delete all data members // std::vector::iterator iter; for(iter = d_allDataVector.begin(); iter != d_allDataVector.end(); iter++) { (*iter)->isDeleted(true); } d_kv_vector.clear(); d_kv_map.clear(); } } size_t Section::getNumDataMembers() const { return d_kv_vector.size(); } const char *Section::getDataNameAt(int index) const { KeyValue *kv = d_kv_vector[index]; if(kv) { return kv->getName(); } return ""; } const char *Section::getDataValueAt(int index) const { KeyValue *kv = d_kv_vector[index]; if(kv) { return kv->getValue(); } return ""; } // MAPPED // bool Section::exists(const char *name) const { if(name) { std::string myname = name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { return true; } } return false; } // MAPPED // const char * Section::getValue(const char *name) const { if(name) { std::string myname=name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { return mydata->getValue(); } } return ""; } // MAPPED // void Section::setValue(const char *name, const char *value) { if(name) { std::string myname=name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { mydata->setValue(value); mydata->isDeleted(false); } else { KeyValue *newdata = new KeyValue(); newdata->setName(name); newdata->setValue(value); d_allDataVector.push_back(newdata); d_kv_vector.push_back(newdata); d_kv_map[myname] = newdata; } } } // MAPPED // const char * Section::getComment(const char *name) const { if(name) { std::string myname=name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { return mydata->getComment(); } } return ""; } // MAPPED // void Section::setComment(const char *name, const char *comment) { if(name) { std::string myname=name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { mydata->setComment(comment); } } } // MAPPED // void Section::setValue(const char *name, const char *value, const char *comment) { if(name) { std::string myname=name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { mydata->setValue(value); mydata->setComment(comment); mydata->isDeleted(false); } else { KeyValue *newdata = new KeyValue(name, value, comment); d_allDataVector.push_back(newdata); d_kv_vector.push_back(newdata); d_kv_map[myname] = newdata; } } } // MAPPED // void Section::addComment(const char *comment) { Comment *newdata = new Comment(comment); d_allDataVector.push_back(newdata); } // MAPPED // void Section::addWhiteSpace(const char *whitespace) { WhiteSpace *newdata = new WhiteSpace(whitespace); d_allDataVector.push_back(newdata); } // MAPPED // bool Section::deleteData(const char *name) { // Since we are keeping deleted data in the d_allDataVector, // multiple set/deletes will require lots of memory!! // if(name) { std::string myname=name; KeyValue *mydata = d_kv_map[myname]; if(mydata) { // Remain in d_allDataVector, but as deleted // mydata->isDeleted(true); // remove from keyvalue vector and map // std::vector::iterator iter; for(iter = d_kv_vector.begin(); iter != d_kv_vector.end(); iter ++) { if( *iter == mydata ) { d_kv_vector.erase(iter); break; } } d_kv_map.erase(myname); return true; } } return false; } }} // end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/Section.h000066400000000000000000000150451216313063400210070ustar00rootroot00000000000000// Section.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_Section_H #define INCLUDED_Section_H #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif #ifndef INCLUDED_VECTOR #include #define INCLUDED_VECTOR #endif #ifndef INCLUDED_MAP #include #define INCLUDED_MAP #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif namespace rude{ namespace config{ class DataLine; class KeyValue; class AbstractWriter; //= // Section represents a single section within a configuration file. // It is identified by its section name, which can include whitespace, // and manages the set of all data and/or comments associated with that section. // // Each piece of data is identified by its name. Currently, only one piece of data // is recognized for any given name. In the case where two or more values exist for the // same name (within a section), only the last value is recognized - any previous values are discarded. //= class Section{ bool d_isDeleted; std::string d_sectionname; std::string d_sectioncomment; mutable std::vector d_allDataVector; mutable std::vector d_kv_vector; mutable std::map d_kv_map; public: Section(const char *sectionname, const char *sectioncomment=0); void acceptWriter(AbstractWriter& writer) const; //= // Writes the section and all associated data to the outputstream // // If the section is marked as deleted: // The entire section is commented out. This means that it is still printed out, // but each line is begun with the comment character. If the comment character is // set to null, then the section is not printed out at all - it is essentially discarded. // // In normal circumstances, the '=' is the most appropriate delimiter to use. // If delimiter is null, then whie //= void write(std::ostream& outputstream, char commentchar, char delimiter, bool preserveDeleted); //= // Returns this section's name, identified by [somename] in the config/ini file //= const char *getSectionName() const; //= // Returns the section-comment (found after the section name) // // An example of a section-comment is: // // [Dogs] # this section is about dogs // //= const char *getSectionComment() const; //= // Sets the section comment (found after the section name) //= void setSectionComment(const char *newcomment); //= // Returns whether or not this section is flagged as deleted... //= bool isDeleted() const; //= // (Un)marks this section as deleted // When marked as deleted, all data members are marked as deleted // When undeleted, data members remain marked as deleted.... //= void isDeleted(bool is_it_or_not); //= // Returns the number of (non-deleted) data members // Deleted data, comments and blank lines are not included in the count. //= size_t getNumDataMembers() const; //= // Returns the name of the (undeleted) data member at the specified index // Returns NULL if the index is out of range //= const char *getDataNameAt(int index) const; //= // Returns the name of the (undeleted) data member at the specified index // Returns NULL if the index is out of range //= const char *getDataValueAt(int index) const; //= // Returns true if data name exists (and is not marked as deleted), false otherwise //= bool exists(const char *name) const; //= // Returns the value associated with the data identified by name // Returns NULL if data name does not exist (or is marked as deleted) //= const char *getValue(const char *name) const; //= // Returns the comment associated with the data identified by name // Returns NULL if data name does not exist (or is marked as deleted) //= const char *getComment(const char *name) const; //= // Sets the value for the data member identified by name // If a data member already exists with the given name, then the value is replaced. // Otherwise a new data item is created.. // If the data item already exists, but has been marked as deleted, // it will be revived (unmarked) and its value updated. // Existing comments associated with the data member are not altered. //= void setValue(const char *name, const char *value); //= // Replaces the comment for the data member identified by name // Sets the comment whether or not the data is marked as deleted. // If the data identified by name does not exist, then nothing happens //= void setComment(const char *name, const char *comment); //= // Sets the value and the comment for the data member identified by name // If a data member already exists with the given name, then the value is replaced. // Otherwise a new data item is created.. // If the data item already exists, but has been marked as deleted, // it will be revived (unmarked) and updated. //= void setValue(const char *name, const char *value, const char *comment); //= // Adds a comment line to the end of the section //= void addComment(const char *comment); //= // Adds whitespace line to the end of the section //= void addWhiteSpace(const char *whitespace); //= // Marks the data identified by name as deleted // Returns false if data does not exist within this // section (or has already been marked as deleted) //= bool deleteData(const char *name); ~Section(); }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/THANKS000066400000000000000000000002661216313063400201440ustar00rootroot00000000000000RudeConfig THANKS file Special thanks goes out to the following individuals who helped to make RudeConfig a better Library. Michael Schwendt Ralf Corsepius Karen Dolan Ole Hansen actionaz-3.7.0/3rdparty/rudeconfig/WhiteSpace.cpp000066400000000000000000000030211216313063400217610ustar00rootroot00000000000000// WhiteSpace.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "WhiteSpace.h" #ifndef INCLUDED_AbstractWriter_H #include "AbstractWriter.h" #endif #ifndef INCLUDED_CSTDIO #include #define INCLUDED_CSTDIO #endif using namespace std; namespace rude{ namespace config{ WhiteSpace::WhiteSpace(const char *whitespace) { d_whitespace = whitespace ? whitespace : ""; } void WhiteSpace::acceptWriter(AbstractWriter& writer) const { writer.visitWhiteSpace(*this); } const char *WhiteSpace::getWhiteSpace() const { return d_whitespace.c_str(); } }} // end namespace rude::config actionaz-3.7.0/3rdparty/rudeconfig/WhiteSpace.h000066400000000000000000000027241216313063400214370ustar00rootroot00000000000000// WhiteSpace.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_WhiteSpace_H #define INCLUDED_WhiteSpace_H #ifndef INCLUDED_DataLine_H #include "DataLine.h" #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif namespace rude{ namespace config{ class WhiteSpace: public DataLine{ std::string d_whitespace; public: WhiteSpace(const char *WhiteSpace); void acceptWriter(AbstractWriter& writer) const; const char *getWhiteSpace() const; }; }} // end namespace rude::config #endif actionaz-3.7.0/3rdparty/rudeconfig/Writer.cpp000066400000000000000000000216301216313063400212070ustar00rootroot00000000000000// Writer.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ /* Edited on 19/08/2010 by Jonathan Mercier-Ganady for Actionaz */ #include "Writer.h" #ifndef INCLUDED_File_H #include "File.h" #endif #ifndef INCLUDED_Section_H #include "Section.h" #endif #ifndef INCLUDED_KeyValue_H #include "KeyValue.h" #endif #ifndef INCLUDED_Comment_H #include "Comment.h" #endif #ifndef INCLUDED_WhiteSpace_H #include "WhiteSpace.h" #endif #ifndef INCLUDED_CSTDLIB #include #define INCLUDED_CSTDLIB #endif #ifndef INCLUDED_CCTYPE #include #define INCLUDED_CCTYPE #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif #ifndef INCLUDED_LOCALE #include #define INCLUDED_LOCALE #endif using namespace std; namespace rude{ namespace config{ Writer::Writer() { } Writer::~Writer() { } void Writer::visitFile(const File& /*configfile*/) const { } void Writer::visitSection(const Section& configsection) const { std::string name = configsection.getSectionName(); // if there is a section name, we print it out [between brackets] // if(name != "") { if( configsection.isDeleted() ) { if ( d_commentchar && d_preservedeleted ) { *d_outputstream << d_commentchar << " "; } else { return; } } int position = 0; size_t location; // escape all backslashes // while( (location = name.find("\\", position)) != string::npos ) { // location points right at the '\' name.insert(location, "\\"); position = (int) location + 2; } // escape all ']''s // while( (location = name.find("]", position)) != string::npos ) { // location points right at the ']' name.insert(location, "\\"); position = (int) location + 2; } *d_outputstream << "[" << name << "]"; // If the section name has a comment, we print it out after the section name // if(configsection.getSectionComment()[0] != 0 && d_commentchar) { *d_outputstream << "\t" << d_commentchar << configsection.getSectionComment(); } // newline ends the section header // *d_outputstream << "\n"; } } void Writer::visitComment(const Comment& comment) const { if(d_preservecomments && d_commentchar && ( !comment.isDeleted() || d_preservedeleted )) { *d_outputstream << d_commentchar << comment.getComment() << "\n"; } } void Writer::visitWhiteSpace(const WhiteSpace& whitespace) const { if(d_preservewhitespace && ( !whitespace.isDeleted() || d_preservedeleted )) { *d_outputstream << whitespace.getWhiteSpace(); } } void Writer::visitKeyValue(const KeyValue& dataline) const { if(dataline.isDeleted() && ( !d_commentchar || !d_preservedeleted)) { // Don't preserve deleted data when comments are null // or we don't want to preserve them return; } else { string key = dataline.getName(); string value = dataline.getValue(); string comment = dataline.getComment(); string commentchar(1,d_commentchar); if(dataline.isDeleted()) { // print the comment character // *d_outputstream << d_commentchar << " "; } if(key != "") { int position = 0; size_t location; // escape all backslashes // while( (location = key.find("\\", position)) != string::npos ) { // location points right at the '\' key.insert(location, "\\"); position = (int) location + 2; } // escape comment characters // unless the comment character is a backslash, which we've already escaped.... // if(d_commentchar && d_commentchar != '\\') { position = 0; while( (location = key.find(commentchar, position)) != string::npos ) { // location points right at the '"' key.insert(location, "\\"); position = (int) location + 2; } } // escape all delimiters, unless the delimiter is a backslash or the same as the comment, god forbid. // // if(d_delimiter != '\\' && d_delimiter != d_commentchar) { if(d_delimiter) { string delimiter(1, d_delimiter); position = 0; while( (location = key.find(delimiter, position)) != string::npos ) { // location points right at the '"' key.insert(location, "\\"); position = (int) location + 2; } } else { position = 0; while( (location = key.find("\t", position)) != string::npos ) { // location points right at the '"' key.insert(location, "\\"); position = (int) location + 2; } position = 0; while( (location = key.find(" ", position)) != string::npos ) { // location points right at the '"' key.insert(location, "\\"); position = (int) location + 2; } } } // print the key // *d_outputstream << key; } if(value != "") { // print out the delimiter // *d_outputstream << " " << ( d_delimiter ? d_delimiter : '\t' ) << " "; int position = 0; size_t location; // escape all backslashes // string backslash(1,'\\'); while( (location = value.find("\\", position)) != string::npos ) { // location points right at the '\' value.insert(location, "\\"); position = (int) location + 2; } // escape all quotes // string quote(1,'"'); position = 0; while( (location = value.find("\"", position)) != string::npos ) { // location points right at the '"' value.insert(location, "\\"); position = (int) location + 2; } // escape comment characters // unless the comment character is a backslash or a quote, which we've already escaped.... // if(d_commentchar && d_commentchar != '\\' && d_commentchar != '"') { position = 0; while( (location = value.find(commentchar, position)) != string::npos ) { // location points right at the '"' value.insert(location, "\\"); position = (int) location + 2; } } // if value starts with whitespace, ends with whitespace or contains the comment character or CRLF's, quote the value, // size_t size = value.size(); locale loc; if( isspace(value[0], loc) || isspace(value[size-1], loc) || (value.find("\r", 0) != string::npos) || (value.find("\f", 0) != string::npos) || (value.find("\n", 0)!= string::npos) ) { value.insert(0, "\""); value += "\""; } // if data is deleted and there are CRLFS // then each line must start with a comment character. // The safest way is just to follow every newline character with a comment // if( dataline.isDeleted() && ( (value.find("\r", 0) != string::npos) || (value.find("\f", 0) != string::npos) || (value.find("\n", 0)!= string::npos) ) ) { position = 0; while( (location = value.find("\r", position)) != string::npos ) { // location points right at the '"' value.insert(location + 1, commentchar); position = (int) location + 2; } position = 0; while( (location = value.find("\f", position)) != string::npos ) { // location points right at the '"' value.insert(location + 1, commentchar); position = (int) location + 2; } position = 0; while( (location = value.find("\n", position)) != string::npos ) { // location points right at the '"' value.insert(location + 1, commentchar); position = (int) location + 2; } } *d_outputstream << value; } if( comment != "" && d_commentchar && d_preservecomments) { // add value's comment at end if it exists // and there is a comment character // *d_outputstream << "\t " << d_commentchar << comment; } // end the entry with a newline // *d_outputstream << "\n"; } } }} // end namespaces actionaz-3.7.0/3rdparty/rudeconfig/Writer.h000066400000000000000000000062111216313063400206520ustar00rootroot00000000000000// Writer.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #ifndef INCLUDED_Writer_H #define INCLUDED_Writer_H #include "AbstractWriter.h" #include namespace rude{ namespace config{ class File; class Section; class KeyValue; class Comment; class WhiteSpace; class Writer: public AbstractWriter{ public: Writer(); virtual void visitFile(const File& configfile) const; virtual void visitSection(const Section& configsection) const; virtual void visitKeyValue(const KeyValue& keyvalue) const; virtual void visitComment(const Comment& comment) const; virtual void visitWhiteSpace(const WhiteSpace& whitespace) const; virtual ~Writer(); //= // Writes the data member to an output stream // // For the following specification examples, assume an object with the following properties: // // name = "color" // value="blue" // comment="Color of the background" // //
    //
  • If comment char is null, comments/deleted items will not be written // // Example: object->write(stdout, 0, "=") // Results: // color = blue // //
  • If delimiter is null, name / value will be separated by whitespace // // Example: object->write(stdout, "#", 0) // Results: // color blue # Color of the background // //
  • Undefined results if outputstream is null // // Example: object->write(0, "#", "=") // Results: // ?????????? // //
  • If the data member is a comment, then only the comment data is written - any values // for the name / value are discarded. // // Example: object->write(stdout, "#", "=") // Results: // # Color of the background // //
  • If the data member has been (flagged as) deleted, then the name, value and original comment are preserved, // preceded by a comment character. // // Example: object->write(stdout, "#", "=") // Results: // # color = blue # Color of the background // //
//= }; }} // end namespaces #endif actionaz-3.7.0/3rdparty/rudeconfig/config.cpp000066400000000000000000000144231216313063400212020ustar00rootroot00000000000000// config.cpp // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ #include "config.h" #ifndef INCLUDED_RUDE_CONFIGIMPL_H #include "ConfigImpl.h" #endif #ifndef INCLUDED_IOSTREAM #include #define INCLUDED_IOSTREAM #endif #ifndef INCLUDED_STRING #include #define INCLUDED_STRING #endif using namespace rude::config; namespace rude{ ////////////////////////////////////////// // STATIC Methods ////////////////////////////////////////// const char *Config::version() { static std::string ver="3."; ver += ConfigImpl::version(); return ver.c_str(); } void Config::setDefaultConfigFile(const char *filepath) { ConfigImpl::setDefaultConfigFile(filepath); } const char *Config::getDefaultConfigFile() { return ConfigImpl::getDefaultConfigFile(); } void Config::setDefaultCommentCharacter(char c) { ConfigImpl::setDefaultCommentCharacter(c); } char Config::getDefaultCommentCharacter() { return ConfigImpl::getDefaultCommentCharacter(); } void Config::setDefaultDelimiter(char c) { ConfigImpl::setDefaultDelimiter(c); } char Config::getDefaultDelimiter() { return ConfigImpl::getDefaultDelimiter(); } void Config::setDefaultPreserveDeleted(bool shouldPreserve) { ConfigImpl::setDefaultPreserveDeleted(shouldPreserve); } bool Config::getDefaultPreserveDeleted() { return ConfigImpl::getDefaultPreserveDeleted(); } ////////////////////////////////////////// // INSTANCE Methods ////////////////////////////////////////// Config::Config() { d_implementation = new ConfigImpl(); } Config::~Config() { delete d_implementation; d_implementation = 0; } void Config::setConfigFile(const char *filepath) { d_implementation->setConfigFile(filepath); } const char * Config::getConfigFile() { return d_implementation->getConfigFile(); } void Config::setCommentCharacter(char commentchar) { d_implementation->setCommentCharacter(commentchar); } void Config::preserveDeletedData(bool shouldPreserve) { d_implementation->preserveDeletedData(shouldPreserve); } void Config::setDelimiter(char delimiter) { d_implementation->setDelimiter(delimiter); } bool Config::load() { return d_implementation->load(); } bool Config::load(const char *filename) { return d_implementation->load(filename); } bool Config::save() { return d_implementation->save(); } bool Config::save(const char *filepath) { return d_implementation->save(filepath); } void Config::clear() { d_implementation->clear(); } const char *Config::getError() { return d_implementation->getError(); } ////////////////////////////////////////// // Section Methods ////////////////////////////////////////// int Config::getNumSections() const { return d_implementation->getNumSections(); } const char *Config::getSectionNameAt(int index) const { return d_implementation->getSectionNameAt(index); } bool Config::setSection(const char *sectionname, bool shouldCreate) { return d_implementation->setSection(sectionname, shouldCreate); } bool Config::setSection(const char *sectionname) { return d_implementation->setSection(sectionname, true); } bool Config::deleteSection(const char *sectionname) { return d_implementation->deleteSection(sectionname); } ////////////////////////////////////////// // Data Methods ////////////////////////////////////////// size_t Config::getNumDataMembers() const { return d_implementation->getNumDataMembers(); } const char *Config::getDataNameAt(int index) const { return d_implementation->getDataNameAt(index); } bool Config::exists(const char *name) const { return d_implementation->exists(name); } void Config::setBoolValue(const char *name, bool value) { d_implementation->setStringValue(name, ConfigImpl::boolToString(value)); // d_implementation->setBoolValue(name, value); } bool Config::getBoolValue(const char *name) const { return ConfigImpl::stringToBool(d_implementation->getStringValue(name)); //return d_implementation->getBoolValue(name); } void Config::setIntValue(const char *name, int value) { d_implementation->setStringValue(name, ConfigImpl::intToString(value)); // d_implementation->setIntValue(name, value); } int Config::getIntValue(const char *name) const { return ConfigImpl::stringToInt(d_implementation->getStringValue(name)); //return d_implementation->getIntValue(name); } void Config::setDoubleValue(const char *name, double value) { d_implementation->setStringValue(name, ConfigImpl::doubleToString(value)); // d_implementation->setDoubleValue(name, value); } double Config::getDoubleValue(const char *name) const { return ConfigImpl::stringToDouble(d_implementation->getStringValue(name)); //return d_implementation->getDoubleValue(name); } void Config::setStringValue(const char *name, const char *value) { d_implementation->setStringValue(name, value); } const char * Config::getStringValue(const char *name) const { return d_implementation->getStringValue(name); } void Config::setValue(const char *name, const char *value) { d_implementation->setStringValue(name, value); } const char * Config::getValue(const char *name) const { return d_implementation->getStringValue(name); } bool Config::deleteData(const char *name) { return d_implementation->deleteData(name); } } // end namespace rude actionaz-3.7.0/3rdparty/rudeconfig/config.h000066400000000000000000000500501216313063400206430ustar00rootroot00000000000000// Config.h // // Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Matthew Flood // See file AUTHORS for contact information // // This file is part of RudeConfig. // // RudeConfig is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. // // RudeConfig is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with RudeConfig; (see COPYING) if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. //------------------------------------------------------------------------ /* Edited on 19/08/2010 by Jonathan Mercier-Ganady for Actionaz */ #ifndef INCLUDED_RUDE_CONFIG_H #define INCLUDED_RUDE_CONFIG_H #include #if defined(RUDECONFIG_LIBRARY) # define RUDECONFIGSHARED_EXPORT Q_DECL_EXPORT #else # define RUDECONFIGSHARED_EXPORT Q_DECL_IMPORT #endif namespace rude{ namespace config{ class ConfigImpl; } //= // rude::Config is the public interface for the config/ini file reader. //= class RUDECONFIGSHARED_EXPORT Config{ // Bridge component // rude::config::ConfigImpl *d_implementation; public: //= // Default constructor // Use to obtain an instance of the rude::Config component // // Example: // // rude::Config myconfig; // // //OR // // rude::Config *myconfig = new rude::Config(); // //= Config(); //= // Returns the version of the component. // // The version is specified by X.Y where: // X is the version of the interface (this class), and // Y is the version of the implementation (the internals). // // Example: // // const char *version = Config::version(); //= static const char *version(); //= // Sets the default filename to be used by all config objects // Initially, this value is "default.ini" // Methods affected include load(void) and save(void) // This method does not affect already existing instances. //= static void setDefaultConfigFile(const char *filepath); //= // Returns the default filename to be used by all config objects //= static const char *getDefaultConfigFile(); //= // Sets the default comment character to be used by all config objects // The comment character affects how config files are parsed, and how they are written. // Initially, the default comment character is set to '#' // This method does not affect already existing instances. //= static void setDefaultCommentCharacter(char c); //= // Returns the default comment character to be used by all config objects //= static char getDefaultCommentCharacter(); //= // Sets the default delimiter character to be used by all config objects // The delimiter affects how config files are parsed, and how they are written. // Initially, the default delimiter is set to '=' // This method does not affect already existing instances. //= static void setDefaultDelimiter(char c); //= // Returns the default delimiter character to be used by all config objects //= static char getDefaultDelimiter(); //= // Sets the default behavior of all config objects in dealing with deleted values. // The default behavior is for config objects to preserve deleted data as comments when // the config object is saved // This method does not affect already existing instances. //= static void setDefaultPreserveDeleted(bool shouldPreserve); //= // Returns the default deletion behavior // true means deleted data will be preserved as comments when the config object is saved // false means that deleted data will be discarded when the config object is saved //= static bool getDefaultPreserveDeleted(); //= // Set's the default filepath to be used by the load() and save() methods // The default filepath is initially set to "./default.ini" // Affects the current instance only //= void setConfigFile(const char *filepath); //= // Returns the default filepath to be used by the load() and save() methods // The default filepath is initially set to "./default.ini" // Affects the current instance only //= const char * getConfigFile(); //= // Sets whether or not deleted data will be preserved as comments. // If set to true, deleted data will be converted into comments when // the save() method is called. If set to false, deleted data // will not be compeltely discarded. Default is false (no preserve). // Affects the current instance only. //= void preserveDeletedData(bool shouldPreserve); //= // Set's the comment character ( initially set to '#' ) // If the comment character is set to NULL (0), // then comments will not be written when save() is called // Affects the current object only //= void setCommentCharacter(char commentchar); //= // Set's the delimiter for new config objects ( initially set to '=' ) // If the delimiter is set to NULL, then it will be assumed that // the key and value are separated by whitespace. // Affects the current object only //= void setDelimiter(char kayvaluedelimiter); //= // // When called before load(), saves the configuration to the default config file. // Initially, the default config file is "./default.ini". // // If load was called with an argument: // load(const char *filename) // then save() will use the same filename. // // The filename used by the instance can be changed by the setConfigFile() method. //= bool save(); //= // Saves the configuration object to the specified file // The default config file path for the instance is not altered... // Use setConfigFile(const char *filename) or load(const char *filename) to set the default filename for the instance //= bool save(const char *filepath); //= // Removes the contents of the configuration file - completely wipes it out. // Does not preserve anything. Afterwards, the current section is set // to the empty section (""), which is the unnamed section // at the beginning of the configuration file. //= void clear(); //= // Loads the default file into the configuration object. // By default, the current file is 'default.conf', // but can be overridden by calling the setConfigFile(const char *filename) method. // This method does not clear the config object before loading. // If you load two or more configuration files that have the same sections, // they are effectively merged. In this case, data members that have the same // name will get the value of the last file loaded. This comes in handy if // you load a global config file first, and you want to override // some custom fields by subsequently loading a "preferences" file tailored to an individual. // Use clear() if the config object already has data that you want to completely discard before loading // a new file, or use another Config object instance. //= bool load(); //= // Adds the file's configuration info to the current object. // Does not delete any existing data in the config object. // The default config file path is not altered... // Use setConfigFile() to permanently set the default config file for load() and save() // This method does not clear the config object before loading. // Use clear() if the config object already has data that you want to discard. //= bool load(const char *filename); //= // Returns the most recent error string, if there is one. // If no error exists, it will return the empty string (""). //= const char *getError(); //= // Returns the number of sections in the entire configuration file // This number includes the default section - "" (the empty section at the beginning of the file) // Sections within the configuration file are identifed by [Square Brackets] surrounding the name of the section. // Whitespace surrounding the section name is ignored. So [ This Section ] and [This Section] are identical. // Section names are case sensitive. // The default section is the empty section - the unnamed section at the beginning of the file that // exists before any other [named] sections. This section exists even if the first line of the file // contains a [named section]. The empty section will simply be void of any data. // As such, the return value will always be >= 1. //= int getNumSections() const; //= // Enumeration method to discover sections // Returns the section name at the given index, // or NULL if the index is out of range // If the section has no name, but is a valid index, then it will return the empty string ("") //= const char *getSectionNameAt(int index) const; //= // Sets the current working [section], possibly creating a new section // The default section is "" (the untitled section at the beginning of the configuration file). // If the new section cannot be found, and shouldCreate is true, // then the section will be created and will exist at the end of all other sections. // If the new section cannot be found, and shouldCreate is false, // then the current section remains unchanged, and the method returns false. // Leading and trailing whitespace is not preserved when the file is written, // and as such should be avoided when naming sections //= bool setSection(const char *sectionname, bool shouldCreate); //= // Sets the current working section, creating the section if it does not exist. // See setSection(const char *sectionname, bool shouldCreate) where shouldCreate = true. //= bool setSection(const char *sectionname); //= // Deletes the section identified by sectionname and all data associated with it // Returns false if the section does not exist or has already been deleted. // If the object is saved, the entire section will be commented out. // If, during the lifetime of this object, the section is re-created, then the section will be revived, but all // previous data members remain commented (as if deleted) unless/until recreated (see deleteData()) //= bool deleteSection(const char *sectionname); //= // Returns the number of data elements for the current section // // Example: // // Given the following configuration: // //[Good Movies] // The 5th Element // Resevoir Dogs // Braveheart // // [Bad Movies] // // Freddy Got Fingered // CONfidential // // [Body Parts] // arm=2 // head=1 // legs=2 // neck=1 // ears=2 // eyes=2 // // // // You'll get the following results: // // config->setSection("Body Parts", true); // config->getNumDataMembers(); // returns 6 // // config->setSection("Bad Movies", true); // config->getNumDataMembers(); // returns 2 // // config->setSection("Good Movies", true); // config->getNumDataMembers(); // returns 3 // //= size_t getNumDataMembers() const; //= // Enumeration method to discover data members within the current section // Returns the name of the data member at // the specified index within the current // section, or NULL if the index is out of range. // // Example: // // Given the following configuration: // //[Contact Info] // name= Mark Twain // email address = mark@twain // phone = 123.456.789 // // // You'll get the following results: // // config->setSection("Contact Info"); // config->getDataNameAt(0); // returns "name" // config->getDataNameAt(2); // returns "phone" // config->getDataNameAt(3); // returns NULL (out of range) // // //= const char *getDataNameAt(int index) const; //= // Returns true if a data member exists with the given //name within the current section // // //  Example: // // Given the following configuration: // // // [Strong Body Parts] // arm=2 // head=1 // legs=2 // neck=1 // // [Weak Body Parts] // eyes=2 // belly=1 // nose=1 // // // You'll get the following results: // // config->setSection("Strong Body Parts"); // // if(config->exists("arm")) // { // // yes, arm exists... // } // // if(config->exists("belly")) // { // // returns false - belly isn't in that section. // } // // config->setSection("Weak Body Parts"); // // if(config->exists("belly")) // { // // yes! belly is in this section.... // } // //= bool exists(const char *name) const; //= // Returns the boolean value of the data identified by name within the current section // This is a helper function that converts the string data stored in the config object to a boolean // Returns true if the current value is "on" or 1, // or if the value starts with the letter 't' or 'y' // ( all of the above are case insensitive ) // returns false otherwise // // As such, it will interpret the following as true: // Yes, yes, On, on, True, true, 1, T, t, Y, y // // Likewise, it will interpret the following as false: // No, no, Off, off, False, false, 0, F, f, N, n // // // Example: // // Given the following configuration: // // // [Things that are and aren't] // Bed Bugs= TRUE // Aliens = 1 // Freud= ON // Water= yes // ducks = false // carpenter = off // floppy = 0 // sand = Nope // // You'll get the following results: // // config->setSection("Things that are and aren't"); // // config->getBoolValue("Aliens"); // returns true // config->getBoolValue("carpenter"); // returns false // // etc... // //= bool getBoolValue(const char *name) const; //= // Returns the integer value of the data identifed by name within the current section // This is a helper function that converts the string value stored in the config object to an int. // Returns 0 if the data does not exist or if an integer value cannot be determined. //= int getIntValue(const char *name) const; //= // Returns the double value, or 0 if a double value cannot be determined // Thie is a helper function that converts the string value stored in the config object to a double //= double getDoubleValue(const char *name) const; //= // Returns the string-character value. // Unless the value is quoted, leading and trailing whitespace is stripped. // If the value is quoted, the quotes are removed, and leading and trailing whitespace // within the quotes are preserved. //= const char * getValue(const char *name) const; //= // Same as const char *getValue(const char *name) // @deprecated //= const char * getStringValue(const char *name) const; //= // Sets the named value within the current section to "true" or "false" // This is a helper function that converts a bool to the string value // that the config object expects. // If the value is already set for the data item, the value is changed. // If the value is not already set, it is created // // Example: // // To create the following configuration entries: // // [On Sale] // Hard Drives = true // Cases = false // Keyboards = false // // // Use this code: // // config->setSection("On Sale"); // config->setBoolValue("Hard Drives", true); // config->setBoolValue("Cases", false); // config->setBoolValue("Keyboards", false); // config->save(); // // // @param name the identifying name of the data member // @param value The integer value of the data member // //= void setBoolValue(const char *name, bool value); //= // Sets the named value within the current section to the specified integer // The config object stores values as strings- this is a helper method // that converts an integer to the expected string value. // If the value is already set for the data item, the value is changed. // If the value is not already set, it is created // // Example: // // To create the following configuration entries: // // [Inventory] // Hard Drives = 35 // Cases = 24 // Keyboards = 103 // // // Use this code: // // config->setSection("Inventory", true); // config->setIntValue("Hard Drives", 35); // config->setIntValue("Cases", 24); // config->setIntValue("Keyboards", 103); // config->save(); // // // @param name the identifying name of the data member // @param value The integer value of the data member // //= void setIntValue(const char *name, int value); //= // Sets the value for a data item within the current section to the specified double // The config object stores values as strings- this is a helper method // that converts an integer to a string value to be stored. // If the value is already set for the data item, the value is changed. // If the value is not already set, it is created // // Example: // // To create the following configuration entries: // // [Prices] // Hard Drives = 59.95 // Cases = 44.00 // Keyboards = 12.25 // // // Use this code: // // config->setSection("Prices", true); // config->setDoubleValue("Hard Drives", 59.95); // config->setDoubleValue("Cases", 44.00); // config->setDoubleValue("Keyboards", 12.25); // config->save(); // // // @param name the identifying name of the data member // @param value The double value of the data member // @author Matt Flood // //= void setDoubleValue(const char *name, double value); //= // Sets the value for a data item within the current section to the specified string // If the value is already set for the data item, the value is changed. // If the value is not already set, it is created. // If leading and/or trailing whitespace exists within the value, it will be preserved in // the config file. The config object will automatically surround the value with quotes. // Likewise, if the value starts with a quote ("), then the value // will necessarily be surrounded by quotes to preserve it. As such, programs do not have to, (and // in fact should not ) perform their own quoting of values. You should provide you own // quotes only when you are modifying the config/ini file using a text editor or some other means // besides the RudeConfig object. // // Note: Leading and traling whitespace of the identifying fieldname (the key for the data item) is not preserved. // // Example: // // To create the following configuration entry: // // [travel]
Travel Agent = Mary Johnson
// // Use this code: // // config->setSection("travel", true); // config->setStringValue("Travel Agent", "Mary Johnson"); // config->save(); // // // @param name the identifying name of the data member // @param value The string value of the data member // @author Matt Flood // //= void setValue(const char *name, const char *value); //= // Same as setValue(const char *name, const char *value); // @deprecated // //= void setStringValue(const char *name, const char *value); //= // Deletes the data member identified by name (if it exists) in the current section. // If the configuration object is saved, // then the data member will be preserved by being commented out. // If a new value is later assigned to this // value (in the lifetime of the instance), // then it becomes undeleted (uncommented). // Values can only be revived this way using the same instance they were deleted with. // Otherwise, they become permanent comments. // See preserveDeletedData(bool shouldPreserve) to alter this behavior. // //= bool deleteData(const char *name); ~Config(); }; } // end namespace rude #endif actionaz-3.7.0/3rdparty/rudeconfig/rudeconfig.pro000066400000000000000000000016231216313063400220760ustar00rootroot00000000000000include(../../common.pri) QT -= gui TEMPLATE = lib CONFIG += dll DEFINES += RUDECONFIG_LIBRARY win32:DEFINES += _CRT_SECURE_NO_WARNINGS TARGET = rudeconfig DESTDIR = ../.. SOURCES += \ Writer.cpp \ WhiteSpace.cpp \ Section.cpp \ RealOrganiser.cpp \ ParserJuly2004.cpp \ KeyValue.cpp \ File.cpp \ DataLine.cpp \ ConfigImpl.cpp \ config.cpp \ Comment.cpp \ Base64Encoder.cpp \ AbstractWriter.cpp \ AbstractParser.cpp \ AbstractOrganiser.cpp \ AbstractData.cpp HEADERS += \ Writer.h \ WhiteSpace.h \ Section.h \ RealOrganiser.h \ ParserJuly2004.h \ KeyValue.h \ File.h \ DataLine.h \ ConfigImpl.h \ config.h \ Comment.h \ Base64Encoder.h \ AbstractWriter.h \ AbstractParser.h \ AbstractOrganiser.h \ AbstractData.h INCLUDEPATH += src UI_DIR = generated MOC_DIR = generated RCC_DIR = generated OBJECTS_DIR = generated unix { target.path = $${PREFIX}/lib/actionaz INSTALLS += target } actionaz-3.7.0/CHANGELOG000066400000000000000000000215231216313063400145450ustar00rootroot000000000000003.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 Actionaz: 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 Actionaz window when using the Exit Actionaz 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 Actionaz 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 Actionaz" 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 actionaz-3.7.0/LICENSE000066400000000000000000000773301216313063400143470ustar00rootroot00000000000000 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 actionaz-3.7.0/README000066400000000000000000000006171216313063400142140ustar00rootroot00000000000000** Actionaz ** Actionaz 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. Actionaz is cross-platform. Please visit www.actionaz.org for more information. actionaz-3.7.0/actexecuter/000077500000000000000000000000001216313063400156445ustar00rootroot00000000000000actionaz-3.7.0/actexecuter/actexecuter.pro000066400000000000000000000020461216313063400207040ustar00rootroot00000000000000include(../common.pri) unix:!mac:QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN -Wl,--rpath=$${PREFIX}/lib/actionaz QT += xml \ network \ script \ scripttools TARGET = actexec VERSION = $$ACTIONAZ_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 unix:!mac:CONFIG += link_pkgconfig unix:!mac:PKGCONFIG += libnotify unix { target.path = $${PREFIX}/bin locales.path = $${PREFIX}/share/actionaz/locale locales.files = ../locale/actexecuter_fr_FR.qm locales.CONFIG = no_check_exist manfile.path = $${PREFIX}/share/man/man1 manfile.files = ../docs/actexec.1 INSTALLS += target locales manfile } actionaz-3.7.0/actexecuter/actexecuter.rc000066400000000000000000000001051216313063400205020ustar00rootroot00000000000000IDI_ICON1 ICON DISCARDABLE "icons/actionaz.ico" actionaz-3.7.0/actexecuter/codeexecuter.cpp000066400000000000000000000131311216313063400210260ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "executer/codeactionaz.h" #include "global.h" #include #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())); foreach(QString extension, mScriptEngine->availableExtensions()) mScriptEngine->importExtension(extension); mScriptEngineDebugger->setAutoShowStandardWindow(false); mScriptEngineDebugger->attachTo(mScriptEngine); QScriptEngineAgent *debuggerAgent = mScriptEngine->agent(); mScriptEngine->setAgent(mScriptAgent); mScriptAgent->setDebuggerAgent(debuggerAgent); } bool CodeExecuter::start(QIODevice *device, const QString &filename) { if(!Executer::start(device, filename)) return false; QString code = device->readAll(); device->close(); mScriptAgent->setContext(LibExecuter::ScriptAgent::ActionInit); LibExecuter::CodeInitializer::initialize(mScriptEngine, mScriptAgent, actionFactory()); Code::CodeTools::addClassToScriptEngine("Console", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::print, "print", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::println, "println", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printWarning, "printWarning", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printlnWarning, "printlnWarning", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printError, "printError", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Console", &LibExecuter::CodeStdio::printlnError, "printlnError", mScriptEngine); Code::CodeTools::addClassToScriptEngine("Actionaz", mScriptEngine); LibExecuter::CodeActionaz::setActExec(true); LibExecuter::CodeActionaz::setActionazVersion(Global::ACTIONAZ_VERSION); LibExecuter::CodeActionaz::setScriptVersion(Global::SCRIPT_VERSION); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actionaz", &LibExecuter::CodeActionaz::version, "version", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actionaz", &LibExecuter::CodeActionaz::scriptVersion, "scriptVersion", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actionaz", &LibExecuter::CodeActionaz::isActExec, "isActExec", mScriptEngine); Code::CodeTools::addClassGlobalFunctionToScriptEngine("Actionaz", &LibExecuter::CodeActionaz::isActionaz, "isActionaz", mScriptEngine); QSettings settings; QString locale = settings.value("locale").toString(); if(locale.isEmpty()) { locale = QLocale::system().name(); #ifdef Q_WS_WIN QString installerLanguage = settings.value("installerLanguage").toString(); if(!installerLanguage.isEmpty()) { if(installerLanguage == "english") locale = "en_US"; else if(installerLanguage == "french") locale = "fr_FR"; } #endif } for(int actionPackIndex = 0; actionPackIndex < actionFactory()->actionPackCount(); ++actionPackIndex) { ActionTools::ActionPack *actionPack = actionFactory()->actionPack(actionPackIndex); QTranslator *actionTranslator = new QTranslator(this); actionTranslator->load(QString("%1/locale/actionpack%2_%3").arg(QApplication::applicationDirPath()).arg(actionPack->id()).arg(locale)); QApplication::installTranslator(actionTranslator); } 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(); } actionaz-3.7.0/actexecuter/codeexecuter.h000066400000000000000000000025051216313063400204760ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actexecuter/executer.cpp000066400000000000000000000035451216313063400202030ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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("locale", QLocale::system().name()).toString(); mActionFactory->loadActionPacks(QApplication::applicationDirPath() + "/actions/", locale); #ifndef Q_WS_WIN if(mActionFactory->actionPackCount() == 0) mActionFactory->loadActionPacks(QString("%1/lib/actionaz/actions/").arg(ACT_PREFIX), 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; } actionaz-3.7.0/actexecuter/executer.h000066400000000000000000000023541216313063400176450ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actexecuter/global.h000066400000000000000000000020331216313063400172530ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 ACTIONAZ_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://www.actionaz.org/"; } #endif // GLOBAL_H actionaz-3.7.0/actexecuter/icons/000077500000000000000000000000001216313063400167575ustar00rootroot00000000000000actionaz-3.7.0/actexecuter/icons/actionaz.ico000066400000000000000000000353561216313063400212770ustar00rootroot00000000000000 h6 00 %F(  @2&n^ o`#@3VH1n_"m[q2&FRq,2&2&7YJusb.=տjM8+K1%A1%ANA]ɶ^˵h`Q"2& }.adϼT±RñNWkʰKtaq_O+ïXquyȸ]Ϳixsi3gU-Ʊ_R^ҿY|/;jSuɷb<eR-T;C%ǶW8пN²]J>R4dP-O-SO]Ni1& K/cO-I"2& E!@NeY" 2&#D,hT!8 xcWE %zƭ83DB喁2r_ #@봢GәA;( @ 2& 1&72&M2&Q2&E2&2&2&2&%2&K2&Q2&I2&'2&2& n)r,كt/مu/F9 M2& 2&gYu/ׂs-لp*{g${2&{5?JHn*;.)2&RDO8ݴKJHz=A{A1Xɴ_ǴX=\La2&2&uf&NκhDzfTtd02&N{ӾpgŲTz12&'2&2&2&2&2&2&=1ECҿiuůfn812&H;YDzfl[K?32&q1%o1%o1%o1%o2&sk] ɷXsqQ1&2&2&YIyx-ѷT]a]ɶRJEGFG°NϼV`lڿ\;_N8+2&2%%x*۸>_sqa\Y]Ͽ_μYѾTY^roRƪD},XHK2&ZKI>ϻbvv{z|zgdkyx{zvsҺS7xe q2&hVWUlrĵbmtxtBU[Si\vvuϿguh>p%u2&jXW[нgŵby:IWϽgfZ<9-#\OOKlm̹eفs5KƶbiFs*u2&iVWX˶`St6GE1]о^̶E9WIer#°GhϽfVB6 !VκdCq(u2&hUWSưWCyl/G1&JuǶ`κKɴ<}%ɷ9Xпd[se-1&Iȳ]=n%u2&gTWQĬUλ1SξXR^ƹ[JeY# 1&>êT5i u2&fRWLīM.j[M1&HoH밟8붧O뭠Pxl/2&<ŬR3gu2&dQWHêB%]N u2&#1&CFA=CICI32&2& 2&#2&K2ǭM0fu2&iUO6*«$cR RBO2&K<7eT q'Ū;0fqhU+C<ư#{s^u2&aN W{ʴ7ǮH@q/]2&CH±GC,{fo2&jWO:G±HJDn3=By;B٠Cא|7S2&r23Cפ;٪AäE=#(0` %2& 2&2&-2&12&12&12&%2&2&2&2&+2&12&12&12&'2&2&2&2&M2&2&2&2&2&w2&92& 2&2&[2&2&2&2&2&k2&/2&2&z/ϙ7:==:N@}2&2& 2&A}n+ӛ=<964zf#a2&2&m.a5u02&2&NǷ_]=@AAVfͽaZvh/=2&#:­XǯZ>02&12& jU{LīWëP;p(2&2&{ŤHŦKšH2&2& 2&5/ŭPȮS7*2&12& gS{CêNé6'p2&_2&;2&%2& 2&2&2&+2&A2&k#ŬCɮO3~)2&12& iTw68å%Ŭ%"bR <02&m2&%2& 2&72&wF8ueѻ$ũ.Ū@1|'2&/2&r] k93"˳%î$~v2&12& eS {x!ŭ$ɮ.ǬG;}.2&#^M+ILƯEDz#í!r2&12& dP {t˸8ϺOëMI?2&2& @JJɸLȶK=$t2&-2& gSw-DIJMʹKűMKIv9k2&|j.DūD. Contact : jmgr@jmgr.info */ #include "globalshortcut/globalshortcutmanager.h" #include "qxtcommandoptions/qxtcommandoptions.h" #include "actioninstance.h" #include "version.h" #include "mainclass.h" #include "nativeeventfilteringapplication.h" #include "global.h" #include "settings.h" #include #include #include #include #include #include #include #include #include #include #include #ifdef Q_WS_X11 #undef signals #include #define signals #include "keysymhelper.h" #endif #ifdef Q_WS_WIN #include #include #include #include #include #include #endif static void cleanup() { ActionTools::GlobalShortcutManager::clear(); } #ifdef Q_WS_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 < 0x040700) #error("You need Qt 4.7.0 or later to compile Actionaz Executer"); #endif ActionTools::NativeEventFilteringApplication app("actionaz-exec", argc, argv); app.setQuitOnLastWindowClosed(false); qAddPostRoutine(cleanup); qsrand(std::time(NULL)); #ifdef Q_WS_X11 notify_init("Actionaz executer"); #endif QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); 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); } QSettings settings; QString locale = settings.value("locale", QLocale::system().name()).toString(); QTranslator qtTranslator; #ifdef Q_WS_WIN qtTranslator.load(QString("%1/locale/qt_%2").arg(QApplication::applicationDirPath()).arg(locale)); #else qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); #endif app.installTranslator(&qtTranslator); QTranslator toolsTranslator; if(!toolsTranslator.load(QString("%1/locale/tools_%2").arg(QApplication::applicationDirPath()).arg(locale))) { #ifndef Q_WS_WIN toolsTranslator.load(QString("%1/share/actionaz/locale/tools_%2").arg(ACT_PREFIX).arg(locale)); #endif } app.installTranslator(&toolsTranslator); QTranslator actionToolsTranslator; if(!actionToolsTranslator.load(QString("%1/locale/actiontools_%2").arg(QApplication::applicationDirPath()).arg(locale))) { #ifndef Q_WS_WIN actionToolsTranslator.load(QString("%1/share/actionaz/locale/actiontools_%2").arg(ACT_PREFIX).arg(locale)); #endif } app.installTranslator(&actionToolsTranslator); QTranslator executerTranslator; if(!executerTranslator.load(QString("%1/locale/executer_%2").arg(QApplication::applicationDirPath()).arg(locale))) { #ifndef Q_WS_WIN executerTranslator.load(QString("%1/share/actionaz/locale/executer_%2").arg(ACT_PREFIX).arg(locale)); #endif } app.installTranslator(&executerTranslator); QTranslator actexecuterTranslator; if(!actexecuterTranslator.load(QString("%1/locale/actexecuter_%2").arg(QApplication::applicationDirPath()).arg(locale))) { #ifndef Q_WS_WIN actexecuterTranslator.load(QString("%1/share/actionaz/locale/actexecuter_%2").arg(ACT_PREFIX).arg(locale)); #endif } app.installTranslator(&actexecuterTranslator); 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_WS_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_WS_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 << "Actionaz Executer version " << Global::ACTIONAZ_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_WS_X11 { #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() != "actionaz") protocolUrl = QUrl(); MainClass::ExecutionMode executionMode = MainClass::Unknown; MainClass mainClass; if(protocolUrl.isValid()) { QString mode; typedef QPair QStringPair; foreach(const QStringPair &queryItem, protocolUrl.queryItems()) { 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(); } actionaz-3.7.0/actexecuter/mainclass.cpp000066400000000000000000000042001216313063400203160ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; } actionaz-3.7.0/actexecuter/mainclass.h000066400000000000000000000025761216313063400200010ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actexecuter/scriptexecuter.cpp000066400000000000000000000054521216313063400214270ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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::ACTIONAZ_VERSION, Global::SCRIPT_VERSION, true, 0); if(!mExecuter->startExecution(false)) { QTextStream stream(stdout); stream << QObject::tr("Start execution failed") << "\n"; stream.flush(); return false; } return true; } void ScriptExecuter::executionStopped() { QApplication::quit(); } void ScriptExecuter::scriptError(int actionIndex, const QString ¶meter, const QString &error) { Q_UNUSED(actionIndex) Q_UNUSED(parameter) QTextStream stream(stdout); stream << QObject::tr("Execution error: ") << error << "\n"; stream.flush(); QApplication::quit(); } actionaz-3.7.0/actexecuter/scriptexecuter.h000066400000000000000000000023701216313063400210700ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actionaz.desktop000066400000000000000000000004721216313063400165360ustar00rootroot00000000000000[Desktop Entry] Name=Actionaz GenericName=Automation Tool GenericName[fr]=Outil d'automatisation Comment=Automate tasks Comment[fr]=Automatise des tâches Exec=actionaz %f Terminal=false Icon=actionaz Type=Application Categories=Utility; Version=1.0 MimeType=application/actionaz-script;application/actionaz-code; actionaz-3.7.0/actionaz.pro000066400000000000000000000036141216313063400156660ustar00rootroot00000000000000TEMPLATE = 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 += 3rdparty \ tools \ actiontools \ executer \ actexecuter \ gui \ actions/actionpackinternal \ actions/actionpackwindows \ actions/actionpackdevice \ actions/actionpacksystem \ actions/actionpackdata actionaz-3.7.0/actions/000077500000000000000000000000001216313063400147705ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdata/000077500000000000000000000000001216313063400177365ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdata/actionpackdata.h000066400000000000000000000071071216313063400230620ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "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 namespace ActionTools { class ActionDefinition; } class ActionPackData : public QObject, public ActionTools::ActionPack { Q_OBJECT Q_INTERFACES(ActionTools::ActionPack) 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)); } 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); } private: Q_DISABLE_COPY(ActionPackData) }; Q_EXPORT_PLUGIN2(ActionPackData, ActionPackData) #endif // ACTIONPACKDATA_H actionaz-3.7.0/actions/actionpackdata/actionpackdata.pro000066400000000000000000000010201216313063400234170ustar00rootroot00000000000000include(../common_actions.pri) include(actions/actions.pri) include(code/code.pri) TARGET = ActionPackData QT += script network sql HEADERS += actionpackdata.h INCLUDEPATH += ../../3rdparty/rudeconfig LIBS += -L../.. -lrudeconfig win32:LIBS += -ladvapi32 \ -lshell32 TRANSLATIONS = ../../locale/actionpackdata_fr_FR.ts RESOURCES += \ actionpackdata.qrc unix { locales.path = $${PREFIX}/share/actionaz/locale locales.files = ../../locale/actionpackdata_fr_FR.qm locales.CONFIG = no_check_exist INSTALLS += locales } actionaz-3.7.0/actions/actionpackdata/actionpackdata.qrc000066400000000000000000000011441216313063400234130ustar00rootroot00000000000000 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 actionaz-3.7.0/actions/actionpackdata/actions/000077500000000000000000000000001216313063400213765ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdata/actions/actions.pri000066400000000000000000000023141216313063400235520ustar00rootroot00000000000000HEADERS += 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 SOURCES += actions/readtextfileinstance.cpp \ actions/readregistryinstance.cpp \ actions/writeregistryinstance.cpp \ actions/writetextfileinstance.cpp \ actions/webdownloadinstance.cpp \ actions/readenvironmentinstance.cpp \ actions/readinifileinstance.cpp actionaz-3.7.0/actions/actionpackdata/actions/copyfiledefinition.h000066400000000000000000000053551216313063400254420ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/copyfileinstance.h000066400000000000000000000043541216313063400251140ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readbinaryfiledefinition.h000066400000000000000000000051021216313063400265760ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readbinaryfileinstance.h000066400000000000000000000042401216313063400262540ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readclipboarddefinition.h000066400000000000000000000042261216313063400264170ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readclipboardinstance.h000066400000000000000000000027341216313063400260750ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readenvironmentdefinition.h000066400000000000000000000070351216313063400270250ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readenvironmentinstance.cpp000066400000000000000000000046411216313063400270340ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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' foreach(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(); } } actionaz-3.7.0/actions/actionpackdata/actions/readenvironmentinstance.h000066400000000000000000000025521216313063400265000ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readinifiledefinition.h000066400000000000000000000100151216313063400260700ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readinifileinstance.cpp000066400000000000000000000066671216313063400261210ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 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; } rude::Config config; if(!config.load(filename.toLocal8Bit())) { setCurrentParameter("filename"); emit executionException(UnableToReadFileException, tr("Unable to read the file")); return; } if(mode == WholeFile) { QHash fileContent; int sectionCount = config.getNumSections(); for(int sectionIndex = 0; sectionIndex < sectionCount; ++sectionIndex) { QString sectionName = QString::fromLatin1(config.getSectionNameAt(sectionIndex)); if(!config.setSection(sectionName.toLatin1(), false)) { emit executionException(UnableToReadFileException, tr("Unable to read the file")); return; } int parameterCount = config.getNumDataMembers(); for(int parameterIndex = 0; parameterIndex < parameterCount; ++parameterIndex) { QString parameterName = QString::fromLatin1(config.getDataNameAt(parameterIndex)); QString parameterValue = QString::fromLatin1(config.getStringValue(parameterName.toLatin1())); fileContent[sectionName + "/" + parameterName] = parameterValue; } } setArrayKeyValue(variable, fileContent); } else { QString section = evaluateString(ok, "section"); QString parameter = evaluateString(ok, "parameter"); if(!ok) return; if(!config.setSection(section.toLatin1(), false)) { setCurrentParameter("section"); emit executionException(UnableToFindSectionException, tr("Unable to find the section named \"%1\"").arg(section)); return; } setVariable(variable, QString::fromLatin1(config.getStringValue(parameter.toLatin1()))); } emit executionEnded(); } } actionaz-3.7.0/actions/actionpackdata/actions/readinifileinstance.h000066400000000000000000000026561216313063400255600ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readregistrydefinition.h000066400000000000000000000063411216313063400263300ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readregistryinstance.cpp000066400000000000000000000044611216313063400263400ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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_WS_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_WS_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(); } } actionaz-3.7.0/actions/actionpackdata/actions/readregistryinstance.h000066400000000000000000000026261216313063400260060ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readtextfiledefinition.h000066400000000000000000000077201216313063400263060ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/readtextfileinstance.cpp000066400000000000000000000055521216313063400263160ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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(); } } actionaz-3.7.0/actions/actionpackdata/actions/readtextfileinstance.h000066400000000000000000000026101216313063400257530ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/webdownloaddefinition.h000066400000000000000000000107551216313063400261350ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/webdownloadinstance.cpp000066400000000000000000000100211216313063400261260ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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(); } } actionaz-3.7.0/actions/actionpackdata/actions/webdownloadinstance.h000066400000000000000000000035071216313063400256060ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writebinaryfiledefinition.h000066400000000000000000000050631216313063400270230ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writebinaryfileinstance.h000066400000000000000000000040721216313063400264760ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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"); QVariant data = evaluateVariant(ok, "data"); if(!ok) return; mData = data.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 actionaz-3.7.0/actions/actionpackdata/actions/writeclipboarddefinition.h000066400000000000000000000041601216313063400266330ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writeclipboardinstance.h000066400000000000000000000026541216313063400263150ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writeinifiledefinition.h000066400000000000000000000057601216313063400263220ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writeinifileinstance.h000066400000000000000000000042321216313063400257670ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 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)) { setCurrentParameter("filename"); emit executionException(UnableToWriteFileException, tr("Unable to write to the file")); return; } emit executionEnded(); } private: bool write(const QString &filename, const QString §ion, const QString ¶meter, const QString &value) { rude::Config config; config.setConfigFile(filename.toLocal8Bit()); config.load(); if(!config.setSection(section.toLatin1(), true)) return false; config.setStringValue(parameter.toLatin1(), value.toLatin1()); if(!config.save()) return false; return true; } Q_DISABLE_COPY(WriteIniFileInstance) }; } #endif // WRITEINIFILEINSTANCE_H actionaz-3.7.0/actions/actionpackdata/actions/writeregistrydefinition.h000066400000000000000000000061221216313063400265440ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writeregistryinstance.cpp000066400000000000000000000033161216313063400265550ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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_WS_WIN #include #endif namespace Actions { void WriteRegistryInstance::startExecution() { #ifdef Q_WS_WIN bool ok = true; ActionTools::Registry::Key key = evaluateListElement(ok, ReadRegistryInstance::keys, "key"); QString subKey = evaluateString(ok, "subKey"); QString value = evaluateString(ok, "value"); QVariant data = evaluateVariant(ok, "data"); if(!ok) return; switch(ActionTools::Registry::write(data, 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(); } } actionaz-3.7.0/actions/actionpackdata/actions/writeregistryinstance.h000066400000000000000000000025341216313063400262230ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writetextfiledefinition.h000066400000000000000000000056671216313063400265350ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/actions/writetextfileinstance.cpp000066400000000000000000000032611216313063400265300ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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(); } } actionaz-3.7.0/actions/actionpackdata/actions/writetextfileinstance.h000066400000000000000000000026201216313063400261730ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 actionaz-3.7.0/actions/actionpackdata/code/000077500000000000000000000000001216313063400206505ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdata/code/clipboard.cpp000066400000000000000000000067041216313063400233220ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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()); } bool Clipboard::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(Clipboard *otherClipboard = qobject_cast(object)) return (otherClipboard == this); return false; } 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); } } actionaz-3.7.0/actions/actionpackdata/code/clipboard.h000066400000000000000000000035401216313063400227620ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; 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 actionaz-3.7.0/actions/actionpackdata/code/code.pri000066400000000000000000000005751216313063400223050ustar00rootroot00000000000000HEADERS += 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 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 actionaz-3.7.0/actions/actionpackdata/code/file.cpp000066400000000000000000000453521216313063400223040ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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_WS_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); } bool File::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(File *otherFile = qobject_cast(object)) return (otherFile == this || &otherFile->mFile == &mFile); return false; } 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_WS_X11 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_WS_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_WS_X11 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_WS_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_WS_X11 movePrivate(source, destination, noErrorDialog, noConfirmDialog, noProgressDialog, allowUndo, createDestinationDirectory, context, engine); #endif #ifdef Q_WS_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_WS_X11 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_WS_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_WS_X11 Q_UNUSED(error) return QString(); #endif #ifdef Q_WS_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 } } actionaz-3.7.0/actions/actionpackdata/code/file.h000066400000000000000000000077711216313063400217540ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; 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 actionaz-3.7.0/actions/actionpackdata/code/inifile.cpp000066400000000000000000000115361216313063400230010ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 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() == "delimiter") iniFile->mConfig.setDelimiter(it.value().toInt32()); else if(it.name() == "commentCharacter") iniFile->mConfig.setCommentCharacter(it.value().toInt32()); else if(it.name() == "encoding") iniFile->mEncoding = static_cast(it.value().toInt32()); } return CodeClass::constructor(iniFile, context, engine); } IniFile::IniFile() : CodeClass(), mEncoding(Native) { } bool IniFile::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(IniFile *otherIniFile = qobject_cast(object)) return (otherIniFile == this); return false; } QScriptValue IniFile::load(const QString &filename) { if(!mConfig.load(toEncoding(filename, mEncoding))) { throwError("LoadFileError", tr("Cannot load the file")); return thisObject(); } return thisObject(); } QScriptValue IniFile::save(const QString &filename) { bool saveResult; if(filename.isEmpty()) saveResult = mConfig.save(); else saveResult = mConfig.save(toEncoding(filename, mEncoding)); if(!saveResult) { throwError("SaveFileError", tr("Cannot save the file")); return thisObject(); } return thisObject(); } QScriptValue IniFile::clear() { mConfig.clear(); return thisObject(); } QScriptValue IniFile::preserveDeletedData(bool preserve) { mConfig.preserveDeletedData(preserve); return thisObject(); } QScriptValue IniFile::setDelimiter(char delimiter) { mConfig.setDefaultDelimiter(delimiter); return thisObject(); } QScriptValue IniFile::setCommentCharacter(char commentchar) { mConfig.setDefaultCommentCharacter(commentchar); return thisObject(); } QScriptValue IniFile::setSection(const QString §ionName, bool create) { if(!mConfig.setSection(toEncoding(sectionName, mEncoding), create)) { throwError("FindSectionError", tr("Cannot find the section named \"%1\"").arg(sectionName)); return thisObject(); } return thisObject(); } QScriptValue IniFile::setEncoding(Encoding encoding) { mEncoding = encoding; return thisObject(); } QString IniFile::sectionAt(int sectionIndex) const { if(sectionIndex < 0 || sectionIndex >= mConfig.getNumSections()) { throwError("FindSectionError", tr("Invalid section index")); return QString(); } return mConfig.getSectionNameAt(sectionIndex); } QScriptValue IniFile::deleteSection(const QString §ionName) { if(!mConfig.deleteSection(toEncoding(sectionName, mEncoding))) { throwError("FindSectionError", tr("Cannot delete section named \"%1\"").arg(sectionName)); return thisObject(); } return thisObject(); } int IniFile::sectionCount() const { return mConfig.getNumSections(); } bool IniFile::keyExists(const QString &keyName) const { return mConfig.exists(toEncoding(keyName, mEncoding)); } QString IniFile::keyAt(int keyIndex) const { if(keyIndex < 0 || keyIndex >= static_cast(mConfig.getNumDataMembers())) { throwError("FindSectionError", tr("Invalid key index")); return QString(); } return mConfig.getDataNameAt(keyIndex); } QString IniFile::keyValue(const QString &keyName) const { return mConfig.getStringValue(toEncoding(keyName, mEncoding)); } QScriptValue IniFile::setKeyValue(const QString &keyName, const QString &value) { mConfig.setStringValue(toEncoding(keyName, mEncoding), toEncoding(value, mEncoding)); return thisObject(); } QScriptValue IniFile::deleteKey(const QString &keyName) { if(!mConfig.deleteData(toEncoding(keyName, mEncoding))) { throwError("FindSectionError", tr("Cannot delete key named \"%1\"").arg(keyName)); return thisObject(); } return thisObject(); } size_t IniFile::keyCount() const { return mConfig.getNumDataMembers(); } } actionaz-3.7.0/actions/actionpackdata/code/inifile.h000066400000000000000000000040271216313063400224430ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; QScriptValue load(const QString &filename); QScriptValue save(const QString &filename = QString()); QScriptValue clear(); QScriptValue preserveDeletedData(bool preserve); QScriptValue setDelimiter(char delimiter); QScriptValue setCommentCharacter(char commentchar); 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); size_t keyCount() const; private: rude::Config mConfig; Encoding mEncoding; }; } #endif // INIFILE_H actionaz-3.7.0/actions/actionpackdata/code/registry.cpp000066400000000000000000000271031216313063400232270ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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_WS_WIN #include #endif namespace Code { QScriptValue Registry::constructor(QScriptContext *context, QScriptEngine *engine) { return CodeClass::constructor(new Registry, context, engine); } Registry::Registry() : CodeClass() #ifdef Q_WS_WIN , mHKey(0) , mRootKey(ClassesRoot) #endif { } Registry::~Registry() { #ifdef Q_WS_WIN RegCloseKey(mHKey); #endif } bool Registry::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(Registry *otherRegistry = qobject_cast(object)) return (otherRegistry == this); return false; } QScriptValue Registry::openKey(Key key, const QString &subKey) { #ifdef Q_WS_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_WS_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_WS_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; foreach(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_WS_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_WS_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_WS_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_WS_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_WS_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_WS_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_WS_WIN RegCloseKey(mHKey); deleteKey(mRootKey, mSubKey); #endif return thisObject(); } QScriptValue Registry::closeKey() const { #ifdef Q_WS_WIN RegCloseKey(mHKey); #endif return thisObject(); } #ifdef Q_WS_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 } actionaz-3.7.0/actions/actionpackdata/code/registry.h000066400000000000000000000037251216313063400227000ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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_WS_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; 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_WS_WIN HKEY enumToKey(Key key) const; HKEY mHKey; Key mRootKey; QString mSubKey; #endif }; } #endif // REGISTRY_H actionaz-3.7.0/actions/actionpackdata/code/sql.cpp000066400000000000000000000154111216313063400221550ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; foreach(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); } bool Sql::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(Sql *otherSql = qobject_cast(object)) return (otherSql == this || otherSql->mDatabase == mDatabase); return false; } 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) { if(!queryString.isEmpty()) { mQuery = QSqlQuery(queryString, *mDatabase); mQuery.setForwardOnly(true); } if(!mQuery.exec()) { 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(); } } } actionaz-3.7.0/actions/actionpackdata/code/sql.h000066400000000000000000000037501216313063400216250ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; 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 actionaz-3.7.0/actions/actionpackdata/code/tcp.cpp000066400000000000000000000130451216313063400221450ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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() { } bool Tcp::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(Tcp *otherTcp = qobject_cast(object)) return (otherTcp == this || otherTcp->mTcpSocket == mTcpSocket); return false; } 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()); } } actionaz-3.7.0/actions/actionpackdata/code/tcp.h000066400000000000000000000067421216313063400216200ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; 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 actionaz-3.7.0/actions/actionpackdata/code/tcpserver.cpp000066400000000000000000000053371216313063400234010ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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(); } bool TcpServer::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(TcpServer *otherTcpServer = qobject_cast(object)) return (otherTcpServer == this || &otherTcpServer->mTcpServer == &mTcpServer); return false; } 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()); } } actionaz-3.7.0/actions/actionpackdata/code/tcpserver.h000066400000000000000000000034521216313063400230420ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; 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 actionaz-3.7.0/actions/actionpackdata/code/udp.cpp000066400000000000000000000101641216313063400221460ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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() { } bool Udp::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(Udp *otherUdp = qobject_cast(object)) return (otherUdp == this || otherUdp->mUdpSocket == mUdpSocket); return false; } 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()); } } actionaz-3.7.0/actions/actionpackdata/code/udp.h000066400000000000000000000056551216313063400216240ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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; QScriptValue connect(const QString &hostname, quint16 port, OpenMode openMode = ReadWrite); QScriptValue waitForConnected(int waitTime = 30000); QScriptValue waitForReadyRead(int waitTime = 30000); QScriptValue write(const QScriptValue &data); QScriptValue writeText(const QString &data, Encoding encoding = Native); QScriptValue read(); QString readText(Encoding encoding = Native); QScriptValue disconnect(); private slots: void connected(); void disconnected(); void readyRead(); void error(QAbstractSocket::SocketError socketError); private: QUdpSocket *mUdpSocket; QScriptValue mOnConnected; QScriptValue mOnDisconnected; QScriptValue mOnReadyRead; QScriptValue mOnError; }; } #endif // UDP_H actionaz-3.7.0/actions/actionpackdata/code/web.cpp000066400000000000000000000145611216313063400221400ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "web.h" #include "code/image.h" #include "code/rawdata.h" #include "file.h" #include #include #include #include #include #include #include namespace Code { QScriptValue Web::constructor(QScriptContext *context, QScriptEngine *engine) { Web *web = new Web; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "onFinished") web->mOnFinished = it.value(); else if(it.name() == "onDownloadProgress") web->mOnDownloadProgress = it.value(); else if(it.name() == "onError") web->mOnError = it.value(); else if(it.name() == "file") web->mFileValue = it.value(); } return CodeClass::constructor(web, context, engine); } Web::Web() : CodeClass(), mNetworkAccessManager(new QNetworkAccessManager(this)), mNetworkReply(0), mFile(0), mCloseFile(false), mIsDownloading(false) { QObject::connect(mNetworkAccessManager, SIGNAL(authenticationRequired(QNetworkReply *, QAuthenticator *)), this, SLOT(authenticationRequired(QNetworkReply *, QAuthenticator *))); } Web::~Web() { } bool Web::equals(const QScriptValue &other) const { if(other.isUndefined() || other.isNull()) return false; QObject *object = other.toQObject(); if(Web *otherWeb = qobject_cast(object)) return (otherWeb == this || otherWeb->mNetworkAccessManager == mNetworkAccessManager); return false; } QScriptValue Web::download(const QString &urlString, const QScriptValue &options) { mData.clear(); if(mFileValue.isValid()) { if(Code::File *file = qobject_cast(mFileValue.toQObject())) mFile = file->file(); else mFile = new QFile(mFileValue.toString(), this); mCloseFile = false; if(!mFile->isOpen()) { if(!mFile->open(QIODevice::WriteOnly)) { throwError("OpenFileError", tr("Unable to open the destination file")); return thisObject(); } mCloseFile = true; } } QUrl url(urlString); if(url.scheme() == QString()) url = QUrl("http://" + urlString, QUrl::TolerantMode); QNetworkRequest request; QScriptValueIterator it(options); Method method = Get; QByteArray postData; while(it.hasNext()) { it.next(); if(it.name() == "rawHeaders") { QScriptValueIterator headerIt(it.value()); while(headerIt.hasNext()) { headerIt.next(); request.setRawHeader(headerIt.name().toUtf8(), headerIt.value().toString().toUtf8()); } } else if(it.name() == "method") { method = static_cast(it.value().toInt32()); } else if(it.name() == "postData") { QScriptValueIterator postDataIt(it.value()); QUrl postDataParameters; while(postDataIt.hasNext()) { postDataIt.next(); postDataParameters.addQueryItem(postDataIt.name(), postDataIt.value().toString()); } postData = postDataParameters.encodedQuery(); } else if(it.name() == "query") { QScriptValueIterator queryIt(it.value()); while(queryIt.hasNext()) { queryIt.next(); url.addQueryItem(queryIt.name(), queryIt.value().toString()); } } else if(it.name() == "user") { mUser = it.value().toString(); } else if(it.name() == "password") { mPassword = it.value().toString(); } } request.setUrl(url); switch(method) { case Post: mNetworkReply = mNetworkAccessManager->post(request, postData); break; case Get: default: mNetworkReply = mNetworkAccessManager->get(request); break; } QObject::connect(mNetworkReply, SIGNAL(finished()), this, SLOT(finished())); QObject::connect(mNetworkReply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64))); QObject::connect(mNetworkReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error())); QObject::connect(mNetworkReply, SIGNAL(readyRead()), this, SLOT(readyRead())); mIsDownloading = true; return thisObject(); } bool Web::isDownloading() const { return mIsDownloading; } QScriptValue Web::toImage() const { return Image::constructor(QImage::fromData(mData), engine()); } QScriptValue Web::toText(Encoding encoding) const { return fromEncoding(mData, encoding); } QScriptValue Web::toRawData() const { return RawData::constructor(mData, engine()); } QScriptValue Web::cancel() { if(!mNetworkReply) return thisObject(); mNetworkReply->abort(); return thisObject(); } void Web::finished() { if(!mNetworkReply) return; if(mFileValue.isValid() && mFile) { if(mCloseFile) { mFile->close(); mFile->deleteLater(); } mFile = 0; } else mData = mNetworkReply->readAll(); if(mOnFinished.isValid()) mOnFinished.call(thisObject()); mNetworkReply->deleteLater(); mNetworkReply = 0; mIsDownloading = false; } void Web::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { if(bytesTotal == -1) return; if(mOnDownloadProgress.isValid()) mOnDownloadProgress.call(thisObject(), QScriptValueList() << static_cast(bytesReceived) << static_cast(bytesTotal)); } void Web::error() { if(!mNetworkReply) return; if(mNetworkReply->error() == QNetworkReply::OperationCanceledError) return; if(mOnError.isValid()) mOnError.call(thisObject(), QScriptValueList() << mNetworkReply->errorString()); } void Web::authenticationRequired(QNetworkReply *, QAuthenticator *authenticator) { authenticator->setUser(mUser); authenticator->setPassword(mPassword); } void Web::readyRead() { if(mFileValue.isValid() && mFile) mFile->write(mNetworkReply->readAll()); } } actionaz-3.7.0/actions/actionpackdata/code/web.h000066400000000000000000000054141216313063400216020ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #ifndef WEB_H #define WEB_H #include "code/codeclass.h" #include #include class QNetworkAccessManager; class QNetworkReply; class QAuthenticator; class QFile; namespace Code { class Web : public CodeClass { Q_OBJECT Q_ENUMS(Method) Q_PROPERTY(QScriptValue onFinished READ onFinished WRITE setOnFinished) Q_PROPERTY(QScriptValue onDownloadProgress READ onDownloadProgress WRITE setOnDownloadProgress) Q_PROPERTY(QScriptValue onError READ onError WRITE setOnError) public: enum Method { Get, Post }; static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Web(); ~Web(); void setOnFinished(const QScriptValue &onFinished) { mOnFinished = onFinished; } void setOnDownloadProgress(const QScriptValue &onDownloadProgress) { mOnDownloadProgress = onDownloadProgress; } void setOnError(const QScriptValue &onError) { mOnError = onError; } QScriptValue onFinished() const { return mOnFinished; } QScriptValue onDownloadProgress() const { return mOnDownloadProgress; } QScriptValue onError() const { return mOnError; } public slots: QString toString() const { return "Web"; } virtual bool equals(const QScriptValue &other) const; QScriptValue download(const QString &urlString, const QScriptValue &options = QScriptValue()); bool isDownloading() const; QScriptValue toImage() const; QScriptValue toText(Encoding encoding = Native) const; QScriptValue toRawData() const; QScriptValue cancel(); private slots: void finished(); void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); void error(); void authenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator); void readyRead(); private: QNetworkAccessManager *mNetworkAccessManager; QNetworkReply *mNetworkReply; QScriptValue mOnFinished; QScriptValue mOnDownloadProgress; QScriptValue mOnError; QScriptValue mFileValue; QFile *mFile; bool mCloseFile; QByteArray mData; bool mIsDownloading; QString mUser; QString mPassword; }; } #endif // WEB_H actionaz-3.7.0/actions/actionpackdata/icons/000077500000000000000000000000001216313063400210515ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdata/icons/copyfile.png000066400000000000000000000012411216313063400233670ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME :u!IDATXAn0g8 ]p'鮧 zn DbKZVEJKdO7 cǦ}zZpc`Iju݇s"":sq8,"1>-wnKL|~=$*`b۶p"UURc̅" H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-bKGD pHYs  tIME  +WKIDATXå[L2Ln&KSO˫1mӴ&}m65iҴ}1՗&MOIsh9åZT,7|:dDdfvZ{ˆoY!DxsƍBx(H)W{>T3l7FZR.Bĉ+H't񢵬~c/F(sVh|`YƇBU(!u]TUM{Q MQ[ٰ0CqB~۟]{v޿SVUSMN'wRa^N:E0$??gϮнHa LA!uD,ɜ@Nǝ(B󴷷ܜѺp]k׮Q'hAD@jUE@U$]w9;|]U{8rk@yRJݟ~06 ~|~fϸ|235>C\mB~}.gB( kh ee8K M´LLgغM1 *~_/vZ[[Gzx61H03<\U" -j .i"Sr| wC56vر5dxcO'3##ħg`Xz&;@ttà00 /cӁrzޏf* # e-{BB^MuXFR#y┝}+M/J8zccFTCCSUjTnMS1 2hiY* ̦GSsC 8=5WL"+3̬,|a9W\ehNwW7 Æ@]b[X[m5P[X9:(L̬XuWټiB@K`brrw 9]~1LYU)A[F}8K7CIN^4iP|k655bdJN~Bz : %j/ /G1%D‹gNYvjfd% BcG}w455% zn/0Mh|Xd'/'#H; QDQ< F*PPP1OZh ē}eIT4M… /'8QxEE(BC N<ϼan߾M__RJfY>L'  |Kz*B֭[3==ͮ]yL|fll@a#=gǖ8ƕnI:s 444 z;(((1oA Kr oIHۗu6 q<.ulP<諠OE""ʻ Jᓖ 7΃l&<ӧX Ӎd#a"#=鯧xJ"12@Q$S0l<ؐCܵ)( 8u=g/]DOOi8w\RPMl&İ1'?ˏw;wm﷥;9*IjDI8\W._AC skH)D"\xaj `<{*rnBbI AmE$b}K*//gvv췆`+BCҽ0^#..{躆%}AEAEZ¥i<o2w TMH|U}0$}}n|Ҹ*aV%֣;Sp ,IENDB`actionaz-3.7.0/actions/actionpackdata/icons/readclipboard.png000066400000000000000000000040321216313063400243510ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME  .WT\IDATXå[^Uk}wozh)P\jA!!Ѥ 1DA}7L&>|0FPX[lRezv|sZ>|3bG8ɹ߿|-~ٗQ{wl+nj_:G.okh.:R3SSΑ65t*,8Ӛ88vL_n4lYi ڱ>xu7>uKnaGowt'7,SE6#Kw]j3#{;8oEY M(]f; S;>ԠHsI28WR2v~ΩaPu_{Zǔv!G=pׯpY ^LKwqffk/ dx4<A" Go{`ku'i.$-H*$^E!4DVm\}#Q %)KN J",b!8wlp5s-#:v Г.3wj4@NUFxQ\^$e@OfӻZ;\6̌OSװ̰<#f 36MJՀ`Ыu ܱ[õKX-ժWC ]T1PG@\R}b"]VLc3W-ۥOJ`RuPehTf~> ^8:$lg3sNgc'7|{6>;ݞrdՍY%j1!H Qbhk,dyF#Y>wEb"lhuVn[q<~fIbOy}黟~]e+l6h%0C#1 AiԨKnSn̏lͺoǻʳ+Y|?%˖$m7ITJپaƊ1N㨨 ԥU~x.n"S(Ҙq7^<0=s?ڭ_|脆k<ղ_M7B,c93ﴡ|ϗ5O8ZL;ˀHPtmu=,$N 5o2(e(,\zuI(͋( QA5 UjС(K_ERU5swZ\PWTE "9zqw7sPpdI,ob*o2DxrKP/b]\ wpJJ#Qros"PD<%? Uܤ-mڴ(IBD .Dp>r!wi,8G.*\L BFi2"ZsLҕs~{2A2 ,Y!.**YIu) }yIڥ9s1#.̕PsW17L\ԥ-A^ѭvI)˄`.2 qGUbB$twJK}7G;` ]/ҕNCYh;"é_GK7uf3,h3 /%1"T !`65BfyԱ?1%3w yiaQ+S+{ct9,hIVfyWDSKC}|VVR}b!NOnE,,wRf qw;"*x&e2]e>B ~ #֮LxġW\HxsXQYl]]8<ƒ:H]> 4g"IENDB`actionaz-3.7.0/actions/actionpackdata/icons/readenvironment.png000066400000000000000000000040321216313063400247560ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME  .WT\IDATXå[^Uk}wozh)P\jA!!Ѥ 1DA}7L&>|0FPX[lRezv|sZ>|3bG8ɹ߿|-~ٗQ{wl+nj_:G.okh.:R3SSΑ65t*,8Ӛ88vL_n4lYi ڱ>xu7>uKnaGowt'7,SE6#Kw]j3#{;8oEY M(]f; S;>ԠHsI28WR2v~ΩaPu_{Zǔv!G=pׯpY ^LKwqffk/ dx4<A" Go{`ku'i.$-H*$^E!4DVm\}#Q %)KN J",b!8wlp5s-#:v Г.3wj4@NUFxQ\^$e@OfӻZ;\6̌OSװ̰<#f 36MJՀ`Ыu ܱ[õKX-ժWC ]T1PG@\R}b"]VLc3W-ۥOJ`RuPehTf~> ^8:$lg3sNgc'7|{6>;ݞrdՍY%j1!H Qbhk,dyF#Y>wEb"lhuVn[q<~fIbOy}黟~]e+l6h%0C#1 AiԨKnSn̏lͺoǻʳ+Y|?%˖$m7ITJپaƊ1N㨨 ԥU~x.n"S(Ҙq7^<0=s?ڭ_|脆k<ղ_M7B,c93ﴡ|ϗ5O8ZL;ˀHPtmu=,$N 5o2(e(,\zuI(͋( QA5 UjС(K_ERU5swZ\PWTE "9zqw7sPpdI,ob*o2DxrKP/b]\ wpJJ#Qros"PD<%? Uܤ-mڴ(IBD .Dp>r!wi,8G.*\L BFi2"ZsLҕs~{2A2 ,Y!.**YIu) }yIڥ9s1#.̕PsW17L\ԥ-A^ѭvI)˄`.2 qGUbB$twJK}7G;` ]/ҕNCYh;"é_GK7uf3,h3 /%1"T !`65BfyԱ?1%3w yiaQ+S+{ct9,hIVfyWDSKC}|VVR}b!NOnE,,wRf qw;"*x&e2]e>B ~ #֮LxġW\HxsXQYl]]8<ƒ:H]> 4g"IENDB`actionaz-3.7.0/actions/actionpackdata/icons/readini.png000066400000000000000000000031761216313063400232010ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME  IDATXåOlU3sg16q QD$iR9fѨH] uWjR]DvJm7BCHE6!{?l4|ߙs A|kX=lԗzwZG-8r-"B5"2\r7E@)e 6=C_8W bhhh Rxd 7o?ϝ0iSyVmӏ<"ʸxCDȲ92PJ1vc.05=t(iSO"",gGyqSKgk#rb}8lL:)LN$>eL2m8g h$_|f+'@)ũ'yJH* >q'q PUsy?1ֹ{L88,x8I: \'&ڱIbw6&)qۘw׷DZQ<90Lܾf9}ܷ?Wݶ $If'Q|;Ggbx|QiyN>~mۯJ@AfIRc}M%7i3"\rrՠbI/k`qsάo&(!hQ5fYJBӳ g-"<lvJ,SLX6uIؠc,E()eC}klD Ar2#B4N!%` `5LI!R eP,߀`&zYGB6B rryrI,*FEJEP P/)֊k CwRB*)*ҊHLOJw{uT*,m!d`k#RIPQTV|M=zo!z2iBB@u?WNYUcb=V[GR+cHwJz|/Q{IENDB`actionaz-3.7.0/actions/actionpackdata/icons/readregistry.png000066400000000000000000000057641216313063400242770ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME  4uq tIDATXÕYp}?KW˕+ " 0 ۀ 6tl38qd}'m<ӗf:Kg%݌k X,6$@ҕt%]IwڇMy;>'ѱ&˲ֻӿn۔qM4]X!k׀;wF79ukjbP(xnjt˭R gsb3iR(B!@0ށ/[_|nwe?x<+.80-g߆k"t\b$VnHgLfosK߲y҂U ρ3IQ.YZ) 1lfO^v& @WU`rk!\Eg2 03-?o?P@3׸=;J>OjGvua{ۣ!hB(,-/n}s ^#) jP C1 mَC AB$..oٴ`2^P{K.^̪Y6m ˲݅q,&.j0 wG(V$BeZ%ZZvzkMmљ5n J2Ss}2WgH^#.@4OEQPWjU uLޣXlqlu=)HOe27tA(+]F KT++89k  \C@Q%BX^)%TR>@nQlkڎ'0b1tImyaZRX,.+c8)yEH] RW8(R(!{P1*na0[ׇ@Uٙ\v}#'2KQ%jPE #D O(T$"!wR[B3T|}pUŹ*N ^! 5|R=?q>:}n6o|]οɞ{cP@[un'HOvu8u ].ޝz{j \.; ns+O?4 s z]AM4g8XN_ A""Fhċzu&&{p8۰|Kl%a"h]/_ai!!.|v[<Ӵ660|!MR0&ՒMuJaH4_|qO?9]ccV]>o0W &Ӝ:yy _WRiԊ"D٢Q-SrUfgt'۩E8~+zw9&ˬ/,FؾvE=FjrUFGN1VrH@c"ڵkay)W(Wn߾bjL4HEiRؾOPu,LYX%jc?+s0,*@M@rnnnw|~y?Ϸm}GxOTv,,MeʒpTr{oR @ Z] VAlJffg;Pi^XY؎c8x‘՗j(;:;rgV&H)[y'W00PJd~oM$ _GQeECP2mMm<ªJ)/-NWՐ]A`n%~0T@{c:_-`^lfYv<IENDB`actionaz-3.7.0/actions/actionpackdata/icons/readtext.png000066400000000000000000000033551216313063400234050ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME "LpFmIDATXåo?;3'1 GZ5yhZUEC}PU}S_U$8%LRJ `H^{ۇ5v4;gs{7X~oC_pYwp?EŌy3O=֋NPѥ/.`[{f+b`?/޵k0ID"mf/OKh,I(^Cs8vXo9._V9)>{2F:Lm0LݹR A)չzhqn<čܞJ^j`r )ãzN˭  yZ0 {ByZtF).p|hAy d/>-!l6 Ð Ww.M~u&o@o GiVgsd^1.PBb#VcZ?eLaƞgͥkU*/4أT#JQiʑA^nB(-ZTp~<7xuCvJ3$O0X @W` S-釉|9daS/? <E` ~P"(iC]0./9=0J1> F7l+,J+8Mq hKV6LLL#Jaf`9Ri#SDhUc. :+v<7?0voF#//8CL HgDP^dpҲ-RǭѤA o+ƙpA9(3bIhbA,uIK-B+7撎#;`zz x=Ռx$Zc 4e94쭚M•LIkbuFKIlB$dEgަx870U.Ԕ4 UDBd#lE?@gBA&ʴYE,=Aơ~Л.D;P(t>L},u]8#h ;:6k:P(م,K@喌 3]} †38s̻9y A(RʿvVJ+Ol]BW![UlZyfFߟXxWUyيf~IENDB`actionaz-3.7.0/actions/actionpackdata/icons/webdownload.png000077500000000000000000000050621216313063400240720ustar00rootroot00000000000000PNG  IHDR szz IDATXŗypU?}{,$JQ"b\R).0Z+JE(T놢CYDH%/o[?n=3Ǚ{>{~{~?a&ϡW M0t H\Ҹ#R+yg.1ts0'I{)]8\npXF8;@ʄfB4 ִ9W"D 9~S%ɸ?Oh ͋^?n9^(tΩis-곣jYq՛B)Xƍ`č>Y{?zCz}[2+^6 rVhZ[KK܋bn@A'?S_RA{ىd.@]󳏥EsG>PdNl:K }F^׳VftLhRP`{p2;Al~m {)c411{ZVC@9B)ȴ`Q&| U `l=Nɺ{hޟ~{4Y ^Ќ*'i[V/]HJpdTOKSs'/~@[+}Pnli"ɩa h&^k0,b`f0E7 8(A|/qX|eJ|,?"ˏ٩ ;$@1svf3e BFv8fCPx)qB8e)aqQ¡ h#'?H_vWwC|N^ BG AUȧL)A" ƹEٌ k? }L.cv2)o͚b˜R,ظd8zMÃ:IhAk?t'`HI< (nFDAHK+=[B`Ӡ>T/΢XaVhn選ÀeCp>}keP 70. $ "1XLO. p%2^{Xrn afJNzc a8w zàz YS1 6XֹzG)TRa WFRv4 %aP iUcݖ cN7ө(tWƿCmo p$ KtdO:$ ۅ&; Mpfd"n4ts4ԇkxՐ )p3H2 IT4ejKoN(A艁_n= G-CP6lLI# uG '@:ht2$<gHx*`^xu7D: ZIN 6 CI#]Vw@a(| =^z'`ɇ}pHpz.`PX/]ܙ0pD3$4CBjS sV2Qf [PFxP@A>r:DT}t`Fv0ΨHteˠICjCTq \l*8 [KjQo$Im&Tu: TGIENDB`actionaz-3.7.0/actions/actionpackdata/icons/writebinary.png000066400000000000000000000110241216313063400241140ustar00rootroot00000000000000PNG  IHDR szz OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3-bKGD pHYs  tIME  f{FIDATXåoT{c0WsNTTUH EjByb% TT"%j.nm330`H>gﵿ6]'#9w9jr}}}c ZkgǑF[c)ERJ !^b۶m3G= ֭[g6ֆkȹ1xy+dc28ƘXÇy!W"RQEYY6\d۷obv dŒ3@Mu5W}>"UUc1e!HIbH)ٿ?.\6GcǏ 山 ~Ja/ZnjBkٳgi&MeYctB1a\^/o'N >{ƽ&= ݻwٳgBH) a:u*p'OdCda"d ٳ),.`0Hgg'LĀ1:%N)1JѦMh!~?>!>}Sc20:ľ}ؽ{7ƀ`Y)i8{G sSc UUU$I,X@uVI,BGxB&aB;~:7&bΙdQm/NM~҂8 _~I^^>Y`2A<Ӧ15n|5yC+)%|yy{lcu- v3qpDx%%q?fb B(N0D7fQ0Bf]xs׬W&ԁ˗_A1J&i~RN$H a>!(n~tk׮}~`dCH$ػw/˗x`t.qeuB h͠\rk==Djjȯ NUCbYn% 0e* , ĕ_)r7oRx1!5o>"(%b,BxYM 8sLgF^\B$`kM 5/c f[lyݰZPSSc xc[ۨ#>/,yaat½IENDB`actionaz-3.7.0/actions/actionpackdata/icons/writeclipboard.png000066400000000000000000000040251216313063400245720ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME  CIDATXíV]]U޹?mgC)@2EZ@$0M|2b|oƒ b-)t~:-0Cܿs{}>;Cvd}Y[Z['/lۦSOL>ao;><{q>sgɓ\ooFc@}6?vc?9][*)+`ҹ-5p8ίyvF'.۳0f3 'O7{Ͻ|Ks~*gvwإ,\̉w.<ƮM?Y NiWbT!zШ+FFdn3.@4CdZJ>FoێqXgK%Xƈd`e>;:'{Fx{fT#J$ܹe Bj\F\F$M1wD.Ifb@fQ .H00 I$IП$6 2b‡=$Hkе GzE H`X rp`P0Q! So\4kG~1F@J#DB%I%ʘeBⲯ|~$ 0+qDVY ;ʻF $!F]q8c nhuOM=-)#\UWnpN3+J`X P.pBB# Ҝ1!1{DlhF `P 1ڞT%f6kO]‰|f}|>v } 6jcG}9IbA=GyaqZ]mCk4 \ׇ7^z }Ρ̈rϗ˳ӧȗ5obSչc{\6Ll~qsd._. tev$^ǁ'HGµ.,8h)_𻥥OiNLl ~f:ټiuFl``Vv) ^=--.gv|A?ꋿv՚1jS۾Hm < 2ρ  A f=<ڇ߿3s-Wό3[ZgF}h5(Bjj$ DP[X fW"T{ΙZI[9G=jj#k:Bl4MX)`Yk6[-X )h)l@:pgՆdttGϊ*3TE$J1B[hC&R*@̨Zzw b" |AF6Mk1DsDRq3c{fO5;! EJIG!V*rwgC2W)W(M|lptWIJ`}߾!)Ӌ8/rgd_ڞM ּHgtɻ3]Β.Ϻ $NlyvpprpS'IENDB`actionaz-3.7.0/actions/actionpackdata/icons/writeini.png000066400000000000000000000031171216313063400234130ustar00rootroot00000000000000PNG  IHDR szzsRGBbKGD pHYs  tIME  7읊IDATXåo?Ɛb(8u vcࡑB%ϼTH@}* H>MdՍC1F %8?XΏ{offq6i4W3=s܁<#VkGNt;Szo q<bkXS*y`jwО>}`RZU C1 l>O_"wMLMM ʀ099yߓbq$J_l1`ٳ7 (Ƚ=lM$ 6 I @k`0KbZ۸ Bc+|gy! 66PJyJ,|8;8ˈ |)skJ)錁`L855ſgg% R(h{'rG!hŀ"q( Wy(9CvL60v8VW * @> Hr]~39_~U <`{HN1$I\p fl۵ d5-yRY˯O?/ یBZ6kɷ@=sܹƻv!jިn]@4jd++`-n v톕Jq]{TֈR7|v8OysOx8}T qU ǘ0d9Yv;Gyo}{С"lΞ.iֻ.&P 8==?sao )╅?RJ3A= yYxT=!0~DQk1:p]pɴ!Gf0/wVw}>Zkk-L`Ul@k:MBH[sIi|jtf?ߺ52޹~}7oH67Sz^뺩:6RyذAj0| ;&^'I?Ez^ziFP []e](}rrL[Uppbss\JQL2X%JBk8|NJ(*KEHa1NuE.=eK_ dgGKaw6P,tkhvhQ&aJ j--݇jDڢdEIt:t(ʽa,v=rh9xB +@x ,NI`DUpv9JBO"V0zmm[0"B 0 $RԐà XgS`HTD!0!MwwwF(2Zr+9:xBTFz/!)@" ĚR8@[h3,8pf)(W QEh &''焠03MRTPԨE5jD5jXm0Z6#Xm2U]#VEk201>1A2g'61.O\zc-tHk"c!EkpB8p8:55H[jFct8@Z 7Z[۪Z^xntDVVV2liii'/{r#:NNq.Kh~w\XVR8T}jKK|ܭ[\{z33;2-[}nfGZH&AZc%˯ #NawtIsg,.e}IZ:;PFGF1BԪӔFǘKp .[?+yOnB%>'AǶ47yJZOn~]Z&=@:QH`ϸO=|z`qqi% G ;wPHg2dWWYgyfR: ,\F>A"AUk?w /`a~^NMB^"WX)R)EQ"- (wY@}<^xfzRUyq/`J>unW٣!و—.]rkJw$!AzJRJU;wn~jgϞ]UA<7i4HE "80e*k8rʪ:W5 \Hfcu\`Fcp@3ƦM nߎskmnZcUsܚ8=#Lvqax\l aR k-J\߆ mnݟ ?S؄  .Jg_:zkhZA@~TC!Р5"ޖlÎɑA9B C w^Hf9 E$bC ᜣ[>kmʁ9"R)072տq sܜcEK@!;1 !ߏmŽKAyr[[GFHMhXPͬ)e^!B^q EhiY\y~e(:Dn`Z% t#!V+YIv*ePH{Q U*|uwzΓ'Ic~vA`)))R(^@Fd'S"ڃ#5:\L+Ģ{p$A"J%3LqS읚ޗ_n,0~8GHuDׂPbb)x|𒉟`㽞pסC,4I(+ޔ3uF?൛& ͿSRVREн95׻-83 F o@DeLƦi`y5j)Q2yӘ3;rkT*d,]NAIg-;EҔDcyT*+:?yJu*bֲi| j.^眼z5l6 ~9j7߿|OսV#0IENDB`actionaz-3.7.0/actions/actionpackdevice/000077500000000000000000000000001216313063400202645ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdevice/actionpackdevice.h000066400000000000000000000042621216313063400237350ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 ACTIONPACKDEVICE_H #define ACTIONPACKDEVICE_H #include "actionpack.h" #include "actions/textdefinition.h" #include "actions/clickdefinition.h" #include "actions/wheeldefinition.h" #include "actions/keydefinition.h" #include "actions/movecursordefinition.h" #include "actions/cursorpathdefinition.h" #include "code/mouse.h" #include "code/keyboard.h" #include namespace ActionTools { class ActionDefinition; } class ActionPackDevice : public QObject, public ActionTools::ActionPack { Q_OBJECT Q_INTERFACES(ActionTools::ActionPack) public: ActionPackDevice() {} void createDefinitions() { addActionDefinition(new Actions::TextDefinition(this)); addActionDefinition(new Actions::ClickDefinition(this)); addActionDefinition(new Actions::WheelDefinition(this)); addActionDefinition(new Actions::KeyDefinition(this)); addActionDefinition(new Actions::MoveCursorDefinition(this)); addActionDefinition(new Actions::CursorPathDefinition(this)); } QString id() const { return "device"; } QString name() const { return tr("Actions dealing with devices like the keyboard or the mouse"); } Tools::Version version() const { return Tools::Version(0, 0, 1); } void codeInit(QScriptEngine *scriptEngine) const { addCodeClass("Mouse", scriptEngine); addCodeClass("Keyboard", scriptEngine); } private: Q_DISABLE_COPY(ActionPackDevice) }; Q_EXPORT_PLUGIN2(ActionPackDevice, ActionPackDevice) #endif // ACTIONPACKDEVICE_H actionaz-3.7.0/actions/actionpackdevice/actionpackdevice.pro000066400000000000000000000010441216313063400243010ustar00rootroot00000000000000include(../common_actions.pri) include(actions/actions.pri) include(code/code.pri) TARGET = ActionPackDevice QT += script HEADERS += actionpackdevice.h \ mousedevice.h \ keyboarddevice.h RESOURCES += actionpackdevice.qrc unix:LIBS += -lXtst win32:LIBS += -luser32 TRANSLATIONS = ../../locale/actionpackdevice_fr_FR.ts SOURCES += mousedevice.cpp \ keyboarddevice.cpp unix { locales.path = $${PREFIX}/share/actionaz/locale locales.files = ../../locale/actionpackdevice_fr_FR.qm locales.CONFIG = no_check_exist INSTALLS += locales } actionaz-3.7.0/actions/actionpackdevice/actionpackdevice.qrc000066400000000000000000000003731216313063400242720ustar00rootroot00000000000000 icons/click.png icons/key.png icons/text.png icons/wheel.png icons/movecursor.png actionaz-3.7.0/actions/actionpackdevice/actions/000077500000000000000000000000001216313063400217245ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdevice/actions/actions.pri000066400000000000000000000007401216313063400241010ustar00rootroot00000000000000HEADERS += actions/wheeldefinition.h \ actions/wheelinstance.h \ actions/keydefinition.h \ actions/keyinstance.h \ actions/movecursorinstance.h \ actions/movecursordefinition.h \ actions/textdefinition.h \ actions/textinstance.h \ actions/clickdefinition.h \ actions/clickinstance.h \ actions/cursorpathdefinition.h \ actions/cursorpathinstance.h SOURCES += actions/textinstance.cpp \ actions/keyinstance.cpp \ actions/clickinstance.cpp actionaz-3.7.0/actions/actionpackdevice/actions/clickdefinition.h000066400000000000000000000103431216313063400252340ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #ifndef CLICKDEFINITION_H #define CLICKDEFINITION_H #include "actiondefinition.h" #include "clickinstance.h" #include "listparameterdefinition.h" #include "numberparameterdefinition.h" #include "positionparameterdefinition.h" #include "groupdefinition.h" #include namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class ClickDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit ClickDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("ClickInstance::buttons", ClickInstance::buttons); translateItems("ClickInstance::actions", ClickInstance::actions); ActionTools::ListParameterDefinition *action = new ActionTools::ListParameterDefinition(ActionTools::Name("action", tr("Action")), this); action->setTooltip(tr("The action to simulate")); action->setItems(ClickInstance::actions); action->setDefaultValue(ClickInstance::actions.second.at(ClickInstance::ClickAction)); addElement(action); ActionTools::ListParameterDefinition *button = new ActionTools::ListParameterDefinition(ActionTools::Name("button", tr("Button")), this); button->setTooltip(tr("The button to simulate")); button->setItems(ClickInstance::buttons); button->setDefaultValue(ClickInstance::buttons.second.at(MouseDevice::LeftButton)); addElement(button); ActionTools::PositionParameterDefinition *position = new ActionTools::PositionParameterDefinition(ActionTools::Name("position", tr("Position")), this); position->setTooltip(tr("The screen position where to simulate a mouse click")); addElement(position); ActionTools::GroupDefinition *clickGroup = new ActionTools::GroupDefinition(this); clickGroup->setMasterList(action); clickGroup->setMasterValues(QStringList() << ClickInstance::actions.first.at(ClickInstance::ClickAction)); ActionTools::NumberParameterDefinition *amount = new ActionTools::NumberParameterDefinition(ActionTools::Name("amount", tr("Amount")), this); amount->setTooltip(tr("The amount of clicks to simulate")); amount->setMinimum(1); amount->setMaximum(std::numeric_limits::max()); amount->setDefaultValue(1); clickGroup->addMember(amount); addElement(clickGroup); ActionTools::PositionParameterDefinition *positionOffset = new ActionTools::PositionParameterDefinition(ActionTools::Name("positionOffset", tr("Offset")), this); positionOffset->setTooltip(tr("The offset to apply to the click position")); addElement(positionOffset, 1); addException(ClickInstance::FailedToSendInputException, tr("Send input failure")); addException(ClickInstance::InvalidActionException, tr("Invalid action")); } QString name() const { return QObject::tr("Click"); } QString id() const { return "ActionClick"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Emulates a mouse click"); } ActionTools::ActionInstance *newActionInstance() const { return new ClickInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/click.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(ClickDefinition) }; } #endif // CLICKDEFINITION_H actionaz-3.7.0/actions/actionpackdevice/actions/clickinstance.cpp000066400000000000000000000054661216313063400252550ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #include "clickinstance.h" #include "consolewidget.h" #include #include namespace Actions { ActionTools::StringListPair ClickInstance::buttons = qMakePair( QStringList() << "left" << "middle" << "right", QStringList() << QT_TRANSLATE_NOOP("ClickInstance::buttons", "Left") << QT_TRANSLATE_NOOP("ClickInstance::buttons", "Middle") << QT_TRANSLATE_NOOP("ClickInstance::buttons", "Right")); ActionTools::StringListPair ClickInstance::actions = qMakePair( QStringList() << "pressRelease" << "press" << "release", QStringList() << QT_TRANSLATE_NOOP("ClickInstance::actions", "Click (press and release)") << QT_TRANSLATE_NOOP("ClickInstance::actions", "Press") << QT_TRANSLATE_NOOP("ClickInstance::actions", "Release")); void ClickInstance::startExecution() { bool ok = true; Action action = evaluateListElement(ok, actions, "action", "value"); MouseDevice::Button button = evaluateListElement(ok, buttons, "button", "value"); QPoint position = evaluatePoint(ok, "position"); QPoint positionOffset = evaluatePoint(ok, "positionOffset"); int amount = evaluateInteger(ok, "amount"); if(!ok) return; if(action != ClickAction) amount = 1; if(amount <= 0) { setCurrentParameter("amount"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid click amount")); return; } position += positionOffset; mMouseDevice.setCursorPosition(position); for(int i = 0; i < amount; ++i) { if(action == ClickAction || action == PressAction) { if(!mMouseDevice.pressButton(button)) { emit executionException(FailedToSendInputException, tr("Unable to emulate click: button event failed")); return; } } if(action == ClickAction || action == ReleaseAction) { if(!mMouseDevice.releaseButton(button)) { emit executionException(FailedToSendInputException, tr("Unable to emulate click: button event failed")); return; } } } QTimer::singleShot(1, this, SIGNAL(executionEnded())); } void ClickInstance::stopLongTermExecution() { mMouseDevice.reset(); } } actionaz-3.7.0/actions/actionpackdevice/actions/clickinstance.h000066400000000000000000000030261216313063400247100ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #ifndef CLICKINSTANCE_H #define CLICKINSTANCE_H #include "actioninstance.h" #include "../mousedevice.h" #include "stringlistpair.h" namespace Actions { class ClickInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Action { ClickAction, PressAction, ReleaseAction }; enum Exceptions { FailedToSendInputException = ActionTools::ActionException::UserException, InvalidActionException }; ClickInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0) : ActionTools::ActionInstance(definition, parent) {} static ActionTools::StringListPair buttons; static ActionTools::StringListPair actions; void startExecution(); void stopLongTermExecution(); private: MouseDevice mMouseDevice; Q_DISABLE_COPY(ClickInstance) }; } #endif // CLICKINSTANCE_H actionaz-3.7.0/actions/actionpackdevice/actions/cursorpathdefinition.h000066400000000000000000000050601216313063400263410ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #ifndef CURSORPATHDEFINITION_H #define CURSORPATHDEFINITION_H #include "actiondefinition.h" #include "cursorpathinstance.h" #include "pointlistparameterdefinition.h" #include "positionparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class CursorPathDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit CursorPathDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::PointListParameterDefinition *path = new ActionTools::PointListParameterDefinition(ActionTools::Name("path", tr("Path")), this); path->setTooltip(tr("The path to follow")); addElement(path); ActionTools::PositionParameterDefinition *positionOffset = new ActionTools::PositionParameterDefinition(ActionTools::Name("positionOffset", tr("Offset")), this); positionOffset->setTooltip(tr("The offset to apply to the path")); addElement(positionOffset, 1); } QString name() const { return QObject::tr("Cursor path"); } QString id() const { return "ActionCursorPath"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Move the mouse cursor on a path"); } ActionTools::ActionInstance *newActionInstance() const { return new CursorPathInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/movecursor.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(CursorPathDefinition) }; } #endif // CURSORPATHDEFINITION_H actionaz-3.7.0/actions/actionpackdevice/actions/cursorpathinstance.h000066400000000000000000000037661216313063400260300ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Contact : jmgr@jmgr.info */ #ifndef CURSORPATHINSTANCE_H #define CURSORPATHINSTANCE_H #include "actioninstance.h" #include "../mousedevice.h" #include #include namespace Actions { class CursorPathInstance : public ActionTools::ActionInstance { Q_OBJECT public: CursorPathInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0) : ActionTools::ActionInstance(definition, parent), mCurrentPoint(0) { connect(&mMoveTimer, SIGNAL(timeout()), this, SLOT(moveToNextPosition())); } void startExecution() { bool ok = true; mPositionOffset = evaluatePoint(ok, "positionOffset"); mPoints = evaluatePolygon(ok, "path"); if(!ok) return; mCurrentPoint = 0; mMoveTimer.start(25); } void stopExecution() { mMoveTimer.stop(); } void stopLongTermExecution() { mMouseDevice.reset(); } private slots: void moveToNextPosition() { if(mCurrentPoint >= mPoints.size()) { emit executionEnded(); mMoveTimer.stop(); } else { mMouseDevice.setCursorPosition(mPoints.at(mCurrentPoint) + mPositionOffset); ++mCurrentPoint; } } private: MouseDevice mMouseDevice; QTimer mMoveTimer; QPoint mPositionOffset; QPolygon mPoints; int mCurrentPoint; Q_DISABLE_COPY(CursorPathInstance) }; } #endif // CURSORPATHINSTANCE_H actionaz-3.7.0/actions/actionpackdevice/actions/keydefinition.h000066400000000000000000000125611216313063400247430ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 KEYDEFINITION_H #define KEYDEFINITION_H #include "actiondefinition.h" #include "keyinstance.h" #include "keyparameterdefinition.h" #include "listparameterdefinition.h" #include "numberparameterdefinition.h" #include "booleanparameterdefinition.h" #include "groupdefinition.h" #include namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class KeyDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit KeyDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { translateItems("KeyInstance::actions", KeyInstance::actions); translateItems("KeyInstance::types", KeyInstance::types); ActionTools::KeyParameterDefinition *key = new ActionTools::KeyParameterDefinition(ActionTools::Name("key", tr("Key")), this); key->setTooltip(tr("The key to simulate")); addElement(key); ActionTools::ListParameterDefinition *action = new ActionTools::ListParameterDefinition(ActionTools::Name("action", tr("Action")), this); action->setTooltip(tr("The action to simulate")); action->setItems(KeyInstance::actions); action->setDefaultValue(KeyInstance::actions.second.at(KeyInstance::PressReleaseAction)); addElement(action); ActionTools::GroupDefinition *pressAndReleaseGroup = new ActionTools::GroupDefinition(this); pressAndReleaseGroup->setMasterList(action); pressAndReleaseGroup->setMasterValues(QStringList() << KeyInstance::actions.first.at(KeyInstance::PressReleaseAction)); ActionTools::NumberParameterDefinition *amount = new ActionTools::NumberParameterDefinition(ActionTools::Name("amount", tr("Amount")), this); amount->setTooltip(tr("The amount of key presses to simulate")); amount->setMinimum(1); amount->setMaximum(std::numeric_limits::max()); amount->setDefaultValue(1); pressAndReleaseGroup->addMember(amount); addElement(pressAndReleaseGroup); ActionTools::BooleanParameterDefinition *ctrl = new ActionTools::BooleanParameterDefinition(ActionTools::Name("ctrl", tr("Ctrl")), this); ctrl->setTooltip(tr("Should the Ctrl key be pressed")); addElement(ctrl); ActionTools::BooleanParameterDefinition *alt = new ActionTools::BooleanParameterDefinition(ActionTools::Name("alt", tr("Alt")), this); alt->setTooltip(tr("Should the Alt key be pressed")); addElement(alt); ActionTools::BooleanParameterDefinition *shift = new ActionTools::BooleanParameterDefinition(ActionTools::Name("shift", tr("Shift")), this); shift->setTooltip(tr("Should the Shift key be pressed")); addElement(shift); #ifdef Q_WS_WIN QString metaKeyName = tr("Windows"); #else QString metaKeyName = tr("Meta"); #endif ActionTools::BooleanParameterDefinition *meta = new ActionTools::BooleanParameterDefinition(ActionTools::Name("meta", metaKeyName), this); meta->setTooltip(tr("Should the %1 key be pressed").arg(metaKeyName)); addElement(meta); ActionTools::ListParameterDefinition *type = new ActionTools::ListParameterDefinition(ActionTools::Name("type", tr("Type")), this); type->setTooltip(tr("The key type to use")); type->setItems(KeyInstance::types); type->setDefaultValue(KeyInstance::types.second.at(KeyInstance::Win32Type)); type->setOperatingSystems(ActionTools::WorksOnWindows); addElement(type, 1); ActionTools::NumberParameterDefinition *pause = new ActionTools::NumberParameterDefinition(ActionTools::Name("pause", tr("Press/Release pause")), this); pause->setTooltip(tr("The pause duration between press and release")); pause->setMinimum(0); pause->setMaximum(std::numeric_limits::max()); pause->setDefaultValue(10); pause->setSuffix(tr(" ms", "milliseconds")); addElement(pause, 1); addException(KeyInstance::FailedToSendInputException, tr("Send input failure")); addException(KeyInstance::InvalidActionException, tr("Invalid action")); } QString name() const { return QObject::tr("Key"); } QString id() const { return "ActionKey"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Emulates a key press"); } ActionTools::ActionInstance *newActionInstance() const { return new KeyInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/key.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(KeyDefinition) }; } #endif // KEYDEFINITION_H actionaz-3.7.0/actions/actionpackdevice/actions/keyinstance.cpp000066400000000000000000000104671216313063400247550ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "keyinstance.h" #include "keyinput.h" #ifdef Q_WS_WIN #include #endif #include namespace Actions { ActionTools::StringListPair KeyInstance::actions = qMakePair( QStringList() << "pressRelease" << "press" << "release", QStringList() << QT_TRANSLATE_NOOP("KeyInstance::actions", "Press and release") << QT_TRANSLATE_NOOP("KeyInstance::actions", "Press") << QT_TRANSLATE_NOOP("KeyInstance::actions", "Release")); ActionTools::StringListPair KeyInstance::types = qMakePair( QStringList() << "win32" << "directx", QStringList() << QT_TRANSLATE_NOOP("KeyInstance::actions", "Win32") << QT_TRANSLATE_NOOP("KeyInstance::actions", "DirectX")); KeyInstance::KeyInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mCtrl(false), mAlt(false), mShift(false), mMeta(false), mTimer(new QTimer(this)) { connect(mTimer, SIGNAL(timeout()), this, SLOT(sendRelease())); } void KeyInstance::startExecution() { bool ok = true; mKey = evaluateString(ok, "key", "key"); Action action = evaluateListElement(ok, actions, "action"); mAmount = evaluateInteger(ok, "amount"); mCtrl = evaluateBoolean(ok, "ctrl"); mAlt = evaluateBoolean(ok, "alt"); mShift = evaluateBoolean(ok, "shift"); mMeta = evaluateBoolean(ok, "meta"); Type type = evaluateListElement(ok, types, "type"); mPause = evaluateInteger(ok, "pause"); if(mPause < 0) mPause = 0; if (!ok) return; if(action != PressReleaseAction) mAmount = 1; if(mAmount <= 0) { setCurrentParameter("amount"); emit executionException(ActionTools::ActionException::InvalidParameterException, tr("Invalid key presses amount")); return; } mKeyboardDevice.setType(static_cast(type)); bool result = true; switch(action) { case PressAction: pressOrReleaseModifiers(true); result &= mKeyboardDevice.pressKey(mKey); break; case ReleaseAction: pressOrReleaseModifiers(false); result &= mKeyboardDevice.releaseKey(mKey); break; case PressReleaseAction: pressOrReleaseModifiers(true); result &= mKeyboardDevice.pressKey(mKey); mTimer->setSingleShot(true); mTimer->start(mPause); break; } if(!result) { emit executionException(FailedToSendInputException, tr("Unable to emulate key: failed to send input")); return; } if(action != PressReleaseAction) emit executionEnded(); } void KeyInstance::stopExecution() { mTimer->stop(); } void KeyInstance::stopLongTermExecution() { mKeyboardDevice.reset(); } void KeyInstance::sendRelease() { pressOrReleaseModifiers(false); mKeyboardDevice.releaseKey(mKey); --mAmount; if (mAmount > 0) emit sendPressKey(); else emit executionEnded(); } void KeyInstance::sendPressKey() { bool result = true; pressOrReleaseModifiers(true); result &= mKeyboardDevice.pressKey(mKey); if(!result) { emit executionException(FailedToSendInputException, tr("Unable to emulate key: failed to send input")); return; } mTimer->start(mPause); } void KeyInstance::pressOrReleaseModifiers(bool press) { if(press) { if(mCtrl) mKeyboardDevice.pressKey("controlLeft"); if(mAlt) mKeyboardDevice.pressKey("altLeft"); if(mShift) mKeyboardDevice.pressKey("shiftLeft"); if(mMeta) mKeyboardDevice.pressKey("metaLeft"); } else { if(mCtrl) mKeyboardDevice.releaseKey("controlLeft"); if(mAlt) mKeyboardDevice.releaseKey("altLeft"); if(mShift) mKeyboardDevice.releaseKey("shiftLeft"); if(mMeta) mKeyboardDevice.releaseKey("metaLeft"); } } } actionaz-3.7.0/actions/actionpackdevice/actions/keyinstance.h000066400000000000000000000034211216313063400244120ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 KEYINSTANCE_H #define KEYINSTANCE_H #include "actioninstance.h" #include "../keyboarddevice.h" #include "stringlistpair.h" class QTimer; namespace Actions { class KeyInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Action { PressReleaseAction, PressAction, ReleaseAction }; enum Type { Win32Type, DirectXType }; enum Exceptions { FailedToSendInputException = ActionTools::ActionException::UserException, InvalidActionException }; KeyInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0); static ActionTools::StringListPair actions; static ActionTools::StringListPair types; void startExecution(); void stopExecution(); void stopLongTermExecution(); private slots: void sendRelease(); void sendPressKey(); private: void pressOrReleaseModifiers(bool press); KeyboardDevice mKeyboardDevice; QString mKey; bool mCtrl; bool mAlt; bool mShift; bool mMeta; int mAmount; int mPause; QTimer *mTimer; Q_DISABLE_COPY(KeyInstance) }; } #endif // KEYINSTANCE_H actionaz-3.7.0/actions/actionpackdevice/actions/movecursordefinition.h000066400000000000000000000050561216313063400263600ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 MOVECURSORDEFINITION_H #define MOVECURSORDEFINITION_H #include "actiondefinition.h" #include "movecursorinstance.h" #include "positionparameterdefinition.h" namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class MoveCursorDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit MoveCursorDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::PositionParameterDefinition *position = new ActionTools::PositionParameterDefinition(ActionTools::Name("position", tr("Position")), this); position->setTooltip(tr("The position where to move the cursor")); addElement(position); ActionTools::PositionParameterDefinition *positionOffset = new ActionTools::PositionParameterDefinition(ActionTools::Name("positionOffset", tr("Offset")), this); positionOffset->setTooltip(tr("The offset to apply to the cursor movement")); addElement(positionOffset, 1); } QString name() const { return QObject::tr("Move cursor"); } QString id() const { return "ActionMoveCursor"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Move the mouse cursor"); } ActionTools::ActionInstance *newActionInstance() const { return new MoveCursorInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/movecursor.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(MoveCursorDefinition) }; } #endif // MOVECURSORDEFINITION_H actionaz-3.7.0/actions/actionpackdevice/actions/movecursorinstance.h000066400000000000000000000030551216313063400260310ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 MOVECURSORINSTANCE_H #define MOVECURSORINSTANCE_H #include "actioninstance.h" #include "../mousedevice.h" namespace Actions { class MoveCursorInstance : public ActionTools::ActionInstance { Q_OBJECT public: MoveCursorInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0) : ActionTools::ActionInstance(definition, parent) {} void startExecution() { bool ok = true; QPoint position = evaluatePoint(ok, "position"); QPoint positionOffset = evaluatePoint(ok, "positionOffset"); if(!ok) return; position += positionOffset; mMouseDevice.setCursorPosition(position); emit executionEnded(); } void stopLongTermExecution() { mMouseDevice.reset(); } private: MouseDevice mMouseDevice; Q_DISABLE_COPY(MoveCursorInstance) }; } #endif // MOVECURSORINSTANCE_H actionaz-3.7.0/actions/actionpackdevice/actions/textdefinition.h000066400000000000000000000053241216313063400251360ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 TEXTDEFINITION_H #define TEXTDEFINITION_H #include "actiondefinition.h" #include "textinstance.h" #include "textparameterdefinition.h" #include "numberparameterdefinition.h" #include namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class TextDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit TextDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::TextParameterDefinition *text = new ActionTools::TextParameterDefinition(ActionTools::Name("text", tr("Text")), this); text->setTooltip(tr("The text to write")); addElement(text); ActionTools::NumberParameterDefinition *pause = new ActionTools::NumberParameterDefinition(ActionTools::Name("pause", tr("Pause between characters")), this); pause->setTooltip(tr("The pause duration between each character")); pause->setMinimum(0); pause->setMaximum(std::numeric_limits::max()); pause->setDefaultValue(0); pause->setSuffix(tr(" ms", "milliseconds")); addElement(pause, 1); addException(TextInstance::FailedToSendInputException, tr("Send input failure")); } QString name() const { return QObject::tr("Write text"); } QString id() const { return "ActionWriteText"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Write some text"); } ActionTools::ActionInstance *newActionInstance() const { return new TextInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/text.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } QStringList tabs() const { return ActionDefinition::StandardTabs; } private: Q_DISABLE_COPY(TextDefinition) }; } #endif // TEXTDEFINITION_H actionaz-3.7.0/actions/actionpackdevice/actions/textinstance.cpp000066400000000000000000000041741216313063400251470ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "textinstance.h" #include namespace Actions { TextInstance::TextInstance(const ActionTools::ActionDefinition *definition, QObject *parent) : ActionTools::ActionInstance(definition, parent), mTimer(new QTimer(this)), mCurrentCharacter(0) { connect(mTimer, SIGNAL(timeout()), this, SLOT(pressNextKey())); mTimer->setSingleShot(false); } void TextInstance::startExecution() { bool ok = true; mText = evaluateString(ok, "text"); int pause = evaluateInteger(ok, "pause"); if(pause < 0) pause = 0; mTimer->setInterval(pause); mCurrentCharacter = 0; if(!ok) return; if(pause == 0) { if(!mKeyboardDevice.writeText(mText)) { emit executionException(FailedToSendInputException, tr("Unable to write the text")); return; } QTimer::singleShot(1, this, SIGNAL(executionEnded())); } else { pressNextKey(); mTimer->start(); } } void TextInstance::stopExecution() { mTimer->stop(); } void TextInstance::stopLongTermExecution() { mKeyboardDevice.reset(); } void TextInstance::pressNextKey() { if(!mKeyboardDevice.writeText(QString(mText.at(mCurrentCharacter)))) { mTimer->stop(); emit executionException(FailedToSendInputException, tr("Unable to write the text")); return; } ++mCurrentCharacter; if(mCurrentCharacter >= mText.size()) { mTimer->stop(); QTimer::singleShot(1, this, SIGNAL(executionEnded())); return; } } } actionaz-3.7.0/actions/actionpackdevice/actions/textinstance.h000066400000000000000000000026101216313063400246050ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 TEXTINSTANCE_H #define TEXTINSTANCE_H #include "actioninstance.h" #include "../keyboarddevice.h" class QTimer; namespace Actions { class TextInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Exceptions { FailedToSendInputException = ActionTools::ActionException::UserException }; TextInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0); void startExecution(); void stopExecution(); void stopLongTermExecution(); private slots: void pressNextKey(); private: KeyboardDevice mKeyboardDevice; QTimer *mTimer; QString mText; int mCurrentCharacter; Q_DISABLE_COPY(TextInstance) }; } #endif // TEXTINSTANCE_H actionaz-3.7.0/actions/actionpackdevice/actions/wheeldefinition.h000066400000000000000000000046101216313063400252530ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 WHEELDEFINITION_H #define WHEELDEFINITION_H #include "actiondefinition.h" #include "wheelinstance.h" #include "numberparameterdefinition.h" #include namespace ActionTools { class ActionPack; class ActionInstance; } namespace Actions { class WheelDefinition : public QObject, public ActionTools::ActionDefinition { Q_OBJECT public: explicit WheelDefinition(ActionTools::ActionPack *pack) : ActionDefinition(pack) { ActionTools::NumberParameterDefinition *intensity = new ActionTools::NumberParameterDefinition(ActionTools::Name("intensity", tr("Intensity")), this); intensity->setTooltip(tr("Intensity of the movement, positive is up, negative is down")); intensity->setMinimum(std::numeric_limits::min()); intensity->setMaximum(std::numeric_limits::max()); addElement(intensity); addException(WheelInstance::FailedToSendInputException, tr("Send input failure")); } QString name() const { return QObject::tr("Wheel"); } QString id() const { return "ActionWheel"; } ActionTools::Flag flags() const { return ActionDefinition::flags() | ActionTools::Official; } QString description() const { return QObject::tr("Emulates the mouse wheel"); } ActionTools::ActionInstance *newActionInstance() const { return new WheelInstance(this); } ActionTools::ActionCategory category() const { return ActionTools::Device; } QPixmap icon() const { return QPixmap(":/actions/icons/wheel.png"); } bool requirementCheck(QStringList &missingRequirements) const { return requirementCheckXTest(missingRequirements); } private: Q_DISABLE_COPY(WheelDefinition) }; } #endif // WHEELDEFINITION_H actionaz-3.7.0/actions/actionpackdevice/actions/wheelinstance.h000066400000000000000000000032211216313063400247240ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 WHEELINSTANCE_H #define WHEELINSTANCE_H #include "actioninstance.h" #include "../mousedevice.h" namespace Actions { class WheelInstance : public ActionTools::ActionInstance { Q_OBJECT public: enum Exceptions { FailedToSendInputException = ActionTools::ActionException::UserException }; WheelInstance(const ActionTools::ActionDefinition *definition, QObject *parent = 0) : ActionTools::ActionInstance(definition, parent) {} void startExecution() { bool ok = true; int intensity = evaluateInteger(ok, "intensity"); if(!ok) return; if(!mMouseDevice.wheel(intensity)) { emit executionException(FailedToSendInputException, tr("Unable to emulate wheel: failed to send input")); return; } emit executionEnded(); } void stopLongTermExecution() { mMouseDevice.reset(); } private: MouseDevice mMouseDevice; Q_DISABLE_COPY(WheelInstance) }; } #endif // WHEELINSTANCE_H actionaz-3.7.0/actions/actionpackdevice/code/000077500000000000000000000000001216313063400211765ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdevice/code/code.pri000066400000000000000000000001411216313063400226200ustar00rootroot00000000000000HEADERS += code/mouse.h \ code/keyboard.h SOURCES += code/mouse.cpp \ code/keyboard.cpp actionaz-3.7.0/actions/actionpackdevice/code/keyboard.cpp000066400000000000000000000033161216313063400235050ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "keyboard.h" namespace Code { QScriptValue Keyboard::constructor(QScriptContext *context, QScriptEngine *engine) { return CodeClass::constructor(new Keyboard, context, engine); } Keyboard::Keyboard() : CodeClass() { } QScriptValue Keyboard::pressKey(const QString &key) { if(!mKeyboardDevice.pressKey(key)) throwError("PressKeyError", tr("Unable to press the key")); return thisObject(); } QScriptValue Keyboard::releaseKey(const QString &key) { if(!mKeyboardDevice.releaseKey(key)) throwError("ReleaseKeyError", tr("Unable to release the key")); return thisObject(); } QScriptValue Keyboard::triggerKey(const QString &key) { if(!mKeyboardDevice.triggerKey(key)) throwError("TriggerKeyError", tr("Unable to trigger the key")); return thisObject(); } QScriptValue Keyboard::writeText(const QString &text, int delay) const { if(!mKeyboardDevice.writeText(text, delay)) throwError("WriteTextError", tr("Unable to write the text")); return thisObject(); } } actionaz-3.7.0/actions/actionpackdevice/code/keyboard.h000066400000000000000000000027271216313063400231570ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 KEYBOARD_H #define KEYBOARD_H #include "../keyboarddevice.h" #include "code/codeclass.h" #include #include #include namespace Code { class Keyboard : public CodeClass { Q_OBJECT public: static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); Keyboard(); public slots: QString toString() const { return "Keyboard"; } QScriptValue pressKey(const QString &key); QScriptValue releaseKey(const QString &key); QScriptValue triggerKey(const QString &key); QScriptValue writeText(const QString &text, int delay = 0) const; virtual bool equals(const QScriptValue &other) const { Q_UNUSED(other) return false; } private: KeyboardDevice mKeyboardDevice; }; } #endif // KEYBOARD_H actionaz-3.7.0/actions/actionpackdevice/code/mouse.cpp000066400000000000000000000063721216313063400230420ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "mouse.h" #include "code/point.h" #include namespace Code { QScriptValue Mouse::constructor(QScriptContext *context, QScriptEngine *engine) { Mouse *mouse = new Mouse; QScriptValueIterator it(context->argument(0)); while(it.hasNext()) { it.next(); if(it.name() == "onMotion") mouse->mOnMotion = it.value(); else if(it.name() == "onWheel") mouse->mOnWheel = it.value(); else if(it.name() == "onButtonPressed") mouse->mOnButtonPressed = it.value(); else if(it.name() == "onButtonReleased") mouse->mOnButtonReleased = it.value(); } return CodeClass::constructor(mouse, context, engine); } Mouse::Mouse() : CodeClass() { } Mouse::~Mouse() { } QScriptValue Mouse::position() const { return Point::constructor(mMouseDevice.cursorPosition(), engine()); } QScriptValue Mouse::move() const { mMouseDevice.setCursorPosition(Point::parameter(context(), engine())); return thisObject(); } bool Mouse::isButtonPressed(Button button) const { return mMouseDevice.isButtonPressed(static_cast(button)); } QScriptValue Mouse::press(Button button) { if(!mMouseDevice.pressButton(static_cast(button))) throwError("PressButtonError", tr("Unable to press the button")); return thisObject(); } QScriptValue Mouse::release(Button button) { if(!mMouseDevice.releaseButton(static_cast(button))) throwError("ReleaseButtonError", tr("Unable to release the button")); return thisObject(); } QScriptValue Mouse::click(Button button) { if(!mMouseDevice.buttonClick(static_cast(button))) throwError("ClickError", tr("Unable to emulate a button click")); return thisObject(); } QScriptValue Mouse::wheel(int intensity) const { if(!mMouseDevice.wheel(intensity)) throwError("WheelError", tr("Unable to emulate the wheel")); return thisObject(); } void Mouse::mouseMotion(int x, int y) { if(mOnMotion.isValid()) mOnMotion.call(thisObject(), QScriptValueList() << x << y); } void Mouse::mouseWheel(int intensity) { if(mOnWheel.isValid()) mOnWheel.call(thisObject(), QScriptValueList() << intensity); } void Mouse::mouseButtonPressed(ActionTools::SystemInput::Button button) { if(mOnButtonPressed.isValid()) mOnButtonPressed.call(thisObject(), QScriptValueList() << button); } void Mouse::mouseButtonReleased(ActionTools::SystemInput::Button button) { if(mOnButtonReleased.isValid()) mOnButtonReleased.call(thisObject(), QScriptValueList() << button); } } actionaz-3.7.0/actions/actionpackdevice/code/mouse.h000066400000000000000000000060071216313063400225020ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 MOUSE_H #define MOUSE_H #include "../mousedevice.h" #include "code/codeclass.h" #include "systeminputlistener.h" #include "systeminputrecorder.h" #include #include #include namespace Code { class Mouse : public CodeClass { Q_OBJECT Q_ENUMS(Button) Q_PROPERTY(QScriptValue onMotion READ onMotion WRITE setOnMotion) Q_PROPERTY(QScriptValue onWheel READ onWheel WRITE setOnWheel) Q_PROPERTY(QScriptValue onButtonPressed READ onButtonPressed WRITE setOnButtonPressed) Q_PROPERTY(QScriptValue onButtonReleased READ onButtonReleased WRITE setOnButtonReleased) public: static QScriptValue constructor(QScriptContext *context, QScriptEngine *engine); enum Button { LeftButton, MiddleButton, RightButton }; Mouse(); ~Mouse(); void setOnMotion(const QScriptValue &onMotion) { mOnMotion = onMotion; } void setOnWheel(const QScriptValue &onWheel) { mOnWheel = onWheel; } void setOnButtonPressed(const QScriptValue &onButtonPressed) { mOnButtonPressed = onButtonPressed; } void setOnButtonReleased(const QScriptValue &onButtonReleased) { mOnButtonReleased = onButtonReleased; } QScriptValue onMotion() const { return mOnMotion; } QScriptValue onWheel() const { return mOnWheel; } QScriptValue onButtonPressed() const { return mOnButtonPressed; } QScriptValue onButtonReleased() const { return mOnButtonReleased; } public slots: QString toString() const { return "Mouse"; } QScriptValue position() const; QScriptValue move() const; bool isButtonPressed(Button button = LeftButton) const; QScriptValue press(Button button = LeftButton); QScriptValue release(Button button = LeftButton); QScriptValue click(Button button = LeftButton); QScriptValue wheel(int intensity = 1) const; virtual bool equals(const QScriptValue &other) const { Q_UNUSED(other) return false; } private: void mouseMotion(int x, int y); void mouseWheel(int intensity); void mouseButtonPressed(ActionTools::SystemInput::Button button); void mouseButtonReleased(ActionTools::SystemInput::Button button); private: MouseDevice mMouseDevice; QScriptValue mOnMotion; QScriptValue mOnWheel; QScriptValue mOnButtonPressed; QScriptValue mOnButtonReleased; }; } Q_DECLARE_METATYPE(MouseDevice::Button) #endif // MOUSE_H actionaz-3.7.0/actions/actionpackdevice/icons/000077500000000000000000000000001216313063400213775ustar00rootroot00000000000000actionaz-3.7.0/actions/actionpackdevice/icons/click.png000066400000000000000000000042171216313063400231760ustar00rootroot00000000000000PNG  IHDR szzsRGBgAMA a pHYsodtEXtSoftwarePaint.NET v3.5.5IIDATXGwPǽ\s^q.8qR'䒶&zPFA,Ff)A{#YbH  Xb#/ x`(hBzp~}~6p8} m;ZI$B?88RK$/ZXXyZh<} UoJ8\`hdBcc,BjX$yY ٹ< 6%e":BY_qQSSkJeNN>ZZJ>oB`'A2R+Y֬O]^YH(ڻ!@L֑5ӋlwrwČF"7_¬vvq/,>u!oT9<JH*J nY  !aWY0 }~H WQPnlCD "b N{-0iDl{ 9YlIy FHX As? >.5T:_ÔqS;l7z+@FJ5'H#o&PMO[5 3x4 ) HcLvzo '#~XS{؝(`<#J= 7 n"NikH+GbRJB5z .ѼhyH:] dM2@?RXqp WB +J|qyBTL6rc\\IIeCADtwZhBns&7UQ!B*3)_9yCN. F\BjCP;Rbwr aIt$$'?P $j B틜b56\Hn #L(GI EH'd0eLL-Mu!&[ٞExqx44Cy~B]CɓRDDǁ}%E%ʂ̭(ntX؜qd&dTA . 488"0,5b1r aewa̬(!Rt!z1x|E uRK/Z3:~T Y[£qԊ A;P)g028 ^E,)8q aC)_.+#I1Pl09} P]Ιat`J2|",Ixd1 ;\DV^1APp؉SZ\g#C ryHaeN%"%o'WHIGs wG%ycCF0𔙅h(0=FX\J]Azv>yHyW գwV^iq|%L?FJf> yjב'4bL?Y^@[CHr#{';wܿeN#>caGþ~ǻ'3sܞi[=Zol bX]oPIENDB`actionaz-3.7.0/actions/actionpackdevice/icons/key.png000066400000000000000000000043461216313063400227040ustar00rootroot00000000000000PNG  IHDR szzsRGBgAMA a pHYsodtEXtSoftwarePaint.NET v3.5.5IVIDATXGV Lk]W1Unuת]+jڸiV]W9<w8< r(UqAf`898eD538\rnclM/{w݂/aa gqX?dd#88;"$Ah$]S[jj,\8EɉɹRUYϻ3nv uoƕ6j3W9996LM0xdlkNÜX<Co-u P|>?/͊kb\ !B)/&}4`bf'INltQ^`@;H :OOxtztzSx^>qSӌnѥ>""2IF>>>wo.%7A~ZU^bUk׭tݰԴnæM7m۸iSSz2O+/6Yro"JWJ577Ip[P... s8e`% ׏&33ssnNϥR¯ fz 2?[$ׅ^uFJKK]Ϲ+3~RIj'OhNYyyH$ɚ*UB4$KgoR,~WBK5#7W(, 6ek~{xx ߷[nCA")åZHKpU0Eqq_?0gSeTWA낦S Y:9u}}\ᲇ>)EWVB$1YX1}N^D,9~zEEomcc3UUոG$*4C8 Ċ{p{d }dʸ\ޛu]SCC`_׳*U$G>H=s^E_%~(΅_>UhI2n{lbΈg⾦kRN6QOcè~}c F}; #lɪH yZX%%pQ|˅9vix'ٰ^~;ԊMԟ?DDž!:}.c @Qe*UTE 9]z؞uL +\c /*#*`T } (5Z@gR~jxjüӪ>}S-.+܊la/K T9|{p,xttO~A|'s5y`!X-_।z_+V_t:ȿU1]m޶a)ti` LzZ)ל!?p ¯ `V\G9g)•ƑQ Dm:g5= J#Rvw~ZϾN;/yf~_#y ˁGf- w\mЏb G r [_!"fbO%rtvw={9^*] >ގb鑊#4.޵f[ |8X N!9a|8ap*Zki$/霳$D;wQP?(HC{ww3! X:~ Z9$p/BTsKMp *{Bx3 [Bا6r dzv_|OF>3`)]O 61 e(!=Ǜi<)Z?o *\Pgk~a{7+hSc+;kS$'G㒔lVf^wM&"knN0;͖GZ݂/aa gqX?dd#88;"$Ah$]S[jj,\8EɉɹRUYϻ3nv uoƕ6j3W9996LM0xdlkNÜX<Co-u P|>?/͊kb\ !B)/&}4`bf'INltQ^`@;H :OOxtztzSx^>qSӌnѥ>""2IF>>>wo.%7A~ZU^bUk׭tݰԴnæM7m۸iSSz2O+/6Yro"JWJ577Ip[P... s8e`% ׏&33ssnNϥR¯ fz 2?[$ׅ^uFJKK]Ϲ+3~RIj'OZZJ>oB`'A2R+Y֬O]^YH(ڻ!@L֑5ӋlwrwČF"7_¬vvq/,>u!oT9<JH*J nY  !aWY0 }~H WQPnlCD "b N{-0iDl{ 9YlIy FHX As? >.5T:_ÔqS;l7z+@FJ5'H#o&PMO[5 3x4 ) HcLvzo '#~XS{؝(`<#J= 7 n"NikH+GbRJB5z .ѼhyH:] dM2@?RXqp WB +J|qyBTL6rc\\IIeCADtwZhBns&7UQ!B*3)_9yCN. F\BjCP;Rbwr aIt$$'?P $j B틜b56\Hn #L(GI EH'd0eLL-Mu!&[ٞExqx44Cy~B]CɓRDDǁ}%E%ʂ̭(ntX؜qd&dTA . 488"0,5b1r aewa̬(!Rt!z1x|E uRK/Z3:~T Y[£qԊ A;P)g028 ^E,)8q aC)_.+#I1Pl09} P]Ιat`J2|",Ixd1 ;\DV^1APp؉SZ\g#C ryHaeN%"%o'WHIGs wG%ycCF0𔙅h(0=FX\J]Azv>yHyW գwV^iq|%L?FJf> yjב'4bL?Y^@[CHr#{';wܿeN#>caGþ~ǻ'3sܞi[=Zol bX]oPIENDB`actionaz-3.7.0/actions/actionpackdevice/keyboarddevice.cpp000066400000000000000000000151551216313063400237570ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "keyboarddevice.h" #include "keymapper.h" #include "keyinput.h" #include "crossplatform.h" #ifdef Q_WS_X11 #include "keysymhelper.h" #include #include #define XK_MISCELLANY #define XK_LATIN1 #define XK_KOREAN #define XK_XKB_KEYS #include #include #include #endif #ifdef Q_WS_WIN #include #endif KeyboardDevice::KeyboardDevice() : mType(Win32) { } KeyboardDevice::~KeyboardDevice() { reset(); } void KeyboardDevice::reset() { foreach(int nativeKey, mPressedKeys) { doKeyAction(Release, nativeKey); } } bool KeyboardDevice::pressKey(const QString &key) { return doKeyAction(Press, stringToNativeKey(key)); } bool KeyboardDevice::releaseKey(const QString &key) { return doKeyAction(Release, stringToNativeKey(key)); } bool KeyboardDevice::triggerKey(const QString &key) { return doKeyAction(Trigger, stringToNativeKey(key)); } #ifdef Q_WS_X11 static KeyCode keyToKeycode(const char *key) { KeySym keySym = XStringToKeysym(key); if(keySym == NoSymbol) return keyToKeycode("space"); return XKeysymToKeycode(QX11Info::display(), keySym); } static bool sendCharacter(KeySym keySym) { bool result = true; KeyCode keyCode = ActionTools::KeySymHelper::keySymToKeyCode(keySym); int shift = ActionTools::KeySymHelper::keySymToModifier(keySym) % 2; const char *wrapKey = ActionTools::KeySymHelper::keyModifiers[ (ActionTools::KeySymHelper::keySymToModifier(keySym) - shift) / 2]; if(wrapKey) result &= XTestFakeKeyEvent(QX11Info::display(), keyToKeycode(wrapKey), True, CurrentTime); if(shift) result &= XTestFakeKeyEvent(QX11Info::display(), keyToKeycode("Shift_L"), True, CurrentTime); result &= XTestFakeKeyEvent(QX11Info::display(), keyCode, True, CurrentTime); result &= XTestFakeKeyEvent(QX11Info::display(), keyCode, False, CurrentTime); if(shift) result &= XTestFakeKeyEvent(QX11Info::display(), keyToKeycode("Shift_L"), False, CurrentTime); if(wrapKey) result &= XTestFakeKeyEvent(QX11Info::display(), keyToKeycode(wrapKey), False, CurrentTime); XFlush(QX11Info::display()); return result; } static bool sendKey(const char *key) { bool result = true; result &= XTestFakeKeyEvent(QX11Info::display(), keyToKeycode(key), True, CurrentTime); result &= XTestFakeKeyEvent(QX11Info::display(), keyToKeycode(key), False, CurrentTime); return result; } #endif bool KeyboardDevice::writeText(const QString &text, int delay) const { #ifdef Q_WS_X11 bool result = true; KeySym keySym[2]; std::wstring wideString = text.toStdWString(); wchar_t wcSinglecharStr[2] = {L'\0'}; for(unsigned int i = 0; wideString[i] != L'\0' && i < wideString.size(); ++i) { wcSinglecharStr[0] = wideString[i]; //KeySym lookup keySym[0] = ActionTools::KeySymHelper::wcharToKeySym(wcSinglecharStr[0]); keySym[1] = 0; if(keySym[0] == 0 || ActionTools::KeySymHelper::keySymToKeyCode(keySym[0]) == 0) { //No keycode found -> try to find a Multi_key combination for this character keySym[0] = 0; for(int j = 0; j < ActionTools::KeySymHelper::MULTIKEY_MAP_SIZE; ++j) { if(wcSinglecharStr[0] == ActionTools::KeySymHelper::multikeyMapChar[j])//Found { keySym[0] = ActionTools::KeySymHelper::wcharToKeySym(ActionTools::KeySymHelper::multikeyMapFirst[j]); keySym[1] = ActionTools::KeySymHelper::wcharToKeySym(ActionTools::KeySymHelper::multikeyMapSecond[j]); if((ActionTools::KeySymHelper::keySymToKeyCode(keySym[0]) == 0) || (ActionTools::KeySymHelper::keySymToKeyCode(keySym[1]) == 0)) keySym[0] = 0;//Character not supported break; } } } if(keySym[0]) { if(keySym[1])//Multi key sequence { result &= sendKey("Multi_key"); result &= sendCharacter(keySym[0]); result &= sendCharacter(keySym[1]); } else//Single key result &= sendCharacter(keySym[0]); } if(delay > 0) ActionTools::CrossPlatform::sleep(delay); } return result; #endif #ifdef Q_WS_WIN INPUT input[2]; std::wstring wideString = text.toStdWString(); bool result = true; for(int i = 0; i < 2; ++i) { input[i].type = INPUT_KEYBOARD; input[i].ki.wVk = 0; input[i].ki.dwFlags = KEYEVENTF_UNICODE | (i == 0 ? 0 : KEYEVENTF_KEYUP); input[i].ki.time = 0; input[i].ki.dwExtraInfo = 0; } for(int i = 0; i < text.length(); ++i) { input[0].ki.wScan = input[1].ki.wScan = wideString[i]; result &= (SendInput(2, input, sizeof(INPUT)) != 0); if(delay > 0) ActionTools::CrossPlatform::sleep(delay); } return result; #endif } bool KeyboardDevice::doKeyAction(Action action, int nativeKey) { bool result = true; #ifdef Q_WS_X11 KeyCode keyCode = XKeysymToKeycode(QX11Info::display(), nativeKey); if(action == Press || action == Trigger) result &= XTestFakeKeyEvent(QX11Info::display(), keyCode, True, CurrentTime); if(action == Release || action == Trigger) result &= XTestFakeKeyEvent(QX11Info::display(), keyCode, False, CurrentTime); XFlush(QX11Info::display()); #endif #ifdef Q_WS_WIN INPUT input; input.type = INPUT_KEYBOARD; input.ki.time = 0; input.ki.dwExtraInfo = 0; input.ki.dwFlags = 0; switch(mType) { case Win32: input.ki.wVk = nativeKey; input.ki.wScan = 0; break; case DirectX: input.ki.wVk = 0; input.ki.wScan = ActionTools::KeyMapper::toDirectXKey(nativeKey); break; } if(action == Press || action == Trigger) result &= (SendInput(1, &input, sizeof(INPUT)) != 0); if(action == Release || action == Trigger) { input.ki.dwFlags |= KEYEVENTF_KEYUP; result &= (SendInput(1, &input, sizeof(INPUT)) != 0); } #endif if(action == Press) mPressedKeys.insert(nativeKey); else if(action == Release) mPressedKeys.remove(nativeKey); return result; } int KeyboardDevice::stringToNativeKey(const QString &key) const { ActionTools::KeyInput keyInput; keyInput.fromPortableText(key); if(keyInput.isQtKey()) return ActionTools::KeyMapper::toNativeKey(static_cast(keyInput.key())); else return ActionTools::KeyInput::nativeKey(keyInput.key()); } actionaz-3.7.0/actions/actionpackdevice/keyboarddevice.h000066400000000000000000000025621216313063400234220ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 KEYBOARDDEVICE_H #define KEYBOARDDEVICE_H #include #include class KeyboardDevice : public QObject { Q_OBJECT public: enum Action { Press, Release, Trigger }; enum Type { Win32, DirectX }; KeyboardDevice(); ~KeyboardDevice(); void reset(); void setType(Type type) { mType = type; } bool pressKey(const QString &key); bool releaseKey(const QString &key); bool triggerKey(const QString &key); bool writeText(const QString &text, int delay = 0) const; private: bool doKeyAction(Action action, int nativeKey); int stringToNativeKey(const QString &key) const; QSet mPressedKeys; Type mType; }; #endif // KEYBOARDDEVICE_H actionaz-3.7.0/actions/actionpackdevice/mousedevice.cpp000066400000000000000000000111151216313063400232770ustar00rootroot00000000000000/* Actionaz Copyright (C) 2008-2013 Jonathan Mercier-Ganady Actionaz is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Actionaz is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 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 "mousedevice.h" #include #ifdef Q_WS_X11 #include #include #include #endif #ifdef Q_WS_WIN #include #endif MouseDevice::MouseDevice() { for(int i = 0; i < ButtonCount; ++i) mPressedButtons[i] = false; } MouseDevice::~MouseDevice() { reset(); } void MouseDevice::reset() { for(int i = 0; i < ButtonCount; ++i) { if(mPressedButtons[i]) releaseButton(static_cast