mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-07-26 06:14:45 +00:00
[dialer] Move the stuff from the tpCaller qml plugin into DialerUtils
Less hassle needed with env vars
This commit is contained in:
parent
def5d16a22
commit
cf00cb85f3
5 changed files with 119 additions and 51 deletions
|
|
@ -28,7 +28,7 @@ import "../Dialpad"
|
||||||
Item {
|
Item {
|
||||||
id: callPage
|
id: callPage
|
||||||
|
|
||||||
property string status: ofonoWrapper.status
|
property string status: dialerUtils.callState
|
||||||
|
|
||||||
property string providerId: ofonoWrapper.providerId
|
property string providerId: ofonoWrapper.providerId
|
||||||
|
|
||||||
|
|
@ -168,10 +168,10 @@ Item {
|
||||||
//STATUS_INCOMING
|
//STATUS_INCOMING
|
||||||
visible: status == "incoming"
|
visible: status == "incoming"
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
ofonoWrapper.answer();
|
dialerUtils.acceptCall();
|
||||||
}
|
}
|
||||||
onRejected: {
|
onRejected: {
|
||||||
ofonoWrapper.hangup();
|
dialerUtils.rejectCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,7 +183,7 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: i18n("End Call")
|
text: i18n("End Call")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
tpCaller.hangUp();
|
dialerUtils.hangUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import QtQuick.Layouts 1.1
|
||||||
import QtQuick.LocalStorage 2.0
|
import QtQuick.LocalStorage 2.0
|
||||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||||
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||||
import org.kde.plasma.private.tpcaller 1.0
|
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
@ -39,6 +38,7 @@ ApplicationWindow {
|
||||||
property string providerId: ofonoWrapper.providerId
|
property string providerId: ofonoWrapper.providerId
|
||||||
//was the last call an incoming one?
|
//was the last call an incoming one?
|
||||||
property bool isIncoming
|
property bool isIncoming
|
||||||
|
|
||||||
//END PROPERTIES
|
//END PROPERTIES
|
||||||
|
|
||||||
//BEGIN SIGNAL HANDLERS
|
//BEGIN SIGNAL HANDLERS
|
||||||
|
|
@ -59,8 +59,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
//BEGIN FUNCTIONS
|
//BEGIN FUNCTIONS
|
||||||
function call(number) {
|
function call(number) {
|
||||||
tpCaller.dial(number);
|
dialerUtils.dial(number);
|
||||||
//ofonoWrapper.call(number);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertCallInHistory(number, duration, callType) {
|
function insertCallInHistory(number, duration, callType) {
|
||||||
|
|
@ -149,19 +148,15 @@ ApplicationWindow {
|
||||||
id: ofonoWrapper
|
id: ofonoWrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
TpCaller {
|
|
||||||
id: tpCaller
|
|
||||||
}
|
|
||||||
|
|
||||||
//END MODELS
|
//END MODELS
|
||||||
|
|
||||||
//BEGIN UI
|
//BEGIN UI
|
||||||
PlasmaExtras.ConditionalLoader {
|
PlasmaExtras.ConditionalLoader {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
when: root.visible && !tpCaller.callInProgress
|
when: root.visible && dialerUtils.callState == "idle"
|
||||||
source: Qt.resolvedUrl("Dialer/DialPage.qml")
|
source: Qt.resolvedUrl("Dialer/DialPage.qml")
|
||||||
z: !tpCaller.callInProgress ? 2 : 0
|
z: dialerUtils.callState == "idle" ? 2 : 0
|
||||||
opacity: !tpCaller.callInProgress ? 1 : 0
|
opacity: dialerUtils.callState == "idle" ? 1 : 0
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
OpacityAnimator {
|
OpacityAnimator {
|
||||||
duration: units.shortDuration
|
duration: units.shortDuration
|
||||||
|
|
@ -172,10 +167,10 @@ ApplicationWindow {
|
||||||
|
|
||||||
PlasmaExtras.ConditionalLoader {
|
PlasmaExtras.ConditionalLoader {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
when: tpCaller.callInProgress
|
when: dialerUtils.callState != "idle"
|
||||||
source: Qt.resolvedUrl("Call/CallPage.qml")
|
source: Qt.resolvedUrl("Call/CallPage.qml")
|
||||||
opacity: tpCaller.callInProgress ? 1 : 0
|
opacity: dialerUtils.callState != "idle" ? 1 : 0
|
||||||
z: tpCaller.callInProgress ? 2 : 0
|
z: dialerUtils.callState != "idle" ? 2 : 0
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
OpacityAnimator {
|
OpacityAnimator {
|
||||||
duration: units.shortDuration
|
duration: units.shortDuration
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,67 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <TelepathyQt/PendingOperation>
|
||||||
|
#include <TelepathyQt/PendingChannelRequest>
|
||||||
|
#include <TelepathyQt/PendingReady>
|
||||||
|
#include <TelepathyQt/Constants>
|
||||||
|
#include <TelepathyQt/PendingContacts>
|
||||||
|
#include <TelepathyQt/Types>
|
||||||
|
#include <TelepathyQt/ContactManager>
|
||||||
|
|
||||||
DialerUtils::DialerUtils(QObject *parent)
|
DialerUtils::DialerUtils(const Tp::AccountPtr &simAccount, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_missedCalls(0)
|
m_missedCalls(0),
|
||||||
|
m_simAccount(simAccount)
|
||||||
{
|
{
|
||||||
|
Tp::PendingReady *op = m_simAccount->becomeReady(Tp::Features() << Tp::Account::FeatureCore);
|
||||||
|
|
||||||
|
connect(op, &Tp::PendingOperation::finished, [=](){
|
||||||
|
if (op->isError()) {
|
||||||
|
qWarning() << "SIM card account failed to get ready:" << op->errorMessage();
|
||||||
|
} else {
|
||||||
|
qDebug() << "SIM Account ready to use";
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
DialerUtils::~DialerUtils()
|
DialerUtils::~DialerUtils()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DialerUtils::dial(const QString &number)
|
||||||
|
{
|
||||||
|
// FIXME: this should be replaced by kpeople thing
|
||||||
|
auto pendingContact = m_simAccount->connection()->contactManager()->contactsForIdentifiers(QStringList() << number);
|
||||||
|
|
||||||
|
connect(pendingContact, &Tp::PendingOperation::finished, [=](){
|
||||||
|
if (pendingContact->contacts().size() < 1) {
|
||||||
|
qWarning() << " no contacts";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qDebug() << "Starting call...";
|
||||||
|
Tp::PendingChannelRequest *pendingChannel = m_simAccount->ensureAudioCall(pendingContact->contacts().first());
|
||||||
|
connect(pendingChannel, &Tp::PendingChannelRequest::finished, [=](){
|
||||||
|
if (pendingChannel->isError()) {
|
||||||
|
qWarning() << "Error when requesting channel" << pendingChannel->errorMessage();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DialerUtils::callState() const
|
||||||
|
{
|
||||||
|
return m_callState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialerUtils::setCallState(const QString &state)
|
||||||
|
{
|
||||||
|
if (m_callState != state) {
|
||||||
|
m_callState = state;
|
||||||
|
Q_EMIT callStateChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DialerUtils::notifyMissedCall(const QString &caller, const QString &description)
|
void DialerUtils::notifyMissedCall(const QString &caller, const QString &description)
|
||||||
{
|
{
|
||||||
qWarning() << "Missed Call.";
|
qWarning() << "Missed Call.";
|
||||||
|
|
|
||||||
|
|
@ -23,26 +23,39 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <KNotification>
|
#include <KNotification>
|
||||||
|
|
||||||
|
#include <TelepathyQt/Account>
|
||||||
|
|
||||||
class DialerUtils : public QObject
|
class DialerUtils : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString callState READ callState NOTIFY callStateChanged);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialerUtils(QObject *parent = 0);
|
DialerUtils(const Tp::AccountPtr &simAccount, QObject *parent = 0);
|
||||||
virtual ~DialerUtils();
|
virtual ~DialerUtils();
|
||||||
|
|
||||||
|
QString callState() const;
|
||||||
|
void setCallState(const QString &state);
|
||||||
|
|
||||||
Q_INVOKABLE void notifyMissedCall(const QString &caller, const QString &description);
|
Q_INVOKABLE void notifyMissedCall(const QString &caller, const QString &description);
|
||||||
Q_INVOKABLE void resetMissedCalls();
|
Q_INVOKABLE void resetMissedCalls();
|
||||||
Q_INVOKABLE void notifyRinging();
|
Q_INVOKABLE void notifyRinging();
|
||||||
Q_INVOKABLE void stopRinging();
|
Q_INVOKABLE void stopRinging();
|
||||||
|
Q_INVOKABLE void dial(const QString &number);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void missedCallsActionTriggered();
|
void missedCallsActionTriggered();
|
||||||
|
void callStateChanged();
|
||||||
|
void acceptCall();
|
||||||
|
void rejectCall();
|
||||||
|
void hangUp();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer <KNotification> m_callsNotification;
|
QPointer <KNotification> m_callsNotification;
|
||||||
QPointer <KNotification> m_ringingNotification;
|
QPointer <KNotification> m_ringingNotification;
|
||||||
int m_missedCalls;
|
int m_missedCalls;
|
||||||
|
QString m_callState;
|
||||||
|
Tp::AccountPtr m_simAccount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,43 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
parser.process(app);
|
parser.process(app);
|
||||||
|
|
||||||
|
Tp::registerTypes();
|
||||||
|
|
||||||
|
Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
|
||||||
|
Tp::Features() << Tp::Account::FeatureCore
|
||||||
|
);
|
||||||
|
|
||||||
|
Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
|
||||||
|
Tp::Features() << Tp::Connection::FeatureCore
|
||||||
|
<< Tp::Connection::FeatureSelfContact
|
||||||
|
<< Tp::Connection::FeatureConnected
|
||||||
|
);
|
||||||
|
|
||||||
|
Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
|
||||||
|
channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);
|
||||||
|
channelFactory->addFeaturesForCalls(Tp::Features() << Tp::CallChannel::FeatureContents
|
||||||
|
<< Tp::CallChannel::FeatureCallState
|
||||||
|
<< Tp::CallChannel::FeatureCallMembers
|
||||||
|
<< Tp::CallChannel::FeatureLocalHoldState
|
||||||
|
);
|
||||||
|
|
||||||
|
// channelFactory->addFeaturesForTextChats(Tp::Features() << Tp::TextChannel::FeatureMessageQueue
|
||||||
|
// << Tp::TextChannel::FeatureMessageSentSignal
|
||||||
|
// << Tp::TextChannel::FeatureChatState
|
||||||
|
// << Tp::TextChannel::FeatureMessageCapabilities);
|
||||||
|
|
||||||
|
Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features() << Tp::Contact::FeatureAlias
|
||||||
|
<< Tp::Contact::FeatureAvatarData
|
||||||
|
);
|
||||||
|
|
||||||
|
Tp::ClientRegistrarPtr registrar =
|
||||||
|
Tp::ClientRegistrar::create(accountFactory, connectionFactory,
|
||||||
|
channelFactory, contactFactory);
|
||||||
|
|
||||||
|
Tp::AccountPtr simAccount = Tp::Account::create(TP_QT_ACCOUNT_MANAGER_BUS_NAME, QStringLiteral("/org/freedesktop/Telepathy/Account/ofono/ofono/account0"),
|
||||||
|
connectionFactory, channelFactory);
|
||||||
|
|
||||||
|
|
||||||
const QString packagePath("org.kde.phone.dialer");
|
const QString packagePath("org.kde.phone.dialer");
|
||||||
|
|
||||||
//usually we have an ApplicationWindow here, so we do not need to create a window by ourselves
|
//usually we have an ApplicationWindow here, so we do not need to create a window by ourselves
|
||||||
|
|
@ -81,7 +118,7 @@ int main(int argc, char **argv)
|
||||||
obj->loadPackage(packagePath);
|
obj->loadPackage(packagePath);
|
||||||
obj->engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments());
|
obj->engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments());
|
||||||
|
|
||||||
DialerUtils *dialerUtils = new DialerUtils;
|
DialerUtils *dialerUtils = new DialerUtils(simAccount);
|
||||||
obj->engine()->rootContext()->setContextProperty("dialerUtils", QVariant::fromValue(dialerUtils));
|
obj->engine()->rootContext()->setContextProperty("dialerUtils", QVariant::fromValue(dialerUtils));
|
||||||
|
|
||||||
obj->completeInitialization();
|
obj->completeInitialization();
|
||||||
|
|
@ -90,6 +127,9 @@ int main(int argc, char **argv)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tp::SharedPtr<CallHandler> callHandler(new CallHandler(dialerUtils));
|
||||||
|
registrar->registerClient(Tp::AbstractClientPtr::dynamicCast(callHandler), "Phone.Dialer");
|
||||||
|
|
||||||
KPluginMetaData data = obj->package().metadata();
|
KPluginMetaData data = obj->package().metadata();
|
||||||
// About data
|
// About data
|
||||||
KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key());
|
KAboutData aboutData(data.pluginId(), data.name(), data.version(), data.description(), KAboutLicense::byKeyword(data.license()).key());
|
||||||
|
|
@ -133,36 +173,6 @@ int main(int argc, char **argv)
|
||||||
qWarning() << "Error loading the ApplicationWindow";
|
qWarning() << "Error loading the ApplicationWindow";
|
||||||
}
|
}
|
||||||
|
|
||||||
Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
|
|
||||||
Tp::Features() << Tp::Account::FeatureCore
|
|
||||||
);
|
|
||||||
|
|
||||||
Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
|
|
||||||
Tp::Features() << Tp::Connection::FeatureCore
|
|
||||||
<< Tp::Connection::FeatureSelfContact
|
|
||||||
);
|
|
||||||
|
|
||||||
Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
|
|
||||||
channelFactory->addCommonFeatures(Tp::Channel::FeatureCore);
|
|
||||||
channelFactory->addFeaturesForCalls(Tp::Features() << Tp::CallChannel::FeatureContents
|
|
||||||
<< Tp::CallChannel::FeatureCallState
|
|
||||||
<< Tp::CallChannel::FeatureCallMembers
|
|
||||||
<< Tp::CallChannel::FeatureLocalHoldState
|
|
||||||
);
|
|
||||||
|
|
||||||
Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features() << Tp::Contact::FeatureAlias
|
|
||||||
<< Tp::Contact::FeatureAvatarData
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
// app.setQuitOnLastWindowClosed(true);
|
|
||||||
|
|
||||||
Tp::ClientRegistrarPtr registrar =
|
|
||||||
Tp::ClientRegistrar::create(accountFactory, connectionFactory,
|
|
||||||
channelFactory, contactFactory);
|
|
||||||
|
|
||||||
Tp::SharedPtr<CallHandler> callHandler(new CallHandler(dialerUtils));
|
|
||||||
registrar->registerClient(Tp::AbstractClientPtr::dynamicCast(callHandler), "Phone.Dialer");
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue