Skip to content
Snippets Groups Projects
Commit f11c9f30 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

conversationsview: always retrieve the correct best id


We used the registeredname as the best id, but it's not the case, we
need to get the best id from the registeredname or the uri.
note, remove useless TODO linked to the quality.

Change-Id: I1339d20ee1e4dd96c5c53b932b1fe262b6a53783
Reviewed-by: default avatarNicolas Jäger <nicolas.jager@savoirfairelinux.com>
parent b2105538
Branches
Tags
No related merge requests found
...@@ -306,10 +306,11 @@ update_contact_methods(ChatView *self) ...@@ -306,10 +306,11 @@ update_contact_methods(ChatView *self)
if (!priv->conversation_) return; if (!priv->conversation_) return;
auto contactUri = priv->conversation_->participants.front(); auto contactUri = priv->conversation_->participants.front();
auto contactInfo = priv->accountContainer_->info.contactModel->getContact(contactUri); auto contactInfo = priv->accountContainer_->info.contactModel->getContact(contactUri);
if (contactInfo.profileInfo.alias == contactInfo.registeredName) { auto bestId = std::string(contactInfo.registeredName).empty() ? contactInfo.profileInfo.uri : contactInfo.registeredName;
if (contactInfo.profileInfo.alias == bestId) {
gtk_widget_hide(priv->label_cm); gtk_widget_hide(priv->label_cm);
} else { } else {
gtk_label_set_text(GTK_LABEL(priv->label_cm), contactInfo.registeredName.c_str()); gtk_label_set_text(GTK_LABEL(priv->label_cm), bestId.c_str());
gtk_widget_show(priv->label_cm); gtk_widget_show(priv->label_cm);
} }
......
...@@ -121,23 +121,26 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column, ...@@ -121,23 +121,26 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
gchar *lastInteraction; gchar *lastInteraction;
gchar *text; gchar *text;
gchar *uid; gchar *uid;
gchar *uri;
gtk_tree_model_get (model, iter, gtk_tree_model_get (model, iter,
0 /* col# */, &uid /* data */, 0 /* col# */, &uid /* data */,
1 /* col# */, &alias /* data */, 1 /* col# */, &alias /* data */,
2 /* col# */, &registeredName /* data */, 2 /* col# */, &uri /* data */,
4 /* col# */, &lastInteraction /* data */, 3 /* col# */, &registeredName /* data */,
5 /* col# */, &lastInteraction /* data */,
-1); -1);
auto bestId = std::string(registeredName).empty() ? uri: registeredName;
if (std::string(alias).empty()) { if (std::string(alias).empty()) {
// For conversations with contacts with no alias // For conversations with contacts with no alias
text = g_markup_printf_escaped( text = g_markup_printf_escaped(
"<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>", "<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>",
registeredName, bestId,
lastInteraction lastInteraction
); );
} else if (std::string(alias) == std::string(registeredName) } else if (std::string(alias) == std::string(bestId)
|| std::string(registeredName).empty() || std::string(uid).empty()) { || std::string(bestId).empty() || std::string(uid).empty()) {
// For temporary item // For temporary item
text = g_markup_printf_escaped( text = g_markup_printf_escaped(
"<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>", "<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>",
...@@ -149,13 +152,14 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column, ...@@ -149,13 +152,14 @@ render_name_and_last_interaction(G_GNUC_UNUSED GtkTreeViewColumn *tree_column,
text = g_markup_printf_escaped( text = g_markup_printf_escaped(
"<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>", "<span font_weight=\"bold\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>\n<span size=\"smaller\" color=\"#666\">%s</span>",
alias, alias,
registeredName, bestId,
lastInteraction lastInteraction
); );
} }
g_object_set(G_OBJECT(cell), "markup", text, NULL); g_object_set(G_OBJECT(cell), "markup", text, NULL);
g_free(uid); g_free(uid);
g_free(uri);
g_free(alias); g_free(alias);
g_free(registeredName); g_free(registeredName);
} }
...@@ -222,7 +226,8 @@ static GtkTreeModel* ...@@ -222,7 +226,8 @@ static GtkTreeModel*
create_and_fill_model(ConversationsView *self) create_and_fill_model(ConversationsView *self)
{ {
auto priv = CONVERSATIONS_VIEW_GET_PRIVATE(self); auto priv = CONVERSATIONS_VIEW_GET_PRIVATE(self);
auto store = gtk_list_store_new (5 /* # of cols */ , auto store = gtk_list_store_new (6 /* # of cols */ ,
G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
...@@ -245,9 +250,10 @@ create_and_fill_model(ConversationsView *self) ...@@ -245,9 +250,10 @@ create_and_fill_model(ConversationsView *self)
gtk_list_store_set (store, &iter, gtk_list_store_set (store, &iter,
0 /* col # */ , conversation.uid.c_str() /* celldata */, 0 /* col # */ , conversation.uid.c_str() /* celldata */,
1 /* col # */ , alias.c_str() /* celldata */, 1 /* col # */ , alias.c_str() /* celldata */,
2 /* col # */ , contactInfo.registeredName.c_str() /* celldata */, 2 /* col # */ , contactInfo.profileInfo.uri.c_str() /* celldata */,
3 /* col # */ , contactInfo.profileInfo.avatar.c_str() /* celldata */, 3 /* col # */ , contactInfo.registeredName.c_str() /* celldata */,
4 /* col # */ , lastMessage.c_str() /* celldata */, 4 /* col # */ , contactInfo.profileInfo.avatar.c_str() /* celldata */,
5 /* col # */ , lastMessage.c_str() /* celldata */,
-1 /* end */); -1 /* end */);
} }
......
...@@ -378,7 +378,6 @@ set_quality(Call *call, gboolean auto_quality_on, double desired_quality) ...@@ -378,7 +378,6 @@ set_quality(Call *call, gboolean auto_quality_on, double desired_quality)
static void static void
autoquality_toggled(GtkToggleButton *button, CurrentCallView *self) autoquality_toggled(GtkToggleButton *button, CurrentCallView *self)
{ {
// TODO
g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
...@@ -406,7 +405,6 @@ autoquality_toggled(GtkToggleButton *button, CurrentCallView *self) ...@@ -406,7 +405,6 @@ autoquality_toggled(GtkToggleButton *button, CurrentCallView *self)
static void static void
quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value, CurrentCallView *self) quality_changed(G_GNUC_UNUSED GtkScaleButton *button, G_GNUC_UNUSED gdouble value, CurrentCallView *self)
{ {
// TODO
g_return_if_fail(IS_CURRENT_CALL_VIEW(self)); g_return_if_fail(IS_CURRENT_CALL_VIEW(self));
CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self); CurrentCallViewPrivate *priv = CURRENT_CALL_VIEW_GET_PRIVATE(self);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment