r7209 - in bigboard/trunk: . applet atom bigboard bigboard/stocks/apps bigboard/stocks/files bigboard/stocks/google_calendar bigboard/stocks/mail bigboard/stocks/mugshot_photos bigboard/stocks/people bigboard/stocks/self bigboard/stocks/workspaces bigboard/themes data gdata gdata/calendar gdata/docs
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7209 - in bigboard/trunk: . applet atom bigboard bigboard/stocks/apps bigboard/stocks/files bigboard/stocks/google_calendar bigboard/stocks/mail bigboard/stocks/mugshot_photos bigboard/stocks/people bigboard/stocks/self bigboard/stocks/workspaces bigboard/themes data gdata gdata/calendar gdata/docs
- Date: Tue, 15 Jan 2008 13:55:03 -0600 (CST)
Author: otaylor
Date: 2008-01-15 13:55:02 -0600 (Tue, 15 Jan 2008)
New Revision: 7209
Removed:
bigboard/trunk/bigboard/presence.py
bigboard/trunk/bigboard/profile.py
Modified:
bigboard/trunk/
bigboard/trunk/applet/
bigboard/trunk/atom/
bigboard/trunk/bigboard/global_mugshot.py
bigboard/trunk/bigboard/people_tracker.py
bigboard/trunk/bigboard/stock.py
bigboard/trunk/bigboard/stocks/apps/AppsStock.py
bigboard/trunk/bigboard/stocks/apps/apps.py
bigboard/trunk/bigboard/stocks/files/
bigboard/trunk/bigboard/stocks/files/FilesStock.py
bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py
bigboard/trunk/bigboard/stocks/mail/
bigboard/trunk/bigboard/stocks/mugshot_photos/PhotosStock.py
bigboard/trunk/bigboard/stocks/people/PeopleStock.py
bigboard/trunk/bigboard/stocks/self/SelfStock.py
bigboard/trunk/bigboard/stocks/workspaces/
bigboard/trunk/bigboard/themes/
bigboard/trunk/data/
bigboard/trunk/gdata/
bigboard/trunk/gdata/calendar/
bigboard/trunk/gdata/docs/
bigboard/trunk/main.py
Log:
PhotoStock.py: Rewrite to use data model
stock.py PeopleStock SelfStock AppsStock CalendarStock: Modify
AbstractMugshotStock to use the data model and have _model/on_ready()
by default.
profile.py presence.py global_mugshot.py: Remove usage of old hand-rolled
D-BUS interfaces.
Property changes on: bigboard/trunk
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
configure
config.*
depcomp
libtool
ltmain.sh
missing
py-compile
install-sh
autom4te.cache
aclocal.m4
intltool-*
version
bigboard.schemas
mkinstalldirs
bigboard*.tar.gz
+ Makefile
Makefile.in
compile
configure
config.*
depcomp
libtool
ltmain.sh
missing
py-compile
install-sh
autom4te.cache
aclocal.m4
intltool-*
stamp-h1
version
bigboard.schemas
mkinstalldirs
bigboard*.tar.gz
Property changes on: bigboard/trunk/applet
___________________________________________________________________
Name: svn:ignore
- BigBoard_Applet.server
BigBoard_Applet.server.in
Makefile
Makefile.in
+ GNOME_OnlineDesktop_BigBoardFactory.server
GNOME_OnlineDesktop_BigBoardFactory.server.in
BigBoard_Applet.server
BigBoard_Applet.server.in
Makefile
Makefile.in
bigboard-applets
.libs
.deps
Property changes on: bigboard/trunk/atom
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Modified: bigboard/trunk/bigboard/global_mugshot.py
===================================================================
--- bigboard/trunk/bigboard/global_mugshot.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/global_mugshot.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -13,56 +13,9 @@
_logger = logging.getLogger("bigboard.Mugshot")
-class ExternalAccount(AutoSignallingStruct):
- pass
-
-class ExternalAccountThumbnail(AutoStruct):
- pass
-
-class Entity(AutoSignallingStruct):
- """Abstract superclass of a Mugshot entity such as person, group, or feed; see
- subclasses."""
- pass
-
-class Person(Entity):
- def __init__(self, *args, **kwargs):
- super(Person, self).__init__(*args, **kwargs)
- self.__requesting_accts = False
- self.__external_accounts = None
-
- def get_external_accounts(self):
- # FIXME - server needs to notify us
- if self.__external_accounts is not None:
- return self.__external_accounts
- elif not self.__requesting_accts:
- self.__requesting_accts = True
- mugshot = get_mugshot()
- mugshot.get_person_accounts(self)
-
- def set_external_accounts(self, accts):
- self.__requesting_accts = False
- self.__external_accounts = accts
- self.emit("changed")
-
-class Group(Entity):
- pass
-
-class Resource(Entity):
- pass
-
-class Feed(Entity):
- pass
-
class Mugshot(gobject.GObject):
- """A combination of a wrapper and cache for the Mugshot D-BUS API. Access
- using the get_mugshot() module method."""
- __gsignals__ = {
- "initialized" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
- "connection-status": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT)),
- "self-known" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
- "network-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
- "pref-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT))
- }
+ """This class is a wrapper for the non-data-model D-BUS API's we use from the data model
+ engine. Access using the get_mugshot() module method."""
def __init__(self, issingleton):
gobject.GObject.__init__(self)
@@ -79,46 +32,20 @@
self.__on_dbus_name_owner_changed)
self.__create_proxy()
self.__create_ws_proxy()
- self.__create_im_proxy()
self.__reset()
- self.__iqcachedir = os.path.expanduser("~/.bigboard/iqcache")
- try:
- os.makedirs(self.__iqcachedir)
- except OSError, e:
- pass
-
def __reset(self):
self._logger.debug("reset")
# Generic properties
- self.__baseprops = None
- self.__connection_status = (None, None, None)
- self.__self_proxy = None
- self.__self = None
- self.__self_path = None
- self.__prefs = {}
- self.__network = None
- self.__entities = {} # <str>,<Entity>
-
self.__endpoint_id = None
- self.__external_iqs = {} # <int>,<function>
-
- def get_im_proxy(self):
- return self.__im_proxy
-
def __create_proxy(self):
try:
bus = dbus.SessionBus()
self._logger.debug("creating proxy for %s" % globals.bus_name)
self.__proxy = bus.get_object(globals.bus_name, '/org/mugshot/Mugshot')
- self.__proxy.connect_to_signal('ConnectionStatusChanged', self.__on_connection_status_changed)
- self.__proxy.connect_to_signal('PrefChanged', self.__on_pref_changed)
- self.__proxy.connect_to_signal('ExternalIQReturn', self.__externalIQReturn)
- self.__get_connection_status()
- self.__proxy.GetBaseProperties(reply_handler=self.__on_get_baseprops, error_handler=self.__on_dbus_error)
self.__mugshot_dbus_proxy = bus.get_object(globals.bus_name, '/com/dumbhippo/client')
self.__mugshot_dbus_proxy.RegisterEndpoint(reply_handler=self.__on_register_endpoint, error_handler=self.__on_dbus_error)
@@ -133,244 +60,26 @@
except dbus.DBusException:
self.__ws_proxy = None
- def __create_im_proxy(self):
- try:
- bus = dbus.SessionBus()
- self.__im_proxy = bus.get_object(globals.bus_name, '/org/freedesktop/od/im')
- except dbus.DBusException:
- self.__im_proxy = None
-
@log_except(_logger)
def __on_dbus_name_owner_changed(self, name, prev_owner, new_owner):
if name == globals.bus_name:
if new_owner != '':
self._logger.debug("owner for %s changed, recreating proxies", globals.bus_name)
self.__create_proxy()
- self.__create_ws_proxy()
- self.__create_im_proxy()
else:
self.__proxy = None
self.__ws_proxy = None
- self.__im_proxy = None
@log_except(_logger)
def __on_register_endpoint(self, id):
self.__endpoint_id = id
@log_except(_logger)
- def __on_connection_status(self, has_auth, connected, contacts):
- self._logger.debug("connection status auth=%s connected=%s contacts=%s" % (has_auth, connected, contacts))
- self.__connection_status = (has_auth, connected, contacts)
- self.emit("connection-status", has_auth, connected, contacts)
-
- def __get_connection_status(self):
- self.__proxy.GetConnectionStatus(reply_handler=self.__on_connection_status,
- error_handler=self.__on_dbus_error)
-
- @log_except(_logger)
- def __on_connection_status_changed(self):
- self._logger.debug("connection status changed")
- self.__get_connection_status()
-
- def current_connection_status(self):
- return self.__connection_status
-
- def get_pref(self, key):
- if self.__prefs.has_key(key):
- return self.__prefs[key]
- return None
-
- @log_except(_logger)
- def __on_pref_changed(self, key, value):
- self._logger.debug("pref %s changed: %s", key, value)
- changed = False
- if not self.__prefs.has_key(key):
- changed = True
- self.__prefs[key] = value
- elif self.__prefs[key] != value:
- changed = True
- self.__prefs[key] = value
- if changed:
- self.emit("pref-changed", key, value)
-
- @log_except(_logger)
- def __externalIQReturn(self, id, content):
- if self.__external_iqs.has_key(id):
- #self._logger.debug("got external IQ reply for %d (%d outstanding)", id, len(self.__external_iqs.keys())-1)
- (cb, iqkey) = self.__external_iqs[id]
- if iqkey:
- iqfile = os.path.join(self.__iqcachedir, iqkey)
- open(iqfile, 'w').write(content)
- cb(content)
- del self.__external_iqs[id]
-
- def get_entity(self, guid):
- return self.__entites[guid]
-
- @log_except(_logger)
def __on_dbus_error(self, err):
# TODO - could schedule a "reboot" of this class here to reload
# information
self._logger.error("D-BUS error: %s", err)
- @log_except(_logger)
- def __on_self_changed(self):
- self.__self_proxy.GetProperties(reply_handler=self.__on_get_self_properties,
- error_handler=self.__on_dbus_error)
-
- @log_except(_logger)
- def __on_get_self(self, myself_path):
- self._logger.debug("got self path: %s" % (myself_path,))
- self.__self_proxy = dbus.SessionBus().get_object(globals.bus_name, myself_path)
- self.__on_self_changed()
- self.__self_proxy.connect_to_signal("Changed",
- self.__on_self_changed,
- 'org.mugshot.Mugshot.Entity')
-
- @log_except(_logger)
- def __on_get_self_properties(self, myself):
- self._logger.debug("self properties: %s" % (myself,))
- if self.__self:
- self.__self.update(myself)
- else:
- self.__self = Person(myself)
- self._logger.debug("emitting self known")
- self.emit("self-known")
-
- @log_except(_logger)
- def __on_get_baseprops(self, props):
- self.__baseprops = {}
- for k,v in props.items():
- self.__baseprops[str(k)] = v
- self.emit("initialized")
-
- def __get_baseprop(self, name):
- return self.__baseprops and self.__baseprops[name] or None
-
- def get_baseurl(self):
- return globals.get_baseurl()
-
- def get_initialized(self):
- return True
-
- def get_self(self):
- if self.__self is None:
- self.__proxy.GetSelf(reply_handler=self.__on_get_self, error_handler=self.__on_dbus_error)
- return None
- return self.__self
-
- @log_except(_logger)
- def __on_get_network_entity_props(self, proxy, attrs, connect=False):
- self._logger.debug("entity properties: %s", attrs)
-
- guid = attrs[u'guid']
- if not self.__network.has_key(guid):
- entity_type = attrs['type']
- entity_class = {'person': Person, 'group': Group,
- 'resource': Resource, 'feed': Feed}
- self.__network[guid] = entity_class[attrs['type']](attrs)
- self.emit("network-changed")
- else:
- self.__network[guid].update(attrs)
- if connect:
- proxy.connect_to_signal("Changed",
- functools.partial(self.__on_get_network_entity_props, None),
- 'org.mugshot.Mugshot.Entity')
-
-
- @log_except(_logger)
- def __on_get_network(self, opaths):
- self._logger.debug("got network reply %s", opaths)
- self.__network = {}
- for opath in opaths:
- proxy = dbus.SessionBus().get_object(globals.bus_name, opath)
- proxy.GetProperties(reply_handler=functools.partial(self.__on_get_network_entity_props, proxy, connect=True),
- error_handler=self.__on_dbus_error)
-
- def get_network(self):
- if self.__network is None:
- self.__proxy.GetNetwork(reply_handler=self.__on_get_network, error_handler=self.__on_dbus_error)
- return None
- return self.__network.itervalues()
-
- def get_cookies(self, url):
- cookies = self.__ws_proxy.GetCookiesToSend(url)
-
- #print cookies
- return cookies
-
- def __iq_key(self, name, xmlns, attrs):
- return sha.new(name+xmlns+repr(attrs)).hexdigest()
-
- def __do_external_iq(self, name, xmlns, cb, attrs=None, content="", is_set=False):
- """Sends a raw IQ request to Mugshot server, indirecting
- via D-BUS to client."""
- if not is_set:
- # Check the cache
- iqkey = self.__iq_key(name, xmlns, attrs)
- iqfile = os.path.join(self.__iqcachedir, iqkey)
- if os.access(iqfile, os.R_OK):
- cachedata = open(iqfile).read()
- gobject.idle_add(log_except(_logger)(cb), cachedata)
- else:
- iqkey = None
- gobject.idle_add(log_except(_logger)(functools.partial(self.__do_external_iq_uncached, iqkey, name, xmlns, cb, attrs=attrs, content=content, is_set=is_set)))
-
- def __do_external_iq_uncached(self, iqkey, name, xmlns, cb, attrs=None, content="", is_set=False):
- if self.__proxy is None:
- self._logger.warn("No Mugshot active, not sending IQ")
- return
- #self._logger.debug("sending external IQ request: set=%s name=%s xmlns=%s attrs=%s (%d bytes)", is_set, name, xmlns, attrs, len(content))
- if attrs is None:
- attrs = {}
- attrs['xmlns'] = xmlns
- flattened_attrs = []
- for k,v in attrs.iteritems():
- flattened_attrs.append(k)
- flattened_attrs.append(v)
- id = self.__proxy.SendExternalIQ(is_set, name, flattened_attrs, content)
- self.__external_iqs[id] = (cb, iqkey)
-
- def __on_get_person_accounts(self, person, xml_str):
- doc = xml.dom.minidom.parseString(xml_str)
- accts = []
- for child in xml_query(doc.documentElement, 'externalAccount*'):
- attrs = xml_get_attrs(child, ['type',
- 'sentiment',
- 'icon'])
- accttype = attrs['type']
- if attrs['sentiment'] == 'love':
- attrs['link'] = child.getAttribute('link')
- thumbnails = []
- try:
- thumbnails_node = xml_query(child, 'thumbnails')
- except KeyError:
- thumbnails_node = None
- if thumbnails_node:
- for thumbnail in xml_query(thumbnails_node, 'thumbnail*'):
- subattrs = xml_get_attrs(thumbnail, ['src', ('title', True), 'href'])
- thumbnails.append(ExternalAccountThumbnail(subattrs))
- #self._logger.debug("%d thumbnails found for account %s (user %s)" % (len(thumbnails), accttype, person))
- attrs['thumbnails'] = thumbnails
- feeds = []
- try:
- feeds_node = xml_query(child, 'feeds')
- except KeyError:
- feeds_node = None
- if feeds_node:
- for feed in xml_query(feeds_node, 'feed*'):
- feeds.append(feed.getAttribute('src'))
- attrs['feeds'] = feeds
- acct = ExternalAccount(attrs)
- accts.append(acct)
- #self._logger.debug("setting %d accounts for user %s" % (len(accts), person))
- person.set_external_accounts(accts)
-
- def get_person_accounts(self, person):
- self.__do_external_iq("whereim", "http://dumbhippo.com/protocol/whereim",
- lambda node: self.__on_get_person_accounts(person, node),
- attrs={'who': person.get_guid()})
-
def install_application(self, id, package_names, desktop_names):
self._logger.debug("requesting install of app id %s", id)
self.__mugshot_dbus_proxy.InstallApplication(self.__endpoint_id, id, package_names, desktop_names)
Modified: bigboard/trunk/bigboard/people_tracker.py
===================================================================
--- bigboard/trunk/bigboard/people_tracker.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/people_tracker.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -602,11 +602,12 @@
# we clear everything and start over.
contact_props = '[+;name;user [+;photoUrl;mugshotLocalBuddy];aims;aimBuddies [+;icon;statusMessage];mugshotLocalBuddies [+;icon;user];xmpps;xmppBuddies [+;icon;statusMessage];emails;status]'
+
+ if self.__model.self_resource != None:
+ query = self.__model.query_resource(self.__model.self_resource, "contacts %s" % contact_props)
+ query.add_handler(self.__on_got_self)
+ query.execute()
- query = self.__model.query_resource(self.__model.self_resource, "contacts %s" % contact_props)
- query.add_handler(self.__on_got_self)
- query.execute()
-
query = self.__model.query_resource(self.__model.global_resource,
"aimBuddies [+;icon;statusMessage;contact %s]; xmppBuddies [+;icon;statusMessage;contact %s]; mugshotLocalBuddies [+;icon;user;contact %s]" % (contact_props, contact_props, contact_props))
Deleted: bigboard/trunk/bigboard/presence.py
===================================================================
--- bigboard/trunk/bigboard/presence.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/presence.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -1,59 +0,0 @@
-import logging
-
-import gobject, dbus
-
-import libbig
-from libbig.struct import AutoStruct, AutoSignallingStruct
-
-import global_mugshot
-
-class Buddy(AutoStruct):
- """An IM buddy."""
- def __init__(self):
- AutoStruct.__init__(self, { 'protocol' : 'unknown', 'name' : None,
- 'status' : 'away', 'online' : False })
-
-class Presence:
-
- def __init__(self, issingleton):
- self._logger = logging.getLogger('bigboard.Presence')
-
- if not issingleton == 42:
- raise Exception("use presence.get_presence()")
-
- self.__proxy = None
- self.__buddies = []
- global_mugshot.get_mugshot().connect("initialized", lambda mugshot: self.__on_reset())
-
- def __reload_buddy_list(self):
- if not self.__proxy:
- return
- self.__buddies = []
- buddies = self.__proxy.GetBuddyList()
- for b in buddies:
- buddy = Buddy()
- buddy.update(b)
- self.__buddies.append(buddy)
-
- def __on_buddy_changed(self, buddy):
- self._logger.debug("buddy changed %s" % str(buddy))
-
- def __on_reset(self):
- if self.__proxy:
- self.__proxy.disconnect_from_signal("BuddyChanged")
- self.__proxy.disconnect_from_signal("BuddyListChanged")
- self.__proxy = global_mugshot.get_mugshot().get_im_proxy()
- if self.__proxy:
- self.__proxy.connect_to_signal("BuddyChanged", self.__on_buddy_changed)
- self.__proxy.connect_to_signal("BuddyListChanged", self.__reload_buddy_list)
- self.__reload_buddy_list()
-
- def get_buddies(self):
- return self.__buddies
-
-presence_inst = None
-def get_presence():
- global presence_inst
- if presence_inst is None:
- presence_inst = Presence(42)
- return presence_inst
Deleted: bigboard/trunk/bigboard/profile.py
===================================================================
--- bigboard/trunk/bigboard/profile.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/profile.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -1,112 +0,0 @@
-# this file handles user's "mugshots" (like their /person page or google gadget)
-
-import logging
-import xml.sax
-import libbig
-import global_mugshot
-
-# object representing a profile; also a sax handler that can parse the xml form
-class Profile(libbig.struct.AutoStruct, xml.sax.ContentHandler):
- def __init__(self, guid):
- super(Profile, self).__init__({ 'name' : None, 'photo' : None, 'who' : str(guid), 'online' : None,
- 'home_url' : None, 'onlineIcon' : None, 'accounts' : [], 'stack' : [],
- 'email' : None, 'aim' : None})
-
- def startElement(self, name, attrs):
- #print name
- #print attrs.getNames() # .getValue('foo')
-
- if name == 'rsp':
- if attrs.getValue('stat') != 'ok':
- raise xml.sax.SAXException, 'failed'
- elif name == 'userSummary':
- online = False
- if attrs.getValue('online') == 'true':
- online = True
- self.update({ 'name' : attrs.getValue('name'),
- 'photo' : attrs.getValue('photo'),
- 'online' : online,
- 'home_url' : attrs.getValue('homeUrl') })
-
- elif name == 'externalAccount':
- accounts = self.get_accounts()
- accounts.append({ 'link' : attrs.getValue('link'),
- 'type' : attrs.getValue('type'),
- 'linkText' : attrs.getValue('linkText'),
- 'icon' : attrs.getValue('icon') })
- elif name == 'address':
- type = attrs.getValue('type')
- if type == 'email':
- self.update({ 'email' : attrs.getValue('value') })
- elif type == 'aim':
- self.update({ 'aim' : attrs.getValue('value') })
-
- def characters(self, content):
- #print content
- pass
-
-class ProfileFactory:
-
- def __init__(self):
- self._fetcher = libbig.http.AsyncHTTPFetcher()
- self._mugshot = global_mugshot.get_mugshot()
- self._baseurl = None
- self._mugshot.connect("initialized", lambda mugshot: self._sync_baseurl())
- self._profiles = {}
- self._callbacks = {}
-
- def _sync_baseurl(self):
- self._baseurl = self._mugshot.get_baseurl()
-
- def _download_summary(self, guid):
- pairs = None
- try:
- pairs = self._mugshot.get_cookies(self._baseurl)
- except:
- logging.exception('failed to get cookies')
- self._fetcher.fetch(self._baseurl + 'xml/userSummary?includeStack=true&who=' + guid,
- lambda url, data: self._do_load(url, data, guid),
- lambda url, exc_info: self._do_load_error(url, exc_info, guid),
- cookies=pairs)
-
- def _notify(self, guid):
- p = None
- if self._profiles.has_key(guid):
- p = self._profiles[guid] # note that if we failed earlier, p = None here
-
- callbacks = []
- if self._callbacks.has_key(guid):
- callbacks = self._callbacks[guid]
- self._callbacks[guid] = []
-
- for c in callbacks:
- c(p)
-
- def _do_load(self, url, data, guid):
- logging.debug("retrieved '%s' (%d bytes) for %s", url, len(data), guid)
- p = Profile(guid)
- try:
- xml.sax.parseString(data, p)
- self._profiles[guid] = p
- except xml.sax.SAXException, e:
- self._profiles[guid] = None
-
- self._notify(guid)
-
- def _do_load_error(self, url, exc_info, guid):
- logging.exception("Caught exception retrieving '%s'", url)
-
- self._notify(guid)
-
- def fetch_profile(self, guid, callback):
- guid = str(guid)
- if self._profiles.has_key(guid):
- callback(self._profiles[guid])
- else:
- if self._callbacks.has_key(guid):
- self._callbacks[guid].append(callback)
- else:
- self._callbacks[guid] = [callback]
-
- self._download_summary(guid)
-
Modified: bigboard/trunk/bigboard/stock.py
===================================================================
--- bigboard/trunk/bigboard/stock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -4,12 +4,13 @@
import hippo
+from ddm import DataModel
import big_widgets
-import global_mugshot
import libbig
from libbig.singletonmixin import Singleton
from bigboard.libbig.gutil import *
from bigboard.libbig.logutil import log_except
+import bigboard.globals as globals
## FIXME remove these from the Stock class ... I can't figure out how to
## refer to them from outside a Stock instance with them there, anyway
@@ -116,40 +117,24 @@
raise NotImplementedError()
class AbstractMugshotStock(Stock):
- """An abstract class for stocks which use Mugshot. The most useful
- method on this class is connect_mugshot_handler. This is deprecated since the
- old mugshot API in mugshot.py should no longer be used, use the data model."""
+ """An abstract class for stocks which use Mugshot.."""
def __init__(self, *args, **kwargs):
super(AbstractMugshotStock, self).__init__(*args, **kwargs)
- self._auth = False
- self.__have_contacts = False
- self._mugshot_initialized = False
- self._dependent_handlers = []
-
- self._mugshot = global_mugshot.get_mugshot()
- self.__connections = DisconnectSet()
- id = self._mugshot.connect("initialized", lambda mugshot: self._on_mugshot_initialized())
- self.__connections.add(self._mugshot, id)
- if self._mugshot.get_initialized():
- call_idle(self.__invoke_mugshot_initialized)
+ self._model = DataModel(globals.server_name)
- id = self._mugshot.connect("connection-status", lambda mugshot, auth, xmpp, contacts: self.__handle_mugshot_connection_status(auth, xmpp, contacts))
- self.__connections.add(self._mugshot, id)
+ # There is a minor danger of calling on_ready twice if we start up and then get a
+ # ready notification before going idle; this could be protected with a flag variable
+ self._model.add_ready_handler(self._on_ready)
+ if self._model.ready:
+ call_idle(self.__invoke_on_ready)
- call_idle(self.__handle_mugshot_connection_status, *self._mugshot.current_connection_status())
-
self.__cursize = None
self.__box = hippo.CanvasBox()
- def on_delisted(self):
- self.__connections.disconnect_all()
-
- super(AbstractMugshotStock, self).on_delisted()
-
def __sync_content(self):
self.__box.remove_all()
- if self._auth:
+ if self._model.self_resource:
content = self.get_authed_content(self.__cursize)
if not content:
return None
@@ -171,26 +156,16 @@
self.__cursize = size
return self.__sync_content()
- # protected
- def get_mugshot_initialized(self):
- return self._mugshot_initialized
-
@log_except(_logger)
- def __invoke_mugshot_initialized(self):
- self._on_mugshot_initialized()
-
- def _on_mugshot_initialized(self):
- logging.debug("mugshot intialized, hooking up %d handlers", len(self._dependent_handlers))
- self._mugshot_initialized = True
- for object, signal, handler in self._dependent_handlers:
- object.connect(signal, handler)
- self.__check_ready()
-
- def _on_mugshot_ready(self):
- """Should be overridden by subclasses to handle the state where mugshot
- is initialized and connected."""
- pass
+ def __invoke_on_ready(self):
+ if self._model.ready:
+ self._on_ready()
+ def _on_ready(self):
+ """Should be overridden by subclasses to handle the state where we
+ have connected to the data model (or tried to connected an failed."""
+ pass
+
@log_except(_logger)
def __handle_mugshot_connection_status(self, auth, xmpp, contacts):
if auth != self._auth:
@@ -200,17 +175,3 @@
self.__sync_content()
self.__have_contacts = contacts
self.__check_ready()
-
- def __check_ready(self):
- if self._mugshot_initialized and self.__have_contacts:
- self._on_mugshot_ready()
-
- # protected
- def connect_mugshot_handler(self, object, signal, handler):
- """Hook up a GObject signal handler only after the Mugshot
- object is initialized. This is useful if your signal handler
- depends on Mugshot properties such as the base URL."""
- if self.get_mugshot_initialized():
- object.connect(signal, handler)
- else:
- self._dependent_handlers.append((object, signal, handler))
Modified: bigboard/trunk/bigboard/stocks/apps/AppsStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -6,7 +6,6 @@
import gconf, hippo
import bigboard.globals as globals
-import bigboard.global_mugshot as global_mugshot
import bigboard.libbig as libbig
from bigboard.libbig.gutil import *
import bigboard.apps_directory as apps_directory
@@ -45,8 +44,6 @@
search.enable_search_provider('apps')
- self.__model = bigboard.globals.get_data_model()
-
self.__box = CanvasVBox(spacing=3)
self.__message = hippo.CanvasText()
self.__message_link = ActionLink()
@@ -81,13 +78,9 @@
self.__repo.connect('global-top-apps-changed', self.__on_global_top_apps_changed)
self.__repo.connect('app-launched', self.__on_app_launched)
- self.__model.add_ready_handler(self.__on_ready)
- if self.__model.ready:
- self.__on_ready()
-
self.__sync()
- def __on_ready(self):
+ def _on_ready(self):
# When we disconnect from the server we freeze existing content, then on reconnect
# we clear everything and start over.
_logger.debug("Connected to data model")
@@ -201,7 +194,7 @@
break
# don't display apps that are not installed if the user is not logged in
- if not self.__model.self_resource and not app.is_installed():
+ if not self._model.self_resource and not app.is_installed():
continue
display = apps_widgets.AppDisplay(apps_widgets.AppLocation.STOCK, app)
@@ -222,7 +215,7 @@
#_logger.debug("usage: %s", usage)
- if usage is False and self.__model.ready and self.__model.global_resource.online:
+ if usage is False and self._model.ready and self._model.global_resource.online:
self.__set_message("Enable application tracking",
globals.get_baseurl() + "/account")
Modified: bigboard/trunk/bigboard/stocks/apps/apps.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/apps/apps.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -307,7 +307,7 @@
_logger.debug("Data model now ready")
if self.__model.self_resource != None:
- query = self.__model.query_resource(self.__model.self_resource, "topApplications[+;description;category;categoryDisplayName;packageNames];pinnedApplications[+;description;category;categoryDisplayName;packageNames];applicationUsageEnabled")
+ query = self.__model.query_resource(self.__model.self_resource, "topApplications[+;description;category;categoryDisplayName;packageNames];pinnedApplications[+;description;category;categoryDisplayName;packageNames];applicationUsageEnabled;applicationUsageStart")
query.add_handler(self.__on_got_self)
query.add_error_handler(lambda code, msg: self.__on_query_error("self resource", code, msg))
query.execute()
Property changes on: bigboard/trunk/bigboard/stocks/files
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Modified: bigboard/trunk/bigboard/stocks/files/FilesStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/files/FilesStock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/files/FilesStock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -4,7 +4,6 @@
import gobject, gtk, pango
import gconf, gnomevfs
import gnome.ui
-import dbus, dbus.glib
import hippo
from pyonlinedesktop.fsutil import VfsMonitor
Modified: bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/google_calendar/CalendarStock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -6,7 +6,6 @@
import gdata.calendar as gcalendar
import bigboard.libbig as libbig
-import bigboard.global_mugshot as global_mugshot
import bigboard.stock as stock
import bigboard.google as google
import bigboard.slideout as slideout
@@ -409,6 +408,9 @@
class CalendarStock(AbstractMugshotStock, google_stock.GoogleStock):
def __init__(self, *args, **kwargs):
+ AbstractMugshotStock.__init__(self, *args, **kwargs)
+ google_stock.GoogleStock.__init__(self, 'calendar', **kwargs)
+
self.__box = hippo.CanvasBox(orientation=hippo.ORIENTATION_VERTICAL)
# We keep calendars in a dictionary, referenced by calendar feed links,
# so that we can get calendar names without updating events that are
@@ -437,10 +439,6 @@
self.__min_event_range_start = self.__event_range_start
self.__max_event_range_end = self.__event_range_end
- # these are at the end since they have the side effect of calling on_mugshot_ready it seems?
- AbstractMugshotStock.__init__(self, *args, **kwargs)
- google_stock.GoogleStock.__init__(self, 'calendar', **kwargs)
-
bus = dbus.SessionBus()
o = bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')
self.__notifications_proxy = dbus.Interface(o, 'org.freedesktop.Notifications')
@@ -450,6 +448,7 @@
def _on_delisted(self):
self._delist_google()
+ super(self, CalendarStock)._on_delisted(self)
def __change_day(self):
self.__close_slideout()
@@ -559,8 +558,8 @@
def update_google_data(self, gobj = None):
self.__update_calendar_list_and_events(gobj)
- def _on_mugshot_ready(self):
- super(CalendarStock, self)._on_mugshot_ready()
+ def _on_ready(self):
+ super(CalendarStock, self)._on_ready()
self.__update_calendar_list_and_events()
def get_authed_content(self, size):
Property changes on: bigboard/trunk/bigboard/stocks/mail
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Modified: bigboard/trunk/bigboard/stocks/mugshot_photos/PhotosStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/mugshot_photos/PhotosStock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/mugshot_photos/PhotosStock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -9,6 +9,8 @@
from bigboard.stock import Stock, AbstractMugshotStock
from bigboard.big_widgets import CanvasURLImage, CanvasVBox, CanvasHBox, CanvasMugshotURLImage, ActionLink
+_logger = logging.getLogger('bigboard.stocks.PhotosStock')
+
class TransitioningURLImage(hippo.CanvasBox, hippo.CanvasItem):
__gtype_name__ = 'TransitioningURLImage'
@@ -22,9 +24,8 @@
TRANSITION_STEPS = 10
- def __init__(self, logger, **kwargs):
+ def __init__(self, **kwargs):
hippo.CanvasBox.__init__(self, **kwargs)
- self._logger = logger
self.set_clickable(True)
self.__current_url = None
self.__prev_url = None
@@ -43,7 +44,7 @@
if url != self.__current_url:
return
- self._logger.debug("loaded url=%s", url)
+ _logger.debug("loaded url=%s", url)
self.emit("loaded", True)
req_changed = False
@@ -97,7 +98,7 @@
else:
scale = (1.0*self.__dimension) / img_height
- self._logger.debug("rendering img width=%s height=%s scale=%s", img_width, img_height, scale)
+ _logger.debug("rendering img width=%s height=%s scale=%s", img_width, img_height, scale)
(x,y,w,h) = self.align(int(img_width*scale), int(img_height*scale))
@@ -176,7 +177,7 @@
self.__displaybox.append(self.__photo_header)
self.__photobox = CanvasHBox(spacing=6)
- self.__photo = TransitioningURLImage(self._logger, dimension=self.__photosize)
+ self.__photo = TransitioningURLImage(dimension=self.__photosize)
self.__photo.connect("loaded", lambda photo, loaded: self.__on_image_load(loaded))
self.__photo.connect("button-press-event", lambda photo, event: self.__visit_photo())
self.__metabox = CanvasVBox()
@@ -205,44 +206,56 @@
self.__person_accts_len = {} # <Person,int>
self.__bearbox = CanvasVBox()
- self.__bearphoto = TransitioningURLImage(self._logger, dimension=self.SIZE_BEAR_CONTENT_PX-6)
+ self.__bearphoto = TransitioningURLImage(dimension=self.SIZE_BEAR_CONTENT_PX-6)
self.__bearphoto.connect("button-press-event", lambda photo, event: self.__visit_photo())
self.__bearbox.append(self.__bearphoto)
-
- self._mugshot.connect("network-changed", lambda mugshot: self.__handle_network_change())
-
- def _on_mugshot_ready(self):
- super(PhotosStock, self)._on_mugshot_ready()
- self._mugshot.get_network()
-
+
+ def _on_ready(self):
+ if self._model.self_resource != None:
+ query = self._model.query_resource(self._model.self_resource, "contacts user [+;lovedAccounts [+;thumbnails +]]")
+ query.add_handler(self.__on_got_self)
+ query.execute()
+
+ def __on_got_self(self, myself):
+ self.__reset()
+
def get_authed_content(self, size):
return size == self.SIZE_BULL and self.__box or self.__bearbox
def __visit_photo(self):
- self._logger.debug("visiting photo for %s", self.__current_image)
+ _logger.debug("visiting photo for %s", self.__current_image)
if not self.__current_image:
return
libbig.show_url(self.__current_image[2].get_href())
def __visit_person(self):
- self._logger.debug("visiting person for %s", self.__current_image)
+ _logger.debug("visiting person for %s", self.__current_image)
if not self.__current_image:
return
libbig.show_url(urlparse.urljoin(globals.get_baseurl(), self.__current_image[0].get_home_url()))
def __thumbnails_generator(self):
"""The infinite photos function. Cool."""
- found_one = False
while True:
- for entity in self._mugshot.get_network():
- accts = entity.get_external_accounts()
- if not accts:
- continue
- for acct in accts:
- if acct.get_thumbnails():
- for thumbnail in acct.get_thumbnails():
- found_one = True
- yield (entity, acct, thumbnail)
+ found_one = False
+ # Iterate through all thumbnails for all "loved accounts" for all contacts.
+ # We don't handle change notification ... if something changes we'll pick
+ # it up next time around. Note the use of temporary copies of lists to avoid
+ # problems if a list is mutated by a change notification while we are iterating it.
+ if self._model.self_resource:
+ for contact in list(getattr(self._model.self_resource, "contacts", [])):
+ user = getattr(contact, "user", None)
+ if user != None:
+ lovedAccounts = getattr(user, "lovedAccounts", None)
+ if lovedAccounts:
+ for externalAccount in lovedAccounts:
+ thumbnails = getattr(externalAccount, "thumbnails", None)
+ if thumbnails:
+ for thumbnail in thumbnails:
+ yield (user, externalAccount, thumbnail)
+
+ # If we didn't find any photos, we go into a "no photos" state; we'll keep on trying
+ # to restart the iterator in the timeout, so when things appear we'll display them
if not found_one:
return
@@ -263,70 +276,43 @@
def __set_image(self, imageinfo):
self.__current_image = imageinfo
- (entity, acct, thumbnail) = imageinfo
+ (user, account, thumbnail) = imageinfo
- self._logger.debug("starting load of url %s" % (thumbnail.get_src(),))
- self.__photo.set_url(thumbnail.get_src())
- self.__bearphoto.set_url(thumbnail.get_src())
+ _logger.debug("starting load of url %s" % (thumbnail.src,))
+ self.__photo.set_url(thumbnail.src)
+ self.__bearphoto.set_url(thumbnail.src)
def __on_image_load(self, success):
if self.__current_image is None:
- self._logger.debug("image load complete, but no current image")
+ _logger.debug("image load complete, but no current image")
return
if not success:
self.__successive_load_failures = max(self.__successive_load_failures+1, 17)
- self._logger.debug("image load failed, queueing skip to next")
+ _logger.debug("image load failed, queueing skip to next")
gobject.timeout_add(8000 + (2 ** self.__successive_load_failures) * 1000, self.__do_next)
else:
self.__successive_load_failures = 0
- self._logger.debug("image load success, syncing metadata")
- (entity, acct, thumbnail) = self.__current_image
+ _logger.debug("image load success, syncing metadata")
+ (user, account, thumbnail) = self.__current_image
- self.__favicon.set_url(acct.get_icon())
- self.__title.set_property("text", thumbnail.get_title() or "(untitled)")
+ self.__favicon.set_url(account.iconUrl)
+
+ title = getattr(thumbnail, "title", None)
+ if not title: title = "(untitled)"
+ self.__title.set_property("text", title)
- self.__fromname.set_property("text", entity.get_name())
- self.__fromphoto.set_url(entity.get_photo_url())
+ self.__fromname.set_property("text", user.name)
+ self.__fromphoto.set_url(user.photoUrl)
def __idle_display_image(self):
- self._logger.debug("in idle, doing next image")
+ _logger.debug("in idle, doing next image")
self.__idle_display_id = 0
self.__do_next()
return False
- def __handle_person_change(self, person):
- need_reset = False
-
- accts = person.get_external_accounts()
- if not self.__person_accts_len.has_key(person):
- need_reset = True
- self.__person_accts_len[person] = -1
- elif accts and self.__person_accts_len[person] != len(accts):
- self.__person_accts_len[person] = len(accts)
- need_reset = True
-
- if need_reset:
- self.__reset()
-
- def __handle_network_change(self):
- self._logger.debug("handling network change")
- for person in self._mugshot.get_network():
- if not self.__person_accts_len.has_key(person):
- person.connect("changed", self.__handle_person_change)
- accts = person.get_external_accounts()
- self.__person_accts_len[person] = accts and len(accts) or 0
- not_in_network = []
- for person in self.__person_accts_len.iterkeys():
- if not person in self._mugshot.get_network():
- not_in_network.append(person)
- for person in not_in_network:
- self._logger.debug("removing not-in-network person %s", person.get_guid())
- del self.__person_accts_len[person]
- self.__reset()
-
def __do_direction(self, is_next):
- self._logger.debug("skipping to %s" % (is_next and "next" or "prev",))
+ _logger.debug("skipping to %s" % (is_next and "next" or "prev",))
try:
self.__set_image(is_next and self.__next_image() or self.__prev_image())
if self.__displaymode == 'text':
@@ -335,7 +321,7 @@
self.__box.append(self.__displaybox)
self.__displaymode = 'photo'
except StopIteration:
- self._logger.debug("caught StopIteration, displaying no photos text")
+ _logger.debug("caught StopIteration, displaying no photos text")
if self.__displaymode == 'photo':
self.__box.remove(self.__displaybox)
if self.__displaymode != 'text':
@@ -352,8 +338,9 @@
self.__do_direction(False)
def __reset(self):
- self._logger.debug("resetting")
+ _logger.debug("resetting")
self.__images = self.__thumbnails_generator()
+ self.__images_reverse = []
self.__box.remove_all()
self.__displaymode = 'uninitialized'
self.__do_next()
Modified: bigboard/trunk/bigboard/stocks/people/PeopleStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/PeopleStock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/people/PeopleStock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -1,14 +1,11 @@
import logging
import hippo
-from ddm import DataModel
import bigboard
from bigboard.people_tracker import PeopleTracker, sort_people
from bigboard.stock import AbstractMugshotStock
-import bigboard.globals
import bigboard.slideout
-import bigboard.profile
import bigboard.search as search
import bigboard.libbig as libbig
import bigboard.scroll_ribbon as scroll_ribbon
@@ -43,8 +40,6 @@
self.__tracker.people.connect("added", self.__on_person_added)
self.__tracker.people.connect("removed", self.__on_person_removed)
- self.__model = DataModel(bigboard.globals.server_name)
-
for person in self.__tracker.people:
self.__on_person_added(self.__tracker.people, person)
@@ -69,7 +64,7 @@
self.__set_item_size(i, size)
def __add_person(self, person, box, map):
- self._logger.debug("person added to people stock %s" % (person.display_name))
+ _logger.debug("person added to people stock %s", person.display_name)
if map.has_key(person):
return
@@ -91,6 +86,7 @@
item.connect('activated', self.__handle_item_pressed)
def __remove_person(self, person, box, map):
+ _logger.debug("person removed from people stock %s", person.display_name)
try:
item = map[person]
except KeyError:
Modified: bigboard/trunk/bigboard/stocks/self/SelfStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/self/SelfStock.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/bigboard/stocks/self/SelfStock.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -282,10 +282,7 @@
self._box.append(self._signin)
self._signin.connect("button-press-event", lambda signin, event: self.__do_account())
- self._model = DataModel(globals.server_name)
-
self.__myself = None
- self._model.add_ready_handler(self.__on_ready)
self.info_loaded = False
@@ -298,9 +295,6 @@
#TODO: need to make this conditional on knowing firefox has started already somehow
#gobject.timeout_add(2000, self.__idle_first_time_signin_check)
- if self._model.ready:
- self.__on_ready()
-
def __idle_first_time_signin_check(self):
ws = dbus.SessionBus().get_object('org.freedesktop.od.Engine', '/org/gnome/web_services')
cookiejar = ws.GetCookiesToSend('http://online.gnome.org')
@@ -324,7 +318,7 @@
self.info_loaded = True
self.emit('info-loaded')
- def __on_ready(self):
+ def _on_ready(self):
try:
protocol_version = self._model.global_resource.ddmProtocolVersion
except AttributeError, e:
@@ -358,10 +352,6 @@
self.__on_self_changed(myself)
self.__info_now_loaded()
- def __handle_mugshot_connection_status(self, auth, xmpp, contacts):
- self._box.set_child_visible(self._whereim_box, not not auth)
- self._box.set_child_visible(self._signin, not auth)
-
def __do_slideout(self, slideout, widget=None):
widget_src = widget or self._box
(box_x, box_y) = self._box.get_context().translate_to_screen(self._box)
Property changes on: bigboard/trunk/bigboard/stocks/workspaces
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Property changes on: bigboard/trunk/bigboard/themes
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Property changes on: bigboard/trunk/data
___________________________________________________________________
Name: svn:ignore
+ Makefile.in
Makefile
Property changes on: bigboard/trunk/gdata
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Property changes on: bigboard/trunk/gdata/calendar
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Property changes on: bigboard/trunk/gdata/docs
___________________________________________________________________
Name: svn:ignore
+ *.pyc
Modified: bigboard/trunk/main.py
===================================================================
--- bigboard/trunk/main.py 2008-01-15 19:46:04 UTC (rev 7208)
+++ bigboard/trunk/main.py 2008-01-15 19:55:02 UTC (rev 7209)
@@ -30,7 +30,6 @@
import bignative
import bigboard.globals
import bigboard.google
-import bigboard.presence
from bigboard.libbig.gutil import *
from bigboard.libbig.logutil import log_except
import bigboard.libbig.dbusutil
@@ -957,7 +956,6 @@
panel = BigBoardPanel(bus_name)
bigboard.google.init()
- #bigboard.presence.get_presence() # for side effect of creating Presence object
gtk.gdk.threads_enter()
_logger.debug("Enter mainloop")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]