Nicolas Jager | a92f131 | 2016-08-25 08:01:22 -0400 | [diff] [blame] | 1 | /**************************************************************************
|
| 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 |
|
| 22 | using namespace Windows::ApplicationModel::Core;
|
| 23 | using namespace Platform;
|
| 24 | using namespace Windows::UI::Core;
|
| 25 |
|
| 26 | using namespace RingClientUWP;
|
| 27 |
|
Nicolas Jager | 5750df0 | 2016-09-13 11:20:33 -0400 | [diff] [blame] | 28 | // REFACTORING : for the whole Call class, change "from" to "peer"
|
| 29 |
|
Nicolas Jager | d76940f | 2016-08-31 14:44:04 -0400 | [diff] [blame] | 30 | Call::Call(String^ accountIdz, String^ callIdz, String^ fromz)
|
Nicolas Jager | a92f131 | 2016-08-25 08:01:22 -0400 | [diff] [blame] | 31 | {
|
Nicolas Jager | d76940f | 2016-08-31 14:44:04 -0400 | [diff] [blame] | 32 | this->accountId = accountIdz;
|
| 33 | this->callId = callIdz;
|
| 34 | this->from = fromz;
|
Nicolas Jager | a92f131 | 2016-08-25 08:01:22 -0400 | [diff] [blame] | 35 |
|
Nicolas Jager | 5750df0 | 2016-09-13 11:20:33 -0400 | [diff] [blame] | 36 | isOutGoing = false; // by default, we consider the call incomming, REFACTO : add this to the constructor params...
|
| 37 |
|
Nicolas Jager | d76940f | 2016-08-31 14:44:04 -0400 | [diff] [blame] | 38 | this->state = "incoming call";
|
Nicolas Jager | a92f131 | 2016-08-25 08:01:22 -0400 | [diff] [blame] | 39 | this->code = -1;
|
| 40 | }
|
| 41 |
|
| 42 | void RingClientUWP::Call::stateChange(String ^ state, int code)
|
| 43 | {
|
| 44 | this->state = state;
|
Nicolas Jager | d76940f | 2016-08-31 14:44:04 -0400 | [diff] [blame] | 45 | PropertyChanged(this, ref new PropertyChangedEventArgs("state"));
|
Nicolas Jager | a92f131 | 2016-08-25 08:01:22 -0400 | [diff] [blame] | 46 | this->code = code;
|
| 47 | }
|
| 48 |
|
| 49 | void
|
| 50 | Call::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 Jager | f6a1032 | 2016-09-06 08:17:49 -0400 | [diff] [blame] | 60 | }
|
| 61 |
|
| 62 | void RingClientUWP::Call::refuse()
|
| 63 | {
|
| 64 | RingD::instance->refuseIncommingCall(this);
|
| 65 | }
|
| 66 |
|
| 67 | void RingClientUWP::Call::accept()
|
| 68 | {
|
| 69 | RingD::instance->acceptIncommingCall(this);
|
| 70 | }
|
Nicolas Jager | 5750df0 | 2016-09-13 11:20:33 -0400 | [diff] [blame] | 71 |
|
| 72 | void RingClientUWP::Call::cancel()
|
| 73 | {
|
| 74 | RingD::instance->cancelOutGoingCall(this);
|
| 75 | }
|