summaryrefslogtreecommitdiff
path: root/sunshine
diff options
context:
space:
mode:
authorKrzysztof Klinikowski <kkszysiu@gmail.com>2010-04-07 07:22:56 +0200
committerKrzysztof Klinikowski <kkszysiu@gmail.com>2010-04-07 07:22:56 +0200
commit41bb8f6643f186e8b2f773bdcd015bd33eb01e56 (patch)
treeb404fd4e6517495ab4570fd0b8a050c95b99dec8 /sunshine
parent58fdc6e812c662175221ac2edfd6703f404ebda4 (diff)
Important update. Now account parameters should work correctly.
Diffstat (limited to 'sunshine')
-rw-r--r--sunshine/connection.py42
-rw-r--r--sunshine/connection_manager.py22
2 files changed, 42 insertions, 22 deletions
diff --git a/sunshine/connection.py b/sunshine/connection.py
index 376cf59..18d119b 100644
--- a/sunshine/connection.py
+++ b/sunshine/connection.py
@@ -207,6 +207,9 @@ class SunshineConnection(telepathy.server.Connection,
SunshineContacts
):
+ _secret_parameters = set([
+ 'password'
+ ])
_mandatory_parameters = {
'account' : 's',
'password' : 's'
@@ -214,25 +217,15 @@ class SunshineConnection(telepathy.server.Connection,
_optional_parameters = {
'server' : 's',
'port' : 'q',
- 'use-ssl' : 'b',
'export-contacts' : 'b'
}
_parameter_defaults = {
'server' : '91.197.13.67',
- 'port' : dbus.UInt16(8074),
- 'use-ssl' : dbus.Boolean(False),
- 'export-contacts' : dbus.Boolean(False)
+ 'port' : 8074,
+ 'export-contacts' : False
}
def __init__(self, manager, parameters):
- try:
- parameters['export-contacts'] = bool(parameters['export-contacts'])
- except KeyError:
- parameters['export-contacts'] = False
- try:
- parameters['use-ssl'] = bool(parameters['use-ssl'])
- except KeyError:
- parameters['use-ssl'] = False
self.check_parameters(parameters)
try:
@@ -672,6 +665,31 @@ class SunshineConnection(telepathy.server.Connection,
def onXmlAction(self, xml):
logger.info("XmlAction: %s" % xml.data)
+ #event occurs when user from our list change avatar
+ #<events>
+ # <event id="12989655759719404037">
+ # <type>28</type>
+ # <sender>4634020</sender>
+ # <time>1270577383</time>
+ # <body></body>
+ # <bodyXML>
+ # <smallAvatar>http://avatars.gadu-gadu.pl/small/4634020?ts=1270577383</smallAvatar>
+ # </bodyXML>
+ # </event>
+ #</events>
+ try:
+ tree = ET.fromstring(xml.data)
+ core = tree.find("event")
+ type = core.find("type").text
+ if type == '28':
+ sender = core.find("sender").text
+ url = core.find("bodyXML/smallAvatar").text
+ print type
+ print sender
+ print url
+ except:
+ pass
+
def onXmlEvent(self, xml):
logger.info("XmlEvent: %s" % xml,data)
diff --git a/sunshine/connection_manager.py b/sunshine/connection_manager.py
index 3a408bd..b2d99c5 100644
--- a/sunshine/connection_manager.py
+++ b/sunshine/connection_manager.py
@@ -48,25 +48,27 @@ class SunshineConnectionManager(telepathy.server.ConnectionManager):
result = []
connection_class = self._protos[proto]
+ secret_parameters = connection_class._secret_parameters
mandatory_parameters = connection_class._mandatory_parameters
optional_parameters = connection_class._optional_parameters
default_parameters = connection_class._parameter_defaults
for parameter_name, parameter_type in mandatory_parameters.iteritems():
- param = (parameter_name,
- telepathy.CONN_MGR_PARAM_FLAG_REQUIRED,
- parameter_type,
- '')
+ flags = telepathy.CONN_MGR_PARAM_FLAG_REQUIRED
+ if parameter_name in secret_parameters:
+ flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
+ param = (parameter_name, flags, parameter_type, '')
result.append(param)
for parameter_name, parameter_type in optional_parameters.iteritems():
+ flags = 0
+ default = ''
+ if parameter_name in secret_parameters:
+ flags |= telepathy.CONN_MGR_PARAM_FLAG_SECRET
if parameter_name in default_parameters:
- param = (parameter_name,
- telepathy.CONN_MGR_PARAM_FLAG_HAS_DEFAULT,
- parameter_name,
- default_parameters[parameter_name])
- else:
- param = (parameter_name, 0, parameter_name, '')
+ flags |= telepathy.CONN_MGR_PARAM_FLAG_HAS_DEFAULT
+ default = default_parameters[parameter_name]
+ param = (parameter_name, flags, parameter_type, default)
result.append(param)
return result