blob: 4683e27e4f366ddde1d17008b067b4a34a2ee6e7 [file] [log] [blame]
Nicolas Jager58c70b02016-08-26 09:50:45 -04001/**************************************************************************
2* Copyright (C) 2016 by Savoir-faire Linux *
3* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
4* Author: Traczyk Andreas <traczyk.andreas@savoirfairelinux.com> *
5* *
6* This program is free software; you can redistribute it and/or modify *
7* it under the terms of the GNU General Public License as published by *
8* the Free Software Foundation; either version 3 of the License, or *
9* (at your option) any later version. *
10* *
11* This program is distributed in the hope that it will be useful, *
12* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14* GNU General Public License for more details. *
15* *
16* You should have received a copy of the GNU General Public License *
17* along with this program. If not, see <http://www.gnu.org/licenses/>. *
18**************************************************************************/
19#include "pch.h"
20
21#include "Conversation.h"
22
23using namespace Windows::ApplicationModel::Core;
24using namespace Platform;
25using namespace Windows::UI::Core;
26
27using namespace RingClientUWP;
28
29Conversation::Conversation()
30{
Nicolas Jager93abfea2016-08-30 12:33:07 -040031 messagesList_ = ref new Vector<ConversationMessage^>();
Nicolas Jager58c70b02016-08-26 09:50:45 -040032}
33
34void
35Conversation::addMessage(String^ date, bool fromContact, String^ payload)
36{
37 ConversationMessage^ message = ref new ConversationMessage();
38 message->Date = date;
39 message->FromContact = fromContact;
40 message->Payload = payload;
Nicolas Jager93abfea2016-08-30 12:33:07 -040041
42 /* add message to _messagesList_ */
43 messagesList_->Append(message);
Nicolas Jager58c70b02016-08-26 09:50:45 -040044}
atraczykf5be5462016-08-31 14:23:06 -040045
46JsonObject^
47ConversationMessage::ToJsonObject()
48{
49 JsonObject^ messageObject = ref new JsonObject();
50 messageObject->SetNamedValue(dateKey, JsonValue::CreateStringValue(Date));
51 messageObject->SetNamedValue(fromContactKey, JsonValue::CreateBooleanValue(FromContact));
52 messageObject->SetNamedValue(payloadKey, JsonValue::CreateStringValue(Payload));
53
54 JsonObject^ jsonObject = ref new JsonObject();
55 jsonObject->SetNamedValue(messageKey, messageObject);
56
57 return jsonObject;
58}