/**
* Copyright (C) 2013 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, 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 .
*
* Authors: Tiago Salem Herrmann
*/
#ifndef OFONOCONNECTION_H
#define OFONOCONNECTION_H
// qt
#include
// telepathy-qt
#include
#include
#include
#include
#include
// ofono-qt
#include
#include
#include
#include
#include
#include
#include
// telepathy-ofono
#include "ofonotextchannel.h"
#include "ofonocallchannel.h"
#include "voicemailiface.h"
#include "mmsdmanager.h"
#include "mmsdmessage.h"
#include "dbustypes.h"
#include "speakeriface.h"
class oFonoConnection;
class oFonoTextChannel;
class oFonoCallChannel;
class MMSDService;
class oFonoConnection : public Tp::BaseConnection
{
Q_OBJECT
Q_DISABLE_COPY(oFonoConnection)
public:
oFonoConnection(const QDBusConnection &dbusConnection,
const QString &cmName,
const QString &protocolName,
const QVariantMap ¶meters);
QStringList inspectHandles(uint handleType, const Tp::UIntList& handles, Tp::DBusError *error);
Tp::UIntList requestHandles(uint handleType, const QStringList& identifiers, Tp::DBusError* error);
Tp::BaseChannelPtr createChannel(const QString& channelType, uint targetHandleType,
uint targetHandle, Tp::DBusError *error);
Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
void connect(Tp::DBusError *error);
void setOnline(bool online);
void setSpeakerMode(bool active);
bool speakerMode();
bool voicemailIndicator(Tp::DBusError *error);
QString voicemailNumber(Tp::DBusError *error);
uint voicemailCount(Tp::DBusError *error);
Tp::BaseConnectionRequestsInterfacePtr requestsIface;
Tp::BaseConnectionSimplePresenceInterfacePtr simplePresenceIface;
Tp::BaseConnectionContactsInterfacePtr contactsIface;
BaseConnectionVoicemailInterfacePtr voicemailIface;
uint newHandle(const QString &identifier);
OfonoMessageManager *messageManager();
OfonoVoiceCallManager *voiceCallManager();
OfonoCallVolume *callVolume();
uint ensureHandle(const QString &phoneNumber);
Tp::BaseChannelPtr createTextChannel(uint targetHandleType,
uint targetHandle, Tp::DBusError *error);
Tp::BaseChannelPtr createCallChannel(uint targetHandleType,
uint targetHandle, Tp::DBusError *error);
~oFonoConnection();
Q_SIGNALS:
void speakerModeChanged(bool active);
public Q_SLOTS:
void Q_DBUS_EXPORT onTryRegister();
void updateAudioRoute();
private Q_SLOTS:
void onOfonoIncomingMessage(const QString &message, const QVariantMap &info);
void onOfonoCallAdded(const QString &call, const QVariantMap &properties);
void onOfonoNetworkRegistrationChanged(const QString &status);
void onTextChannelClosed();
void onCallChannelClosed();
void onValidityChanged(bool valid);
void onMMSDServiceAdded(const QString&);
void onMMSDServiceRemoved(const QString&);
void onMMSAdded(const QString &, const QVariantMap&);
void onMMSRemoved(const QString &);
void onMMSPropertyChanged(QString property, QVariant value);
void onCheckMMSServices();
void onMessageRead(const QString &id);
private:
bool isNetworkRegistered();
void addMMSToService(const QString &path, const QVariantMap &properties, const QString &servicePath);
QMap mHandles;
QMap mTextChannels;
QMap mCallChannels;
QStringList mModems;
OfonoModemManager *mOfonoModemManager;
OfonoMessageManager *mOfonoMessageManager;
OfonoVoiceCallManager *mOfonoVoiceCallManager;
OfonoCallVolume *mOfonoCallVolume;
OfonoNetworkRegistration *mOfonoNetworkRegistration;
OfonoMessageWaiting *mOfonoMessageWaiting;
uint mHandleCount;
Tp::SimplePresence mSelfPresence;
Tp::SimplePresence mRequestedSelfPresence;
QTimer *mRegisterTimer;
MMSDManager *mMmsdManager;
QMap mMmsdServices;
QMap > mServiceMMSList;
bool mSpeakerMode;
};
#endif