calls: adds optional messaging frame to the call page

- adds the ability to split the call page into a video area and a
  messaging area

Change-Id: I6fd25b7256f3b14b9da1f5de175b606def928712
Tuleap: #1052
diff --git a/MessageTextPage.xaml b/MessageTextPage.xaml
index c7c0273..9d9db36 100644
--- a/MessageTextPage.xaml
+++ b/MessageTextPage.xaml
@@ -39,73 +39,73 @@
             </Grid>

         </DataTemplate>

         <!-- barre d'envoi de message -->

-    <Style TargetType="TextBox">

-        <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />

-        <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />

-        <Setter Property="Foreground" Value="Black" />

-        <Setter Property="Background" Value="white" />

-        <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />

-        <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />

-        <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />

-        <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />

-        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />

-        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />

-        <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />

-        <Setter Property="Padding" Value="4,4"/>

-        <Setter Property="Template">

-            <Setter.Value>

-                <ControlTemplate TargetType="TextBox">

-                        <Grid>

-                            <Grid.ColumnDefinitions>

-                            <ColumnDefinition Width="*" />

-                            <ColumnDefinition Width="Auto" />

-                        </Grid.ColumnDefinitions>

-                        <Grid.RowDefinitions>

-                            <RowDefinition Height="Auto" />

-                            <RowDefinition Height="*" />

-                        </Grid.RowDefinitions>

-                        <Border x:Name="BackgroundElement"

-                                Grid.Row="1"

-                                Background="{TemplateBinding Background}"

-                                Margin="{TemplateBinding BorderThickness}"

-                                Opacity="1"

-                                Grid.ColumnSpan="2"

-                                BorderBrush="LightBlue"

-                                BorderThickness="1"

-                                Grid.RowSpan="1"/>

-                        <ScrollViewer x:Name="ContentElement"

-                                      Grid.Row="1"

-                                      HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"

-                                      HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"

-                                      VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"

-                                      VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"

-                                      IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"

-                                      IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"

-                                      IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"

-                                      Margin="{TemplateBinding BorderThickness}"

-                                      Padding="{TemplateBinding Padding}"

-                                      IsTabStop="False"

-                                      AutomationProperties.AccessibilityView="Raw"

-                                      ZoomMode="Disabled" />

+        <Style TargetType="TextBox">

+            <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />

+            <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />

+            <Setter Property="Foreground" Value="Black" />

+            <Setter Property="Background" Value="white" />

+            <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />

+            <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />

+            <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />

+            <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />

+            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />

+            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />

+            <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />

+            <Setter Property="Padding" Value="4,4"/>

+            <Setter Property="Template">

+                <Setter.Value>

+                    <ControlTemplate TargetType="TextBox">

+                            <Grid>

+                                <Grid.ColumnDefinitions>

+                                <ColumnDefinition Width="*" />

+                                <ColumnDefinition Width="Auto" />

+                            </Grid.ColumnDefinitions>

+                            <Grid.RowDefinitions>

+                                <RowDefinition Height="Auto" />

+                                <RowDefinition Height="*" />

+                            </Grid.RowDefinitions>

+                            <Border x:Name="BackgroundElement"

+                                    Grid.Row="1"

+                                    Background="{TemplateBinding Background}"

+                                    Margin="{TemplateBinding BorderThickness}"

+                                    Opacity="1"

+                                    Grid.ColumnSpan="2"

+                                    BorderBrush="LightBlue"

+                                    BorderThickness="1"

+                                    Grid.RowSpan="1"/>

+                            <ScrollViewer x:Name="ContentElement"

+                                          Grid.Row="1"

+                                          HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"

+                                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"

+                                          VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"

+                                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"

+                                          IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"

+                                          IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"

+                                          IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"

+                                          Margin="{TemplateBinding BorderThickness}"

+                                          Padding="{TemplateBinding Padding}"

+                                          IsTabStop="False"

+                                          AutomationProperties.AccessibilityView="Raw"

+                                          ZoomMode="Disabled" />

 

-                        <Button x:Name="_sendBtn_"

-                                Background="Transparent"

-                                Grid.Row="1"

-                                FontFamily="Segoe MDL2 Assets"

-                                Foreground="LightBlue"

-                                Content="&#xE122;"

-                                IsTabStop="False"

-                                Grid.Column="1"

