diff options
Diffstat (limited to 'community/spacebar/0001-Normalize-numbers-for-Ofono.patch')
-rw-r--r-- | community/spacebar/0001-Normalize-numbers-for-Ofono.patch | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/community/spacebar/0001-Normalize-numbers-for-Ofono.patch b/community/spacebar/0001-Normalize-numbers-for-Ofono.patch deleted file mode 100644 index e28ad2e5dde..00000000000 --- a/community/spacebar/0001-Normalize-numbers-for-Ofono.patch +++ /dev/null @@ -1,113 +0,0 @@ -From bbf06092209dbc47ff5b53a0cdbf8afe7a45c3b6 Mon Sep 17 00:00:00 2001 -From: Smitty van Bodegom <me@smitop.com> -Date: Tue, 20 Jul 2021 19:09:11 -0400 -Subject: [PATCH] Normalize numbers for Ofono - ---- - lib/telephonySupport/phonenumberutils.cpp | 22 +++++++++++++++ - lib/telephonySupport/phonenumberutils.h | 1 + - src/messagemanager.cpp | 33 +++++++++++++---------- - 3 files changed, 42 insertions(+), 14 deletions(-) - -diff --git a/lib/telephonySupport/phonenumberutils.cpp b/lib/telephonySupport/phonenumberutils.cpp -index 7865224..f019c86 100644 ---- a/lib/telephonySupport/phonenumberutils.cpp -+++ b/lib/telephonySupport/phonenumberutils.cpp -@@ -4,6 +4,7 @@ - - #include "phonenumberutils.h" - -+#include <QChar> - #include <QLocale> - - #include <phonenumbers/phonenumberutil.h> -@@ -46,4 +47,25 @@ QString normalizeNumber(const QString &numberString, PhoneNumberFormat format) - return numberString; - } - -+// normalize a number so that Ofono can understand it -+QString normalizeForOfono(const QString &numberString) -+{ -+ // ofono number parsing: -+ // https://github.com/rilmodem/ofono/blob/efc9c0a85d32706bc088e449e847be41dcc73b3d/src/common.c#L238 -+ -+ QString normalized; -+ for (int i = 0; i < numberString.size(); ++i) { -+ QChar c = numberString.at(i); -+ if (c == QChar(u'+') && normalized.isEmpty()) { -+ // plus is allowed but only as first character -+ normalized.append(u'+'); -+ } else if ((c >= QChar(u'0') && c <= QChar(u'9')) || c == QChar(u'*') || -+ c == QChar(u'#')) { -+ normalized.append(c); -+ } -+ // ignore all other characters -+ } -+ -+ return normalized; -+} - } -diff --git a/lib/telephonySupport/phonenumberutils.h b/lib/telephonySupport/phonenumberutils.h -index 6aeb5fd..30da605 100644 ---- a/lib/telephonySupport/phonenumberutils.h -+++ b/lib/telephonySupport/phonenumberutils.h -@@ -31,4 +31,5 @@ using NormalizeResult = std::variant<std::string, ErrorType>; - - NormalizeResult normalizeNumber(const std::string &numberString, PhoneNumberFormat format = International); - QString normalizeNumber(const QString &numberString, PhoneNumberFormat format = International); -+QString normalizeForOfono(const QString &numberString); - }; -diff --git a/src/messagemanager.cpp b/src/messagemanager.cpp -index 4934a94..6811ace 100644 ---- a/src/messagemanager.cpp -+++ b/src/messagemanager.cpp -@@ -7,6 +7,7 @@ - #include <QFutureInterface> - - #include <global.h> -+#include <phonenumberutils.h> - - MessageManager::MessageManager(QObject *parent) - : QOfonoMessageManager(parent) -@@ -25,20 +26,24 @@ QFuture<SendMessageResult> MessageManager::sendMessage(const QString &to, const - return futureInterface->future(); - } - -- connect(new QDBusPendingCallWatcher(iface->asyncCall(SL("SendMessage"), to, text), iface), -- &QDBusPendingCallWatcher::finished, -- [=](QDBusPendingCallWatcher *watcher) { -- watcher->deleteLater(); -- -- QDBusPendingReply<QDBusObjectPath> reply = *watcher; -- if (reply.isError()) { -- futureInterface->reportResult(reply.error()); -- futureInterface->reportFinished(); -- } else { -- futureInterface->reportResult(reply.value()); -- futureInterface->reportFinished(); -- } -- }); -+ connect(new QDBusPendingCallWatcher( -+ iface->asyncCall(SL("SendMessage"), -+ phoneNumberUtils::normalizeForOfono(to), -+ text), -+ iface), -+ &QDBusPendingCallWatcher::finished, -+ [=](QDBusPendingCallWatcher *watcher) { -+ watcher->deleteLater(); -+ -+ QDBusPendingReply<QDBusObjectPath> reply = *watcher; -+ if (reply.isError()) { -+ futureInterface->reportResult(reply.error()); -+ futureInterface->reportFinished(); -+ } else { -+ futureInterface->reportResult(reply.value()); -+ futureInterface->reportFinished(); -+ } -+ }); - - return futureInterface->future(); - } --- -GitLab - |