Contact.h 3.81 KB
Newer Older
Nicolas Jager's avatar
Nicolas Jager committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#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::Data::Json;
22
using namespace Windows::UI::Xaml;
Nicolas Jager's avatar
Nicolas Jager committed
23 24 25 26 27
using namespace Windows::UI::Xaml::Data;

/* strings required by Windows::Data::Json. Defined here on puprose */
String^ nameKey = "name";
String^ ringIDKey = "ringid";
28
String^ GUIDKey = "guid";
29
String^ unreadMessagesKey = "unreadmessages";
Nicolas Jager's avatar
Nicolas Jager committed
30 31
String^ contactKey = "contact";
String^ contactListKey = "contactlist";
32
String^ accountIdAssociatedKey = "accountIdAssociated";
Nicolas Jager's avatar
Nicolas Jager committed
33 34 35 36 37 38 39

namespace RingClientUWP
{
ref class Conversation;
public ref class Contact sealed : public INotifyPropertyChanged
{
public:
40
    Contact(String^ name, String^ ringID, String^ GUID, unsigned int unreadmessages);
Nicolas Jager's avatar
Nicolas Jager committed
41 42 43 44 45 46
    JsonObject^ ToJsonObject();

    virtual event PropertyChangedEventHandler^ PropertyChanged;

    property String^ name_;
    property String^ ringID_;
47 48
    property String^ GUID_;

Nicolas Jager's avatar
Nicolas Jager committed
49 50 51 52 53 54 55
    property Conversation^ _conversation
    {
        Conversation^ get()
        {
            return conversation_;
        }
    }
56 57 58 59 60 61 62 63 64
    property Visibility notificationNewMessage
    {
        Visibility get()
        {
            return notificationNewMessage_;
        }
        void set(Visibility visibility)
        {
            notificationNewMessage_ = visibility;
65
            NotifyPropertyChanged("notificationNewMessage");
66 67
        }
    }
Nicolas Jager's avatar
Nicolas Jager committed
68
    property uint32 _unreadMessages
69
    {
Nicolas Jager's avatar
Nicolas Jager committed
70
        uint32 get()
71
        {
Nicolas Jager's avatar
Nicolas Jager committed
72
            return unreadMessages_;
73
        }
Nicolas Jager's avatar
Nicolas Jager committed
74
        void set(uint32 value)
75
        {
Nicolas Jager's avatar
Nicolas Jager committed
76
            unreadMessages_ = value;
77
            NotifyPropertyChanged("_unreadMessages");
78 79
        }
    }
80 81 82 83 84 85 86 87 88
    property Windows::UI::Xaml::GridLength _contactBarHeight
    {
        Windows::UI::Xaml::GridLength get()
        {
            return contactBarHeight_;
        }
        void set(Windows::UI::Xaml::GridLength value)
        {
            contactBarHeight_ = value;
89
            NotifyPropertyChanged("_contactBarHeight");
90 91
        }
    }
92
    property String^ _accountIdAssociated;
Nicolas Jager's avatar
Nicolas Jager committed
93

94 95 96 97
internal:
    void        saveConversationToFile();
    String^     StringifyConversation();
    void        DestringifyConversation(String^ data);
98
    void        deleteConversationFile();
99

Nicolas Jager's avatar
Nicolas Jager committed
100 101 102 103 104
protected:
    void NotifyPropertyChanged(String^ propertyName);

private:
    Conversation^ conversation_;
105 106
    Visibility notificationNewMessage_;
    unsigned int unreadMessages_;
107
    Windows::UI::Xaml::GridLength contactBarHeight_ = 0;
Nicolas Jager's avatar
Nicolas Jager committed
108 109 110
};
}