-                                Click="_sendBtn__Click"

-                                Visibility="Visible"

-                                MinWidth="34"

-                                FontSize="20"

-                                VerticalAlignment="Stretch"/>

-                    </Grid>

-                </ControlTemplate>

-            </Setter.Value>

-        </Setter>

-    </Style>

+                            <Button x:Name="_sendBtn_"

+                                    Background="Transparent"

+                                    Grid.Row="1"

+                                    FontFamily="Segoe MDL2 Assets"

+                                    Foreground="LightBlue"

+                                    Content="&#xE122;"

+                                    IsTabStop="False"

+                                    Grid.Column="1"

+                                    Click="_sendBtn__Click"

+                                    Visibility="Visible"

+                                    MinWidth="34"

+                                    FontSize="20"

+                                    VerticalAlignment="Stretch"/>

+                        </Grid>

+                    </ControlTemplate>

+                </Setter.Value>

+            </Setter>

+        </Style>

     </Page.Resources>

 

     <Grid Background="#FFF2F2F2">

diff --git a/RingD.cpp b/RingD.cpp
index 03e0b25..3187639 100644
--- a/RingD.cpp
+++ b/RingD.cpp
@@ -242,6 +242,45 @@
                     }));

                 }

             }),

+            DRing::exportable_callback<DRing::CallSignal::IncomingMessage>([&](

+                        const std::string& callId,

+                        const std::string& from,

+                        const std::map<std::string, std::string>& payloads)

+            {

+                MSG_("<IncomingMessage>");

+                MSG_("callId = " + callId);

+                MSG_("from = " + from);

+

+                auto callId2 = toPlatformString(callId);

+                auto from2 = toPlatformString(from);

+

+                from2 = Utils::TrimRingId2(from2);

+

+                Call^ call = CallsViewModel::instance->findCall(callId2);

+

+                if (!call)

+                    return;

+

+                String^ accountId2 = call->accountId;

+                const std::string PROFILE_VCF = "x-ring/ring.profile.vcard";

+                static const unsigned int profileSize = PROFILE_VCF.size();

+

+                for (auto i : payloads) {

+                    if (i.first.compare(0, profileSize, PROFILE_VCF) == 0) {

+                        MSG_("VCARD");

+                        return;

+                    }

+                    MSG_("payload.first = " + i.first);

+                    MSG_("payload.second = " + i.second);

+

+                    auto payload = Utils::toPlatformString(i.second);

+                    CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(

+                        CoreDispatcherPriority::Low, ref new DispatchedHandler([=]()

+                    {

+                        incomingAccountMessage(accountId2, from2, payload);

+                    }));

+                }

+            }),

             DRing::exportable_callback<DRing::ConfigurationSignal::RegistrationStateChanged>([this](

                         const std::string& account_id, const std::string& state,

                         int detailsCode, const std::string& detailsStr)

diff --git a/SmartPanel.xaml b/SmartPanel.xaml
index b291d37..2dcc436 100644
--- a/SmartPanel.xaml
+++ b/SmartPanel.xaml
@@ -291,7 +291,7 @@
                 <StackPanel Grid.Column="1"

                             VerticalAlignment="Bottom">

                     <TextBlock x:Name="_selectedAccountName_"

-                               Text="default name"

+                               Text="[TEXT MISSING]"

                                Margin="10"

                                Style="{StaticResource TextStyle2}"/>

                     <StackPanel Orientation="Horizontal">

diff --git a/Utils.h b/Utils.h
index 5eada9a..2f6e4f4 100644
--- a/Utils.h
+++ b/Utils.h
@@ -124,6 +124,20 @@
     return ref new Platform::String(first, static_cast<unsigned int>(last - first));

 }

 

+/* fix some issue in the daemon -->  remove "@..." */

+Platform::String^ TrimRingId2(Platform::String^ s)

+{

+    const WCHAR* first = s->Begin();

+    const WCHAR* last = s->End();

+

+    while (first != last && last[-1] != '@')

+        --last;

+

+    last--;

+

+    return ref new Platform::String(first, static_cast<unsigned int>(last - first));

+}

