Fix hard dependency on AccountsService (lp 1311938) (debian 745548)

This commit is contained in:
Sean Davis 2014-05-14 07:13:04 -04:00
parent 71f1a53274
commit 323ae84363
2 changed files with 58 additions and 45 deletions

View File

@ -223,6 +223,15 @@ class MugshotWindow(Window):
face = os.path.join(home, '.face') face = os.path.join(home, '.face')
logger.debug('Checking AccountsService for profile image') logger.debug('Checking AccountsService for profile image')
image = self.accounts_service_get_user_image() image = self.accounts_service_get_user_image()
# AccountsService may not be supported or desired.
if image is None:
logger.debug("AccountsService is not supported.")
self.updated_image = face
self.set_user_image(face)
# If it is supported, process and compare to ~/.face
else:
logger.debug('Found profile image: %s' % str(image)) logger.debug('Found profile image: %s' % str(image))
if os.path.isfile(face): if os.path.isfile(face):
@ -435,6 +444,7 @@ class MugshotWindow(Window):
def accounts_service_get_user_image(self): def accounts_service_get_user_image(self):
"""Get user profile image using AccountsService.""" """Get user profile image using AccountsService."""
try:
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
result = bus.call_sync('org.freedesktop.Accounts', result = bus.call_sync('org.freedesktop.Accounts',
'/org/freedesktop/Accounts', '/org/freedesktop/Accounts',
@ -447,19 +457,22 @@ class MugshotWindow(Window):
None) None)
(path,) = result.unpack() (path,) = result.unpack()
variant = GLib.Variant('(s)',
('org.freedesktop.Accounts.User',)
)
result = bus.call_sync('org.freedesktop.Accounts', result = bus.call_sync('org.freedesktop.Accounts',
path, path,
'org.freedesktop.DBus.Properties', 'org.freedesktop.DBus.Properties',
'GetAll', 'GetAll',
GLib.Variant('(s)', variant,
('org.freedesktop.Accounts.User',)
),
GLib.VariantType.new('(a{sv})'), GLib.VariantType.new('(a{sv})'),
Gio.DBusCallFlags.NONE, Gio.DBusCallFlags.NONE,
-1, -1,
None) None)
(props,) = result.unpack() (props,) = result.unpack()
return props['IconFile'] return props['IconFile']
except GLib.GError:
return None
def accounts_service_set_user_image(self, filename): def accounts_service_set_user_image(self, filename):
"""Set user profile image using AccountsService.""" """Set user profile image using AccountsService."""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-04-22 06:13-0400\n" "POT-Creation-Date: 2014-05-14 07:11-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -61,7 +61,7 @@ msgstr ""
msgid "Browse…" msgid "Browse…"
msgstr "" msgstr ""
#: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:573 #: ../data/ui/MugshotWindow.ui.h:9 ../mugshot/MugshotWindow.py:591
msgid "Mugshot" msgid "Mugshot"
msgstr "" msgstr ""
@ -131,37 +131,37 @@ msgid "Retry"
msgstr "" msgstr ""
#. Password was incorrect, complain. #. Password was incorrect, complain.
#: ../mugshot/MugshotWindow.py:327 #: ../mugshot/MugshotWindow.py:341
msgid "Authentication Failed" msgid "Authentication Failed"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:328 #: ../mugshot/MugshotWindow.py:342
msgid "User details were not updated." msgid "User details were not updated."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:495 #: ../mugshot/MugshotWindow.py:513
msgid "Update Pidgin buddy icon?" msgid "Update Pidgin buddy icon?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:496 #: ../mugshot/MugshotWindow.py:514
msgid "Would you also like to update your Pidgin buddy icon?" msgid "Would you also like to update your Pidgin buddy icon?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:574 #: ../mugshot/MugshotWindow.py:592
msgid "Enter your password to change user details." msgid "Enter your password to change user details."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:576 #: ../mugshot/MugshotWindow.py:594
msgid "" msgid ""
"This is a security measure to prevent unwanted updates\n" "This is a security measure to prevent unwanted updates\n"
"to your personal information." "to your personal information."
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:727 #: ../mugshot/MugshotWindow.py:745
msgid "Update LibreOffice user details?" msgid "Update LibreOffice user details?"
msgstr "" msgstr ""
#: ../mugshot/MugshotWindow.py:728 #: ../mugshot/MugshotWindow.py:746
msgid "Would you also like to update your user details in LibreOffice?" msgid "Would you also like to update your user details in LibreOffice?"
msgstr "" msgstr ""