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,20 +223,29 @@ 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()
logger.debug('Found profile image: %s' % str(image))
if os.path.isfile(face): # AccountsService may not be supported or desired.
if os.path.samefile(image, face): if image is None:
self.updated_image = face 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))
if os.path.isfile(face):
if os.path.samefile(image, face):
self.updated_image = face
else:
self.updated_image = None
self.set_user_image(face)
elif os.path.isfile(image):
self.updated_image = image
self.set_user_image(image)
else: else:
self.updated_image = None self.updated_image = None
self.set_user_image(face) self.set_user_image(None)
elif os.path.isfile(image):
self.updated_image = image
self.set_user_image(image)
else:
self.updated_image = None
self.set_user_image(None)
# Search /etc/passwd for the current user's details. # Search /etc/passwd for the current user's details.
logger.debug('Getting user details from /etc/passwd') logger.debug('Getting user details from /etc/passwd')
@ -435,31 +444,35 @@ 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."""
bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) try:
result = bus.call_sync('org.freedesktop.Accounts', bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None)
'/org/freedesktop/Accounts', result = bus.call_sync('org.freedesktop.Accounts',
'org.freedesktop.Accounts', '/org/freedesktop/Accounts',
'FindUserByName', 'org.freedesktop.Accounts',
GLib.Variant('(s)', (username,)), 'FindUserByName',
GLib.VariantType.new('(o)'), GLib.Variant('(s)', (username,)),
Gio.DBusCallFlags.NONE, GLib.VariantType.new('(o)'),
-1, Gio.DBusCallFlags.NONE,
None) -1,
(path,) = result.unpack() None)
(path,) = result.unpack()
result = bus.call_sync('org.freedesktop.Accounts', variant = GLib.Variant('(s)',
path, ('org.freedesktop.Accounts.User',)
'org.freedesktop.DBus.Properties', )
'GetAll', result = bus.call_sync('org.freedesktop.Accounts',
GLib.Variant('(s)', path,
('org.freedesktop.Accounts.User',) 'org.freedesktop.DBus.Properties',
), 'GetAll',
GLib.VariantType.new('(a{sv})'), variant,
Gio.DBusCallFlags.NONE, GLib.VariantType.new('(a{sv})'),
-1, Gio.DBusCallFlags.NONE,
None) -1,
(props,) = result.unpack() None)
return props['IconFile'] (props,) = result.unpack()
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 ""