Hide google contacts not in My Contacts
These contacts are autogenerated stuff which is not supposed to be visible in the UI.
This commit is contained in:
parent
9335c9b9bc
commit
a3eaab0b01
4 changed files with 48 additions and 0 deletions
|
@ -277,7 +277,15 @@ public class Contacts.Contact : GLib.Object {
|
|||
if (store.type_id == "telepathy" &&
|
||||
store.trust_level == PersonaStoreTrust.NONE)
|
||||
return true;
|
||||
|
||||
// Filter out google contacts not in "My Contacts" as these are not really useful
|
||||
if (store.type_id == "eds" && esource_uid_is_google (store.id)) {
|
||||
var g = persona as GroupDetails;
|
||||
if (g != null && !g.groups.contains (eds_personal_google_group_name ()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <libedataserver/e-source.h>
|
||||
#include <libedataserver/e-source-group.h>
|
||||
#include <libedataserver/e-uid.h>
|
||||
#include <libedataserver/eds-version.h>
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
char *contacts_eds_local_store = NULL;
|
||||
|
@ -572,6 +573,39 @@ void contacts_ensure_eds_accounts (void)
|
|||
}
|
||||
|
||||
|
||||
/* This is an enourmous hack to find google eds contacts that are
|
||||
in the "My Contacts" system group. */
|
||||
char *
|
||||
eds_personal_google_group_name (void)
|
||||
{
|
||||
static char *name = NULL;
|
||||
char *domain;
|
||||
|
||||
if (name == NULL) {
|
||||
domain = g_strdup_printf ("evolution-data-server-%d.%d\n",
|
||||
EDS_MAJOR_VERSION,
|
||||
EDS_MINOR_VERSION + ((EDS_MINOR_VERSION + 1) % 2));
|
||||
name = dgettext (domain, "Personal");
|
||||
g_free (domain);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
gboolean
|
||||
contacts_esource_uid_is_google (const char *uid)
|
||||
{
|
||||
if (contacts_source_list) {
|
||||
ESource *source = e_source_list_peek_source_by_uid (contacts_source_list, uid);
|
||||
if (source) {
|
||||
const char *relative_uri = e_source_peek_relative_uri (source);
|
||||
if (relative_uri && g_str_has_suffix (relative_uri, "@gmail.com"))
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const char *
|
||||
contacts_lookup_esource_name_by_uid (const char *uid)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
void contacts_ensure_eds_accounts (void);
|
||||
extern char *contacts_eds_local_store;
|
||||
const char *contacts_lookup_esource_name_by_uid (const char *uid);
|
||||
gboolean contacts_esource_uid_is_google (const char *uid);
|
||||
char *eds_personal_google_group_name (void);
|
||||
|
|
|
@ -31,4 +31,8 @@ namespace Contacts {
|
|||
public static string? eds_local_store;
|
||||
[CCode (cname = "contacts_lookup_esource_name_by_uid")]
|
||||
public static unowned string? lookup_esource_name_by_uid (string uid);
|
||||
[CCode (cname = "contacts_esource_uid_is_google")]
|
||||
public static bool esource_uid_is_google (string uid);
|
||||
[CCode (cname = "eds_personal_google_group_name")]
|
||||
public static unowned string? eds_personal_google_group_name ();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue