diff options
Diffstat (limited to 'doc')
53 files changed, 5269 insertions, 0 deletions
diff --git a/doc/COPYING b/doc/COPYING new file mode 100644 index 00000000..7381eeed --- /dev/null +++ b/doc/COPYING @@ -0,0 +1,302 @@ +This is the KVIrc Irc Client license. +It is based on the GNU General Public License Version 2. +It contains all the GPL terms and conditions and adds a special exception +(see Terms and Conditions , clause 13) to the distribution limitations. + +Note that the GPL below is copyrighted by the Free Software +Foundation, but the instance of code that it refers to is copyrighted by +Szymon Stefanek and other members of the KVIrc Development Team. + +The source code for all versions of KVIrc is available at http://www.kvirc.net + +Have fun! +Szymon Stefanek :) + +------------------------------------------------------------------------------ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + Extended by Szymon Stefanek + + 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. + + 13. As a special exception, Szymon Stefanek gives permission to link this +program with Qt non-commercial edition for Windows, and distribute the +resulting executable, without including the source code for the Qt +non-commercial edition in the source distribution. The Qt non-commercial +edition library is covered by the Qt Non-Commercial license. +See http://www.trolltech.com for informations. + diff --git a/doc/INSTALL-MacOS.txt b/doc/INSTALL-MacOS.txt new file mode 100644 index 00000000..e0733aeb --- /dev/null +++ b/doc/INSTALL-MacOS.txt @@ -0,0 +1,168 @@ +Thomas Kalla, 29.06.2006 +######################### + +This document contains step-by-step instructions for compiling kvirc on a MacOS X system. +I compiled several versions of kvirc (beginning with 3.0.0 up to recent CVS) on a Powerbook G4, 1.5GHz, 512 MB RAM and MacOS X 10.3.3-9. + + +All this has worked fine several times for me. I've been using KVirc on Mac since May 2004 without any crashes & faults. Only the sound interface does not work, but I have no use for it within an IRC client. However, I cannot guarantee that this instructions will work for you as they do for me and I'm not responsible for any problems or damage you may encounter after following them. You should always understand what you are doing! + + + +IMPORTANT: These instructions refer to Qt/Mac. If you want Qt/X11 which is included in Fink you are on your own. There is no support for the latter and most probably you don't get a working build. + + +######################### +Compilation with QT-MAC +######################### + +IMPORTANT: When compiled with QT-MAC, kvirc has to be run out of a bundle! Otherwise the application won't dispatch the keyboard events correctly and will be pretty unusable for you. + +A bundle is "just" a special directory structure on Mac systems which contains the application binary, dependant libraries, plugins, modules and other resources. So all we have to do is to run configure with proper paths and relink the binary, libraries and modules with relative paths after the compilation. + +For details look at http://doc.trolltech.com/qq/qq09-mac-deployment.html and the documentation on http://developer.apple.com, please. + +Prerequisites: + +1. Apple XCode +Get the latest version from Apple. I've been using only V1.5 for building with QT-MAC + +2. QT-MAC +Get the latest V3.*-version from Trolltech. + +3. GNU gettext +Get the latest sources from your favourite GNU mirror. + +Prerequisites installation: + +1) Install XCode +If not included on your Panther install media or if you want the latest version, you have to register at http://developer.apple.com (it's free), download XCode and follow the install instructions in the documentation. + +2) Install QT-MAC +You have to compile QT yourself. As far as I know there are no compiled binaries avaiable. Download and unpack the sources and follow the documentation. + +I used V3.3.4 + +Add the following two lines to your ~/.profile file, otherwise the compilation if Qt may fail. + +export QTDIR=/Developer/qt-mac-free-3.3.4 +export DYLD_FALLBACK_LIBRARY_PATH=$QTDIR/lib + + +Open a terminal window +# cd /Developer +# tar -xjf <your_path_to_the_sources>/qt-mac-free-3.3.4.tar.bz2 +# cd qt-mac-free-3.3.4 +# ./configure -thread -qt-gif -fast -no-exceptions -debug +# make sub-tools + +(If you don't want to build with debug information, remove the "-debug" switch in te configure line. You may also want to change "QMAKE_CFLAGS_RELEASE = -Os" in the mkspec/macx-g++/qmake.conf file to -O2. If you want the tutorial and examples, run "make" instead of "make sub-tools") + +3) Install GNU gettext +If you want non-english locales, you need GNU gettext. +If you already installed Fink, you already have gettext so you may skip this step. + +I used V0.14.5 + +Open a terminal window +# cd /Developer +# tar -xzf <your_path_to_the_sources>/gettext-0.14.5.tar.gz +# cd gettext-0.14.5 +# ./configure +# make +# make install + + +######################### +KVirc installation: + + +1) Get the KVirc sources: + +IMOPRTANT: Only the CVS sources compile cleanly with QT-MAC for now! + +# cvs -d:pserver:anonymous@cvs.kvirc.net:/cvs login + +You will be asked for a password: just hit return. + +# cvs -z3 -d:pserver:anonymous@cvs.kvirc.net:/cvs co kvirccvs + +Run autogen: +# cd kvirccvs/kvirc +# ./autogen.sh + + +2) Run configure + +The application bundle will be built in the kvirc sources directory. +Feel free to remove --enable-debug if you don't want to have a debuggable build and use addictional options like --enable-optimisation=2 or --with-big-channels. + +# ./configure --enable-pipes --enable-debug --exec-prefix=$(pwd)/KVirc.app/Contents/Resources --prefix=$(pwd)/KVirc.app/Contents --bindir=$(pwd)/KVirc.app/Contents/MacOS --libdir=$(pwd)/KVirc.app/Contents/Frameworks --datadir=$(pwd)//KVirc.app/Contents/Resources --disable-x-support + + +3) Run make + +CAUTION!!! Because of a problem with libtool you have to remove or rename the file libqt-mt.la (or libqt.la if you compiled QT without threads). It is located in $QTDIR/lib/. Otherwise the compilation will stop with a link error. + +# mv $QTDIR/lib/libqt-mt.la $QTDIR/lib/libqt-mt.la.bak + +Now run make and relax :-) + +# make + +(A debuggable, non-optimized build takes about 40 minutes on my PowerBook.) + + +4) Run make install + +# make install + + +5) Relinking + +KVirc and its modules depend on libkvilib and libqt which are not in the dynamic linker search path by default. The paths set during the compilation are absolute paths and have to be changed to be realtive to the executable path. + +The following commands do this for libkvilib: + +# install_name_tool -id @executable_path/../Frameworks/libkvilib.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib +# install_name_tool -change $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib @executable_path/../Frameworks/libkvilib.3.dylib $(pwd)/KVirc.app/Contents/MacOS/kvirc +# find $(pwd)/KVirc.app/Contents -name '*.so' | xargs -n1 install_name_tool -change $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib @executable_path/../Frameworks/libkvilib.3.dylib + +Now you have to decide whether you want to include libqt within the bundle or not. This is useful if you consider to share your bundle with your friends and they don't want to compile QT themselves. + + +a) You don't want to include libqt within the bundle + +Make sure the dynamic linker is able to find libqt. The easiest way is to make symlinks in the /usr/lib directory. + +# ln -sf $QTDIR/lib/libqt-mt.3.dylib /usr/lib +# ln -sf $QTDIR/lib/libqui.1.dylib /usr/lib + + +b) You want to include libqt within the bundle + +Copy libqt into the bundle: + +# cp $QTDIR/lib/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/ + +Relinking commands for libqt: + +# install_name_tool -id @executable_path/../Frameworks/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/libqt-mt.3.dylib +# install_name_tool -change libqt-mt.3.dylib @executable_path/../Frameworks/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/MacOS/kvirc +# install_name_tool -change libqt-mt.3.dylib @executable_path/../Frameworks/libqt-mt.3.dylib $(pwd)/KVirc.app/Contents/Frameworks/libkvilib.3.dylib +# find $(pwd)/KVirc.app/Contents -name '*.so' | xargs -n1 install_name_tool -change libqt-mt.3.dylib @executable_path/../Frameworks/libqt-mt.3.dylib + +6) Cleaning up + +The bundle is funtional but is looks better with a nice icon :-) +Copy the icon file from the data/resources_mac directory to the resources directory and the Info.plist file to the contents directory + +# cp data/resources_mac/kvirc.icns $(pwd)/KVirc.app/Contents/Resources +# cp data/resources_mac/Info.plist $(pwd)/KVirc.app/Contents + + +7) Enjoy :-) + +Open Finder, move your bundle into a better location (e.g. /Applications), and double click to start. + + diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 00000000..c23bd7d6 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,11 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +SUBDIRS = scriptexamples + +EXTRA_DIST = COPYING *.txt + + +tmpdir = $(licensedir) +tmp_DATA = COPYING diff --git a/doc/firefox.hack.txt b/doc/firefox.hack.txt new file mode 100644 index 00000000..4cdd239e --- /dev/null +++ b/doc/firefox.hack.txt @@ -0,0 +1,32 @@ +Firefox Hack Guide - HelLViS69 - 2007.02.08 +------------------------------------------------------------------------------- + +@ Prologue + +This guide is meant to be a simple hack to add protocols handlers to Firefox, +such as irc:// +This guide is been tested on Linux, Mac and Windows. + +@ How To + +- Open Firefox at the url about:config + You'll find the Firefox configuration + +- Click with right button, select New, then Boolean + As Name insert network.protocol-handler.external.irc and true as Value + +- Click with right button, select New, then String + As Name insert network.protocol-handler.app.irc + As Value you have to insert the path of KVIrc binary, eg /usr/bin/kvirc , + `which kvirc` or C:\Programs\Firefox\firefox.exe + +- Make sure that network.protocol-handler.expose-all are setted as true + +With these simple steps you can handle irc://irc.something.tld from Firefox + +If you want to add more protocols handlers, just follow the same steps changing +the protocol you want to add in firefox and the application you want to use to +handle the new protcol + +Elvio Basello +<HelLViS69> diff --git a/doc/hackers.guide.txt b/doc/hackers.guide.txt new file mode 100644 index 00000000..5eddcc8c --- /dev/null +++ b/doc/hackers.guide.txt @@ -0,0 +1,935 @@ +KVIrc hackers guide - Szymon Stefanek - 2004.05.26 +------------------------------------------------------------------------------- + +This is an always-work-in-progress guide for KVIrc source code hackers. + +------------------------------------------------------------------------------- +The source tree +------------------------------------------------------------------------------- + +/ Root directory. +| This is almost completely automake and autoconf stuff. +| +|-- admin Administrative files used during the compilation +| automake, autoconf and document generation scripts. +| +|-- data Data for the KVIrc program. Most of this stuff is +| | installed in $(prefix)/share/kvirc/$VERSION/ +| | +| |-- applnk *.desktop and menu entries for KDE +| | +| |-- config Default configuration files +| | +| |-- defscript The default script +| | +| |-- deftheme The default themes +| | +| |-- doctemplates Some document templates that get parsed by gendoc.pl +| | when the html documentation is generated +| | +| |-- helppics Data pictures for the html documentation +| | +| |-- icons Icons in various sizes +| | +| |-- man The manual pages +| | +| |-- mimelnk *.desktop entries for the *.kvs and *.kvc file types +| | that are respectively kvirc scripts and kvirc +| | configuration files. This is all stuff for KDE +| | +| |-- msgcolors Default sets of message colors +| | +| |-- pics Most of the pictures that KVIrc uses +| | +| |-- protocols irc:// and irc6:// protocol definitions for konqueror +| | +| `-- resources Resources for the windows compilation. +| +|-- debian Debian mantainer's stuff +|-- debian.robin +| +|-- doc Any kind of documentation +| | +| `-- scriptexamples Various script examples +| +|-- no-dist Stuff that does NOT end in the final distribution + +|-- po Internationalisation (i18n :) +| | +| |-- kvirc Translations for kvilib and the main KVIrc executable +| | +| `-- modules Translations for the modules +| +|-- scripts Some SHELL scripts. Probably only config is used atm. +| +|-- src The sources +| | +| |-- kvilib KVIrc library. Any source code snippet that can be +| | | abstracted enough to not depend on the KVIrc core +| | | ends up here. kvilib depends only on external stuff. +| | | +| | |-- build This is the build directory for automake. +| | | The main Makefile.am is here. +| | | +| | |-- config The headers that control the compile-time +| | | configuration. +| | | +| | |-- core The really basic classes: strings, memory management, +| | | error code defines etc.. +| | | +| | |-- ext Here ends everything that has no other specific place +| | | in kvilib. +| | | +| | |-- file File management and file utilities +| | | +| | |-- include Compile-time generated include files. these are +| | | only links. +| | | +| | |-- irc IRC protocol related classes. +| | | +| | |-- net Networking related stuff: sockets, ssl, http ... +| | | +| | |-- system System function wrappers or stuff that depends +| | | on the strict operating system support. +| | | Threads, localisation, env, time, shared library.. +| | | +| | `-- tal Toolkit Abstraction Layer: wrapper classes that +| | inherit from KDE* or QT classes, depending on the +| | compilation type. +| | +| |-- kvirc The KVIrc executable sources +| | | +| | |-- build Again the build directory for automake. +| | | Makefile.am is here. +| | | +| | |-- include Again compile-time include files. Only links. +| | | +| | |-- kernel The core of the executable. The main function is +| | | here. Here is also the KviApp object and the options +| | | core management. +| | | +| | |-- kvs The NEW shiny scripting engine. +| | | At the time of writing this two-stage UNICODE +| | | KVS interpreter is not finished yet and thus almost +| | | nothing here is really hardwired to the rest +| | | of the core. +| | | +| | |-- module The module management stuff: the loader, the module +| | | interface definitions etc.. +| | | +| | |-- sparser The IRC server parser +| | | +| | |-- ui User interface. 99% of the core GUI is here. +| | | Here you can find KviFrame (the main window) +| | | KviMdiManager, KviWindow, KviChannel, KviQuery, +| | | KviConsole, KviInput, KviIrcView and KviUserListView +| | | which are the most common widgets in kvirc. +| | | +| | `-- uparser The currently used scripting engine (user parser). +| | If you want to implement just some simple features +| | (like new commands or functions) then this is the +| | place to look at. If you want to make some long +| | term hacks then it's probably better to look at the +| | kvs directory instead. +| | +| `-- modules Yes, the modules :D +| | +| |-- about The about dialog +| | +| |-- aliaseditor The alias editor window +| | +| |-- avatar Avatar manipulation stuff +| | +| |-- chan $chan.* scripting stuff +| | +| |-- channelsjoin The channelsjoin dialog +| | +| |-- clock This was a clock applet but actually it is not +| | working and thus not compiled. +| | +| |-- codetester The codetester window +| | +| |-- config config.* scripting stuff +| | +| |-- dcc This module implements the whole DCC protocol. +| | Windows, transfer threads etc: everyting is here. +| | +| |-- dialog dialog.* scripting stuff +| | +| |-- dockwidget The dock widget for KDE and windows. +| | +| |-- editor The scripting editor core widget. +| | +| |-- eventeditor The event editor window +| | +| |-- file file.* scripting stuff +| | +| |-- filetransferwindow The file transfers window +| | +| |-- help The help browser +| | +| |-- http http.* scripting stuff +| | +| |-- ident A small ident daemon +| | +| |-- iograph Another applet that is not compiled for now. +| | +| |-- lag Lag meter +| | +| |-- lamerizer A crypt/text-transformation engine +| | +| |-- links The links window +| | +| |-- list The channel list window +| | +| |-- log log.* scripting stuff +| | +| |-- logview The logviewer window +| | +| |-- mask mask.* scripting stuff +| | +| |-- mircimport A server entry importer from the mirc's servers.ini +| | +| |-- mp3player mp3player.* scripting stuff +| | This is an interface to the xmms program on unix +| | and to winamp on windows. On unix libxmms.so is +| | loaded at runtime. On windows there is also +| | a gen_kvirc.dll plugin for winamp that needs +| | to be loaded by the winamp program in order to make +| | communications with KVIrc possible. +| | +| |-- my my.* scripting stuff +| | +| |-- objects All the object oriented scripting stuff +| | +| |-- options The options dialog +| | +| |-- popupeditor The popup editor window +| | +| |-- raweditor The raw events editor window +| | +| |-- regchan regchan.* scripting stuff +| | +| |-- reguser reguser.* scripting stuff +| | +| |-- rijndael A crypting engine +| | +| |-- setup The module that is loaded when KVIrc is started +| | for the first time. It contains the initial +| | configuration wizard. +| | +| |-- sharedfile sharedfile.* scripting stuff +| | +| |-- sharedfileswindow The shared files window +| | +| |-- snd snd.* scripting stuff +| | +| |-- socketspy The socketspy window +| | +| |-- spaste spaste.* scripting stuff +| | +| |-- str str.* scripting stuff +| | +| |-- system system.* scripting stuff +| | +| |-- tb_options The options toolbar +| | +| |-- tb_scripting The scripting toolbar +| | +| |-- tb_winops The window operations toolbar +| | +| |-- term The embedded terminal emulator (needs KDE) +| | +| |-- tip The tip of the day +| | +| |-- tmphighlight tmphighlight.* scripting stuff +| | +| |-- toolbar toolbar.* scripting stuff +| | +| |-- toolbareditor The toolbar editor window +| | +| |-- url The url window +| | +| `-- window window.* scripting stuff +| +`-- win32build The directory for Windows builds + + +[pragma@phoenix src]# cat $(find ./ -name \*.h) | wc -l + 60189 +[pragma@phoenix src]# cat $(find ./ -name \*.cpp) | wc -l + 164400 + + +------------------------------------------------------------------------------- +The coding style +------------------------------------------------------------------------------- + +The coding style helps the reader a lot. In a large project you tend +to forget the exact meaning of some functions or variables. +A good naming convention makes the code "auto commenting": by looking +at the name of a variable or function you can understand its type +and guess its meaning and usage. +Following these rules is not strictly mandatory (maybe with the +exception of the first one) but it is highly appreciated. + +- INDENT WITH TABS (the only MANDATORY rule) + + Go back to the line above and read it again. + + INDENT, TABS. + + Tabs can be assigned any number of spaces in any decent source code + editor. + + Actually 95% of the KVIrc code is indented in BSD/Allman style + but the K&R style is also tolerated. + +- Try to use the following variable naming conventions + + g_* : global variables + m_* : member variables + no prefix : any other scope + + [prefix]pName : pointer to something named Name + [prefix]iName : integer (signed) variable named Name + [prefix]uName : unsigned integer + [prefix]szName : string named Name + [prefix]dName : floating point vars + [prefix]eName : enumerated value variables + [prefix]tName : kvi_time_t values + + i,j,k,tmp,aux,p : short names are used for short term variables + like the temporaries used in functions. + Do NOT name a member or global variable i. + + So finally: + + g_pApp is a global pointer to the application object + m_pData is a member variable pointer to some data object + m_szName is a string member variable named Name + szPippo is a string variable named Pippo + tmp is a short term temporary variable + i,j,k are probably some short term iteration variables + ... + + +- Function names + + C++ class member functions + Function names start with lower case letters. Each word except the first + one should start with an upper case letter. Try to use descriptive names + and not acronyms or shortcuts (unless they are really obvious). + For example: + fillUserList, setAutoDelete, joinChannel, markQueryAsDead ... + Standalone C/C++ functions + For standalone functions you can follow the C++ rule but the + kernel-like syntax is also acceptable (all low case letters with + underscore separators). + If you're defining a widely used C function (maybe in kvilib) + then adding a kvi_ prefix is also a good idea. + +- Class names + + The class names start with an upper case letter. In most cases + there is a Kvi prefix and the rest follows the rule for function names. + KviApp, KviConsole, KviWindow, KviStr, KviConfig, KviUserParser ... + + If possible, do not use "shortcut" names. + Actually KviCommand is preferred over KviCmd unless the KviCmd class + is REALLY widely used across the source (like KviStr for example). + + This helps a lot in remembering the class names: with the shortcuts + you're often forced to open the corresponding header file to look up + which letters have been left off... + + Structure names usually follow the same conventions. + +- Simple data types + + If you need to define a simple data type then something like kvi_typename_t + is a good choice. + +- Preprocessor + + Preprocessor macros should be all uppercase with undescores separating + words. + +- Comment the code + + You don't need to write poems: two lines describing what a function + does will be enough. + If a function is simple and its meaning is clear from its name + then comments are not needed (this is why we're using expressive + variable and function names). + Single line C++ comments are preferred over the C style comments. + +------------------------------------------------------------------------------- +Coding tips +------------------------------------------------------------------------------- + +- Don't use C++ exceptions: they make the code unmanteinable in the long term + +- If you need to access some system function then first look if there is + an existing kvi_* wrapper and use that one instead. The wrapper is there + because of portability issues. + +- Don't use the STL features: anything that you need IS either in the Qt library + or in kvilib. + +- Windows compilation has COMPILE_ON_WINDOWS #defined and a KDE compilation + has COMPILE_KDE_SUPPORT #defined. + +- Modularize, abstract, modularize, abstract ... + +- When your objects need to be allocated with new in a module and destroyed + in the kvirc core or kvilib (or viceversa) then derive the class from + KviHeapObject that will provide the new and delete operators. + This is a workaround for Windows that uses a separate + heap for each executable module (*.exe or *.dll). Data allocated on one + heap must be freed on the same heap. + +------------------------------------------------------------------------------- +The strings +------------------------------------------------------------------------------- + +This is the list of the various string types used in KVIrc. + +(const) char * + The classic C null terminated string. + +KviStr + The basic KVIrc string class. It has been first implemented as a hack + around various bugs of the original QString class (the NOT unicode one + that now has been renamed to QCString). It has the property of being + always non null and it has no reference counting. + Actually many occurences of this string are replaced by QString + (especially in GUI modules) to handle correctly the UNICODE character set. + +QString + The Qt UNICODE string. See the Qt documentation for details. + This is the string that should be mostly used in KVIrc in the near future. + Take care: in general it is NOT null terminated. + There is a KviQString wrapper namespace (#include "kvi_qstring.h") that + adds some missing functionality. For example, + KviQString::sprintf(qstring_buffer,qstring_format,...) + allows formatting a QString with a format string that is a QString itself + (and thus it is UNICODE). + QString uses reference counting. An assigment of a QString to another + QString does NOT make an immediate copy, it just increases the reference + count instead. The copy is made at the first modification of one of the + two strings (the operation is called "detaching"). While generally this + is not an issue, you must take care when passing QString objects between + concurrent threads. + +(const) QChar * + The array of Qt chars. This is usually obtained by callling + KviQString::nullTerminatedArray() which itself is a hack... + This array is used in some functions that were written for + const char * strings and haven't been ported completely. + +QCString + The Qt non UNICODE string. See the Qt documentation for details. + +The Goal: + - Use KviStr only where it is strictly needed (for protocol or performance + related issues). One of such places is the IRC server parser (but there + are more). + - Use QString everywhere in the user interface and in any other + place where KviStr is not strictly needed. Save and restore + strings in the UTF8 format. + - Get rid of ALL occurences of KviWStr and kvi_wchar_t * : DONE on 2004.11.02 + +------------------------------------------------------------------------------- +Strings and localisation +------------------------------------------------------------------------------- + +Any string that is shown to the user should be translated to the user's local +language. To make a string translaetable use one of the __tr* macros. +The most common one across the sources is __tr("string") that returns +a const char * translation of "string". +Actually __tr() is being phased out in favor of __tr2qs() that returns +a QString instead of a const char * pointer. +The arguments of these macros are extracted from the sources by the +gettext program and are used to build the translation hashes loaded at runtime. +Remember that the arguments must be string constants and not variables. + +The list that follows describes briefly the localisation macros +defined in kvi_locale.h + +CSTRING is an US-ASCII null terminated C string. + +__tr2qs(CSTRING) : translates CSTRING to a QString & +__tr(CSTRING) : translates CSTRING to another CSTRING + This should disappear in favor of __tr2qs + +These macros are NOT THREAD SAFE: you can't call them from non GUI threads. +If you need to translate some string in a slave thread (probably when +sending a message event to the main GUI thread) then you need to use the +__tr_no_lookup() (on the slave side) and __tr_no_xgettext() (on the master side). + + +------------------------------------------------------------------------------- +Anatomy of an IRC context +------------------------------------------------------------------------------- + + +KviIrcContext [persistent set of resources] + | + +--KviIrcConnection [changed at every connection, with (almost) all the children] + | | + | +--KviIrcConnectionTarget [target server, proxy to use and address to bind] + | | | + | | +--KviIrcServer + | | | + | | +--KviProxy [null if not using a proxy] + | | + | +--KviIrcLink [high level network link: trasmits and receives IRC messages] + | | | + | | +--(KviIrcConnectionTargetResolver) [kickstarts the connection] + | | | + | | +--KviIrcSocket [low level network link: transmits packets of bytes] + | | + | +--KviPtrList<KviChannel> [active channels] + | | + | +--KviPtrList<KviQuery> [active queries] + | | + | +--KviIrcConnectionUserInfo [nick, user, host, local ip...] + | | + | +--KviIrcConnectionServerInfo [name, supported modes, supported flags...] + | | + | +--KviNotifyListManager [kvi_notifylist.h] + | | + | +--... + | + +--KviConsole [persistent] + | + +--(KviLinksWindow), (KviListWindow) [other may-be-persistent context windows] + | + +--KviPtrList<KviChannel> [dead channels] + | + +--KviPtrList<KviQuery> [dead queries] + | + +--... + +KviIrcContext is the set of resources used to deal with a single irc +connection. An irc context is persistent and reusable until the user decides to +destroy it. The irc context owns the console window (KviConsole) that is +strictly tied to the lifetime of the context itself. The console is created +when the IRC context is created and when the user closes the console then +the IRC context is destroyed too. +In earlier KVIrc versions there was only KviConsole that did the role of both +KviConsole and KviIrcContext, but since the class has grown in complexity +to a point where it started to be unmantainable the splitting has been unavoidable. + +KviIrcConnection rappresents an IRC connection: it is the highest protocol +implementation on the KVIrc's networking stack. A KviIrcConnection +owns a KviIrcLink (that is the lower level). KviIrcConnection is NOT reusable: +it lives only for the lifetime of a single IRC connection inside the parent +irc context. KviIrcConnection talks to the parent's KviConsole. +The connection target is a KviIrcConnectionTarget class and it contains +the KviIrcServer, KviProxy and the eventual bind address. The owned target +is passed down the networking stack to the lower level classes. +The connection contains also the lists of queries and channels currently opened. +When a channel or query is marked as dead then its ownership is passed to +the KviIrcContext (it becomes permanent between two connections). +The connection owns a lot of other interesting classes to take a look at: +KviIrcConnectionUserInfo, KviIrcConnectionServerInfo, KviNotifyListManager... + +KviIrcLink is the middle level of the KVIrc's networking stack. +It handles host lookups, the connection startup and data stream input and output. +This is meant to be a "pluggable" class: it should be flexible enough to allow +inheritance and protocol overriding. KviIrcLink owns and manages the KviIrcSocket. +It takes care of extracting IRC protocol messages from the KviIrcSocket raw data +stream and of formatting the outgoing messages by adding the trailing CRLF. +The host lookups are done by the means of KviIrcConnectionTargetResolver. + +KviIrcSocket is the lowest level of the KVIrc's networking stack. +It manages the connection through proxies and accesses the system level +socket directly. The incoming data stream is passed to KviIrcLink::processData() +and the outgoing data stream is received through KviIrcSocket::sendPacket() +KviIrcSocket also manages the outgoing send queue and implements the +"anti-server-flood" algorithm. +This class doesn't know anything about the IRC protocol: it just receives +and sends out raw data packets! + + +....... + +kvirc (KviApp) + | + +-frame window (KviFrame) + | + +-irc_context 1 (KviIrcContext) + | | + | +-irc_connection (KviIrcConnection) + | | | + | | +-list of channels + | | | + | | +-list of queries + | | | + | | +-irc_link + | | + | +-console (KviConsole) + | + +-irc_context 2 + | ... + + +KviConsole <-> KviIrcContext + +------------------------------------------------------------------------------- +Important global variables +------------------------------------------------------------------------------- + +All these variables are almost alwas set (and point to a real alive object). +The only critical moments where these variables must be double checked +are the startup phase and the shutdown phase. +Do not attempt to change the values of these variables unless you REALLY know +what you're doing. + + +KviApp * g_pApp; + The one and only application object + Declared in "kvi_app.h" + Always set. + +KviServerParser * g_pServerParser; + The one and only server parser + Declared in "kvi_sparser.h" + Almost always set (critical phases at early startup and late shutdown) + +KviFrame * g_pFrame; + The one and only main window + Declared in "kvi_frame.h" + Almost always set (critical phases at early startup and late shutdown) + +KviWindow * g_pActiveWindow; + The one and only active window + Declared in "kvi_window.h" + Almost always set (critical phases at early startup and late shutdown) + +Note for C++ purists: In fact we could be using the protected singleton pattern +on most of these variables and access it by the means of Class::instance(). +The global var names save some typing and can be written by any other class +without having to worry about friends or write-access functions. + +------------------------------------------------------------------------------- +The charset mess +------------------------------------------------------------------------------- + +IRC is not UNICODE :/ ... sigh ... +The fact is that every user wants his local encoding to be used. +KVIrc tries to be even smarter and allow a different encoding for each window. +This is a difficult task since we simply can't translate the strings that +come from and go to the server just at the socket level. + +User -> Server + +We need to allow the local user to write UNICODE data, encode it to the +proper charset (again depending on the window the text was typed in) and +send it down to the server. +When the user writes commands this is going to become a little mess since +nicknames, channel names or usernames may or may not be encoded in the +encoding of the current window. + +Server -> User + +We need to carry the plain 8bit data (in whatever encoding it is) from the +server up to the GUI level, then convert to UNICODE by choosing the proper +decode routine just when we know in which window the text is going to be +displayed. In (non RFC) servers that allow encoded characters in nicknames +this is going to become a real mess since the same 8bit nick may result in +a different UNICODE string depending on the window it was "decoded" on. + +(Partial) Solution: +- Each server has an encoding set. If empty then the network encoding is used. +- Each network han and encoding set. If empty then the default system encoding + is used. +- The system encoding is set by the user. If empty then the encoding is guessed + from the user's locale. +- Each window (with the exception of the console) has its own encoding used + ONLY for private messages and notices. This allows one to join + a channel with a "special" encoding and still see what's being written in. + The real utility of this last feature still needs to be evaluated. + +------------------------------------------------------------------------------- +Output levels +------------------------------------------------------------------------------- + +There are few macros that specify the output level that the user desires. +These marcors are defined in "kvi_options.h" + +_OUTPUT_MUTE: returns true if the user wants KVIrc to spit less useless output + possible. The goal of the user is to chat on IRC so print only data + relevant to this. If stuff goes wrong then print the errors in + short forms (one liners) and do it only in case of serious ones. + Don't print any transient error or warning. + Usage: if(!_OUTPUT_MUTE)output... + +_OUTPUT_QUIET: returns true if the uses wants KVIrc to spit less output than + normal. The goal of the user is to chat visually on IRC so print + only data relevant to this. + Usage: if(!_OUTPUT_QUIET)output... + +<normal level>: Reference output level: here stuff is printed unconditionally. + Usage: output... + +_OUTPUT_VERBOSE: returns true if the users allows KVIrc to print some + additional output. This is intended mainly for scripters and + curious pepole that want detailed informations about what is going + on around them. + Usage: if(_OUTPUT_VERBOSE)output... + +_OUTPUT_PARANOIC: returns true if the users allows KVIrc to print anything + including debug info. This is intended mainly for developers. + Usage: if(_OUTPUT_PARANOIC)output... + +------------------------------------------------------------------------------- +Rule for safe text output +------------------------------------------------------------------------------- + +If the format string you're going to output is not constant (i.e. it +comes from the server) you MUST use KviWindow::outputNoFmt() instead +of KviWindow::output(). + +BAD: + QString szText = pConnection->decodeText(msg.safeTrailing()); + pWindow->output(KVI_OUT_SOMETHING,szText); <--potential crash/security hole + +GOOD: + QString szText = pConnection->decodeText(msg.safeTrailing()); + pWindow->outputNoFmt(KVI_OUT_SOMETHING,szText); <--faster and no crashes + +------------------------------------------------------------------------------- +KVIrc (and script) versioning +------------------------------------------------------------------------------- + +- Standard definition + +The KVIrc versioning follows a really common standard: we use a +string of numbers separated by dots with decreasing weight from left to right. + + <N1>.<N2>.<N3>.<N4>..... + +where each <NX> is a number. + +Theoretically there is no limit on the parts the version can be composed +of but in fact we use either three or four part versions. The omitted +parts on the right are implicitly assumed to be 0. + +The first part is called the major release number and it is bumped +up only when really big changes occur in the source tree. A bump from N to N+1 +in the major version number means that a great milestone has been achieved +and the software is really different from what it was in the moment +when the major number was bumped from N-1 to N. This usually also means +that the software might be somewhat incompatible with the previous major release. + +When the major number is bumped up all the following parts are reset to 0 +(and could be even temporairly omitted). + +The second part is called minor release number and it is increased +more often than the major. A bump from N to N+1 in the minor version number +means that an ordinary (small) development milestone has been achieved. +Software versions with the same major and close minor numbers are likely +to be totally compatible with each other. + +When the minor number is bumped up all the following parts are reset to 0. + +The third part is called (public) revision number and it is increased often. +A bump from N to N+1 in the revision number usually means that a set of bugfixes +or some new features have been included in the software. Compatibility +should be assumed unless explicitly noted. Again, when the revision number +is bumped up all the following parts are reset to 0. + +The fourth part is actually used only on the svn tree and it is usually not +present in the official public releases (it is assumed to be 0 for comparison +purposes). It is called the "internal revision" number and when taken +out of the version string it may assume a meaning on its own (but it's not +required in fact). KVIrc uses the ISO sources date in the format YYYYMMDD for this +number. The sources date number is defined in src/kvilib/config/kvi_sourcesdate.h +and is also displayed by kvirc --version. Some packagers prefer to use the svn +revision number instead of the sources date. This is not "official" but it's +still ok as long as it follows the "order-preserving" rule (see below). + +It is unlikely that you will find a KVIrc versioned with more than +four numbers... but if you will (for some strange reason) then it will +still follow the same rules: it will be increased for yet minor changes +(two versions within a single day ?) and will be reset to (implicit) +zero when the fourth part changes. + +- Comparison of version strings + +The comparison of two version strings is defined as follows. +Let N1.N2.N3.N4.N5..... and M1.M2.M3.M4.M5..... be version strings. +To find out which one is greater compare each couple of numbers Ni-Mi at the same +position i (with the same weight) until Ni and Mi differ or both Ni and +Mi are omitted. If both Ni and Mi are omitted then the version strings +are equal, otherwise the greater version string is the one that +contains the greater of the Ni - Mi couple. Easy, right ? + +This means that to compare 3.2.6.3.4 and 3.2.9 you first compare +3 with 3 and find that they are equal. Then you compare 2 with 2 +and find that they are equal. Then compare 6 with 9 and find that +they are different and 9 is greater. This allows you to say that +the first version string is greater than the second. + +To compare 3.2.6.1 with 3.2.6 you compare 3 and 3, 2 and 2, 6 and 6 +and 1 with (implicit) 0, that tells you that the first version string +is greater than the second one. + +This also means that 3 and 3.0.0 are assumed to be EQUAL since +the algorithm above finds that at the fourth comparison step +both numbers are omitted (thus zero from there up to infinity). + +This comparison function is monotonically increasing or in +other words order-preserving. This is a *requirement* for a consistent +versioning scheme. + +- Package versioning schemes with letters + +It is common for packages to add letters to some of the parts +of the version string. This causes the string to lose the +advantage of being universally comparable but it might still +define a consistent scheme for some package line. In the case +that letters are added to a version string (like 3.2.6.svn10) +we say that it is comparable only to the version strings +that have the same letter pattern: 3.2.6.svn10 and 4.3.1.svn344 +are comparable but 3.2.6.svn10 and 3.2.6.cvs15 are not. +For comparable strings we strip the letters in order to make the comparison. + +- Stable and unstable versions + +Our numbering scheme does NOT tell which versions are stable +and which are unstable. The versions are declared to be (more or less) stable +by other means (read: the mailing list and the www site). +It is true, tough, that stable versions are likely to have +more numbers omitted (read: 3.5 looks more "stable" than 3.4.5.43), +but this is not a strict requirement. It is also true that +almost all "unstable" versions come out from the svn tree and +usually contain all the four parts. + +- Official, semi-official and unofficial packages + +We tend to have three types of packages. The official packages are the +ones considered to be stable and released on the site in all the supported forms +(source and various kinds of binaries). The official releases are also announced +in tracker sites and spread between distributors. Since "most" stable, the +official releases are the ones likely to be included in the OS distributions. +The official packages have md5 sums and a gpg signature of one of the KVIrc +developers (with a public key available from a "trusteable" location such +as the KVIrc web site). + +The semi-official packages are snapshots of the source tree made when +some important changes have occured. They are announced on the KVIrc site +only and are likely to be stable (but are not declared officially to be so). +The semi-official packages usually are at least in the source form but +there are likely to be some binaries available too. +We do not sign the semi-official packages but it's still somewhat +granted that WE (the KVIrc Development Team) make them and thus the +source can be trusted. + +The unofficial packages are random snapshots of the svn source tree made +by anyone who wants to do it at any time. They are not announced on the KVIrc +web site (but might be uploaded to ftp.kvirc.net) but rather announced and available +at some other internet location. Since we always try to keep the svn +tree clean and compilable they should work fine but there is no guarantee. +There is no rule for the unofficial package format: there might be source-only +or binary only packages. We *suggest* to use the four part version string format +but in fact they might contain third party patches and even follow their own +derived version numbering scheme. The general rule is: we don't control +the unofficial packages and don't provide support if they don't compile/work +as expected the user/packager is on his own.. but we'll try to be helpful, +if possible :) + +- Putting it all together + +At the moment of writing the KVIrc svn tree has version 3.2.6.20070115. +Today is 15 Jan 2007 and the current svn revision number is 174. +The latest "semi-official" release was 3.2.6 (where the internal revision number +was omitted and implicitly assumed to be 0). +If tomorrow we had to emit a quick fix for the semi-official release we'd either +use 3.2.7 (increasing the public revision for a large set of bugfixes) or +(unlikely) 3.2.6.20060116 (expliciting the internal revision number for a small +set of quick, and probably dirty, bugfixes). The next "semi-official" +release is likely to be 3.2.7 while the next official stable release +might be 3.3, 3.4 or even 4. + +------------------------------------------------------------------------------- +Porting to Qt 4.x (while mantaining Qt 3.x compatibility) (Work In Progress) +------------------------------------------------------------------------------- + +For the moment, in random order: + +- Avoid using QString::null, use KviQString::empty instead. + This is because Qt 4.x does NOT have a null static variable. Qt 4.x in fact + does not have the distinction between null and empty strings (Note that for + KviStr this choice was made since the beginning). + Do NOT replace all the uses of QString::null with QString() (as the qt 4.x + porting documentation suggests) since for Qt 3.x this construct is SLOW. + +- We're building a compatibility layer in kvilib. + Before using ANY Qt class, look if there is an override in kvilib. + In fact always, prefer Kvi* classes over the Q* ones and include + the "kvi_*.h" files instead of the <qt*.h> ones. + +- Widgets will be probably abstracted in kvilib/tal. + +- Qt 4.x has no QCString anymore. It uses QByteArray instead. From my own + point of view this is ugly since the name is misleading and QByteArray + is forced to mantain the null terminator which is not needed + in normal "byte array" operations...but well, we have to live with it. + kvilib has kvi_qcstring.h that defines the KviQCString MACRO. + It expands to QCString under Qt 3.x and QByteArray under Qt 4.x. + +- Use: + #ifdef COMPILE_USE_QT4 + to check if the compilation requires Qt 4.x or Qt 3.x. + Later this *might* be automatically replaced with + #if QT_VERSION >= 0x040000 + +- Use: + ./configure --enable-debug --enable-qt4 --with-qt4-moc=/path/moc + make clean + make + to switch to Qt 4.x + Use: + ./configure --enable-debug + make clean + make + to switch back to Qt 3.x + +- Use less possible Qt3Compat features. + +- Before committing to the svn always test your changes under Qt 3.x: this is + the primary goal for now: keeping 3.x compatibility. + Qt 3.x-only developers are encouraged (but not required) to test their + changes agains Qt 4.x. + +- Use the KviQString::* wrapper functions around QString (take a look at + kvi_qstring.h) even if there exist QString functions that do the same + thing. This is because the QString interface has changed a lot between + Qt 3.x and Qt 4.x and KviQString introduces a compatibility layer. + +- Do not use the "char * c = KviQString::toUtf8(string).data();" construct. + It leads to crashes on many compilers since the returned KviQCString + goes out of scope just at the end of the instruction. + +------------------------------------------------------------------------------- +Code documentation +------------------------------------------------------------------------------- + +KVIrc is LARGE. We need to start documenting the source code if we want +to understand our own code in a year from now and if we want help from +others. + +Use doxygen. + +There is a Doxyfile in the admin subdirectory. You can either +run doxygen from there or simply type "make devdocs" from the +top directory of the source tree. +Then take a look at doc/api/html/annotated.html + +Let's also try to document the code we write: the doxygen syntax +is trivial and you can find a 5 minute tutorial by googling. + diff --git a/doc/scriptexamples/Makefile.am b/doc/scriptexamples/Makefile.am new file mode 100644 index 00000000..a63d4435 --- /dev/null +++ b/doc/scriptexamples/Makefile.am @@ -0,0 +1,7 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +SUBDIRS = antiidle minesweeper mp3share playing runmenu simplehttp tutorial + +EXTRA_DIST = *.kvs diff --git a/doc/scriptexamples/README b/doc/scriptexamples/README new file mode 100644 index 00000000..be35ddce --- /dev/null +++ b/doc/scriptexamples/README @@ -0,0 +1,6 @@ +This directory and the subdirectories contain a set of KVIrc scripting examples/tests. + +The *.kvs files in this directory are mostly tests written while implementing scripting +language features. They're rather simple (but also useless) so you can use them to learn basic scripting :) + +The subdirectories contain more complex scripts written with the demonstration purpose. diff --git a/doc/scriptexamples/antiidle/Makefile.am b/doc/scriptexamples/antiidle/Makefile.am new file mode 100644 index 00000000..840a6b4e --- /dev/null +++ b/doc/scriptexamples/antiidle/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = antiidle.kvs diff --git a/doc/scriptexamples/antiidle/antiidle.kvs b/doc/scriptexamples/antiidle/antiidle.kvs new file mode 100644 index 00000000..a4b59cca --- /dev/null +++ b/doc/scriptexamples/antiidle/antiidle.kvs @@ -0,0 +1,159 @@ +# +# anti idle script +# : some people like it, some people need it +# : by Balboy :)) +# + +# creating the main alias + +alias(aidle) +{ + # using a switch to see what option has been selected + switch($0) + { + # ok, so the script should start + case(start): + { + # checking if it wasn't running already + if(!%Aidlestatus{$ic}) + { + # the script wasn't running already, so it should be started by calling the + # script with the run parameter + aidle internal_run + # saving the status of the anti idle script + %Aidlestatus{$ic} = 1 + # an anti idle var is set, to define the speed of the anti itde script + # there are 2 possible ways + %Aidletype{$ic} = 1 + echo "Anti idle has been enabled" + } else { + # the script was already running + echo "Anti idle has already been enabled on this server" + } + } + break + # the script should be halted + case(stop): + { + # checking if it was already running + if(%Aidlestatus{$ic}) + { + # the script was running, so it should be stopped by killing the timer + killtimer antiidle{$ic} + # clearing variabled + %Aidlestatus{$ic} = "" + %Aidletype{$ic} = "" + echo "Anti idle has been disabled" + } else { + # the script wasn't running + echo "Anti idle has not been enabled on this server" + } + } + break + # the script status should be shown + case(status): + { + # checking the status variable + if(%Aidlestatus{$ic}) + { + echo "anti idle is enabled on this server" + } else { + echo "anti idle is disabled on this server" + } + } + break + # this is a parameter that should only be called by the script itself + # this is where the idle time gets actualy killed + + case(internal_run): + { + # this part will make a varianle to switch random anti idle modes (fast/slow) + # note: once a type has been decided, changing the type works by a small chance + %aidletypecheck{$ic} = $rand(100) + if(%aidletypecheck{$ic} < 10) + { + if(%Aidletype{$ic} == 1) + { + %Aidletype{$ic} = 2 + } else { + %Aidletype{$ic} = 1 + } + } + # use the var just created to start one of the anti idle modes + if(%Aidletype{$ic} == 1){ + # starting a timer who will keep sending messages to yourself, no output will be shown + timer -r=$console -s (antiidle{$ic},$(10000 + $rand(50000))) + { + aidle internal_run + # checking if we are online + if($server) + { + raw -q privmsg $me : + } + } + } else { + # this part is simular as above + timer -r=$console -s (antiidle{$ic},$(10000 + $rand(30000))) + { + aidle internal_run + if($server) + { + raw -q privmsg $me : + } + } + } + } + break + # the script should be uninstalled + case(uninstall): + { + echo "the anti idle script has been uninstalled succesfully" + # defining the alias by empty code will remove it + alias(aidle){} + event(412,aidle){} + + } + break + # if help was asked + case(help): + { + echo "usage: /aidle <option>" + echo "" + echo "possible options:" + echo "start start the anti idle" + echo "stop stop the anti idle" + echo "status tell you if the anti idle script is enabled or not" + echo "uninstall uninstall the script" + echo "help this help output" + } + break + # if the parameter you give with the anti idle script is not valid + # a small program usage is printed + default + { + echo "Unsupported anti idle parameter ($0)" + echo "Try '/aidle help' for more information." + } + } +} + + +# creating an event + +event(412,aidle) +{ + # this raw will stop the error messages you will get from the server, + # every time you send an empty msg to yourself + halt; +} + +# and at last, we also put some output, with some information :) + +echo "installation of the anti idle script succesful" +echo "you can always uninstall it by typing /aidle uinstall" +echo "just type '/aidle help' to get all the possible commands" +echo "---" +echo "Happy ircing or should i say idling :)" +echo "Balboy and The KVIrc Development Team" + +# hint for later: $window.list(console,all) diff --git a/doc/scriptexamples/class1.kvs b/doc/scriptexamples/class1.kvs new file mode 100644 index 00000000..6098000d --- /dev/null +++ b/doc/scriptexamples/class1.kvs @@ -0,0 +1,102 @@ +# Example of object function overriding and calling +# This is quite intricated...try to get out of this +# by examining the code. + +class (A,object) +{ + # The base class at all + # Implements $A::function and $A::virtual + function + { + echo -i=10 "$0\Entering A::function()" + $$->$virtual("----$0") + echo -i=10 "$0\Exiting A::function()" + } + virtual + { + echo -i=10 "$0\This is A::virtual()" + } +} + +class (B,A) +{ + # Derived from A : inherits $A::function() + # overrides $A::virtual + virtual + { + echo -i=20 "$0\Entering B::virtual()" + $$->$A::virtual("----$0") + echo -i=20 "$0\Exiting B::virtual()" + } +} + +class (C,B) +{ + # Derived from B : inherits $B::virtual and + # overrides $B::function (that is $A::function) + function + { + echo -i=30 "$0\This is C::function" + } +} + +echo -i=7 "Ok...now try to gusess what's going on :)" + +%o = $new(C,0,test) + +echo "# Calling \%o->\$function" +%o->$function +echo "# Calling \%o->\$C::function" +%o->$C::function +echo "# Calling \%o->\$B::function" +%o->$B::function +echo "# Calling \%o->\$A::function" +%o->$A::function +echo "# Implementing private \%o->\$function" +privateimpl(%o,function) +{ + # This is a private implementation that + # overrides $C::function + echo "$0\Entering \$\$::function" + $$->$C::function("----$0"); + echo "$0\Exiting \$\$::function" +} + +echo "# Calling \%o->\$function" +%o->$function +echo "# Calling \%o->\$C::function" +%o->$C::function +echo "# Calling \%o->\$B::function" +%o->$B::function +echo "# Calling \%o->\$A::function" +%o->$A::function +echo "# Implementing private \%o->\$virtual" +privateimpl(%o,virtual) +{ + # This is a private implementation that + # overrides $C::virtual (that is $B::virtual in fact) + echo "$0\Entering \$\$::virtual" + $$->$C::virtual("----$0") + echo "$0\Exiting \$\$::virtual" +} + +echo "# Calling \%o->\$function" +%o->$function +echo "# Calling \%o->\$C::function" +%o->$C::function +echo "# Calling \%o->\$B::function" +%o->$B::function +echo "# Calling \%o->\$A::function" +%o->$A::function +echo "# Removing private \%o->\$function" +privateimpl(%o,function){} +echo "# Calling \%o->\$function" +%o->$function +echo "# Calling \%o->\$C::function" +%o->$C::function +echo "# Calling \%o->\$B::function" +%o->$B::function +echo "# Calling \%o->\$A::function" +%o->$A::function + +delete %o diff --git a/doc/scriptexamples/exprtest.kvs b/doc/scriptexamples/exprtest.kvs new file mode 100644 index 00000000..c07d199d --- /dev/null +++ b/doc/scriptexamples/exprtest.kvs @@ -0,0 +1,24 @@ +# A stresstest for the expression evaluation engine + +alias(exprtest) +{ + %txt = "Testing expression:" $0; + + %ret = ${ eval "return \$(" $0 ")"; } + if(%ret != $1) + { + %txt .= " ... Failed (return value" %ret "!=" $1")"; + echo %txt + } else { + %txt .= " ... Success (return value $1)"; + echo %txt + } +} + +exprtest "5 - 0 - 1" 4 +exprtest "5 - (0 - 1)" 6 +exprtest "2+3-5+3+1-2-3-8+5*3-2" 4 +exprtest "2*2 + 2*2 - 2*2" 4 +exprtest "-1" -1 +exprtest "--1--1" 2 +exprtest "-1+1" -2 diff --git a/doc/scriptexamples/label1.kvs b/doc/scriptexamples/label1.kvs new file mode 100644 index 00000000..d66cf154 --- /dev/null +++ b/doc/scriptexamples/label1.kvs @@ -0,0 +1,39 @@ +# A little label test. + +class(myLabel, label) +{ + constructor + { + $$->$setBackgroundColor(dcdc00); + $$->$setAutoResize(0); + $$->$setGeometry(10, 10, 500, 150); + $$->$setAlignment(Center); + $$->$setText("Come here !"); + } + + mouseEnterEvent + { + $$->$setMargin(10); + $$->$setAlignment(Right, Top); + %al = "My alignment is $$->$alignment(), and I have margin $$->$margin() pixels wide !"; + $$->$setText(%al); + $$->$setFrameStyle(Panel, Raised); + echo "Label frame style: $$->$frameStyle()"; + } + + mouseLeaveEvent + { + $$->$setMargin(0); + $$->$setAlignment(Left, Bottom); + %al = "My alignment is $$->$alignment(), and I have margin $$->$margin() pixels wide !"; + $$->$setText(%al); + $$->$setFrameStyle(Panel, Sunken); + echo "Label frame style: $$->$frameStyle()"; + } +} + +%w = $new(widget, 0); +%w->$resize(520, 170); +%w->$move(50, 50); +%l = $new(myLabel, %w); +%w->$show(); diff --git a/doc/scriptexamples/mail.kvs b/doc/scriptexamples/mail.kvs new file mode 100644 index 00000000..94fb70e2 --- /dev/null +++ b/doc/scriptexamples/mail.kvs @@ -0,0 +1,159 @@ +# This is a really basic mail sender script +# It uses exec and a telnet slave process +# You will probably need to hack it a bit since +# most mail servers will simply refuse to +# send so spam-looking mail :D + +# Ah... remember that spamming creates bad karma. + + +# exec a telnet slave. +# Since we want to make sure that it does not run for too long, +# we give it 60 seconds to complete the operations + +exec -x -k=60000 -t -e ("telnet my.mail.server.com 25") +{ + # We keep the state in the %:state extended scope variable + + if($0 == "started") + { + # This is the first event triggered + # Initialize our variables... + echo [process started] + %:state = 0 + # This is the source address as specified in the MAIL command + %:from = "<me@me.com>" + %:rcpt = "<me@me.com>" + # This is the From field + %:sender = "\"Me\" <me@me.com>" + %:receiver = "\"Me\" <me@me.com>" + %:body = "Hello, this is a test mesage for the small KVIrc mail script$cr$lf" + %:body .= "I hope that you have fun writing in kvs :)))" + %:subject = "This is a test subject" + # Returning an empty string does not write to stdin + return + } + + if($0 == "stderr") + { + # This is our stderr handler.. just in case something goes wrong + echo "[stderr] $1" + return + } + + if($0 == "terminated") + { + echo "[process terminated]" + return + } + + # Ok.. this must be a stdout data event + # Echo the line to the user + echo "[stdout] $1" + + # And make our little state machine work + switch(%:state) + { + case(0): + { + # We're waiting for 220 (ready) + if($str.match("220*",$1)) + { + # Send the HELO and go to next state + %:state++ + echo "Sending HELO..." + return "HELO myhostname$cr$lf"; + } + } + break + case(1): + { + # Waiting for 250 (after the HELO) + if($str.match("250*",$1)) + { + # Send the MAIL command + %:state++ + echo "Sending MAIL..." + return "MAIL From: %:from$cr$lf" + } else { + # The server replied with something that is not a 250... + # Fail :/ + echo "HELO command not accepted: $1" + halt + } + } + break; + case(2): + { + # Waiting for another 250 (MAIL accepted) + if($str.match("250*",$1)) + { + # ... + %:state++ + echo "Sending RCPT..." + return "RCPT To: %:rcpt$cr$lf" + } else { + echo "MAIL command not accepted: $1" + halt + } + } + break; + case(3): + { + # Waiting for another 250 (RCPT accepted) + if($str.match("250*",$1)) + { + %:state++ + echo "Sending DATA..." + return "DATA$cr$lf" + } else { + echo "RCPT not accepted: $1" + halt + } + } + break; + case(4): + { + # Waiting for 354 (ok, go on) + if($str.match("354*",$1)) + { + # You will probably need to hack in the Date: field :) + %:state++ + echo "Sending body..." + %x = "From: %:sender$cr$lf" + %x .= "To: %:receiver$cr$lf" + %x .= "Subject: %:subject$cr$lf" + %x .= "Reply-To: %:sender$cr$lf" + %x .= "Date: Thu, 8 Apr 2004 05:28:01 +0200$cr$lf" + %x .= "X-Mailer: KVIrc funky KVS script$cr$lf" + %x .= "$cr$lf" + %x .= "%:body$cr$lf$cr$lf" + %x .= ".$cr$lf" + return %x + } else { + echo "DATA not accepted: $1" + halt + } + } + break; + case(5): + { + # We don't wait anymore :) + %:state++ + echo "Sending QUIT..." + return "QUIT$cr$lf" + } + break; + default: + { + # Usually the mail server closes the connection + %:state++ + if(%:state > 10) + { + # But if it does not in few messages + # Then force the process to die + halt + } + } + } +}
\ No newline at end of file diff --git a/doc/scriptexamples/minesweeper/Makefile.am b/doc/scriptexamples/minesweeper/Makefile.am new file mode 100644 index 00000000..914e3823 --- /dev/null +++ b/doc/scriptexamples/minesweeper/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = *.kvs diff --git a/doc/scriptexamples/minesweeper/minesweeper.kvs b/doc/scriptexamples/minesweeper/minesweeper.kvs new file mode 100644 index 00000000..24f3b0cb --- /dev/null +++ b/doc/scriptexamples/minesweeper/minesweeper.kvs @@ -0,0 +1,131 @@ + + +class(minelabel,label) +{ + mousePressEvent() + { + $$->$parent()->$mineLabelPressed($this) + } +} + +class(minesweeper,widget) +{ + constructor() + { + $$->$setCaption("KVIrc's Minesweeper (0.1.0)"); + + $$->%rows = 10 + $$->%cols = 10 + $$->%mines = 10 + + $$->%layout = $new(layout,$this) + + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + $$->%label{%i,%j}=$new(minelabel,$this,"%i_%j") + $$->%label{%i,%j}->%row = %i + $$->%label{%i,%j}->%col = %j + $$->%layout->$addWidget($$->%label{%i,%j},%i,%j) + } + } + + $$->$newGame() + } + + destructor() + { + } + + newGame() + { + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + %l = $$->%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->$setText("") + } + } + # drop the mines + for(%i = 0;%i < $$->%mines;%i++) + { + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + while($$->%label{%row,%col}->%bIsMine != 0) + { + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + } + $$->%label{%row,%col}->%bIsMine = 1 + # increase the mine count for the adiacent cells + if(%row > 0) + { + $$->%label{$(%row - 1),%col}->%numMines++ + if(%col > 0)$$->%label{$(%row - 1),$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < ($$->%rows - 1)) + { + $$->%label{$(%row + 1),%col}->%numMines++ + if(%col > 0)$$->%label{$(%row + 1),$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + if(%col > 0)$$->%label{%row,$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{%row,$(%col + 1)}->%numMines++ + } + } + + mineLabelPressed($0 = mine label object that has been pressed) + { + #echo "MINE LABEL PRESSED $0" + if($0->%bIsMine) + { + #echo "IS MINE!" + $0->$setFrameStyle(WinPanel,Sunken) + $0->$setText("*") + } else { + #echo "IS NOT MINE" + $$->$discoverCells($0) + } + } + + discoverCells($0 = mine label that has to be discovered) + { + #echo "Discover cells $0" + if($0->%bIsMine)return; + if($0->%bIsDiscovered)return; + $0->%bIsDiscovered = 1 + $0->$setFrameStyle(WinPanel,Sunken) + if($0->%numMines > 0)$0->$setText($0->%numMines) + else { + if($0->%row > 0) + { + $$->$discoverCells($$->%label{$($0->%row - 1),$0->%col}) + if($0->%col > 0)$$->$discoverCells($$->%label{$($0->%row - 1),$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$($0->%row - 1),$($0->%col + 1)}) + } + if($0->%row < ($$->%rows - 1)) + { + $$->$discoverCells($$->%label{$($0->%row + 1),$0->%col}) + if($0->%col > 0)$$->$discoverCells($$->%label{$($0->%row + 1),$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$($0->%row + 1),$($0->%col + 1)}) + } + if($0->%col > 0)$$->$discoverCells($$->%label{$0->%row,$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$0->%row,$($0->%col + 1)}) + } + } + +} + +alias(mines) +{ + %m = $new(minesweeper) + %m->$show() + +} diff --git a/doc/scriptexamples/mp3_kdemediaplayers.kvs b/doc/scriptexamples/mp3_kdemediaplayers.kvs new file mode 100644 index 00000000..98be29e9 --- /dev/null +++ b/doc/scriptexamples/mp3_kdemediaplayers.kvs @@ -0,0 +1,206 @@ + + +%Xmms_play=$mp3player.getfilename; + + + +%Prefix = $str.left(%Xmms_play,4) +%Postfix = $str.right(%Xmms_play,4) + %Http_prefix = "http" + %Cda_postfix = ".cda" + if(%Prefix == %Http_prefix) { + + %Stime = $($mp3player.gettime/1000) + %Mtime = 0 + %Ctime =" "; + + while(%Stime > 59) { + %Mtime++ + %Stime-=60 + } + + %Htime=0 + + while(%Mtime > 59) { + %Htime++ + %Mtime-=60 + } + + if (%Stime < 10){ + %tmp = %Stime + %Stime = $str.append("0",%tmp) + } + if (%Mtime < 10 && %Htime > 1){ + %tmp = %Mtime + %Mtime = $str.append("0",%tmp) + } + + + + if (%Htime > 0) + %Ctime = $str.append %Htime:%Mtime:%Stime + + + + if (%Mtime > 0 && %Htime < 1) + %Ctime = $str.append %Mtime:%Stime + + + + if (%Mtime < 1 && %Htime < 1) + %Ctime = %Stime + + + + me muckelt grad [$mp3player.gettitle @ %Xmms_play - $($mp3player.getrate/1000) kbps - $($mp3player.getfreq/1000) kHz - seit: %Ctime (h:m:s)] + } + else if(%Postfix == %Cda_postfix) { + me muckelt grad [$mp3player.gettitle - Audio CD] + + } + + + else { + + if ($mp3player.getchannels == 2) + %Channels = Stereo + else + %Channels = Mono + + %Frequ = $mp3player.getfreq + %Frequ2 = $(%Frequ/1000) + + %tmins = $($mp3player.getlength / 60000) + %tsecs = $(($mp3player.getlength % 60000) / 1000) + %tsecs1 = $(%tsecs / 10) + %tsecs2 = $(%tsecs % 10) + %mins = $($mp3player.gettime / 60000) + %secs = $(($mp3player.gettime % 60000) / 1000) + %secs1 = $(%secs / 10) + %secs2 = $(%secs % 10) + %rate = $($mp3player.getrate / 1000) + %size = $file.size("$mp3player.getfilename") + %msize = $(%size / (1024*1024)) + %ksize = $((%size - ((%size / (1024*1024)) * 1024 * 1024) - (%size % 1024)) / 1024) + + %bsize = $(%size % 1024) + + if(%msize > 0) + { + %size = "%msize MByte %ksize KByte" + }else{ + if(%ksize > 0) + { + %size = "%ksize KByte %bsize Byte" + }else{ + %size = "%bsize Byte" + } + } + if ($mp3player.isplaying){ + + if($mp3player.getmp3tag_artist != ""){ + %outartist= $mp3player.getmp3tag_artist + } + else { + %outartist="" + } + if ($mp3player.getmp3tag_title != ""){ + %outtitle= $mp3player.getmp3tag_title + } + else { + %outtitle="" + } + if ((%outartitst != "") && (%outtitle != "")) { + %outartisttitle="["%outartitst" - "%autartisttitle"]" + } + else { + if (%outtitle == ""){ + %outartisttitle="["%outartist"]" + } + else { + %outartisttitle="["%outtitle"]" + } + + } + + if (mp3player.getmp3tag_album !=""){ + %outalbum =" - [Album: "$mp3player.getmp3tag_album"]" + } + else { + %outalbum ="" + } + + if (mp3player.getmp3tag_genre !=""){ + %outgenre =" - [Genre: "$mp3player.getmp3tag_genre"]" + } + else { + %outgenre ="" + } + + + if ($mp3player.getmp3tag_comment !=""){ + %outcomment =" - [Comment: "$mp3player.getmp3tag_comment"]" + } + else { + %outcomment="" + } + if ($mp3player.getmp3tag_version != ""){ + %outmp3tagversion = "MPEG"$mp3player.getmp3tag_version + } + else { + %outmp3tagversion="" + } + if ($mp3player.getmp3tag_layer != ""){ + %outmp3taglayer = "Layer"$mp3player.getmp3tag_layer + } + else { + %outmp3taglayer = "" + } + if (%outmp3taglayer != "" && %outmp3tagversion != ""){ + %outmp3tagversionlayer = " - ["%outmp3tagversion" - "%outmp3taglayer"]" + } + else { + %outmp3tagversionlayer= "" + if (%outmp3tagversion != ""){ + %outmp3tagversionlayer= "["%mp3tagversion"]" + } + if (%outmp3taglayer != ""){ + %outmp3tagversionlayer= "["%mp3taglayer"]" + } + + } + + + %rate = $($mp3player.getrate/1000) + if (%rate != 0){ + %outrate=" - ["%rate KBps"]" + } + else { + %outrate="" + } + if (%Frequ2 != 0){ + %outfrequ2=" - ["%Frequ2 KHz"]" + } + else { + %outfrequ2="" + } + if (%Channels != 0){ + %outchannels = " - ["%Channels"]" + } + else { + %outchannels="" + } + if (%size != 0){ + %outsize = " - ["%size"]" + } + else { + %outsize="" + } + + me muckelt grad %outartisttitle %outalbum %outgenre %outcomment %outmp3tagversionlayer %outrate %outfrequ2 - [%mins:%secs1%secs2 min of %tmins:%tsecs1%tsecs2 min] - [Player: $mp3player.getplayer ] + } + } + if (!$mp3player.isplaying){ + me muckelt grad * nix * + + }
\ No newline at end of file diff --git a/doc/scriptexamples/mp3info.kvs b/doc/scriptexamples/mp3info.kvs new file mode 100644 index 00000000..b5324145 --- /dev/null +++ b/doc/scriptexamples/mp3info.kvs @@ -0,0 +1,109 @@ +%Xmms_play=$mp3player.getfilename; + +%Prefix = $str.left(%Xmms_play,4) +%Postfix = $str.right(%Xmms_play,4) + + %Http_prefix = "http" + %Cda_postfix = ".cda" + if(%Prefix == %Http_prefix) { + + + %Stime = $($mp3player.gettime/1000) + %Mtime = 0 + %Ctime =" "; + + while(%Stime > 59) { + %Mtime++ + %Stime-=60 + } + + %Htime=0 + + while(%Mtime > 59) { + %Htime++ + %Mtime-=60 + } + + if (%Stime < 10){ + %tmp = %Stime + %Stime = $str.append("0",%tmp) + } + if (%Mtime < 10 && %Htime > 1){ + %tmp = %Mtime + %Mtime = $str.append("0",%tmp) + } + + + + if (%Htime > 0) + %Ctime = $str.append %Htime:%Mtime:%Stime + + + + if (%Mtime > 0 && %Htime < 1) + %Ctime = $str.append %Mtime:%Stime + + + + if (%Mtime < 1 && %Htime < 1) + %Ctime = %Stime + + + + me has currently [$mp3player.gettitle @ %Xmms_play - $($mp3player.getrate/1000) kbps - $($mp3player.getfreq/1000) kHz - seit: %Ctime (h:m:s)] + } + + + else if(%Postfix == %Cda_postfix) { + %Xmms_play=$mp3player.getfilename; + + } + + + else { + + if ($mp3player.getchannels == 2) { + %Channels = Stereo + } + else { + %Channels = Mono + } + + %Frequ = $mp3player.getfreq + %Frequ2 = $(%Frequ/1000) + + %tmins = $($mp3player.getlength / 60000) + %tsecs = $(($mp3player.getlength % 60000) / 1000) + %tsecs1 = $(%tsecs / 10) + %tsecs2 = $(%tsecs % 10) + %mins = $($mp3player.gettime / 60000) + %secs = $(($mp3player.gettime % 60000) / 1000) + %secs1 = $(%secs / 10) + %secs2 = $(%secs % 10) + %rate = $($mp3player.getrate / 1000) + %size = $file.size("$mp3player.getfilename") + %msize = $(%size / (1024*1024)) + %ksize = $((%size - ((%size / (1024*1024)) * 1024 * 1024) - (%size % 1024)) / 1024) + + %bsize = $(%size % 1024) + + + if(%msize > 0){ + %size = "%msize MByte %ksize KByte" + } + else { + if(%ksize > 0){ + %size = "%ksize KByte %bsize Byte" + } + else { + %size = "%bsize Byte" + } + } + me has currently [$mp3player.getmp3tag_artist - $mp3player.getmp3tag_title] - [Album: $mp3player.getmp3tag_album] - [Genre: $mp3player.getmp3tag_genre] - [Comment: $mp3player.getmp3tag_comment] - [MPEG$mp3player.getmp3tag_version Layer$mp3player.getmp3tag_layer] - [$($mp3player.getrate/1000) Bit] - [%Frequ2 kHz] - [%Channels] - [%size] - [%mins:%secs1%secs2 min von %tmins:%tsecs1%tsecs2 min] + } + + if (!$mp3player.isplaying) + { + me's player has currently stopped + +} diff --git a/doc/scriptexamples/mp3share/Makefile.am b/doc/scriptexamples/mp3share/Makefile.am new file mode 100644 index 00000000..a48a9984 --- /dev/null +++ b/doc/scriptexamples/mp3share/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = mp3share.kvs mp3share_icon.png diff --git a/doc/scriptexamples/mp3share/mp3share.kvs b/doc/scriptexamples/mp3share/mp3share.kvs new file mode 100644 index 00000000..57c30032 --- /dev/null +++ b/doc/scriptexamples/mp3share/mp3share.kvs @@ -0,0 +1,84 @@ +###################################################################################################### +# +# MP3Share KVIrc script +# +# This small script communicates with the platform mp3 player +# and advertises the currently played song, allowing its download by dcc +# +# +# The following things are left as exercise to the readed: +# +# - "max downloads" checking is done +# - starting the platform mp3player if it is not running +# +###################################################################################################### + +file.mkdir $file.localdir("pics") +file.copy -o $file.extractPath($0)"/mp3share_icon.png" $file.localdir("pics/mp3share_icon.png") + + +action.create -w=cqd (mp3share_advertise,$tr("Advertise MP3"),$tr("Advertises the currently played song and shares it"),mp3share_icon.png) +{ + if(!$mp3player.isplaying) + { + echo It looks like your mp3 player is not playing + halt + } + + if($mp3player.getlength <= 0) + { + # Playing a stream + + me plays$k(4) $mp3player.gettitle() $k(2)(streaming from $mp3player.getfilename()) + + } else { + %mins = $($mp3player.getlength / 60000) + %secs = $(($mp3player.getlength % 60000) / 1000) + %secs1 = $(%secs / 10) + %secs2 = $(%secs % 10) + %rate = $($mp3player.getrate / 1000) + + %text = $k(4) $mp3player.gettitle() $k(2)[%mins:%secs1%secs2 %rate Kbps $mp3player.getfreq Hz \ + $file.size("$mp3player.getfilename") Bytes]$o + + if(%type != "dccchat") + { + srand $unixtime + %a = $rand(9) + %b = $rand(9) + %c = $rand(9) + + me plays%text (Use $b/CTCP $me XDCC GET mp3_%a%b%c$b to download) + + sharedfile.add -t=$(($mp3player.getlength / 1000) + 60) \ + -n="mp3_%a%b%c" $mp3player.getfilename; + } else me plays%text + } +} + +toolbar.create mp3share $tr("MP3 Sharing") +toolbar.additem mp3share mp3share_advertise +toolbar.show mp3share + +alias(mp3share_uninstall) +{ + action.destroy mp3share_advertise + toolbar.destroy mp3share + alias(mp3share_uninstall){} +} + + +echo "The Mp3share script is installed." +if("$system.ostype" == "windows") +{ + echo "On Windows you need the Winamp multimedia player" + echo "freely available at http://www.winamp.com" + echo "You also need to install the gen_kvirc.dll from the KVIrc" + echo "distribution as a Winamp plugin (this involves copying the" + echo "file to the winamp \"plugins\" directory)." +} else { + echo "On Unix you need the Xmms multimedia player" + echo "freely available at http://www.xmms.org" +} +echo "Use mp3share_uninstall to uninstall the script." +echo "Have fun :)" diff --git a/doc/scriptexamples/mp3share/mp3share_icon.png b/doc/scriptexamples/mp3share/mp3share_icon.png Binary files differnew file mode 100644 index 00000000..6aeec0e1 --- /dev/null +++ b/doc/scriptexamples/mp3share/mp3share_icon.png diff --git a/doc/scriptexamples/newkvstest.kvs b/doc/scriptexamples/newkvstest.kvs new file mode 100644 index 00000000..0fe06a25 --- /dev/null +++ b/doc/scriptexamples/newkvstest.kvs @@ -0,0 +1,101 @@ +# This file contains test code for the new KVS parser +# It does nothing useful + + +echo "Foreach test 1" + +%arry[0] = "test0" +%arry[2] = "test2" + +%i = 0 + +foreach(%x,%arry) +{ + echo "Array item %i: (%x)" + %i++ +} + +echo "Foreach test 2" + +%ahash{"keyA"} = "dataA" +%ahash{"keyB"} = "dataB" + +%i = 0 + +foreach(%x,%ahash) +{ + echo "Hash item %i: (%x)" + %i++ +} + +echo "Foreach test 3" + +%i = 0 + +foreach(%x,$keys(%ahash)) +{ + echo "Hash entry %i: key->(%x), item->(%ahash{%x})" + %i++ +} + +echo "Foreach test 4" + +%i = 0 + +foreach(%x,%arry,$keys(%ahash)) +{ + echo "Item %i: %x" + %i++ +} + + +%tmp = 1 +switch(%tmp) +{ + case(1): + echo \%tmp was 1! + break; + case(2) + echo \%tmp was 2! + break; + default: + echo \%tmp was not 1 nor 2: it was %tmp! + break; +} + +%tmp = 1 +switch(%tmp) +{ + case(1): + echo \%tmp was 1! + case(2) + echo \%tmp was 2! + break; + default: + echo \%tmp was either 1 or something different from 2 (%tmp) + break; +} + +%tmp = "This is a test" +%tmp2 = "This is not a test" +switch(%tmp) +{ + case(%tmp2) + echo \%tmp == \%tmp2 + break; + case(%tmp) + { + # do not break here + echo "Yeah.. it's stupid.. \%tmp == \%tmp :D" + } + match("*TEST"): + echo "Matched *TEST" + regexp("[a-zA-Z ]*test"): + echo "Matched [a-zA-Z ]*text" + regexp("[a-zA-Z ]*not[a-zA-Z ]*"): + echo "Matched [a-zA-Z ]*not[a-zA-Z ]*" + default: + echo This is executed anyway (unless some break was called) + break; +} + diff --git a/doc/scriptexamples/playing/Makefile.am b/doc/scriptexamples/playing/Makefile.am new file mode 100644 index 00000000..d673dfb9 --- /dev/null +++ b/doc/scriptexamples/playing/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = playing.kvs playing_icon.png diff --git a/doc/scriptexamples/playing/playing.kvs b/doc/scriptexamples/playing/playing.kvs new file mode 100644 index 00000000..984dd8c2 --- /dev/null +++ b/doc/scriptexamples/playing/playing.kvs @@ -0,0 +1,108 @@ +###################################################################################################### +# +# playing KVIrc script +# +# I started this script cause I was scared about the colors of Pragmas mp3share script +# and the insecierness of dcc download. +# +# So I did set up this little script for mp3 advertising based on Pragmas ugly mp3share. +# +# Hints, donations and stuff can be delivered to istari@kvirc.net. +# +# This small script communicates with the platform mp3 player +# and advertises the currently played song +# +# The following things are left as exercise to the readed: +# +# - starting the platform mp3player if it is not running +# +###################################################################################################### + +file.mkdir $file.localdir(pics) +file.copy -o $file.extractPath($0)/playing_icon.png $file.localdir(pics/playing_icon.png) + +action.create -w=cqd (playing_adv,$tr("Advertise MP3"),$tr("Advertises the currently played song"),playing_icon.png) +{ + if(!($mp3player.isplaying)) + { + echo It looks like your mp3 player is not playing + halt + } + + switch ($mp3player.getchannels()) + { + case("1"): %channel="mono" + break + case("2"): %channel="stereo" + break + } + + %tmins = $($mp3player.getlength / 60000) + %tsecs = $(($mp3player.getlength % 60000) / 1000) + %tsecs1 = $(%tsecs / 10) + %tsecs2 = $(%tsecs % 10) + %mins = $($mp3player.gettime / 60000) + %secs = $(($mp3player.gettime % 60000) / 1000) + %secs1 = $(%secs / 10) + %secs2 = $(%secs % 10) + %rate = $($mp3player.getrate / 1000) + %size = $file.size("$mp3player.getfilename") + %msize = $(%size / (1024*1024)) + %ksize = $((%size - ((%size / (1024*1024)) * 1024 * 1024) - (%size % 1024)) / 1024) + %bsize = $(%size % 1024) + + + if(%size > 0) + { + if(%msize > 0) + { + %size = "%msize MByte %ksize KByte" + }else{ + if(%ksize > 0) + { + %size = "%ksize KByte %bsize Byte" + }else{ + %size = "%bsize Byte" + } + } + + me is listening to $mp3player.gettitle() =- %mins:%secs1%secs2 of %tmins:%tsecs1%tsecs2 -=- %rate Kbps -=- \ + $mp3player.getfreq Hz -=- %channel -=- %size -=$o + }else{ + me is streaming \"$mp3player.gettitle()\" from $mp3player.getfilename =- %mins:%secs1%secs2 mins -=- %rate Kbps -=- \ + $mp3player.getfreq Hz -=- %channel -=$o + } + +# offer.add -t=$(($mp3player.getlength / 1000) + 60) \ +# -n="mp3_$mp3player.getposition" $mp3player.getfilename; +} + +toolbar.create playing $tr("MP3 Sharing") +toolbar.additem playing playing_advertise +toolbar.show playing + +alias(playing_uninstall) +{ + # Kill the playing_adv alias + action.destroy -q playing_adv + # Kill this alias + alias(playing_uninstall){} +} + + +playing_addbutton + +echo The playing script is installed. +if("$system.ostype" == "windows") +{ + echo On Windows you need the Winamp multimedia player + echo freely available at http://www.winamp.com + echo You also need to install the gen_kvirc.dll from the KVIrc + echo distribution as a Winamp plugin (this involves copying the + echo file to the winamp \"plugins\" directory). +} else { + echo On Unix you need the Xmms multimedia player + echo freely available at http://www.xmms.org +} +echo Use playing_uninstall to uninstall the script. +echo Have fun :) diff --git a/doc/scriptexamples/playing/playing_icon.png b/doc/scriptexamples/playing/playing_icon.png Binary files differnew file mode 100644 index 00000000..2635e618 --- /dev/null +++ b/doc/scriptexamples/playing/playing_icon.png diff --git a/doc/scriptexamples/popup1.kvs b/doc/scriptexamples/popup1.kvs new file mode 100644 index 00000000..107c5a6e --- /dev/null +++ b/doc/scriptexamples/popup1.kvs @@ -0,0 +1,17 @@ + +defpopup (test) +{ + item(Say "$0 ($1)" , 0)echo $0 ($1) + separator + popup(Popup) + { + item(Say "$0" twice) + { + echo $0 (1) + echo $0 (2) + } + } +} + + +echo "Use '/popup test <parameter>' to test the popup" diff --git a/doc/scriptexamples/popup2.kvs b/doc/scriptexamples/popup2.kvs new file mode 100644 index 00000000..10aa07a1 --- /dev/null +++ b/doc/scriptexamples/popup2.kvs @@ -0,0 +1,124 @@ +# This code adds a channel popup that accepts: +# a comma separated list of nicknames + +defpopup (channel) +{ + prologue + { + # the local variables are visible in the entire defpopup scope + %visible=$0 + %multiple = 0 + if($str.findfirst(%visible,",") != -1) + { + %visible = "multiple users" + %multiple = 1 + } + } + + popup(Control,9)($isMeOp) + { + label(Operator power) + item(Op %visible,34)op $0 + item(Deop %visible,62)deop $0 + separator; + item(Voice %visible,35)voice $0 + item(Devoice %visible,63)devoice $0 + separator; + item(Kick %visible (You're not welcome here!),110)kick $0 You're not welcome here! + item(Ban %visible (Nick!*@* mask),67)ban $0 + } + + popup(Info,49) + { + item(Who %visible,75)who $0 + item(Whois %visible,75)whois $0 + item(Whois %visible (with idle time),75) whois $0 $0 + item(Whowas %visible,92)whowas $0 + } + + popup(Ctcp,51) + { + item(PING,36)ping $0 + item(VERSION,16)ctcp $0 VERSION + item(USERINFO,57)ctcp $0 USERINFO + item(CLIENTINFO,52)ctcp $0 CLIENTINFO + item(SOURCE,14)ctcp $0 SOURCE + item(FINGER,53)ctcp $0 FINGER + item(TIME,93)ctcp $0 TIME + } + + popup(Dcc,77) + { + item(Chat with %visible,78) dcc.chat $0 + item(Send to %visible,79) dcc.send $0 + item(TDCC Send to %visible,77) dcc.send -t $0 + } + + popup("Registration",111)(!%multiple) + { + prologue + { + # This is really smart...we're loading + # the reguser module only if this popup is being requested. + %regName = $reguser.match($mask(%visible)) + %labelText = "<center><b>%visible</b> is"; + if("%regName" != "") + { + %labelText << "registered as<br><b>%regName</b>" + # We want to display masks here!!! + %inNotifyList = $reguser.property(%regName,notify); + if("%inNotifyList" != "")%labelText << "<br>$0 is in the notify list" + %curAvatar = $avatar($0); + %defAvatar = $reguser.property(%regName,avatar); + if("%defAvatar" != "")%labelText << "<br>$0 has a default avatar" + %labelText << "</center>" + } else { + %labelText << "not registered</center>" + } + } + label("%labelText") + popup("Register")("%regName" == "") + { + item("Register as $0 ($mask(%visible,11))")("$reguser.exactMatch($mask(%visible,11))" == "")reguser.add %visible $mask(%visible,11) + item("Register as $0 ($mask(%visible,12))")("$reguser.exactMatch($mask(%visible,12))" == "")reguser.add %visible $mask(%visible,12) + item("Register as $0 ($mask(%visible,13))")("$reguser.exactMatch($mask(%visible,13))" == "")reguser.add %visible $mask(%visible,13) + item("Register as $0 ($mask(%visible,3))")("$reguser.exactMatch($mask(%visible,3))" == "")reguser.add %visible $mask(%visible,3) + item("Register as $0 ($mask(%visible,4))")("$reguser.exactMatch($mask(%visible,4))" == "")reguser.add %visible $mask(%visible,4) + item("Register as $0 ($mask(%visible,5))")("$reguser.exactMatch($mask(%visible,5))" == "")reguser.add %visible $mask(%visible,5) + } + item("Edit registration entry",113)("%regName" != "")reguser.edit "%regName" + item("Unregister %regName")("%regName" != "")reguser.remove "%regName" + + item("Add to notify list")(("%regName" != "") && ("%inNotifyList" == "")) + reguser.setproperty -n "%regName" notify %visible + + item("Remove from notify list") + (("%regName" != "") && ("%inNotifyList" != "")) + reguser.setproperty -n "%regName" notify + + item("Set the current avatar as default")(("%curAvatar" != "") && ("%curAvatar" != "%defAvatar")) + reguser.setproperty "%regName" avatar %curAvatar + + item("Unset the default avatar")("%defAvatar" != "") + reguser.setproperty %regName avatar + +# item("Choose the default avatar")("%regMask" != "") +# dialog.fileopen("Choose the avatar filename",%regMask){ reguser.setproperty -e $magic $selectedFile; } + + } + + separator; + + #item(Notify avatar,57)("$0" != "$myNick")avatar $0 + #item(Notify avatar (No offer),57)("$0" != "$myNick")avatar -n $0 + item(Notify avatar,57)avatar $0 + item(Notify avatar (No offer),57)avatar -n $0 + + separator; + item(Query %visible,47)(!%multiple)query $0 + item(Query %visible (Single queries),47)(%multiple)query $0 + item(Query %visible (Multiple query),47)(%multiple)query -m $0 +} + + +event (OnChannelUserListRightClicked,default){ if("$selected" != "")popup channel $selected; }; diff --git a/doc/scriptexamples/popup3.kvs b/doc/scriptexamples/popup3.kvs new file mode 100644 index 00000000..0ad7d4a6 --- /dev/null +++ b/doc/scriptexamples/popup3.kvs @@ -0,0 +1,46 @@ +defpopup (channeltextview) +{ + item(Leave $0,40){ part $0; } +} + + +event (OnChannelTextViewRightClicked,default){ if("$target" != "")popup channeltextview $target; } + + +defpopup (querytextview) +{ + item(Whois $0,57){ whois $0; } +} + + +event (OnQueryTextViewRightClicked,default){ if("$target" != "")popup querytextview $target; } + + + +defpopup (consoletextview) +{ + popup(Server queries,13) + { + item(Version,16)version + item(Motd,30)motd + item(Info,29)info + item(Admin,29)admin + item(Lusers,57)lusers + item(Time,93)time + item(Help,49)raw help + popup(Stats,22) + { + item(d (debug/dns ?))stats d + item(l (connections))stats l + item(m (command usage))stats m + item(o (operators))stats o + item(t (connection stats ?),23)stats t + item(u (uptime),93)stats u + item(y (y-lines))stats y + item(z (debug stats ?),11)stats z + } + } +} + + +event (OnConsoleTextViewRightClicked,default){ popup consoletextview; } diff --git a/doc/scriptexamples/popup4.kvs b/doc/scriptexamples/popup4.kvs new file mode 100644 index 00000000..1680bbeb --- /dev/null +++ b/doc/scriptexamples/popup4.kvs @@ -0,0 +1,40 @@ +defpopup (windowpopup) +{ + label("$caption") + + popup(Logging,119) + { + prologue + { + %logfile = $log.file + } + label("Logging to file<br><b>%logfile</b>")("%logfile" != "") + item("Stop logging")("%logfile" != "")log.stop + item("Flush log file")("%logfile" != "")log.flush + + label("Logging is disabled")("%logfile" == "") + item("Log (default file)")("%logfile" == "")log.start + item("Log (default file) (prepend existing data)")("%logfile" == "")log.start -e + } +# popup(Buffer) +# { +# item("Save to file...")window.savebuffer +# item("Clear")window.clear +# item("Find...")window.findtext +# } +# popup(View) +# { +# item("Show images")($window.images == 0)window.images 1 +# item("Enable timestamps")($window.timestamp == 0)window.timestamp 1 +# item("Disable timestamps")($window.timestam == 1)window.timestamp 0 +# item("Set font...")$window.setfont +# item("Set background...")$window.setbackground +# } +# popup(Mdi) +# { +# item("Minimize")window.minimize +# item("Maximize")window.maximize +# } +} + +event (OnWindowPopupRequest,default){ popup windowpopup; } diff --git a/doc/scriptexamples/relay.kvs b/doc/scriptexamples/relay.kvs new file mode 100644 index 00000000..d8689866 --- /dev/null +++ b/doc/scriptexamples/relay.kvs @@ -0,0 +1,33 @@ +# Relay bot (unfinished for now :D) +# TODO : finish me! + + +alias (relay_start) +{ + # Usage : relay_start <window1> <window2> +} + + +alias (relay_stop) +{ + # Usage : relay_stop <window1> <window2> +} + +event (OnChannelPrivmsg) +{ + %target = %RelayTarget[$window]; + if("%target" != "") + { + msg -w=%t $target <$0> $1- + } +} + +alias (relay_uninstall) +{ + timer -s (relay_uninstall_timer,0) + { + alias(relay_start){} + alias(relay_stop){} + alias(relay_uninstall){} + } +} diff --git a/doc/scriptexamples/runmenu/Makefile.am b/doc/scriptexamples/runmenu/Makefile.am new file mode 100644 index 00000000..d91889ea --- /dev/null +++ b/doc/scriptexamples/runmenu/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = runmenu.kvs diff --git a/doc/scriptexamples/runmenu/runmenu.kvs b/doc/scriptexamples/runmenu/runmenu.kvs new file mode 100644 index 00000000..dea6a27d --- /dev/null +++ b/doc/scriptexamples/runmenu/runmenu.kvs @@ -0,0 +1,111 @@ +# This simple script adds a sample "run external program" popup +# to your menubar +# This is just a sample popup... you will probably +# want to add/remove entries here +# This will also work mainly on unix... windows has not so much +# proggies to be run as example + + +# Define the popup with run entries... +# You prolly will change a lot here :) + +defpopup(runmenu) +{ + popup(Terminal,138) + { + item(XTerm,25) ($system.ostype == unix) + { + run xterm + } + + item(Konsole,151) ($system.ostype == unix) + { + run konsole + } + + item(ETerm,25) ($system.ostype == unix) + { + run eterm + } + } + + popup(Browser,172) + { + item(konqueror,135) ($system.ostype == unix) + { + run konqueror + } + + item(netscape,164) + { + if($system.ostype == unix)run kvi_run_netscape + else run netscape.exe + } + } + + popup(Multimedia,177) + { + item(xmms) + { + run xmms + } + item(mplayer) + { + run mplayer + } + item(kscd) + { + run kscd + } + } + + popup(Utils) + { + item(xcalc) + { + run xcalc; + } + item(kcalc) + { + run kcalc; + } + } + + separator; + + # Let's allow to run an user specified command + + item(Run...,183) + { + dialog.textinput(Run,<center>Please enter the command name</center>,Ok,Cancel) + { + if($0 == 0 && $1)run $1 + } + } + + separator; + + # This is an interesting item + # It allows this script to be uninstalled :) + + popup(Uninstall,110) + { + item(Uninstall this menu,110) + { + timer -s (runmenu_uninstall,0){ defpopup(runmenu){}; } + } + } +} + +# add it to the menubar of each new frame + +event(OnFrameWindowCreated,runmenu) +{ + setmenu -i=3 "&Run" runmenu +} + +# set it also just now, in the current frame + +setmenu -i=3 "&Run" runmenu + +# done :) diff --git a/doc/scriptexamples/signal1.kvs b/doc/scriptexamples/signal1.kvs new file mode 100644 index 00000000..7777e679 --- /dev/null +++ b/doc/scriptexamples/signal1.kvs @@ -0,0 +1,47 @@ +# This implements a "fake timer" object that emits the "timeout" signal +# and a target object slot connected to this signal. + +# We also test the immediate object deletion...it seems to work + +class(faketimer,object) +{ + timerEvent(<timer id>) + { + $this->$emit(timeout,$0) + } +} + + +class(target,object) +{ + constructor + { + $$->%num = 10; + } + + timerSlot(<timer id>) + { + echo "Timer $0 fired $$->%num" + $$->%num--; + if($$->%num == 0) + { + echo "Deleting sender $$->$signalSender()->$name() : Kaboom!" + # Immediate sender deletion.... + delete -i $$->$signalSender + $$->$startTimer(1000) + } + } + + timerEvent(<timer id>) + { + echo "Deleting self! : Kaboom!" + delete $this; + } +} + + +%source = $new(faketimer,0,sender) +%target = $new(target,0,target) +connect %source timeout %target timerSlot +echo "Starting timer...." +%source->$startTimer(1000) diff --git a/doc/scriptexamples/simplehttp/Makefile.am b/doc/scriptexamples/simplehttp/Makefile.am new file mode 100644 index 00000000..540ab61c --- /dev/null +++ b/doc/scriptexamples/simplehttp/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = simplehttp.kvs diff --git a/doc/scriptexamples/simplehttp/simplehttp.kvs b/doc/scriptexamples/simplehttp/simplehttp.kvs new file mode 100644 index 00000000..8c49014a --- /dev/null +++ b/doc/scriptexamples/simplehttp/simplehttp.kvs @@ -0,0 +1,105 @@ +# +# This is a really simple and senseless HTTP server +# It listens on port 8080 and serves a "Hello world" page +# to the incoming browser connections. +# + + +# Define the "startup" alias +alias(simplehttp_start) +{ + # If the server is already running , well... give up + if($classDefined(simpleHttpListeningSocket) && (%SimpleHttpListeningSocket)) + { + echo "The Simple HTTP server is already running" + halt + } + + # Define the server class (if the class is already defined it will be overridden) + class(simpleHttpListeningSocket,socket) + { + # The constructor fails if we can't listen on port 8080! + constructor() + { + if(!$$->$listen(8080)) + { + return 0 + } + return 1 + } + + # Handle the incoming connections + incomingConnectionEvent() + { + # Create a slave socket + %tmp = $new(socket) + # Accept the connection + $$->$accept(%tmp) + # And handle it + echo "Incoming connection:" + echo "Remote end: %tmp->$remoteIp : %tmp->$remotePort" + echo "Local end: %tmp->$localIp : %tmp->$localPort" + # Write a "Hello world" page to the client + %tmp->$write("HTTP/1.0 200 OK\r\n"); + %tmp->$write("Content-type: text/html\r\n\r\n"); + %tmp->$write("<html>\n") + %tmp->$write(" <head><title>KVIrc simple http server</title></head>\n") + %tmp->$write(" <body bgcolor=\"#000000\" text=\"#FF0000\">\n") + %tmp->$write(" <center><h1><b>Hello World!</b></h1></center>\n") + %tmp->$write(" </body>\n") + %tmp->$write("</html>\n\r\n\r\n") + # Close (this ensures data delivery) + %tmp->$close() + # Kill the slave + delete %tmp; + # Some browsers may tell you that the connection is "broken" + # (konqueror , for example) since they can't send + # the GET request... (we don't read it!) + # Well...this is left as exercise to the scripter: + # Write the data to the socket only in response to the GET message :) + # You CAN do it. + } + } + + # Create the server socket + %SimpleHttpListeningSocket = $new(simpleHttpListeningSocket) + + if(!%SimpleHttpListeningSocket)echo "Ops.. can't start the simple http server :(((" + else { + echo "Ok.. up and running :)" + echo "Point your browser to http://127.0.0.1:8080" + } + +} + +# Stop alias : this is easy + +alias(simplehttp_stop) +{ + if(!%SimpleHttpListeningSocket) + { + echo "The simple HTTP server is not running" + halt + } + %SimpleHttpListeningSocket->$close() + delete %SimpleHttpListeningSocket + %SimpleHttpListeningSocket = "" +} + +# Uninstall alias: another easy one + +alias(simplehttp_uninstall) +{ + # Stop the service eventually + if(%SimpleHttpListeningSocket)simplehttp_stop + # Kill the class (again eventually) + killclass -q simpleHttpListeningSocket + # And kill the aliases (including "myself") + alias(simplehttp_start){} + alias(simplehttp_stop){} + alias(simplehttp_uninstall){} +} + +# and let's start it the first time + +simplehttp_start diff --git a/doc/scriptexamples/socket1.kvs b/doc/scriptexamples/socket1.kvs new file mode 100644 index 00000000..382b48c9 --- /dev/null +++ b/doc/scriptexamples/socket1.kvs @@ -0,0 +1,45 @@ +# This is a simple socket class to play with from the console +# It just echoes the events to the console window + +class(testsocket,socket) +{ + connectEvent() + { + echo "[$$] Connected to $$->$remoteIp() $$->$remotePort()" + } + + disconnectEvent() + { + echo "[$$] Disconnected ($0-)" + } + + connectFailedEvent() + { + echo "[$$] Connect failed ($0-)" + } + + dataAvailableEvent() + { + echo "[$$] Data: $$->$read()" + } +} + +echo "testsocket class installed" +echo "You can play with it by using:" + +echo "/\%X = \$new(testsocket); # To create it" +echo "/\%X->\$connect(<host>,<port>); # To connect to a host" +echo "/\%X->\$write(<data>); # To write ASCII data" +echo "/\%X->\$close(); # To terminate a connection" +echo "/delete \%X; # To destroy it" +echo "...." +echo "Tip: why don't you try to IRC ?" +echo "The sequence might be something like:" +echo "/\%X = \$new(testsocket)" +echo "/\%X->\$connect(<your_irc_server>,6667)" +echo "/\%X->\$write(\"USER <youruser> <somestring> <somestring> :<realname>\$cr\$lf\")" +echo "/\%X->\$write(\"NICK <yournick>\$cr\$lf\")" +echo "/\%X->\$write(\"JOIN #kvirc\$cr\$lf\")" +echo "/\%X->\$write(\"PRIVMSG #kvirc :Hello IRC-World! :D\$cr\$lf\")" +echo "...." +echo "Have fun! :)" diff --git a/doc/scriptexamples/srfs.kvs b/doc/scriptexamples/srfs.kvs new file mode 100644 index 00000000..1d4bd2e7 --- /dev/null +++ b/doc/scriptexamples/srfs.kvs @@ -0,0 +1,42 @@ +# Connect to firewalled sysreset fserves without /dccserver +# SlickMcSly@mail.com +# Everything here was derived through simple experimentation while learning how everything involved +# works. If there's a better way I'm in no rush figure it out. +# +# Firewalled sysreset fserves try to open a dcc chat connection to the target port and send +# the message "100 fservenick". After the fserve sends the "100 fservenick" message it expects a +# "101 recipientnick" message, with "recipientnick" being the nick of whoever got the message. +# I wasn't able to send it some1 else's nick and get a connection that way, which would be +# interesting since you could theoretically serve connections to other ppl behind firewalls. +# +# This code requires opening a listening socket, but since sysreset is mircx specific (essentially +# winhozed specific) it doesn't hestitate to asking people who connect to open a listening port in +# the well known/privileged range which requires root (NONO). To deal with this, I setup iptables +# to forward packets bound for port 59 to port 12345 (which can be bound by non-root) by using: +# "iptables -t nat -I PREROUTING -p tcp -m multiport --dports 59 -j DNAT --to-destination :12345" +# (this requires root) +# +# There also appears to also be an option for some firewalled dcc send protocol. I've only +# encountered this once though and didn't care to figure it out. + +# Execute all the following code in the "New code tester" window +alias(srfs) # Create alias: srfs + { + if($0 && $1) # make sure there are enough parameters + { + dcc.chat -n -u -p=12345 $0; # listen on port 12345 for incoming chat + ctcp $0 $1-; # send the ctcp trigger + } + else + echo "Usage: /srfs <nick> <trigger>"; # when there aren't enough parameters + } + +event(OnDCCChatMessage,srfsHook) # Create OnDCCChatMessage event: srfs + { + # Since this event will parse ALL dcc chat messages, it looks for a message in the format + # "100 word" with no other trailing text. This is only a hack so it doesn't verify that + # "word" is a nickname, much less the nick of an expected fserve. + if(!$str.cmp($str.word(0, $0-), "100") && $str.cmp($str.word(1, $0-), "") && !$str.cmp($str.word(2, $0-), "")) + say "101 $me"; # reply 101 mynick # reply "101 mynick" + } +# End diff --git a/doc/scriptexamples/switchstress.kvs b/doc/scriptexamples/switchstress.kvs new file mode 100644 index 00000000..883383d2 --- /dev/null +++ b/doc/scriptexamples/switchstress.kvs @@ -0,0 +1,46 @@ +echo "Beginning the test! ==========================" + +switch(test) +{ + case(test) + { + echo "case(test)" + } + match(test) + { + echo "match(test)" + # comment + } + match(T*) + { + echo "match(T*)" + } + # Comment + match(T*): echo "match(T*) 2" + default: echo "default 1" + case(texto): + { + echo "case(texto)" + break + break + } + break; + default: + { + echo "default 2" + } + default: + { + echo "default 3" + } + break + regexp([a-z]*) + { + echo "match([a-z]*)" + } + default: + { + echo "default 4" + } + +} diff --git a/doc/scriptexamples/timer1.kvs b/doc/scriptexamples/timer1.kvs new file mode 100644 index 00000000..b123c6b7 --- /dev/null +++ b/doc/scriptexamples/timer1.kvs @@ -0,0 +1,25 @@ +# This is a simple example of using the builtin object timer +# capabilities. + +# we create a new object +%bomb = $new(object,0,myobject) + +# implement its timerEvent +privateimpl(%bomb,timerEvent) +{ + if($$->%secsToGo > 0) + { + echo "Countdown: $$->%secsToGo" + $$->%secsToGo--; + } else { + echo "Boom!" + delete $this + } +} + +# and trigger it +echo "Countdown: 10 seconds to go" +%bomb->%secsToGo = 9 +%bomb->$startTimer(1000) + +# now just have to wait... diff --git a/doc/scriptexamples/tutorial/Makefile.am b/doc/scriptexamples/tutorial/Makefile.am new file mode 100644 index 00000000..914e3823 --- /dev/null +++ b/doc/scriptexamples/tutorial/Makefile.am @@ -0,0 +1,5 @@ +############################################################################### +# KVirc IRC client Makefile - 16.12.98 Szymon Stefanek <stefanek@tin.it> +############################################################################### + +EXTRA_DIST = *.kvs diff --git a/doc/scriptexamples/tutorial/minesweeper1.kvs b/doc/scriptexamples/tutorial/minesweeper1.kvs new file mode 100644 index 00000000..f4f5f5ee --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper1.kvs @@ -0,0 +1,78 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 1 + + + +# First of all we create the main game widget +# The minesweeper widget inherits from the widget class +class(minesweepermain,widget) +{ + # The constructor sets the basic widget properties + # and creates the child widgets + constructor() + { + # Set the widget caption + $$->$setCaption("KVIrc's Minesweeper (0.1.0)"); + + # We will have a variable number of rows , columns and mines + # For now we hardcorde it , later they might become user definable parameters + $$->%rows = 10 + $$->%cols = 10 + $$->%mines = 10 + + # The child labels will be put in a layout that will manage automatically their geometries + $$->%layout = $new(layout,$this) + + # Time to create the child labels + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + # We use a dictionary to simulate a two dimensional array + # The label references are stored in the dictionary associated to a key + # that is build from the row and column index + $$->%label{%i,%j}=$new(label,$this,"%i_%j") + # Each label must remember its position + $$->%label{%i,%j}->%row = %i + $$->%label{%i,%j}->%col = %j + # We add the labels to the layout grid + $$->%layout->$addWidget($$->%label{%i,%j},%i,%j) + } + } + + # Time to initialize a new game + $$->$newGame(); + } + + # We need no destructor for now : the child widgets and the layout will be + # destroyed when the user will close the main widget + + + # Here we start a new game + newGame() + { + # We set the labels + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + # KVIrc is parsed on-the-fly so we use the following line as optimisation. + # parsing %l is really faster than parsing a $$->%label{%i,%j} + %l = $$->%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); # raised labels are "unpressed" buttons + %l->%bIsMine = 0 # for now it is NOT a mine + %l->%numMines = 0 # number of adiacent mines , for now 0 + %l->%bIsDiscovered = 0 # this label has been pressed ? + %l->$setText("") # set the text to an empty string + } + } + } +} + +# Create an instance of the minesweepermain object + +%m = $new(minesweepermain) +%m->$show() + +# /parse this file + diff --git a/doc/scriptexamples/tutorial/minesweeper2.kvs b/doc/scriptexamples/tutorial/minesweeper2.kvs new file mode 100644 index 00000000..16eb3172 --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper2.kvs @@ -0,0 +1,93 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 2 + +class(minesweepermain,widget) +{ + constructor() + { + $$->$setCaption("KVIrc's Minesweeper (0.1.0)"); + + $$->%rows = 10 + $$->%cols = 10 + $$->%mines = 10 + + $$->%layout = $new(layout,$this) + + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + $$->%label{%i,%j}=$new(label,$this,"%i_%j") + $$->%label{%i,%j}->%row = %i + $$->%label{%i,%j}->%col = %j + $$->%layout->$addWidget($$->%label{%i,%j},%i,%j) + } + } + + $$->$newGame() + } + + newGame() + { + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + %l = $$->%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->$setText("") + } + } + # Here we drop the mines around: it is a bit complex problem: + # We want to have a fixed number of mines placed randomly in our grid + # + # So .. for each mine that we have to place... + for(%i = 0;%i < $$->%mines;%i++) + { + # Choose a random position for this mine + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + # Ensure that we're not placing this mine over an existing one + while($$->%label{%row,%col}->%bIsMine != 0) + { + # If there was already a mine, then choose the position again + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + } + # Ok.. this is a mine then + $$->%label{%row,%col}->%bIsMine = 1 + + # increase the mine count for the adiacent cells: this is again a bit complex thingie + if(%row > 0) + { + # There is a row over our mine: the cells above must have their mine count updated + # The cell just above us + $$->%label{$(%row - 1),%col}->%numMines++ + # The cell above on the left (if exists) + if(%col > 0)$$->%label{$(%row - 1),$(%col - 1)}->%numMines++ + # The cell above on the right (if exists) + if(%col < ($$->%cols - 1))$$->%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < ($$->%rows - 1)) + { + # There is a row below our mine: the cells below must have their mine count updated + # The cell just below us + $$->%label{$(%row + 1),%col}->%numMines++ + # The cell below on the left (if exists) + if(%col > 0)$$->%label{$(%row + 1),$(%col - 1)}->%numMines++ + # The cell below on the right (if exists) + if(%col < ($$->%cols - 1))$$->%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + # Now the cell on the left side (if exists) + if(%col > 0)$$->%label{%row,$(%col - 1)}->%numMines++ + # And on the right side (if exists) + if(%col < ($$->%cols - 1))$$->%label{%row,$(%col + 1)}->%numMines++ + } + } +} + +%m = $new(minesweepermain) +%m->$show() diff --git a/doc/scriptexamples/tutorial/minesweeper3.kvs b/doc/scriptexamples/tutorial/minesweeper3.kvs new file mode 100644 index 00000000..7522c390 --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper3.kvs @@ -0,0 +1,147 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 3 + +# We want the labels to report us the clicks thus we will use +# a class derived from label +class(minelabel,label) +{ + # We ovverride the implementation for mousePressEvent() + # and we signal the mouse press to the parent minesweeper widget + mousePressEvent() + { + # We could check that $$->$parent() is a minesweeper in fact... + # but well... let's keep it simple :) + $$->$parent()->$mineLabelPressed($this) + } +} + +class(minesweepermain,widget) +{ + constructor() + { + $$->$setCaption("KVIrc's Minesweeper (0.1.0)"); + + $$->%rows = 10 + $$->%cols = 10 + $$->%mines = 10 + + $$->%layout = $new(layout,$this) + + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + # we change label to minelabel then + #$$->%label{%i,%j}=$new(label,$this,"%i_%j") + $$->%label{%i,%j}=$new(minelabel,$this,"%i_%j") + $$->%label{%i,%j}->%row = %i + $$->%label{%i,%j}->%col = %j + $$->%layout->$addWidget($$->%label{%i,%j},%i,%j) + } + } + + $$->$newGame() + } + + newGame() + { + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + %l = $$->%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->$setText("") + } + } + # drop the mines + for(%i = 0;%i < $$->%mines;%i++) + { + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + while($$->%label{%row,%col}->%bIsMine != 0) + { + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + } + $$->%label{%row,%col}->%bIsMine = 1 + # increase the mine count for the adiacent cells + if(%row > 0) + { + $$->%label{$(%row - 1),%col}->%numMines++ + if(%col > 0)$$->%label{$(%row - 1),$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < ($$->%rows - 1)) + { + $$->%label{$(%row + 1),%col}->%numMines++ + if(%col > 0)$$->%label{$(%row + 1),$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + if(%col > 0)$$->%label{%row,$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{%row,$(%col + 1)}->%numMines++ + } + } + + # A mine label was pressed! + # This function is called by our children minelabel objects + # and the parameter passed is the minelabel reference + mineLabelPressed($0 = mine label object that has been pressed) + { + # Is is a mine ? + if($0->%bIsMine) + { + # Yes , a mine :( + # Game over + $0->$setFrameStyle(WinPanel,Sunken) + $0->$setText("*") + } else { + # Not a mine.. discover the adiacent cells + # We pass the minelabel reference + $$->$discoverCells($0) + } + } + + # This function is recursive: it discovers the adjacent cells + # that are not mines + discoverCells($0 = mine label that has to be discovered) + { + # If it is a mine ,then do not discover it + if($0->%bIsMine)return; + # If it is already discovered , return too + if($0->%bIsDiscovered)return; + # Ok.. this is discovered + $0->%bIsDiscovered = 1 + $0->$setFrameStyle(WinPanel,Sunken) + # If this cell has adjacent mines then show their number and return + if($0->%numMines > 0)$0->$setText($0->%numMines) + else { + # There are no adjacent mines : discover the cells recursively + # This block of code is similar to the one used in dropping the bombs around + if($0->%row > 0) + { + # Discover the cells in the row above + $$->$discoverCells($$->%label{$($0->%row - 1),$0->%col}) + if($0->%col > 0)$$->$discoverCells($$->%label{$($0->%row - 1),$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$($0->%row - 1),$($0->%col + 1)}) + } + if($0->%row < ($$->%rows - 1)) + { + # Discover the cells in the row below + $$->$discoverCells($$->%label{$($0->%row + 1),$0->%col}) + if($0->%col > 0)$$->$discoverCells($$->%label{$($0->%row + 1),$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$($0->%row + 1),$($0->%col + 1)}) + } + # Discover on the left and right + if($0->%col > 0)$$->$discoverCells($$->%label{$0->%row,$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$0->%row,$($0->%col + 1)}) + } + } + +} + +%m = $new(minesweepermain) +%m->$show() diff --git a/doc/scriptexamples/tutorial/minesweeper4.kvs b/doc/scriptexamples/tutorial/minesweeper4.kvs new file mode 100644 index 00000000..0013736b --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper4.kvs @@ -0,0 +1,187 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 4 + +class(minelabel,label) +{ + mousePressEvent() + { + $$->$parent()->$mineLabelPressed($this) + } +} + +class(minesweepermain,widget) +{ + constructor() + { + # This is no longer needed here : we move it to the container widget + + $$->%rows = 10 + $$->%cols = 10 + $$->%mines = 10 + # is there a running game ? + $$->%bGameRunning = 0 + + + $$->%layout = $new(layout,$this) + + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + $$->%label{%i,%j}=$new(minelabel,$this,"%i_%j") + $$->%label{%i,%j}->%row = %i + $$->%label{%i,%j}->%col = %j + # Let's set the minimum size of the labels: they look better this way + $$->%label{%i,%j}->$setMinimumWidth(26) + $$->%label{%i,%j}->$setMinimumHeight(26) + $$->%label{%i,%j}->$setAlignment(HCenter , VCenter) + $$->%layout->$addWidget($$->%label{%i,%j},%i,%j) + } + } + # We remove this call, $$->$newGame() will be called from the container widget + #$$->$newGame() + } + + newGame() + { + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + %l = $$->%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->$setText("") + # Set enabled ! + %l->$setEnabled(1) + } + } + # drop the mines + for(%i = 0;%i < $$->%mines;%i++) + { + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + while($$->%label{%row,%col}->%bIsMine != 0) + { + %row = $rand($($$->%rows - 1)) + %col = $rand($($$->%cols - 1)) + } + $$->%label{%row,%col}->%bIsMine = 1 + # increase the mine count for the adiacent cells + if(%row > 0) + { + $$->%label{$(%row - 1),%col}->%numMines++ + if(%col > 0)$$->%label{$(%row - 1),$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < ($$->%rows - 1)) + { + $$->%label{$(%row + 1),%col}->%numMines++ + if(%col > 0)$$->%label{$(%row + 1),$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + if(%col > 0)$$->%label{%row,$(%col - 1)}->%numMines++ + if(%col < ($$->%cols - 1))$$->%label{%row,$(%col + 1)}->%numMines++ + } + # A game is running + $$->%bGameRunning = 1 + } + + mineLabelPressed($0 = mine label object that has been pressed) + { + # When the game isn't running we don't care about the mouse press events + if(!$$->%bGameRunning)return + if($0->%bIsMine) + { + $0->$setFrameStyle(WinPanel,Sunken) + $0->$setImage(82); # 82 is a bomb + # We emit the gameOver signal so the container widget knows + $$->$emit(gameOver) + # And disable all the cells + for(%i = 0;%i < $$->%rows;%i++) + { + for(%j = 0;%j < $$->%cols;%j++) + { + $$->%label{%i,%j}->$setEnabled(0) + } + } + # leave the bomb image enabled :D + $0->$setEnabled(1) + # Game finished :( + $$->%bGameRunning = 0 + } else { + $$->$discoverCells($0) + } + } + + discoverCells($0 = mine label that has to be discovered) + { + if($0->%bIsMine)return; + if($0->%bIsDiscovered)return; + $0->%bIsDiscovered = 1 + $0->$setFrameStyle(WinPanel,Sunken) + if($0->%numMines > 0)$0->$setText($0->%numMines) + else { + if($0->%row > 0) + { + $$->$discoverCells($$->%label{$($0->%row - 1),$0->%col}) + if($0->%col > 0)$$->$discoverCells($$->%label{$($0->%row - 1),$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$($0->%row - 1),$($0->%col + 1)}) + } + if($0->%row < ($$->%rows - 1)) + { + $$->$discoverCells($$->%label{$($0->%row + 1),$0->%col}) + if($0->%col > 0)$$->$discoverCells($$->%label{$($0->%row + 1),$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$($0->%row + 1),$($0->%col + 1)}) + } + if($0->%col > 0)$$->$discoverCells($$->%label{$0->%row,$($0->%col - 1)}) + if($0->%col < ($$->%cols - 1))$$->$discoverCells($$->%label{$0->%row,$($0->%col + 1)}) + } + } + +} + +# We want a bigger window around our minesweeper widget +# we want to provide some output and user menus... +# Thus we create a container widget class , that will be also our new toplevel widget + +class(minesweeper,widget) +{ + constructor() + { + $$->$setCaption("KVIrc's Minesweeper (0.1.0)"); + + # we need a layout to manage the children + $$->%layout = $new(layout,$$) + + + $$->%gamepool = $new(minesweepermain,$$) + $$->%layout->$addWidget($$->%gamepool,1,0) + connect $$->%gamepool gameOver $$ gameOver + + $$->%output = $new(label,$$) + $$->%output->$setFrameStyle(WinPanel,Sunken) + $$->%layout->$addWidget($$->%output,2,0) + + $$->$newGame() + } + + gameOver() + { + $$->%output->$setText("Game Over :(") + } + + newGame() + { + $$->%gamepool->$newGame() + $$->%output->$setText("Ready") + } +} + + +#We substitute the old creation call with the new container object creation call +#%m = $new(minesweepermain) +%m = $new(minesweeper) +%m->$show() diff --git a/doc/scriptexamples/tutorial/minesweeper5.kvs b/doc/scriptexamples/tutorial/minesweeper5.kvs new file mode 100644 index 00000000..1bda6c83 --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper5.kvs @@ -0,0 +1,201 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 5 + + +# First of all we convert all the $$-> to @ : this is faster both to write and for KVIrc to process + +class(minelabel,label) +{ + mousePressEvent() + { + # We also pass the mouse button pressed + @$parent()->$mineLabelPressed($this,$0) + } +} + +class(minesweepermain,widget) +{ + constructor() + { + @%rows = 20 + @%cols = 20 + @%mines = 60 + @%bGameRunning = 0 + + @%layout = $new(layout,$this) + + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + @%label{%i,%j}=$new(minelabel,$this,"%i_%j") + @%label{%i,%j}->%row = %i + @%label{%i,%j}->%col = %j + @%label{%i,%j}->$setMinimumWidth(26) + @%label{%i,%j}->$setMinimumHeight(26) + @%label{%i,%j}->$setAlignment(HCenter , VCenter) + @%layout->$addWidget(@%label{%i,%j},%i,%j) + } + } + } + + newGame() + { + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + %l = @%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->%iState = 0; # In state 0 it doesn't show anything + %l->$setText("") + %l->$setImage(); # show no image + %l->$setEnabled(1) + } + } + + for(%i = 0;%i < @%mines;%i++) + { + %row = $rand($(@%rows - 1)) + %col = $rand($(@%cols - 1)) + while(@%label{%row,%col}->%bIsMine != 0) + { + %row = $rand($(@%rows - 1)) + %col = $rand($(@%cols - 1)) + } + @%label{%row,%col}->%bIsMine = 1 + if(%row > 0) + { + @%label{$(%row - 1),%col}->%numMines++ + if(%col > 0)@%label{$(%row - 1),$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < (@%rows - 1)) + { + @%label{$(%row + 1),%col}->%numMines++ + if(%col > 0)@%label{$(%row + 1),$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + if(%col > 0)@%label{%row,$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{%row,$(%col + 1)}->%numMines++ + } + @%bGameRunning = 1 + } + + mineLabelPressed($0 = mine label object that has been pressed,$1 = the button that has been pressed) + { + if(!@%bGameRunning)return + + # We add the right button handling : the user can mark the cells discovered + if($1 == 1) + { + # Right button was pressed + if($0->%bIsDiscovered)return; # does nothing + # we loop the state thru 0->1->2->0 + switch($0->%iState) + { + case(0): + { + $0->$setImage(58) + $0->%iState = 1 + } + case(1): + { + $0->$setImage(28) + $0->%iState = 2 + } + case(2): + { + $0->$setImage() + $0->%iState = 0 + } + } + return; + } + + if($0->%bIsMine) + { + $0->$setFrameStyle(WinPanel,Sunken) + $0->$setImage(82); # 82 is a bomb + @$emit(gameOver) + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + @%label{%i,%j}->$setEnabled(0) + } + } + $0->$setEnabled(1) + @%bGameRunning = 0 + } else { + @$discoverCells($0) + } + } + + discoverCells($0 = mine label that has to be discovered) + { + if($0->%bIsMine)return; + if($0->%bIsDiscovered)return; + $0->%bIsDiscovered = 1 + $0->$setFrameStyle(WinPanel,Sunken) + if($0->%iState != 0)$0->$setImage(); # ensure that no image is shown + if($0->%numMines > 0)$0->$setText($0->%numMines) + else { + if($0->%row > 0) + { + @$discoverCells(@%label{$($0->%row - 1),$0->%col}) + if($0->%col > 0)@$discoverCells(@%label{$($0->%row - 1),$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$($0->%row - 1),$($0->%col + 1)}) + } + if($0->%row < (@%rows - 1)) + { + @$discoverCells(@%label{$($0->%row + 1),$0->%col}) + if($0->%col > 0)@$discoverCells(@%label{$($0->%row + 1),$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$($0->%row + 1),$($0->%col + 1)}) + } + if($0->%col > 0)@$discoverCells(@%label{$0->%row,$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$0->%row,$($0->%col + 1)}) + } + } + +} + + +class(minesweeper,widget) +{ + constructor() + { + @$setCaption("KVIrc's Minesweeper (0.1.0)"); + + @%layout = $new(layout,$$) + + + @%gamepool = $new(minesweepermain,$$) + @%layout->$addWidget(@%gamepool,1,0) + connect @%gamepool gameOver $$ gameOver + + @%output = $new(label,$$) + @%output->$setFrameStyle(WinPanel,Sunken) + @%layout->$addWidget(@%output,2,0) + + @$newGame() + } + + gameOver() + { + @%output->$setText("Game Over :(") + } + + newGame() + { + @%gamepool->$newGame() + @%output->$setText("Ready") + } +} + + +%m = $new(minesweeper) +%m->$show() diff --git a/doc/scriptexamples/tutorial/minesweeper6.kvs b/doc/scriptexamples/tutorial/minesweeper6.kvs new file mode 100644 index 00000000..f03ffb05 --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper6.kvs @@ -0,0 +1,254 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 6 + +class(minelabel,label) +{ + mousePressEvent() + { + # We also pass the mouse button pressed + @$parent()->$mineLabelPressed($this,$0) + } +} + +class(minesweepermain,widget) +{ + # We accept constructor parameters now + constructor($0 = rows,$1 = cols,$2 = num mines) + { + # We should check the parameters passed here, and maybe return 0 + # if the params are not positive numbers + echo $0,$1,$2 + @%rows = $0 + @%cols = $1 + @%mines = $2 + @%bGameRunning = 0 + + @%layout = $new(layout,$this) + + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + @%label{%i,%j}=$new(minelabel,$this,"%i_%j") + @%label{%i,%j}->%row = %i + @%label{%i,%j}->%col = %j + @%label{%i,%j}->$setMinimumWidth(26) + @%label{%i,%j}->$setMinimumHeight(26) + @%label{%i,%j}->$setAlignment(HCenter , VCenter) + @%layout->$addWidget(@%label{%i,%j},%i,%j) + } + } + } + + newGame() + { + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + %l = @%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->%iState = 0; # In state 0 it doesn't show anything + %l->$setText("") + %l->$setImage(); # show no image + %l->$setEnabled(1) + } + } + + for(%i = 0;%i < @%mines;%i++) + { + %row = $rand($(@%rows - 1)) + %col = $rand($(@%cols - 1)) + while(@%label{%row,%col}->%bIsMine != 0) + { + %row = $rand($(@%rows - 1)) + %col = $rand($(@%cols - 1)) + } + @%label{%row,%col}->%bIsMine = 1 + if(%row > 0) + { + @%label{$(%row - 1),%col}->%numMines++ + if(%col > 0)@%label{$(%row - 1),$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < (@%rows - 1)) + { + @%label{$(%row + 1),%col}->%numMines++ + if(%col > 0)@%label{$(%row + 1),$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + if(%col > 0)@%label{%row,$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{%row,$(%col + 1)}->%numMines++ + } + @%bGameRunning = 1 + # We keep track of the number of the discovered cells + @%iTotalNonMineCells = $((@%rows * @%cols) - @%mines) + @%iUndiscoveredNonMineCells = @%iTotalNonMineCells + } + + mineLabelPressed($0 = mine label object that has been pressed,$1 = the button that has been pressed) + { + if(!@%bGameRunning)return + + # We add the right button handling : the user can mark the cells discovered + if($1 == 1) + { + # Right button was pressed + if($0->%bIsDiscovered)return; # does nothing + # we loop the state thru 0->1->2->0 + switch($0->%iState) + { + case(0): + { + $0->$setImage(58) + $0->%iState = 1 + } + case(1): + { + $0->$setImage(28) + $0->%iState = 2 + } + case(2): + { + $0->$setImage() + $0->%iState = 0 + } + } + return; + } + + if($0->%bIsMine) + { + @$gameFailure($0) + } else { + @$discoverCells($0) + if(@%iUndiscoveredNonMineCells == 0) + { + # Finished! + @$gameSuccess() + } else { + @$emit(userMoved) + } + } + } + + discoverAllCells() + { + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + %l = @%label{%i,%j} + if(!%l->%bIsDiscovered) + { + %l->$setFrameStyle(WinPanel,Sunken) + if(%l->%bIsMine)%l->$setImage(82) + else { + %l->$setImage("") + if(%l->%numMines > 0)%l->$setText(%l->%numMines) + else %l->$setText("") + } + } + %l->$setEnabled(0) + } + } + } + + gameFailure($0 = the game cell that had the bomb) + { + @$discoverAllCells() + $0->$setFrameStyle(WinPanel,Sunken) + $0->$setImage(82); # 82 is a bomb + $0->$setEnabled(1) + @%bGameRunning = 0 + @$emit(gameOver) + } + + gameSuccess() + { + @$discoverAllCells() + @%bGameRunning = 0 + @$emit(success) + } + + discoverCells($0 = mine label that has to be discovered) + { + if($0->%bIsMine)return; + if($0->%bIsDiscovered)return; + $0->%bIsDiscovered = 1 + $0->$setFrameStyle(WinPanel,Sunken) + @%iUndiscoveredNonMineCells-- + if($0->%iState != 0)$0->$setImage(); # ensure that no image is shown + if($0->%numMines > 0)$0->$setText($0->%numMines) + else { + if($0->%row > 0) + { + @$discoverCells(@%label{$($0->%row - 1),$0->%col}) + if($0->%col > 0)@$discoverCells(@%label{$($0->%row - 1),$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$($0->%row - 1),$($0->%col + 1)}) + } + if($0->%row < (@%rows - 1)) + { + @$discoverCells(@%label{$($0->%row + 1),$0->%col}) + if($0->%col > 0)@$discoverCells(@%label{$($0->%row + 1),$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$($0->%row + 1),$($0->%col + 1)}) + } + if($0->%col > 0)@$discoverCells(@%label{$0->%row,$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$0->%row,$($0->%col + 1)}) + } + } + +} + + +class(minesweeper,widget) +{ + constructor() + { + @$setCaption("KVIrc's Minesweeper (0.1.0)"); + + @%layout = $new(layout,$$) + + # Create a 10x10 game pool with 10 mines + @%gamepool = $new(minesweepermain,$$,myGamepool,10,10,10) + @%layout->$addWidget(@%gamepool,1,0) + connect @%gamepool gameOver $$ gameOver + # We connect the two new signals + connect @%gamepool userMoved $$ showState + connect @%gamepool success $$ success + @%output = $new(label,$$) + @%output->$setFrameStyle(WinPanel,Sunken) + @%layout->$addWidget(@%output,2,0) + + @$newGame() + } + + showState() + { + @%output->$setText("@%gamepool->%iUndiscoveredNonMineCells to go") + } + + success() + { + @%output->$setText("You did it!") + } + + gameOver() + { + @%output->$setText("Game Over :(") + } + + newGame() + { + @%gamepool->$newGame() + @%output->$setText("Ready") + @$showState() + } +} + + +%m = $new(minesweeper) +%m->$show() diff --git a/doc/scriptexamples/tutorial/minesweeper7.kvs b/doc/scriptexamples/tutorial/minesweeper7.kvs new file mode 100644 index 00000000..701c09d3 --- /dev/null +++ b/doc/scriptexamples/tutorial/minesweeper7.kvs @@ -0,0 +1,253 @@ +# The scripts in this tutorial implement the famous minesweeper game +# STEP 7 + +class(minelabel,label) +{ + mousePressEvent() + { + @$parent()->$mineLabelPressed($this,$0) + } +} + +class(minesweepermain,widget) +{ + constructor($0 = rows,$1 = cols,$2 = num mines) + { + # We should check the parameters passed here, and maybe return 0 + # if the params are not positive numbers + echo $0,$1,$2 + @%rows = $0 + @%cols = $1 + @%mines = $2 + @%bGameRunning = 0 + + @%layout = $new(layout,$this) + + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + @%label{%i,%j}=$new(minelabel,$this,"%i_%j") + @%label{%i,%j}->%row = %i + @%label{%i,%j}->%col = %j + @%label{%i,%j}->$setMinimumWidth(26) + @%label{%i,%j}->$setMinimumHeight(26) + @%label{%i,%j}->$setAlignment(HCenter , VCenter) + @%layout->$addWidget(@%label{%i,%j},%i,%j) + } + } + } + + newGame() + { + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + %l = @%label{%i,%j} + %l->$setFrameStyle(Raised,WinPanel); + %l->%bIsMine = 0 + %l->%numMines = 0 + %l->%bIsDiscovered = 0 + %l->%iState = 0; # In state 0 it doesn't show anything + %l->$setText("") + %l->$setImage(); # show no image + %l->$setEnabled(1) + } + } + + for(%i = 0;%i < @%mines;%i++) + { + %row = $rand($(@%rows - 1)) + %col = $rand($(@%cols - 1)) + while(@%label{%row,%col}->%bIsMine != 0) + { + %row = $rand($(@%rows - 1)) + %col = $rand($(@%cols - 1)) + } + @%label{%row,%col}->%bIsMine = 1 + if(%row > 0) + { + @%label{$(%row - 1),%col}->%numMines++ + if(%col > 0)@%label{$(%row - 1),$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{$(%row - 1),$(%col + 1)}->%numMines++ + } + if(%row < (@%rows - 1)) + { + @%label{$(%row + 1),%col}->%numMines++ + if(%col > 0)@%label{$(%row + 1),$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{$(%row + 1),$(%col + 1)}->%numMines++ + } + if(%col > 0)@%label{%row,$(%col - 1)}->%numMines++ + if(%col < (@%cols - 1))@%label{%row,$(%col + 1)}->%numMines++ + } + @%bGameRunning = 1 + # We keep track of the number of the discovered cells + @%iTotalNonMineCells = $((@%rows * @%cols) - @%mines) + @%iUndiscoveredNonMineCells = @%iTotalNonMineCells + } + + mineLabelPressed($0 = mine label object that has been pressed,$1 = the button that has been pressed) + { + if(!@%bGameRunning)return + + if($1 == 1) + { + # Right button + if($0->%bIsDiscovered)return; # does nothing + switch($0->%iState) + { + case(0): + { + $0->$setImage(58) + $0->%iState = 1 + } + case(1): + { + $0->$setImage(28) + $0->%iState = 2 + } + case(2): + { + $0->$setImage() + $0->%iState = 0 + } + } + return; + } + + if($0->%bIsMine) + { + @$gameFailure($0) + } else { + @$discoverCells($0) + if(@%iUndiscoveredNonMineCells == 0) + { + # Finished! + @$gameSuccess() + } else { + @$emit(userMoved) + } + } + } + + discoverAllCells() + { + for(%i = 0;%i < @%rows;%i++) + { + for(%j = 0;%j < @%cols;%j++) + { + %l = @%label{%i,%j} + if(!%l->%bIsDiscovered) + { + %l->$setFrameStyle(WinPanel,Sunken) + if(%l->%bIsMine)%l->$setImage(82) + else { + %l->$setImage("") + if(%l->%numMines > 0)%l->$setText(%l->%numMines) + else %l->$setText("") + } + } + %l->$setEnabled(0) + } + } + } + + gameFailure($0 = the game cell that had the bomb) + { + @$discoverAllCells() + $0->$setFrameStyle(WinPanel,Sunken) + $0->$setImage(82); # 82 is a bomb + $0->$setEnabled(1) + @%bGameRunning = 0 + @$emit(gameOver) + } + + gameSuccess() + { + @$discoverAllCells() + @%bGameRunning = 0 + @$emit(success) + } + + discoverCells($0 = mine label that has to be discovered) + { + if($0->%bIsMine)return; + if($0->%bIsDiscovered)return; + $0->%bIsDiscovered = 1 + $0->$setFrameStyle(WinPanel,Sunken) + @%iUndiscoveredNonMineCells-- + if($0->%iState != 0)$0->$setImage(); # ensure that no image is shown + if($0->%numMines > 0)$0->$setText($0->%numMines) + else { + if($0->%row > 0) + { + @$discoverCells(@%label{$($0->%row - 1),$0->%col}) + if($0->%col > 0)@$discoverCells(@%label{$($0->%row - 1),$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$($0->%row - 1),$($0->%col + 1)}) + } + if($0->%row < (@%rows - 1)) + { + @$discoverCells(@%label{$($0->%row + 1),$0->%col}) + if($0->%col > 0)@$discoverCells(@%label{$($0->%row + 1),$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$($0->%row + 1),$($0->%col + 1)}) + } + if($0->%col > 0)@$discoverCells(@%label{$0->%row,$($0->%col - 1)}) + if($0->%col < (@%cols - 1))@$discoverCells(@%label{$0->%row,$($0->%col + 1)}) + } + } + +} + + +class(minesweeper,window) +{ + constructor() + { + @$setCaption("KVIrc's Minesweeper (0.1.0)"); + + @%layout = $new(layout,$$) + + @%menubar = $new(menubar,$$) + @%menubar->$insertItem(test) + @%layout->$addWidget(@%menubar,0,0) + + @%gamepool = $new(minesweepermain,$$,myGamepool,10,10,10) + @%layout->$addWidget(@%gamepool,1,0) + connect @%gamepool gameOver $$ gameOver + # We connect the two new signals + connect @%gamepool userMoved $$ showState + connect @%gamepool success $$ success + @%output = $new(label,$$) + @%output->$setFrameStyle(WinPanel,Sunken) + @%layout->$addWidget(@%output,2,0) + + @$newGame() + } + + showState() + { + @%output->$setText("@%gamepool->%iUndiscoveredNonMineCells to go") + } + + success() + { + @%output->$setText("You did it!") + } + + gameOver() + { + @%output->$setText("Game Over :(") + } + + newGame() + { + @%gamepool->$newGame() + @%output->$setText("Ready") + @$showState() + } +} + + +%m = $new(minesweeper) +%m->$show() diff --git a/doc/scriptexamples/widget1.kvs b/doc/scriptexamples/widget1.kvs new file mode 100644 index 00000000..21511b34 --- /dev/null +++ b/doc/scriptexamples/widget1.kvs @@ -0,0 +1,20 @@ +# a stupid game :) + +srand $unixTime + +%w = $new(widget,0,mywidget) +%w->$setCaption(":)"); +%w->$setGeometry($rand(770),$rand(570),30,30); + +privateimpl(%w,mouseEnterEvent) +{ + $$->$move($rand(770),$rand(570)); +} + +privateimpl(%w,mousePressEvent) +{ + echo "You got me!" + delete $$ +} + +%w->$show() diff --git a/doc/scriptexamples/widget2.kvs b/doc/scriptexamples/widget2.kvs new file mode 100644 index 00000000..8c9b5b7a --- /dev/null +++ b/doc/scriptexamples/widget2.kvs @@ -0,0 +1,23 @@ +# a stupid game :) (version 2) + +class(mystupidgame,widget) +{ + constructor + { + srand $unixTime; + $$->$setCaption(":)"); + $$->$setGeometry($rand(770),$rand(570),30,30); + } + mouseEnterEvent + { + $$->$move($rand(770),$rand(570)); + } + mousePressEvent + { + echo "You got me!" + delete $$ + } +} + +%w = $new(mystupidgame,0) +%w->$show() diff --git a/doc/scripting.faq.txt b/doc/scripting.faq.txt new file mode 100644 index 00000000..7d594cd1 --- /dev/null +++ b/doc/scripting.faq.txt @@ -0,0 +1,48 @@ +------------------------------------------------------------------------------- +Q: What is a callback (command) ? + +A: A callback is a command or set of commands that is called by KVIrc in + response to an event. It is similar to an event handler; the difference + is that the event handler is usually static, the callback is "created" + at runtime instead. + Consider the command exec (see /help exec); its syntax is as follows: + + exec(<commandline>[,<magicparams>]) + { + <callback> + } + + The <callback> is a list of commands that will be called by KVIrc when + the <commandline> has been executed and the slave process has printed + some data on its stdout. + + +------------------------------------------------------------------------------- +Q: How can i print on a window the result of an external command like nmap + or uname ? + +A: Starting from version 3.0.0 KVIrc supports (again) the /exec command. + The commandline you're looking for might be something similar to: + + exec("uname -a"){ echo $1; }; + + If you want to say the result to a channel you may use say instead of echo + + exec("uname -a"){ say $1; }; + + For nmap you might consider using the -e switch too in order to see + the errors printed on stderr. + + exec -e ("nmap -sS -p 1-1024 somehost"){ say $1; } + + Exec is a really flexible command, it can process the slave output in blocks + or as a whole and can write data to the slave too. See /help exec for + more details. + +------------------------------------------------------------------------------- +Q: KVIrc crashes when I use a commandline like the following: + alias(identify){ identify password; } + +A: This is infinite recursion: a programming error. + Take a look at http://en.wikipedia.org/wiki/Infinite_loop , learn + that once for all and fix your script. diff --git a/doc/themes.howto.txt b/doc/themes.howto.txt new file mode 100644 index 00000000..ac04de35 --- /dev/null +++ b/doc/themes.howto.txt @@ -0,0 +1,123 @@ +Starting from the release 3.0.0 KVIrc supports user interface themeing. + +A KVIrc theme is basically: +- a subset of the options that controls the visual appearance + of the user interface +- a set of icons that override the default ones + +The skeleton for a new theme can be produced by simply saving your current +theme. Open the options dialog and go to the Look & Feel / Theme page. +Click on "Save current theme", enter the description in the dialog that +appears and select "Ok". The theme skeleton is now saved in your home +directory.The confirmation dialog +should have told you exactly where: it should be a directory like +$HOME/.kvirc/<kvircversion>/theme/<yourthemename>-<yourthemeversion>. +Cd to that directory and look around. You should see two configuration *.kvc +files and a lot of *.png images. + +themeinfo.kvc contains the informations that the user can see when browsing +the themes in the options dialog. The format of this file should be obvious: +you can edit it manually if you want to make some changes. +(The %20 strings are url-encoded spaces, KVirc will accept also plain spaces). + +themedata.kvc contains the visual settings. It looks more or less like this: + + .... + uintGlobalTransparencyParentFadeFactor=10 + boolObtainGlobalBackgroundFromKde=false + pixmapLabelBackground= + msgtypeMotd=30,1,100,1,1 + fontIrcView=helvetica,10,5,50 + colorIrcToolBarAppletForegroundLowContrast=180,180,180 + boolUseGuiEffectFadeMenu=false + pixmapGlobalTransparencyBackground=pixmapGlobalTransparencyBackground.png + pixmapTreeTaskBarBackground= + iccolor2=0,0,200 + mirccolor13=200,0,200 + .... + +You can *carefully* edit it by hand, if you wish. +Each option starts with a prefix that defines the "type" of that option. + +pixmap defines an image and thus should contain an image path (see below) +color defines an user interface color and is an R,G,B triplet +font defines an user interface font: you usually need to change only the + first two values: font family and size +msgtype defines the icon, text color, background color, log level and + alert level of the messages +uint is an unsigned integer value +bool is a boolean value: true or false +mirccolor defines the colors used by the CTRL+K escape and is an + R,G,B triplet like color. +iccolor defines the default color of an irc context and is again an + R,G,B triplet. + +Hints: + - When changing the pixmap entries remember to use filenames + without path. KVIrc will lookup the filenames in the directory + of your the me. + + - The options stringIconThemeSubdir reflects the name of the + directory in which the theme images are stored. + If you change the directory name, you must also change this option. + +The theme directory contains also a set of *.png files. +KVIrc will load these files instead of the default ones shipped in the +distribution. You can modify/replace them, but keep in mind the +following simple rules: + - you can't modify the image size: if you do it, + the images will look bad + - the image format must be *.png: it is the only + format granted to be loaded by all the versions of KVIrc. + +If you don't want to "override" an image (and thus you want to leave +the "default" one) you can delete it from the theme directory. KVIrc will +fallback to the default image shipped in the distribution. + +If you look at the global kvirc installation directory (usually +/usr/local/share/kvirc/version/pics/) you will notice that there are other +images that KVIrc loads. You can override each image by placing your version +with the same name in your theme directory. + +Hints: + - All the small icons have a meaning and a name: + you should reflect it when painting. + This small script will show you the associations between + the icons and their names: + + %i = 0 + do { + %name = $iconname(%i) + echo The icon by id %i is named %name + %i++ + } while(%name != "") + + - The id's of the icons are just their ZERO_BASED indexes. + The kvi_smallicon_<number>.png files are numbered in increasing + order and contain 16 images each one. kvi_smallicon_00.png + contains images from 0 to 15, kvi_smallicon_01.png contains images + 16 to 31 etc... Thus the third icon in kvi_smallicon_02.png + has id (2*16)+(3)-1 = 34. + + + + +What happens when an user installs a theme +----------------------------------------------------------------------------- + +When an user attempts to install a theme from the options dialog, +KVIrc reads the themedata.kvc file and applies all the visual settings. +This is an one-time action: the settings are applied only once from the +themedata.kvc file and then are saved to the user's configuration files. +In this way the user can alter the theme by freely changing the individual +settings. One of the applied options is stringIconThemeSubdir that contains +the directory of the theme images. KVIrc uses this option to lookup the +image files before looking at any other directory. If the image file is found +there, it is loaded and used, otherwise KVIrc falls back to the images +shipped in the distribution. + + +Have fun :) + +Szymon Stefanek + diff --git a/doc/translations.howto.txt b/doc/translations.howto.txt new file mode 100644 index 00000000..52cb5c28 --- /dev/null +++ b/doc/translations.howto.txt @@ -0,0 +1,134 @@ +This mini-howto describes the procedure for translating KVIrc in a new language.----------------------------------------------------------------------------------- + +Step 0: Getting the right sources. + + First of all you need the SVN version of kvirc. + To obtain the SVN version you can follow the instructions on + http://www.kvirc.net/?id=svn + + The translation stuff is in kvirc/po/kvirc . + + + + +Step 1: Finding out your language code + +You must find out the contents of your language code. +Usually this is a string formed of at least two letters and it +can be found by examining the contents of your $LANG shell variable +or by looking at http://translation.sourceforge.net/HTML/teams.html +Examples of such codes are "it", "en", "hu" or "pt_BR" + + + +Step 2: Generating the list of messages to translate + +You must perform this step only if it is the first time that KVIrc is translated +to your language. If you're going to update an existing translation then +you can jump directly to step 3. + +Run the command to extract the messages from the sources. + +# cd kvirc/po/kvirc +# make messages-extract + +A file named kvirc.pot will be created +You rename this file to kvirc_xxx.po where xxx is your language code +found in step 1. + +# mv kvirc.pot kvirc_xxx.po + + + +Step 3: Translating the messages + +If you did the step 2 then you have just created the kvirc_xxx.po +file where xxx stands for your language code (found in step 1). +If you jumped directly here from 1 then you need to find and existing +kvirc_xxx.po in the kvirc/po/kvirc directory. +If there isn't one then go back to step 2. + +Just use a translation tool for translation (for example kbabel or poedit). + + +The next part of this step is only for information: +The kvirc_xxx.po file contains a set of strings like the following one: + +#: /path/to/the/file/which/contains/the/string: line number +msgid "The original english message" +msgstr "The translation goes here" + +The msgid is the original message that needs to be translated +and msgstr is the translation (that will be initially empty, when +the kvirc_xxx.po file is created). + +The msgid can contain html tags, escapes like "\n" and format specifications +like "%s". You MUST match the tags, escapes and format specs in the msgstr +strings. Keep special attention to the format specifications (%s, %W, +%Q...).. +They must remain in EXACTLY the same order as in the msgid: exchanging the +order or writing a wrong format spec will make kvirc crash sooner or later. + + + +Step 4: Adding the translation to the Makefile.am + +Once you have translated some strings you can try to run the translation in +kvirc. If you are updating an existing translation then you can jump +directly to step 5. + +You must force the make process to pick up your translation +file and compile it. This is again an one time step. +In kvirc/src/kvirc there is a file named Makefile.am +You should edit it and add kvirc_xxx.po where the other *.po files are +mentioned. You should have no problems in guessing what needs to be added +by looking at the other *.po entries in that file. +Then you just run ./autogen.sh , ./configure and you build kvirc as usual. +After it has finished building you run kvirc after making sure that your LANG +variable is set correctly. + + + +Step 5: Trying the translation + +Run make and wait until it finishes. + +# export LANG="xxx" +# kvirc + +KVirc should then pick up your translation file and use it. + + +Step 6: Updating the translation when the sources change + +While the development goes on new messages are added to the sources +and a small part of the existing messages change. +When you do a svn update to obtain the latest sources you should +cd to kvirc/po/kvirc and run: + +# make messages-update + +This procedure will update your kvirc_xxx.po file with the new messages +and mark the old messages as either fuzzy or invalid. +The invalid entries must be re-translated completely again while the +fuzzy entries have minor changes and can be probably adjusted in few seconds. + + +Misc: + + +If you're in doubt about some translation, you should take a look at how +similar sentences have been translated in the KDE *.po files: there should +be a hungarian translation file for KDE available on the KDE svn. + +Since many of the modules have their own translation files then +the procedure above may (but not must) be repeated for the po/modules/*/ +subdirectories. + +When you're satisfied with your translation you may send your *.po files to +pragma at kvirc dot net asking for inclusion in the svn. If you want +to mantain the translation then you may also ask for a writeable svn account. + + +Happy translating :) +Szymon Stefanek diff --git a/doc/ui-style.tips.txt b/doc/ui-style.tips.txt new file mode 100644 index 00000000..b2162fc2 --- /dev/null +++ b/doc/ui-style.tips.txt @@ -0,0 +1,40 @@ +************************ +*** KVIrc Style Tips *** +************************ + +[Dialog Windows] +- Title should be like "Choose a Script File", not "Choose a script file". +- For any non-modal dialogs (config ones, etc.), the name should have " - KVIrc" + at the end. This also applies to wizards and file selection dialogs. + +[Menubars] +- Menus have specific locations in menubars, see KDE style guide. + +[Menus] +- Menu item text be like "An Item", not "An item" +- Common items are: + "Cu&t" "&Copy" "&Paste" "Clear" "&Open..." "&Save As..." +- Items that open a dialog or otherwise require confirmation or additional + information should have "..." immediately following their text (no spaces). + +[Selector Widgets] +- bool selector labels should be like "Enable debug output" +- string/file path/integer selectors should have labels with a colon ":" at the end, e.g. "Comment:" +- QGroupBox text should be like "Use Filtering For". +- Config selector tooltips should have "<center></center>", and end each + sentence with a fullstop (period). There should be few <br> except for + separating sections. + +[Buttons] +- Button text should be like "A Button", not "A button". +- Common labels are: + "&OK" "&Apply" "Cancel" "&New" "&Add..." "Re&move" "&Close" "&Browse..." +- Button QToolTips should be a description of its function, and +ending with a fullstop (period): + "Accept all changes, and close this dialog." + "Kill the current user." ("Kill", not "Kills") +- OR if the button has no text, the tooltip should be the *label text*. +- Buttons are best in a QHBox. +- Try to keep names short. + +* For further reference, see the KDE Style Guide (google for it). diff --git a/doc/win32.compiling.1.2.txt b/doc/win32.compiling.1.2.txt new file mode 100644 index 00000000..bb396a33 --- /dev/null +++ b/doc/win32.compiling.1.2.txt @@ -0,0 +1,269 @@ +Win32 KVIrc compiling 1.2 +a tutorial by <Grifisx> +updated by <LoSko> on 2007/01/18 + +english translation by <etherea`> + +Index + +@ Prologue +@ Ingredients +@ Providing ingredients +@ Setting up the ambiency +@ Setting ambiency variables +@ Compiling +@ Creating ambiency for setup +@ Creating setup + +@ Prologue + +This is meant to be a simple guide to KVIrc compiling under Windows ambiency, so +that everyone who's willing to try to compile the latest version of this cross platform +client can easily do without the need for the latest snapshot/development to be +released. + +@ Ingredients + +1) CVS version of KVIrc +2) Visual C++ 2005 Express +3) SDK package from Microsoft +4) Perl. +5) gettext for Windows +6) Innosetup or NSIS +7) Non Commercial QT 3.2.1 +8) OpenSSL +9) zlib for Win32 + +@ Providing ingredients + +So, let's see where to find the necessary ingredients to bake up our freshy KVIrc. + +-1) CVS version of KVIrc + +To get this out you will need a CVS client for Windows, then type the following +command: + +cvs -z3 -d:pserver:anonymous@cvs.kvirc.net:/cvs co kvirccvs + + +And just in case you can find instructions here: +Link: http://www.kvirc.net/?id=cvs +A suggestion for a tiny and free CVS is Tortoise CVS. +Link: http://www.tortoisecvs.org/ + +-2) Visual C++ 2005 Express + +This compiler is free (at least for the moment), you will only need to register in order to +get it and use it for free, use it! +Link: http://msdn.microsoft.com/vstudio/express/visualc/ + +-3) SDK package from Microsoft + +This one too is for free, then download and install it! +Link: http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3A93E-40C0EC4F68E5&displaylang=en + +-4) Perl +Perl is needed to create documentation and make perl module works, you can +download it from here: +Link: http://www.activestate.com/Products/ActivePerl/? + +-5) gettext for Windows +Download and install it, it's needed to create languages localization files: +Link: http://sourceforge.net/projects/gettext +Note: be sure to install gettext in this directory C:\Program Files\GnuWin32 so that all the +executables are located in C:\Program Files\GnuWin32\bin otherwise you'll be forced to +change something in the file needed to create the setup ambiency. + +-6) Innosetup + +Another free program, required to create the final setup. +Link: http://www.jrsoftware.org/isinfo.php +If you are using NSIS you can have your copy here: +Link: http://nsis.sourceforge.net/Download + +-7) Non Commercial QT 3.2.1 + +That's probably the most difficult thing to acquire; you can try find a book on QT that +has it enclosed (the non commercial one) or you'll have to figure out how to find it out. +You can buy a commercial version too, 3.x.x higher than 3.2.1. + +Book: C++ GUI Programming with QT 3 +Link: http://www.amazon.com/gp/product/0131240722/102-11831924381702?v=glance&n=283155 +If you are pretty acknowledged with compiling you can try these instructions: +Link: http://qtwin.sourceforge.net/qt3-win32/compile-msvc-2005.php +Even if this last choice's a bit nasty to make out working =) +You still can find some precompiled version of this free stand (found on the same site of +qtwin even if a bit older) but beware: choosing this last chance will make KVIrc XP +themes not supported. +By using a different version of QT you'll need to modify every KVIrc project adapting +the qt.xxxx.dll and headers and libraries paths. +For example, assuming you have installed commercial QT 3.3.4 you'll have to modify +the projects this way: +a) selecting Properties of each project then ->Linker and ->Input +b) store the right library in the qt-mtnc321.lib matching the installed version +requirements, ie qt-3.3.4.lib. To know the exact name of your .lib file to be linked just go +to the directory where you did installed QT, in the subfolder /lib (like C:\Qt\3.3.4\lib) + +-8) OpenSSL +That is needed in order to compile SSL support for KVIrc, you can have libraries and +everything else from here: +Link: http://www.slproweb.com/products/Win32OpenSSL.html + +-9) zlib for win32 + +To give KVIrc the ability to save log files in compressed format that's what you need. +Link: http://gnuwin32.sourceforge.net/packages/zlib.htm + +That's the main page, but you will need the developers files: +Link: http://gnuwin32.sourceforge.net/downloadlinks/zlib-lib-zip.php +Extract them in any folder you may like, my own suggestion is folder C:\lib for your +convenience; directory tree will be as follows: + +C:(dir) +|__zlib(dir) +|__include(dir) +| |__zconf.h +| |__zlib.h +|__lib(dir) +|__zlib.lib +|__zlib.exp + +Remember where did you have this folder extract because you will have to setup paths +of the include files (the .h files) and of the libraries (the .lib files) in ambiency variables +of your operating system. + +@ Setting up the ambiency + +Install in the following order (theoretically it is not necessary a given order but this +“recipe” is fully oriented to non expert users): +1-Visual C++ 2005 Express +2-SDK ; once you have installed it take the folders Lib, Include and Bin (you will find +them all in the SDK given path – generally in folder C:\Program Files\Microsoft Platform +SDK) and copy them in the folder \SDK\v2.0 that is under the installation path of Visual +C++ (generally in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0). +Attention: when copying these files you'll be prompted to overwrite one or more files; +just answer NO. +3-QT 3.x.x ; during the installation you'll be prompted to record ambiency variables: +answer YES. +4-OpenSSL ; during the installation you'll be prompted to record ambiency variables: +answer YES. +5-Perl ; during the installation you'll be prompted to record ambiency variables: +answer YES. +6-gettext +7-Innosetup or NSIS or both =) (Freedom is the power to choose ;)) +8-zlib ; if you did download the install&compile package; otherwise just unpack +and/or extract the ready-to-use pakage wherever you may like (generally in folder C:\). + +@ Setting ambiency variables + +Now we need to set up every variable of this ambiency, needed in order the compiler +will be able to find every library from which KVIrc depends. +Right-button on Resources then Properties -> Advanced -> Ambient Variables and this will +engage all QT system variables (QTDIR) set; if that doesn't match you will need to +reinstall QT and remember to answer YES once you're prompted for setting all ambiency +variables, otherwise you will need to set them manually – that parts from this tutorial. + +In the section dedicated to variables of the actual user add (if you don't have it yet) the +following and then give the right paths that are on your own machine (hereby are my +own paths): + +Variable: + +PERLDIR +Value: +C:\perl +Meaning: +Directory that stores Perl + +Variable: +ZLIBLIBDIR +Value: +C:\zlib\lib +Meaning: +Directory that stores file .lib of zlib installed library, the file name must be zlib.lib + +Variable: +OPENSSL +Value: +C:\OpenSLL +Meaning: +Installation folder of OpenSSL + +Variable: +SSLINCDIR +Value: +C:\OpenSSL\include +Meaning: +Directory that stores OpenSSL .h files + +Variable: +SSLLIBDIR +Value: +C:\OpenSSL\lib\VC +Meaning: +OpenSSL .lib files storage + +Variable: +MSGFMT +Value: +C:\Program Files\GnuWin32\bin\msgfmt.exe +Meaning: +msgfmt executable path + +After you've added all the variables with their own values you need to reboot. + +@ Compiling + +Go to folder kvirccvs\kvirc and open the file kvirc_vc05.sln then -for the less +experienced-select Build -> Configure Manager -> Release and run the compiling with +Build ->Build Solution. +You'll need to wait a little before the building ends, mostly that's up to your processor +(on a P3 800MHz it takes about 40/45 minutes, on a P4 3000 just 10/15 minutes). +Now.. pray everything is going to get the right place and no unexpected to happen; but +in case you do have troubles here are 3 different solutions: + +a) read this tutorial once more, hoping you missed some points; +b) try to find out where the problem is; +c) step to Azzurranet on channel #kvirc.net and ask for Grifisx or Noldor or Pragma. + +@ Creating ambiency for setup + +If you're reading this, thank God, your patience and your mother (yes, yet she didn't +managed to kill you death nevertheless you spent 28 hours a day reading lines on a +monitor) you're almost done! +The latest 2 steps are quite easy. +Go to folder kvirccvs\kvirc\win32build and run makedist.vbs file. +Then run the process, on which end you'll get a folder named pakage; be sure inside +there are kvirc.exe, kvilib.dll, the folder with every KVIrc module and the following dlls: + +ssleay32.dll +libeay32.dll +qt-mtnc3321.dll +perl58.dll +zlib1.dll +idleui.dll +msvcr80.dll + + +If you see something missing just run up a search onto your system and copy them into +the pakage directory. +Check even the file Microsoft.VC80.CRT.manifest is placed both in root folder and sub folder +modules, otherwise copy it into them (files are stored into kvirccvs\kvirc\data\manifests ; +in this last case you will only need to rename the given file +Microsoft.VC80.CRT.modules.manifest into Microsoft.VC80.CRT.manifest before you put it in +the modules folder). + +@ Creating setup + +Easypeasy! +After installation of Innosetup launch file KVIrc.iss that houses in folder +kvirccvs\kvirc\win32build and run the script so that at the end of the process you'll find +a freshy hot setup.exe in folder kvirccvs\kvirc\win32build\package\setup. +If you did chose NSIS: right click on the KVIrc.nsi installation script that is found in +folder kvirccvs\kvirc\win32build and run Compile NSIS Script. +This way you'll have a KVIrc.VERSION-dev-DATE.exe in your actual directory! +Run. +If everything went ok then.. EnjoY! =D + +Tonino Imbesi +<Grifisx> |