+

 Platform::String^ GetNewGUID()

 {

     GUID result;

diff --git a/VideoPage.xaml b/VideoPage.xaml
index e3f3123..d81d3f5 100644
--- a/VideoPage.xaml
+++ b/VideoPage.xaml
@@ -3,6 +3,8 @@
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

     xmlns:local="using:RingClientUWP"

+    xmlns:views="using:RingClientUWP.Views"

+    xmlns:ctl="using:RingClientUWP.Controls"

     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

     mc:Ignorable="d"

@@ -27,6 +29,102 @@
                 <LinearDoubleKeyFrame Value="0" KeyTime="0:0:4" />

             </DoubleAnimationUsingKeyFrames>

         </Storyboard>

+        <!-- bubble -->

+        <views:BubbleBackground x:Key="_bubbleBackground_" />

+        <views:BubbleHorizontalAlignement x:Key="_bubbleHorizontalAlignement_" />

+        <DataTemplate x:Key="ConversationMessageTemplate"

+                      x:DataType="local:ConversationMessage">

+            <Grid Margin="0"

+                  HorizontalAlignment="{x:Bind FromContact, Converter={StaticResource _bubbleHorizontalAlignement_}}" >

+                <Grid.ColumnDefinitions>

+                    <ColumnDefinition Width="2*" />

+                    <ColumnDefinition Width="8*" />

+                </Grid.ColumnDefinitions>

+                <Border  Background="{x:Bind FromContact, Converter={StaticResource _bubbleBackground_}}"

+                         CornerRadius="10"

+                         Grid.Column="1"

+                         Width="auto"

+                         Height="auto"

+                         Padding="5"

+                         Margin="5" >

+                    <ContentPresenter>

+                        <!--Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."-->

+                        <TextBlock x:Name="_msgContent_"

+                                   TextWrapping="Wrap"

+                                   Text="{x:Bind Payload}"

+                                   Foreground="White"/>

+                    </ContentPresenter>

+                </Border>

+            </Grid>

+        </DataTemplate>

+        <!-- barre d'envoi de message -->

+        <Style TargetType="TextBox">

+            <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />

+            <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />

+            <Setter Property="Foreground" Value="Black" />

+            <Setter Property="Background" Value="white" />

+            <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />

+            <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />

+            <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />

+            <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />

+            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />

+            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />

+            <Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />

+            <Setter Property="Padding" Value="4,4"/>

+            <Setter Property="Template">

+                <Setter.Value>

+                    <ControlTemplate TargetType="TextBox">

+                        <Grid>

+                            <Grid.ColumnDefinitions>

+                                <ColumnDefinition Width="*" />

+                                <ColumnDefinition Width="Auto" />

+                            </Grid.ColumnDefinitions>

+                            <Grid.RowDefinitions>

+                                <RowDefinition Height="Auto" />

+                                <RowDefinition Height="*" />

+                            </Grid.RowDefinitions>

+                            <Border x:Name="BackgroundElement"

+                                    Grid.Row="1"

+                                    Background="{TemplateBinding Background}"

+                                    Margin="{TemplateBinding BorderThickness}"

+                                    Opacity="1"

+                                    Grid.ColumnSpan="2"

+                                    BorderBrush="LightBlue"

+                                    BorderThickness="1"

+                                    Grid.RowSpan="1"/>

+                            <ScrollViewer x:Name="ContentElement"

+                                          Grid.Row="1"

+                                          HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"

+                                          HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"

+                                          VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"

+                                          VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"

+                                          IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"

+                                          IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"

+                                          IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"

+                                          Margin="{TemplateBinding BorderThickness}"

+                                          Padding="{TemplateBinding Padding}"

+                                          IsTabStop="False"

+                                          AutomationProperties.AccessibilityView="Raw"

+                                          ZoomMode="Disabled" />

+

+                            <Button x:Name="_sendBtn_"

+                                    Background="Transparent"

+                                    Grid.Row="1"

+                                    FontFamily="Segoe MDL2 Assets"

+                                    Foreground="LightBlue"

+                                    Content="&#xE122;"

+                                    IsTabStop="False"

+                                    Grid.Column="1"

+                                    Click="_sendBtn__Click"

+                                    Visibility="Visible"

+                                    MinWidth="34"

+                                    FontSize="20"

+                                    VerticalAlignment="Stretch"/>

+                        </Grid>

+                    </ControlTemplate>

+                </Setter.Value>

+            </Setter>

+        </Style>

     </Page.Resources>

 

     <SplitView x:Name="_videoSplitView_" IsPaneOpen="False" OpenPaneLength="400" PanePlacement="Right">

@@ -34,101 +132,105 @@
             <Frame x:Name="_chatPanel_"/>

         </SplitView.Pane>

         <SplitView.Content>

-            <Grid Background="#000000">

-                <Image x:Name="_videoControl_"

-                       PointerMoved="_videoControl__PointerMoved"

-                       Stretch="UniformToFill"/>

-                <StackPanel x:Name="_headerBar_"

+            <Grid>

+                <Grid.RowDefinitions>

+                    <RowDefinition Height="*"/>

+                    <RowDefinition x:Name="_rowChatBx_" Height="0"/>

+                </Grid.RowDefinitions>

+                <Grid Background="#000000"

+                      Grid.Row="0"

+                  PointerMoved="_videoControl__PointerMoved">

+                    <StackPanel x:Name="_headerBar_"

                             Background="{StaticResource SemiTransparentBlack}"

                             HorizontalAlignment="Stretch"

                             VerticalAlignment="Top"

                             Height="50">

-                    <TextBlock x:Name="_callee_"

+                        <TextBlock x:Name="_callee_"

                                Text="callee"

                                Foreground="White"

                                Margin="20,10"/>

-                </StackPanel>

-                <StackPanel x:Name="_controlsBar_"

+                    </StackPanel>

+                    <StackPanel x:Name="_controlsBar_"

                             HorizontalAlignment="Center"

                             VerticalAlignment="Bottom"

                             Orientation="Horizontal">

-                    <StackPanel.Resources>

-                        <Style TargetType="Button">

-                            <Setter Property="Margin" Value="10,30"/>

-                            <Setter Property="Width" Value="40"/>

-                            <Setter Property="Height" Value="40"/>

-                            <Setter Property="Background" Value="Black"/>

-                            <Setter Property="Foreground" Value="White"/>

-                            <Setter Property="BorderBrush" Value="Gray"/>

-                            <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/>

-                            <Setter Property="Template">

-                                <Setter.Value>

-                                    <ControlTemplate TargetType="Button">

-                                        <Grid x:Name="RootGrid" Background="{TemplateBinding Background}">

-                                            <VisualStateManager.VisualStateGroups>

-                                                <VisualStateGroup x:Name="CommonStates">

-                                                    <VisualState x:Name="PointerOver">

-                                                        <Storyboard>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"

+                        <StackPanel.Resources>

+                            <Style TargetType="Button">

+                                <Setter Property="Margin" Value="10,30"/>

+                                <Setter Property="Width" Value="40"/>

+                                <Setter Property="Height" Value="40"/>

+                                <Setter Property="Background" Value="Black"/>

+                                <Setter Property="Foreground" Value="White"/>

+                                <Setter Property="BorderBrush" Value="Gray"/>

+                                <Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}"/>

