From 0f8d89147661b6e6afee8e012a889c79c5830459 Mon Sep 17 00:00:00 2001
From: kkostiuk <kateryna.kostiuk@savoirfairelinux.com>
Date: Mon, 25 Jul 2022 11:34:23 -0400
Subject: [PATCH] iOS: drop support for voip notifications

---
 CMakeLists.txt                     |  7 -----
 configure.ac                       |  4 ---
 include/opendht/dht_proxy_server.h |  3 +-
 src/Makefile.am                    |  6 ----
 src/compat/apple/apple_utils.h     | 26 ------------------
 src/compat/apple/apple_utils.mm    | 44 ------------------------------
 src/dht_proxy_client.cpp           |  5 +---
 src/dht_proxy_server.cpp           | 32 +++++++---------------
 8 files changed, 12 insertions(+), 115 deletions(-)
 delete mode 100644 src/compat/apple/apple_utils.h
 delete mode 100644 src/compat/apple/apple_utils.mm

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1d0d8f2..ad4aaad0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -223,13 +223,6 @@ list (APPEND opendht_SOURCES
     src/thread_pool.cpp
 )
 
-if (APPLE)
-    list (APPEND opendht_SOURCES
-        src/compat/apple/apple_utils.h
-        src/compat/apple/apple_utils.mm
-    )
-endif()
-
 list (APPEND opendht_HEADERS
     include/opendht/def.h
     include/opendht/utils.h
diff --git a/configure.ac b/configure.ac
index 61b565bd..4afaad1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,6 @@ LT_INIT()
 LT_LANG(C++)
 AC_LANG(C++)
 AC_PROG_CXX
-AC_PROG_OBJCXX
 AX_CXX_COMPILE_STDCXX(17,[noext],[mandatory])
 
 dnl Check for logs
@@ -92,7 +91,6 @@ case "${host_os}" in
     SYS=linux
     ;;
   darwin*)
-    APPLE=1
     SYS=darwin
     ;;
   mingw32*)
@@ -112,7 +110,6 @@ case "${host_os}" in
     ;;
 esac
 
-AM_CONDITIONAL(APPLE, [test "x$SYS" = "xdarwin"])
 AM_CONDITIONAL(WIN32, [test "x$SYS" = "xmingw32"])
 AS_IF([test "x$SYS" = "xandroid"],
       [], [LDFLAGS="${LDFLAGS} -lpthread"])
@@ -191,7 +188,6 @@ AM_COND_IF([PROXY_CLIENT_OR_SERVER], [
 ])
 
 CXXFLAGS="${CXXFLAGS} -DMSGPACK_NO_BOOST -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT"
-OBJCXX="$CXX $CXXFLAGS"
 
 AC_ARG_ENABLE([tools], AS_HELP_STRING([--disable-tools],[Disable tools (CLI DHT node)]),,build_tools=yes)
 AM_CONDITIONAL(ENABLE_TOOLS, test x$build_tools == xyes)
diff --git a/include/opendht/dht_proxy_server.h b/include/opendht/dht_proxy_server.h
index 742a5e7f..63d527c2 100644
--- a/include/opendht/dht_proxy_server.h
+++ b/include/opendht/dht_proxy_server.h
@@ -40,8 +40,7 @@ namespace dht {
 enum class PushType {
     None = 0,
     Android,
-    iOS,
-    iOSLegacy
+    iOS
 };
 }
 MSGPACK_ADD_ENUM(dht::PushType)
diff --git a/src/Makefile.am b/src/Makefile.am
index e7a23ad7..acaccf79 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,12 +30,6 @@ libopendht_la_SOURCES  = \
         network_utils.cpp \
         thread_pool.cpp
 
-if APPLE
-libopendht_la_SOURCES += \
-        compat/apple/apple_utils.h \
-        compat/apple/apple_utils.mm
-endif
-
 if WIN32
 libopendht_la_SOURCES += rng.cpp
 endif
