'Register user callback as stanzas handler of declared type. Callback must take
(if chained, see later) arguments: dispatcher instance (for replying), incomed
return of previous handlers.
The callback must raise xmpp.NodeProcessed just before return if it want preven
callbacks to be called with the same stanza as argument _and_, more importantly
library from returning stanza to sender with error set (to be enabled in 0.2 ve
Arguments:
"name" - name of stanza. F.e. "iq".
"handler" - user callback.
"typ" - value of stanza\'s "type" attribute. If not specified any value match
"ns" - namespace of child that stanza must contain.
"chained" - chain together output of several handlers.
"makefirst" - insert handler in the beginning of handlers list instead of
adding it to the end. Note that more common handlers (i.e. w/o "typ" and "
will be called first nevertheless.
"system" - call handler even if NodeProcessed Exception were raised already.'

def RegisterHandler(self, name, handler, typ='', ns='', xmlns=None, makefirst=0, system=0):

    if (not xmlns):
        xmlns = self._owner.defaultNamespace
    self.DEBUG(('Registering    handler    %s    for    "%s"    type->%s    ns->%s(%s)' % (handler, name, typ, ns, xmlns)), 'info')
    if ((not typ) and (not ns)):
        typ = 'default'
    if (not self.handlers.has_key(xmlns)):
        self.RegisterNamespace(xmlns, 'warn')
    if (not self.handlers[xmlns].has_key(name)):
        self.RegisterProtocol(name, Protocol, xmlns, 'warn')
    if (not self.handlers[xmlns][name].has_key((typ + ns))):
        self.handlers[xmlns][name][(typ + ns)] = []
    if makefirst:
        self.handlers[xmlns][name][(typ + ns)].insert(0, {'func': handler, 'system': system})
    else:
        self.handlers[xmlns][name][(typ + ns)].append({'func': handler, 'system': system})
