AccountsViewModel.h 4.56 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/***************************************************************************
 * Copyright (C) 2016 by Savoir-faire Linux                                *
 * Author: Jger Nicolas <nicolas.jager@savoirfairelinux.com>              *
 * Author: Traczyk Andreas <andreas.traczyk@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/>.   *
 **************************************************************************/
Nicolas Jager's avatar
Nicolas Jager committed
19
#pragma once
20

21 22
#include "ContactListModel.h"

Nicolas Jager's avatar
Nicolas Jager committed
23 24 25 26
using namespace Platform::Collections;

namespace RingClientUWP
{
27
ref class Contact;
Nicolas Jager's avatar
Nicolas Jager committed
28

29 30
delegate void NewAccountSelected();
delegate void NoAccountSelected();
31
delegate void UpdateScrollView();
Nicolas Jager's avatar
Nicolas Jager committed
32 33
delegate void AccountAdded(Account^ account);
delegate void ClearAccountsList();
34 35 36
delegate void ContactAdded(String^, Contact^);
delegate void ContactDeleted(String^, Contact^);
delegate void ContactDataModified(String^, Contact^);
37 38
delegate void NewUnreadMessage(Contact^);
delegate void NewUnreadContactRequest();
39

40 41
namespace ViewModel
{
42

Nicolas Jager's avatar
Nicolas Jager committed
43 44
public ref class AccountsViewModel sealed
{
45
public:
46 47 48 49
    void raiseContactAdded(String^ accountId, Contact^ contact);
    void raiseContactDeleted(String^ accountId, Contact^ contact);
    void raiseContactDataModified(String^ accountId, Contact^ contact);
    void raiseUnreadContactRequest();
50

Nicolas Jager's avatar
Nicolas Jager committed
51
internal:
52 53 54
    /* properties */
    static property AccountsViewModel^ instance {
        AccountsViewModel^ get() {
Nicolas Jager's avatar
Nicolas Jager committed
55 56 57 58 59
            static AccountsViewModel^ instance_ = ref new AccountsViewModel();
            return instance_;
        }
    }

60 61
    property Vector<Account^>^ accountsList {
        Vector<Account^>^ get() {
Nicolas Jager's avatar
Nicolas Jager committed
62 63 64 65
            return accountsList_;
        }
    }

66
    /* functions */
67
    Account^ addRingAccount(std::string& alias,
68 69 70 71 72 73 74 75 76 77
                        std::string& ringID,
                        std::string& accountID,
                        std::string& deviceId,
                        std::string& deviceName,
                        bool active,
                        bool upnpState,
                        bool autoAnswer,
                        bool dhtPublicInCalls,
                        bool turnEnabled,
                        std::string& turnAddress);
78
    Account^ addSipAccount( std::string& alias,
79 80 81 82 83
                        std::string& accountID,
                        bool active,
                        std::string& sipHostname,
                        std::string& sipUsername,
                        std::string& sipPassword);
84 85
    void clearAccountList();
    Account^ findItem(String^ accountId);
86
    Account^ findAccountByRingID(String ^ ringId);
87 88
    ContactListModel^ getContactListModel(std::string& accountId);
    int unreadMessages(String^ accountId);
89 90 91
    int unreadContactRequests(String^ accountId);
    int bannedContacts(String^ accountId);
    int activeAccounts();
92

Nicolas Jager's avatar
Nicolas Jager committed
93
    /* events */
94 95
    event NewAccountSelected^ newAccountSelected;
    event NoAccountSelected^ noAccountSelected;
96
    event UpdateScrollView^ updateScrollView;
Nicolas Jager's avatar
Nicolas Jager committed
97 98
    event AccountAdded^ accountAdded;
    event ClearAccountsList^ clearAccountsList;
99 100 101 102
    event ContactAdded^ contactAdded;
    event ContactDeleted^ contactDeleted;
    event ContactDataModified^ contactDataModified;
    event NewUnreadMessage^ newUnreadMessage;
103
    event NewUnreadContactRequest^ newUnreadContactRequest;
Nicolas Jager's avatar
Nicolas Jager committed
104 105

private:
106
    AccountsViewModel();
107

108 109 110 111 112
    void OnincomingAccountMessage(String^ accountId, String^ fromRingId, String^ payload);
    void OnincomingMessage(String ^callId, String ^payload);

    Vector<Account^>^ accountsList_;
    Map<String^, ContactListModel^>^ contactListModels_;
Nicolas Jager's avatar
Nicolas Jager committed
113 114 115
};
}
}