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
1=== modified file 'connection.cpp'
2--- connection.cpp 2014-04-03 19:27:12 +0000
3+++ connection.cpp 2014-04-03 19:27:12 +0000
4@@ -250,6 +250,7 @@
5 plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactsIface));
6
7 QObject::connect(mOfonoMessageManager, SIGNAL(incomingMessage(QString,QVariantMap)), this, SLOT(onOfonoIncomingMessage(QString,QVariantMap)));
8+ QObject::connect(mOfonoMessageManager, SIGNAL(immediateMessage(QString,QVariantMap)), this, SLOT(onOfonoImmediateMessage(QString,QVariantMap)));
9 QObject::connect(mOfonoMessageManager, SIGNAL(statusReport(QString,QVariantMap)), this, SLOT(onDeliveryReportReceived(QString,QVariantMap)));
10 QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(onOfonoCallAdded(QString, QVariantMap)));
11 QObject::connect(mOfonoVoiceCallManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool)));
12@@ -624,13 +625,18 @@
13 Q_UNUSED(targetHandleType);
14
15 QStringList phoneNumbers;
16+ bool flash = false;
17 if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles"))) {
18 phoneNumbers << inspectHandles(Tp::HandleTypeContact, qdbus_cast<Tp::UIntList>(hints[TP_QT_IFACE_CHANNEL_INTERFACE_CONFERENCE + QLatin1String(".InitialInviteeHandles")]), error);
19 } else {
20 phoneNumbers << mHandles.value(targetHandle);
21 }
22
23- oFonoTextChannel *channel = new oFonoTextChannel(this, phoneNumbers);
24+ if (hints.contains(TP_QT_IFACE_CHANNEL_INTERFACE_SMS + QLatin1String(".Flash"))) {
25+ flash = hints[TP_QT_IFACE_CHANNEL_INTERFACE_SMS + QLatin1String(".Flash")].toBool();
26+ }
27+
28+ oFonoTextChannel *channel = new oFonoTextChannel(this, phoneNumbers, flash);
29 mTextChannels << channel;
30 QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString)));
31 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed()));
32@@ -683,32 +689,12 @@
33 return Tp::BaseChannelPtr();
34 }
35
36- Q_FOREACH(const QString &phoneNumber, mCallChannels.keys()) {
37- if (PhoneUtils::comparePhoneNumbers(phoneNumber, newPhoneNumber)) {
38- return mCallChannels[phoneNumber]->baseChannel();
39- }
40- }
41-
42- bool isOngoingCall = false;
43- QDBusObjectPath objpath;
44- Q_FOREACH(const QString &callId, mOfonoVoiceCallManager->getCalls()) {
45- // check if this is an ongoing call
46- OfonoVoiceCall *call = new OfonoVoiceCall(callId);
47- if ((call->lineIdentification().isEmpty() && newPhoneNumber == "x-ofono-unknown") ||
48- (call->lineIdentification() == "withheld" && newPhoneNumber == "x-ofono-private") ||
49- PhoneUtils::comparePhoneNumbers(call->lineIdentification(), newPhoneNumber)) {
50- isOngoingCall = true;
51- }
52- call->deleteLater();
53- if (isOngoingCall) {
54- objpath.setPath(callId);
55- break;
56- }
57- }
58-
59- if (!isOngoingCall) {
60+ QDBusObjectPath objpath(hints["ofonoObjPath"].toString());
61+
62+ if (objpath.path().isEmpty()) {
63 objpath = mOfonoVoiceCallManager->dial(newPhoneNumber, "", success);
64 }
65+
66 qDebug() << "success " << success;
67 if (objpath.path().isEmpty() || !success) {
68 if (!success) {
69@@ -719,8 +705,8 @@
70 return Tp::BaseChannelPtr();
71 }
72
73- oFonoCallChannel *channel = new oFonoCallChannel(this, newPhoneNumber, targetHandle,objpath.path());
74- mCallChannels[newPhoneNumber] = channel;
75+ oFonoCallChannel *channel = new oFonoCallChannel(this, newPhoneNumber, targetHandle, objpath.path());
76+ mCallChannels[objpath.path()] = channel;
77 QObject::connect(channel, SIGNAL(destroyed()), SLOT(onCallChannelDestroyed()));
78 QObject::connect(channel, SIGNAL(closed()), SLOT(onCallChannelClosed()));
79 QObject::connect(channel, SIGNAL(merged()), SLOT(onCallChannelMerged()));
80@@ -835,6 +821,16 @@
81
82 void oFonoConnection::onOfonoIncomingMessage(const QString &message, const QVariantMap &info)
83 {
84+ ensureTextChannel(message, info, false);
85+}
86+
87+void oFonoConnection::onOfonoImmediateMessage(const QString &message, const QVariantMap &info)
88+{
89+ ensureTextChannel(message, info, true);
90+}
91+
92+void oFonoConnection::ensureTextChannel(const QString &message, const QVariantMap &info, bool flash)
93+{
94 const QString normalizedNumber = PhoneUtils::normalizePhoneNumber(info["Sender"].toString());
95 // check if there is an open channel for this sender and use it
96 oFonoTextChannel *channel = textChannelForMembers(QStringList() << normalizedNumber);
97@@ -845,8 +841,10 @@
98
99 Tp::DBusError error;
100 bool yours;
101+ QVariantMap hints;
102+ hints[TP_QT_IFACE_CHANNEL_INTERFACE_SMS + QLatin1String(".Flash")] = flash;
103 uint handle = newHandle(normalizedNumber);
104- ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_TEXT,Tp::HandleTypeContact, handle, yours, handle, false, QVariantMap(), &error);
105+ ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_TEXT,Tp::HandleTypeContact, handle, yours, handle, false, hints, &error);
106 if(error.isValid()) {
107 qWarning() << "Error creating channel for incoming message" << error.name() << error.message();
108 return;
109@@ -901,6 +899,26 @@
110 return newHandle(normalizedNumber);
111 }
112
113+Tp::BaseChannelPtr oFonoConnection::ensureChannel(const QString &channelType, uint targetHandleType,
114+ uint targetHandle, bool &yours, uint initiatorHandle,
115+ bool suppressHandler,
116+ const QVariantMap &hints,
117+ Tp::DBusError* error)
118+{
119+ // we only reuse old text channels
120+ if (channelType == TP_QT_IFACE_CHANNEL_TYPE_TEXT) {
121+ Q_FOREACH(oFonoTextChannel *channel, mTextChannels) {
122+ if (channel->baseChannel()->targetHandleType() == targetHandleType
123+ && channel->baseChannel()->targetHandle() == targetHandle) {
124+ yours = false;
125+ return channel->baseChannel();
126+ }
127+ }
128+ }
129+ yours = true;
130+ return Tp::BaseConnection::createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, hints, error);
131+}
132+
133 void oFonoConnection::onOfonoCallAdded(const QString &call, const QVariantMap &properties)
134 {
135 qDebug() << "new call" << call << properties;
136@@ -908,6 +926,13 @@
137 bool yours;
138 Tp::DBusError error;
139 QString lineIdentification = properties["LineIdentification"].toString();
140+
141+ // check if there is an open channel for this call, if so, ignore it
142+ if (mCallChannels.keys().contains(call)) {
143+ qWarning() << "call channel for this object path already exists: " << call;
144+ return;
145+ }
146+
147 QString normalizedNumber;
148 // TODO check if more than one private/unknown calls are supported at the same time
149 if (lineIdentification.isEmpty()) {
150@@ -921,13 +946,6 @@
151 } else {
152 normalizedNumber = PhoneUtils::normalizePhoneNumber(lineIdentification);
153 }
154- // check if there is an open channel for this number, if so, ignore it
155- Q_FOREACH(const QString &phoneNumber, mCallChannels.keys()) {
156- if (PhoneUtils::comparePhoneNumbers(normalizedNumber, phoneNumber)) {
157- qWarning() << "call channel for this number already exists: " << phoneNumber;
158- return;
159- }
160- }
161
162 uint handle = ensureHandle(normalizedNumber);
163 uint initiatorHandle = 0;
164@@ -940,7 +958,9 @@
165 qDebug() << "initiatorHandle " <<initiatorHandle;
166 qDebug() << "handle" << handle;
167
168- Tp::BaseChannelPtr channel = ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_CALL, Tp::HandleTypeContact, handle, yours, initiatorHandle, false, QVariantMap(), &error);
169+ QVariantMap hints;
170+ hints["ofonoObjPath"] = call;
171+ Tp::BaseChannelPtr channel = ensureChannel(TP_QT_IFACE_CHANNEL_TYPE_CALL, Tp::HandleTypeContact, handle, yours, initiatorHandle, false, hints, &error);
172 if (error.isValid() || channel.isNull()) {
173 qWarning() << "error creating the channel " << error.name() << error.message();
174 return;
175
176=== modified file 'connection.h'
177--- connection.h 2014-04-03 19:27:12 +0000
178+++ connection.h 2014-04-03 19:27:12 +0000
179@@ -68,7 +68,7 @@
180 QStringList inspectHandles(uint handleType, const Tp::UIntList& handles, Tp::DBusError *error);
181 Tp::UIntList requestHandles(uint handleType, const QStringList& identifiers, Tp::DBusError* error);
182 Tp::BaseChannelPtr createChannel(const QString& channelType, uint targetHandleType,
183- uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
184+ uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
185 Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
186 uint setPresence(const QString& status, const QString& statusMessage, Tp::DBusError *error);
187 void connect(Tp::DBusError *error);
188@@ -97,9 +97,15 @@
189 uint ensureHandle(const QString &phoneNumber);
190 oFonoTextChannel* textChannelForMembers(const QStringList &members);
191 Tp::BaseChannelPtr createTextChannel(uint targetHandleType,
192- uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
193+ uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
194 Tp::BaseChannelPtr createCallChannel(uint targetHandleType,
195- uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
196+ uint targetHandle, const QVariantMap &hints, Tp::DBusError *error);
197+ Tp::BaseChannelPtr ensureChannel(const QString &channelType, uint targetHandleType,
198+ uint targetHandle, bool &yours, uint initiatorHandle,
199+ bool suppressHandler,
200+ const QVariantMap &hints,
201+ Tp::DBusError* error);
202+
203
204 ~oFonoConnection();
205
206@@ -115,6 +121,7 @@
207
208 private Q_SLOTS:
209 void onOfonoIncomingMessage(const QString &message, const QVariantMap &info);
210+ void onOfonoImmediateMessage(const QString &message, const QVariantMap &info);
211 void onOfonoCallAdded(const QString &call, const QVariantMap &properties);
212 void onOfonoNetworkRegistrationChanged(const QString &status);
213 void onTextChannelClosed();
214@@ -138,6 +145,7 @@
215 private:
216 bool isNetworkRegistered();
217 void addMMSToService(const QString &path, const QVariantMap &properties, const QString &servicePath);
218+ void ensureTextChannel(const QString &message, const QVariantMap &info, bool flash);
219 QMap<uint, QString> mHandles;
220
221 QList<oFonoTextChannel*> mTextChannels;
222
223=== modified file 'ofonotextchannel.cpp'
224--- ofonotextchannel.cpp 2014-02-24 21:12:26 +0000
225+++ ofonotextchannel.cpp 2014-04-03 19:27:12 +0000
226@@ -39,10 +39,11 @@
227 return argument;
228 }
229
230-oFonoTextChannel::oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, QObject *parent):
231+oFonoTextChannel::oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, bool flash, QObject *parent):
232 QObject(parent),
233 mConnection(conn),
234 mPhoneNumbers(phoneNumbers),
235+ mFlash(flash),
236 mMessageCounter(1)
237 {
238 qDBusRegisterMetaType<AttachmentStruct>();
239@@ -87,6 +88,9 @@
240 baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mGroupIface));
241 addMembers(phoneNumbers);
242
243+ mSMSIface = Tp::BaseChannelSMSInterface::create(flash, true);
244+ baseChannel->plugInterface(Tp::AbstractChannelInterfacePtr::dynamicCast(mSMSIface));
245+
246 mBaseChannel = baseChannel;
247 mTextChannel = Tp::BaseChannelTextTypePtr::dynamicCast(mBaseChannel->interface(TP_QT_IFACE_CHANNEL_TYPE_TEXT));
248 mTextChannel->setMessageAcknowledgedCallback(Tp::memFun(this,&oFonoTextChannel::messageAcknowledged));
249
250=== modified file 'ofonotextchannel.h'
251--- ofonotextchannel.h 2014-02-18 21:09:03 +0000
252+++ ofonotextchannel.h 2014-04-03 19:27:12 +0000
253@@ -34,7 +34,7 @@
254 {
255 Q_OBJECT
256 public:
257- oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, QObject *parent = 0);
258+ oFonoTextChannel(oFonoConnection *conn, QStringList phoneNumbers, bool flash = false, QObject *parent = 0);
259 QString sendMessage(const Tp::MessagePartList& message, uint flags, Tp::DBusError* error);
260 void messageReceived(const QString & message, uint handle, const QVariantMap &info);
261 Tp::BaseChannelPtr baseChannel();
262@@ -61,11 +61,13 @@
263 oFonoConnection *mConnection;
264 Tp::BaseChannelMessagesInterfacePtr mMessagesIface;
265 Tp::BaseChannelGroupInterfacePtr mGroupIface;
266+ Tp::BaseChannelSMSInterfacePtr mSMSIface;
267 Tp::BaseChannelTextTypePtr mTextChannel;
268 uint mMessageCounter;
269 QMap<QString, uint> mPendingDeliveryReportFailed;
270 QMap<QString, uint> mPendingDeliveryReportDelivered;
271 Tp::UIntList mMembers;
272+ bool mFlash;
273 };
274
275 #endif // OFONOTEXTCHANNEL_H

Subscribers

People subscribed via source and target branches