r3624 - in trunk/src/target/OM-2007.2/applications/openmoko-messages2: . src
chris at sita.openmoko.org
chris at sita.openmoko.org
Mon Dec 10 17:07:20 CET 2007
Author: chris
Date: 2007-12-10 17:07:18 +0100 (Mon, 10 Dec 2007)
New Revision: 3624
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-contacts.c
trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-notes.c
trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-utils.c
trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms.h
Log:
* src/sms-contacts.c: (contacts_iter_compare_func),
(sms_contacts_page_new):
Sort higher priorities first, rather than last and add a special
'unknown' contact for messages from people not in the list
* src/sms-notes.c: (page_shown), (sms_notes_page_new):
Handle the 'unknown' contact
* src/sms-utils.c: (sms_get_selected_contact), (set_message_count),
(sms_contacts_note_count_update):
Add code to collect messages from contacts not in the contact list and
update the count for the 'unknown' contact
* src/sms.h:
Add a list for unassigned contacts, add an 'assigned' field to
SmsNoteCountData to detect when notes aren't assigned to a contact
Modified: trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog 2007-12-10 10:56:49 UTC (rev 3623)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog 2007-12-10 16:07:18 UTC (rev 3624)
@@ -1,3 +1,22 @@
+2007-12-10 Chris Lord <chris at openedhand.com>
+
+ * src/sms-contacts.c: (contacts_iter_compare_func),
+ (sms_contacts_page_new):
+ Sort higher priorities first, rather than last and add a special
+ 'unknown' contact for messages from people not in the list
+
+ * src/sms-notes.c: (page_shown), (sms_notes_page_new):
+ Handle the 'unknown' contact
+
+ * src/sms-utils.c: (sms_get_selected_contact), (set_message_count),
+ (sms_contacts_note_count_update):
+ Add code to collect messages from contacts not in the contact list and
+ update the count for the 'unknown' contact
+
+ * src/sms.h:
+ Add a list for unassigned contacts, add an 'assigned' field to
+ SmsNoteCountData to detect when notes aren't assigned to a contact
+
2007-12-07 Chris Lord <chris at openedhand.com>
* src/sms-contacts.c: (contacts_added_cb), (contacts_changed_cb),
Modified: trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-contacts.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-contacts.c 2007-12-10 10:56:49 UTC (rev 3623)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-contacts.c 2007-12-10 16:07:18 UTC (rev 3624)
@@ -177,7 +177,7 @@
gtk_tree_model_get (model, a, COL_PRIORITY, &prio1, -1);
gtk_tree_model_get (model, b, COL_PRIORITY, &prio2, -1);
- if (prio1 != prio2) return prio1 - prio2;
+ if (prio1 != prio2) return prio2 - prio1;
gtk_tree_model_get (model, a, COL_NAME, &name1, -1);
gtk_tree_model_get (model, b, COL_NAME, &name2, -1);
@@ -268,6 +268,11 @@
data->numbers = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, (GDestroyNotify)g_free);
+ /* Insert contact for 'unknown' messages */
+ gtk_list_store_insert_with_values (
+ GTK_LIST_STORE (data->contacts_store), NULL, 0,
+ COL_UID, NULL, COL_NAME, "Unknown sender", COL_PRIORITY, 5, -1);
+
/* Create filter */
data->contacts_filter = gtk_tree_model_filter_new (
data->contacts_store, NULL);
Modified: trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-notes.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-notes.c 2007-12-10 10:56:49 UTC (rev 3623)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-notes.c 2007-12-10 16:07:18 UTC (rev 3624)
@@ -88,7 +88,37 @@
if (!open) return;
- if (!(contact = sms_get_selected_contact (data))) return;
+ if (!(contact = sms_get_selected_contact (data))) {
+ GList *u, *components = NULL;
+
+ /* Assume the 'unknown' contact was selected */
+ data->author_icon = g_object_ref (data->no_photo);
+
+ /* Manually feed the notes in - this is a bit naughty as if
+ * they change, we won't be notified...
+ */
+ for (u = data->unassigned_notes; u; u = u->next) {
+ JanaComponent *component;
+ const gchar *uid = (const gchar *)u->data;
+
+ component = jana_store_get_component (data->notes, uid);
+ if (component) components = g_list_prepend (
+ components, component);
+ }
+
+ store_view = jana_store_get_view (data->notes);
+ jana_gtk_note_store_set_view (JANA_GTK_NOTE_STORE (
+ data->note_store), store_view);
+ note_changed_cb (store_view, components, data);
+ g_signal_emit_by_name (store_view, "added", components);
+
+ for (u = components; u; u = u->next) {
+ g_object_unref (G_OBJECT (u->data));
+ }
+ g_list_free (components);
+
+ return;
+ }
data->author_icon = sms_contact_load_photo (contact);
if (!data->author_icon)
@@ -401,6 +431,7 @@
data->note_count = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify)g_free, (GDestroyNotify)free_count_data);
data->note_count_idle = 0;
+ data->unassigned_notes = NULL;
/* Create note store */
data->notes = jana_ecal_store_new (JANA_COMPONENT_NOTE);
Modified: trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-utils.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-utils.c 2007-12-10 10:56:49 UTC (rev 3623)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-utils.c 2007-12-10 16:07:18 UTC (rev 3624)
@@ -39,6 +39,7 @@
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return NULL;
gtk_tree_model_get (model, &iter, COL_UID, &data->author_uid, -1);
+ if (!data->author_uid) return NULL;
if (!e_book_get_contact (data->ebook,
data->author_uid, &contact, &error)) {
@@ -110,10 +111,29 @@
return pixbuf;
}
+static void
+set_message_count (SmsData *data, GtkTreeIter *iter, gint read, gint unread,
+ gboolean unknown)
+{
+ gchar *detail;
+ gint priority;
+
+ detail = g_strdup_printf ("%d unread\n%d read", unread, read);
+ priority = unread ? (unknown ? 15 : 10) : (unknown ? 5 : 0);
+ gtk_list_store_set (GTK_LIST_STORE (data->contacts_store),
+ iter, COL_DETAIL, detail, COL_PRIORITY, priority, -1);
+ g_free (detail);
+}
+
gboolean
sms_contacts_note_count_update (SmsData *data)
{
- GtkTreeIter iter;
+ static guint assignment = 1;
+ GHashTable *indexed_uids;
+ GList *ncdatas, *n;
+ gint unread, read;
+
+ GtkTreeIter iter, unknown_iter;
if (!gtk_tree_model_get_iter_first (data->contacts_store, &iter)) {
data->note_count_idle = 0;
@@ -123,12 +143,14 @@
do {
gint i;
EContact *contact;
- gchar *uid, *detail;
- gint unread, read;
+ gchar *uid;
gtk_tree_model_get (data->contacts_store, &iter, COL_UID,
&uid, -1);
- if (!uid) continue;
+ if (!uid) {
+ unknown_iter = iter;
+ continue;
+ }
if (!e_book_get_contact (data->ebook, uid, &contact, NULL)) {
g_free (uid);
@@ -150,15 +172,57 @@
read += g_list_length (ncdata->read);
unread += g_list_length (ncdata->unread);
+ ncdata->assigned = assignment;
}
- detail = g_strdup_printf ("%d unread\n%d read", unread, read);
- gtk_list_store_set (GTK_LIST_STORE (data->contacts_store),
- &iter, COL_DETAIL, detail, -1);
- g_free (detail);
+ set_message_count (data, &iter, read, unread, FALSE);
} while (gtk_tree_model_iter_next (data->contacts_store, &iter));
data->note_count_idle = 0;
+ /* Make a list of unassigned note UIDs */
+ while (data->unassigned_notes) {
+ g_free (data->unassigned_notes->data);
+ data->unassigned_notes = g_list_delete_link (
+ data->unassigned_notes, data->unassigned_notes);
+ }
+ indexed_uids = g_hash_table_new (g_str_hash, g_str_equal);
+ ncdatas = g_hash_table_get_values (data->note_count);
+ read = 0;
+ unread = 0;
+ for (n = ncdatas; n; n = n->next) {
+ gint i;
+ GList *u;
+ SmsNoteCountData *ncdata = (SmsNoteCountData *)n->data;
+
+ if (ncdata->assigned == assignment) continue;
+
+ for (i = 0; i < 2; i++) {
+ for (u = i ? ncdata->read : ncdata->unread;
+ u; u = u->next) {
+ gchar *uid = (gchar *)u->data;
+ if (!g_hash_table_lookup (indexed_uids, uid)) {
+ g_hash_table_insert (indexed_uids, uid,
+ GINT_TO_POINTER (1));
+ data->unassigned_notes =
+ g_list_prepend (
+ data->unassigned_notes,
+ g_strdup (uid));
+ if (i) read ++;
+ else unread ++;
+ }
+ }
+ }
+ }
+ g_list_free (ncdatas);
+ g_hash_table_destroy (indexed_uids);
+
+ set_message_count (data, &unknown_iter, read, unread, TRUE);
+
+ /* Add 2 to assignment so that when it eventually wraps (which will
+ * almost certainly not happen, but still), it won't ever equal 0.
+ */
+ assignment += 2;
+
return FALSE;
}
Modified: trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms.h 2007-12-10 10:56:49 UTC (rev 3623)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms.h 2007-12-10 16:07:18 UTC (rev 3624)
@@ -30,6 +30,7 @@
typedef struct {
GList *unread; /* List of JanaNote uids for unread messages */
GList *read; /* The same for read messages */
+ gint assigned;
} SmsNoteCountData;
typedef struct {
@@ -39,6 +40,7 @@
GtkTreeModel *note_filter;
GHashTable *note_count;
guint note_count_idle;
+ GList *unassigned_notes;
EBook *ebook;
GtkTreeModel *contacts_store;
More information about the commitlog
mailing list