telepathy-ofono-0.2+14.04.20140407/ 0000755 0000153 0177776 00000000000 12320627204 017065 5 ustar pbuser nogroup 0000000 0000000 telepathy-ofono-0.2+14.04.20140407/voicemailiface.cpp 0000644 0000153 0177776 00000015706 12320626651 022547 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include
#include
#include "voicemailiface.h"
// Conn.I.Voicemail
BaseConnectionVoicemailInterface::Adaptee::Adaptee(BaseConnectionVoicemailInterface *interface)
: QObject(interface),
mInterface(interface)
{
}
struct TP_QT_NO_EXPORT BaseConnectionVoicemailInterface::Private {
Private(BaseConnectionVoicemailInterface *parent)
: adaptee(new BaseConnectionVoicemailInterface::Adaptee(parent)) {
}
VoicemailCountCallback voicemailCountCB;
VoicemailNumberCallback voicemailNumberCB;
VoicemailIndicatorCallback voicemailIndicatorCB;
BaseConnectionVoicemailInterface::Adaptee *adaptee;
};
BaseConnectionVoicemailInterface::Adaptee::~Adaptee()
{
}
void BaseConnectionVoicemailInterface::Adaptee::voicemailIndicator(const ConnectionInterfaceVoicemailAdaptor::VoicemailIndicatorContextPtr &context)
{
if (!mInterface->mPriv->voicemailIndicatorCB.isValid()) {
context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
return;
}
Tp::DBusError error;
bool active = mInterface->mPriv->voicemailIndicatorCB(&error);
if (error.isValid()) {
context->setFinishedWithError(error.name(), error.message());
return;
}
context->setFinished(active);
}
void BaseConnectionVoicemailInterface::Adaptee::voicemailNumber(const ConnectionInterfaceVoicemailAdaptor::VoicemailNumberContextPtr &context)
{
if (!mInterface->mPriv->voicemailNumberCB.isValid()) {
context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
return;
}
Tp::DBusError error;
QString number = mInterface->mPriv->voicemailNumberCB(&error);
if (error.isValid()) {
context->setFinishedWithError(error.name(), error.message());
return;
}
context->setFinished(number);
}
void BaseConnectionVoicemailInterface::Adaptee::voicemailCount(const ConnectionInterfaceVoicemailAdaptor::VoicemailCountContextPtr &context)
{
if (!mInterface->mPriv->voicemailCountCB.isValid()) {
context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
return;
}
Tp::DBusError error;
uint count = mInterface->mPriv->voicemailCountCB(&error);
if (error.isValid()) {
context->setFinishedWithError(error.name(), error.message());
return;
}
context->setFinished(count);
}
BaseConnectionVoicemailInterface::BaseConnectionVoicemailInterface()
: AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_VOICEMAIL),
mPriv(new Private(this))
{
}
BaseConnectionVoicemailInterface::~BaseConnectionVoicemailInterface()
{
delete mPriv;
}
void BaseConnectionVoicemailInterface::setVoicemailIndicatorCallback(const VoicemailIndicatorCallback &cb)
{
mPriv->voicemailIndicatorCB = cb;
}
void BaseConnectionVoicemailInterface::setVoicemailNumberCallback(const VoicemailNumberCallback &cb)
{
mPriv->voicemailNumberCB = cb;
}
void BaseConnectionVoicemailInterface::setVoicemailCountCallback(const VoicemailCountCallback &cb)
{
mPriv->voicemailCountCB = cb;
}
void BaseConnectionVoicemailInterface::setVoicemailCount(int count)
{
Q_EMIT mPriv->adaptee->voicemailCountChanged(uint(count));
}
void BaseConnectionVoicemailInterface::setVoicemailIndicator(bool active)
{
Q_EMIT mPriv->adaptee->voicemailIndicatorChanged(active);
}
QVariantMap BaseConnectionVoicemailInterface::immutableProperties() const
{
QVariantMap map;
return map;
}
void BaseConnectionVoicemailInterface::createAdaptor()
{
(void) new ConnectionInterfaceVoicemailAdaptor(dbusObject()->dbusConnection(),
mPriv->adaptee, dbusObject());
}
ConnectionInterfaceVoicemailAdaptor::ConnectionInterfaceVoicemailAdaptor(const QDBusConnection& bus, QObject* adaptee, QObject* parent)
: Tp::AbstractAdaptor(bus, adaptee, parent)
{
connect(adaptee, SIGNAL(voicemailCountChanged(uint)), SIGNAL(VoicemailCountChanged(uint)));
connect(adaptee, SIGNAL(voicemailIndicatorChanged(bool)), SIGNAL(VoicemailIndicatorChanged(bool)));
}
ConnectionInterfaceVoicemailAdaptor::~ConnectionInterfaceVoicemailAdaptor()
{
}
bool ConnectionInterfaceVoicemailAdaptor::VoicemailIndicator(const QDBusMessage& dbusMessage)
{
if (!adaptee()->metaObject()->indexOfMethod("voicemailIndicator(ConnectionInterfaceVoicemailAdaptor::VoicemailIndicatorContextPtr)") == -1) {
dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
return bool();
}
VoicemailIndicatorContextPtr ctx = VoicemailIndicatorContextPtr(
new Tp::MethodInvocationContext< bool >(dbusConnection(), dbusMessage));
QMetaObject::invokeMethod(adaptee(), "voicemailIndicator",
Q_ARG(ConnectionInterfaceVoicemailAdaptor::VoicemailIndicatorContextPtr, ctx));
return bool();
}
QString ConnectionInterfaceVoicemailAdaptor::VoicemailNumber(const QDBusMessage& dbusMessage)
{
if (!adaptee()->metaObject()->indexOfMethod("voicemailNumber(ConnectionInterfaceVoicemailAdaptor::VoicemailNumberContextPtr)") == -1) {
dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
return QString();
}
VoicemailNumberContextPtr ctx = VoicemailNumberContextPtr(
new Tp::MethodInvocationContext< QString >(dbusConnection(), dbusMessage));
QMetaObject::invokeMethod(adaptee(), "voicemailNumber",
Q_ARG(ConnectionInterfaceVoicemailAdaptor::VoicemailNumberContextPtr, ctx));
return QString();
}
uint ConnectionInterfaceVoicemailAdaptor::VoicemailCount(const QDBusMessage& dbusMessage)
{
if (!adaptee()->metaObject()->indexOfMethod("voicemailCount(ConnectionInterfaceVoicemailAdaptor::VoicemailCountContextPtr)") == -1) {
dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")));
return uint();
}
VoicemailCountContextPtr ctx = VoicemailCountContextPtr(
new Tp::MethodInvocationContext< uint >(dbusConnection(), dbusMessage));
QMetaObject::invokeMethod(adaptee(), "voicemailCount",
Q_ARG(ConnectionInterfaceVoicemailAdaptor::VoicemailCountContextPtr, ctx));
return uint();
}
telepathy-ofono-0.2+14.04.20140407/mmsdservice.cpp 0000644 0000153 0177776 00000007705 12320626651 022130 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include
#include "dbustypes.h"
#include "mmsdservice.h"
QDBusArgument &operator<<(QDBusArgument &argument, const MessageStruct &message)
{
argument.beginStructure();
argument << message.path << message.properties;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, MessageStruct &message)
{
argument.beginStructure();
argument >> message.path >> message.properties;
argument.endStructure();
return argument;
}
MMSDService::MMSDService(QString objectPath, oFonoConnection* connection, QObject *parent)
: QObject(parent),
m_servicePath(objectPath)
{
QDBusReply replyMessages;
QDBusReply replyProperties;
QDBusMessage request;
qDBusRegisterMetaType();
qDBusRegisterMetaType();
request = QDBusMessage::createMethodCall("org.ofono.mms",
m_servicePath, "org.ofono.mms.Service",
"GetProperties");
replyProperties = QDBusConnection::sessionBus().call(request);
m_properties = replyProperties;
request = QDBusMessage::createMethodCall("org.ofono.mms",
m_servicePath, "org.ofono.mms.Service",
"GetMessages");
replyMessages = QDBusConnection::sessionBus().call(request);
m_messages = replyMessages;
QDBusConnection::sessionBus().connect("org.ofono.mms", m_servicePath, "org.ofono.mms.Service",
"MessageAdded", this,
SLOT(onMessageAdded(const QDBusObjectPath&, const QVariantMap&)));
QDBusConnection::sessionBus().connect("org.ofono.mms", m_servicePath, "org.ofono.mms.Service",
"MessageRemoved", this,
SLOT(onMessageRemoved(const QDBusObjectPath&)));
}
MMSDService::~MMSDService()
{
}
QString MMSDService::path() const
{
return m_servicePath;
}
QVariantMap MMSDService::properties() const
{
return m_properties;
}
MessageList MMSDService::messages() const
{
return m_messages;
}
void MMSDService::onMessageAdded(const QDBusObjectPath &path, const QVariantMap &properties)
{
qDebug() << "message added" << path.path() << properties;
Q_EMIT messageAdded(path.path(), properties);
}
void MMSDService::onMessageRemoved(const QDBusObjectPath& path)
{
qDebug() << "message removed" << path.path();
Q_EMIT messageRemoved(path.path());
}
QDBusObjectPath MMSDService::sendMessage(QStringList recipients, QString smil, AttachmentList attachments)
{
QDBusMessage request;
QList arguments;
QDBusReply reply;
arguments.append(recipients);
arguments.append(smil);
arguments.append(QVariant::fromValue(attachments));
request = QDBusMessage::createMethodCall("org.ofono.mms",
m_servicePath, "org.ofono.mms.Service",
"SendMessage");
request.setArguments(arguments);
reply = QDBusConnection::sessionBus().call(request);
return reply;
}
telepathy-ofono-0.2+14.04.20140407/dbustypes.h 0000644 0000153 0177776 00000002322 12320626651 021264 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 DBUSTYPES
#define DBUSTYPES
struct MessageStruct {
QDBusObjectPath path;
QVariantMap properties;
};
struct AttachmentStruct {
QString id;
QString contentType;
QString filePath;
quint64 offset;
quint64 length;
};
typedef QList AttachmentList;
Q_DECLARE_METATYPE(AttachmentStruct)
Q_DECLARE_METATYPE(AttachmentList)
typedef QList MessageList;
Q_DECLARE_METATYPE(MessageStruct)
Q_DECLARE_METATYPE(MessageList)
#endif
telepathy-ofono-0.2+14.04.20140407/cmake/ 0000755 0000153 0177776 00000000000 12320627204 020145 5 ustar pbuser nogroup 0000000 0000000 telepathy-ofono-0.2+14.04.20140407/cmake/modules/ 0000755 0000153 0177776 00000000000 12320627204 021615 5 ustar pbuser nogroup 0000000 0000000 telepathy-ofono-0.2+14.04.20140407/cmake/modules/FindLcov.cmake 0000644 0000153 0177776 00000001720 12320626651 024330 0 ustar pbuser nogroup 0000000 0000000 # - Find lcov
# Will define:
#
# LCOV_EXECUTABLE - the lcov binary
# GENHTML_EXECUTABLE - the genhtml executable
#
# Copyright (C) 2010 by Johannes Wienke
#
# 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, 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.
#
INCLUDE(FindPackageHandleStandardArgs)
FIND_PROGRAM(LCOV_EXECUTABLE lcov)
FIND_PROGRAM(GENHTML_EXECUTABLE genhtml)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE)
# only visible in advanced view
MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
telepathy-ofono-0.2+14.04.20140407/cmake/modules/EnableCoverageReport.cmake 0000644 0000153 0177776 00000015311 12320626651 026663 0 ustar pbuser nogroup 0000000 0000000 # - Creates a special coverage build type and target on GCC.
#
# Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target
# for selected targets. Optional arguments to this function are used to filter
# unwanted results using globbing expressions. Moreover targets with tests for
# the source code can be specified to trigger regenerating the report if the
# test has changed
#
# ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...])
#
# To generate a coverage report first build the project with
# CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage.
#
# The coverage report is based on gcov. Depending on the availability of lcov
# a HTML report will be generated and/or an XML report of gcovr is found.
# The generated coverage target executes all found solutions. Special targets
# exist to create e.g. only the xml report: coverage-xml.
#
# Copyright (C) 2010 by Johannes Wienke
#
# 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, 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.
#
INCLUDE(ParseArguments)
FIND_PACKAGE(Lcov)
FIND_PACKAGE(gcovr)
FUNCTION(ENABLE_COVERAGE_REPORT)
# argument parsing
PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN})
SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info")
SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info")
SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport")
SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml")
SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake")
# decide if there is any tool to create coverage data
SET(TOOL_FOUND FALSE)
IF(LCOV_FOUND OR GCOVR_FOUND)
SET(TOOL_FOUND TRUE)
ENDIF()
IF(NOT TOOL_FOUND)
MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.")
ENDIF()
STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE)
IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage")
MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}")
# create coverage build type
SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE)
SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE)
# instrument targets
SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage
LINK_FLAGS --coverage)
# html report
IF (LCOV_FOUND)
MESSAGE(STATUS "Enabling HTML coverage report")
# set up coverage target
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE}
COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Collecting coverage data"
DEPENDS ${ARG_TARGETS} ${ARG_TESTS}
VERBATIM)
# filter unwanted stuff
LIST(LENGTH ARG_FILTER FILTER_LENGTH)
IF(${FILTER_LENGTH} GREATER 0)
SET(FILTER COMMAND ${LCOV_EXECUTABLE})
FOREACH(F ${ARG_FILTER})
SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F})
ENDFOREACH()
SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE})
ELSE()
SET(FILTER "")
ENDIF()
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE}
COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE}
${FILTER}
DEPENDS ${COVERAGE_RAW_FILE}
COMMENT "Filtering recorded coverage data for project-relevant entries"
VERBATIM)
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR}
COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE}
DEPENDS ${COVERAGE_FILTERED_FILE}
COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}"
VERBATIM)
ADD_CUSTOM_TARGET(coverage-html
DEPENDS ${COVERAGE_REPORT_DIR})
ENDIF()
# xml coverage report
IF(GCOVR_FOUND)
MESSAGE(STATUS "Enabling XML coverage report")
# gcovr cannot write directly to a file so the execution needs to
# be wrapped in a cmake file that generates the file output
FILE(WRITE ${COVERAGE_XML_COMMAND_FILE}
"SET(ENV{LANG} en)\n")
FILE(APPEND ${COVERAGE_XML_COMMAND_FILE}
"EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n")
ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE}
COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE}
COMMENT "Generating coverage XML report"
VERBATIM)
ADD_CUSTOM_TARGET(coverage-xml
DEPENDS ${COVERAGE_XML_FILE})
ENDIF()
# provide a global coverage target executing both steps if available
SET(GLOBAL_DEPENDS "")
IF(LCOV_FOUND)
LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR})
ENDIF()
IF(GCOVR_FOUND)
LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE})
ENDIF()
IF(LCOV_FOUND OR GCOVR_FOUND)
ADD_CUSTOM_TARGET(coverage
DEPENDS ${GLOBAL_DEPENDS})
ENDIF()
ENDIF()
ENDFUNCTION()
telepathy-ofono-0.2+14.04.20140407/cmake/modules/Findgcovr.cmake 0000644 0000153 0177776 00000001702 12320626651 024545 0 ustar pbuser nogroup 0000000 0000000 # - Find gcovr scrip
# Will define:
#
# GCOVR_EXECUTABLE - the gcovr script
#
# Uses:
#
# GCOVR_ROOT - root to search for the script
#
# Copyright (C) 2011 by Johannes Wienke
#
# 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, 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.
#
INCLUDE(FindPackageHandleStandardArgs)
FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE)
# only visible in advanced view
MARK_AS_ADVANCED(GCOVR_EXECUTABLE)
telepathy-ofono-0.2+14.04.20140407/cmake/modules/ParseArguments.cmake 0000644 0000153 0177776 00000003406 12320626651 025567 0 ustar pbuser nogroup 0000000 0000000 # Parse arguments passed to a function into several lists separated by
# upper-case identifiers and options that do not have an associated list e.g.:
#
# SET(arguments
# hello OPTION3 world
# LIST3 foo bar
# OPTION2
# LIST1 fuz baz
# )
# PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments})
#
# results in 7 distinct variables:
# * ARG_DEFAULT_ARGS: hello;world
# * ARG_LIST1: fuz;baz
# * ARG_LIST2:
# * ARG_LIST3: foo;bar
# * ARG_OPTION1: FALSE
# * ARG_OPTION2: TRUE
# * ARG_OPTION3: TRUE
#
# taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments
MACRO(PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO(PARSE_ARGUMENTS)
telepathy-ofono-0.2+14.04.20140407/pendingmessagesmanager.h 0000644 0000153 0177776 00000002400 12320626651 023746 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include
struct PendingMessage
{
QString recipientId;
QDateTime timestamp;
};
class PendingMessagesManager : public QObject
{
Q_OBJECT
public:
static PendingMessagesManager *instance();
void addPendingMessage(const QString &objectPath, const QString &id);
void removePendingMessage(const QString &objectPath);
QString recipientIdForMessageId(const QString &messageId);
private:
explicit PendingMessagesManager(QObject *parent = 0);
QSqlDatabase mDatabase;
};
telepathy-ofono-0.2+14.04.20140407/ofonotextchannel.cpp 0000644 0000153 0177776 00000035205 12320626661 023162 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
// ofono-qt
#include
// telepathy-ofono
#include "ofonotextchannel.h"
#include "pendingmessagesmanager.h"
QDBusArgument &operator<<(QDBusArgument &argument, const AttachmentStruct &attachment)
{
argument.beginStructure();
argument << attachment.id << attachment.contentType << attachment.filePath << attachment.offset << attachment.length;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, AttachmentStruct &attachment)
{
argument.beginStructure();
argument >> attachment.id >> attachment.contentType >> attachment.filePath >> attachment.offset >> attachment.length;
argument.endStructure();
return argument;
}
oFonoTextChannel::oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, bool flash, QObject *parent):
QObject(parent),
mConnection(conn),
mPhoneNumbers(phoneNumbers),
mFlash(flash),
mMessageCounter(1)
{
qDBusRegisterMetaType();
qDBusRegisterMetaType();
Tp::BaseChannelPtr baseChannel;
if (phoneNumbers.size() == 1) {
baseChannel = Tp::BaseChannel::create(mConnection,
TP_QT_IFACE_CHANNEL_TYPE_TEXT,
mConnection->ensureHandle(mPhoneNumbers[0]),
Tp::HandleTypeContact);
} else {
baseChannel = Tp::BaseChannel::create(mConnection,
TP_QT_IFACE_CHANNEL_TYPE_TEXT,
0,
Tp::HandleTypeNone);
}
Tp::BaseChannelTextTypePtr textType = Tp::BaseChannelTextType::create(baseChannel.data());
baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(textType));
QStringList supportedContentTypes = QStringList() << "text/plain";
Tp::UIntList messageTypes = Tp::UIntList() <<
Tp::ChannelTextMessageTypeNormal <<
Tp::ChannelTextMessageTypeDeliveryReport;
uint messagePartSupportFlags = 0;
uint deliveryReportingSupport = Tp::DeliveryReportingSupportFlagReceiveSuccesses;
mMessagesIface = Tp::BaseChannelMessagesInterface::create(textType.data(),
supportedContentTypes,
messageTypes,
messagePartSupportFlags,
deliveryReportingSupport);
mMessagesIface->setSendMessageCallback(Tp::memFun(this,&oFonoTextChannel::sendMessage));
baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mMessagesIface));
mGroupIface = Tp::BaseChannelGroupInterface::create(Tp::ChannelGroupFlagCanAdd, conn->selfHandle());
mGroupIface->setAddMembersCallback(Tp::memFun(this,&oFonoTextChannel::onAddMembers));
mGroupIface->setRemoveMembersCallback(Tp::memFun(this,&oFonoTextChannel::onRemoveMembers));
baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mGroupIface));
addMembers(phoneNumbers);
mSMSIface = Tp::BaseChannelSMSInterface::create(flash, true);
baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mSMSIface));
mBaseChannel = baseChannel;
mTextChannel = Tp::BaseChannelTextTypePtr::dynamicCast(mBaseChannel->interface(TP_QT_IFACE_CHANNEL_TYPE_TEXT));
mTextChannel->setMessageAcknowledgedCallback(Tp::memFun(this,&oFonoTextChannel::messageAcknowledged));
QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater()));
}
void oFonoTextChannel::onAddMembers(const Tp::UIntList& handles, const QString& message, Tp::DBusError* error)
{
addMembers(mConnection->inspectHandles(Tp::HandleTypeContact, handles, error));
}
void oFonoTextChannel::onRemoveMembers(const Tp::UIntList& handles, const QString& message, Tp::DBusError* error)
{
Q_FOREACH(uint handle, handles) {
Q_FOREACH(const QString &phoneNumber, mConnection->inspectHandles(Tp::HandleTypeContact, Tp::UIntList() << handle, error)) {
mPhoneNumbers.removeAll(phoneNumber);
}
mMembers.removeAll(handle);
}
mGroupIface->removeMembers(handles);
}
void oFonoTextChannel::addMembers(QStringList phoneNumbers)
{
Tp::UIntList handles;
Q_FOREACH(const QString &phoneNumber, phoneNumbers) {
uint handle = mConnection->ensureHandle(phoneNumber);
handles << handle;
if (!mPhoneNumbers.contains(phoneNumber)) {
mPhoneNumbers << phoneNumber;
}
if (!mMembers.contains(handle)) {
mMembers << handle;
}
}
mGroupIface->addMembers(handles, phoneNumbers);
}
Tp::UIntList oFonoTextChannel::members()
{
return mMembers;
}
oFonoTextChannel::~oFonoTextChannel()
{
}
Tp::BaseChannelPtr oFonoTextChannel::baseChannel()
{
return mBaseChannel;
}
void oFonoTextChannel::sendDeliveryReport(const QString &messageId, uint handle, Tp::DeliveryStatus status)
{
Tp::MessagePartList partList;
Tp::MessagePart header;
header["message-sender"] = QDBusVariant(handle);
header["message-sender-id"] = QDBusVariant(mPhoneNumbers[0]);
header["message-type"] = QDBusVariant(Tp::ChannelTextMessageTypeDeliveryReport);
header["delivery-status"] = QDBusVariant(status);
header["delivery-token"] = QDBusVariant(messageId);
partList << header;
mTextChannel->addReceivedMessage(partList);
}
void oFonoTextChannel::deliveryReportReceived(const QString &messageId, uint handle, bool success)
{
sendDeliveryReport(messageId, handle, success ? Tp::DeliveryStatusDelivered : Tp::DeliveryStatusPermanentlyFailed);
}
void oFonoTextChannel::messageAcknowledged(const QString &id)
{
Q_EMIT messageRead(id);
}
QString oFonoTextChannel::sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error)
{
bool success = true;
Tp::MessagePart header = message.at(0);
Tp::MessagePart body = message.at(1);
QString objpath;
if (mPhoneNumbers.size() == 1) {
QString phoneNumber = mPhoneNumbers[0];
uint handle = mConnection->ensureHandle(phoneNumber);
objpath = mConnection->messageManager()->sendMessage(phoneNumber, body["content"].variant().toString(), success).path();
if (objpath.isEmpty() || !success) {
if (!success) {
qWarning() << mConnection->messageManager()->errorName() << mConnection->messageManager()->errorMessage();
} else {
error->set(TP_QT_ERROR_INVALID_ARGUMENT, mConnection->messageManager()->errorMessage());
}
// create an unique id for this message that ofono failed to send
objpath = QDateTime::currentDateTimeUtc().toString(Qt::ISODate) + "-" + QString::number(mMessageCounter++);
mPendingDeliveryReportFailed[objpath] = handle;
QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport()));
return objpath;
}
OfonoMessage *msg = new OfonoMessage(objpath);
if (msg->state() == "") {
// message was already sent or failed too fast (this case is only reproducible with the emulator)
msg->deleteLater();
mPendingDeliveryReportDelivered[objpath] = handle;
QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport()));
return objpath;
}
// FIXME: track pending messages only if delivery reports are enabled. We need a system config option for it.
PendingMessagesManager::instance()->addPendingMessage(objpath, mPhoneNumbers[0]);
QObject::connect(msg, SIGNAL(stateChanged(QString)), SLOT(onOfonoMessageStateChanged(QString)));
return objpath;
} else {
bool someMessageSent = false;
QString lastPhoneNumber;
Q_FOREACH(const QString &phoneNumber, mPhoneNumbers) {
uint handle = mConnection->ensureHandle(mPhoneNumbers[0]);
objpath = mConnection->messageManager()->sendMessage(phoneNumber, body["content"].variant().toString(), success).path();
lastPhoneNumber = phoneNumber;
// dont fail if this is a group chat as we cannot track individual messages
if (objpath.isEmpty() || !success) {
if (!success) {
qWarning() << mConnection->messageManager()->errorName() << mConnection->messageManager()->errorMessage();
} else {
error->set(TP_QT_ERROR_INVALID_ARGUMENT, mConnection->messageManager()->errorMessage());
}
continue;
}
someMessageSent = true;
}
if (!someMessageSent) {
// for group chat we only fail if all the messages failed to send
objpath = QDateTime::currentDateTimeUtc().toString(Qt::ISODate) + "-" + QString::number(mMessageCounter++);
uint handle = mConnection->ensureHandle(lastPhoneNumber);
mPendingDeliveryReportFailed[objpath] = handle;
QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport()));
return objpath;
}
OfonoMessage *msg = new OfonoMessage(objpath);
if (msg->state() == "") {
// message was already sent or failed too fast (this case is only reproducible with the emulator)
msg->deleteLater();
uint handle = mConnection->ensureHandle(lastPhoneNumber);
mPendingDeliveryReportDelivered[objpath] = handle;
QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport()));
// return only the last one in case of group chat for history purposes
return objpath;
}
QObject::connect(msg, SIGNAL(stateChanged(QString)), SLOT(onOfonoMessageStateChanged(QString)));
return objpath;
}
}
void oFonoTextChannel::onProcessPendingDeliveryReport()
{
QMapIterator iterator(mPendingDeliveryReportFailed);
while(iterator.hasNext()) {
iterator.next();
sendDeliveryReport(iterator.key(), iterator.value(), Tp::DeliveryStatusPermanentlyFailed);
}
iterator = mPendingDeliveryReportDelivered;
while(iterator.hasNext()) {
iterator.next();
sendDeliveryReport(iterator.key(), iterator.value(), Tp::DeliveryStatusPermanentlyFailed);
}
mPendingDeliveryReportFailed.clear();
mPendingDeliveryReportDelivered.clear();
}
void oFonoTextChannel::onOfonoMessageStateChanged(QString status)
{
OfonoMessage *msg = static_cast(sender());
if(msg) {
Tp::DeliveryStatus delivery_status;
if (status == "sent") {
delivery_status = Tp::DeliveryStatusAccepted;
msg->deleteLater();
} else if(status == "failed") {
delivery_status = Tp::DeliveryStatusPermanentlyFailed;
PendingMessagesManager::instance()->removePendingMessage(msg->path());
msg->deleteLater();
} else if(status == "pending") {
delivery_status = Tp::DeliveryStatusTemporarilyFailed;
} else {
delivery_status = Tp::DeliveryStatusUnknown;
}
sendDeliveryReport(msg->path(), mConnection->ensureHandle(mPhoneNumbers[0]), delivery_status);
}
}
void oFonoTextChannel::messageReceived(const QString &message, uint handle, const QVariantMap &info)
{
Tp::MessagePartList partList;
Tp::MessagePart body;
body["content-type"] = QDBusVariant("text/plain");
body["content"] = QDBusVariant(message);
Tp::MessagePart header;
header["message-token"] = QDBusVariant(info["SentTime"].toString() +"-" + QString::number(mMessageCounter++));
header["message-received"] = QDBusVariant(QDateTime::fromString(info["SentTime"].toString(), Qt::ISODate).toTime_t());
header["message-sender"] = QDBusVariant(handle);
header["message-sender-id"] = QDBusVariant(mPhoneNumbers[0]);
header["message-type"] = QDBusVariant(Tp::ChannelTextMessageTypeNormal);
partList << header << body;
mTextChannel->addReceivedMessage(partList);
}
void oFonoTextChannel::mmsReceived(const QString &id, uint handle, const QVariantMap &properties)
{
Tp::MessagePartList message;
QString subject = properties["Subject"].toString();
QString smil = properties["Smil"].toString();
Tp::MessagePart header;
header["message-token"] = QDBusVariant(id);
header["message-sender"] = QDBusVariant(handle);
header["message-received"] = QDBusVariant(QDateTime::fromString(properties["Date"].toString(), Qt::ISODate).toTime_t());
header["message-type"] = QDBusVariant(Tp::DeliveryStatusDelivered);
if (!subject.isEmpty())
{
header["subject"] = QDBusVariant(subject);
}
message << header;
AttachmentList mmsdAttachments = qdbus_cast(properties["Attachments"]);
Q_FOREACH(const AttachmentStruct &attachment, mmsdAttachments) {
QFile attachmentFile(attachment.filePath);
if (!attachmentFile.open(QIODevice::ReadOnly)) {
qWarning() << "fail to load attachment" << attachmentFile.errorString() << attachment.filePath;
continue;
}
// FIXME check if we managed to read the total attachment file
attachmentFile.seek(attachment.offset);
QByteArray fileData = attachmentFile.read(attachment.length);
Tp::MessagePart part;
part["content-type"] = QDBusVariant(attachment.contentType);
part["identifier"] = QDBusVariant(attachment.id);
part["content"] = QDBusVariant(fileData);
part["size"] = QDBusVariant(attachment.length);
message << part;
}
if (!smil.isEmpty()) {
Tp::MessagePart part;
part["content-type"] = QDBusVariant(QString("application/smil"));
part["identifier"] = QDBusVariant(QString("smil"));
part["content"] = QDBusVariant(smil);
part["size"] = QDBusVariant(smil.size());
message << part;
}
mTextChannel->addReceivedMessage(message);
}
telepathy-ofono-0.2+14.04.20140407/qpulseaudioengine.cpp 0000644 0000153 0177776 00000027644 12320626651 023334 0 ustar pbuser nogroup 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file was taken from qt5 and modified by
** David Henningsson for usage in
** telepathy-ofono.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
****************************************************************************/
#include
#include "qpulseaudioengine.h"
#include
#include
QT_BEGIN_NAMESPACE
static void contextStateCallbackInit(pa_context *context, void *userdata)
{
Q_UNUSED(context);
#ifdef DEBUG_PULSE
qDebug() << QPulseAudioInternal::stateToQString(pa_context_get_state(context));
#endif
QPulseAudioEngine *pulseEngine = reinterpret_cast(userdata);
pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
}
static void contextStateCallback(pa_context *context, void *userdata)
{
Q_UNUSED(userdata);
Q_UNUSED(context);
#ifdef DEBUG_PULSE
pa_context_state_t state = pa_context_get_state(context);
qDebug() << QPulseAudioInternal::stateToQString(state);
#endif
}
static void success_cb(pa_context *context, int success, void *userdata)
{
QPulseAudioEngine *pulseEngine = reinterpret_cast(userdata);
pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
}
static void subscribeCallback(pa_context *context, pa_subscription_event_type_t t, uint32_t idx, void *userdata)
{
/* We're interested in plug/unplug stuff only, i e, card changes */
if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) != PA_SUBSCRIPTION_EVENT_CARD)
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) != PA_SUBSCRIPTION_EVENT_CHANGE)
return;
/* Handle it later, and in the right thread */
QMetaObject::invokeMethod((QPulseAudioEngine *) userdata, "plugUnplugSlot", Qt::QueuedConnection);
}
Q_GLOBAL_STATIC(QPulseAudioEngine, pulseEngine);
QPulseAudioEngine::QPulseAudioEngine(QObject *parent)
: QObject(parent)
, m_mainLoopApi(0)
, m_context(0)
, m_incall(false)
, m_speakermode(false)
, m_micmute(false)
{
bool keepGoing = true;
bool ok = true;
m_mainLoop = pa_threaded_mainloop_new();
if (m_mainLoop == 0) {
qWarning("Unable to create pulseaudio mainloop");
return;
}
if (pa_threaded_mainloop_start(m_mainLoop) != 0) {
qWarning("Unable to start pulseaudio mainloop");
pa_threaded_mainloop_free(m_mainLoop);
return;
}
m_mainLoopApi = pa_threaded_mainloop_get_api(m_mainLoop);
pa_threaded_mainloop_lock(m_mainLoop);
m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtmPulseContext:%1")).arg(::getpid()).toLatin1().constData());
pa_context_set_state_callback(m_context, contextStateCallbackInit, this);
if (!m_context) {
qWarning("Unable to create new pulseaudio context");
pa_threaded_mainloop_free(m_mainLoop);
return;
}
if (pa_context_connect(m_context, NULL, (pa_context_flags_t)0, NULL) < 0) {
qWarning("Unable to create a connection to the pulseaudio context");
pa_context_unref(m_context);
pa_threaded_mainloop_free(m_mainLoop);
return;
}
pa_threaded_mainloop_wait(m_mainLoop);
while (keepGoing) {
switch (pa_context_get_state(m_context)) {
case PA_CONTEXT_CONNECTING:
case PA_CONTEXT_AUTHORIZING:
case PA_CONTEXT_SETTING_NAME:
break;
case PA_CONTEXT_READY:
#ifdef DEBUG_PULSE
qDebug("Connection established.");
#endif
keepGoing = false;
break;
case PA_CONTEXT_TERMINATED:
qCritical("Context terminated.");
keepGoing = false;
ok = false;
break;
case PA_CONTEXT_FAILED:
default:
qCritical() << QString("Connection failure: %1").arg(pa_strerror(pa_context_errno(m_context)));
keepGoing = false;
ok = false;
}
if (keepGoing) {
pa_threaded_mainloop_wait(m_mainLoop);
}
}
if (ok) {
pa_context_set_state_callback(m_context, contextStateCallback, this);
pa_context_set_subscribe_callback(m_context, subscribeCallback, this);
pa_context_subscribe(m_context, PA_SUBSCRIPTION_MASK_CARD, NULL, this);
} else {
if (m_context) {
pa_context_unref(m_context);
m_context = 0;
}
}
pa_threaded_mainloop_unlock(m_mainLoop);
}
QPulseAudioEngine::~QPulseAudioEngine()
{
if (m_context) {
pa_threaded_mainloop_lock(m_mainLoop);
pa_context_disconnect(m_context);
pa_threaded_mainloop_unlock(m_mainLoop);
m_context = 0;
}
if (m_mainLoop) {
pa_threaded_mainloop_stop(m_mainLoop);
pa_threaded_mainloop_free(m_mainLoop);
m_mainLoop = 0;
}
}
QPulseAudioEngine *QPulseAudioEngine::instance()
{
return pulseEngine();
}
void QPulseAudioEngine::sinkInfoCallback(const pa_sink_info *info)
{
pa_sink_port_info *earpiece = NULL, *speaker = NULL, *headphones = NULL;
pa_sink_port_info *highest = NULL, *preferred = NULL;
for (int i = 0; i < info->n_ports; i++) {
if (!highest || info->ports[i]->priority > highest->priority) {
if (info->ports[i]->available != PA_PORT_AVAILABLE_NO)
highest = info->ports[i];
}
if (!strcmp(info->ports[i]->name, "[Out] Earpiece"))
earpiece = info->ports[i];
if (!strcmp(info->ports[i]->name, "[Out] Speaker"))
speaker = info->ports[i];
if (!strcmp(info->ports[i]->name, "[Out] Headphones") && info->ports[i]->available != PA_PORT_AVAILABLE_NO)
headphones = info->ports[i];
}
if (!earpiece)
return; /* Not the right sink */
/* TODO: When on ringtone and headphones are plugged in, people want output
through *both* headphones and speaker, but when on call with speaker mode,
people want *just* speaker, not including headphones. */
if (m_speakermode)
preferred = speaker;
else if (m_incall)
preferred = headphones ? headphones : earpiece;
if (!preferred)
preferred = highest;
if (preferred && preferred != info->active_port) {
m_nametoset = info->name;
m_valuetoset = preferred->name;
}
}
void QPulseAudioEngine::cardInfoCallback(const pa_card_info *info)
{
pa_card_profile_info *voice_call = NULL, *highest = NULL;
for (int i = 0; i < info->n_profiles; i++) {
if (!highest || info->profiles[i].priority > highest->priority)
highest = &info->profiles[i];
if (!strcmp(info->profiles[i].name, "Voice Call"))
voice_call = &info->profiles[i];
}
if (!voice_call)
return; /* Not the right card */
if (m_incall && (voice_call != info->active_profile)) {
m_nametoset = info->name;
m_valuetoset = voice_call->name;
}
else if (!m_incall && (voice_call == info->active_profile)) {
m_nametoset = info->name;
m_valuetoset = highest->name;
}
}
void QPulseAudioEngine::sourceInfoCallback(const pa_source_info *info)
{
pa_source_port_info *handset = NULL;
if (info->monitor_of_sink != PA_INVALID_INDEX)
return; /* Not the right source */
for (int i = 0; i < info->n_ports; i++) {
if (!strcmp(info->ports[i]->name, "[In] Handset"))
handset = info->ports[i];
}
if (!handset)
return; /* Not the right source */
if (!!info->mute != !!m_micmute) {
m_nametoset = info->name;
}
}
static void cardinfo_cb(pa_context *context, const pa_card_info *info, int isLast, void *userdata)
{
QPulseAudioEngine *pulseEngine = static_cast(userdata);
/* qDebug("cardinfo_cb: pulseengine = %p, info = %p, isLast = %d", pulseEngine, info, isLast); */
if (isLast != 0 || !pulseEngine || !info) {
pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
return;
}
pulseEngine->cardInfoCallback(info);
}
static void sinkinfo_cb(pa_context *context, const pa_sink_info *info, int isLast, void *userdata)
{
QPulseAudioEngine *pulseEngine = static_cast(userdata);
if (isLast != 0 || !pulseEngine || !info) {
pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
return;
}
pulseEngine->sinkInfoCallback(info);
}
static void sourceinfo_cb(pa_context *context, const pa_source_info *info, int isLast, void *userdata)
{
QPulseAudioEngine *pulseEngine = static_cast(userdata);
if (isLast != 0 || !pulseEngine || !info) {
pa_threaded_mainloop_signal(pulseEngine->mainloop(), 0);
return;
}
pulseEngine->sourceInfoCallback(info);
}
bool QPulseAudioEngine::handleOperation(pa_operation *operation, const char *func_name)
{
if (!operation) {
qDebug("'%s' failed (lost PulseAudio connection?)", func_name);
pa_threaded_mainloop_unlock(m_mainLoop);
return false;
}
while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
pa_threaded_mainloop_wait(m_mainLoop);
pa_operation_unref(operation);
return true;
}
void QPulseAudioEngine::setCallMode(bool inCall, bool speakerMode)
{
pa_operation *operation;
m_incall = inCall;
m_speakermode = speakerMode;
pa_threaded_mainloop_lock(m_mainLoop);
m_nametoset = "";
pa_operation *o = pa_context_get_card_info_list(m_context, cardinfo_cb, this);
if (!handleOperation(o, "pa_context_get_card_info_list"))
return;
if (m_nametoset != "") {
qDebug("Setting PulseAudio card '%s' profile '%s'", m_nametoset.c_str(), m_valuetoset.c_str());
o = pa_context_set_card_profile_by_name(m_context,
m_nametoset.c_str(), m_valuetoset.c_str(), success_cb, this);
if (!handleOperation(o, "pa_context_set_card_profile_by_name"))
return;
}
m_nametoset = "";
o = pa_context_get_sink_info_list(m_context, sinkinfo_cb, this);
if (!handleOperation(o, "pa_context_get_sink_info_list"))
return;
if (m_nametoset != "") {
qDebug("Setting PulseAudio sink '%s' port '%s'", m_nametoset.c_str(), m_valuetoset.c_str());
o = pa_context_set_sink_port_by_name(m_context,
m_nametoset.c_str(), m_valuetoset.c_str(), success_cb, this);
if (!handleOperation(o, "pa_context_set_sink_port_by_name"))
return;
}
pa_threaded_mainloop_unlock(m_mainLoop);
if (inCall)
setMicMute(m_micmute);
}
void QPulseAudioEngine::setMicMute(bool muted)
{
m_nametoset = "";
m_micmute = muted;
if (!m_incall)
return;
pa_threaded_mainloop_lock(m_mainLoop);
pa_operation *o = pa_context_get_source_info_list(m_context, sourceinfo_cb, this);
if (!handleOperation(o, "pa_context_get_source_info_list"))
return;
if (m_nametoset != "") {
int m = m_micmute ? 1 : 0;
qDebug("Setting PulseAudio source '%s' muted '%d'", m_nametoset.c_str(), m);
o = pa_context_set_source_mute_by_name(m_context,
m_nametoset.c_str(), m, success_cb, this);
if (!handleOperation(o, "pa_context_set_source_mute_by_name"))
return;
}
pa_threaded_mainloop_unlock(m_mainLoop);
}
void QPulseAudioEngine::plugUnplugSlot()
{
qDebug("Notified about card event from PulseAudio");
if (m_incall)
setCallMode(m_incall, m_speakermode);
}
QT_END_NAMESPACE
telepathy-ofono-0.2+14.04.20140407/speakeriface.h 0000644 0000153 0177776 00000007466 12320626651 021702 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 OFONOSPEAKERIFACE_H
#define OFONOSPEAKERIFACE_H
// telepathy-qt
#include
#include
#include
#include
#include
#define TP_QT_IFACE_CHANNEL_SPEAKER "com.canonical.Telephony.Speaker"
class BaseChannelSpeakerInterface;
typedef Tp::SharedPtr BaseChannelSpeakerInterfacePtr;
class TP_QT_EXPORT BaseChannelSpeakerInterface : public Tp::AbstractChannelInterface
{
Q_OBJECT
Q_DISABLE_COPY(BaseChannelSpeakerInterface)
public:
static BaseChannelSpeakerInterfacePtr create() {
return BaseChannelSpeakerInterfacePtr(new BaseChannelSpeakerInterface());
}
template
static Tp::SharedPtr create() {
return Tp::SharedPtr(
new BaseChannelSpeakerInterfaceSubclass());
}
QVariantMap immutableProperties() const;
virtual ~BaseChannelSpeakerInterface();
bool speakerMode() const;
typedef Tp::Callback2 turnOnSpeakerCallback;
void setTurnOnSpeakerCallback(const turnOnSpeakerCallback &cb);
public Q_SLOTS:
void setSpeakerMode(bool active);
protected:
BaseChannelSpeakerInterface();
private:
void createAdaptor();
class Adaptee;
friend class Adaptee;
struct Private;
friend struct Private;
Private *mPriv;
};
class TP_QT_EXPORT ChannelInterfaceSpeakerAdaptor : public Tp::AbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", TP_QT_IFACE_CHANNEL_SPEAKER)
Q_CLASSINFO("D-Bus Introspection", ""
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
"")
Q_PROPERTY(bool SpeakerMode READ SpeakerMode)
public:
ChannelInterfaceSpeakerAdaptor(const QDBusConnection& dbusConnection, QObject* adaptee, QObject* parent);
virtual ~ChannelInterfaceSpeakerAdaptor();
typedef Tp::MethodInvocationContextPtr< bool > turnOnSpeakerContextPtr;
public: // PROPERTIES
bool SpeakerMode() const;
public Q_SLOTS: // METHODS
void turnOnSpeaker(bool active, const QDBusMessage& dbusMessage);
Q_SIGNALS: // SIGNALS
void SpeakerChanged(bool active);
};
class TP_QT_NO_EXPORT BaseChannelSpeakerInterface::Adaptee : public QObject
{
Q_OBJECT
Q_PROPERTY(bool speakerMode READ speakerMode)
public:
Adaptee(BaseChannelSpeakerInterface *interface);
~Adaptee();
bool speakerMode() const
{
return mInterface->speakerMode();
}
private Q_SLOTS:
void turnOnSpeaker(bool active, const ChannelInterfaceSpeakerAdaptor::turnOnSpeakerContextPtr &context);
Q_SIGNALS:
void speakerChanged(bool active);
public:
BaseChannelSpeakerInterface *mInterface;
};
#endif
telepathy-ofono-0.2+14.04.20140407/voicemailiface.h 0000644 0000153 0177776 00000011642 12320626651 022207 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 OFONOVOICEMAILIFACE_H
#define OFONOVOICEMAILIFACE_H
// telepathy-qt
#include
#include
#include
#include
#include
class BaseConnectionVoicemailInterface;
typedef Tp::SharedPtr BaseConnectionVoicemailInterfacePtr;
#define TP_QT_IFACE_CONNECTION_VOICEMAIL "com.canonical.Telephony.Voicemail"
class TP_QT_EXPORT BaseConnectionVoicemailInterface : public Tp::AbstractConnectionInterface
{
Q_OBJECT
Q_DISABLE_COPY(BaseConnectionVoicemailInterface)
public:
static BaseConnectionVoicemailInterfacePtr create() {
return BaseConnectionVoicemailInterfacePtr(new BaseConnectionVoicemailInterface());
}
template
static Tp::SharedPtr create() {
return Tp::SharedPtr(
new BaseConnectionVoicemailInterfaceSubclass());
}
QVariantMap immutableProperties() const;
virtual ~BaseConnectionVoicemailInterface();
typedef Tp::Callback1 VoicemailCountCallback;
void setVoicemailCountCallback(const VoicemailCountCallback &cb);
typedef Tp::Callback1 VoicemailIndicatorCallback;
void setVoicemailIndicatorCallback(const VoicemailIndicatorCallback &cb);
typedef Tp::Callback1 VoicemailNumberCallback;
void setVoicemailNumberCallback(const VoicemailNumberCallback &cb);
public Q_SLOTS:
void setVoicemailCount(int count);
void setVoicemailIndicator(bool active);
protected:
BaseConnectionVoicemailInterface();
private:
void createAdaptor();
class Adaptee;
friend class Adaptee;
struct Private;
friend struct Private;
Private *mPriv;
};
class TP_QT_EXPORT ConnectionInterfaceVoicemailAdaptor : public Tp::AbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", TP_QT_IFACE_CONNECTION_VOICEMAIL)
Q_CLASSINFO("D-Bus Introspection", ""
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
" \n"
"")
public:
ConnectionInterfaceVoicemailAdaptor(const QDBusConnection& dbusConnection, QObject* adaptee, QObject* parent);
virtual ~ConnectionInterfaceVoicemailAdaptor();
typedef Tp::MethodInvocationContextPtr< bool > VoicemailIndicatorContextPtr;
typedef Tp::MethodInvocationContextPtr< QString > VoicemailNumberContextPtr;
typedef Tp::MethodInvocationContextPtr< uint > VoicemailCountContextPtr;
public Q_SLOTS: // METHODS
bool VoicemailIndicator(const QDBusMessage& dbusMessage);
QString VoicemailNumber(const QDBusMessage& dbusMessage);
uint VoicemailCount(const QDBusMessage& dbusMessage);
Q_SIGNALS: // SIGNALS
void VoicemailCountChanged(uint count);
void VoicemailIndicatorChanged(bool active);
};
class TP_QT_NO_EXPORT BaseConnectionVoicemailInterface::Adaptee : public QObject
{
Q_OBJECT
public:
Adaptee(BaseConnectionVoicemailInterface *interface);
~Adaptee();
private Q_SLOTS:
void voicemailIndicator(const ConnectionInterfaceVoicemailAdaptor::VoicemailIndicatorContextPtr &context);
void voicemailNumber(const ConnectionInterfaceVoicemailAdaptor::VoicemailNumberContextPtr &context);
void voicemailCount(const ConnectionInterfaceVoicemailAdaptor::VoicemailCountContextPtr &context);
Q_SIGNALS:
void voicemailCountChanged(uint count);
void voicemailIndicatorChanged(bool active);
public:
BaseConnectionVoicemailInterface *mInterface;
};
#endif
telepathy-ofono-0.2+14.04.20140407/tests/ 0000755 0000153 0177776 00000000000 12320627204 020227 5 ustar pbuser nogroup 0000000 0000000 telepathy-ofono-0.2+14.04.20140407/tests/MessagesTest.cpp 0000644 0000153 0177776 00000015522 12320626651 023354 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "telepathyhelper.h"
#include "ofonomockcontroller.h"
#include "handler.h"
#include "approvertext.h"
Q_DECLARE_METATYPE(Tp::TextChannelPtr);
Q_DECLARE_METATYPE(QList);
class MessagesTest : public QObject
{
Q_OBJECT
Q_SIGNALS:
void contactsReceived(QList contacts);
private Q_SLOTS:
void initTestCase();
void testMessageReceived();
void testMessageSend();
void testMessageSendGroupChat();
// helper slots
void onPendingContactsFinished(Tp::PendingOperation*);
private:
Approver *mApprover;
Handler *mHandler;
};
void MessagesTest::initTestCase()
{
qRegisterMetaType();
qRegisterMetaType();
qRegisterMetaType();
qRegisterMetaType >();
TelepathyHelper::instance();
QSignalSpy spy(TelepathyHelper::instance(), SIGNAL(accountReady()));
QTRY_COMPARE(spy.count(), 1);
OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
// the account should be connected
QTRY_VERIFY(TelepathyHelper::instance()->connected());
mHandler = new Handler(this);
TelepathyHelper::instance()->registerClient(mHandler, "TpOfonoTestHandler");
QTRY_VERIFY(mHandler->isRegistered());
// register the approver
mApprover = new Approver(this);
TelepathyHelper::instance()->registerClient(mApprover, "TpOfonoTestApprover");
// Tp-qt does not set registered status to approvers
QTRY_VERIFY(QDBusConnection::sessionBus().interface()->isServiceRegistered(TELEPHONY_SERVICE_APPROVER));
// we need to wait in order to give telepathy time to notify about the approver and handler
QTest::qWait(10000);
}
void MessagesTest::testMessageReceived()
{
QSignalSpy spy(mHandler, SIGNAL(textChannelAvailable(Tp::TextChannelPtr)));
OfonoMockController::instance()->MessageManagerSendMessage("123", "text");
QTRY_COMPARE(spy.count(), 1);
Tp::TextChannelPtr channel = spy.first().first().value();
QVERIFY(channel);
QCOMPARE(channel->messageQueue().count(), 1);
Tp::ReceivedMessage message = channel->messageQueue().first();
QCOMPARE(message.sender()->id(), QString("123"));
QCOMPARE(message.text(), QString("text"));
}
void MessagesTest::testMessageSend()
{
// Request the contact to start chatting to
Tp::AccountPtr account = TelepathyHelper::instance()->account();
QSignalSpy spy(this, SIGNAL(contactsReceived(QList)));
connect(account->connection()->contactManager()->contactsForIdentifiers(QStringList() << "321"),
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onPendingContactsFinished(Tp::PendingOperation*)));
QTRY_COMPARE(spy.count(), 1);
QList contacts = spy.first().first().value >();
QCOMPARE(contacts.count(), 1);
QCOMPARE(contacts.first()->id(), QString("321"));
QSignalSpy spyTextChannel(mHandler, SIGNAL(textChannelAvailable(Tp::TextChannelPtr)));
Q_FOREACH(Tp::ContactPtr contact, contacts) {
account->ensureTextChat(contact, QDateTime::currentDateTime(), TP_QT_IFACE_CLIENT + ".TpOfonoTestHandler");
}
QTRY_COMPARE(spyTextChannel.count(), 1);
Tp::TextChannelPtr channel = spyTextChannel.first().first().value();
QVERIFY(channel);
QSignalSpy spyOfonoMessageAdded(OfonoMockController::instance(), SIGNAL(MessageAdded(QDBusObjectPath, QVariantMap)));
Tp::PendingSendMessage *message = channel->send("text");
QTRY_COMPARE(spyOfonoMessageAdded.count(), 1);
QDBusObjectPath path = spyOfonoMessageAdded.first().first().value();
OfonoMockController::instance()->MessageMarkSent(path.path());
QTRY_COMPARE(channel->messageQueue().count(), 1);
QVERIFY(channel->messageQueue()[0].isDeliveryReport());
QCOMPARE(channel->messageQueue()[0].deliveryDetails().status(), Tp::DeliveryStatusAccepted);
OfonoMockController::instance()->MessageManagerStatusReport(path.path(), true);
QTRY_COMPARE(channel->messageQueue().count(), 2);
QVERIFY(channel->messageQueue()[1].isDeliveryReport());
QCOMPARE(channel->messageQueue()[1].deliveryDetails().status(), Tp::DeliveryStatusDelivered);
}
void MessagesTest::testMessageSendGroupChat()
{
// Request the contact to start chatting to
Tp::AccountPtr account = TelepathyHelper::instance()->account();
QSignalSpy spy(this, SIGNAL(contactsReceived(QList)));
connect(account->connection()->contactManager()->contactsForIdentifiers(QStringList() << "321" << "123"),
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onPendingContactsFinished(Tp::PendingOperation*)));
QTRY_COMPARE(spy.count(), 1);
QList contacts = spy.first().first().value >();
QCOMPARE(contacts.count(), 2);
QCOMPARE(contacts[0]->id(), QString("321"));
QCOMPARE(contacts[1]->id(), QString("123"));
QSignalSpy spyTextChannel(mHandler, SIGNAL(textChannelAvailable(Tp::TextChannelPtr)));
account->createConferenceTextChat(QList(), contacts, QDateTime::currentDateTime(), TP_QT_IFACE_CLIENT + ".TpOfonoTestHandler");
QTRY_COMPARE(spyTextChannel.count(), 1);
Tp::TextChannelPtr channel = spyTextChannel.first().first().value();
QVERIFY(channel);
QSignalSpy spyOfonoMessageAdded(OfonoMockController::instance(), SIGNAL(MessageAdded(QDBusObjectPath, QVariantMap)));
Tp::PendingSendMessage *message = channel->send("text");
QTRY_COMPARE(spyOfonoMessageAdded.count(), 2);
}
void MessagesTest::onPendingContactsFinished(Tp::PendingOperation *op)
{
Tp::PendingContacts *pc = qobject_cast(op);
if (!pc) {
return;
}
Q_EMIT contactsReceived(pc->contacts());
}
QTEST_MAIN(MessagesTest)
#include "MessagesTest.moc"
telepathy-ofono-0.2+14.04.20140407/tests/approvertext.h 0000644 0000153 0177776 00000003070 12320626651 023150 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 APPROVER_H
#define APPROVER_H
#include
#include
#include
#include
#define TELEPHONY_SERVICE_HANDLER TP_QT_IFACE_CLIENT + ".TpOfonoTestHandler"
#define TELEPHONY_SERVICE_APPROVER TP_QT_IFACE_CLIENT + ".TpOfonoTestApprover"
class Approver : public QObject, public Tp::AbstractClientApprover
{
Q_OBJECT
public:
Approver(QObject *parent = 0);
~Approver();
Tp::ChannelClassSpecList channelFilters() const;
void addDispatchOperation(const Tp::MethodInvocationContextPtr<> &context,
const Tp::ChannelDispatchOperationPtr &dispatchOperation);
private Q_SLOTS:
void processChannels();
private:
QList mDispatchOps;
};
#endif // APPROVER_H
telepathy-ofono-0.2+14.04.20140407/tests/ConnectionTest.cpp 0000644 0000153 0177776 00000010136 12320626651 023700 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include
#include
#include
#include "telepathyhelper.h"
#include "ofonomockcontroller.h"
class ConnectionTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void testConnected();
void testModemStatus();
};
void ConnectionTest::initTestCase()
{
TelepathyHelper::instance();
QSignalSpy spy(TelepathyHelper::instance(),
SIGNAL(accountReady()));
QTRY_COMPARE(spy.count(), 1);
OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
qRegisterMetaType();
QTest::qWait(3000);
}
void ConnectionTest::testConnected()
{
// the account should be connected automatically
QTRY_VERIFY(TelepathyHelper::instance()->connected());
}
void ConnectionTest::testModemStatus()
{
Tp::ContactPtr selfContact = TelepathyHelper::instance()->account()->connection()->selfContact();
QSignalSpy signalSpy(selfContact.data(), SIGNAL(presenceChanged(Tp::Presence)));
// set the status as unregistered
OfonoMockController::instance()->NetworkRegistrationSetStatus("unregistered");
QTRY_COMPARE(signalSpy.count(), 1);
Tp::Presence presence = signalSpy.first().first().value();
QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
signalSpy.clear();
// now set the modem as registered to the network again to see if it works
OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
QTRY_COMPARE(signalSpy.count(), 1);
presence = signalSpy.first().first().value();
QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAvailable);
signalSpy.clear();
// searching should be reported as offline
OfonoMockController::instance()->NetworkRegistrationSetStatus("searching");
QTRY_COMPARE(signalSpy.count(), 1);
presence = signalSpy.first().first().value();
QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
signalSpy.clear();
// denied should be reported as offline (set registered first to force the signal to be emitted)
OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
QTRY_COMPARE(signalSpy.count(), 1);
signalSpy.clear();
OfonoMockController::instance()->NetworkRegistrationSetStatus("denied");
QTRY_COMPARE(signalSpy.count(), 1);
presence = signalSpy.first().first().value();
QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
signalSpy.clear();
// unknown should be reported as offline (set registered first to force the signal to be emitted)
OfonoMockController::instance()->NetworkRegistrationSetStatus("registered");
QTRY_COMPARE(signalSpy.count(), 1);
signalSpy.clear();
OfonoMockController::instance()->NetworkRegistrationSetStatus("unknown");
QTRY_COMPARE(signalSpy.count(), 1);
presence = signalSpy.first().first().value();
QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeOffline);
signalSpy.clear();
// roaming should be reported as available
OfonoMockController::instance()->NetworkRegistrationSetStatus("roaming");
QTRY_COMPARE(signalSpy.count(), 1);
presence = signalSpy.first().first().value();
QCOMPARE(presence.type(), Tp::ConnectionPresenceTypeAvailable);
}
QTEST_MAIN(ConnectionTest)
#include "ConnectionTest.moc"
telepathy-ofono-0.2+14.04.20140407/tests/mock/ 0000755 0000153 0177776 00000000000 12320627204 021160 5 ustar pbuser nogroup 0000000 0000000 telepathy-ofono-0.2+14.04.20140407/tests/mock/callvolumeprivate.cpp 0000644 0000153 0177776 00000003023 12320626651 025425 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include "callvolumeprivateadaptor.h"
QMap callVolumeData;
CallVolumePrivate::CallVolumePrivate(QObject *parent) :
QObject(parent)
{
QDBusConnection::sessionBus().registerObject(OFONO_MOCK_CALL_VOLUME_OBJECT, this);
QDBusConnection::sessionBus().registerService("org.ofono");
SetProperty("Muted", QDBusVariant(QVariant(false)));
new CallVolumeAdaptor(this);
}
CallVolumePrivate::~CallVolumePrivate()
{
}
QVariantMap CallVolumePrivate::GetProperties()
{
return mProperties;
}
void CallVolumePrivate::SetProperty(const QString &name, const QDBusVariant& value)
{
qDebug() << "CallVolumePrivate::SetProperty" << name << value.variant();
mProperties[name] = value.variant();
Q_EMIT PropertyChanged(name, value);
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/CallVolumePrivate.xml 0000644 0000153 0177776 00000001255 12320626651 025310 0 ustar pbuser nogroup 0000000 0000000
telepathy-ofono-0.2+14.04.20140407/tests/mock/MessagePrivate.xml 0000644 0000153 0177776 00000001463 12320626651 024632 0 ustar pbuser nogroup 0000000 0000000
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonovoicecall.cpp 0000644 0000153 0177776 00000016517 12320626651 024705 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include
#include
#include "ofonointerface.h"
#include "ofonovoicecall.h"
#include "voicecallprivate.h"
#define VOICECALL_TIMEOUT 30000
OfonoVoiceCall::OfonoVoiceCall(const QString& callId, QObject *parent)
: QObject(parent)
{
m_if = new OfonoInterface(callId, "org.ofono.VoiceCall", OfonoGetAllOnStartup, this);
if (!voiceCallData.keys().contains(callId)) {
m_if->setPath(callId);
voiceCallData[callId] = new VoiceCallPrivate(callId);
}
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
QDBusConnection::sessionBus().connect("org.ofono",path(),m_if->ifname(),
"DisconnectReason", this,
SIGNAL(disconnectReason(const QString&)));
}
OfonoVoiceCall::OfonoVoiceCall(const OfonoVoiceCall& call)
: QObject(call.parent())
{
m_if = new OfonoInterface(call.path(), "org.ofono.VoiceCall", OfonoGetAllOnStartup, this);
if (!voiceCallData.keys().contains(call.path())) {
m_if->setPath(call.path());
voiceCallData[call.path()] = new VoiceCallPrivate(call.path());
}
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
QDBusConnection::sessionBus().connect("org.ofono",path(),m_if->ifname(),
"DisconnectReason", this,
SIGNAL(disconnectReason(const QString&)));
}
bool OfonoVoiceCall::operator==(const OfonoVoiceCall &call)
{
return path() == call.path();
}
OfonoVoiceCall::~OfonoVoiceCall()
{
}
void OfonoVoiceCall::answer()
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"Answer");
QDBusConnection::sessionBus().callWithCallback(request, this,
SLOT(answerResp()),
SLOT(answerErr(const QDBusError&)),
VOICECALL_TIMEOUT);
}
void OfonoVoiceCall::hangup()
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"Hangup");
QDBusConnection::sessionBus().callWithCallback(request, this,
SLOT(hangupResp()),
SLOT(hangupErr(const QDBusError&)),
VOICECALL_TIMEOUT);
}
void OfonoVoiceCall::deflect(const QString &number)
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"Deflect");
QListarg;
arg.append(QVariant(number));
request.setArguments(arg);
QDBusConnection::sessionBus().callWithCallback(request, this,
SLOT(deflectResp()),
SLOT(deflectErr(const QDBusError&)),
VOICECALL_TIMEOUT);
}
void OfonoVoiceCall::answerResp()
{
Q_EMIT answerComplete(true);
}
void OfonoVoiceCall::answerErr(const QDBusError &error)
{
m_if->setError(error.name(), error.message());
Q_EMIT answerComplete(false);
}
void OfonoVoiceCall::hangupResp()
{
Q_EMIT hangupComplete(true);
}
void OfonoVoiceCall::hangupErr(const QDBusError &error)
{
m_if->setError(error.name(), error.message());
Q_EMIT hangupComplete(false);
}
void OfonoVoiceCall::deflectResp()
{
Q_EMIT deflectComplete(true);
}
void OfonoVoiceCall::deflectErr(const QDBusError &error)
{
m_if->setError(error.name(), error.message());
Q_EMIT deflectComplete(false);
}
QString OfonoVoiceCall::incomingLine() const
{
return m_if->properties()["IncomingLine"].value();
}
QString OfonoVoiceCall::lineIdentification() const
{
return m_if->properties()["LineIdentification"].value();
}
QString OfonoVoiceCall::name() const
{
return m_if->properties()["Name"].value();
}
QString OfonoVoiceCall::state() const
{
return m_if->properties()["State"].value();
}
QString OfonoVoiceCall::startTime() const
{
return m_if->properties()["StartTime"].value();
}
QString OfonoVoiceCall::information() const
{
return m_if->properties()["Information"].value();
}
bool OfonoVoiceCall::multiparty() const
{
return m_if->properties()["Multiparty"].value();
}
bool OfonoVoiceCall::emergency() const
{
return m_if->properties()["Emergency"].value();
}
quint8 OfonoVoiceCall::icon() const
{
return m_if->properties()["Icon"].value();
}
bool OfonoVoiceCall::remoteHeld() const
{
return m_if->properties()["RemoteHeld"].value();
}
bool OfonoVoiceCall::remoteMultiparty() const
{
return m_if->properties()["RemoteMultiparty"].value();
}
void OfonoVoiceCall::propertyChanged(const QString &property, const QVariant &value)
{
if (property == "LineIdentification") {
Q_EMIT lineIdentificationChanged(value.value());
} else if (property == "Name") {
Q_EMIT nameChanged(value.value());
} else if (property == "State") {
Q_EMIT stateChanged(value.value());
} else if (property == "Information") {
Q_EMIT informationChanged(value.value());
} else if (property == "IncomingLine") {
Q_EMIT incomingLineChanged(value.value());
} else if (property == "Multiparty") {
Q_EMIT multipartyChanged(value.value());
} else if (property == "Emergency") {
Q_EMIT emergencyChanged(value.value());
} else if (property == "StartTime") {
Q_EMIT startTimeChanged(value.value());
} else if (property == "Icon") {
Q_EMIT iconChanged(value.value());
} else if (property == "RemoteHeld") {
Q_EMIT remoteHeldChanged(value.value());
} else if (property == "RemoteMultiparty") {
Q_EMIT remoteMultipartyChanged(value.value());
}
}
QString OfonoVoiceCall::path() const
{
return m_if->path();
}
QString OfonoVoiceCall::errorName() const
{
return m_if->errorName();
}
QString OfonoVoiceCall::errorMessage() const
{
return m_if->errorMessage();
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/messagemanagerprivate.h 0000644 0000153 0177776 00000004006 12320626651 025710 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 MESSAGEMANAGERPRIVATE_H
#define MESSAGEMANAGERPRIVATE_H
#include
#include
#include "mock_common.h"
class OfonoMessage;
class MessageManagerPrivate : public QObject, protected QDBusContext {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ofono.MessageManager")
public:
MessageManagerPrivate(QObject *parent = 0);
~MessageManagerPrivate();
Q_SIGNALS:
void MessageRemoved(const QDBusObjectPath &obj);
void PropertyChanged(const QString &name, const QDBusVariant &value);
void MessageAdded(const QDBusObjectPath &obj, const QVariantMap &value);
void IncomingMessage(const QString &text, const QVariantMap &info);
void StatusReport(const QString &message, const QVariantMap &info);
private Q_SLOTS:
void onMessageDestroyed();
public Q_SLOTS:
QVariantMap GetProperties();
void SetProperty(const QString &name, const QDBusVariant &value);
void MockSendMessage(const QString &from, const QString &text);
QDBusObjectPath SendMessage(const QString &to, const QString &text);
void MockStatusReport(const QString &message, bool success);
private:
QVariantMap mProperties;
QMap mMessages;
int messageCount;
};
extern QMap messageManagerData;
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/voicecallmanagerprivate.cpp 0000644 0000153 0177776 00000015352 12320626651 026566 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include "voicecallmanagerprivateadaptor.h"
#include "ofonovoicecall.h"
#include "voicecallprivate.h"
QMap voiceCallManagerData;
VoiceCallManagerPrivate::VoiceCallManagerPrivate(QObject *parent) :
voiceCallCount(0),
failNextDtmf(false),
QObject(parent)
{
qDBusRegisterMetaType >();
QDBusConnection::sessionBus().registerObject(OFONO_MOCK_VOICECALL_MANAGER_OBJECT, this);
QDBusConnection::sessionBus().registerService("org.ofono");
SetProperty("EmergencyNumbers", QDBusVariant(QVariant(QStringList())));
new VoiceCallManagerAdaptor(this);
}
VoiceCallManagerPrivate::~VoiceCallManagerPrivate()
{
}
QMap VoiceCallManagerPrivate::GetCalls()
{
QMap props;
Q_FOREACH(const QString &key, mVoiceCalls.keys()) {
VoiceCallPrivate *callPrivate = voiceCallData[key];
if (callPrivate) {
props[QDBusObjectPath(key)] = callPrivate->GetProperties();
}
}
return props;
}
QVariantMap VoiceCallManagerPrivate::GetProperties()
{
return mProperties;
}
void VoiceCallManagerPrivate::SetProperty(const QString &name, const QDBusVariant& value)
{
qDebug() << "VoiceCallManagerPrivate::SetProperty" << name << value.variant();
if (mProperties[name] != value.variant()) {
mProperties[name] = value.variant();
Q_EMIT PropertyChanged(name, value);
}
}
void VoiceCallManagerPrivate::MockFailNextDtmf()
{
failNextDtmf = true;
}
QDBusObjectPath VoiceCallManagerPrivate::MockIncomingCall(const QString &from)
{
qDebug() << "VoiceCallManagerPrivate::MockIncomingCall" << from;
QString newPath("/OfonoVoiceCall/OfonoVoiceCall"+QString::number(++voiceCallCount));
QDBusObjectPath newPathObj(newPath);
QVariantMap callProperties;
callProperties["State"] = "incoming";
callProperties["LineIdentification"] = from;
callProperties["Name"] = "";
callProperties["Multiparty"] = false;
callProperties["RemoteHeld"] = false;
callProperties["RemoteMultiparty"] = false;
callProperties["Emergency"] = false;
initialCallProperties[newPath] = callProperties;
mVoiceCalls[newPath] = new OfonoVoiceCall(newPath);
connect(voiceCallData[newPath], SIGNAL(destroyed()), this, SLOT(onVoiceCallDestroyed()));
Q_EMIT CallAdded(newPathObj, callProperties);
return newPathObj;
}
void VoiceCallManagerPrivate::SwapCalls()
{
Q_FOREACH(const QString &objPath, mVoiceCalls.keys()) {
QDBusInterface iface("org.ofono", objPath, "org.ofono.VoiceCall");
if (mVoiceCalls[objPath]->state() == "active") {
iface.call("SetProperty", "State", QVariant::fromValue(QDBusVariant("held")));;
} else if (mVoiceCalls[objPath]->state() == "held") {
iface.call("SetProperty", "State", QVariant::fromValue(QDBusVariant("active")));;
}
}
}
QList VoiceCallManagerPrivate::CreateMultiparty()
{
QList calls;
if (mVoiceCalls.size() < 2) {
return QList();
}
// set everything as active
Q_FOREACH(const QString &objPath, mVoiceCalls.keys()) {
QDBusInterface iface("org.ofono", objPath, "org.ofono.VoiceCall");
iface.call("SetProperty", "State", QVariant::fromValue(QDBusVariant("active")));;
iface.call("SetProperty", "Multiparty", QVariant::fromValue(QDBusVariant(true)));;
calls << QDBusObjectPath(objPath);
}
return calls;
}
QList VoiceCallManagerPrivate::PrivateChat(const QDBusObjectPath &objPath)
{
QList remainingCalls;
Q_FOREACH(const QString &path, mVoiceCalls.keys()) {
QDBusInterface iface("org.ofono", objPath.path(), "org.ofono.VoiceCall");
if (objPath.path() == path) {
iface.call("SetProperty", "State", QVariant::fromValue(QDBusVariant("active")));
} else {
iface.call("SetProperty", "State", QVariant::fromValue(QDBusVariant("held")));
remainingCalls << objPath;
}
}
// remove the multiparty call if there are only 2 calls
if (mVoiceCalls.size() == 2) {
Q_FOREACH(const QString &objPath, mVoiceCalls.keys()) {
QDBusInterface iface("org.ofono", objPath, "org.ofono.VoiceCall");
iface.call("SetProperty", "Multiparty", QVariant::fromValue(QDBusVariant(false)));;
}
}
if (remainingCalls.size() < 2) {
return QList();
}
return remainingCalls;
}
void VoiceCallManagerPrivate::SendTones(const QString &tones)
{
if (failNextDtmf) {
failNextDtmf = false;
sendErrorReply("org.ofono.Error.InProgress", "Operation already in progress");
return;
}
Q_EMIT TonesReceived(tones);
}
QDBusObjectPath VoiceCallManagerPrivate::Dial(const QString &to, const QString &hideCallerId)
{
qDebug() << "DIAL" << to;
QString newPath("/OfonoVoiceCall/OfonoVoiceCall"+QString::number(++voiceCallCount));
QDBusObjectPath newPathObj(newPath);
QVariantMap callProperties;
callProperties["State"] = "dialing";
callProperties["LineIdentification"] = to;
callProperties["Name"] = "";
callProperties["Multiparty"] = false;
callProperties["RemoteHeld"] = false;
callProperties["RemoteMultiparty"] = false;
callProperties["Emergency"] = false;
initialCallProperties[newPath] = callProperties;
mVoiceCalls[newPath] = new OfonoVoiceCall(newPath);
connect(voiceCallData[newPath], SIGNAL(destroyed()), this, SLOT(onVoiceCallDestroyed()));
Q_EMIT CallAdded(newPathObj, callProperties);
return newPathObj;
}
void VoiceCallManagerPrivate::onVoiceCallDestroyed()
{
VoiceCallPrivate *voiceCall = static_cast(sender());
if (voiceCall) {
voiceCallData.remove(voiceCall->objectPath());
mVoiceCalls[voiceCall->objectPath()]->deleteLater();
mVoiceCalls.remove(voiceCall->objectPath());
Q_EMIT CallRemoved(QDBusObjectPath(voiceCall->objectPath()));
}
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/networkregistrationprivate.h 0000644 0000153 0177776 00000002643 12320626651 027062 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 NETWORKREGISTRATIONPRIVATE_H
#define NETWORKREGISTRATIONPRIVATE_H
#include
#include "mock_common.h"
class NetworkRegistrationPrivate : public QObject, protected QDBusContext {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ofono.NetworkRegistration")
public:
NetworkRegistrationPrivate(QObject *parent = 0);
~NetworkRegistrationPrivate();
Q_SIGNALS:
void PropertyChanged(const QString &, const QDBusVariant &);
public Q_SLOTS:
QVariantMap GetProperties();
void SetProperty(const QString &name, const QDBusVariant &value);
private:
QVariantMap mProperties;
};
extern QMap networkRegistrationData;
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofononetworkregistration.cpp 0000644 0000153 0177776 00000015137 12320626651 027065 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include
#include
#include "ofononetworkregistration.h"
#include "ofonointerface.h"
#include "modemprivate.h"
#include "networkregistrationprivate.h"
#define REGISTER_TIMEOUT 300000
#define SCAN_TIMEOUT 300000
QDBusArgument &operator<<(QDBusArgument &argument, const OfonoOperatorStruct &op)
{
argument.beginStructure();
argument << op.path << op.properties;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoOperatorStruct &op)
{
argument.beginStructure();
argument >> op.path >> op.properties;
argument.endStructure();
return argument;
}
OfonoNetworkRegistration::OfonoNetworkRegistration(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
: OfonoModemInterface(modemSetting, modemPath, "org.ofono.NetworkRegistration", OfonoGetAllOnStartup, parent)
{
qDBusRegisterMetaType();
qDBusRegisterMetaType();
m_if->setPath(OFONO_MOCK_NETWORK_REGISTRATION_OBJECT);
if (!networkRegistrationData.keys().contains(modem()->path())) {
networkRegistrationData[modem()->path()] = new NetworkRegistrationPrivate();
}
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
}
OfonoNetworkRegistration::~OfonoNetworkRegistration()
{
}
void OfonoNetworkRegistration::registerOp()
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
OFONO_MOCK_NETWORK_REGISTRATION_OBJECT, m_if->ifname(),
"Register");
QDBusConnection::sessionBus().callWithCallback(request, this,
SLOT(registerResp()),
SLOT(registerErr(const QDBusError&)),
REGISTER_TIMEOUT);
}
void OfonoNetworkRegistration::scan()
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
OFONO_MOCK_NETWORK_REGISTRATION_OBJECT, m_if->ifname(),
"Scan");
QDBusConnection::sessionBus().callWithCallback(request, this,
SLOT(scanResp(OfonoOperatorList)),
SLOT(scanErr(const QDBusError&)),
REGISTER_TIMEOUT);
}
void OfonoNetworkRegistration::getOperators()
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
OFONO_MOCK_NETWORK_REGISTRATION_OBJECT, m_if->ifname(),
"GetOperators");
QDBusConnection::sessionBus().callWithCallback(request, this,
SLOT(getOperatorsResp(OfonoOperatorList)),
SLOT(getOperatorsErr(const QDBusError&)),
SCAN_TIMEOUT);
}
QString OfonoNetworkRegistration::mode() const
{
return m_if->properties()["Mode"].value();
}
QString OfonoNetworkRegistration::status() const
{
return m_if->properties()["Status"].value();
}
uint OfonoNetworkRegistration::locationAreaCode() const
{
return m_if->properties()["LocationAreaCode"].value();
}
uint OfonoNetworkRegistration::cellId() const
{
return m_if->properties()["CellId"].value();
}
QString OfonoNetworkRegistration::mcc() const
{
return m_if->properties()["MobileCountryCode"].value();
}
QString OfonoNetworkRegistration::mnc() const
{
return m_if->properties()["MobileNetworkCode"].value();
}
QString OfonoNetworkRegistration::technology() const
{
return m_if->properties()["Technology"].value();
}
QString OfonoNetworkRegistration::name() const
{
return m_if->properties()["Name"].value();
}
uint OfonoNetworkRegistration::strength() const
{
return m_if->properties()["Strength"].value();
}
QString OfonoNetworkRegistration::baseStation() const
{
return m_if->properties()["BaseStation"].value();
}
void OfonoNetworkRegistration::propertyChanged(const QString& property, const QVariant& value)
{
if (property == "Mode") {
Q_EMIT modeChanged(value.value());
} else if (property == "Status") {
Q_EMIT statusChanged(value.value());
} else if (property == "LocationAreaCode") {
Q_EMIT locationAreaCodeChanged(value.value());
} else if (property == "CellId") {
Q_EMIT cellIdChanged(value.value());
} else if (property == "MobileCountryCode") {
Q_EMIT mccChanged(value.value());
} else if (property == "MobileNetworkCode") {
Q_EMIT mncChanged(value.value());
} else if (property == "Technology") {
Q_EMIT technologyChanged(value.value());
} else if (property == "Name") {
Q_EMIT nameChanged(value.value());
} else if (property == "Strength") {
Q_EMIT strengthChanged(value.value());
} else if (property == "BaseStation") {
Q_EMIT baseStationChanged(value.value());
}
}
void OfonoNetworkRegistration::registerResp()
{
Q_EMIT registerComplete(true);
}
void OfonoNetworkRegistration::registerErr(QDBusError error)
{
m_if->setError(error.name(), error.message());
Q_EMIT registerComplete(false);
}
void OfonoNetworkRegistration::getOperatorsResp(OfonoOperatorList list)
{
QStringList oplist;
Q_FOREACH(OfonoOperatorStruct op, list) {
oplist << op.path.path();
}
Q_EMIT getOperatorsComplete(true, oplist);
}
void OfonoNetworkRegistration::getOperatorsErr(QDBusError error)
{
m_if->setError(error.name(), error.message());
Q_EMIT getOperatorsComplete(false, QStringList());
}
void OfonoNetworkRegistration::scanResp(OfonoOperatorList list)
{
QStringList oplist;
Q_FOREACH(OfonoOperatorStruct op, list) {
oplist << op.path.path();
}
Q_EMIT scanComplete(true, oplist);
}
void OfonoNetworkRegistration::scanErr(QDBusError error)
{
m_if->setError(error.name(), error.message());
Q_EMIT scanComplete(false, QStringList());
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/VoiceCallPrivate.xml 0000644 0000153 0177776 00000001535 12320626651 025107 0 ustar pbuser nogroup 0000000 0000000
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofononetworkregistration.h 0000644 0000153 0177776 00000007427 12320626651 026535 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef OFONONETWORKREGISTRATION_H
#define OFONONETWORKREGISTRATION_H
#include
#include
#include
#include
#include "ofonomodeminterface.h"
#include "libofono-qt_global.h"
struct OfonoOperatorStruct {
QDBusObjectPath path;
QVariantMap properties;
};
typedef QList OfonoOperatorList;
Q_DECLARE_METATYPE(OfonoOperatorStruct)
Q_DECLARE_METATYPE(OfonoOperatorList)
//! This class is used to access oFono network registration API
/*!
* The API is documented in
* http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/network-api.txt
*/
class OFONO_QT_EXPORT OfonoNetworkRegistration : public OfonoModemInterface
{
Q_OBJECT
Q_PROPERTY(QString mode READ mode NOTIFY modeChanged)
Q_PROPERTY(QString status READ status NOTIFY statusChanged)
Q_PROPERTY(uint locationAreaCode READ locationAreaCode NOTIFY locationAreaCodeChanged)
Q_PROPERTY(uint cellId READ cellId NOTIFY cellIdChanged)
Q_PROPERTY(QString mcc READ mcc NOTIFY mccChanged)
Q_PROPERTY(QString mnc READ mnc NOTIFY mncChanged)
Q_PROPERTY(QString technology READ technology NOTIFY technologyChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(uint strength READ strength NOTIFY strengthChanged)
Q_PROPERTY(QString baseStation READ baseStation NOTIFY baseStationChanged)
public:
OfonoNetworkRegistration(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent=0);
~OfonoNetworkRegistration();
/* Properties */
QString mode() const;
QString status() const;
uint locationAreaCode() const;
uint cellId() const;
QString mcc() const;
QString mnc() const;
QString technology() const;
QString name() const;
uint strength() const;
QString baseStation() const;
public Q_SLOTS:
void registerOp();
void getOperators();
void scan();
Q_SIGNALS:
void modeChanged(const QString &mode);
void statusChanged(const QString &status);
void locationAreaCodeChanged(uint locationAreaCode);
void cellIdChanged(uint cellId);
void mccChanged(const QString &mcc);
void mncChanged(const QString &mnc);
void technologyChanged(const QString &technology);
void nameChanged(const QString &name);
void strengthChanged(uint strength);
void baseStationChanged(const QString &baseStation);
void registerComplete(bool success);
void getOperatorsComplete(bool success, const QStringList &operatorIds);
void scanComplete(bool success, const QStringList &operatorIds);
private Q_SLOTS:
void propertyChanged(const QString& property, const QVariant& value);
void registerResp();
void registerErr(QDBusError error);
void getOperatorsResp(OfonoOperatorList list);
void getOperatorsErr(QDBusError error);
void scanResp(OfonoOperatorList list);
void scanErr(QDBusError error);
private:
};
#endif /* !OFONONETWORKREGISTRATION_H */
telepathy-ofono-0.2+14.04.20140407/tests/mock/voicecallprivate.h 0000644 0000153 0177776 00000003043 12320626651 024672 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 VOICECALLPRIVATE_H
#define VOICECALLPRIVATE_H
#include
class VoiceCallPrivate : public QObject, protected QDBusContext {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ofono.VoiceCall")
public:
VoiceCallPrivate(const QString &path, QObject *parent = 0);
~VoiceCallPrivate();
QString objectPath() const;
Q_SIGNALS:
void PropertyChanged(const QString &name, const QDBusVariant &value);
public Q_SLOTS:
QVariantMap GetProperties();
void SetProperty(const QString &name, const QDBusVariant &value);
void Hangup();
void Answer();
void MockSetAlerting();
void MockAnswer();
private:
QVariantMap mProperties;
QString mObjectPath;
};
extern QMap voiceCallData;
extern QMap initialCallProperties;
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/ModemPrivate.xml 0000644 0000153 0177776 00000001413 12320626651 024302 0 ustar pbuser nogroup 0000000 0000000
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonomodem.h 0000644 0000153 0177776 00000012736 12320626651 023511 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef OFONOMODEM_H
#define OFONOMODEM_H
#include
#include
#include
#include "libofono-qt_global.h"
class OfonoModemManager;
class OfonoInterface;
//! This class is used to access an oFono modem object and its properties
/*!
* oFono modem properties are documented in
* http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/modem-api.txt
*/
class OFONO_QT_EXPORT OfonoModem : public QObject
{
Q_OBJECT
Q_PROPERTY(bool isValid READ isValid NOTIFY validityChanged)
Q_PROPERTY(QString path READ path NOTIFY pathChanged)
Q_PROPERTY(QString errorName READ errorName)
Q_PROPERTY(QString errorMessage READ errorMessage)
Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged)
Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged)
Q_PROPERTY(bool lockdown READ lockdown WRITE setLockdown NOTIFY lockdownChanged)
Q_PROPERTY(bool emergency READ emergency NOTIFY emergencyChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged)
Q_PROPERTY(QString model READ model NOTIFY modelChanged)
Q_PROPERTY(QString revision READ revision NOTIFY revisionChanged)
Q_PROPERTY(QString serial READ serial NOTIFY serialChanged)
Q_PROPERTY(QString type READ type NOTIFY typeChanged)
Q_PROPERTY(QStringList features READ features NOTIFY featuresChanged)
Q_PROPERTY(QStringList interfaces READ interfaces NOTIFY interfacesChanged)
public:
//! How the modem object should select a modem
enum SelectionSetting {
AutomaticSelect, /*!< Select the first available modem automatically;
* if that modem becomes unavailable, select the first available
* modem again. */
ManualSelect /*!< Do not select a modem automatically,
* use the modem path provided in the constructor, and do not
* attempt to select another modem if the first one becomes
* unavailable. */
};
/*!
* \param setting sets the modem selection policy for the object
* \param modemPath if modem selection policy is ManualSelect, then this contains
* the D-Bus path to the modem object. Otherwise, it is ignored.
*/
OfonoModem(SelectionSetting setting, const QString& modemPath, QObject *parent=0);
~OfonoModem();
//! Returns true if D-Bus modem object exists.
bool isValid() const;
//! Returns the D-Bus object path of the modem
QString path() const;
//! Get the D-Bus error name of the last operation.
/*!
* Returns the D-Bus error name of the last operation (setting a property
* or calling a method) if it has failed
*/
QString errorName() const;
//! Get the D-Bus error message of the last operation.
/*!
* Returns the D-Bus error message of the last operation (setting a property
* or calling a method) if it has failed
*/
QString errorMessage() const;
bool powered() const;
bool online() const;
bool lockdown() const;
bool emergency() const;
QString name() const;
QString manufacturer() const;
QString model() const;
QString revision() const;
QString serial() const;
QString type() const;
QStringList features() const;
QStringList interfaces() const;
public Q_SLOTS:
void setPowered(bool powered);
void setOnline(bool online);
void setLockdown(bool lockdown);
Q_SIGNALS:
//! Issued when a modem becomes unavailable or available again
void validityChanged(bool validity);
//! Issued when the object has switched to another modem
void pathChanged(QString modemPath);
void poweredChanged(bool powered);
void setPoweredFailed();
void onlineChanged(bool online);
void setOnlineFailed();
void lockdownChanged(bool lockdown);
void setLockdownFailed();
void emergencyChanged(bool emergency);
void nameChanged(const QString &name);
void manufacturerChanged(const QString &manufacturer);
void modelChanged(const QString &model);
void revisionChanged(const QString &revision);
void serialChanged(const QString &serial);
void typeChanged(const QString &type);
void featuresChanged(const QStringList &features);
void interfacesChanged(const QStringList &interfaces);
private Q_SLOTS:
void propertyChanged(const QString &property, const QVariant &value);
void setPropertyFailed(const QString& property);
void modemAdded(const QString &modem);
void modemRemoved(const QString &modem);
private:
void modemsChanged();
private:
OfonoModemManager *m_mm;
OfonoInterface *m_if;
SelectionSetting m_selectionSetting;
bool m_isValid;
};
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonointerface.h 0000644 0000153 0177776 00000011527 12320626651 024345 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef OFONOINTERFACE_H
#define OFONOINTERFACE_H
#include
#include
#include
#include
#include "ofonopropertysetting.h"
#include "libofono-qt_global.h"
//! Basic oFono interface class
/*!
* This class implements basic access to properties of oFono interfaces.
* It should not be instantiated directly; instead you should instantiate
* interface-specific classes.
*/
class OFONO_QT_EXPORT OfonoInterface : public QObject
{
Q_OBJECT
public:
/*!
* \param path D-Bus path to the interface
* \param ifname D-Bus name of the interface
* \param setting specifies how the object should handle oFono properties of the interface
*/
OfonoInterface(const QString &path, const QString &ifname, OfonoGetPropertySetting setting, QObject *parent=0);
~OfonoInterface();
//! Get all properties
/*!
* Returns the full set of current properties. If the object was constructed with
* OfonoInterface::GetAllOnFirstRequest, and no properties have been explicitly queried yet
* via requestProperty(), then returns nothing.
*/
QVariantMap properties() const;
//! Request a property asynchronously.
/*!
* Result is returned via requestPropertyComplete() signal.
*/
void requestProperty(const QString &name);
//! Set a property asynchronously.
/*!
* Result is returned via propertyChanged() signal
* if setting is successful or via setPropertyFailed() signal if setting has failed.
*/
void setProperty(const QString &name, const QVariant &property, const QString& password=0);
//! Resets the property cache.
void resetProperties();
//! Get the interface D-Bus path
QString path() const {return m_path;}
//! Get the interface D-Bus name
QString ifname() const {return m_ifname;}
//! Get the D-Bus error name of the last operation.
/*!
* Returns the D-Bus error name of the last operation (setting a property
* or calling a method) if it has failed
*/
QString errorName() const {return m_errorName;}
//! Get the D-Bus error message of the last operation.
/*!
* Returns the D-Bus error message of the last operation (setting a property
* or calling a method) if it has failed
*/
QString errorMessage() const {return m_errorMessage;}
public Q_SLOTS:
//! Changes the interface path
/*!
* This method changes the D-Bus path to the interface.
* Properties are updated immediately if property setting is set to
* GetAllOnStartup or reset otherwise.
*/
void setPath(const QString &path);
//! Sets the last error explicitly
void setError(const QString &errorName, const QString &errorMessage);
Q_SIGNALS:
//! Issued when a property has changed
/*!
* \param name name of the property
* \param property value of the property
*/
void propertyChanged(const QString &name, const QVariant &property);
//! Issued when requesting a property has completed
/*!
* \param success true if requesting a property was successful, false if there was an error
* \param name name of the property
* \param property value of the property
*/
void requestPropertyComplete(bool success, const QString &name, const QVariant &property);
//! Issued when setting a property has failed
/*!
* \param name name of the property
*/
void setPropertyFailed(const QString &name);
private Q_SLOTS:
void onPropertyChanged(QString property, QDBusVariant value);
void getPropertiesAsyncResp(QVariantMap properties);
void getPropertiesAsyncErr(const QDBusError&);
void setPropertyResp();
void setPropertyErr(const QDBusError& error);
protected Q_SLOTS:
private:
QVariantMap getAllPropertiesSync();
protected:
QString m_errorName;
QString m_errorMessage;
private:
QString m_path;
QString m_ifname;
QVariantMap m_properties;
QString m_pendingProperty;
OfonoGetPropertySetting m_getpropsetting;
};
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/callvolumeprivate.h 0000644 0000153 0177776 00000002574 12320626651 025104 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 CALLVOLUMEPRIVATE_H
#define CALLVOLUMEPRIVATE_H
#include
#include
#include "mock_common.h"
class CallVolumePrivate : public QObject, protected QDBusContext {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ofono.CallVolume")
public:
CallVolumePrivate(QObject *parent = 0);
~CallVolumePrivate();
Q_SIGNALS:
void PropertyChanged(const QString &name, const QDBusVariant &value);
public Q_SLOTS:
QVariantMap GetProperties();
void SetProperty(const QString &name, const QDBusVariant &value);
private:
QVariantMap mProperties;
};
extern QMap callVolumeData;
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/modemprivate.h 0000644 0000153 0177776 00000002631 12320626651 024034 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 MODEMPRIVATE_H
#define MODEMPRIVATE_H
#include
#include
#include
#include "mock_common.h"
class ModemPrivate : public QObject, protected QDBusContext {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ofono.Modem")
public:
ModemPrivate(QObject *parent = 0);
~ModemPrivate();
Q_SIGNALS:
void PropertyChanged(const QString &name, const QDBusVariant& value);
public Q_SLOTS:
void MockSetOnline(bool online);
QVariantMap GetProperties();
void SetProperty(const QString &name, const QDBusVariant& value);
private:
QVariantMap mProperties;
};
extern QMap modemData;
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonomessagemanager.cpp 0000644 0000153 0177776 00000023331 12320626651 025713 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include
#include
#include "ofonomessagemanager.h"
#include "ofonointerface.h"
#include "messagemanagerprivate.h"
QDBusArgument &operator<<(QDBusArgument &argument, const OfonoMessageManagerStruct &message)
{
argument.beginStructure();
argument << message.path << message.properties;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoMessageManagerStruct &message)
{
argument.beginStructure();
argument >> message.path >> message.properties;
argument.endStructure();
return argument;
}
OfonoMessageManager::OfonoMessageManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
: OfonoModemInterface(modemSetting, modemPath, "org.ofono.MessageManager", OfonoGetAllOnFirstRequest, parent)
{
qDBusRegisterMetaType();
qDBusRegisterMetaType();
if (!messageManagerData.keys().contains(modem()->path())) {
m_if->setPath(OFONO_MOCK_MESSAGE_MANAGER_OBJECT);
messageManagerData[modem()->path()] = new MessageManagerPrivate();
}
m_messagelist = getMessageList();
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
connect(this, SIGNAL(validityChanged(bool)),
this, SLOT(validityChanged(bool)));
connect(modem(), SIGNAL(pathChanged(QString)), this, SLOT(pathChanged(const QString&)));
connectDbusSignals(path());
}
OfonoMessageManager::~OfonoMessageManager()
{
}
void OfonoMessageManager::validityChanged(bool /*validity*/)
{
m_messagelist = getMessageList();
}
void OfonoMessageManager::pathChanged(const QString& path)
{
connectDbusSignals(path);
}
QStringList OfonoMessageManager::getMessageList()
{
QDBusReply reply;
OfonoMessageManagerList messages;
QDBusMessage request;
QStringList messageList;
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"GetMessages");
reply = QDBusConnection::sessionBus().call(request);
messages = reply;
Q_FOREACH(OfonoMessageManagerStruct message, messages) {
messageList << message.path.path();
}
return messageList;
}
void OfonoMessageManager::connectDbusSignals(const QString& path)
{
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"MessageAdded",
this,
SLOT(onMessageAdded(const QDBusObjectPath&, const QVariantMap&)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"MessageRemoved",
this,
SLOT(onMessageRemoved(const QDBusObjectPath&)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"IncomingMessage",
this,
SIGNAL(incomingMessage(QString, QVariantMap)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"ImmediateMessage",
this,
SIGNAL(immediateMessage(QString, QVariantMap)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"StatusReport",
this,
SIGNAL(statusReport(QString, QVariantMap)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"MessageAdded",
this,
SLOT(onMessageAdded(const QDBusObjectPath&, const QVariantMap&)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"MessageRemoved",
this,
SLOT(onMessageRemoved(const QDBusObjectPath&)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"IncomingMessage",
this,
SIGNAL(incomingMessage(QString, QVariantMap)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"ImmediateMessage",
this,
SIGNAL(immediateMessage(QString, QVariantMap)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"StatusReport",
this,
SIGNAL(statusReport(QString, QVariantMap)));
}
void OfonoMessageManager::requestServiceCenterAddress()
{
m_if->requestProperty("ServiceCenterAddress");
}
void OfonoMessageManager::setServiceCenterAddress(QString address)
{
m_if->setProperty("ServiceCenterAddress", qVariantFromValue(address));
}
void OfonoMessageManager::requestUseDeliveryReports()
{
m_if->requestProperty("UseDeliveryReports");
}
void OfonoMessageManager::setUseDeliveryReports(bool useDeliveryReports)
{
m_if->setProperty("UseDeliveryReports", qVariantFromValue(useDeliveryReports));
}
void OfonoMessageManager::requestBearer()
{
m_if->requestProperty("Bearer");
}
void OfonoMessageManager::setBearer(QString bearer)
{
m_if->setProperty("Bearer", qVariantFromValue(bearer));
}
void OfonoMessageManager::requestAlphabet()
{
m_if->requestProperty("Alphabet");
}
void OfonoMessageManager::setAlphabet(QString alphabet)
{
m_if->setProperty("Alphabet", qVariantFromValue(alphabet));
}
QDBusObjectPath OfonoMessageManager::sendMessage(const QString &to, const QString &message, bool &success)
{
QDBusMessage request;
QDBusReply reply;
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"SendMessage");
request << to << message;
reply = QDBusConnection::sessionBus().call(request);
success = reply.isValid();
if (!success) {
m_if->setError(reply.error().name(), reply.error().message());
}
return reply;
}
void OfonoMessageManager::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
{
if (property == "ServiceCenterAddress") {
Q_EMIT serviceCenterAddressComplete(success, value.value());
} else if (property == "UseDeliveryReports") {
Q_EMIT useDeliveryReportsComplete(success, value.value());
} else if (property == "Bearer") {
Q_EMIT bearerComplete(success, value.value());
} else if (property == "Alphabet") {
Q_EMIT alphabetComplete(success, value.value());
}
}
void OfonoMessageManager::propertyChanged(const QString& property, const QVariant& value)
{
if (property == "ServiceCenterAddress") {
Q_EMIT serviceCenterAddressChanged(value.value());
} else if (property == "UseDeliveryReports") {
Q_EMIT useDeliveryReportsChanged(value.value());
} else if (property == "Bearer") {
Q_EMIT bearerChanged(value.value());
} else if (property == "Alphabet") {
Q_EMIT alphabetChanged(value.value());
}
}
void OfonoMessageManager::setPropertyFailed(const QString& property)
{
if (property == "ServiceCenterAddress") {
Q_EMIT setServiceCenterAddressFailed();
} else if (property == "UseDeliveryReports") {
Q_EMIT setUseDeliveryReportsFailed();
} else if (property == "Bearer") {
Q_EMIT setBearerFailed();
} else if (property == "Alphabet") {
Q_EMIT setAlphabetFailed();
}
}
QStringList OfonoMessageManager::getMessages() const
{
return m_messagelist;
}
void OfonoMessageManager::onMessageAdded(const QDBusObjectPath &path, const QVariantMap& /*properties*/)
{
m_messagelist << path.path();
Q_EMIT messageAdded(path.path());
}
void OfonoMessageManager::onMessageRemoved(const QDBusObjectPath &path)
{
m_messagelist.removeAll(path.path());
Q_EMIT messageRemoved(path.path());
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/voicecallprivate.cpp 0000644 0000153 0177776 00000006070 12320626651 025230 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include "voicecallprivateadaptor.h"
QMap voiceCallData;
QMap initialCallProperties;
VoiceCallPrivate::VoiceCallPrivate(const QString &path, QObject *parent) :
QObject(parent), mObjectPath(path)
{
QDBusConnection::sessionBus().registerObject(path, this);
QDBusConnection::sessionBus().registerService("org.ofono");
SetProperty("LineIdentification", QDBusVariant(QVariant("")));
SetProperty("IncomingLine", QDBusVariant(QVariant("")));
SetProperty("Name", QDBusVariant(QVariant("")));
SetProperty("Multiparty", QDBusVariant(QVariant(false)));
SetProperty("State", QDBusVariant(QVariant("")));
SetProperty("StartTime", QDBusVariant(QVariant("")));
SetProperty("Information", QDBusVariant(QVariant("")));
SetProperty("Icon", QDBusVariant(QVariant("")));
SetProperty("Emergency", QDBusVariant(QVariant(false)));
SetProperty("RemoteHeld", QDBusVariant(QVariant(false)));
SetProperty("RemoteMultiparty", QDBusVariant(QVariant(false)));
QMapIterator i(initialCallProperties[path]);
while (i.hasNext()) {
i.next();
SetProperty(i.key(), QDBusVariant(i.value()));
}
new VoiceCallAdaptor(this);
}
VoiceCallPrivate::~VoiceCallPrivate()
{
}
QString VoiceCallPrivate::objectPath() const
{
return mObjectPath;
}
QVariantMap VoiceCallPrivate::GetProperties()
{
return mProperties;
}
void VoiceCallPrivate::SetProperty(const QString &name, const QDBusVariant& value)
{
qDebug() << "VoiceCallPrivate::SetProperty" << name << value.variant();
mProperties[name] = value.variant();
Q_EMIT PropertyChanged(name, value);
}
void VoiceCallPrivate::Hangup()
{
SetProperty("State", QDBusVariant(QVariant("disconnected")));
deleteLater();
}
void VoiceCallPrivate::Answer()
{
if (mProperties["State"] == QString("incoming")) {
SetProperty("State", QDBusVariant(QVariant("active")));
}
}
void VoiceCallPrivate::MockSetAlerting()
{
if (mProperties["State"] == QString("dialing")) {
SetProperty("State", QDBusVariant(QVariant("alerting")));
}
}
void VoiceCallPrivate::MockAnswer()
{
if (mProperties["State"] == QString("dialing") || mProperties["State"] == QString("alerting")) {
SetProperty("State", QDBusVariant(QVariant("active")));
}
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/messagemanagerprivate.cpp 0000644 0000153 0177776 00000006000 12320626651 026237 0 ustar pbuser nogroup 0000000 0000000 /**
* 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
*/
#include
#include "messagemanagerprivateadaptor.h"
#include "ofonomessage.h"
QMap messageManagerData;
MessageManagerPrivate::MessageManagerPrivate(QObject *parent) :
messageCount(0),
QObject(parent)
{
QDBusConnection::sessionBus().registerObject(OFONO_MOCK_MESSAGE_MANAGER_OBJECT, this);
QDBusConnection::sessionBus().registerService("org.ofono");
SetProperty("ServiceCenterAddress", QDBusVariant(QVariant("")));
SetProperty("UseDeliveryReports", QDBusVariant(QVariant(false)));
SetProperty("Bearer", QDBusVariant(QVariant("")));
SetProperty("Alphabet", QDBusVariant(QVariant("")));
new MessageManagerAdaptor(this);
}
MessageManagerPrivate::~MessageManagerPrivate()
{
}
QVariantMap MessageManagerPrivate::GetProperties()
{
return mProperties;
}
void MessageManagerPrivate::SetProperty(const QString &name, const QDBusVariant& value)
{
qDebug() << "MessageManagerPrivate::SetProperty" << name << value.variant();
mProperties[name] = value.variant();
Q_EMIT PropertyChanged(name, value);
}
void MessageManagerPrivate::MockSendMessage(const QString &from, const QString &text)
{
QVariantMap properties;
properties["Sender"] = from;
properties["SentTime"] = QDateTime::currentDateTime().toString(Qt::ISODate);
properties["LocalSentTime"] = QDateTime::currentDateTime().toString(Qt::ISODate);
Q_EMIT IncomingMessage(text, properties);
}
QDBusObjectPath MessageManagerPrivate::SendMessage(const QString &to, const QString &text)
{
QString newPath("/OfonoMessage"+QString::number(++messageCount));
QDBusObjectPath newPathObj(newPath);
mMessages[newPath] = new OfonoMessage(newPath);
connect(mMessages[newPath], SIGNAL(destroyed()), this, SLOT(onMessageDestroyed()));
Q_EMIT MessageAdded(newPathObj, QVariantMap());
return newPathObj;
}
void MessageManagerPrivate::MockStatusReport(const QString &message, bool success)
{
QVariantMap info;
info["Delivered"] = success;
Q_EMIT StatusReport(message, info);
}
void MessageManagerPrivate::onMessageDestroyed()
{
OfonoMessage *message = static_cast(sender());
if (message) {
mMessages.remove(message->path());
Q_EMIT MessageRemoved(QDBusObjectPath(message->path()));
}
}
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonopropertysetting.h 0000644 0000153 0177776 00000002432 12320626651 025662 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef OFONOPROPERTYSETTING_H
#define OFONOPROPERTYSETTING_H
//! How to handle getting the properties
enum OfonoGetPropertySetting {
OfonoGetAllOnStartup, /*!< Get all properties synchronously on startup;
* they would be immediately available. */
OfonoGetAllOnFirstRequest /*!< Do not get properties on startup;
* get them in an asynhronous way when the first
* property is requested. */
};
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonovoicecall.h 0000644 0000153 0177776 00000010502 12320626651 024336 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef OFONOVOICECALL_H
#define OFONOVOICECALL_H
#include
#include
#include
#include
#include "libofono-qt_global.h"
class OfonoInterface;
//! This class is used to access oFono voice call API
/*!
* The API is documented in
* http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=doc/voicecall-api.txt
*/
class OFONO_QT_EXPORT OfonoVoiceCall : public QObject
{
Q_OBJECT
Q_PROPERTY(QString path READ path)
Q_PROPERTY(QString errorName READ errorName)
Q_PROPERTY(QString errorMessage READ errorMessage)
Q_PROPERTY(QString lineIdentification READ lineIdentification NOTIFY lineIdentificationChanged)
Q_PROPERTY(QString incomingLine READ incomingLine NOTIFY incomingLineChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString state READ state NOTIFY stateChanged)
Q_PROPERTY(QString startTime READ startTime NOTIFY startTimeChanged)
Q_PROPERTY(QString information READ information NOTIFY informationChanged)
Q_PROPERTY(bool multiparty READ multiparty NOTIFY multipartyChanged)
Q_PROPERTY(bool emergency READ emergency NOTIFY emergencyChanged)
Q_PROPERTY(quint8 icon READ icon NOTIFY iconChanged)
public:
OfonoVoiceCall(const QString &callId, QObject *parent=0);
OfonoVoiceCall(const OfonoVoiceCall &op);
~OfonoVoiceCall();
OfonoVoiceCall operator=(const OfonoVoiceCall &op);
bool operator==(const OfonoVoiceCall &op);
//! Returns the D-Bus object path of the voice call object
QString path() const;
//! Get the D-Bus error name of the last operation.
/*!
* Returns the D-Bus error name of the last operation (setting a property
* or calling a method) if it has failed
*/
QString errorName() const;
//! Get the D-Bus error message of the last operation.
/*!
* Returns the D-Bus error message of the last operation (setting a property
* or calling a method) if it has failed
*/
QString errorMessage() const;
QString lineIdentification() const;
QString incomingLine() const;
QString name() const;
QString state() const;
QString startTime() const;
QString information() const;
bool multiparty() const;
bool emergency() const;
quint8 icon() const;
bool remoteHeld() const;
bool remoteMultiparty() const;
public Q_SLOTS:
void answer();
void hangup();
void deflect(const QString &number);
Q_SIGNALS:
void answerComplete(bool status);
void hangupComplete(bool status);
void deflectComplete(bool status);
void lineIdentificationChanged(const QString &name);
void nameChanged(const QString &name);
void stateChanged(const QString &state);
void startTimeChanged(const QString &time);
void informationChanged(const QString &mcc);
void incomingLineChanged(const QString &line);
void disconnectReason(const QString &reason);
void multipartyChanged(const bool multiparty);
void iconChanged(const quint8 &icon);
void emergencyChanged(const bool emergency);
void remoteHeldChanged(const bool remoteHeld);
void remoteMultipartyChanged(const bool remoteMultiparty);
private Q_SLOTS:
void propertyChanged(const QString &property, const QVariant &value);
void answerResp();
void answerErr(const QDBusError &error);
void hangupResp();
void hangupErr(const QDBusError &error);
void deflectResp();
void deflectErr(const QDBusError &error);
private:
OfonoInterface *m_if;
};
#endif // OFONOVOICECALL_H
telepathy-ofono-0.2+14.04.20140407/tests/mock/messageprivate.h 0000644 0000153 0177776 00000002617 12320626651 024363 0 ustar pbuser nogroup 0000000 0000000 /**
* 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 MESSAGEPRIVATE_H
#define MESSAGEPRIVATE_H
#include
class MessagePrivate : public QObject, protected QDBusContext {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.ofono.Message")
public:
MessagePrivate(const QString &path, QObject *parent = 0);
~MessagePrivate();
Q_SIGNALS:
void PropertyChanged(const QString &name, const QDBusVariant &value);
public Q_SLOTS:
QVariantMap GetProperties();
void SetProperty(const QString &name, const QDBusVariant &value);
void Cancel();
void MockMarkFailed();
void MockMarkSent();
private:
QVariantMap mProperties;
};
extern QMap messageData;
#endif
telepathy-ofono-0.2+14.04.20140407/tests/mock/MessageManagerPrivate.xml 0000644 0000153 0177776 00000004266 12320626651 026131 0 ustar pbuser nogroup 0000000 0000000
telepathy-ofono-0.2+14.04.20140407/tests/mock/ofonovoicecallmanager.cpp 0000644 0000153 0177776 00000035006 12320626651 026232 0 ustar pbuser nogroup 0000000 0000000 /*
* This file is part of ofono-qt
*
* Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Alexander Kanavin
*
* Portions of this file are Copyright (C) 2011 Intel Corporation
* Contact: Shane Bryan
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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 St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include
#include
#include "ofonovoicecallmanager.h"
#include "ofonointerface.h"
#include "voicecallmanagerprivate.h"
#define DIAL_TIMEOUT 30000
#define TONE_TIMEOUT 10000
#define TRANSFER_TIMEOUT 20000
#define SWAP_TIMEOUT 20000
#define HANGUP_TIMEOUT 30000
#define HOLD_TIMEOUT 30000
#define PRIVATE_CHAT_TIMEOUT 30000
#define CREATE_MULTIPARTY_TIMEOUT 30000
QDBusArgument &operator<<(QDBusArgument &argument, const OfonoVoiceCallManagerStruct &call)
{
argument.beginStructure();
argument << call.path << call.properties;
argument.endStructure();
return argument;
}
const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoVoiceCallManagerStruct &call)
{
argument.beginStructure();
argument >> call.path >> call.properties;
argument.endStructure();
return argument;
}
OfonoVoiceCallManager::OfonoVoiceCallManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
: OfonoModemInterface(modemSetting, modemPath, "org.ofono.VoiceCallManager", OfonoGetAllOnStartup, parent)
{
qDBusRegisterMetaType();
qDBusRegisterMetaType();
if (!voiceCallManagerData.keys().contains(modem()->path())) {
m_if->setPath(OFONO_MOCK_VOICECALL_MANAGER_OBJECT);
voiceCallManagerData[modem()->path()] = new VoiceCallManagerPrivate();
}
m_calllist = getCallList();
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
connect(this, SIGNAL(validityChanged(bool)),
this, SLOT(validityChanged(bool)));
connect(modem(), SIGNAL(pathChanged(QString)), this, SLOT(pathChanged(const QString&)));
connectDbusSignals(path());
}
OfonoVoiceCallManager::~OfonoVoiceCallManager()
{
}
void OfonoVoiceCallManager::validityChanged(bool /*validity*/)
{
m_calllist = getCallList();
}
void OfonoVoiceCallManager::pathChanged(const QString& path)
{
connectDbusSignals(path);
}
QStringList OfonoVoiceCallManager::getCallList()
{
QDBusReply reply;
OfonoVoiceCallManagerList calls;
QDBusMessage request;
QStringList messageList;
qDBusRegisterMetaType();
qDBusRegisterMetaType();
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"GetCalls");
reply = QDBusConnection::sessionBus().call(request);
calls = reply;
Q_FOREACH(OfonoVoiceCallManagerStruct call, calls) {
messageList<< call.path.path();
}
return messageList;
}
void OfonoVoiceCallManager::connectDbusSignals(const QString& path)
{
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"CallAdded", this,
SLOT(callAddedChanged(const QDBusObjectPath&, const QVariantMap&)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"CallRemoved", this,
SLOT(callRemovedChanged(const QDBusObjectPath&)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"BarringActive", this,
SIGNAL(barringActive(const QString&)));
QDBusConnection::sessionBus().disconnect("org.ofono", QString(), m_if->ifname(),
"Forwarded", this,
SIGNAL(forwarded(const QString&)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"CallAdded", this,
SLOT(callAddedChanged(const QDBusObjectPath&, const QVariantMap&)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"CallRemoved", this,
SLOT(callRemovedChanged(const QDBusObjectPath&)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"BarringActive", this,
SIGNAL(barringActive(const QString&)));
QDBusConnection::sessionBus().connect("org.ofono", path, m_if->ifname(),
"Forwarded", this,
SIGNAL(forwarded(const QString&)));
}
QDBusObjectPath OfonoVoiceCallManager::dial(const QString &number, const QString &callerid_hide, bool &success)
{
QDBusMessage request;
QDBusReply reply;
request = QDBusMessage::createMethodCall("org.ofono",
path(), m_if->ifname(),
"Dial");
QList