summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/google_nosave
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-01-24 23:05:05 -0800
committerLance Stout <lancestout@gmail.com>2013-01-24 23:05:05 -0800
commita1b33da9ca7eb0d93c02b842935386d9286d82be (patch)
treef603d724710c76afb434fd10607bf360634a9f5c /sleekxmpp/plugins/google_nosave
parent1741059cf629960fbbe0c135fa530a786ec9b72e (diff)
downloadslixmpp-a1b33da9ca7eb0d93c02b842935386d9286d82be.tar.gz
slixmpp-a1b33da9ca7eb0d93c02b842935386d9286d82be.tar.bz2
slixmpp-a1b33da9ca7eb0d93c02b842935386d9286d82be.tar.xz
slixmpp-a1b33da9ca7eb0d93c02b842935386d9286d82be.zip
Refactor Google GTalk extensions into a single meta plugin.
Diffstat (limited to 'sleekxmpp/plugins/google_nosave')
-rw-r--r--sleekxmpp/plugins/google_nosave/__init__.py15
-rw-r--r--sleekxmpp/plugins/google_nosave/nosave.py83
-rw-r--r--sleekxmpp/plugins/google_nosave/stanza.py59
3 files changed, 0 insertions, 157 deletions
diff --git a/sleekxmpp/plugins/google_nosave/__init__.py b/sleekxmpp/plugins/google_nosave/__init__.py
deleted file mode 100644
index eba50a35..00000000
--- a/sleekxmpp/plugins/google_nosave/__init__.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-from sleekxmpp.plugins.base import register_plugin
-
-from sleekxmpp.plugins.google_nosave import stanza
-from sleekxmpp.plugins.google_nosave.nosave import GoogleNoSave
-
-
-register_plugin(GoogleNoSave)
diff --git a/sleekxmpp/plugins/google_nosave/nosave.py b/sleekxmpp/plugins/google_nosave/nosave.py
deleted file mode 100644
index 1d3b36db..00000000
--- a/sleekxmpp/plugins/google_nosave/nosave.py
+++ /dev/null
@@ -1,83 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-import logging
-
-from sleekxmpp.stanza import Iq, Message
-from sleekxmpp.xmlstream.handler import Callback
-from sleekxmpp.xmlstream.matcher import StanzaPath
-from sleekxmpp.xmlstream import register_stanza_plugin
-from sleekxmpp.plugins import BasePlugin
-from sleekxmpp.plugins.google_nosave import stanza
-
-
-log = logging.getLogger(__name__)
-
-
-class GoogleNoSave(BasePlugin):
-
- """
- Google: Off the Record Chats
-
- NOTE: This is NOT an encryption method.
-
- Also see <https://developers.google.com/talk/jep_extensions/otr>.
- """
-
- name = 'google_nosave'
- description = 'Google: Off the Record Chats'
- dependencies = set(['google_settings'])
- stanza = stanza
-
- def plugin_init(self):
- register_stanza_plugin(Message, stanza.NoSave)
- register_stanza_plugin(Iq, stanza.NoSaveQuery)
-
- self.xmpp.register_handler(
- Callback('Google Nosave',
- StanzaPath('iq@type=set/google_nosave'),
- self._handle_nosave_change))
-
- def plugin_end(self):
- self.xmpp.remove_handler('Google Nosave')
-
- def enable(self, jid=None, block=True, timeout=None, callback=None):
- if jid is None:
- self.xmpp['google_settings'].update({'archiving_enabled': False},
- block=block, timeout=timeout, callback=callback)
- else:
- iq = self.xmpp.Iq()
- iq['type'] = 'set'
- iq['google_nosave']['item']['jid'] = jid
- iq['google_nosave']['item']['value'] = True
- return iq.send(block=block, timeout=timeout, callback=callback)
-
- def disable(self, jid=None, block=True, timeout=None, callback=None):
- if jid is None:
- self.xmpp['google_settings'].update({'archiving_enabled': True},
- block=block, timeout=timeout, callback=callback)
- else:
- iq = self.xmpp.Iq()
- iq['type'] = 'set'
- iq['google_nosave']['item']['jid'] = jid
- iq['google_nosave']['item']['value'] = False
- return iq.send(block=block, timeout=timeout, callback=callback)
-
- def get(self, block=True, timeout=None, callback=None):
- iq = self.xmpp.Iq()
- iq['type'] = 'get'
- iq.enable('google_nosave')
- return iq.send(block=block, timeout=timeout, callback=callback)
-
- def _handle_nosave_change(self, iq):
- reply = self.xmpp.Iq()
- reply['type'] = 'result'
- reply['id'] = iq['id']
- reply['to'] = iq['from']
- reply.send()
- self.xmpp.event('google_nosave_change', iq)
diff --git a/sleekxmpp/plugins/google_nosave/stanza.py b/sleekxmpp/plugins/google_nosave/stanza.py
deleted file mode 100644
index d8701322..00000000
--- a/sleekxmpp/plugins/google_nosave/stanza.py
+++ /dev/null
@@ -1,59 +0,0 @@
-"""
- SleekXMPP: The Sleek XMPP Library
- Copyright (C) 2013 Nathanael C. Fritz, Lance J.T. Stout
- This file is part of SleekXMPP.
-
- See the file LICENSE for copying permission.
-"""
-
-from sleekxmpp.jid import JID
-from sleekxmpp.xmlstream import ElementBase, register_stanza_plugin
-
-
-class NoSave(ElementBase):
- name = 'x'
- namespace = 'google:nosave'
- plugin_attrib = 'google_nosave'
- interfaces = set(['value'])
-
- def get_value(self):
- return self._get_attr('value', '') == 'enabled'
-
- def set_value(self, value):
- self._set_attr('value', 'enabled' if value else 'disabled')
-
-
-class NoSaveQuery(ElementBase):
- name = 'query'
- namespace = 'google:nosave'
- plugin_attrib = 'google_nosave'
- interfaces = set()
-
-
-class Item(ElementBase):
- name = 'item'
- namespace = 'google:nosave'
- plugin_attrib = 'item'
- plugin_multi_attrib = 'items'
- interfaces = set(['jid', 'source', 'value'])
-
- def get_value(self):
- return self._get_attr('value', '') == 'enabled'
-
- def set_value(self, value):
- self._set_attr('value', 'enabled' if value else 'disabled')
-
- def get_jid(self):
- return JID(self._get_attr('jid', ''))
-
- def set_jid(self, value):
- self._set_attr('jid', str(value))
-
- def get_source(self):
- return JID(self._get_attr('source', ''))
-
- def set_source(self):
- self._set_attr('source', str(value))
-
-
-register_stanza_plugin(NoSaveQuery, Item)