Merge branch 'master' of git+ssh://crank.laptop.org/git/sugar
Conflicts: sugar/presence/Buddy.py
This commit is contained in:
+33
-21
@@ -6,6 +6,7 @@ import dbus
|
||||
import cgi
|
||||
import xml.sax.saxutils
|
||||
import gobject
|
||||
import socket
|
||||
|
||||
from google import google
|
||||
from sugar.presence.PresenceService import PresenceService
|
||||
@@ -18,14 +19,15 @@ _COLUMN_SUBTITLE = 2
|
||||
_COLUMN_SERVICE = 3
|
||||
|
||||
class SearchHelper(object):
|
||||
def __init__(self, activity_uid):
|
||||
self.search_uid = activity_uid
|
||||
def __init__(self, activity_id):
|
||||
self.search_id = activity_id
|
||||
self.found = False
|
||||
|
||||
class SearchModel(gtk.ListStore):
|
||||
def __init__(self, activities_model, search_text):
|
||||
gtk.ListStore.__init__(self, gobject.TYPE_STRING, gobject.TYPE_STRING,
|
||||
gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
|
||||
success = False
|
||||
|
||||
for row in activities_model:
|
||||
title = row[_COLUMN_TITLE]
|
||||
@@ -34,21 +36,31 @@ class SearchModel(gtk.ListStore):
|
||||
self.append([ title, address, row[_COLUMN_SUBTITLE], row[_COLUMN_SERVICE] ])
|
||||
|
||||
google.LICENSE_KEY = '1As9KaJQFHIJ1L0W5EZPl6vBOFvh/Vaf'
|
||||
data = google.doGoogleSearch(search_text)
|
||||
|
||||
for result in data.results:
|
||||
title = result.title
|
||||
|
||||
# FIXME what tags should we actually strip?
|
||||
title = title.replace('<b>', '')
|
||||
title = title.replace('</b>', '')
|
||||
try:
|
||||
data = google.doGoogleSearch(search_text)
|
||||
success = True
|
||||
except socket.gaierror, exc:
|
||||
if exc[0] == -3: # Temporary failure in name resolution
|
||||
errdlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO,
|
||||
gtk.BUTTONS_OK, "There appears to be no network connection.")
|
||||
errdlg.connect("response", lambda d, e: d.destroy())
|
||||
errdlg.connect("close", lambda d, e: d.destroy())
|
||||
errdlg.show()
|
||||
|
||||
# FIXME I'm sure there is a better way to
|
||||
# unescape these.
|
||||
title = title.replace('"', '"')
|
||||
title = title.replace('&', '&')
|
||||
|
||||
self.append([ title, result.URL, None, None ])
|
||||
if success == True:
|
||||
for result in data.results:
|
||||
title = result.title
|
||||
|
||||
# FIXME what tags should we actually strip?
|
||||
title = title.replace('<b>', '')
|
||||
title = title.replace('</b>', '')
|
||||
|
||||
# FIXME I'm sure there is a better way to
|
||||
# unescape these.
|
||||
title = title.replace('"', '"')
|
||||
title = title.replace('&', '&')
|
||||
|
||||
self.append([ title, result.URL, None, None ])
|
||||
|
||||
class ActivitiesModel(gtk.ListStore):
|
||||
def __init__(self):
|
||||
@@ -62,18 +74,18 @@ class ActivitiesModel(gtk.ListStore):
|
||||
(service, ) = model.get(it, _COLUMN_SERVICE)
|
||||
if not service:
|
||||
return False
|
||||
if service.get_activity_uid() == helper.search_uid:
|
||||
if service.get_activity_id() == helper.search_id:
|
||||
helper.found = True
|
||||
return True
|
||||
return False
|
||||
|
||||
def add_activity(self, buddy, service):
|
||||
# Web Activity check
|
||||
activity_uid = service.get_activity_uid()
|
||||
if activity_uid is None:
|
||||
activity_id = service.get_activity_id()
|
||||
if activity_id is None:
|
||||
return
|
||||
# Don't show dupes
|
||||
helper = SearchHelper(activity_uid)
|
||||
helper = SearchHelper(activity_id)
|
||||
self.foreach(self._filter_dupe_activities, helper)
|
||||
if helper.found == True:
|
||||
return
|
||||
@@ -265,7 +277,7 @@ class StartPage(gtk.HBox):
|
||||
self._activities.set_owner(None)
|
||||
|
||||
def _on_activity_announced_cb(self, pservice, service, buddy):
|
||||
print "Found new activity with type %s" % service.get_full_type()
|
||||
print "Found new activity service (activity %s of type %s)" % (service.get_activity_id(), service.get_type())
|
||||
self._activities_model.add_activity(buddy, service)
|
||||
if self._activities.get_model() != self._activities_model:
|
||||
self._search(self._last_search)
|
||||
|
||||
+3
-3
@@ -83,10 +83,10 @@ class ActivityHost(dbus.service.Object):
|
||||
notebook.set_current_page(index)
|
||||
|
||||
def _create_chat(self):
|
||||
self._group_chat = ActivityChat(self)
|
||||
self._activity_chat = ActivityChat(self)
|
||||
|
||||
def get_chat(self):
|
||||
return self._group_chat
|
||||
return self._activity_chat
|
||||
|
||||
def get_default_type(self):
|
||||
return self._default_type
|
||||
@@ -98,7 +98,7 @@ class ActivityHost(dbus.service.Object):
|
||||
pass
|
||||
|
||||
def publish(self):
|
||||
self._group_chat.publish()
|
||||
self._activity_chat.publish()
|
||||
self.peer_service.publish()
|
||||
|
||||
def tab_close_button_clicked(self, button):
|
||||
|
||||
Reference in New Issue
Block a user