Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
Merge pull request #25 from smurfy/fix_update9
Browse files Browse the repository at this point in the history
Fix for Sailfish update9 and QT5.2

Fixes #23
Closes #24
  • Loading branch information
smokku committed Oct 29, 2014
2 parents 31a206e + b5ecd0a commit ecba425
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 116 deletions.
138 changes: 30 additions & 108 deletions daemon/voicecallhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,92 +65,6 @@ void VoiceCallHandler::initialize(bool notifyError)
{
Q_D(VoiceCallHandler);

/*
method return sender=:1.13 -> dest=:1.150 reply_serial=2
string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.nemomobile.voicecall.VoiceCall">
<property name="handlerId" type="s" access="read"/>
<property name="providerId" type="s" access="read"/>
<property name="status" type="i" access="read"/>
<property name="statusText" type="s" access="read"/>
<property name="lineId" type="s" access="read"/>
<property name="startedAt" type="((iii)(iiii)i)" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QDateTime"/>
</property>
<property name="duration" type="i" access="read"/>
<property name="isIncoming" type="b" access="read"/>
<property name="isEmergency" type="b" access="read"/>
<property name="isMultiparty" type="b" access="read"/>
<property name="isForwarded" type="b" access="read"/>
<signal name="error">
<arg name="message" type="s" direction="out"/>
</signal>
<signal name="statusChanged">
</signal>
<signal name="lineIdChanged">
</signal>
<signal name="startedAtChanged">
</signal>
<signal name="durationChanged">
</signal>
<signal name="emergencyChanged">
</signal>
<signal name="multipartyChanged">
</signal>
<signal name="forwardedChanged">
</signal>
<method name="answer">
<arg type="b" direction="out"/>
</method>
<method name="hangup">
<arg type="b" direction="out"/>
</method>
<method name="hold">
<arg type="b" direction="out"/>
<arg name="on" type="b" direction="in"/>
</method>
<method name="deflect">
<arg type="b" direction="out"/>
<arg name="target" type="s" direction="in"/>
</method>
<method name="sendDtmf">
<arg name="tones" type="s" direction="in"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Properties">
<method name="Get">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="out"/>
</method>
<method name="Set">
<arg name="interface_name" type="s" direction="in"/>
<arg name="property_name" type="s" direction="in"/>
<arg name="value" type="v" direction="in"/>
</method>
<method name="GetAll">
<arg name="interface_name" type="s" direction="in"/>
<arg name="values" type="a{sv}" direction="out"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Introspectable">
<method name="Introspect">
<arg name="xml_data" type="s" direction="out"/>
</method>
</interface>
<interface name="org.freedesktop.DBus.Peer">
<method name="Ping"/>
<method name="GetMachineId">
<arg name="machine_uuid" type="s" direction="out"/>
</method>
</interface>
</node>
"
*/

if (d->interface->isValid()) {
if (getProperties()) {
emit durationChanged();
Expand All @@ -162,13 +76,13 @@ method return sender=:1.13 -> dest=:1.150 reply_serial=2
emit forwardedChanged();

connect(d->interface, SIGNAL(error(QString)), SIGNAL(error(QString)));
connect(d->interface, SIGNAL(statusChanged()), SLOT(onStatusChanged()));
connect(d->interface, SIGNAL(lineIdChanged()), SLOT(onLineIdChanged()));
connect(d->interface, SIGNAL(durationChanged()), SLOT(onDurationChanged()));
connect(d->interface, SIGNAL(startedAtChanged()), SLOT(onStartedAtChanged()));
connect(d->interface, SIGNAL(emergencyChanged()), SLOT(onEmergencyChanged()));
connect(d->interface, SIGNAL(multipartyChanged()), SLOT(onMultipartyChanged()));
connect(d->interface, SIGNAL(forwardedChanged()), SLOT(onForwardedChanged()));
connect(d->interface, SIGNAL(statusChanged(int, QString)), SLOT(onStatusChanged(int, QString)));
connect(d->interface, SIGNAL(lineIdChanged(QString)), SLOT(onLineIdChanged(QString)));
connect(d->interface, SIGNAL(durationChanged(int)), SLOT(onDurationChanged(int)));
connect(d->interface, SIGNAL(startedAtChanged(QDateTime)), SLOT(onStartedAtChanged(QDateTime)));
connect(d->interface, SIGNAL(emergencyChanged(bool)), SLOT(onEmergencyChanged(bool)));
connect(d->interface, SIGNAL(multipartyChanged(bool)), SLOT(onMultipartyChanged(bool)));
connect(d->interface, SIGNAL(forwardedChanged(bool)), SLOT(onForwardedChanged(bool)));
}
else {
if (notifyError) emit this->error("Failed to get VoiceCall properties from VCM D-Bus service.");
Expand Down Expand Up @@ -207,54 +121,62 @@ bool VoiceCallHandler::getProperties()
}
}

void VoiceCallHandler::onDurationChanged()
void VoiceCallHandler::onDurationChanged(int duration)
{
Q_D(VoiceCallHandler);
d->duration = d->interface->property("duration").toInt();
//logger()->debug() <<"onDurationChanged"<<duration;
d->duration = duration;
emit durationChanged();
}

void VoiceCallHandler::onStatusChanged()
void VoiceCallHandler::onStatusChanged(int status, QString statusText)
{
// a) initialize() might returned crap with STATUS_NULL (no lineId)
// b) we need to fetch two properties "status" and "statusText"
// so, we might aswell get them all
Q_D(VoiceCallHandler);
logger()->debug() <<"onStatusChanged" << status << statusText;
d->status = status;
d->statusText = statusText;
// we still fetch all properties to be sure all properties are present.
getProperties();
emit statusChanged();
}

void VoiceCallHandler::onLineIdChanged()
void VoiceCallHandler::onLineIdChanged(QString lineId)
{
Q_D(VoiceCallHandler);
d->lineId = d->interface->property("lineId").toString();
logger()->debug() << "onLineIdChanged" << lineId;
d->lineId = lineId;
emit lineIdChanged();
}

void VoiceCallHandler::onStartedAtChanged()
void VoiceCallHandler::onStartedAtChanged(const QDateTime &startedAt)
{
Q_D(VoiceCallHandler);
logger()->debug() << "onStartedAtChanged" << startedAt;
d->startedAt = d->interface->property("startedAt").toDateTime();
emit startedAtChanged();
}

void VoiceCallHandler::onEmergencyChanged()
void VoiceCallHandler::onEmergencyChanged(bool isEmergency)
{
Q_D(VoiceCallHandler);
d->emergency = d->interface->property("isEmergency").toBool();
logger()->debug() << "onEmergencyChanged" << isEmergency;
d->emergency = isEmergency;
emit emergencyChanged();
}

void VoiceCallHandler::onMultipartyChanged()
void VoiceCallHandler::onMultipartyChanged(bool isMultiparty)
{
Q_D(VoiceCallHandler);
d->multiparty = d->interface->property("isMultiparty").toBool();
logger()->debug() << "onMultipartyChanged" << isMultiparty;
d->multiparty = isMultiparty;
emit multipartyChanged();
}

void VoiceCallHandler::onForwardedChanged()
void VoiceCallHandler::onForwardedChanged(bool isForwarded)
{
Q_D(VoiceCallHandler);
d->forwarded = d->interface->property("isForwarded").toBool();
logger()->debug() << "onForwardedChanged" << isForwarded;
d->forwarded = isForwarded;
emit forwardedChanged();
}

Expand Down
14 changes: 7 additions & 7 deletions daemon/voicecallhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ protected Q_SLOTS:
bool getProperties();

void onPendingCallFinished(QDBusPendingCallWatcher *watcher);
void onDurationChanged();
void onStatusChanged();
void onLineIdChanged();
void onStartedAtChanged();
void onEmergencyChanged();
void onMultipartyChanged();
void onForwardedChanged();
void onDurationChanged(int duration);
void onStatusChanged(int status, QString statusText);
void onLineIdChanged(QString lineId);
void onStartedAtChanged(const QDateTime &startedAt);
void onEmergencyChanged(bool isEmergency);
void onMultipartyChanged(bool isMultiparty);
void onForwardedChanged(bool isForwarded);

private:
class VoiceCallHandlerPrivate *d_ptr;
Expand Down
15 changes: 14 additions & 1 deletion daemon/watchconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ void WatchConnector::handleWatch(const QString &name, const QString &address)
if (emit_name) emit nameChanged();

logger()->debug() << "Creating socket";
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);

#else
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol);
#endif
connect(socket, SIGNAL(readyRead()), SLOT(onReadSocket()));
connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(onBytesWritten(qint64)));
connect(socket, SIGNAL(connected()), SLOT(onConnected()));
Expand All @@ -87,6 +90,16 @@ QString WatchConnector::decodeEndpoint(uint val)

void WatchConnector::decodeMsg(QByteArray data)
{
//Sometimes pebble sends a "00", we ignore it without future action
if (data.length() == 1 && data.at(0) == 0) {
return;
}

if (data.length() < 4) {
logger()->error() << "Can not decode message data length invalid: " << data.toHex();
return;
}

unsigned int datalen = 0;
int index = 0;
datalen = (data.at(index) << 8) + data.at(index+1);
Expand Down
2 changes: 2 additions & 0 deletions daemon/watchconnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
#include <QBluetoothServiceInfo>
#include <Log4Qt/Logger>

#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
using namespace QtBluetooth;
#endif

namespace watch
{
Expand Down

0 comments on commit ecba425

Please sign in to comment.