* mu: add the backend for freq information for contacts

This commit is contained in:
djcb 2013-06-16 23:02:19 +03:00
parent 401f30ee26
commit bfe74d1d11
5 changed files with 17 additions and 11 deletions

View File

@ -338,7 +338,7 @@ each_contact (const char *group, ContactInfo *ci, EachContactData *ecdata)
}
ecdata->_func (ci->_email, ci->_name, ci->_personal,
ci->_tstamp, ecdata->_user_data);
ci->_tstamp, ci->_freq, ecdata->_user_data);
++ecdata->_num;
}

View File

@ -97,13 +97,15 @@ size_t mu_contacts_count (MuContacts *self);
/**
* call called for mu_contacts_foreach; returns the e-mail address,
* name (which may be NULL) , whether the message is 'personal', and
* the timestamp for the address
* name (which may be NULL) , whether the message is 'personal', the
* timestamp for the address (when it was last seen), and the
* frequency (in how many message did this contact participate)
*
*/
typedef void (*MuContactsForeachFunc) (const char *email, const char *name,
gboolean personal,
time_t tstamp, gpointer user_data);
time_t tstamp, unsigned freq,
gpointer user_data);
/**
* call a function for either each contact, or each contact satisfying

View File

@ -294,7 +294,7 @@ typedef struct _ECData ECData;
static void
each_contact (const char *email, const char *name, gboolean personal,
time_t tstamp, ECData *ecdata)
time_t tstamp, unsigned freq, ECData *ecdata)
{
if (ecdata->personal && !personal)
return;

View File

@ -547,7 +547,7 @@ typedef struct _SexpData SexpData;
static void
each_contact_sexp (const char *email, const char *name, gboolean personal,
time_t tstamp, SexpData *sdata)
time_t tstamp, unsigned freq, SexpData *sdata)
{
char *escmail;
@ -569,11 +569,14 @@ each_contact_sexp (const char *email, const char *name, gboolean personal,
if (name) {
char *escname;
escname = mu_str_escape_c_literal (name, TRUE);
g_string_append_printf (sdata->gstr, "(:name %s :mail %s)\n",
escname, escmail);
g_string_append_printf (sdata->gstr,
"(:name %s :mail %s :tstamp %u :freq %u)\n",
escname, escmail, (unsigned)tstamp, freq);
g_free (escname);
} else
g_string_append_printf (sdata->gstr, "(:mail %s)\n", escmail);
g_string_append_printf (sdata->gstr,
"(:mail %s :tstamp %u :freq %u)\n",
escmail, (unsigned)tstamp, freq);
g_free (escmail);
}

View File

@ -65,7 +65,8 @@ struct _Contact {
typedef struct _Contact Contact;
static Contact*
contact_new (const char *email, const char *name, gboolean personal, size_t tstamp)
contact_new (const char *email, const char *name,
gboolean personal, size_t tstamp)
{
Contact *contact;
@ -92,7 +93,7 @@ contact_destroy (Contact *contact)
static void
each_contact (const char *email, const char *name, gboolean personal,
time_t tstamp, GSList **lst)
time_t tstamp, unsigned freq, GSList **lst)
{
Contact *contact;