changeset 1669:004739237999

Update modules howto
author Myhailo Danylenko <isbear@ukrpost.net>
date Mon, 18 Jan 2010 15:53:20 +0200
parents 41c26b7d2890
children efee21002ffb
files mcabber/doc/HOWTO_modules.txt
diffstat 1 files changed, 45 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/doc/HOWTO_modules.txt	Mon Jan 18 15:36:19 2010 +0200
+++ b/mcabber/doc/HOWTO_modules.txt	Mon Jan 18 15:53:20 2010 +0200
@@ -28,7 +28,7 @@
 especially for module writers.
 
 --------------------------------------------------------
-  #include "commands.h"
+  #include <mcabber/commands.h>
 
   void cmd_add (const char *name, const char *help,
                 guint flags1, guint flags2,
@@ -53,7 +53,7 @@
    to callback. See f description.
 
 --------------------------------------------------------
-  #include "compl.h"
+  #include <mcabber/compl.h>
 
   guint compl_new_category (void);
   void  compl_del_category (guint id);
@@ -86,7 +86,7 @@
 list of words (both, words and list).
 
 --------------------------------------------------------
-  #include "hooks.h"
+  #include <mcabber/hooks.h>
  
   typedef struct { 
     const char *name; 
@@ -153,7 +153,7 @@
    parameters
 
 --------------------------------------------------------
-  #include "xmpp_helper.h"
+  #include <mcabber/xmpp_helper.h>
 
   void xmpp_add_feature (const char *xmlns);
   void xmpp_del_feature (const char *xmlns);
@@ -179,19 +179,19 @@
 
 /* We will use scr_LogPrint mcabber function,
    that does mcabber's messages output */
-#include "logprint.h"
+#include <mcabber/logprint.h>
 
 /* Print something on module loading */
 const gchar* g_module_check_init (GModule *module)
 {
-	scr_LogPrint (LPRINT_LOGNORM, "Hello, World!");
+	scr_LogPrint (LPRINT_NORMAL, "Hello, World!");
 	return NULL;
 }
 
 /* ... and unloading */
 void g_module_unload (GModule *module)
 {
-	scr_LogPrint (LPRINT_LOGNORM, "Bye, World!");
+	scr_LogPrint (LPRINT_NORMAL, "Bye, World!");
 }
 
 /* The End */
@@ -236,15 +236,15 @@
 #include <glib.h>
 #include <gmodule.h>
 
-#include "logprint.h"
-#include "commands.h"
+#include <mcabber/logprint.h>
+#include <mcabber/commands.h>
 
 /* Handler for command */
 void do_hello (char *args)
 {
 	/* args contains command line with command
          * name and any spaces after it stripped */
-	scr_LogPrint (LPRINT_LOGNORM, "Hello, %s!", 
+	scr_LogPrint (LPRINT_NORMAL, "Hello, %s!", 
                       *args != '\0' ? args : "World");
 }
 
@@ -264,19 +264,6 @@
 /* The End */
 --------------------------------------------------------
 
-There we will need also config.h with defined MODULES_ENABLE
-to satisfy ifdefs in commands.h. You can get one from mcabber
-build tree, generated by configure or just provide your own:
-
---------------------------------------------------------
-#ifndef LOCAL_CONFIG_H
-#define LOCAL_CONFIG_H
-
-#define MODULES_ENABLE 1
-
-#endif
---------------------------------------------------------
-
 Now, compile it and try to load and run /hello with some
 arguments.
 
@@ -289,7 +276,7 @@
 
 ==========================
 
-Now le's investigate how to provide custom completion to
+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.
 
@@ -297,9 +284,9 @@
 #include <glib.h>
 #include <gmodule.h>
 
-#include "logprint.h"
-#include "commands.h"
-#include "compl.h"
+#include <mcabber/logprint.h>
+#include <mcabber/commands.h>
+#include <mcabber/compl.h>
 
 static guint hello_cid = 0;
 
@@ -311,7 +298,7 @@
 	if (hello_cid && *args != '\0')
 		compl_add_category_word (hello_cid,
 		                         args);
-	scr_LogPrint (LPRINT_LOGNORM, "Hello, %s!",
+	scr_LogPrint (LPRINT_NORMAL, "Hello, %s!",
 	              *args != '\0' ? args : "World");
 }
 
@@ -348,10 +335,7 @@
 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. Also, we should
-check, that args contains only one word, or this will
-confuse completion system, so, it will stop on this
-completion.
+will), so, we should check it ourselves.
 
 =====================
 
@@ -369,12 +353,12 @@
 #include <gmodule.h>
 #include <string.h>
 
-#include "logprint.h"
-#include "commands.h"
-#include "compl.h"
-#include "hooks.h"
-#include "screen.h"
-#include "settings.h"
+#include <mcabber/logprint.h>
+#include <mcabber/commands.h>
+#include <mcabber/compl.h>
+#include <mcabber/hooks.h>
+#include <mcabber/screen.h>
+#include <mcabber/settings.h>
 
 static guint beep_cid = 0;
 
@@ -449,16 +433,13 @@
 --------------------------------------------------------
 
 Note, that to compile this we also need to add loudmouth-1.0
-to pkg-config command line and to add -I. to compilation
-mode gcc command line (specify include directory with our
-config.h as system include directory), so, you will have
-something like
+to pkg-config command line, so, you will have something like
 
 libtool --mode=compile gcc `pkg-config --cflags glib-2.0 \
-  gmodule-2.0 loudmouth-1.0` -I. -c beep.c
+  gmodule-2.0 loudmouth-1.0` -c beep.c
 libtool --mode=link gcc -module -rpath /usr/lib/mcabber/ \
-  `pkg-config --cflags glib-2.0 gmodule-2.0 loudmouth-1.0` \
-  -o libbeep.la beep.lo
+  `pkg-config --cflags glib-2.0 gmodule-2.0` -o libbeep.la \
+  beep.lo
 libtool --mode=install install libbeep.la \
   /usr/lib/mcabber/libbeep.la
 
@@ -469,24 +450,27 @@
 cmake_minimum_required(VERSION 2.6)
 project(beep C)
 
-add_library(beep MODULE beep.c)
-
-set(MCABBER_INCLUDE_DIR "${beep_SOURCE_DIR}/include"
-    CACHE FILEPATH "Path to mcabber headers")
+set(MCABBER_INCLUDE_DIR "/usr/include" CACHE FILEPATH
+    "Path to mcabber headers")
 
 find_package(PkgConfig REQUIRED)
 pkg_check_modules(GLIB REQUIRED glib-2.0)
 pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
 pkg_check_modules(LM REQUIRED loudmouth-1.0)
+# this one should be before any target definitions
+link_directories(${GLIB_LIBRARY_DIRS}
+                 ${GMODULE_LIBRARY_DIRS})
+
+add_library(beep MODULE beep.c)
 
 include_directories(SYSTEM ${GLIB_INCLUDE_DIRS}
                     ${GMODULE_INCLUDE_DIRS}
-                    ${LM_INCLUDE_DIRS})
+                    ${LM_INCLUDE_DIRS}
+                    ${MCABBER_INCLUDE_DIR})
 target_link_libraries(beep ${GLIB_LIBRARIES}
                       ${GMODULE_LIBRARIES})
 include_directories(${beep_SOURCE_DIR}
-                    ${beep_BINARY_DIR}
-                    ${MCABBER_INCLUDE_DIR})
+                    ${beep_BINARY_DIR})
 
 install(TARGETS beep DESTINATION lib/mcabber)
 --------------------------------------------------------
@@ -498,8 +482,8 @@
 ==============
 
 As mcabber now uses glib mainloop, you can use glib's
-event sources, for example, fifo reading can be easily
-modularized with GIOChannels.
+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
@@ -508,20 +492,22 @@
 This is where you may need to modify set of advertised
 supported disco features.
 
-Many useful examples can be found in my mcabber-lua
-module.
+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 mcabber-lua module.
+that I found necessary for written by me 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).
 
-  -- Myhailo Danylenko <isbear@ukrpost.net>
-  -- Mon, 05 Oct 2009 00:00:00 +0300
+  -- Myhailo Danylenko
+  -- mailto:isbear@ukrpost.net
+  -- xmpp:isbear@unixzone.org.ua
+  -- Mon, 18 Jan 2010 15:52:40 +0200