blob: b75603386a600cf98a636f0b3b66d10088fa787b [file] [log] [blame]
Nicolas Jagera92f1312016-08-25 08:01:22 -04001/**************************************************************************
2* Copyright (C) 2016 by Savoir-faire Linux *
3* Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 3 of the License, or *
8* (at your option) any later version. *
9* *
10* This program is distributed in the hope that it will be useful, *
11* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13* GNU General Public License for more details. *
14* *
15* You should have received a copy of the GNU General Public License *
16* along with this program. If not, see <http://www.gnu.org/licenses/>. *
17**************************************************************************/
18#include "pch.h"
19
20#include "Call.h"
21
22using namespace Windows::ApplicationModel::Core;
23using namespace Platform;
24using namespace Windows::UI::Core;
25
26using namespace RingClientUWP;
27
Nicolas Jager5750df02016-09-13 11:20:33 -040028// REFACTORING : for the whole Call class, change "from" to "peer"
29
Nicolas Jagerd76940f2016-08-31 14:44:04 -040030Call::Call(String^ accountIdz, String^ callIdz, String^ fromz)
Nicolas Jagera92f1312016-08-25 08:01:22 -040031{
Nicolas Jagerd76940f2016-08-31 14:44:04 -040032 this->accountId = accountIdz;
33 this->callId = callIdz;
34 this->from = fromz;
Nicolas Jagera92f1312016-08-25 08:01:22 -040035
Nicolas Jager5750df02016-09-13 11:20:33 -040036 isOutGoing = false; // by default, we consider the call incomming, REFACTO : add this to the constructor params...
37
Nicolas Jagerd76940f2016-08-31 14:44:04 -040038 this->state = "incoming call";
Nicolas Jagera92f1312016-08-25 08:01:22 -040039 this->code = -1;
40}
41
42void RingClientUWP::Call::stateChange(String ^ state, int code)
43{
44 this->state = state;
Nicolas Jagerd76940f2016-08-31 14:44:04 -040045 PropertyChanged(this, ref new PropertyChangedEventArgs("state"));
Nicolas Jagera92f1312016-08-25 08:01:22 -040046 this->code = code;
47}
48
49void
50Call::NotifyPropertyChanged(String^ propertyName)
51{
52 CoreApplicationView^ view = CoreApplication::MainView;
53 view->CoreWindow->Dispatcher->RunAsync(
54 CoreDispatcherPriority::Normal,
55 ref new DispatchedHandler([this, propertyName]()
56 {
57 PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
58
59 }));
Nicolas Jagerf6a10322016-09-06 08:17:49 -040060}
61
62void RingClientUWP::Call::refuse()
63{
64 RingD::instance->refuseIncommingCall(this);
65}
66
67void RingClientUWP::Call::accept()
68{
69 RingD::instance->acceptIncommingCall(this);
70}
Nicolas Jager5750df02016-09-13 11:20:33 -040071
72void RingClientUWP::Call::cancel()
73{
74 RingD::instance->cancelOutGoingCall(this);
75}