Fixing empathy in ubuntu 12.10, 13.04, 13.10, and 14.04

I recently decided I'll upgrade my Ubuntu 12.04 to Quantal 12.10.

There wasn't a lot of new feature, and I was really disappointed by the changes in empathy.

Empathy was not usable anymore. I installed pidgin and recalled that it wasn't correctly integrated with SIP technology which was a no-go for me.

I felt trapped with this upgrade: the version of empathy shipped with 12.04 was way better than what I was confronted in 12.10 (and 13.04, and 13.10, and 14.04)... Hopefully I managed to fix all this to my needs. Here's what I did.

Note

And when I upgraded to 13.04 (then 13.10, and 14.04), I could make the same complaints, and the same fixes.

The Griefs

Bugs were reported:

  • the contact list has HUGE avatars and you can't choose to have smaller ones: what happened exactly is that the contact list skin drastically changed in a very un-wise move: each avatar took 48 pixel height, leading to un-manageably long, multi-screen tall contact list. (30 people are awaiting on this bug resolution). Worse: the option to get compact list was removed and more than 96 people are awaiting for this option to come back. A bug report was also reported on bugzilla at least twice.

    • I'm providing a fix to set avatar icon size.
  • The contact list is not anymore sorted by status: yes, this means that connected and away contacts are mixed, if you have more than 10 contacts using google talk for instance, they probably be growing your contact list as away. You'll have to painfully filter by eye the ones that are really available and active.

    • I'm providing a quick fix to this also.
  • You can't phone using your SIP account to your address book phone numbers.

    • Hit only 12.10, on which I've provided a fix by cherry-picking the upstream bug resolution
  • No more notification of new message (launchpad report). What a failure ! I could hear message alert sound whenever I received a new message but could not get to see the incoming messages as there is no way to make the messaging window appear without the messaging indicator. Additionaly for the same reason, I could not answer to standard events as standard requests from new contacts to share our visibility status despite a pretty notification message displayed on the top right corner of my screen telling me that the request was received (and that the contact awaited an answer).

    • This one was Ubuntu's fault, and can be fixed by installing telepathy-indicator, more info following

Of course, I'm not the only one to have expressed deep concerns on theses empathy regressions.

The Cure

TL;DR

Provided you are on 64bit architecture, here are the new DEB files:

How you could patch it yourself the next time

Open-source matters. Let me show you why:

Let's get the source code:

cd /tmp
apt-get source empathy

Note that this last command will get the source package of empathy, and apply ubuntu specific patches.

Now, we'll proceed with getting all build dependencies required for compilation of empathy sources:

apt-get build-dep empathy

With Ubuntu 12.10 (13.04, 13.10, and 14.04), the version of empathy is 3.6.0.3 (3.6.4, 3.8.4, and 3.8.6 respectively). We will now access to the source and make some modifications:

cd empathy-*
sed -ri 's/#define AVATAR_SIZE 48/#define AVATAR_SIZE 24/g' \
    libempathy-gtk/empathy-roster-contact.c

I'll let you tweak the size in this line, it's expressed in pixel. New value is 24 here, instead of 48.

Optionally, I found that the SIP bug that prevented to call landlines phones was corrected in empathy 3.7.4. And that it wasn't included in 12.10 but was in 13.04 and newer.

If using 12.10 and interested by this feature, you should cherry-pick the patch:

wget -O - "https://bug691195.bugzilla-attachments.gnome.org/attachment.cgi?id=232954&action=diff&collapsed=&context=patch&format=raw&headers=1" | patch -p 1

Optionally, I patched the sort algorithm to sort by contact status before sorting by alphabetical order, if you want to get this patch:

