From 58c70b063152023c640b8ea835c1fc1c418635df Mon Sep 17 00:00:00 2001 From: Nicolas Jager <nicolas.jager@savoirfairelinux.com> Date: Fri, 26 Aug 2016 09:50:45 -0400 Subject: [PATCH] account/text message : add conversation model - adds conversation class and conversationMessage class. - adds to each contact a conversation member wich will store the messages history. Change-Id: Icdab0e2345ef2889057c06d965ff0eb2940c5a27 Tuleap: #943 --- Contact.cpp | 2 ++ Contact.h | 11 ++++++++ Conversation.cpp | 43 +++++++++++++++++++++++++++++ Conversation.h | 49 +++++++++++++++++++++++++++++++++ pch.h | 2 ++ ring-client-uwp.vcxproj | 2 ++ ring-client-uwp.vcxproj.filters | 6 ++++ 7 files changed, 115 insertions(+) create mode 100644 Conversation.cpp create mode 100644 Conversation.h diff --git a/Contact.cpp b/Contact.cpp index 2377b9c..703e293 100644 --- a/Contact.cpp +++ b/Contact.cpp @@ -1,6 +1,7 @@ /************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -30,6 +31,7 @@ Contact::Contact(String^ name, { name_ = name; ringID_ = ringID; + conversation_ = ref new Conversation(); } void diff --git a/Contact.h b/Contact.h index a68e57b..5c9b14b 100644 --- a/Contact.h +++ b/Contact.h @@ -2,6 +2,7 @@ /************************************************************************** * Copyright (C) 2016 by Savoir-faire Linux * * Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -21,6 +22,7 @@ using namespace Windows::UI::Xaml::Data; namespace RingClientUWP { +ref class Conversation; public ref class Contact sealed : public INotifyPropertyChanged { public: @@ -31,10 +33,19 @@ public: property String^ name_; property String^ ringID_; + property Conversation^ _conversation + { + Conversation^ get() + { + return conversation_; + } + } protected: void NotifyPropertyChanged(String^ propertyName); +private: + Conversation^ conversation_; }; } diff --git a/Conversation.cpp b/Conversation.cpp new file mode 100644 index 0000000..5e64a7e --- /dev/null +++ b/Conversation.cpp @@ -0,0 +1,43 @@ +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +**************************************************************************/ +#include "pch.h" + +#include "Conversation.h" + +using namespace Windows::ApplicationModel::Core; +using namespace Platform; +using namespace Windows::UI::Core; + +using namespace RingClientUWP; + +Conversation::Conversation() +{ +} + +void +Conversation::addMessage(String^ date, bool fromContact, String^ payload) +{ + ConversationMessage^ message = ref new ConversationMessage(); + message->Date = date; + message->FromContact = fromContact; + message->Payload = payload; + std::string owner((fromContact) ? "from contact" : " from me"); + MSG_("{Conversation::addMessage}"); + MSG_("owner = " + owner); +} diff --git a/Conversation.h b/Conversation.h new file mode 100644 index 0000000..7717330 --- /dev/null +++ b/Conversation.h @@ -0,0 +1,49 @@ +#pragma once +/************************************************************************** +* Copyright (C) 2016 by Savoir-faire Linux * +* Author: J�ger Nicolas <nicolas.jager@savoirfairelinux.com> * +* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +**************************************************************************/ +using namespace Platform; +using namespace Windows::UI::Xaml::Data; + +namespace RingClientUWP +{ +public ref class ConversationMessage sealed +{ +public: + property String^ Date; + property bool FromContact; + property String^ Payload; +}; + +public ref class Conversation sealed +{ +private: + + +public: + Conversation(); + void addMessage(String^ date, bool fromContact, String^ payload); + +private: + Vector<ConversationMessage^> messages; + +}; +#define MSG_FROM_CONTACT true +#define MSG_FROM_ME false +} + diff --git a/pch.h b/pch.h index 7e025e8..0ccf589 100644 --- a/pch.h +++ b/pch.h @@ -20,6 +20,7 @@ /* standard system include files. */ #include <ppltasks.h> #include <iomanip> +#include <queue> /* required by generated headers. */ #include "App.xaml.h" @@ -28,6 +29,7 @@ #include "Call.h" #include "Contact.h" #include "ContactsViewModel.h" +#include "Conversation.h" /* ensure to be accessed from anywhere */ #include "RingD.h" diff --git a/ring-client-uwp.vcxproj b/ring-client-uwp.vcxproj index 656d2c3..edd60f8 100644 --- a/ring-client-uwp.vcxproj +++ b/ring-client-uwp.vcxproj @@ -164,6 +164,7 @@ <ClInclude Include="CallsViewModel.h" /> <ClInclude Include="Contact.h" /> <ClInclude Include="ContactsViewModel.h" /> + <ClInclude Include="Conversation.h" /> <ClInclude Include="LoadingPage.xaml.h"> <DependentUpon>LoadingPage.xaml</DependentUpon> </ClInclude> @@ -263,6 +264,7 @@ <ClCompile Include="CallsViewModel.cpp" /> <ClCompile Include="Contact.cpp" /> <ClCompile Include="ContactsViewModel.cpp" /> + <ClCompile Include="Conversation.cpp" /> <ClCompile Include="LoadingPage.xaml.cpp"> <DependentUpon>LoadingPage.xaml</DependentUpon> </ClCompile> diff --git a/ring-client-uwp.vcxproj.filters b/ring-client-uwp.vcxproj.filters index fb11f41..0ad361d 100644 --- a/ring-client-uwp.vcxproj.filters +++ b/ring-client-uwp.vcxproj.filters @@ -71,6 +71,9 @@ <ClCompile Include="Call.cpp"> <Filter>Common</Filter> </ClCompile> + <ClCompile Include="Conversation.cpp"> + <Filter>Model</Filter> + </ClCompile> <ClCompile Include="CallsViewModel.cpp"> <Filter>ModelViews</Filter> </ClCompile> @@ -112,6 +115,9 @@ </ClInclude> <ClInclude Include="CallsViewModel.h"> <Filter>ModelViews</Filter> + </ClInclude> + <ClInclude Include="Conversation.h"> + <Filter>Model</Filter> </ClInclude> </ItemGroup> <ItemGroup> -- GitLab