| 1 |
/* |
| 2 |
* Copyright (C) 2014 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
* |
| 16 |
* Authored by: Nick Dedekind <[email protected] |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "MockCallManager.h" |
| 20 |
|
| 21 |
MockCallManager::MockCallManager(QObject *parent) |
| 22 |
: QObject(parent) |
| 23 |
, m_foregroundCall(nullptr) |
| 24 |
, m_backgroundCall(nullptr) |
| 25 |
, m_callIndicatorVisible(false) |
| 26 |
{ |
| 27 |
} |
| 28 |
|
| 29 |
MockCallManager *MockCallManager::instance() |
| 30 |
{ |
| 31 |
static MockCallManager* manager = new MockCallManager(); |
| 32 |
return manager; |
| 33 |
} |
| 34 |
|
| 35 |
QObject* MockCallManager::foregroundCall() const |
| 36 |
{ |
| 37 |
return m_foregroundCall; |
| 38 |
} |
| 39 |
|
| 40 |
void MockCallManager::setForegroundCall(QObject* foregroundCall) |
| 41 |
{ |
| 42 |
if(m_foregroundCall != foregroundCall){ |
| 43 |
m_foregroundCall = foregroundCall; |
| 44 |
Q_EMIT foregroundCallChanged(); |
| 45 |
Q_EMIT hasCallsChanged(); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
QObject* MockCallManager::backgroundCall() const |
| 50 |
{ |
| 51 |
return m_backgroundCall; |
| 52 |
} |
| 53 |
|
| 54 |
void MockCallManager::setBackgroundCall(QObject* backgroundCall) |
| 55 |
{ |
| 56 |
if(m_backgroundCall != backgroundCall){ |
| 57 |
m_backgroundCall = backgroundCall; |
| 58 |
Q_EMIT backgroundCallChanged(); |
| 59 |
Q_EMIT hasCallsChanged(); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
bool MockCallManager::hasCalls() const |
| 64 |
{ |
| 65 |
return m_foregroundCall || m_backgroundCall; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
bool MockCallManager::callIndicatorVisible() const |
| 70 |
{ |
| 71 |
return m_callIndicatorVisible; |
| 72 |
} |
| 73 |
|
| 74 |
void MockCallManager::setCallIndicatorVisible(bool callIndicatorVisible) |
| 75 |
{ |
| 76 |
if(m_callIndicatorVisible != callIndicatorVisible){ |
| 77 |
m_callIndicatorVisible = callIndicatorVisible; |
| 78 |
Q_EMIT callIndicatorVisibleChanged(); |
| 79 |
} |
| 80 |
} |