Commit 6107e39f authored by Bhushan Shah's avatar Bhushan Shah 📱

dialer: remove from repository

This has been split into separate repository at :
https://invent.kde.org/kde/plasma-dialer/
parent 8f7db8a9
......@@ -27,9 +27,8 @@ include(FeatureSummary)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick Test Sql)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n KIO People)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n KIO)
find_package(KF5 REQUIRED COMPONENTS PlasmaQuick DBusAddons Notifications)
find_package(TelepathyQt5 REQUIRED)
find_package(KF5Wayland CONFIG)
set_package_properties(KF5Wayland PROPERTIES
TYPE REQUIRED
......@@ -54,7 +53,6 @@ install( DIRECTORY qtvirtualkeyboardplugin/ DESTINATION ${KDE_INSTALL_QMLDIR}/Qt
add_subdirectory(bin)
add_subdirectory(applets)
add_subdirectory(containments)
add_subdirectory(dialer)
add_subdirectory(sounds)
#add_subdirectory(touchscreentest)
......
install(FILES metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.dialer.desktop)
install(FILES dialer.svg DESTINATION ${KDE_INSTALL_FULL_ICONDIR}/hicolor/scalable/apps/)
include_directories(${TELEPATHY_QT5_INCLUDE_DIR})
#
add_subdirectory(src)
<?xml version="1.0" encoding="UTF-8"?>
<svg width="48" height="48" version="1.1" viewBox="0 0 12.7 12.7" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="linearGradient4886">
<stop stop-color="#34495e" offset="0"/>
<stop stop-color="#2980b9" stop-opacity=".23451327" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient3861" x1="24" x2="24" y1="294" y2="257" gradientTransform="matrix(.26458333 0 0 .25828372 0 -64.293749)" gradientUnits="userSpaceOnUse">
<stop stop-color="#1d99f3" offset="0"/>
<stop stop-color="#3daee9" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient4824" x1="8.7066565" x2="57.365421" y1="10.199831" y2="58.858597" gradientTransform="scale(.26458333)" gradientUnits="userSpaceOnUse">
<stop stop-color="#fcfcfc" offset="0"/>
<stop stop-color="#fff" stop-opacity=".36725664" offset="1"/>
</linearGradient>
<linearGradient id="linearGradient4832" x1="7.5606313" x2="30.16894" y1="1.7317699" y2="24.340078" gradientTransform="scale(.26458334)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient4886"/>
<linearGradient id="linearGradient4865" x1="96.583733" x2="148.57768" y1="106.90627" y2="158.90022" gradientTransform="scale(.26458333)" gradientUnits="userSpaceOnUse" xlink:href="#linearGradient4886"/>
</defs>
<metadata>
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
<dc:title/>
</cc:Work>
</rdf:RDF>
</metadata>
<g stroke-width=".26458332">
<rect x="1.0583333" y="1.0583333" width="10.583333" height="10.583333" ry="1.8520839" fill="#2980b9" style="paint-order:markers fill stroke"/>
<rect x="1.0583333" y="1.0583333" width="10.583333" height="10.318749" ry="1.8079867" fill="url(#linearGradient3861)" style="paint-order:markers fill stroke"/>
<path transform="scale(.26458333)" d="m39.535156 33.705078c1.427335 1.425988 0 2.853516 0 2.853516l-2.234375 2.234375c-2.193735 2.193736-9.802268 0.002382-13.466797-3.66211l7.869141 7.869141h5.462891c3.172977 0 5.819572-2.144357 6.595703-5.066406l-4.226563-4.228516z" fill="url(#linearGradient4865)" opacity=".48200001" style="paint-order:normal"/>
</g>
<path d="m5.273159 3.7310126c0.3776498 0.3776493 0 0.754871 0 0.754871l-0.1886837 0.1886836c-0.3135807 0.3135807-0.3135804 0.8189314 0 1.1325116l0.7803024 0.7803022 0.1155344 0.1155346 0.7803024 0.7803019c0.3135803 0.313581 0.8189311 0.313581 1.1325113 0l0.1886841-0.1886834s0.3769342-0.3773105 0.7544606-2.8e-4l1.4e-4 -1.4e-4z" fill="url(#linearGradient4832)" opacity=".48200001" stroke-width=".07000434"/>
<rect x="1.8551151" y="6.0670886" width=".15750976" height=".017501084" ry=".0087505421" fill="#fdbc4b" stroke-width=".26458332" style="paint-order:normal"/>
<path d="m3.6497222 2.1075024c-0.3772926-0.377649-0.7548832 0-0.7548832 0l-0.5912028 0.5912029c-0.5804255 0.5804254-8.202e-4 2.5933061 0.968741 3.5628791l1.4591056 1.4591059 0.1155338 0.1155335 1.4591056 1.4591056c0.969573 0.9695726 2.9824537 1.5491666 3.5628791 0.9687416l0.5912027-0.5912032s0.377649-0.3775908 0-0.7548835l-1.6234631-1.6234632c-0.3776488-0.3776493-0.7548833 0-0.7548833 0l-0.1887209 0.1887207c-0.3135807 0.3135807-0.8189375 0.3135807-1.132518 3e-7l-0.7803105-0.7803102-0.1155335-0.1155335-0.7803102-0.7803105c-0.3135804-0.3135802-0.3135807-0.8189375 0-1.1325183l0.1887207-0.1887206s0.3776498-0.377234 0-0.7548833z" fill="url(#linearGradient4824)" stroke-width=".26458332"/>
<flowRoot fill="#000000" font-family="sans-serif" font-size="10.583334px" letter-spacing="0px" stroke-width=".26458335" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><flowRegion><rect x="-215.52615" y="-106.53525" width="190.08208" height="166.50893" stroke-width=".07000434"/></flowRegion><flowPara/></flowRoot>
</svg>
[Desktop Entry]
Comment=Plasma phone dialer
Comment[ca]=Marcador del telèfon del Plasma
Comment[ca@valencia]=Marcador del telèfon del Plasma
Comment[da]=Opkaldstastatur til telefon
Comment[en_GB]=Plasma phone dialer
Comment[es]=Marcador del teléfono Plasma
Comment[et]=Plasma kõnevalija
Comment[eu]=Plasma telefonoko markatzailea
Comment[fi]=Plasman numerovalitsin
Comment[fr]=Centre d'appel Plasma du téléphone
Comment[gl]=Marcador de números de teléfono de Plasma.
Comment[hu]=Plasma tárcsázó
Comment[id]=Pendial ponsel Plasma
Comment[it]=Combinatore telefonico di Plasma
Comment[ko]=Plasma 전화 다이얼
Comment[lt]=Plasma telefono numerio rinkiklis
Comment[nl]=Telefoonkiezer van Plasma
Comment[nn]=Telefonringjar for Plasma
Comment[pl]=Pole wybierania telefonu
Comment[pt]=Teclado do Plasma
Comment[pt_BR]=Discador do telefone Plasma
Comment[ru]=Номеронабиратель Plasma для телефона
Comment[sk]=Plasma vytáčanie telefónu
Comment[sv]=Plasma telefonuppringning
Comment[tr]=Plasma telefon çevirici
Comment[uk]=Засіб набирання номеру Плазми
Comment[x-test]=xxPlasma phone dialerxx
Comment[zh_CN]=Plasma 手机拨号器
Comment[zh_TW]=Plasma 手機撥號程式
Encoding=UTF-8
Keywords=
Name=Phone
Name[ca]=Telèfon
Name[ca@valencia]=Telèfon
Name[cs]=Telefon
Name[da]=Telefon
Name[de]=Telefon
Name[en_GB]=Phone
Name[es]=Teléfono
Name[et]=Telefon
Name[eu]=Telefonoa
Name[fi]=Phone
Name[fr]=Téléphone
Name[gl]=Teléfono
Name[hu]=Telefon
Name[ia]=Telephono
Name[id]=Ponsel
Name[it]=Telefono
Name[ko]=전화
Name[lt]=Telefonas
Name[nl]=Telefoon
Name[nn]=Telefon
Name[pl]=Telefon
Name[pt]=Telefone
Name[pt_BR]=Telefone
Name[ru]=Телефон
Name[sk]=Telefón
Name[sv]=Telefon
Name[tr]=Telefon
Name[uk]=Телефон
Name[x-test]=xxPhonexx
Name[zh_CN]=手机
Name[zh_TW]=電話
Type=Application
Icon=dialer
Exec=plasmaphonedialer %u
MimeType=x-scheme-handler/tel
set(plasmaphonedialer_SRCS
main.cpp
dialerutils.cpp
call-handler.cpp
callhistorymodel.cpp
call-manager.cpp
resources.qrc
)
add_executable(plasmaphonedialer ${plasmaphonedialer_SRCS})
target_compile_definitions(plasmaphonedialer PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
find_package(PhoneNumber COMPONENTS PhoneNumber REQUIRED)
target_link_libraries(plasmaphonedialer
PhoneNumber::PhoneNumber
Qt5::Gui
Qt5::Quick
Qt5::Widgets
Qt5::Sql
KF5::Declarative
KF5::I18n
KF5::QuickAddons
KF5::DBusAddons
KF5::Notifications
${TELEPATHY_QT5_LIBRARIES}
)
install(TARGETS plasmaphonedialer ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES plasma_dialer.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR})
configure_file(org.freedesktop.Telepathy.Client.Plasma.Dialer.service.in
org.freedesktop.Telepathy.Client.Plasma.Dialer.service)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.freedesktop.Telepathy.Client.Plasma.Dialer.service
DESTINATION ${DBUS_SERVICES_INSTALL_DIR})
install(FILES Plasma.Dialer.client DESTINATION ${SHARE_INSTALL_PREFIX}/telepathy/clients/)
[org.freedesktop.Telepathy.Client]
Interfaces=org.freedesktop.Telepathy.Client.Handler
[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 0]
org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call1
org.freedesktop.Telepathy.Channel.TargetHandleType u=1
[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 1]
org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call1
org.freedesktop.Telepathy.Channel.TargetHandleType u=1
org.freedesktop.Telepathy.Channel.Type.Call1.InitialAudio b=true
[org.freedesktop.Telepathy.Client.Handler.HandlerChannelFilter 2]
org.freedesktop.Telepathy.Channel.ChannelType s=org.freedesktop.Telepathy.Channel.Type.Call1
org.freedesktop.Telepathy.Channel.TargetHandleType u=1
org.freedesktop.Telepathy.Channel.Type.Call1.InitialVideo b=true
[org.freedesktop.Telepathy.Client.Handler]
BypassApproval=true
[org.freedesktop.Telepathy.Client.Handler.Capabilities]
org.freedesktop.Telepathy.Channel.Type.Call1/audio=true
org.freedesktop.Telepathy.Channel.Type.Call1/video=false
org.freedesktop.Telepathy.Channel.Type.Call1/ice=true
org.freedesktop.Telepathy.Channel.Type.Call1/gtalk-p2p=false
org.freedesktop.Telepathy.Channel.Type.Call1/shm=true
org.freedesktop.Telepathy.Channel.Type.Call1/video/h264=false
/*
Copyright (C) 2009-2012 George Kiagiadakis <kiagiadakis.george@gmail.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 2 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/>.
*/
#include "call-handler.h"
#include "call-manager.h"
#include "dialerutils.h"
#include <TelepathyQt/CallChannel>
#include <TelepathyQt/ChannelClassSpec>
static inline Tp::ChannelClassSpecList channelClassSpecList()
{
return Tp::ChannelClassSpecList() << Tp::ChannelClassSpec::audioCall();
}
static inline Tp::AbstractClientHandler::Capabilities capabilities()
{
Tp::AbstractClientHandler::Capabilities caps;
//we support both audio and video in calls
caps.setToken(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String("/audio"));
//transport methods - farstream supports them all
caps.setToken(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String("/ice"));
caps.setToken(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String("/gtalk-p2p"));
caps.setToken(TP_QT_IFACE_CHANNEL_TYPE_CALL + QLatin1String("/shm"));
return caps;
}
CallHandler::CallHandler(DialerUtils *utils)
: Tp::AbstractClientHandler(channelClassSpecList(), capabilities())
{
m_dialerUtils = utils;
m_dialerUtils->setCallState("idle");
qDebug() << "Call handler ready";
}
CallHandler::~CallHandler()
= default;
bool CallHandler::bypassApproval() const
{
return true;
}
void CallHandler::handleChannels(const Tp::MethodInvocationContextPtr<> & context,
const Tp::AccountPtr & account,
const Tp::ConnectionPtr & connection,
const QList<Tp::ChannelPtr> & channels,
const QList<Tp::ChannelRequestPtr> & requestsSatisfied,
const QDateTime & userActionTime,
const Tp::AbstractClientHandler::HandlerInfo & handlerInfo)
{
Q_UNUSED(account);
Q_UNUSED(connection);
Q_UNUSED(requestsSatisfied);
Q_UNUSED(userActionTime);
Q_UNUSED(handlerInfo);
Q_FOREACH(const Tp::ChannelPtr & channel, channels) {
Tp::CallChannelPtr callChannel = Tp::CallChannelPtr::qObjectCast(channel);
if (!callChannel) {
qDebug() << "Channel is not a Call channel. Ignoring";
continue;
}
//check if any call manager is already handling this channel
if (!handledCallChannels.contains(callChannel)) {
handledCallChannels.append(callChannel);
new CallManager(callChannel, m_dialerUtils, this);
}
}
context->setFinished();
}
/*
Copyright (C) 2009 George Kiagiadakis <kiagiadakis.george@gmail.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 2 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/>.
*/
#ifndef CALL_HANDLER_H
#define CALL_HANDLER_H
#include <TelepathyQt/AbstractClientHandler>
class DialerUtils;
class CallHandler : public QObject, public Tp::AbstractClientHandler
{
Q_OBJECT
public:
CallHandler(DialerUtils *utils);
~CallHandler() override;
bool bypassApproval() const override;
void handleChannels(const Tp::MethodInvocationContextPtr<> & context,
const Tp::AccountPtr & account,
const Tp::ConnectionPtr & connection,
const QList<Tp::ChannelPtr> & channels,
const QList<Tp::ChannelRequestPtr> & requestsSatisfied,
const QDateTime & userActionTime,
const Tp::AbstractClientHandler::HandlerInfo & handlerInfo) override;
private:
QList<Tp::CallChannelPtr> handledCallChannels;
DialerUtils *m_dialerUtils;
};
#endif
This diff is collapsed.
/*
Copyright (C) 2012 George Kiagiadakis <kiagiadakis.george@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CALL_MANAGER_H
#define CALL_MANAGER_H
#include <QObject>
#include <TelepathyQt/CallChannel>
class DialerUtils;
class CallManager : public QObject
{
Q_OBJECT
public:
explicit CallManager(const Tp::CallChannelPtr &callChannel, DialerUtils *dialerUtils, QObject *parent = nullptr);
~CallManager() override;
private Q_SLOTS:
void onCallStateChanged(Tp::CallState state);
void onCallAccepted();
void onCallRejected();
void onHangUpRequested();
private:
void ensureCallWindow();
private:
struct Private;
Private *const d;
};
#endif // CALL_MANAGER_H
/*
Copyright (C) 2019 Nicolas Fella <nicolas.fella@gmx.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "callhistorymodel.h"
#include <QDateTime>
#include <QStandardPaths>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>
CallHistoryModel::CallHistoryModel(QObject *parent)
: QAbstractListModel(parent)
, m_db(QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), QStringLiteral("calldb")))
{
m_db.setDatabaseName(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "plasmaphonedialerdb.sqlite");
bool open = m_db.open();
if (!open) {
qWarning() << "Could not open call database" << m_db.lastError();
}
QSqlQuery createTable(m_db);
createTable.exec(QStringLiteral("CREATE TABLE IF NOT EXISTS History(id INTEGER PRIMARY KEY AUTOINCREMENT, number TEXT, time DATETIME, duration INTEGER, callType INTEGER)"));
QSqlQuery fetchCalls(m_db);
fetchCalls.exec(QStringLiteral("SELECT id, number, time, duration, callType FROM History"));
beginResetModel();
while (fetchCalls.next()) {
CallData call;
call.id = fetchCalls.value(0).toString();
call.number = fetchCalls.value(1).toString();
call.time = QDateTime::fromMSecsSinceEpoch(fetchCalls.value(2).toInt());
call.duration = fetchCalls.value(3).toInt();
call.callType = fetchCalls.value(4).toInt();
m_calls.append(call);
}
endResetModel();
}
void CallHistoryModel::addCall(QString number, int duration, int type)
{
beginInsertRows(QModelIndex(), m_calls.size(), m_calls.size());
QSqlQuery putCall(m_db);
putCall.prepare(QStringLiteral("INSERT INTO History (number, time, duration, callType) VALUES (:number, :time, :duration, :callType)"));
putCall.bindValue(":number", number);
putCall.bindValue(":time", QDateTime::currentDateTime().toMSecsSinceEpoch());
putCall.bindValue(":duration", duration);
putCall.bindValue(":callType", type);
putCall.exec();
CallData data;
data.id = putCall.lastInsertId().toString();
data.number = number;
data.duration = duration;
data.time = QDateTime::currentDateTime();
data.callType = type;
m_calls.append(data);
endInsertRows();
}
void CallHistoryModel::clear()
{
beginResetModel();
QSqlQuery clearCalls(m_db);
clearCalls.exec(QStringLiteral("DELETE FROM History"));
m_calls.clear();
endResetModel();
}
QVariant CallHistoryModel::data(const QModelIndex& index, int role) const
{
int row = index.row();
switch (role) {
case Roles::PhoneNumberRole:
return m_calls[row].number;
case Roles::CallTypeRole:
return m_calls[row].callType;
case Roles::DurationRole:
return m_calls[row].duration;
case Roles::TimeRole:
return m_calls[row].time;
case Roles::IdRole:
return m_calls[row].id;
}
return {};
}
int CallHistoryModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return m_calls.size();
}
QHash<int, QByteArray> CallHistoryModel::roleNames() const
{
QHash<int, QByteArray> roleNames;
roleNames[PhoneNumberRole] = "number";
roleNames[CallTypeRole] = "time";
roleNames[DurationRole] = "duration";
roleNames[TimeRole] = "callType";
roleNames[IdRole] = "dbid";
return roleNames;
}
bool CallHistoryModel::removeRows(int row, int count, const QModelIndex &parent)
{
Q_UNUSED(count)
beginRemoveRows(parent, row, row);
QSqlQuery remove(m_db);
remove.prepare(QStringLiteral("DELETE FROM History WHERE id=:id"));
remove.bindValue(":id", m_calls[row].id);
remove.exec();
endRemoveRows();
return true;
}
void CallHistorySortFilterModel::remove(int index)
{
QSortFilterProxyModel::removeRow(index);
}
void CallHistorySortFilterModel::sort(int column, Qt::SortOrder order)
{
QSortFilterProxyModel::sort(column, order);
}
/*
Copyright (C) 2019 Nicolas Fella <nicolas.fella@gmx.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <QAbstractListModel>
#include <QSortFilterProxyModel>
#include <QSqlDatabase>
#include <QDateTime>
#include <QVector>
struct CallData {
QString id;
QString number;
QDateTime time;
int duration;
int callType;
};
class CallHistoryModel : public QAbstractListModel
{
Q_OBJECT
public:
CallHistoryModel(QObject *parent = nullptr);
enum Roles {
PhoneNumberRole = Qt::UserRole + 1,
DurationRole,
TimeRole,
CallTypeRole,
IdRole
};
Q_ENUM(Roles)
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE void addCall(QString number, int duration, int type);
Q_INVOKABLE void clear();
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
private:
QSqlDatabase m_db;
QVector<CallData> m_calls;
};
class CallHistorySortFilterModel : public QSortFilterProxyModel
{
Q_OBJECT
public:
Q_INVOKABLE void remove(int index);
Q_INVOKABLE void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
};
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library 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
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**/
#include "dialerutils.h"
#include <QDebug>
#include <TelepathyQt/PendingOperation>
#include <TelepathyQt/PendingChannelRequest>
#include <TelepathyQt/PendingReady>
#include <TelepathyQt/Constants>
#include <TelepathyQt/PendingContacts>
#include <TelepathyQt/Types>
#include <TelepathyQt/ContactManager>
#include "phonenumbers/phonenumberutil.h"
#include "phonenumbers/asyoutypeformatter.h"
DialerUtils::DialerUtils(const Tp::AccountPtr &simAccount, QObject *parent)
: QObject(parent),
m_missedCalls(0),
m_simAccount(simAccount),
m_callDuration(0),
m_callContactAlias(QString())
{
if (!m_simAccount) {
return;
}
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()
= default;
void DialerUtils::dial(const QString &number)
{
// FIXME: this should be replaced by kpeople thing
qDebug() << "Starting call...";
if (m_simAccount) {
Tp::PendingChannelRequest *pendingChannel = m_simAccount->ensureAudioCall(number);
connect(pendingChannel, &Tp::PendingChannelRequest::finished, pendingChannel, [=](){
if (pendingChannel->isError()) {
qWarning() << "Error when requesting channel" << pendingChannel->errorMessage();
setCallState("failed");
}
});
} else {
setCallState("failed");
}
}
QString DialerUtils::callState() const
{
return m_callState;
}