cat <<EOF | patch -p 1
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index c3ae66e..77d76d6 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -188,6 +188,10 @@ add_roster_contact (EmpathyRosterView *self,
   g_signal_connect (contact, "notify::alias",
       G_CALLBACK (roster_contact_changed_cb), self);

+  /* Need to resort if presence is changed */
+  g_signal_connect (contact, "notify::presence-type",
+      G_CALLBACK (roster_contact_changed_cb), self);
+
   gtk_widget_show (contact);
   gtk_container_add (GTK_CONTAINER (self), contact);

@@ -633,19 +637,76 @@ compare_roster_contacts_by_alias (EmpathyRosterContact *a,
 }

 static gint
+presence_sort_key (FolksPresenceType presence) {
+
+  switch (presence)
+    {
+      case FOLKS_PRESENCE_TYPE_UNSET:
+      case FOLKS_PRESENCE_TYPE_OFFLINE:
+      case FOLKS_PRESENCE_TYPE_UNKNOWN:
+      case FOLKS_PRESENCE_TYPE_ERROR:
+        return 0;
+
+      case FOLKS_PRESENCE_TYPE_HIDDEN:
+      case FOLKS_PRESENCE_TYPE_EXTENDED_AWAY:
+        return 1;
+
+      case FOLKS_PRESENCE_TYPE_AWAY:
+        return 2;
+
+      case FOLKS_PRESENCE_TYPE_BUSY:
+      case FOLKS_PRESENCE_TYPE_AVAILABLE:
+        return 3;
+
+      default:
+        g_warning ("Unknown FolksPresenceType: %d", presence);
+        return 0;
+  }
+
+}
+
+static gint
+compare_roster_contacts_by_presence (EmpathyRosterContact *a,
+    EmpathyRosterContact *b)
+{
+  FolksPresenceType presence_a, presence_b;
+  FolksIndividual *ind_a, *ind_b;
+  gint key_a, key_b;
+
+  ind_a = empathy_roster_contact_get_individual (a);
+  ind_b = empathy_roster_contact_get_individual (b);
+
+  presence_a = folks_presence_details_get_presence_type (
+      FOLKS_PRESENCE_DETAILS (ind_a));
+  presence_b = folks_presence_details_get_presence_type (
+      FOLKS_PRESENCE_DETAILS (ind_b));
+
+  key_a = presence_sort_key(presence_a);
+  key_b = presence_sort_key(presence_b);
+
+  return key_b - key_a;
+}
+
+static gint
 compare_roster_contacts_no_group (EmpathyRosterView *self,
     EmpathyRosterContact *a,
     EmpathyRosterContact *b)
 {
   gboolean top_a, top_b;
+  gint presence_cmp;

   top_a = contact_in_top (self, a);
   top_b = contact_in_top (self, b);

   if (top_a == top_b)
-    /* Both contacts are in the top of the roster (or not). Sort them
-     * alphabetically */
-    return compare_roster_contacts_by_alias (a, b);
+    {
+      /* Both contacts are in the top of the roster (or not). Sort them
+       * by status, then alphabetically */
+      presence_cmp = compare_roster_contacts_by_presence(a, b);
+      if (presence_cmp == 0)
+        return compare_roster_contacts_by_alias (a, b);
+      return presence_cmp;
+    }
   else if (top_a)
     return -1;
   else
@@ -676,14 +737,18 @@ compare_roster_contacts_with_groups (EmpathyRosterView *self,
     EmpathyRosterContact *b)
 {
   const gchar *group_a, *group_b;
+  gint presence_cmp;

   group_a = empathy_roster_contact_get_group (a);
   group_b = empathy_roster_contact_get_group (b);

-  if (!tp_strdiff (group_a, group_b))
+  if (!tp_strdiff (group_a, group_b)) {
     /* Same group, compare the contacts */
-    return compare_roster_contacts_by_alias (a, b);
-
+    presence_cmp = compare_roster_contacts_by_presence(a, b);
+    if (presence_cmp == 0)
+      return compare_roster_contacts_by_alias (a, b);
+    return presence_cmp;
+  }
   /* Sort by group */
   return compare_group_names (group_a, group_b);
 }
EOF

And proceeded with the recompilation of the debian package:

dpkg-buildpackage -rfakeroot -b

After some time waiting for the compilation to finish, you should have some new 'deb' packages in /tmp:

cd ..
ls -al *.deb

Before installing these packages, you can make sure to remove any empathy/telepathy process:

killall telepathy-gabble empathy-auth-client empathy-chat \
        telepathy-idle telepathy-logger telepathy-rakia  \
        telepathy-salut telepathy-haze mission-control-5 \
        empathy

And then install the new empathy:

sudo dpkg -i empathy_*.deb

If you applied the SIP patch:

sudo dpkg -i account-plugin-sip_*.deb

Then run empathy by any usual way you could think of.

More info

  • http://www.insign.ch Bachi

    The commit that removed the settings is here: https://git.gnome.org/browse/empathy/commit/?id=f58d68ddddf15dfe4e0d49af86e2add3c606316e – why not asking whether they could undo that? It seems the better way than patching in the long run. I certainly sent an email.

    • http://www.kalysto.org vaab

      I agree that patching is never the better way in the long run. But as the contact list was completely re-skinned, I don’t think that simply reverting this commit will help. There must have been discussion on this topic and the removal of this feature was obviously not accidental. I would be happy to know where we could get information on future developments or current discussions. Besides, it should also be noted that 12.10 Ubuntu has a quite old version (3.6.3) of empathy and that Gnome current version is around 3.8.1 and the last version is not so straightforward to install on 12.10 Ubuntu, and having used and tested this last version might be a natural prerequisite to any complaints.

      In the meantime, this patch brought my empathy back up to my expectation.

  • M. Rubio-Roy

    Either I’m doing something wrong or this doesn’t work on Ubuntu 14.04 with empathy 3.8.6

    • http://www.kalysto.org vaab

      I’ve just copy-pasted all the instruction and it worked for me (on 14.04 with empathy 3.8.6). Are you sure that you’ve applied exactly all the instruction ?

  • Valentino

    It work’s perfectly on ubuntu 14.04. It’s the first time in my life that I’ve modified a source code for my own use. I don’t understand the changes on empathy and I particulary hate the big size on contact list.

    Now I can still use empathy on my way.

    Thank you, thank you very much!

  • Pingback: Ubuntu:Can I make user list in Empathy more compressed? – Ubuntu Linux Questions()