+                                <Setter Property="Template">

+                                    <Setter.Value>

+                                        <ControlTemplate TargetType="Button">

+                                            <Grid x:Name="RootGrid" Background="{TemplateBinding Background}">

+                                                <VisualStateManager.VisualStateGroups>

+                                                    <VisualStateGroup x:Name="CommonStates">

+                                                        <VisualState x:Name="PointerOver">

+                                                            <Storyboard>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="Gray"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="White"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="White"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                        </Storyboard>

-                                                    </VisualState>

-                                                    <VisualState x:Name="Normal">

-                                                        <Storyboard>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                            </Storyboard>

+                                                        </VisualState>

+                                                        <VisualState x:Name="Normal">

+                                                            <Storyboard>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="Black"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="White"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="Gray"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/>

-                                                        </Storyboard>

-                                                    </VisualState>

-                                                    <VisualState x:Name="Pressed">

-                                                        <Storyboard>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/>

+                                                            </Storyboard>

+                                                        </VisualState>

+                                                        <VisualState x:Name="Pressed">

+                                                            <Storyboard>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="White"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="Black"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush"

                                                                                            Storyboard.TargetName="ContentPresenter">

-                                                                <DiscreteObjectKeyFrame KeyTime="0"

+                                                                    <DiscreteObjectKeyFrame KeyTime="0"

                                                                                         Value="Gray"/>

-                                                            </ObjectAnimationUsingKeyFrames>

-                                                            <PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/>

-                                                        </Storyboard>

-                                                    </VisualState>

-                                                </VisualStateGroup>

