Nicolas Jager | 58c70b0 | 2016-08-26 09:50:45 -0400 | [diff] [blame] | 1 | /**************************************************************************
|
| 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 |
|
| 23 | using namespace Windows::ApplicationModel::Core;
|
| 24 | using namespace Platform;
|
| 25 | using namespace Windows::UI::Core;
|
| 26 |
|
| 27 | using namespace RingClientUWP;
|
| 28 |
|
| 29 | Conversation::Conversation()
|
| 30 | {
|
Nicolas Jager | 93abfea | 2016-08-30 12:33:07 -0400 | [diff] [blame] | 31 | messagesList_ = ref new Vector<ConversationMessage^>();
|
Nicolas Jager | 58c70b0 | 2016-08-26 09:50:45 -0400 | [diff] [blame] | 32 | }
|
| 33 |
|
| 34 | void
|
| 35 | Conversation::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 Jager | 93abfea | 2016-08-30 12:33:07 -0400 | [diff] [blame] | 41 |
|
| 42 | /* add message to _messagesList_ */
|
| 43 | messagesList_->Append(message);
|
Nicolas Jager | 58c70b0 | 2016-08-26 09:50:45 -0400 | [diff] [blame] | 44 | }
|
atraczyk | f5be546 | 2016-08-31 14:23:06 -0400 | [diff] [blame] | 45 |
|
| 46 | JsonObject^
|
| 47 | ConversationMessage::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 | } |