| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ License |
|---|
| 4 |
##~ |
|---|
| 5 |
##- The RuneBlade Foundation library is intended to ease some |
|---|
| 6 |
##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.) |
|---|
| 7 |
##- applications, while providing the flexibility to modularly change the |
|---|
| 8 |
##- architecture. Enjoy. |
|---|
| 9 |
##~ |
|---|
| 10 |
##~ Copyright (C) 2002 TechGame Networks, LLC. |
|---|
| 11 |
##~ |
|---|
| 12 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 13 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 14 |
##~ LICENSE file included with this distribution. |
|---|
| 15 |
##~ |
|---|
| 16 |
##~ TechGame Networks, LLC can be reached at: |
|---|
| 17 |
##~ 3578 E. Hartsel Drive #211 |
|---|
| 18 |
##~ Colorado Springs, Colorado, USA, 80920 |
|---|
| 19 |
##~ |
|---|
| 20 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 23 |
#~ Imports |
|---|
| 24 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 25 |
|
|---|
| 26 |
from JabberSubject import FromJIDSubjectMixin, JabberSubjectBase |
|---|
| 27 |
|
|---|
| 28 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 29 |
#~ Definitions |
|---|
| 30 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 31 |
|
|---|
| 32 |
class MessageRouterByFrom(FromJIDSubjectMixin): |
|---|
| 33 |
def __init__(self, JC): |
|---|
| 34 |
JC.stream.AddObserver('message', self) |
|---|
| 35 |
|
|---|
| 36 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 37 |
|
|---|
| 38 |
class MessageRouterByType(JabberSubjectBase): |
|---|
| 39 |
def __init__(self, JC): |
|---|
| 40 |
JC.stream.AddObserver('message', self) |
|---|
| 41 |
|
|---|
| 42 |
def _ProxyObserverList(self, category): |
|---|
| 43 |
result = [] |
|---|
| 44 |
result.extend(self._ObserverList(category[1].type)) |
|---|
| 45 |
result.extend(super(MessageRouterByType, self)._ProxyObserverList(category)) |
|---|
| 46 |
return result |
|---|
| 47 |
|
|---|
| 48 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 49 |
|
|---|
| 50 |
class MessageRouterByID(JabberSubjectBase): |
|---|
| 51 |
def __init__(self, JC): |
|---|
| 52 |
JC.stream.AddObserver('message', self) |
|---|
| 53 |
|
|---|
| 54 |
def _ProxyObserverList(self, category): |
|---|
| 55 |
result = [] |
|---|
| 56 |
result.extend(self._ObserverList(category[1].id)) |
|---|
| 57 |
result.extend(super(MessageRouterByType, self)._ProxyObserverList(category)) |
|---|
| 58 |
return result |
|---|
| 59 |
|
|---|
| 60 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 61 |
|
|---|
| 62 |
class MessageRouter(MessageRouterByFrom, MessageRouterByType, MessageRouterByID): |
|---|
| 63 |
pass |
|---|
| 64 |
|
|---|
| 65 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 66 |
|
|---|
| 67 |
class MessageRouterByThread(JabberSubjectBase): |
|---|
| 68 |
def __init__(self, JC): |
|---|
| 69 |
JC.stream.AddObserver('message', self) |
|---|
| 70 |
|
|---|
| 71 |
def _ProxyObserverList(self, category): |
|---|
| 72 |
result = [] |
|---|
| 73 |
thread = ':'.join(map(str, category[1].Elements(value='thread'))) |
|---|
| 74 |
result.extend(self._ObserverList(thread)) |
|---|
| 75 |
result.extend(super(MessageRouterByThread, self)._ProxyObserverList(category)) |
|---|
| 76 |
return result |
|---|
| 77 |
|
|---|