-                                            </VisualStateManager.VisualStateGroups>

-                                            <ContentPresenter x:Name="ContentPresenter"

+                                                                </ObjectAnimationUsingKeyFrames>

+                                                                <PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/>

+                                                            </Storyboard>

+                                                        </VisualState>

+                                                    </VisualStateGroup>

+                                                </VisualStateManager.VisualStateGroups>

+                                                <ContentPresenter x:Name="ContentPresenter"

                                                               AutomationProperties.AccessibilityView="Raw"

                                                               BorderBrush="{TemplateBinding BorderBrush}"

                                                               BorderThickness="{TemplateBinding BorderThickness}"

@@ -138,68 +240,103 @@
                                                               HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"

                                                               Padding="{TemplateBinding Padding}"

                                                               VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>

-                                        </Grid>

-                                    </ControlTemplate>

-                                </Setter.Value>

-                            </Setter>

-                        </Style>

-                    </StackPanel.Resources>

+                                            </Grid>

+                                        </ControlTemplate>

+                                    </Setter.Value>

+                                </Setter>

+                            </Style>

+                        </StackPanel.Resources>

 

-                    <Button x:Name="_btnHangUp_"

+                        <Button x:Name="_btnHangUp_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnHangUp__Tapped">

-                        <SymbolIcon Symbol="HangUp"/>

-                    </Button>

-                    <Button x:Name="_btnPause_"

+                            <SymbolIcon Symbol="HangUp"/>

+                        </Button>

+                        <Button x:Name="_btnPause_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnPause__Tapped">

-                        <SymbolIcon Symbol="Pause"/>

-                    </Button>

-                    <Button x:Name="_btnChat_"

+                            <SymbolIcon Symbol="Pause"/>

+                        </Button>

+                        <Button x:Name="_btnChat_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnChat__Tapped">

-                        <SymbolIcon Symbol="Message" HorizontalAlignment="Left" Width="20"/>

-                    </Button>

-                    <Button x:Name="_btnAddFriend_"

+                            <SymbolIcon Symbol="Message" HorizontalAlignment="Left" Width="20"/>

+                        </Button>

+                        <Button x:Name="_btnAddFriend_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnAddFriend__Tapped">

-                        <SymbolIcon Symbol="AddFriend"/>

-                    </Button>

-                    <Button x:Name="_btnSwitch_"

+                            <SymbolIcon Symbol="AddFriend"/>

+                        </Button>

+                        <Button x:Name="_btnSwitch_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnSwitch__Tapped">

-                        <SymbolIcon Symbol="Switch"/>

-                    </Button>

-                    <Button x:Name="_btnMicrophone_"

+                            <SymbolIcon Symbol="Switch"/>

+                        </Button>

+                        <Button x:Name="_btnMicrophone_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnMicrophone__Tapped">

-                        <SymbolIcon Symbol="Microphone"/>

-                    </Button>

-                    <Button x:Name="_btnVideo_"

+                            <SymbolIcon Symbol="Microphone"/>

+                        </Button>

+                        <Button x:Name="_btnVideo_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnVideo__Tapped">

-                        <SymbolIcon Symbol="Video"/>

-                    </Button>

-                    <Button x:Name="_btnMemo_"

+                            <SymbolIcon Symbol="Video"/>

+                        </Button>

+                        <Button x:Name="_btnMemo_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnMemo__Tapped">

-                        <SymbolIcon Symbol="Memo"/>

-                    </Button>

-                    <Button x:Name="_btnHQ_"

+                            <SymbolIcon Symbol="Memo"/>

+                        </Button>

+                        <Button x:Name="_btnHQ_"

                             PointerEntered="btnAny_entered"

                             PointerExited="btnAny_exited"

                             Tapped="_btnHQ__Tapped">

-                        <TextBlock FontSize="12" Text="HQ"/>

-                    </Button>

-                </StackPanel>

+                            <TextBlock FontSize="12" Text="HQ"/>

+                        </Button>

+                    </StackPanel>

+                </Grid>

+                <!-- in call chat box -->

+                <Grid Grid.Row="1">

+                    <Grid Background="#FFF2F2F2">

+                        <Grid.RowDefinitions>

+                            <RowDefinition Height="auto" />

+                            <RowDefinition Height="*"/>

+                            <RowDefinition Height="auto" />

+                        </Grid.RowDefinitions>

