Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2018-12-26 14:14:14 +0300
committerPhilipp Hörist <philipp@hoerist.com>2018-12-28 00:17:16 +0300
commit122be999edf6fe7919a85f14377febeff4c2621f (patch)
treed7bb69cb69cb1bd9a99052267a84cacd407ee3c4 /nbxmpp/structs.py
parentbb712047cd0db4db9ebbbea21a10f78e98d9e5a4 (diff)
Add parsing for MUC invites
- Move structs into own module
Diffstat (limited to 'nbxmpp/structs.py')
-rw-r--r--nbxmpp/structs.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/nbxmpp/structs.py b/nbxmpp/structs.py
new file mode 100644
index 0000000..e46affa
--- /dev/null
+++ b/nbxmpp/structs.py
@@ -0,0 +1,106 @@
+# Copyright (C) 2018 Philipp Hörist <philipp AT hoerist.com>
+#
+# This file is part of nbxmpp.
+#
+# 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 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 <http://www.gnu.org/licenses/>.
+
+import time
+from collections import namedtuple
+
+from nbxmpp.const import MessageType
+
+StanzaHandler = namedtuple('StanzaHandler',
+ 'name callback typ ns xmlns system priority')
+StanzaHandler.__new__.__defaults__ = ('', '', None, False, 50)
+
+InviteData = namedtuple('InviteData',
+ 'muc from_ reason password type continued thread')
+
+DeclineData = namedtuple('DeclineData', 'muc from_ reason')
+
+
+class Properties:
+ pass
+
+
+class MessageProperties:
+ def __init__(self):
+ self.carbon_type = None
+ self.type = MessageType.NORMAL
+ self.id = None
+ self.jid = None
+ self.subject = None
+ self.body = None
+ self.thread = None
+ self.user_timestamp = None
+ self.timestamp = time.time()
+ self.error_code = None
+ self.error_message = None
+ self.eme = None
+ self.http_auth = None
+ self.nickname = None
+ self.from_muc = False
+ self.muc_nickname = None
+ self.muc_status_codes = None
+ self.muc_private_message = False
+ self.muc_invite = None
+ self.muc_decline = None
+
+ @property
+ def is_http_auth(self):
+ return self.http_auth is not None
+
+ @property
+ def is_muc_subject(self):
+ return (self.type == MessageType.GROUPCHAT and
+ self.body is None and
+ self.subject is not None)
+
+ @property
+ def is_muc_config_change(self):
+ return self.body is None and self.muc_status_codes
+
+ @property
+ def is_muc_pm(self):
+ return self.muc_private_message
+
+ @property
+ def is_muc_invite_or_decline(self):
+ return (self.muc_invite is not None or
+ self.muc_decline is not None)
+
+
+class IqProperties:
+ def __init__(self):
+ self.http_auth = None
+
+ @property
+ def is_http_auth(self):
+ return self.http_auth is not None
+
+
+class PresenceProperties:
+ def __init__(self):
+ self.type = None
+ self.priority = None
+ self.show = None
+ self.jid = None
+ self.resource = None
+ self.id = None
+ self.nickname = None
+ self.self_presence = False
+ self.from_muc = False
+ self.status = ''
+ self.error_message = ''
+ self.error_code = ''