summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Klinikowski <kkszysiu@gmail.com>2010-07-09 17:54:24 +0200
committerKrzysztof Klinikowski <kkszysiu@gmail.com>2010-07-09 17:54:24 +0200
commitb41aff866715220c1c679b9f74621ac8b879370d (patch)
treeaa1a88625c35adf265f22c9c59efaaff528a2aa1
parent397c3d3c54d6e006d4206b330da9906f3a040836 (diff)
Fixed Contact Info fetching.
-rw-r--r--sunshine/Connection_Interface_Contact_Info.py2
-rw-r--r--sunshine/contacts_info.py20
-rw-r--r--sunshine/lqsoft/gaduapi.py11
3 files changed, 29 insertions, 4 deletions
diff --git a/sunshine/Connection_Interface_Contact_Info.py b/sunshine/Connection_Interface_Contact_Info.py
index 39d2ec7..870de99 100644
--- a/sunshine/Connection_Interface_Contact_Info.py
+++ b/sunshine/Connection_Interface_Contact_Info.py
@@ -121,4 +121,4 @@ class ConnectionInterfaceContactInfo(dbus.service.Interface):
"""
pass
- \ No newline at end of file
+
diff --git a/sunshine/contacts_info.py b/sunshine/contacts_info.py
index cd824ed..d7e0060 100644
--- a/sunshine/contacts_info.py
+++ b/sunshine/contacts_info.py
@@ -26,6 +26,8 @@ import telepathy
import telepathy.constants
import telepathy.errors
+from twisted.internet.defer import Deferred
+
from sunshine.handle import SunshineHandleFactory
from sunshine.util.decorator import async
@@ -83,10 +85,22 @@ class SunshineContactInfo(ConnectionInterfaceContactInfo):
handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
self.ggapi.getUserInfo(str(handle.name))
pass
-
- def RequestContactInfo(self, contact):
+
+ @dbus.service.method(CONNECTION_INTERFACE_CONTACT_INFO, in_signature='u', out_signature='a(sasas)',
+ async_callbacks=('reply_handler', 'error_handler'))
+ def RequestContactInfo(self, contact, reply_handler, error_handler):
logger.info('RequestContactInfo')
- pass
+ handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, contact)
+ self.ggapi.getUserInfo(str(handle.name))
+ #TODO: This need to be fixed as soon as possible.
+ #d = Deferred()
+ #d = self.ggapi.getUserInfoDeffered(str(handle.name))
+ #d.addCallbacks(reply_handler, error_handler)
+ #d.callback(result)
+ #print 'result:', result
+ #return d
+ reply_handler([])
+ return []
def SetContactInfo(self, contactinfo):
logger.info('SetContactInfo')
diff --git a/sunshine/lqsoft/gaduapi.py b/sunshine/lqsoft/gaduapi.py
index 59015bf..99ec850 100644
--- a/sunshine/lqsoft/gaduapi.py
+++ b/sunshine/lqsoft/gaduapi.py
@@ -336,6 +336,17 @@ class GG_Oauth(object):
self.requestToken()
self.__loopingcall = task.LoopingCall(self.checkTokenForUserInfo, uin)
self.__loopingcall.start(1.0)
+
+ def getUserInfoDeffered(self, uin):
+ d = Deferred()
+ if int(time.time()) <= self.expire_token and self.access_token != None:
+ d.addCallback(self.onUserInfoRecv)
+ d.addErrback(self.cbShutdown)
+ else:
+ self.requestToken()
+ self.__loopingcall = task.LoopingCall(self.checkTokenForUserInfo, uin)
+ self.__loopingcall.start(1.0)
+ return d
#if check_requirements() == True:
# gg = GG_Oauth(4634020, 'xxxxxx')