+                        <ScrollViewer   x:Name="_scrollView_"

+                                        Grid.Row="1">

+                            <StackPanel>

+                                <ListBox    x:Name="_messagesList_"

+                                            Margin="0"

+                                            Padding="0"

+                                            ItemContainerStyle="{StaticResource messageBubleStyle}"

+                                            ItemTemplate="{StaticResource ConversationMessageTemplate}">

+                                </ListBox>

+                            </StackPanel>

+                        </ScrollViewer>

+                        <Grid   Height="50"

+                                Grid.Row="2"

+                                Margin="0"

+                                Padding="0"

+                                Background="#FFF2F2F2">

+                            <TextBox    x:Name="_messageTextBox_"

+                                        HorizontalAlignment="Stretch"

+                                        TextWrapping="NoWrap"

+                                        VerticalAlignment="Bottom"

+                                        Margin="10"

+                                        Background="White"

+                                        KeyDown="_messageTextBox__KeyDown"/>

+                        </Grid>

+                    </Grid>

+                </Grid>

             </Grid>

         </SplitView.Content>

     </SplitView>

diff --git a/VideoPage.xaml.cpp b/VideoPage.xaml.cpp
index e8ccc36..70eed4a 100644
--- a/VideoPage.xaml.cpp
+++ b/VideoPage.xaml.cpp
@@ -46,6 +46,11 @@
 void

 RingClientUWP::Views::VideoPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e)

 {

+    RingD::instance->incomingAccountMessage += ref new IncomingAccountMessage([&](String^ accountId,

+    String^ from, String^ payload) {

+        scrollDown();

+    });

+

     updatePageContent();

 }

 

@@ -59,6 +64,46 @@
         return;

 

     _callee_->Text = contact->name_;

+

+    _messagesList_->ItemsSource = contact->_conversation->_messages;

+

+    scrollDown();

+}

+

+void RingClientUWP::Views::VideoPage::scrollDown()

+{

+    _scrollView_->UpdateLayout();

+    _scrollView_->ScrollToVerticalOffset(_scrollView_->ScrollableHeight);

+}

+

+void

+RingClientUWP::Views::VideoPage::_sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)

+{

+    sendMessage();

+}

+

+void

+RingClientUWP::Views::VideoPage::_messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)

+{

+    if (e->Key == Windows::System::VirtualKey::Enter) {

+        sendMessage();

+    }

+}

+

+void

+RingClientUWP::Views::VideoPage::sendMessage()

+{

+    auto contact = ViewModel::ContactsViewModel::instance->selectedContact;

+    auto txt = _messageTextBox_->Text;

+

+    /* empty the textbox */

+    _messageTextBox_->Text = "";

+

+    if (!contact || txt->IsEmpty())

+        return;

+

+    RingD::instance->sendAccountTextMessage(txt);

+    scrollDown();

 }

 

 void RingClientUWP::Views::VideoPage::Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)

@@ -91,7 +136,14 @@
 

 void RingClientUWP::Views::VideoPage::_btnChat__Tapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e)

 {

-    chatPanelCall();

+    chatOpen = !chatOpen;

+    if (chatOpen) {

+        _rowChatBx_->Height = 200;

+        chatPanelCall();

+    }

+    else {

+        _rowChatBx_->Height = 0;

+    }

 }

 

 

diff --git a/VideoPage.xaml.h b/VideoPage.xaml.h
index 4b76ee8..0f17ac0 100644
--- a/VideoPage.xaml.h
+++ b/VideoPage.xaml.h
@@ -18,6 +18,7 @@
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *

 **************************************************************************/

 #include "VideoPage.g.h"

+#include "MessageTextPage.xaml.h"

 

 using namespace Windows::Media::Capture;

 using namespace Windows::UI::Xaml::Navigation;

@@ -56,6 +57,20 @@
         }

     }

 

+    property bool chatOpen

+    {

+        bool get()

+        {

+            return chatOpen_;

+        }

+        void set(bool value)

+        {

+            chatOpen_ = value;

+        }

+    }

+

+    void scrollDown();

+

 protected:

     virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;

 

@@ -73,6 +88,11 @@
 

 private:

     bool barFading_;

+    bool chatOpen_;

+

+    void _sendBtn__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);

+    void _messageTextBox__KeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);

+    void sendMessage();

 

     void Button_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);

     void _btnCancel__Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);