summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins
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
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')
-rw-r--r--sleekxmpp/plugins/google/__init__.py47
-rw-r--r--sleekxmpp/plugins/google/auth/__init__.py (renamed from sleekxmpp/plugins/gmail/__init__.py)9
-rw-r--r--sleekxmpp/plugins/google/auth/auth.py (renamed from sleekxmpp/plugins/google_domain_discovery/auth.py)25
-rw-r--r--sleekxmpp/plugins/google/auth/stanza.py49
-rw-r--r--sleekxmpp/plugins/google/gmail/__init__.py10
-rw-r--r--sleekxmpp/plugins/google/gmail/notifications.py (renamed from sleekxmpp/plugins/gmail/notifications.py)2
-rw-r--r--sleekxmpp/plugins/google/gmail/stanza.py (renamed from sleekxmpp/plugins/gmail/stanza.py)0
-rw-r--r--sleekxmpp/plugins/google/nosave/__init__.py10
-rw-r--r--sleekxmpp/plugins/google/nosave/nosave.py (renamed from sleekxmpp/plugins/google_nosave/nosave.py)2
-rw-r--r--sleekxmpp/plugins/google/nosave/stanza.py (renamed from sleekxmpp/plugins/google_nosave/stanza.py)0
-rw-r--r--sleekxmpp/plugins/google/settings/__init__.py10
-rw-r--r--sleekxmpp/plugins/google/settings/settings.py (renamed from sleekxmpp/plugins/google_settings/settings.py)5
-rw-r--r--sleekxmpp/plugins/google/settings/stanza.py (renamed from sleekxmpp/plugins/google_settings/stanza.py)0
-rw-r--r--sleekxmpp/plugins/google_domain_discovery/__init__.py15
-rw-r--r--sleekxmpp/plugins/google_domain_discovery/stanza.py35
-rw-r--r--sleekxmpp/plugins/google_nosave/__init__.py15
-rw-r--r--sleekxmpp/plugins/google_settings/__init__.py15
17 files changed, 145 insertions, 104 deletions
diff --git a/sleekxmpp/plugins/google/__init__.py b/sleekxmpp/plugins/google/__init__.py
new file mode 100644
index 00000000..bd7ca123
--- /dev/null
+++ b/sleekxmpp/plugins/google/__init__.py
@@ -0,0 +1,47 @@
+"""
+ 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, BasePlugin
+
+from sleekxmpp.plugins.google.gmail import Gmail
+from sleekxmpp.plugins.google.auth import GoogleAuth
+from sleekxmpp.plugins.google.settings import GoogleSettings
+from sleekxmpp.plugins.google.nosave import GoogleNoSave
+
+
+class Google(BasePlugin):
+
+ """
+ Google: Custom GTalk Features
+
+ Also see: <https://developers.google.com/talk/jep_extensions/extensions>
+ """
+
+ name = 'google'
+ description = 'Google: Custom GTalk Features'
+ dependencies = set([
+ 'gmail',
+ 'google_settings',
+ 'google_nosave',
+ 'google_auth'
+ ])
+
+ def __getitem__(self, attr):
+ if attr in ('settings', 'nosave', 'auth'):
+ return self.xmpp['google_%s' % attr]
+ elif attr == 'gmail':
+ return self.xmpp['gmail']
+ else:
+ raise KeyError(attr)
+
+
+register_plugin(Gmail)
+register_plugin(GoogleAuth)
+register_plugin(GoogleSettings)
+register_plugin(GoogleNoSave)
+register_plugin(Google)
diff --git a/sleekxmpp/plugins/gmail/__init__.py b/sleekxmpp/plugins/google/auth/__init__.py
index a87c78bb..5a8feb0d 100644
--- a/sleekxmpp/plugins/gmail/__init__.py
+++ b/sleekxmpp/plugins/google/auth/__init__.py
@@ -6,10 +6,5 @@
See the file LICENSE for copying permission.
"""
-from sleekxmpp.plugins.base import register_plugin
-
-from sleekxmpp.plugins.gmail import stanza
-from sleekxmpp.plugins.gmail.notifications import Gmail
-
-
-register_plugin(Gmail)
+from sleekxmpp.plugins.google.auth import stanza
+from sleekxmpp.plugins.google.auth.auth import GoogleAuth
diff --git a/sleekxmpp/plugins/google_domain_discovery/auth.py b/sleekxmpp/plugins/google/auth/auth.py
index 4de35f9f..042bd404 100644
--- a/sleekxmpp/plugins/google_domain_discovery/auth.py
+++ b/sleekxmpp/plugins/google/auth/auth.py
@@ -8,32 +8,31 @@
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_domain_discovery import stanza
+from sleekxmpp.plugins.google.auth import stanza
log = logging.getLogger(__name__)
-class GoogleDomainDiscovery(BasePlugin):
+class GoogleAuth(BasePlugin):
"""
- Google: JID Domain Discovery
+ Google: Auth Extensions (JID Domain Discovery, OAuth2)
- Also see <https://developers.google.com/talk/jep_extensions/jid_domain_change
+ Also see:
+ <https://developers.google.com/talk/jep_extensions/jid_domain_change>
+ <https://developers.google.com/talk/jep_extensions/oauth>
"""
- name = 'google_domain_discovery'
- description = 'Google: JID Domain Discovery'
+ name = 'google_auth'
+ description = 'Google: Auth Extensions (JID Domain Discovery, OAuth2)'
dependencies = set(['feature_mechanisms'])
stanza = stanza
def plugin_init(self):
- self.xmpp.namespace_map[stanza.GoogleAuth.namespace] = 'ga'
+ self.xmpp.namespace_map['http://www.google.com/talk/protocol/auth'] = 'ga'
register_stanza_plugin(self.xmpp['feature_mechanisms'].stanza.Auth,
stanza.GoogleAuth)
@@ -45,5 +44,9 @@ class GoogleDomainDiscovery(BasePlugin):
def _auth(self, stanza):
if isinstance(stanza, self.xmpp['feature_mechanisms'].stanza.Auth):
- stanza['use_full_bind_result'] = True
+ stanza.stream = self.xmpp
+ stanza['google']['client_uses_full_bind_result'] = True
+ if stanza['mechanism'] == 'X-OAUTH2':
+ stanza['google']['service'] = 'oauth2'
+ print(stanza)
return stanza
diff --git a/sleekxmpp/plugins/google/auth/stanza.py b/sleekxmpp/plugins/google/auth/stanza.py
new file mode 100644
index 00000000..49c5cba7
--- /dev/null
+++ b/sleekxmpp/plugins/google/auth/stanza.py
@@ -0,0 +1,49 @@
+"""
+ 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.xmlstream import ElementBase, ET
+
+
+class GoogleAuth(ElementBase):
+ name = 'auth'
+ namespace = 'http://www.google.com/talk/protocol/auth'
+ plugin_attrib = 'google'
+ interfaces = set(['client_uses_full_bind_result', 'service'])
+
+ discovery_attr= '{%s}client-uses-full-bind-result' % namespace
+ service_attr= '{%s}service' % namespace
+
+ def setup(self, xml):
+ """Don't create XML for the plugin."""
+ self.xml = ET.Element('')
+ print('setting up google extension')
+
+ def get_client_uses_full_bind_result(self):
+ return self.parent()._get_attr(self.disovery_attr) == 'true'
+
+ def set_client_uses_full_bind_result(self, value):
+ print('>>>', value)
+ if value in (True, 'true'):
+ self.parent()._set_attr(self.discovery_attr, 'true')
+ else:
+ self.parent()._del_attr(self.discovery_attr)
+
+ def del_client_uses_full_bind_result(self):
+ self.parent()._del_attr(self.discovery_attr)
+
+ def get_service(self):
+ return self.parent()._get_attr(self.service_attr, '')
+
+ def set_service(self, value):
+ if value:
+ self.parent()._set_attr(self.service_attr, value)
+ else:
+ self.parent()._del_attr(self.service_attr)
+
+ def del_service(self):
+ self.parent()._del_attr(self.service_attr)
diff --git a/sleekxmpp/plugins/google/gmail/__init__.py b/sleekxmpp/plugins/google/gmail/__init__.py
new file mode 100644
index 00000000..a92e363b
--- /dev/null
+++ b/sleekxmpp/plugins/google/gmail/__init__.py
@@ -0,0 +1,10 @@
+"""
+ 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.google.gmail import stanza
+from sleekxmpp.plugins.google.gmail.notifications import Gmail
diff --git a/sleekxmpp/plugins/gmail/notifications.py b/sleekxmpp/plugins/google/gmail/notifications.py
index dbc68162..6a0ceed4 100644
--- a/sleekxmpp/plugins/gmail/notifications.py
+++ b/sleekxmpp/plugins/google/gmail/notifications.py
@@ -13,7 +13,7 @@ from sleekxmpp.xmlstream.handler import Callback
from sleekxmpp.xmlstream.matcher import MatchXPath
from sleekxmpp.xmlstream import register_stanza_plugin
from sleekxmpp.plugins import BasePlugin
-from sleekxmpp.plugins.gmail import stanza
+from sleekxmpp.plugins.google.gmail import stanza
log = logging.getLogger(__name__)
diff --git a/sleekxmpp/plugins/gmail/stanza.py b/sleekxmpp/plugins/google/gmail/stanza.py
index e7e308e1..e7e308e1 100644
--- a/sleekxmpp/plugins/gmail/stanza.py
+++ b/sleekxmpp/plugins/google/gmail/stanza.py
diff --git a/sleekxmpp/plugins/google/nosave/__init__.py b/sleekxmpp/plugins/google/nosave/__init__.py
new file mode 100644
index 00000000..57847af5
--- /dev/null
+++ b/sleekxmpp/plugins/google/nosave/__init__.py
@@ -0,0 +1,10 @@
+"""
+ 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.google.nosave import stanza
+from sleekxmpp.plugins.google.nosave.nosave import GoogleNoSave
diff --git a/sleekxmpp/plugins/google_nosave/nosave.py b/sleekxmpp/plugins/google/nosave/nosave.py
index 1d3b36db..d6bef615 100644
--- a/sleekxmpp/plugins/google_nosave/nosave.py
+++ b/sleekxmpp/plugins/google/nosave/nosave.py
@@ -13,7 +13,7 @@ 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
+from sleekxmpp.plugins.google.nosave import stanza
log = logging.getLogger(__name__)
diff --git a/sleekxmpp/plugins/google_nosave/stanza.py b/sleekxmpp/plugins/google/nosave/stanza.py
index d8701322..d8701322 100644
--- a/sleekxmpp/plugins/google_nosave/stanza.py
+++ b/sleekxmpp/plugins/google/nosave/stanza.py
diff --git a/sleekxmpp/plugins/google/settings/__init__.py b/sleekxmpp/plugins/google/settings/__init__.py
new file mode 100644
index 00000000..c3a0471d
--- /dev/null
+++ b/sleekxmpp/plugins/google/settings/__init__.py
@@ -0,0 +1,10 @@
+"""
+ 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.google.settings import stanza
+from sleekxmpp.plugins.google.settings.settings import GoogleSettings
diff --git a/sleekxmpp/plugins/google_settings/settings.py b/sleekxmpp/plugins/google/settings/settings.py
index 6bd209c7..7122ff56 100644
--- a/sleekxmpp/plugins/google_settings/settings.py
+++ b/sleekxmpp/plugins/google/settings/settings.py
@@ -13,10 +13,7 @@ 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_settings import stanza
-
-
-log = logging.getLogger(__name__)
+from sleekxmpp.plugins.google.settings import stanza
class GoogleSettings(BasePlugin):
diff --git a/sleekxmpp/plugins/google_settings/stanza.py b/sleekxmpp/plugins/google/settings/stanza.py
index d8161770..d8161770 100644
--- a/sleekxmpp/plugins/google_settings/stanza.py
+++ b/sleekxmpp/plugins/google/settings/stanza.py
diff --git a/sleekxmpp/plugins/google_domain_discovery/__init__.py b/sleekxmpp/plugins/google_domain_discovery/__init__.py
deleted file mode 100644
index 828d1859..00000000
--- a/sleekxmpp/plugins/google_domain_discovery/__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_domain_discovery import stanza
-from sleekxmpp.plugins.google_domain_discovery.auth import GoogleDomainDiscovery
-
-
-register_plugin(GoogleDomainDiscovery)
diff --git a/sleekxmpp/plugins/google_domain_discovery/stanza.py b/sleekxmpp/plugins/google_domain_discovery/stanza.py
deleted file mode 100644
index 8a195afd..00000000
--- a/sleekxmpp/plugins/google_domain_discovery/stanza.py
+++ /dev/null
@@ -1,35 +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.xmlstream import ElementBase, ET
-
-
-class GoogleAuth(ElementBase):
- name = 'use_full_bind_result'
- namespace = 'http://www.google.com/talk/protocol/auth'
- plugin_attrib = name
- interfaces = set([name])
- is_extension = True
-
- attribute = '{%s}client-users-full-bind-result' % namespace
-
- def setup(self, xml):
- """Don't create XML for the plugin."""
- self.xml = ET.Element('')
-
- def get_use_full_bind_result(self):
- return self.parent()._get_attr(self.attribute) == 'true'
-
- def set_use_full_bind_result(self, value):
- if value in (True, 'true'):
- self.parent()._set_attr(self.attribute, 'true')
- else:
- self.parent()._del_attr(self.attribute)
-
- def del_use_full_bind_result(self):
- self.parent()._del_attr(self.attribute)
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_settings/__init__.py b/sleekxmpp/plugins/google_settings/__init__.py
deleted file mode 100644
index ef4b2342..00000000
--- a/sleekxmpp/plugins/google_settings/__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_settings import stanza
-from sleekxmpp.plugins.google_settings.settings import GoogleSettings
-
-
-register_plugin(GoogleSettings)