Merge lp:~tiagosh/telepathy-ofono/class0sms into lp:telepathy-ofono

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 73
Merged at revision: 73
Proposed branch: lp:~tiagosh/telepathy-ofono/class0sms
Merge into: lp:telepathy-ofono
Prerequisite: lp:~tiagosh/telepathy-ofono/ussd
Diff against target: 275 lines (+75/-41)
4 files modified
connection.cpp (+56/-36)
connection.h (+11/-3)
ofonotextchannel.cpp (+5/-1)
ofonotextchannel.h (+3/-1)
To merge this branch: bzr merge lp:~tiagosh/telepathy-ofono/class0sms
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+214102@code.launchpad.net

Commit message

Add class 0 SMS support

Description of the change

Add class 0 SMS support.

This MR depends on this other MR: https://code.launchpad.net/~tiagosh/ubuntu/trusty/telepathy-qt5/class0sms/+merge/214099

--------------
Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~tiagosh/telephony-service/class0sms/+merge/214100
https://code.launchpad.net/~tiagosh/history-service/class0sms/+merge/214103
https://code.launchpad.net/~tiagosh/ubuntu/trusty/telepathy-qt5/class0sms/+merge/214099

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/telepathy-ofono) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed the packaging (debian), did you subscribe a core-dev to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
No, a dependent change on telepathy-qt5 is required for it to build.

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'connection.cpp'
--- connection.cpp 2014-04-03 19:27:12 +0000
+++ connection.cpp 2014-04-03 19:27:12 +0000
@@ -250,6 +250,7 @@
250 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactsIface));250 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactsIface));
251251
252 QObject::connect(mOfonoMessageManager, SIGNAL(incomingMessage(QString,QVariantMap)), this, SLOT(onOfonoIncomingMessage(QString,QVariantMap)));252 QObject::connect(mOfonoMessageManager, SIGNAL(incomingMessage(QString,QVariantMap)), this, SLOT(onOfonoIncomingMessage(QString,QVariantMap)));
253 QObject::connect(mOfonoMessageManager, SIGNAL(immediateMessage(QString,QVariantMap)), this, SLOT(onOfonoImmediateMessage(QString,QVariantMap)));
253 QObject::connect(mOfonoMessageManager, SIGNAL(statusReport(QString,QVariantMap)), this, SLOT(onDeliveryReportReceived(QString,QVariantMap)));254 QObject::connect(mOfonoMessageManager, SIGNAL(statusReport(QString,QVariantMap)), this, SLOT(onDeliveryReportReceived(QString,QVariantMap)));
254 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(onOfonoCallAdded(QString, QVariantMap)));255 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(onOfonoCallAdded(QString, QVariantMap)));
255 QObject::connect(mOfonoVoiceCallManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool)));256 QObject::connect(mOfonoVoiceCallManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool)));
@@ -624,13 +625,18 @@
624 Q_UNUSED(targetHandleType);625 Q_UNUSED(targetHandleType);
625626
626 QStringList phoneNumbers;627 QStringList phoneNumbers;
628 bool flash = false;
627 if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles"))) {629 if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles"))) {
628 phoneNumbers << inspectHandles(Tp::HandleTypeContact, qdbus_cast<Tp::UIntList>(hints[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")]), error);630 phoneNumbers << inspectHandles(Tp::HandleTypeContact, qdbus_cast<Tp::UIntList>(hints[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")]), error);
629 } else {631 } else {
630 phoneNumbers << mHandles.value(targetHandle);632 phoneNumbers << mHandles.value(targetHandle);
631 }633 }
632634
633 oFonoTextChannel *channel = new oFonoTextChannel(this, phoneNumbers);635 if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_SMS + QLatin1String(".Flash"))) {
636 flash = hints[TP_QT_IFACE_CHANNEL_INTERFACE_SMS + QLatin1String(".Flash")].toBool();
637 }
638
639 oFonoTextChannel *channel = new oFonoTextChannel(this, phoneNumbers, flash);
634 mTextChannels << channel;640 mTextChannels << channel;
635 QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString)));641 QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString)));
636 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed()));642 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed()));
@@ -683,32 +689,12 @@
683 return Tp::BaseChannelPtr();689 return Tp::BaseChannelPtr();
684 }690 }
685691
686 Q_FOREACH(const QString &phoneNumber, mCallChannels.keys()) {692 QDBusObjectPath objpath(hints["ofonoObjPath"].toString());
687 if (PhoneUtils::comparePhoneNumbers(phoneNumber, newPhoneNumber)) {693
688 return mCallChannels[phoneNumber]->baseChannel();694 if (objpath.path().isEmpty()) {
689 }
690 }
691
692 bool isOngoingCall = false;
693 QDBusObjectPath objpath;
694 Q_FOREACH(const QString &callId, mOfonoVoiceCallManager->getCalls()) {
695 // check if this is an ongoing call
696 OfonoVoiceCall *call = new OfonoVoiceCall(callId);
697 if ((call->lineIdentification().isEmpty() && newPhoneNumber == "x-ofono-unknown") ||
698 (call->lineIdentification() == "withheld" && newPhoneNumber == "x-ofono-private") ||
699 PhoneUtils::comparePhoneNumbers(call->lineIdentification(), newPhoneNumber)) {
700 isOngoingCall = true;
701 }
702 call->deleteLater();
703 if (isOngoingCall) {
704 objpath.setPath(callId);
705 break;
706 }
707 }
708
709 if (!isOngoingCall) {
710 objpath = mOfonoVoiceCallManager->dial(newPhoneNumber, "", success);695 objpath = mOfonoVoiceCallManager->dial(newPhoneNumber, "", success);
711 }696 }
697
712 qDebug() << "success " << success;698 qDebug() << "success " << success;
713 if (objpath.path().isEmpty() || !success) {699 if (objpath.path().isEmpty() || !success) {
714 if (!success) {700 if (!success) {
@@ -719,8 +705,8 @@
719 return Tp::BaseChannelPtr();705 return Tp::BaseChannelPtr();
720 }706 }
721707
722 oFonoCallChannel *channel = new oFonoCallChannel(this, newPhoneNumber, targetHandle,objpath.path());708 oFonoCallChannel *channel = new oFonoCallChannel(this, newPhoneNumber, targetHandle, objpath.path());
723 mCallChannels[newPhoneNumber] = channel;709 mCallChannels[objpath.path()] = channel;
724 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onCallChannelDestroyed()));710 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onCallChannelDestroyed()));
725 QObject::connect(channel, SIGNAL(closed()), SLOT(onCallChannelClosed()));711 QObject::connect(channel, SIGNAL(closed()), SLOT(onCallChannelClosed()));
726 QObject::connect(channel, SIGNAL(merged()), SLOT(onCallChannelMerged()));712 QObject::connect(channel, SIGNAL(merged()), SLOT(onCallChannelMerged()));
@@ -835,6 +821,16 @@
835821
836void oFonoConnection::onOfonoIncomingMessage(const QString &message, const QVariantMap &info)822void oFonoConnection::onOfonoIncomingMessage(const QString &message, const QVariantMap &info)
837{823{
824 ensureTextChannel(message, info, false);
825}
826
827void oFonoConnection::onOfonoImmediateMessage(const QString &message, const QVariantMap &info)
828{
829 ensureTextChannel(message, info, true);
830}
831
832void oFonoConnection::ensureTextChannel(const QString &message, const QVariantMap &info, bool flash)
833{
838 const QString normalizedNumber = PhoneUtils::normalizePhoneNumber(info["Sender"].toString());834 const QString normalizedNumber = PhoneUtils::normalizePhoneNumber(info["Sender"].toString());
839 // check if there is an open channel for this sender and use it835 // check if there is an open channel for this sender and use it
840 oFonoTextChannel *channel = textChannelForMembers(QStringList() << normalizedNumber);836 oFonoTextChannel *channel = textChannelForMembers(QStringList() << normalizedNumber);
@@ -845,8 +841,10 @@
845841
846 Tp::DBusError error;842 Tp::DBusError error;
847 bool yours;843 bool yours;
844 QVariantMap hints;
845 hints[TP_QT_IFACE_CHANNEL_INTERFACE_SMS + QLatin1String(".Flash")] = flash;
848 uint handle = newHandle(normalizedNumber);846 uint handle = newHandle(normalizedNumber);
849 ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_TEXT,Tp::HandleTypeContact, handle, yours, handle, false, QVariantMap(), &error);847 ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_TEXT,Tp::HandleTypeContact, handle, yours, handle, false, hints, &error);
850 if(error.isValid()) {848 if(error.isValid()) {
851 qWarning() << "Error creating channel for incoming message" << error.name() << error.message();849 qWarning() << "Error creating channel for incoming message" << error.name() << error.message();
852 return;850 return;
@@ -901,6 +899,26 @@
901 return newHandle(normalizedNumber);899 return newHandle(normalizedNumber);
902}900}
903901
902Tp::BaseChannelPtr oFonoConnection::ensureChannel(const QString &channelType, uint targetHandleType,
903 uint targetHandle, bool &yours, uint initiatorHandle,
904 bool suppressHandler,
905 const QVariantMap &hints,
906 Tp::DBusError* error)
907{
908 // we only reuse old text channels
909 if (channelType == TP_QT_IFACE_CHANNEL_TYPE_TEXT) {
910 Q_FOREACH(oFonoTextChannel *channel, mTextChannels) {
911 if (channel->baseChannel()->targetHandleType() == targetHandleType
912 && channel->baseChannel()->targetHandle() == targetHandle) {
913 yours = false;
914 return channel->baseChannel();
915 }
916 }
917 }
918 yours = true;
919 return Tp::BaseConnection::createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, hints, error);
920}
921
904void oFonoConnection::onOfonoCallAdded(const QString &call, const QVariantMap &properties)922void oFonoConnection::onOfonoCallAdded(const QString &call, const QVariantMap &properties)
905{923{
906 qDebug() << "new call" << call << properties;924 qDebug() << "new call" << call << properties;
@@ -908,6 +926,13 @@
908 bool yours;926 bool yours;
909 Tp::DBusError error;927 Tp::DBusError error;
910 QString lineIdentification = properties["LineIdentification"].toString();928 QString lineIdentification = properties["LineIdentification"].toString();
929
930 // check if there is an open channel for this call, if so, ignore it
931 if (mCallChannels.keys().contains(call)) {
932 qWarning() << "call channel for this object path already exists: " << call;
933 return;
934 }
935
911 QString normalizedNumber;936 QString normalizedNumber;
912 // TODO check if more than one private/unknown calls are supported at the same time937 // TODO check if more than one private/unknown calls are supported at the same time
913 if (lineIdentification.isEmpty()) {938 if (lineIdentification.isEmpty()) {
@@ -921,13 +946,6 @@
921 } else {946 } else {
922 normalizedNumber = PhoneUtils::normalizePhoneNumber(lineIdentification);947 normalizedNumber = PhoneUtils::normalizePhoneNumber(lineIdentification);
923 }948 }
924 // check if there is an open channel for this number, if so, ignore it
925 Q_FOREACH(const QString &phoneNumber, mCallChannels.keys()) {
926 if (PhoneUtils::comparePhoneNumbers(normalizedNumber, phoneNumber)) {
927 qWarning() << "call channel for this number already exists: " << phoneNumber;
928 return;
929 }
930 }
931949
932 uint handle = ensureHandle(normalizedNumber);950 uint handle = ensureHandle(normalizedNumber);
933 uint initiatorHandle = 0;951 uint initiatorHandle = 0;
@@ -940,7 +958,9 @@
940 qDebug() << "initiatorHandle " <<initiatorHandle;958 qDebug() << "initiatorHandle " <<initiatorHandle;
941 qDebug() << "handle" << handle;959 qDebug() << "handle" << handle;
942960
943 Tp::BaseChannelPtr channel = ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_CALL, Tp::HandleTypeContact, handle, yours, initiatorHandle, false, QVariantMap(), &error);961 QVariantMap hints;
962 hints["ofonoObjPath"] = call;
963 Tp::BaseChannelPtr channel = ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_CALL, Tp::HandleTypeContact, handle, yours, initiatorHandle, false, hints, &error);
944 if (error.isValid() || channel.isNull()) {964 if (error.isValid() || channel.isNull()) {
945 qWarning() << "error creating the channel " << error.name() << error.message();965 qWarning() << "error creating the channel " << error.name() << error.message();
946 return;966 return;
947967
=== modified file 'connection.h'
--- connection.h 2014-04-03 19:27:12 +0000
+++ connection.h 2014-04-03 19:27:12 +0000
@@ -68,7 +68,7 @@
68 QStringList inspectHandles(uint handleType, const Tp::UIntList& handles, Tp::DBusError *error);68 QStringList inspectHandles(uint handleType, const Tp::UIntList& handles, Tp::DBusError *error);
69 Tp::UIntList requestHandles(uint handleType, const QStringList& identifiers, Tp::DBusError* error);69 Tp::UIntList requestHandles(uint handleType, const QStringList& identifiers, Tp::DBusError* error);
70 Tp::BaseChannelPtr createChannel(const QString& channelType, uint targetHandleType,70 Tp::BaseChannelPtr createChannel(const QString& channelType, uint targetHandleType,
71 uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);71 uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
72 Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);72 Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
73 uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);73 uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
74 void connect(Tp::DBusError *error);74 void connect(Tp::DBusError *error);
@@ -97,9 +97,15 @@
97 uint ensureHandle(const QString &phoneNumber);97 uint ensureHandle(const QString &phoneNumber);
98 oFonoTextChannel* textChannelForMembers(const QStringList &members);98 oFonoTextChannel* textChannelForMembers(const QStringList &members);
99 Tp::BaseChannelPtr createTextChannel(uint targetHandleType,99 Tp::BaseChannelPtr createTextChannel(uint targetHandleType,
100 uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);100 uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
101 Tp::BaseChannelPtr createCallChannel(uint targetHandleType,101 Tp::BaseChannelPtr createCallChannel(uint targetHandleType,
102 uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);102 uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
103 Tp::BaseChannelPtr ensureChannel(const QString &channelType, uint targetHandleType,
104 uint targetHandle, bool &yours, uint initiatorHandle,
105 bool suppressHandler,
106 const QVariantMap &hints,
107 Tp::DBusError* error);
108
103109
104 ~oFonoConnection();110 ~oFonoConnection();
105111
@@ -115,6 +121,7 @@
115121
116private Q_SLOTS:122private Q_SLOTS:
117 void onOfonoIncomingMessage(const QString &message, const QVariantMap &info);123 void onOfonoIncomingMessage(const QString &message, const QVariantMap &info);
124 void onOfonoImmediateMessage(const QString &message, const QVariantMap &info);
118 void onOfonoCallAdded(const QString &call, const QVariantMap &properties);125 void onOfonoCallAdded(const QString &call, const QVariantMap &properties);
119 void onOfonoNetworkRegistrationChanged(const QString &status);126 void onOfonoNetworkRegistrationChanged(const QString &status);
120 void onTextChannelClosed();127 void onTextChannelClosed();
@@ -138,6 +145,7 @@
138private:145private:
139 bool isNetworkRegistered();146 bool isNetworkRegistered();
140 void addMMSToService(const QString &path, const QVariantMap &properties, const QString &servicePath);147 void addMMSToService(const QString &path, const QVariantMap &properties, const QString &servicePath);
148 void ensureTextChannel(const QString &message, const QVariantMap &info, bool flash);
141 QMap<uint, QString> mHandles;149 QMap<uint, QString> mHandles;
142150
143 QList<oFonoTextChannel*> mTextChannels;151 QList<oFonoTextChannel*> mTextChannels;
144152
=== modified file 'ofonotextchannel.cpp'
--- ofonotextchannel.cpp 2014-02-24 21:12:26 +0000
+++ ofonotextchannel.cpp 2014-04-03 19:27:12 +0000
@@ -39,10 +39,11 @@
39 return argument;39 return argument;
40}40}
4141
42oFonoTextChannel::oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, QObject *parent):42oFonoTextChannel::oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, bool flash, QObject *parent):
43 QObject(parent),43 QObject(parent),
44 mConnection(conn),44 mConnection(conn),
45 mPhoneNumbers(phoneNumbers),45 mPhoneNumbers(phoneNumbers),
46 mFlash(flash),
46 mMessageCounter(1)47 mMessageCounter(1)
47{48{
48 qDBusRegisterMetaType<AttachmentStruct>();49 qDBusRegisterMetaType<AttachmentStruct>();
@@ -87,6 +88,9 @@
87 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mGroupIface));88 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mGroupIface));
88 addMembers(phoneNumbers);89 addMembers(phoneNumbers);
8990
91 mSMSIface = Tp::BaseChannelSMSInterface::create(flash, true);
92 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mSMSIface));
93
90 mBaseChannel = baseChannel;94 mBaseChannel = baseChannel;
91 mTextChannel = Tp::BaseChannelTextTypePtr::dynamicCast(mBaseChannel->interface(TP_QT_IFACE_CHANNEL_TYPE_TEXT));95 mTextChannel = Tp::BaseChannelTextTypePtr::dynamicCast(mBaseChannel->interface(TP_QT_IFACE_CHANNEL_TYPE_TEXT));
92 mTextChannel->setMessageAcknowledgedCallback(Tp::memFun(this,&oFonoTextChannel::messageAcknowledged));96 mTextChannel->setMessageAcknowledgedCallback(Tp::memFun(this,&oFonoTextChannel::messageAcknowledged));
9397
=== modified file 'ofonotextchannel.h'
--- ofonotextchannel.h 2014-02-18 21:09:03 +0000
+++ ofonotextchannel.h 2014-04-03 19:27:12 +0000
@@ -34,7 +34,7 @@
34{34{
35 Q_OBJECT35 Q_OBJECT
36public:36public:
37 oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, QObject *parent = 0);37 oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, bool flash = false, QObject *parent = 0);
38 QString sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error);38 QString sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error);
39 void messageReceived(const QString & message, uint handle, const QVariantMap &info);39 void messageReceived(const QString & message, uint handle, const QVariantMap &info);
40 Tp::BaseChannelPtr baseChannel();40 Tp::BaseChannelPtr baseChannel();
@@ -61,11 +61,13 @@
61 oFonoConnection *mConnection;61 oFonoConnection *mConnection;
62 Tp::BaseChannelMessagesInterfacePtr mMessagesIface;62 Tp::BaseChannelMessagesInterfacePtr mMessagesIface;
63 Tp::BaseChannelGroupInterfacePtr mGroupIface;63 Tp::BaseChannelGroupInterfacePtr mGroupIface;
64 Tp::BaseChannelSMSInterfacePtr mSMSIface;
64 Tp::BaseChannelTextTypePtr mTextChannel;65 Tp::BaseChannelTextTypePtr mTextChannel;
65 uint mMessageCounter;66 uint mMessageCounter;
66 QMap<QString, uint> mPendingDeliveryReportFailed;67 QMap<QString, uint> mPendingDeliveryReportFailed;
67 QMap<QString, uint> mPendingDeliveryReportDelivered;68 QMap<QString, uint> mPendingDeliveryReportDelivered;
68 Tp::UIntList mMembers;69 Tp::UIntList mMembers;
70 bool mFlash;
69};71};
7072
71#endif // OFONOTEXTCHANNEL_H73#endif // OFONOTEXTCHANNEL_H

Subscribers

People subscribed via source and target branches