incomingcallview: show the peer's uri

In the case that the peer has a display name or is a contact, we
show the uri below so the user is aware of the number or ringId
being used for the call.

Change-Id: I3a59a34452110d1cebc8decde28599926d676d7a
Tuleap: #645
diff --git a/src/incomingcallview.cpp b/src/incomingcallview.cpp
index 6dfaa61..b7e0812 100644
--- a/src/incomingcallview.cpp
+++ b/src/incomingcallview.cpp
@@ -27,6 +27,8 @@
 #include <person.h>
 #include <globalinstances.h>
 #include "native/pixbufmanipulator.h"
+#include <itemdataroles.h>
+#include <numbercategory.h>
 
 struct _IncomingCallView
 {
@@ -43,7 +45,8 @@
 struct _IncomingCallViewPrivate
 {
     GtkWidget *image_incoming;
-    GtkWidget *label_identity;
+    GtkWidget *label_name;
+    GtkWidget *label_uri;
     GtkWidget *spinner_status;
     GtkWidget *placeholder;
     GtkWidget *label_status;
@@ -88,7 +91,8 @@
                                                 "/cx/ring/RingGnome/incomingcallview.ui");
 
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, image_incoming);
-    gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, label_identity);
+    gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, label_name);
+    gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, label_uri);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, spinner_status);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, placeholder);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), IncomingCallView, label_status);
@@ -168,9 +172,19 @@
     gtk_image_set_from_pixbuf(GTK_IMAGE(priv->image_incoming), image.get());
 
     /* get name */
-    QVariant var = idx.model()->data(idx, static_cast<int>(Call::Role::Name));
-    QByteArray ba_name = var.toString().toLocal8Bit();
-    gtk_label_set_text(GTK_LABEL(priv->label_identity), ba_name.constData());
+    auto name = idx.model()->data(idx, static_cast<int>(Ring::Role::Name));
+    gtk_label_set_text(GTK_LABEL(priv->label_name), name.toString().toUtf8().constData());
+
+    /* get uri, if different from name */
+    auto uri = idx.model()->data(idx, static_cast<int>(Ring::Role::Number));
+    if (name.toString() != uri.toString()) {
+        auto cat_uri = g_strdup_printf("(%s) %s"
+                                       ,call->peerContactMethod()->category()->name().toUtf8().constData()
+                                       ,uri.toString().toUtf8().constData());
+        gtk_label_set_text(GTK_LABEL(priv->label_uri), cat_uri);
+        g_free(cat_uri);
+        gtk_widget_show(priv->label_uri);
+    }
 
     /* change some things depending on call state */
     update_state(view, call);
diff --git a/ui/incomingcallview.ui b/ui/incomingcallview.ui
index 6fb7770..ac798a0 100644
--- a/ui/incomingcallview.ui
+++ b/ui/incomingcallview.ui
@@ -12,7 +12,6 @@
         <property name="visible">True</property>
         <property name="can_focus">True</property>
         <property name="shadow_type">none</property>
-        <!-- <property name="min-content-height">250</property> -->
         <!-- for now, disable scrolling, display everything -->
         <property name="vscrollbar_policy">never</property>
         <property name="hscrollbar_policy">never</property>
@@ -47,7 +46,7 @@
                 <!-- end image of contact -->
                 <!-- name or other identity of contact -->
                 <child>
-                  <object class="GtkLabel" id="label_identity">
+                  <object class="GtkLabel" id="label_name">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="halign">center</property>
@@ -63,6 +62,24 @@
                   </packing>
                 </child>
                 <!-- end name or other identity of contact -->
+                <!-- uri of contact -->
+                <child>
+                  <object class="GtkLabel" id="label_uri">
+                    <property name="visible">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="halign">center</property>
+                    <property name="selectable">True</property>
+                    <property name="ellipsize">end</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
+                <!-- end uri of contact -->
                 <!-- call initialization progress -->
                 <child>
                   <object class="GtkSpinner" id="spinner_status">
@@ -87,9 +104,9 @@
                     <property name="can_focus">False</property>
                     <property name="label" translatable="yes">Incoming...</property>
                     <property name="ellipsize">end</property>
-                    <attributes>
-                      <attribute name="foreground" value="#88888a8a8585"/>
-                    </attributes>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
                   </object>
                 </child>
               </object>