r3709 - in trunk/src/target/OM-2007.2/applications/openmoko-messages2: . src
chris at sita.openmoko.org
chris at sita.openmoko.org
Thu Dec 20 16:53:51 CET 2007
Author: chris
Date: 2007-12-20 16:53:50 +0100 (Thu, 20 Dec 2007)
New Revision: 3709
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-notes.c
Log:
* src/sms-notes.c: (note_changed_cb), (page_shown),
(sms_notes_data_func), (global_note_added_cb),
(notes_visible_func):
Only add messages once to the global note store, use Sent category to
decide whether to index on author/recipient (fixes incorrect unknown
messages count, bug #1144, #1142), fix avatar display, improve
sent/received filter.
Modified: trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog 2007-12-20 15:05:52 UTC (rev 3708)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/ChangeLog 2007-12-20 15:53:50 UTC (rev 3709)
@@ -1,5 +1,15 @@
2007-12-20 Chris Lord <chris at openedhand.com>
+ * src/sms-notes.c: (note_changed_cb), (page_shown),
+ (sms_notes_data_func), (global_note_added_cb),
+ (notes_visible_func):
+ Only add messages once to the global note store, use Sent category to
+ decide whether to index on author/recipient (fixes incorrect unknown
+ messages count, bug #1144, #1142), fix avatar display, improve
+ sent/received filter.
+
+2007-12-20 Chris Lord <chris at openedhand.com>
+
* src/sms-notes.c: (note_changed_cb), (page_shown):
Fix avatars not appearing when viewing messages from unknown contacts
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-20 15:05:52 UTC (rev 3708)
+++ trunk/src/target/OM-2007.2/applications/openmoko-messages2/src/sms-notes.c 2007-12-20 15:53:50 UTC (rev 3709)
@@ -70,6 +70,8 @@
if (!e_book_get_contact (data->ebook, uid, &contact, &error)) {
/* TODO: Unknown contact, probably */
} else {
+ if (data->recipient_icon)
+ g_object_unref (data->recipient_icon);
data->recipient_icon =
sms_contact_load_photo (contact);
g_object_unref (contact);
@@ -80,9 +82,6 @@
note_changed_cb_end:
/* Remove handlers */
if (data->recipient_number) {
- if ((!data->recipient_icon) && (data->no_photo))
- data->recipient_icon =
- g_object_ref (data->no_photo);
g_signal_handlers_disconnect_by_func (
store_view, note_changed_cb, data);
}
@@ -159,17 +158,18 @@
g_signal_connect (vadjust, "value-changed",
G_CALLBACK (scroll_changed_cb), data);
+ /* Assign the recipient photo to the generic avatar icon, in case we
+ * can't find it later.
+ */
+ if (data->no_photo)
+ data->recipient_icon = g_object_ref (data->no_photo);
+
if (!(contact = sms_get_selected_contact (data))) {
GList *u, *components = NULL;
/* Assume the 'unknown' contact was selected */
if (data->no_photo) {
data->author_icon = g_object_ref (data->no_photo);
-
- /* Without the author UID, we won't be able to
- * identify the recipient - so set their photo here
- */
- data->recipient_icon = g_object_ref (data->no_photo);
}
/* Manually feed the notes in - this is a bit naughty as if
@@ -300,7 +300,7 @@
GtkTreeIter *iter,
SmsData *data)
{
- gchar *author, *recipient, *body;
+ gchar *author, *recipient, *body, **categories;
JanaTime *created, *modified;
gboolean outgoing;
@@ -310,13 +310,21 @@
JANA_GTK_NOTE_STORE_COL_BODY, &body,
JANA_GTK_NOTE_STORE_COL_CREATED, &created,
JANA_GTK_NOTE_STORE_COL_MODIFIED, &modified,
+ JANA_GTK_NOTE_STORE_COL_CATEGORIES, &categories,
-1);
- if (recipient && data->recipient_number &&
- (strcmp (recipient, data->recipient_number) == 0))
- outgoing = TRUE;
- else
- outgoing = FALSE;
+ outgoing = FALSE;
+ if (categories) {
+ gint i;
+ for (i = 0; categories[i]; i++) {
+ if ((strcmp (categories[i], "Sent") == 0) ||
+ (strcmp (categories[i], "Sending") == 0)) {
+ outgoing = TRUE;
+ break;
+ }
+ }
+ g_strfreev (categories);
+ }
g_object_set (cell,
"author", author,
@@ -325,9 +333,9 @@
"created", created,
"modified", modified,
"justify", outgoing ?
- GTK_JUSTIFY_RIGHT : GTK_JUSTIFY_LEFT,
+ GTK_JUSTIFY_LEFT : GTK_JUSTIFY_RIGHT,
"icon", outgoing ?
- data->author_icon : data->recipient_icon,
+ data->recipient_icon : data->author_icon,
NULL);
g_free (author);
@@ -344,38 +352,43 @@
for (; components; components = components->next) {
SmsNoteCountData *ncdata;
JanaNote *note;
- gint i;
+ gchar *uid;
+ gchar *key;
if (!JANA_IS_NOTE (components->data)) continue;
note = JANA_NOTE (components->data);
- for (i = 0; i < 2; i++) {
- gchar *uid;
- gchar *key = i ? jana_note_get_author (note) :
- jana_note_get_recipient (note);
- if (!key) continue;
- ncdata = g_hash_table_lookup (data->note_count, key);
-
- if (!ncdata) {
- ncdata = g_slice_new0 (SmsNoteCountData);
- g_hash_table_insert (
- data->note_count, key, ncdata);
- } else {
- g_free (key);
- }
-
- uid = jana_component_get_uid (
- JANA_COMPONENT (note));
- if (jana_utils_component_has_category (
- JANA_COMPONENT (note), "Read")) {
- ncdata->read = g_list_prepend (
- ncdata->read, uid);
- } else {
- ncdata->unread = g_list_prepend (
- ncdata->unread, uid);
- }
+ if (jana_utils_component_has_category (
+ (JanaComponent *)note, "Sent") ||
+ jana_utils_component_has_category (
+ (JanaComponent *)note, "Sending"))
+ key = jana_note_get_recipient (note);
+ else
+ key = jana_note_get_author (note);
+
+ if (!key) continue;
+
+ ncdata = g_hash_table_lookup (data->note_count, key);
+
+ if (!ncdata) {
+ ncdata = g_slice_new0 (SmsNoteCountData);
+ g_hash_table_insert (
+ data->note_count, key, ncdata);
+ } else {
+ g_free (key);
}
+
+ uid = jana_component_get_uid (
+ JANA_COMPONENT (note));
+ if (jana_utils_component_has_category (
+ JANA_COMPONENT (note), "Read")) {
+ ncdata->read = g_list_prepend (
+ ncdata->read, uid);
+ } else {
+ ncdata->unread = g_list_prepend (
+ ncdata->unread, uid);
+ }
}
if (!data->note_count_idle) data->note_count_idle =
@@ -607,8 +620,9 @@
return result;
} else {
- gchar *author_uid;
+ gchar **categories;
gboolean result;
+ gint i;
/* Filter on selected category */
gint type = gtk_combo_box_get_active (
@@ -618,16 +632,17 @@
if ((type <= ALL_NOTES) || (!data->author_uid)) return TRUE;
gtk_tree_model_get (model, iter,
- JANA_GTK_NOTE_STORE_COL_UID, &author_uid, -1);
- if (!author_uid) return FALSE;
+ JANA_GTK_NOTE_STORE_COL_CATEGORIES, &categories, -1);
+ result = (type == SENT_NOTES) ? FALSE : TRUE;
+ for (i = 0; categories && categories[i]; i++) {
+ if ((strcmp (categories[i], "Sent") == 0) ||
+ (strcmp (categories[i], "Sending") == 0)) {
+ result = !result;
+ break;
+ }
+ }
+ if (categories) g_strfreev (categories);
- if (strcmp (author_uid, data->author_uid) == 0)
- result = (type == SENT_NOTES) ? TRUE : FALSE;
- else
- result = (type == SENT_NOTES) ? FALSE : TRUE;
-
- g_free (author_uid);
-
return result;
}
}
More information about the commitlog
mailing list