r6885 - in bigboard/trunk: . applet bigboard bigboard/stocks/apps bigboard/stocks/people bigboard/stocks/self
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r6885 - in bigboard/trunk: . applet bigboard bigboard/stocks/apps bigboard/stocks/people bigboard/stocks/self
- Date: Thu, 8 Nov 2007 15:27:53 -0600 (CST)
Author: otaylor
Date: 2007-11-08 15:27:52 -0600 (Thu, 08 Nov 2007)
New Revision: 6885
Modified:
bigboard/trunk/applet/apps.c
bigboard/trunk/applet/self.c
bigboard/trunk/bigboard/globals.py
bigboard/trunk/bigboard/people_tracker.py
bigboard/trunk/bigboard/stocks/apps/AppsStock.py
bigboard/trunk/bigboard/stocks/apps/apps.py
bigboard/trunk/bigboard/stocks/people/PeopleStock.py
bigboard/trunk/bigboard/stocks/people/peoplebrowser.py
bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
bigboard/trunk/bigboard/stocks/self/SelfStock.py
bigboard/trunk/main.py
Log:
applets/apps.c applet/self.c: Adapt to new C data model API
main.py bigboard/**.py: Adapt to new Python data model API
Modified: bigboard/trunk/applet/apps.c
===================================================================
--- bigboard/trunk/applet/apps.c 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/applet/apps.c 2007-11-08 21:27:52 UTC (rev 6885)
@@ -172,7 +172,7 @@
app = g_object_new(APP_TYPE, NULL);
- app->resource = resource;
+ app->resource = ddm_data_resource_ref(resource);
ddm_data_resource_connect(app->resource,
NULL, /* NULL = all properties */
@@ -206,6 +206,7 @@
ddm_data_resource_disconnect(app->resource,
on_app_resource_changed,
app);
+ ddm_data_resource_unref(app->resource);
}
void
Modified: bigboard/trunk/applet/self.c
===================================================================
--- bigboard/trunk/applet/self.c 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/applet/self.c 2007-11-08 21:27:52 UTC (rev 6885)
@@ -109,14 +109,9 @@
GSList *changed_properties,
gpointer user_data)
{
- SelfData *sd;
-
- sd = user_data;
-
- if (sd->self_resource == resource)
- update_photo_from_self(sd);
- else
- g_warning("Got photo changed notification for someone else?");
+ SelfData *sd = user_data;
+
+ update_photo_from_self(sd);
}
static void
@@ -250,64 +245,57 @@
GSList *changed_properties,
gpointer user_data)
{
- SelfData *sd;
-
- sd = user_data;
+ SelfData *sd = user_data;
- if (sd->self_resource == resource)
- update_applications_from_self(sd);
- else
- g_warning("Got apps changed notification for someone else?");
+ update_applications_from_self(sd);
}
static void
-on_query_response(GSList *resources,
- gpointer user_data)
+on_query_response(DDMDataResource *self_resource,
+ gpointer user_data)
{
SelfData *sd;
sd = user_data;
- /* we ignore the returned resources and just fetch out
- * the one we wanted
- */
- if (sd->self_resource == NULL) {
- DDMDataResource *global_resource;
-
- global_resource = ddm_data_model_lookup_resource(sd->ddm_model,
- "online-desktop:/o/global");
- if (global_resource == NULL) {
- g_printerr("No global resource in data model");
- return;
- }
-
- ddm_data_resource_get(global_resource,
- "self", DDM_DATA_RESOURCE, &sd->self_resource,
- NULL);
+ if (self_resource)
+ ddm_data_resource_ref(self_resource);
+
+ if (sd->self_resource) {
+ ddm_data_resource_disconnect(sd->self_resource,
+ on_photo_changed,
+ sd);
+ ddm_data_resource_disconnect(sd->self_resource,
+ on_applications_changed,
+ sd);
- if (sd->self_resource == NULL) {
- g_printerr("No self resource on global resource");
- return;
- }
+ ddm_data_resource_unref(sd->self_resource);
+ }
- update_photo_from_self(sd);
- update_applications_from_self(sd);
-
- /* FIXME hack since child fetch does not work yet */
- ddm_data_model_query_resource(sd->ddm_model,
- ddm_data_resource_get_resource_id(sd->self_resource),
- "topApplications+");
-
- ddm_data_resource_connect(sd->self_resource,
- "photoUrl",
- on_photo_changed,
- sd);
-
- ddm_data_resource_connect(sd->self_resource,
- "topApplications",
- on_applications_changed,
- sd);
+ sd->self_resource = self_resource;
+
+ if (sd->self_resource == NULL) {
+ g_debug("No self resource on global resource");
+ /* If there was previous data; just leave it there. It's not 100% clear
+ * to me that this is right ... the only time self should go from there
+ * to not there is when the user clears there online.gnome.org login
+ * entirely.
+ */
+ return;
}
+
+ ddm_data_resource_connect(sd->self_resource,
+ "photoUrl",
+ on_photo_changed,
+ sd);
+
+ ddm_data_resource_connect(sd->self_resource,
+ "topApplications",
+ on_applications_changed,
+ sd);
+
+ update_photo_from_self(sd);
+ update_applications_from_self(sd);
}
static void
@@ -315,27 +303,26 @@
const char *message,
gpointer user_data)
{
- g_printerr("Failed to get query reply: '%s'\n", message);
+ g_printerr("Query for photoUrl and topApplications failed: '%s'\n", message);
}
static void
-on_ddm_connected_changed(DDMDataModel *ddm_model,
- gboolean connected,
- void *data)
+on_ddm_ready(DDMDataModel *ddm_model,
+ void *data)
{
SelfData *sd = data;
-
- if (connected) {
+ DDMDataResource *self_resource = ddm_data_model_get_self_resource(ddm_model);
+
+ if (self_resource) {
DDMDataQuery *query;
-
- query = ddm_data_model_query_resource(ddm_model,
- /* the child fetch in [] does not work yet */
- "online-desktop:/o/global", "self [ photoUrl;topApplications+ ]");
-
+
+ query = ddm_data_model_query_resource(ddm_model, self_resource,
+ "photoUrl; topApplications +");
+
/* query frees itself when either handler is called */
- ddm_data_query_set_multi_handler(query,
- on_query_response, sd);
+ ddm_data_query_set_single_handler(query,
+ on_query_response, sd);
ddm_data_query_set_error_handler(query,
on_query_error, sd);
@@ -352,9 +339,13 @@
global_self_data->ddm_model = ddm_data_model_get_default();
g_signal_connect(G_OBJECT(global_self_data->ddm_model),
- "connected-changed",
- G_CALLBACK(on_ddm_connected_changed),
+ "ready",
+ G_CALLBACK(on_ddm_ready),
global_self_data);
+
+ if (ddm_data_model_is_ready(global_self_data->ddm_model)) {
+ on_ddm_ready(global_self_data->ddm_model, global_self_data);
+ }
}
return global_self_data;
Modified: bigboard/trunk/bigboard/globals.py
===================================================================
--- bigboard/trunk/bigboard/globals.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/globals.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -60,8 +60,11 @@
## is supposed to have an offline mode.
url = None
model = get_data_model()
- if model.self_id:
- url = model.get_web_base_url()
+ if model.global_resource:
+ try:
+ return model.global_resource.webBaseUrl
+ except AttributeError:
+ pass
## next we fall back to the server name set by command line option,
## see set_server_name() above which is called from main.py
Modified: bigboard/trunk/bigboard/people_tracker.py
===================================================================
--- bigboard/trunk/bigboard/people_tracker.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/people_tracker.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -146,7 +146,7 @@
def __init__(self):
self.__model = DataModel(bigboard.globals.server_name)
- self.__model.add_connected_handler(self.__on_connected)
+ self.__model.add_ready_handler(self.__on_ready)
self.__myself = None
self.__globalResource = None
@@ -161,10 +161,10 @@
self.__users_by_aim = _MultiDict()
self.__users_by_resource_id = _MultiDict()
- if self.__model.self_id:
- self.__on_connected()
+ if self.__model.ready:
+ self.__on_ready()
- def __on_connected(self):
+ def __on_ready(self):
# When we disconnect from the server we freeze existing content, then on reconnect
# we clear everything and start over.
@@ -174,10 +174,10 @@
if self.__myself != None:
self.__set_new_contacts([])
self.__myself.disconnect(self.__on_contacts_changed)
+
+ self.__myself = None
- self.__myself = None
-
- query = self.__model.query_resource(self.__model.self_id, "contacts [+;aim;email;contactStatus]")
+ query = self.__model.query_resource(self.__model.self_resource, "contacts [+;aim;email;contactStatus]")
query.add_handler(self.__on_got_self)
query.execute()
@@ -187,7 +187,7 @@
self.__globalResource = None
- query = self.__model.query_resource("online-desktop:/o/global", "onlineBuddies +")
+ query = self.__model.query_resource(self.__model.global_resource, "onlineBuddies +")
query.add_handler(self.__on_got_buddies)
query.execute()
Modified: bigboard/trunk/bigboard/stocks/apps/AppsStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -47,10 +47,6 @@
self.__model = bigboard.globals.get_data_model()
- self.__model.add_connected_handler(self.__on_connected)
- if self.__model.self_id:
- self.__on_connected()
-
self.__box = CanvasVBox(spacing=3)
self.__message = hippo.CanvasText()
self.__message_link = ActionLink()
@@ -85,9 +81,13 @@
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_connected(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")
@@ -203,7 +203,7 @@
# don't display apps that are not installed if the user is not logged in;
# because the user should be able to see the same list regardless of whether
# they are connected, we don't check self.__model.connected here
- if not self.__model.self_id 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)
Modified: bigboard/trunk/bigboard/stocks/apps/apps.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/stocks/apps/apps.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -267,8 +267,7 @@
super(AppsRepo, self).__init__(*args, **kwargs)
self.__model = bigboard.globals.get_data_model()
- self.__model.add_initialized_handler(self.__on_initialized)
- self.__model.add_connected_handler(self.__on_connected)
+ self.__model.add_ready_handler(self.__on_ready)
self.__model.add_server_connected_handler(self.__on_server_connected)
self.__myself = None
@@ -297,46 +296,51 @@
self.__get_popular_apps_pending = False
self.__got_popular_apps = False
- if self.__model.initialized:
- self.__on_initialized()
+ if self.__model.ready:
+ self.__on_ready()
- if self.__model.self_id:
- self.__on_connected()
-
if self.__model.connected:
self.__on_server_connected()
- def __on_initialized(self):
- if not self.__model.self_id and not self.__got_popular_apps and not self.__get_popular_apps_pending:
- _logger.debug("will get popular apps from http")
- self.__get_popular_apps_pending = True
- downloader = AppsHttpDownloader('/xml/popularapplications',
- self.__on_got_global_popular_apps_from_http)
- downloader.go()
-
- def __on_connected(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")
+ _logger.debug("Data model now ready")
- query = self.__model.query_resource(self.__model.self_id, "topApplications[+;description;category;categoryDisplayName;packageNames];pinnedApplications[+;description;category;categoryDisplayName;packageNames];applicationUsageEnabled")
- query.add_handler(self.__on_got_self)
- query.add_error_handler(lambda code, msg: self.__on_query_error("self resource", code, msg))
- query.execute()
+ 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.add_handler(self.__on_got_self)
+ query.add_error_handler(lambda code, msg: self.__on_query_error("self resource", code, msg))
+ query.execute()
- query = self.__model.query(("http://online.gnome.org/p/application", "getPopularApplications"),
- "+;description;category;categoryDisplayName;packageNames",
- single_result=False,
- start=0)
+ query = self.__model.query(("http://online.gnome.org/p/application", "getPopularApplications"),
+ "+;description;category;categoryDisplayName;packageNames",
+ single_result=False,
+ start=0)
- query.add_handler(self.__on_got_global_popular_apps)
- query.add_error_handler(lambda code, msg: self.__on_query_error("getPopularApplications", code, msg))
- query.execute()
+ query.add_handler(self.__on_got_global_popular_apps)
+ query.add_error_handler(lambda code, msg: self.__on_query_error("getPopularApplications", code, msg))
+ query.execute()
+ else:
+ if not self.__got_popular_apps and not self.__get_popular_apps_pending:
+ _logger.debug("will get popular apps from http")
+ self.__get_popular_apps_pending = True
+ downloader = AppsHttpDownloader('/xml/popularapplications',
+ self.__on_got_global_popular_apps_from_http)
+ downloader.go()
- def __on_server_connected(self):
+ # getAllApplications is just too slow over XMPP, so we always do it over HTTP
+ #
+ # We possibly should remove self.__got_all_apps and just re-download whenever we
+ # become ready, since there might have been changes to the apps database while
+ # we were disconnected.
+ #
+ # We probably should also redownload periodically even if we stay connected.
+ #
+ # These changes would require some careful examination of the caching setup to
+ # avoid overloading the server.
+ #
if not self.__got_all_apps and not self.__get_all_apps_pending:
- ## getAllApplications is just too slow over XMPP
-
## do the getAllApplications last since it emits the all-apps-loaded signal when complete
#query = self.__model.query(("http://online.gnome.org/p/application", "getAllApplications"),
@@ -353,7 +357,6 @@
self.__on_got_global_all_apps_from_http)
downloader.go()
-
def __on_query_error(self, where, error_code, message):
_logger.warn("Query '" + where + "' failed, code " + str(error_code) + " message: " + str(message))
Modified: bigboard/trunk/bigboard/stocks/people/PeopleStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/PeopleStock.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/stocks/people/PeopleStock.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -122,7 +122,7 @@
self.__remove_user(contact, self.__contact_box, self.__contact_items)
def __on_local_user_added(self, list, user):
- if user.resource_id == self.__model.self_id:
+ if user == self.__model.self_resource:
return
self.__add_user(user, self.__local_box, self.__local_items)
Modified: bigboard/trunk/bigboard/stocks/people/peoplebrowser.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/peoplebrowser.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/stocks/people/peoplebrowser.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -240,7 +240,7 @@
self.__people_list.remove_user(contact, CONTACTS)
def __on_local_user_added(self, list, user):
- if user.resource_id == self.__model.self_id:
+ if user == self.__model.self_resource:
return
self.__people_list.add_user(user, LOCAL_PEOPLE)
Modified: bigboard/trunk/bigboard/stocks/people/peoplewidgets.py
===================================================================
--- bigboard/trunk/bigboard/stocks/people/peoplewidgets.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/stocks/people/peoplewidgets.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -66,7 +66,7 @@
self.__current_track = None
self.__current_track_timeout = None
- query = model.query_resource(self.resource.resource_id, "currentTrack +;currentTrackPlayTime")
+ query = model.query_resource(self.resource, "currentTrack +;currentTrackPlayTime")
query.add_handler(self.__update_current_track)
query.execute()
@@ -445,7 +445,7 @@
self.connect_resource(self.__update_loved_accounts, "lovedAccounts")
self.connect_resource(self.__update_local_buddy, "localBuddy")
- query = DataModel(bigboard.globals.server_name).query_resource(self.resource.resource_id, "lovedAccounts +")
+ query = DataModel(bigboard.globals.server_name).query_resource(self.resource, "lovedAccounts +")
query.add_handler(self.__update_loved_accounts)
query.execute()
Modified: bigboard/trunk/bigboard/stocks/self/SelfStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/self/SelfStock.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/bigboard/stocks/self/SelfStock.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -278,13 +278,10 @@
self._model = DataModel(globals.server_name)
self.__myself = None
- self._model.add_initialized_handler(self.__on_initialized)
- self._model.add_connected_handler(self.__on_connected)
- if self._model.self_id:
- self.__on_connected()
- else:
- _logger.debug("datamodel not connected, deferring")
+ self._model.add_ready_handler(self.__on_ready)
+ self.info_loaded = False
+
self.__slideout = None
self.__slideout_display = None
@@ -295,6 +292,9 @@
#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 __on_sync_prelight(self, prelighted):
if prelighted:
self._bulb.set_property("image-name", 'bigboard-bulb')
@@ -319,31 +319,32 @@
self.__fus_service = None
pass
- def __on_initialized(self):
- if not self._model.connected:
+ def __info_now_loaded(self):
+ if not self.info_loaded:
+ self.info_loaded = True
self.emit('info-loaded')
- def __on_connected(self):
- _logger.debug("doing datamodel connected handler")
- self._box.set_child_visible(self._signin, self._model.self_id == None)
- self._box.set_child_visible(self._whereim_box, self._model.self_id != None)
+ def __on_ready(self):
+ self._box.set_child_visible(self._signin, self._model.self_resource == None)
+ self._box.set_child_visible(self._whereim_box, self._model.self_resource != None)
- query = self._model.query_resource(self._model.self_id, "+;lovedAccounts +")
- query.add_handler(self.__on_got_self)
- query.add_error_handler(self.__on_self_datamodel_error)
- query.execute()
+ if self._model.self_resource != None:
+ query = self._model.query_resource(self._model.self_resource, "+;lovedAccounts +")
+ query.add_handler(self.__on_got_self)
+ query.add_error_handler(self.__on_self_datamodel_error)
+ query.execute()
+ else:
+ self.__info_now_loaded()
- def __on_datamodel_error(self, code, str):
- _logger.error("datamodel error %s: %s", code, str)
-
def __on_self_datamodel_error(self, code, str):
_logger.error("datamodel error %s: %s", code, str)
- self.emit('info-loaded')
+ self.__info_now_loaded()
def __on_got_self(self, myself):
self.__myself = myself
myself.connect(self.__on_self_changed)
- self.__on_self_changed(myself)
+ 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)
@@ -419,4 +420,3 @@
if self.__slideout_display != None:
self.__slideout_display.update_self(myself)
- self.emit("info-loaded")
Modified: bigboard/trunk/main.py
===================================================================
--- bigboard/trunk/main.py 2007-11-08 21:24:37 UTC (rev 6884)
+++ bigboard/trunk/main.py 2007-11-08 21:27:52 UTC (rev 6885)
@@ -446,9 +446,12 @@
self.__self_stock = self._exchanges[self.__hardcoded_stocks[0]].get_pymodule()
self.__search_stock = self._exchanges[self.__hardcoded_stocks[1]].get_pymodule()
gobject.idle_add(self.__sync_listing)
-
- self.__self_stock.connect('info-loaded', lambda *args: self.__initial_appearance())
+ if self.__self_stock.info_loaded:
+ self.__initial_appearance()
+ else:
+ self.__self_stock.connect('info-loaded', lambda *args: self.__initial_appearance())
+
## visible=True means we never hide, visible=False means we "autohide" and popout
## when the hotkey or applet is used
gconf_client.notify_add(GCONF_PREFIX + 'visible', self.__sync_visible_mode)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]