# HG changeset patch # User Mikael Berthe # Date 1269703031 -3600 # Node ID b2b3b42944ac32bf9a78e5c436bfe758d5ec69f4 # Parent d3d4d1c1cb00a6a21d74eb6141a28f980da48e8d# Parent c08db93d4907a55816bb9cbd4851db37d2680613 Merge reverted commit diff -r c08db93d4907 -r b2b3b42944ac mcabber/INSTALL --- a/mcabber/INSTALL Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/INSTALL Sat Mar 27 16:17:11 2010 +0100 @@ -8,6 +8,9 @@ You will need the Loudmouth library, version >= 1.4.3 is recommended. +We have a Loudmouth repository on github, if you want to have the latest +features and bugfixes: + MCabber needs ncurses and ncurses development packages to build correctly. For UTF-8 terminal support, use ncursesw instead. Note: On FreeBSD (and maybe other BSD systems as well), it is recommended @@ -29,6 +32,7 @@ Please send me a message (mcabber AT lilotux DOT net) if you have questions, suggestions or even patches... +Our MUC room is there: Mikael @@ -36,16 +40,25 @@ Installation Instructions ************************* -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007, 2008, 2009 Free Software Foundation, Inc. -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. + Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. This file is offered as-is, +without warranty of any kind. Basic Installation ================== -These are generic installation instructions. + Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. Some packages provide this +`INSTALL' file but do not implement all of the features documented +below. The lack of an optional feature in a given package is not +necessarily a bug. More recommendations for GNU packages can be found +in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses @@ -58,9 +71,9 @@ It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is +the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale -cache files.) +cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail @@ -70,30 +83,37 @@ may remove or edit it. The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. -The simplest way to compile this package is: + The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. + `./configure' to configure the package for your system. - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with - the package. + the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and - documentation. + documentation. When installing into a prefix owned by root, it is + recommended that the package be configured and built as a regular + user, and only the `make install' phase executed with root + privileges. - 5. You can remove the program binaries and object files from the + 5. Optionally, type `make installcheck' to repeat any self-tests, but + this time using the binaries in their final installed location. + This target does not install anything. Running this target as a + regular user, particularly if the prior `make install' required + root privileges, verifies that the installation completed + correctly. + + 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is @@ -102,65 +122,120 @@ all sorts of other programs in order to regenerate files that came with the distribution. + 7. Often, you can also type `make uninstall' to remove the installed + files again. In practice, not all packages have tested that + uninstallation works correctly, even though it is required by the + GNU Coding Standards. + + 8. Some packages, particularly those that use Automake, provide `make + distcheck', which can by used by developers to test that all other + targets like `make install' and `make uninstall' work correctly. + This target is generally not run by end users. + Compilers and Options ===================== -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. Run `./configure --help' +for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== -You can compile the package for more than one kind of computer at the + You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the +own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. +source code in the directory that `configure' is in and in `..'. This +is known as a "VPATH" build. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. + On MacOS X 10.5 and later systems, you can create libraries and +executables that work on multiple system types--known as "fat" or +"universal" binaries--by specifying multiple `-arch' options to the +compiler but only a single `-arch' option to the preprocessor. Like +this: + + ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ + CPP="gcc -E" CXXCPP="g++ -E" + + This is not guaranteed to produce working output in all cases, you +may have to build one architecture at a time and combine the results +using the `lipo' tool if you have problems. Installation Names ================== -By default, `make install' will install the package's files in -`/usr/local/bin', `/usr/local/man', etc. You can specify an -installation prefix other than `/usr/local' by giving `configure' the -option `--prefix=PREFIX'. + By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX', where PREFIX must be an +absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you -give `configure' the option `--exec-prefix=PREFIX', the package will -use PREFIX as the prefix for installing programs and libraries. -Documentation and other data files will still use the regular prefix. +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. +you can set and what kinds of files go in them. In general, the +default for these options is expressed in terms of `${prefix}', so that +specifying just `--prefix' will affect all of the other directory +specifications that were not explicitly provided. + + The most portable way to affect installation locations is to pass the +correct locations to `configure'; however, many packages provide one or +both of the following shortcuts of passing variable assignments to the +`make install' command line to change installation locations without +having to reconfigure or recompile. + + The first method involves providing an override variable for each +affected directory. For example, `make install +prefix=/alternate/directory' will choose an alternate location for all +directory configuration variables that were expressed in terms of +`${prefix}'. Any directories that were specified during `configure', +but not in terms of `${prefix}', must each be overridden at install +time for the entire installation to be relocated. The approach of +makefile variable overrides for each directory variable is required by +the GNU Coding Standards, and ideally causes no recompilation. +However, some platforms have known limitations with the semantics of +shared libraries that end up requiring recompilation when using this +method, particularly noticeable in packages that use GNU Libtool. + + The second method involves providing the `DESTDIR' variable. For +example, `make install DESTDIR=/alternate/directory' will prepend +`/alternate/directory' before all installation names. The approach of +`DESTDIR' overrides is not required by the GNU Coding Standards, and +does not work on platforms that have drive letters. On the other hand, +it does better at avoiding recompilation issues, and works well even +when some directory options were not specified in terms of `${prefix}' +at `configure' time. + +Optional Features +================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to + Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The @@ -172,14 +247,53 @@ you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. + Some packages offer the ability to configure how verbose the +execution of `make' will be. For these packages, running `./configure +--enable-silent-rules' sets the default to minimal output, which can be +overridden with `make V=1'; while running `./configure +--disable-silent-rules' sets the default to verbose, which can be +overridden with `make V=0'. + +Particular systems +================== + + On HP-UX, the default C compiler is not ANSI C compatible. If GNU +CC is not installed, it is recommended to use the following options in +order to use an ANSI C compiler: + + ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" + +and if that doesn't work, install pre-built binaries of GCC for HP-UX. + + On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot +parse its `' header file. The option `-nodtk' can be used as +a workaround. If GNU CC is not installed, it is therefore recommended +to try + + ./configure CC="cc" + +and if that doesn't work, try + + ./configure CC="cc -nodtk" + + On Solaris, don't put `/usr/ucb' early in your `PATH'. This +directory contains several dysfunctional programs; working variants of +these programs are available in `/usr/bin'. So, if you need `/usr/ucb' +in your `PATH', put it _after_ `/usr/bin'. + + On Haiku, software installed for all users goes in `/boot/common', +not `/usr/local'. It is recommended to use the following options: + + ./configure --prefix=/boot/common + Specifying the System Type ========================== -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the + There may be some features `configure' cannot figure out +automatically, but needs to determine by the type of machine the package +will run on. Usually, assuming the package is built to be run on the +_same_ architectures, `configure' can figure that out, but if it prints +a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: @@ -187,14 +301,15 @@ where SYSTEM can have one of these forms: - OS KERNEL-OS + OS + KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should -use the `--target=TYPE' option to select the type of system they will +use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a @@ -205,9 +320,9 @@ Sharing Defaults ================ -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. @@ -216,7 +331,7 @@ Defining Variables ================== -Variables not defined in a site shell script can be set in the + Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set @@ -225,21 +340,29 @@ ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). Here is a another example: +overridden in the site shell script). - /bin/bash ./configure CONFIG_SHELL=/bin/bash +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== -`configure' recognizes the following options to control how it operates. + `configure' recognizes the following options to control how it +operates. `--help' `-h' - Print a summary of the options to `configure', and exit. + Print a summary of all of the options to `configure', and exit. + +`--help=short' +`--help=recursive' + Print a summary of the options unique to this package's + `configure', and exit. The `short' variant lists options used + only in the top level, while the `recursive' variant lists options + also present in any nested packages. `--version' `-V' @@ -266,6 +389,16 @@ Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. +`--prefix=DIR' + Use DIR as the installation prefix. *note Installation Names:: + for more details, including other options available for fine-tuning + the installation locations. + +`--no-create' +`-n' + Run the configure checks, but stop before creating any output + files. + `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. diff -r c08db93d4907 -r b2b3b42944ac mcabber/configure.ac --- a/mcabber/configure.ac Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/configure.ac Sat Mar 27 16:17:11 2010 +0100 @@ -72,7 +72,7 @@ # Check if we must provide a SIGWINCH handler AC_ARG_ENABLE(sigwinch, - [ --enable-sigwinch compile with SIGWINCH handler], + AC_HELP_STRING([--enable-sigwinch], [compile with SIGWINCH handler]), [with_sigwinch=$enableval], [with_sigwinch=$with_ext_funcs]) AC_MSG_RESULT($with_sigwinch) @@ -131,9 +131,10 @@ [Define if ncurses has ESCDELAY variable]) fi -AC_ARG_ENABLE(modules, [ --enable-modules enable dynamic modules loading], +AC_ARG_ENABLE(modules, AC_HELP_STRING([--disable-modules], + [disable dynamic modules loading]), enable_modules=$enableval) -if test "x$enable_modules" = "xyes"; then +if test "x$enable_modules" != "xno"; then AC_DEFINE(MODULES_ENABLE, 1, [Define if you want dynamic modules loading]) gmodule_module=gmodule else @@ -169,7 +170,8 @@ fi # Check for gpgme -AC_ARG_ENABLE(gpgme, AC_HELP_STRING([--disable-gpgme], [disable GPGME support]), +AC_ARG_ENABLE(gpgme, + AC_HELP_STRING([--disable-gpgme], [disable GPGME support]), [ if test x"$enableval" = x"no"; then enable_gpgme=no fi @@ -181,7 +183,9 @@ fi # Check for otr -AC_ARG_ENABLE(otr, [ --enable-otr enable OTR (Off-the-Record) messaging support], +AC_ARG_ENABLE(otr, + AC_HELP_STRING([--enable-otr], + [enable OTR (Off-the-Record) messaging support]), enable_otr=$enableval, otr="") if test "x$enable_otr" = "xyes"; then # Look for libgcrypt and libotr @@ -193,10 +197,12 @@ fi # Check for Enchant stuff -AC_ARG_ENABLE(enchant, [ --enable-enchant enable enchant support], +AC_ARG_ENABLE(enchant, + AC_HELP_STRING([--enable-enchant], [enable enchant support]), enable_enchant=$enableval, enchant="") # Check for Aspell stuff -AC_ARG_ENABLE(aspell, [ --enable-aspell enable aspell support], +AC_ARG_ENABLE(aspell, + AC_HELP_STRING([--enable-aspell], [enable aspell support]), enable_aspell=$enableval, aspell="") if test "x$enable_enchant" = "xyes"; then @@ -229,7 +235,7 @@ AC_DEFINE_DIR(PKGLIB_DIR, "${libdir}/${PACKAGE}", [Modules directory]) AC_ARG_ENABLE(debug, - [AC_HELP_STRING(--enable-debug, add development compilation options)], + AC_HELP_STRING([--enable-debug], [add development compilation options]), debug=$enableval, debug="") if test x"${debug}" = x"yes"; then AC_DEFINE_UNQUOTED([ENABLE_DEBUG],[1],[Devel compilation options]) @@ -247,7 +253,7 @@ fi AC_ARG_ENABLE(hgcset, - [AC_HELP_STRING(--disable-hgcset, do not use Mercurial changeset value)], + AC_HELP_STRING([--disable-hgcset], [do not use Mercurial changeset value]), hgcset=$enableval, hgcset="yes") AM_CONDITIONAL(HGCSET, [test x$hgcset = xyes]) if test "${hgcset}" = "yes"; then @@ -255,7 +261,7 @@ fi AM_CONDITIONAL([OTR], [test x$libotr_found = xyes]) -AM_CONDITIONAL([INSTALL_HEADERS], [test x$enable_modules = xyes]) +AM_CONDITIONAL([INSTALL_HEADERS], [test x$enable_modules != xyes]) # Prepare some config.h variables AC_DEFINE([MCABBER_BRANCH], "dev", [Mcabber branch]) @@ -267,6 +273,7 @@ AC_CONFIG_FILES([mcabber/Makefile modules/Makefile modules/beep/Makefile + modules/xttitle/Makefile doc/Makefile doc/guide/Makefile doc/help/Makefile diff -r c08db93d4907 -r b2b3b42944ac mcabber/doc/HOWTO_modules.txt --- a/mcabber/doc/HOWTO_modules.txt Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/doc/HOWTO_modules.txt Sat Mar 27 16:17:11 2010 +0100 @@ -5,13 +5,12 @@ =========================================== -To obtain information on module mcabber uses struct -module_info_t, that module should provide in public -variable with name info_. If module name -contains any extra symbols except [a-z0-9_] they should -be replaced with '_'. +To obtain information on module mcabber uses struct module_info_t, that +module should provide in public variable with name info_. +If the module name contains any extra symbols except [a-z0-9_] they +should be replaced with '_'. --------------------------------------------------------- +------------------------------------------------------------------------ #include typedef void (*module_init_t)(void); @@ -28,46 +27,42 @@ module_uninit_t uninit; module_info_t *next; }; --------------------------------------------------------- +------------------------------------------------------------------------ -Callbacks init and uninit will be called after module -and it's dependencies loading. 'requires' can contain a -NULL-terminated list of module names, that should be loaded -before this. 'branch' and 'api' are required and should -contain mcabber branch and api version, that this module is -designed to work with. For these values see ChangeLog.api. -'version' and 'description' fields are optional and just -provide user with additional information about module. -'description' field can contain newlines. 'next' field can -contain pointer to the next struct with another branch of -mcabber, if your module can work with multiple branches. +Callbacks init and uninit will be called after module and its +dependencies loading. 'requires' can contain a NULL-terminated list of +module names, that should be loaded before this. 'branch' and 'api' are +required and should contain mcabber branch and api version, that this +module is designed to work with. For these values see ChangeLog.api. +'version' and 'description' fields are optional and just provide user +with additional information about the module. 'description' field can +contain newlines. The 'next' field can contain pointer to the next +struct with another branch of mcabber, if your module can work with +multiple branches. -To load modules, mcabber uses glib's GModule, thus, in your -module you can also use functions +To load modules, mcabber uses glib's GModule, thus, in your module you +can also use functions --------------------------------------------------------- +------------------------------------------------------------------------ #include #include const gchar* g_module_check_init (GModule *module); void g_module_unload (GModule *module); --------------------------------------------------------- +------------------------------------------------------------------------ -to do something before any version/dependency checks will -be performed when module is loaded/unloaded. On success -g_module_check_init should return NULL, and error message -otherwise. +to do something before any version/dependency check is performed when +your module is loaded/unloaded. On success g_module_check_init should +return NULL, and error message otherwise. -As module is loaded, you can use mcabber functions, -declared in mcabber's header files (though you should -consider, that they may change their calling conventions -some day). +As module is loaded, you can use mcabber functions, declared in +mcabber's header files (though you should consider, that they may change +their calling conventions some day). -I will not explain them all, there are too much of -them, but will provide description for those, provided -especially for module writers. +I will not explain them all, there are too much of them, but will +provide description for those, provided especially for module writers. --------------------------------------------------------- +------------------------------------------------------------------------ #include const gchar *module_load (const gchar *name, @@ -76,173 +71,178 @@ const gchar *module_unload (const gchar *name, gboolean manual, gboolean force); --------------------------------------------------------- +------------------------------------------------------------------------ -These functions load and unload modules respectively. -You can use them to handle optional dependencies. What -happens, when module is loaded: - - check if module is present, and if present just - increase it's reference count - - load .so via glib (and call g_module_check_init, if - present) +These functions load and unload modules respectively. You can use them +to handle optional dependencies. What happens, when module is loaded: + - check if module is present, and if present just increase it's + reference count + - load .so via glib (and call g_module_check_init, if present) - check for information structure presence - - find suitable branch and check api version - compatibility - - load modules, that this module requires (note, that - dependency problems will be reported as error - invariably, force flag have no effect on this check) + - find suitable branch and check api version compatibility + - load modules, that this module requires (note, that dependency + problems will be reported as error invariably, force flag have no + effect on this check) - module placed into a list of modules - module init routine is called And when unloaded: - check if module is present - decrease reference count, if it is not zero, return - run module uninit routine - - unload modules, that were loaded as dependencies for - this + - unload modules, that were loaded as dependencies for this one - remove from modules list -They return error message or NULL in case of success. -'manual' flag indicates, that module will be loaded by -direct user request. It serves the purpose of tracking -user and automatic references (user can have only one). -'force' flag on module loading causes mcabber to ignore -most of the loading errors. On unload it forces -unloading even if reference count is not zero. +They return error message or NULL in case of success. 'manual' flag +indicates, that module will be loaded by direct user request. It serves +the purpose of tracking user and automatic references (user can have +only one). 'force' flag on module loading causes mcabber to ignore most +of the loading errors. On unload it forces unloading even if reference +count is not zero. --------------------------------------------------------- +------------------------------------------------------------------------ #include void cmd_add (const char *name, const char *help, guint flags1, guint flags2, void (*f)(char*), gpointer userdata); void cmd_del (const char *name); --------------------------------------------------------- +------------------------------------------------------------------------ -These two functions are provided to declare mcabber -commands, offered by your module. +These two functions are provided to declare mcabber commands, offered by +your module. - name is a command name. - - help is a short description of your command, however - for now it is not used at all and can be omitted. - - flags are completion identifiers for first and second - command arguments, for list of built-in completions, - see compl.h. You can declare your own completion - lists, using functions from compl.h, described later. - - f is a user-provided callback function, that will be - called upon executing mcabber command. If you will - provide non-NULL userdata, function must be of type + - help is a short description of your command, however for now it is + not used at all and can be omitted. + - flags are completion identifiers for first and second command + arguments, for list of built-in completions, see compl.h. You can + declare your own completion lists, using functions from compl.h, + described later. + - f is a user-provided callback function, that will be called upon + executing mcabber command. If you will provide non-NULL userdata, + function must be of type void (*f) (char *commandline, gpointer userdata). - - userdata is a pointer to data, transparently passed - to callback. See f description. + - userdata is a pointer to data, transparently passed to callback. + See f description. --------------------------------------------------------- +------------------------------------------------------------------------ #include guint compl_new_category (void); void compl_del_category (guint id); void compl_add_category_word (guint categ, - const char *command); + const char *command); void compl_del_category_word (guint categ, - const char *word); + const char *word); GSList *compl_get_category_list (guint cat_flags, - guint *dynlist); --------------------------------------------------------- + guint *dynlist); +------------------------------------------------------------------------ -These functions allow you to define and manage word -lists for completion categories, used by your commands. -First you need to obtain handle for completion type, -that you later will supply as flags, when declaring -your commands. For that use function compl_new_category. -It returns new category id or zero, if mcabber runs -out of completion ids (for now there are only 32 ids -available, and 20 of them are already taken by builtin -commands). compl_del_category allows you to delete -user-defined category, deleting all words in it too. +These functions allow you to define and manage word lists for completion +categories, used by your commands. First you need to obtain handle for +completion type, that you later will supply as flags, when declaring +your commands. For that use function compl_new_category. It returns +new category id, or zero if mcabber runs out of completion ids (for now +there are only 32 ids available, and 20 of them are already used for +builtin commands). compl_del_category allows you to delete user-defined +category, deleting all words in it too. -Now, that you have a completion category, you can at any -time add or delete words from it's completion list. -For that use functions compl_add_category_word and -compl_del_category_word. You can obtain current contents -of category by using gompl_get_category_list. If after -execution dynlist is TRUE, you should free obtained -list of words (both, words and list). +Now, that you have a completion category, you can at any time add or +delete words from its completion list. To do that, use the functions +compl_add_category_word and compl_del_category_word. You can obtain +current contents of category by using gompl_get_category_list. If after +execution dynlist is TRUE, you should free obtained list of words (both, +words and list). --------------------------------------------------------- +------------------------------------------------------------------------ #include - - typedef struct { - const char *name; - const char *value; - } hk_arg_t; - - typedef void (*hk_handler_t) (guint32 hookid, - hk_arg_t *args, - gpointer userdata); - - void hk_add_handler (hk_handler_t handler, - guint32 flags, - gpointer userdata); - void hk_del_handler (hk_handler_t handler, - gpointer userdata); --------------------------------------------------------- + + typedef struct { + const char *name; + const char *value; + } hk_arg_t; + + typedef guint (*hk_handler_t) (const gchar *hookname, + hk_arg_t *args, + gpointer userdata); + + guint hk_add_handler (hk_handler_t handler, + const gchar *hookname, + gint priority, + gpointer userdata); + void hk_del_handler (const gchar *hookname, + guint hid); +------------------------------------------------------------------------ + +These functions allow your module to react to events, such as incoming +and outgoing messages, buddy status changes and server connection +establishment or breakup. The hookname string specifies the events the +handler wants to subscribe to. The available strings can be found in +hooks.h. -These functions allow your module to react to events, -such as incoming and outgoing messages, buddy status -changes and sever connection establishment or breakup. -Flags field specifies mask of events, upon which this -handler should be called. Flags, that comprise this -mask can be found in hooks.h. You can specify not yet -used flags in mask, if you need to handle all events. -Handler can determine, which event is occured by -hookid argument and by a "hook" field in args, that -may provide more precise information in some cases. -Args argument is a list of hk_arg_t structures, -terminated by structure, whose name field is set to -NULL. Usually the "hook" field is in the first -structure of the list, however it is not guaranted, -that this will be so forever. +The hk_add_handler() function will return a handler id which you will +use to remove the handler with hk_del_handler(). +Args argument is a list of hk_arg_t structures, terminated by structure, +whose name field is set to NULL. + +Your handler should return one of the values in the hk_handler_result +enum (see hooks.h), usually HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS so +that other handlers can be triggers as well. + +A handler can determine which event has occured by checking the hookname +argument (a same hook handler can subscribe to several events by using +hk_add_handler() several times). -Currently there are next events possible: - - hook-message-in (HOOK_MESSAGE_IN) with parameters +Currently the following events exist: + - hook-pre-message-in (HOOK_PRE_MESSAGE_IN) with parameters * jid - sender of the incoming message - * message - message body, converted to locale - charset - * groupchat ("true" or "false") + * resource - resource of the incoming message + * message - message body, converted to locale charset + * groupchat - ("true" or "false") + - hook-post-message-in (HOOK_POST_MESSAGE_IN) with parameters + * jid - sender of the incoming message + * resource - resource of the incoming message + * message - message body, converted to locale charset + * groupchat - ("true" or "false") + * attention - In a MUC message, true if you've been highlighted + In a regular message, true if the sender has requested your + attention (only implemented for MUC currently) - hook-message-out (HOOK_MESSAGE_OUT) with parameters * jid - recipient of the outgoing message - * message - message body, converted to locale - charset + * message - message body, converted to locale charset - hook-status-change (HOOK_STATUS_CHANGE) with parameters * jid - buddy, whose status has changed * resource - resource, whose status has changed - * old_status - old status of the buddy, one-char - string, representing mcabber status letter - - one of 'ofdna?_'. - * new_status - new buddy status. The same as - old_status. - * message - new status message. Old one should be - still available to module as the current buddy's - message. + * old_status - old status of the buddy, one-char string, + representing mcabber status letter - one of 'ofdna?_'. + * new_status - new buddy status. Same as above. + * message - new status message. Old one should still be + available to module as the current buddy's message. - hook-my-status-change (HOOK_MY_STATUS_CHANGE) with parameters * new_status - user's new status, see - hook-status-change. Old one should still be + hook-status-change. Old one should still be available as the current status of the user. * message - new status message - hook-post-connect (HOOK_POST_CONNECT) with no parameters - - hook-pre-disconnect (HOOK_PRE_DICSONNECT) with no - parameters + - hook-pre-disconnect (HOOK_PRE_DISCONNECT) with no parameters + - hook-unread-list-change (HOOK_UNREAD_LIST_CHANGE) + * unread - number of buffers with the pending message flag (#) + * attention - number of non-MUC buffers with the attention sign (!) + * muc_unread - number of MUC buffers with the unread message flag + * muc_attention - number of MUC buffers with the attention sign --------------------------------------------------------- + +------------------------------------------------------------------------ #include void xmpp_add_feature (const char *xmlns); void xmpp_del_feature (const char *xmlns); --------------------------------------------------------- +------------------------------------------------------------------------ -These functions may be useful, if your module implements -some additional functionality to mcabber, that should be -advertised in a client's discovery features list. +These functions may be useful, if your module implements some additional +functionality to mcabber, that should be advertised in a client's +discovery features list. ===================== @@ -250,33 +250,32 @@ ===================== -Now, let's write a simple module, called "hello", that -will do no more than just print something on loading -and unloading. +Now, let's write a simple module, called "hello", that will do no more +than just print something on loading and unloading. --------------------------------------------------------- +------------------------------------------------------------------------ #include #include -/* We will use scr_LogPrint mcabber function, +/* We will use scr_log_print() mcabber function, that does mcabber's messages output */ #include /* Print something on module loading */ -const gchar* g_module_check_init (GModule *module) +const gchar* g_module_check_init(GModule *module) { - scr_LogPrint (LPRINT_NORMAL, "Hello, World!"); + scr_log_print(LPRINT_NORMAL, "Hello, World!"); return NULL; } /* ... and unloading */ -void g_module_unload (GModule *module) +void g_module_unload(GModule *module) { - scr_LogPrint (LPRINT_NORMAL, "Bye, World!"); + scr_log_print(LPRINT_NORMAL, "Bye, World!"); } /* The End */ --------------------------------------------------------- +------------------------------------------------------------------------ Now, compile this file (hello.c) with @@ -286,27 +285,26 @@ `pkg-config --libs glib-2.0 gmodule-2.0 mcabber` \ -o libhello.la hello.lo -(you should substitute /usr/lib/mcabber to directory, where +(you should substitute /usr/lib/mcabber to the directory where your modules are located) and then install obtained module with libtool --mode=install install libhello.la \ /usr/lib/mcabber/libhello.la -Note, that you, most likely need not run suggested by libtool -finish action, as we're working with module object, not system- -wide library, but maybe some systems require that. +Note that you most likely need not run suggested by libtool finish +action, as we're working with module object, not system- wide library, +but maybe some systems require that. Now, set modules_dir mcabber variable to point to your modules -dir, and try to run /module -f load hello. If all goes well, -you should see in status buffer message "Hello World!" (as -well as some complaints, as we forced module loading). +directory, and try to run /module -f load hello. If all goes well, +you should see in status buffer message "Hello World!" (as well as +some complaints, as we forced module loading). Now unload module by running command /module unload hello, that should bring up message "Bye, World!". -That's it, you just created very simple dynamically loadable -mcabber module. But, as you noticed, it needs force to be -loaded. Now, let's add information structure, that mcabber -wants. +That's it, you just created very simple dynamically loadable mcabber +module. But, as you noticed, it needs force to be loaded. Now, let's +add the information structure that mcabber wants. ========================== @@ -314,56 +312,54 @@ ========================== --------------------------------------------------------- +------------------------------------------------------------------------ #include /* module_info_t definition */ #include /* Print something on module loading */ -void hello_init (void) +void hello_init(void) { - scr_LogPrint (LPRINT_NORMAL, "Hello, World!"); + scr_log_print(LPRINT_NORMAL, "Hello, World!"); } /* ... and unloading */ -void hello_uninit (void) +void hello_uninit(void) { - scr_LogPrint (LPRINT_NORMAL, "Bye, World!"); + scr_log_print(LPRINT_NORMAL, "Bye, World!"); } module_info_t info_hello = { .branch = "dev", .api = 1, + .version = "0.0.1", + .description = "Hello world module\n" + " (as well as bye world module)", .requires = NULL, .init = hello_init, .uninit = hello_uninit, - .version = "0.0.1", - .description = "Hello world module\n" - "(as well as bye world module)", .next = NULL, }; /* The End */ --------------------------------------------------------- +------------------------------------------------------------------------ -Here we now do not use glib nor gmodule, so, we can omit -them in compilation lines: +Here we still do not use glib nor gmodule, so, we can omit them in +compilation lines: libtool --mode=compile gcc `pkg-config --cflags mcabber` \ -c hello.c libtool --mode=link gcc -module -rpath /usr/lib/mcabber/ \ `pkg-config --libs mcabber` -o libhello.la hello.lo -Again compile it, copy, and try to load, now without -f -flag. As you may notice, when loading previous example, -mcabber first printed "Hello, World!", and only then -complaint about module not having information struct. -That's because g_module_check_init is called right -after module loading, before mcabber even have a chance -to look at module, while .init from info struct is -called afterwards by mcabber itself. You can try to -introduce some error (eg too high or missing target -mcabber version) and see the difference. +Again compile it, copy, and try to load, now without -f flag. As you +may notice, when loading previous example, mcabber first printed "Hello, +World!", and only then complaint about module not having information +struct. That's because g_module_check_init is called right after module +loading, before mcabber even has a chance to look at module, while .init +from info struct is called afterwards by mcabber itself. You can try to +introduce some error (e.g. too high or missing target mcabber version) +and see the difference. ======================= @@ -373,52 +369,51 @@ Now, let's allow our module to do some real work. --------------------------------------------------------- +------------------------------------------------------------------------ #include #include #include /* Handler for command */ -void do_hello (char *args) +void do_hello(char *args) { /* args contains command line with command * name and any spaces after it stripped */ - scr_LogPrint (LPRINT_NORMAL, "Hello, %s!", + scr_log_print(LPRINT_NORMAL, "Hello, %s!", *args != '\0' ? args : "World"); } /* Register command */ -void hello_init (void) +void hello_init(void) { - cmd_add ("hello", "", 0, 0, do_hello, NULL); + cmd_add("hello", "", 0, 0, do_hello, NULL); } /* Unregister command */ -void hello_uninit (void) +void hello_uninit(void) { - cmd_del ("hello"); + cmd_del("hello"); } module_info_t hello_info = { .branch = "dev", .api = 1, + .version = "0.0.2", + .description = "Hello world module\n" + " Provides command /hello", .requires = NULL, .init = hello_init, .uninit = hello_uninit, - .version = "0.0.2", - .description = "Hello world module\n" - "Provides command /hello", .next = NULL, } /* The End */ --------------------------------------------------------- +------------------------------------------------------------------------ -Now, compile it and try to load and run /hello with some -arguments. +Now, compile it and try to load and run /hello with some arguments. -Note, that we used one-argument version of command -handler, as we specified no userdata. +Note, that we used one-argument version of command handler, as we have +specified no userdata. ========================== @@ -426,11 +421,11 @@ ========================== -Now let's investigate how to provide custom completion to -your commands. You can as well use built-in completions, -their IDs are listed in compl.h. +Now let's investigate how to provide custom completion to your commands. +You can as well use built-in completions, their IDs are listed in +compl.h. --------------------------------------------------------- +------------------------------------------------------------------------ #include #include #include @@ -439,62 +434,61 @@ static guint hello_cid = 0; /* hello command handler */ -void do_hello (char *args) +void do_hello(char *args) { /* If argument is provided, add it to * completions list. */ if (hello_cid && *args != '\0') - compl_add_category_word (hello_cid, - args); - scr_LogPrint (LPRINT_NORMAL, "Hello, %s!", + compl_add_category_word(hello_cid, + args); + scr_log_print(LPRINT_NORMAL, "Hello, %s!", *args != '\0' ? args : "World"); } /* Initialization */ -void hello_init (void) +void hello_init(void) { /* Obtain handle for our completion * category */ - hello_cid = compl_new_category (); + hello_cid = compl_new_category(); if (hello_cid) /* Add known default word to * completion list */ - compl_add_category_word (hello_cid, + compl_add_category_word(hello_cid, "World"); - cmd_add ("hello", "", hello_cid, 0, do_hello, + cmd_add("hello", "", hello_cid, 0, do_hello, NULL); } /* Deinitialization */ -void hello_uninit (void) +void hello_uninit(void) { /* Give back category handle */ if (hello_cid) - compl_del_category (hello_cid); - cmd_del ("hello"); + compl_del_category(hello_cid); + cmd_del("hello"); } module_info_t hello_info = { .branch = "dev", .api = 1, + .version = "0.0.3", + .description = "Hello world module" + " Provides command /hello with completion", .requires = NULL, .init = hello_init, .uninit = hello_uninit, - .version = "0.0.3", - .description = "Hello world module" - "Provides command /hello with completion", .next = NULL, } /* The End */ --------------------------------------------------------- +------------------------------------------------------------------------ -Now you can use completion for hello command. Note, that -this code have some serious simplifications, made for -simplicity reasons. For now, compl_add_category_word -does not checks, if word already exists in completions -list (although it is marked as TODO, so, some day it -will), so, we should check it ourselves. +Now you can use completion for hello command. Note, that this code have +some serious simplifications, made for simplicity reasons. For now, +compl_add_category_word does not checks, if word already exists in +completions list (although it is marked as TODO, so, some day it will), +so, we should check it ourselves. ===================== @@ -502,12 +496,12 @@ ===================== -Now let's implement our own beeper. Why anyone may wish -to do this? I am not satisfied with default mcabber's -builtin beeper flexibility. I wanted beeping on any -muc conference message, not just ones, directed to me. +Now let's implement our own beeper. Why may anyone wish to do this? +I am not satisfied with default mcabber's builtin beeper flexibility. +I wanted beeping on any MUC conference message, not just the ones +directed to me. --------------------------------------------------------- +------------------------------------------------------------------------ #include #include @@ -518,94 +512,98 @@ #include #include -static guint beep_cid = 0; +static guint beep_cid = 0; /* Command completion category id */ +static guint beep_hid = 0; /* Hook handler id */ /* Event handler */ -void beep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) +static guint beep_hh(const gchar *hookname, hk_arg_t *args, + gpointer userdata) { /* Check if beeping is enabled */ - if (settings_opt_get_int ("beep_enable")) - /* *BEEP*! */ - scr_Beep (); + if (settings_opt_get_int("beep_enable")) + scr_Beep(); /* *BEEP*! */ + + return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS; } /* beep command handler */ -void do_beep (char *args) +static void do_beep(char *args) { /* Check arguments, and if recognized, * set mcabber option accordingly */ - if (!strcmp (args, "enable") || - !strcmp (args, "on") || - !strcmp (args, "yes") || - !strcmp (args, "1")) - settings_set (SETTINGS_TYPE_OPTION, + if (!strcmp(args, "enable") || + !strcmp(args, "on") || + !strcmp(args, "yes") || + !strcmp(args, "1")) + settings_set(SETTINGS_TYPE_OPTION, "beep_enable", "1"); - else if (!strcmp (args, "disable") || - !strcmp (args, "off") || - !strcmp (args, "no") || - !strcmp (args, "0")) - settings_set (SETTINGS_TYPE_OPTION, + else if (!strcmp(args, "disable") || + !strcmp(args, "off") || + !strcmp(args, "no") || + !strcmp(args, "0")) + settings_set(SETTINGS_TYPE_OPTION, "beep_enable", "0"); /* Output current state, either if state is * changed and if argument is not recognized */ - if (settings_opt_get_int ("beep_enable")) - scr_LogPrint (LPRINT_NORMAL, + if (settings_opt_get_int("beep_enable")) + scr_log_print(LPRINT_NORMAL, "Beep on messages is enabled"); else - scr_LogPrint (LPRINT_NORMAL, + scr_log_print(LPRINT_NORMAL, "Beep on messages is disabled"); } /* Initialization */ -void beep_init (void) +static void beep_init (void) { /* Create completions */ - beep_cid = compl_new_category (); + beep_cid = compl_new_category(); if (beep_cid) { - compl_add_category_word (beep_cid, "enable"); - compl_add_category_word (beep_cid, "disable"); + compl_add_category_word(beep_cid, "enable"); + compl_add_category_word(beep_cid, "disable"); } /* Add command */ - cmd_add ("beep", "", beep_cid, 0, do_beep, NULL); + cmd_add("beep", "", beep_cid, 0, do_beep, NULL); /* Add handler * We are only interested in incoming message events */ - hk_add_handler (beep_hh, HOOK_MESSAGE_IN, NULL); + beep_hid = hk_add_handler(beep_hh, HOOK_POST_MESSAGE_IN, + G_PRIORITY_DEFAULT_IDLE, NULL); } /* Deinitialization */ -void beep_uninit (void) +void beep_uninit(void) { /* Unregister event handler */ - hk_del_handler (beep_hh, NULL); + hk_del_handler(HOOK_POST_MESSAGE_IN, beep_hid); /* Unregister command */ - cmd_del ("beep"); + cmd_del("beep"); /* Give back completion handle */ if (beep_cid) - compl_del_category (beep_cid); + compl_del_category(beep_cid); } module_info_t beep_info = { .branch = "dev", .api = 1, + .version = "0.0.1", + .description = "Simple beeper module\n" + " Recognizes option beep_enable\n" + " Provides command /beep", .requires = NULL, .init = beep_init, .uninit = beep_uninit, - .version = "0.0.1", - .description = "Simple beeper module\n" - "Recognizes option beep_enable\n" - "Provides command /beep", .next = NULL, } /* The End */ --------------------------------------------------------- +------------------------------------------------------------------------ If you use CMake (as do I), corresponding CMakeLists.txt snippet: --------------------------------------------------------- +------------------------------------------------------------------------ cmake_minimum_required(VERSION 2.6) project(beep C) @@ -622,7 +620,7 @@ ${beep_BINARY_DIR}) install(TARGETS beep DESTINATION lib/mcabber) --------------------------------------------------------- +------------------------------------------------------------------------ =========================== @@ -630,14 +628,12 @@ =========================== -I will not provide here a complete example of two -modules, one of which depends on other, only some -use cases. +I will not provide here a complete example of two modules, one of which +depends on other, only some use cases. -Info struct for module, that depends on two other -modules: +Info struct for module, that depends on two other modules: --------------------------------------------------------- +------------------------------------------------------------------------ #include const gchar *a_deps[] = { "b", "c", NULL }; @@ -645,19 +641,19 @@ module_info_t info_a = { .branch = "dev", .api = 1, + .version = NULL, + .description = NULL, .requires = a_deps, .init = a_init, .uninit = a_uninit, - .version = NULL, - .description = NULL, .next = NULL, }; --------------------------------------------------------- +------------------------------------------------------------------------ -If your module needs to "authenticate" mcabber version -too, this can be done in g_module_check_init: +If your module needs to "authenticate" mcabber version too, this can be +done in g_module_check_init: --------------------------------------------------------- +------------------------------------------------------------------------ #include #include @@ -679,24 +675,20 @@ g_free (ver); return error; } --------------------------------------------------------- +------------------------------------------------------------------------ -Also you can use glib check_init routine to modify -module information, that will be checked by mcabber, -eg. if you want your module to always pass mcabber -version check, you can assign branch information, -obtained from mcabber_... variables to corresponding -fields in your struct. -Or you can modify your module's dependencies, though -direct module_load() will have the same effect, and -can be used for optional dependencies, that your module -can still work without. +Also you can use glib check_init routine to modify module information, +that will be checked by mcabber, e.g. if you want your module to always +pass mcabber version check, you can assign branch information, obtained +from mcabber_... variables to corresponding fields in your struct. +Or you can modify your module's dependencies, though direct +module_load() will have the same effect, and can be used for optional +dependencies, that your module can still work without. -Note: remember, that g_module_check_init will be always -called, even if later module will not pass checks, thus: +Note: remember, that g_module_check_init will be always called, even if +later the module will not pass checks, thus: - do not use functions from other modules there; - - provide g_module_unload to undo anything, check_init - has done. + - provide g_module_unload to undo anything, check_init has done. ============== @@ -704,33 +696,29 @@ ============== -As mcabber now uses glib mainloop, you can use glib's -event sources, for example, fifo reading already uses -GIOChannels for non-blocking IO. +As mcabber now uses glib mainloop, you can use glib's event sources, for +example, fifo reading already uses GIOChannels for non-blocking IO. -You can extend xmpp part of mcabber functionality by -providing lm message handlers with high priority and -allowing unhandled by your handler messages be taken -care by mcabber's handlers on normal priority level. -This is where you may need to modify set of advertised -supported disco features. +You can extend XMPP part of mcabber functionality by providing lm +message handlers with high priority and allowing unhandled by your +handler messages be taken care by mcabber's handlers on normal priority +level. This is where you may need to modify set of advertised supported +disco features. -Many useful examples can be found in my modules, that -can be found at http://isbear.unixzone.org.ua/source. +Many useful examples can be found in my modules, that can be found at +http://isbear.unixzone.org.ua/source. -If you think, that your module needs to change -something, hardcoded in current implementation - feel -free to mail me or join mcabber's MUC room and -discuss this - for now I have only implemented things, -that I found necessary for written by me modules. +If you think, that your module needs to change something, hardcoded in +current implementation - feel free to mail me or join mcabber's MUC room +and discuss it - for now we have only implemented things, that we have +found necessary for our own modules. -Also I am not native English speaker, so, if you find -some errors or non-natural constructs in this howto, -please, inform me (I will be glad, if you also provide -a more suitable version of text in question). +Also I am not native English speaker, so, if you find some errors or +non-natural constructs in this howto, please, inform me (I will be glad, +if you also provide a more suitable version of text in question). -- Myhailo Danylenko -- mailto:isbear@ukrpost.net -- xmpp:isbear@unixzone.org.ua - -- Sat, 13 Mar 2010 12:18:17 +0200 + -- Sat, 27 Mar 2010 13:30:00 +0100 diff -r c08db93d4907 -r b2b3b42944ac mcabber/install-sh --- a/mcabber/install-sh Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/install-sh Sat Mar 27 16:17:11 2010 +0100 @@ -1,251 +1,520 @@ #!/bin/sh -# # install - install a program, script, or datafile -# This comes from X11R5 (mit/util/scripts/install.sh). + +scriptversion=2009-04-28.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. # -# Copyright 1991 by the Massachusetts Institute of Technology +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: # -# Permission to use, copy, modify, distribute, and sell this software and its -# documentation for any purpose is hereby granted without fee, provided that -# the above copyright notice appear in all copies and that both that -# copyright notice and this permission notice appear in supporting -# documentation, and that the name of M.I.T. not be used in advertising or -# publicity pertaining to distribution of the software without specific, -# written prior permission. M.I.T. makes no representations about the -# suitability of this software for any purpose. It is provided "as is" -# without express or implied warranty. +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written -# from scratch. It can only install one file at a time, a restriction -# shared with many OS's install programs. +# from scratch. +nl=' +' +IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi - -# put in absolute paths if you don't have them in your path; or use env. vars. +# Put in absolute file names if you don't have them in your path; +# or use environment vars. -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... - -d) dir_arg=true - shift - continue;; +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. - -o) chowncmd="$chownprog $2" - shift - shift - continue;; +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; +while test $# -ne 0; do + case $1 in + -c) ;; - -s) stripcmd="$stripprog" - shift - continue;; + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; + --help) echo "$usage"; exit $?;; - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift done -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac fi -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - chmodcmd="" - else - instcmd=mkdir - fi -else +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` - if [ -f $src -o -d $src ] - then - true + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true + mkdir_mode= fi -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else -pathcomp='' + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi -# If we're going to rename the final executable, determine the name now. + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && -# don't allow the sed command to completely eliminate the filename + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 -fi && + trap '' 0 + fi +done - -exit 0 +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff -r c08db93d4907 -r b2b3b42944ac mcabber/mcabber/compl.c --- a/mcabber/mcabber/compl.c Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/mcabber/compl.c Sat Mar 27 16:17:11 2010 +0100 @@ -2,6 +2,7 @@ * compl.c -- Completion system * * Copyright (C) 2005-2010 Mikael Berthe + * Copyright (C) 2009,2010 Myhailo Danylenko * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,12 +68,12 @@ // Returns 0, if no more categories can be allocated. // Note, that user should not make any assumptions about id nature, // as it is likely to change in future. -guint compl_new_category (void) +guint compl_new_category(void) { guint i = 0; while ((registered_cats >> i) & 1) i++; - if (i >= sizeof (guint)*8) + if (i >= 8 * sizeof (guint)) return 0; else { guint id = 1 << i; @@ -81,11 +82,11 @@ } } -// compl_del_category (id) +// compl_del_category(id) // Frees reserved id for category. // Note, that for now it not validates its input, so, be careful // and specify exactly what you get from compl_new_category. -void compl_del_category (guint id) +void compl_del_category(guint id) { registered_cats &= ~id; } diff -r c08db93d4907 -r b2b3b42944ac mcabber/mcabber/modules.c --- a/mcabber/mcabber/modules.c Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/mcabber/modules.c Sat Mar 27 16:17:11 2010 +0100 @@ -1,5 +1,5 @@ /* - * modules.c -- modules handling + * modules.c -- Modules handling * * Copyright (C) 2010 Myhailo Danylenko * @@ -372,17 +372,17 @@ module = lmod->data; info = module->info; - scr_LogPrint(LPRINT_NORMAL, "Name: %s", module->name); - scr_LogPrint(LPRINT_NORMAL, "Location: %s", g_module_name(module->module)); - scr_LogPrint(LPRINT_NORMAL, "Loaded: %s", + scr_LogPrint(LPRINT_NORMAL, "Module %s", module->name); + scr_LogPrint(LPRINT_NORMAL, " Location: %s", g_module_name(module->module)); + scr_LogPrint(LPRINT_NORMAL, " Loaded: %s", module->locked ? "Manually" : "Automatically"); - scr_LogPrint(LPRINT_NORMAL, "Reference count: %u", module->refcount); + scr_LogPrint(LPRINT_NORMAL, " Reference count: %u", module->refcount); if (info) { if (info->version) - scr_LogPrint(LPRINT_NORMAL, "Version: %s", info->version); - scr_LogPrint(LPRINT_NORMAL, "API: %s:%u", info->branch, info->api); + scr_LogPrint(LPRINT_NORMAL, " Version: %s", info->version); + scr_LogPrint(LPRINT_NORMAL, " API: %s:%u", info->branch, info->api); if (info->requires && *(info->requires)) { GString *message = g_string_new("Depends on: "); @@ -394,12 +394,12 @@ // Chop last ", " g_string_truncate(message, message->len - 2); - scr_LogPrint(LPRINT_NORMAL, "%s", message->str); + scr_LogPrint(LPRINT_NORMAL, " %s", message->str); g_string_free(message, TRUE); } if (info->description) - scr_LogPrint(LPRINT_NORMAL, "Description: %s", info->description); + scr_LogPrint(LPRINT_NORMAL, " Description: %s", info->description); } scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); scr_setattentionflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE, diff -r c08db93d4907 -r b2b3b42944ac mcabber/modules/Makefile.am --- a/mcabber/modules/Makefile.am Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/modules/Makefile.am Sat Mar 27 16:17:11 2010 +0100 @@ -1,1 +1,1 @@ -SUBDIRS = beep +SUBDIRS = beep xttitle diff -r c08db93d4907 -r b2b3b42944ac mcabber/modules/beep/Makefile.am --- a/mcabber/modules/beep/Makefile.am Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/modules/beep/Makefile.am Sat Mar 27 16:17:11 2010 +0100 @@ -1,13 +1,14 @@ if INSTALL_HEADERS + pkglib_LTLIBRARIES = libbeep.la libbeep_la_SOURCES = beep.c libbeep_la_LDFLAGS = -module -avoid-version -shared LDADD = $(GLIB_LIBS) AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(LOUDMOUTH_CFLAGS) \ - $(GPGME_CFLAGS) $(LIBOTR_CFLAGS) \ - $(ENCHANT_CFLAGS) + $(GPGME_CFLAGS) $(LIBOTR_CFLAGS) \ + $(ENCHANT_CFLAGS) endif diff -r c08db93d4907 -r b2b3b42944ac mcabber/modules/beep/beep.c --- a/mcabber/modules/beep/beep.c Sat Mar 27 16:15:55 2010 +0100 +++ b/mcabber/modules/beep/beep.c Sat Mar 27 16:17:11 2010 +0100 @@ -1,20 +1,22 @@ - -/* Copyright 2009 Myhailo Danylenko - -This file is part of mcabber module writing howto examples. - -Examples are free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . */ +/* + * Module "beep" -- Beep on all incoming messages + * + * Copyright 2009 Myhailo Danylenko + * This file is part of mcabber module writing howto examples. + * + * This module is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include @@ -32,86 +34,85 @@ /* Module description */ module_info_t info_beep = { - .branch = MCABBER_BRANCH, - .requires = NULL, - .init = beep_init, - .uninit = beep_uninit, - .api = MCABBER_API_VERSION, - .version = MCABBER_VERSION, - .description = "Simple beeper module\n" - "Recognizes option beep_enable\n" - "Provides command /beep", - .next = NULL, + .branch = MCABBER_BRANCH, + .api = MCABBER_API_VERSION, + .version = MCABBER_VERSION, + .description = "Simple beeper module\n" + " Recognizes option beep_enable\n" + " Provides command /beep", + .requires = NULL, + .init = beep_init, + .uninit = beep_uninit, + .next = NULL, }; -static guint beep_cid = 0; -static guint beep_hid; +static guint beep_cid = 0; /* Command completion category id */ +static guint beep_hid = 0; /* Hook handler id */ /* Event handler */ -static guint beep_hh (const gchar *hookname, hk_arg_t *args, gpointer userdata) +static guint beep_hh(const gchar *hookname, hk_arg_t *args, gpointer userdata) { - /* Check if beeping is enabled */ - if (settings_opt_get_int ("beep_enable")) - scr_beep (); /* *BEEP*! */ - return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + /* Check if beeping is enabled */ + if (settings_opt_get_int("beep_enable")) + scr_beep(); /* *BEEP*! */ + + /* We're done, let the other handlers do their job! */ + return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS; } /* beep command handler */ -static void do_beep (char *args) +static void do_beep(char *args) { - /* Check arguments, and if recognized, - * set mcabber option accordingly */ - if (!strcmp (args, "enable") || - !strcmp (args, "on") || - !strcmp (args, "yes") || - !strcmp (args, "1")) - settings_set (SETTINGS_TYPE_OPTION, - "beep_enable", "1"); - else if (!strcmp (args, "disable") || - !strcmp (args, "off") || - !strcmp (args, "no") || - !strcmp (args, "0")) - settings_set (SETTINGS_TYPE_OPTION, - "beep_enable", "0"); + /* Check arguments, and if recognized, + * set mcabber option accordingly */ + if (!strcmp(args, "enable") || + !strcmp(args, "on") || + !strcmp(args, "yes") || + !strcmp(args, "1")) + settings_set(SETTINGS_TYPE_OPTION, "beep_enable", "1"); + else if (!strcmp(args, "disable") || + !strcmp(args, "off") || + !strcmp(args, "no") || + !strcmp(args, "0")) + settings_set(SETTINGS_TYPE_OPTION, "beep_enable", "0"); - /* Output current state, either if state is - * changed and if argument is not recognized */ - if (settings_opt_get_int ("beep_enable")) - scr_LogPrint (LPRINT_NORMAL, - "Beep on messages is enabled"); - else - scr_LogPrint (LPRINT_NORMAL, - "Beep on messages is disabled"); + /* Output current state, either if state is + * changed or if argument is not recognized */ + if (settings_opt_get_int("beep_enable")) + scr_log_print(LPRINT_NORMAL, "Beep on messages is enabled"); + else + scr_log_print(LPRINT_NORMAL, "Beep on messages is disabled"); } /* Initialization */ -static void beep_init (void) +static void beep_init(void) { - /* Create completions */ - beep_cid = compl_new_category (); - if (beep_cid) { - compl_add_category_word (beep_cid, "enable"); - compl_add_category_word (beep_cid, "disable"); - } - /* Add command */ - cmd_add ("beep", "", beep_cid, 0, do_beep, NULL); - /* Add handler - * We are only interested in incoming message events - */ - beep_hid = hk_add_handler (beep_hh, HOOK_POST_MESSAGE_IN, - G_PRIORITY_DEFAULT_IDLE, NULL); + /* Create completions */ + beep_cid = compl_new_category(); + if (beep_cid) { + compl_add_category_word(beep_cid, "enable"); + compl_add_category_word(beep_cid, "disable"); + } + /* Add command */ + cmd_add("beep", "", beep_cid, 0, do_beep, NULL); + /* Add handler + * We are only interested in incoming message events + */ + beep_hid = hk_add_handler(beep_hh, HOOK_POST_MESSAGE_IN, + G_PRIORITY_DEFAULT_IDLE, NULL); } -/* Deinitialization */ -static void beep_uninit (void) +/* Uninitialization */ +static void beep_uninit(void) { - /* Unregister event handler */ - hk_del_handler (HOOK_POST_MESSAGE_IN, beep_hid); - /* Unregister command */ - cmd_del ("beep"); - /* Give back completion handle */ - if (beep_cid) - compl_del_category (beep_cid); + /* Unregister event handler */ + hk_del_handler(HOOK_POST_MESSAGE_IN, beep_hid); + /* Unregister command */ + cmd_del("beep"); + /* Give back completion handle */ + if (beep_cid) + compl_del_category(beep_cid); } /* The End */ +/* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */ diff -r c08db93d4907 -r b2b3b42944ac mcabber/modules/xttitle/Makefile.am --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcabber/modules/xttitle/Makefile.am Sat Mar 27 16:17:11 2010 +0100 @@ -0,0 +1,12 @@ + +if INSTALL_HEADERS + +pkglib_LTLIBRARIES = libxttitle.la +libxttitle_la_SOURCES = xttitle.c +libxttitle_la_LDFLAGS = -module -avoid-version -shared + +LDADD = $(GLIB_LIBS) +AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(LOUDMOUTH_CFLAGS) \ + $(GPGME_CFLAGS) $(LIBOTR_CFLAGS) $(ENCHANT_CFLAGS) + +endif diff -r c08db93d4907 -r b2b3b42944ac mcabber/modules/xttitle/xttitle.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mcabber/modules/xttitle/xttitle.c Sat Mar 27 16:17:11 2010 +0100 @@ -0,0 +1,99 @@ +/* + * Module "xttitle" -- Update X terminal title + * + * Copyright (C) 2010 Mikael Berthe + * + * This module is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +static void xttitle_init(void); +static void xttitle_uninit(void); + +/* Module description */ +module_info_t info_xttitle = { + .branch = MCABBER_BRANCH, + .api = MCABBER_API_VERSION, + .version = MCABBER_VERSION, + .description = "Show unread message count in X terminal title", + .requires = NULL, + .init = xttitle_init, + .uninit = xttitle_uninit, + .next = NULL, +}; + +// Hook handler id +static guint unread_list_hid; + +// Event handler for HOOK_UNREAD_LIST_CHANGE events +static guint unread_list_hh(const gchar *hookname, hk_arg_t *args, + gpointer userdata) +{ + guint all_unread = 0; + guint muc_unread = 0; + guint muc_attention = 0; + guint unread; // private message count + + // Note: We can add "attention" string later, but it isn't used + // yet in mcabber... + for ( ; args->name; args++) { + if (!g_strcmp0(args->name, "unread")) { + all_unread = atoi(args->value); + } else if (!g_strcmp0(args->name, "muc_unread")) { + muc_unread = atoi(args->value); + } else if (!g_strcmp0(args->name, "muc_attention")) { + muc_attention = atoi(args->value); + } + } + + // Let's not count the MUC unread buffers that don't have the attention + // flag (that is, MUC buffer that have no highlighted messages). + unread = all_unread - (muc_unread - muc_attention); + + // Update the terminal title + if (muc_unread) { + printf("\033]0;MCabber -- %d message%c (total:%d / MUC:%d)\007", + unread, (unread > 1 ? 's' : ' '), all_unread, muc_unread); + } else { + if (unread) + printf("\033]0;MCabber -- %d message%c\007", unread, + (unread > 1 ? 's' : ' ')); + else + printf("\033]0;MCabber -- No message\007"); + } + + return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS; +} + +// Initialization +static void xttitle_init(void) +{ + // Add hook handler for unread message data + unread_list_hid = hk_add_handler(unread_list_hh, HOOK_UNREAD_LIST_CHANGE, + G_PRIORITY_DEFAULT_IDLE, NULL); +} + +// Uninitialization +static void xttitle_uninit(void) +{ + // Unregister handler + hk_del_handler(HOOK_UNREAD_LIST_CHANGE, unread_list_hid); +} + +/* vim: set et cindent cinoptions=>2\:2(0 ts=2 sw=2: For Vim users... */