diff --git a/src/compat/apple/apple_utils.h b/src/compat/apple/apple_utils.h
deleted file mode 100644
index e308398a..00000000
--- a/src/compat/apple/apple_utils.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *  Copyright (C) 2014-2022 Savoir-faire Linux Inc.
- *
- *  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 3 of the License, 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.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#include <string>
-
-namespace dht {
-namespace apple_utils {
-
-std::string getPlatformVersion();
-
-}
-}
diff --git a/src/compat/apple/apple_utils.mm b/src/compat/apple/apple_utils.mm
deleted file mode 100644
index 427f4f1c..00000000
--- a/src/compat/apple/apple_utils.mm
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *  Copyright (C) 2014-2022 Savoir-faire Linux Inc.
- *
- *  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 3 of the License, 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.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-#include "apple_utils.h"
-
-#ifdef __APPLE__
-#include <Foundation/Foundation.h>
-#include "TargetConditionals.h"
-#endif
-
-namespace dht {
-namespace apple_utils {
-
-std::string
-getPlatformVersion() {
-#ifdef __APPLE__
-    #if TARGET_OS_IPHONE
-    if (@available(iOS 14.5, *)) {
-        return  "ios";
-    }
-    return "apple";
-    #elif TARGET_OS_MAC
-    return "macos";
-    #endif
-#endif
-    return "";
-}
-
-}
-} /* dht */
diff --git a/src/dht_proxy_client.cpp b/src/dht_proxy_client.cpp
index 6930da8c..6085741c 100644
--- a/src/dht_proxy_client.cpp
+++ b/src/dht_proxy_client.cpp
@@ -22,9 +22,6 @@
 #include "dhtrunner.h"
 #include "op_cache.h"
 #include "utils.h"
-#ifdef __APPLE__
-#include "compat/apple/apple_utils.h"
-#endif
 
 #include <http_parser.h>
 #include <deque>
@@ -1308,7 +1305,7 @@ DhtProxyClient::getPushRequest(Json::Value& body) const
 #endif
 #ifdef __APPLE__
     body["topic"] = notificationTopic_;
-    body["platform"] = apple_utils::getPlatformVersion();
+    body["platform"] = "ios";
 #endif
 }
 
diff --git a/src/dht_proxy_server.cpp b/src/dht_proxy_server.cpp
index f391fa6f..5b1fbb0b 100644
--- a/src/dht_proxy_server.cpp
+++ b/src/dht_proxy_server.cpp
@@ -756,20 +756,12 @@ DhtProxyServer::getTypeFromString(const std::string& type) {
         return PushType::Android;
     else if (type == "ios")
         return PushType::iOS;
-    else if (type == "apple")
-        return PushType::iOSLegacy; // proxy_client is not updated or using ios < 14.5
     return PushType::None;
 }
 
 std::string
 DhtProxyServer::getDefaultTopic(PushType type) {
-    if (bundleId_.empty())
-        return {};
-    if (type == PushType::iOS)
-        return bundleId_;
-    else if (type == PushType::iOSLegacy)
-        return bundleId_  + ".voip";
-    return {};
+    return bundleId_;
 }
 
 RequestStatus
@@ -1045,19 +1037,15 @@ DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& jso
             notification["expiration"] = exp;
             if (!topic.empty())
                 notification["topic"] = topic;
-            if (type == PushType::iOS) {
-                if (highPriority) {
-                    Json::Value alert(Json::objectValue);
-                    alert["title"]="hello";
-                    notification["push_type"] = "alert";
-                    notification["alert"] = alert;
-                    notification["mutable_content"] = true;
-                } else {
-                    notification["push_type"] = "background";
-                    notification["content_available"] = true;
-                }
-            } else if (type == PushType::iOSLegacy) {
-                notification["push_type"] = "voip";
+            if (highPriority) {
+                Json::Value alert(Json::objectValue);
+                alert["title"]="hello";
+                notification["push_type"] = "alert";
+                notification["alert"] = alert;
+                notification["mutable_content"] = true;
+            } else {
+                notification["push_type"] = "background";
+                notification["content_available"] = true;
             }
         }
 
-- 
GitLab