From 691f54619a63959edac79d571ca51bc648c03b5d Mon Sep 17 00:00:00 2001
From: Olivier SOLDANO <olivier.soldano@savoirfairelinux.com>
Date: Mon, 7 Aug 2017 15:28:26 -0400
Subject: [PATCH] mingw compatibility patch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

when sanitizing the namespaces of client-windows, encontered few
incompatibilities due to windows.h inclusion. This header file defines a
lot of common macros such as ERROR... This patch wraps all conflics with
push/pop macro pragmas.

Change-Id: I7f95fac84ace5388e7134db372bd36720210f886
Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com>
---
 src/call.h                          | 9 +++++++++
 src/call.hpp                        | 4 +++-
 src/interfaces/pixmapmanipulatori.h | 2 +-
 src/media/media.h                   | 7 ++++++-
 src/securityevaluationmodel.h       | 5 +++--
 5 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/call.h b/src/call.h
index 4144fc4d..20afc360 100644
--- a/src/call.h
+++ b/src/call.h
@@ -152,6 +152,8 @@ public:
 
    ///Possible call states
    enum class State : unsigned int{
+   #pragma push_macro("ERROR")
+   #undef ERROR
       NEW             = 0, /*!< The call has been created, but no dialing number been set                         */
       INCOMING        = 1, /*!< Ringing incoming call                                                             */
       RINGING         = 2, /*!< Ringing outgoing call                                                             */
@@ -170,6 +172,7 @@ public:
       ABORTED         = 15,/*!< The call was dropped before being sent to the daemon                              */
       CONNECTED       = 16,/*!< The peer has been found, attempting negotiation                                   */
       COUNT__,
+   #pragma pop_macro("ERROR")
    };
    Q_ENUMS(State)
 
@@ -223,10 +226,16 @@ public:
     * only used for outgoing holding.
     */
    enum class HoldFlags {
+   #pragma push_macro("OUT")
+   #pragma push_macro("IN")
+   #undef OUT
+   #undef IN
       NONE = 0x0 << 0, /*!< The call is not on hold        */
       OUT  = 0x1 << 0, /*!< This side put the peer on hold */
       IN   = 0x1 << 1, /*!< The peer put this side on hold */
       COUNT__
+   #pragma pop_macro("OUT")
+   #pragma pop_macro("IN")
    };
    Q_FLAGS(HoldFlags)
 
diff --git a/src/call.hpp b/src/call.hpp
index 138901bf..3d31c194 100644
--- a/src/call.hpp
+++ b/src/call.hpp
@@ -61,14 +61,16 @@ T* Call::firstMedia(Media::Media::Direction direction) const
 template<typename T>
 T* Call::addOutgoingMedia(bool useExisting)
 {
+   #pragma push_macro("OUT")
+   #undef OUT
    T* existing = firstMedia<T>(Media::Media::Direction::OUT);
-
    if (useExisting && existing)
       return existing;
 
    Media::Media::Type t = MediaTypeInference::getType<T>();
 
    return static_cast<T*>(MediaTypeInference::safeMediaCreator(this,t,Media::Media::Direction::OUT));
+   #pragma pop_macro("OUT")
 }
 
 #define REGISTER_MEDIA() __attribute__ ((unused)) static auto forceType = [] {\
diff --git a/src/interfaces/pixmapmanipulatori.h b/src/interfaces/pixmapmanipulatori.h
index a2d0baee..01b4d1ef 100644
--- a/src/interfaces/pixmapmanipulatori.h
+++ b/src/interfaces/pixmapmanipulatori.h
@@ -72,7 +72,7 @@ public:
     virtual QVariant   securityIssueIcon(const QModelIndex& index) = 0;
     virtual QByteArray toByteArray(const QVariant& pxm) = 0;
     virtual QVariant   personPhoto(const QByteArray& data, const QString& type = "PNG") = 0;
-    virtual QVariant   collectionIcon(const CollectionInterface* interface, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const = 0;
+    virtual QVariant   collectionIcon(const CollectionInterface* colItf, PixmapManipulatorI::CollectionIconHint hint = PixmapManipulatorI::CollectionIconHint::NONE) const = 0;
     virtual QVariant   securityLevelIcon(const SecurityEvaluationModel::SecurityLevel level) const = 0;
     virtual QVariant   historySortingCategoryIcon(const CategorizedHistoryModel::SortedProxy::Categories cat) const = 0;
     virtual QVariant   contactSortingCategoryIcon(const CategorizedContactModel::SortedProxy::Categories cat) const = 0;
diff --git a/src/media/media.h b/src/media/media.h
index 7bde8dfd..0d125240 100644
--- a/src/media/media.h
+++ b/src/media/media.h
@@ -52,9 +52,15 @@ public:
    };
 
    enum class Direction {
+   #pragma push_macro("OUT")
+   #pragma push_macro("IN")
+   #undef OUT
+   #undef IN
       IN , /*!< The media is coming from the peer */
       OUT, /*!< The media is going to the peer    */
       COUNT__
+   #pragma pop_macro("OUT")
+   #pragma pop_macro("IN")
    };
 
    enum class Action {
@@ -98,4 +104,3 @@ private:
 Q_DECLARE_METATYPE(Media::Media::Direction)
 
 Media::Media* operator<<(Media::Media* m, Media::Media::Action a);
-
diff --git a/src/securityevaluationmodel.h b/src/securityevaluationmodel.h
index fcddce33..10e0e603 100644
--- a/src/securityevaluationmodel.h
+++ b/src/securityevaluationmodel.h
@@ -87,6 +87,8 @@ public:
 
    ///The severity of a given flaw
    enum class Severity {
+   #pragma push_macro("ERROR")
+   #undef ERROR
       UNSUPPORTED   = 0, /*!< This severity is unsupported, to be ignored                  */
       INFORMATION   = 1, /*!< Tip and tricks to have better security                       */
       WARNING       = 2, /*!< It is a problem, but it won't have other side effects         */
@@ -94,9 +96,9 @@ public:
       ERROR         = 4, /*!< It simply won't work (REGISTER)                               */
       FATAL_WARNING = 5, /*!< Registration may work, but it render everything else useless */
       COUNT__,
+   #pragma pop_macro("ERROR")
    };
    Q_ENUMS(Severity)
-
    ///Every supported flaws
    enum class AccountSecurityChecks {
       SRTP_ENABLED                , /*!< The account use secure media streams                    */
@@ -160,4 +162,3 @@ private:
 Q_DECLARE_METATYPE(SecurityEvaluationModel*)
 Q_DECLARE_METATYPE(SecurityEvaluationModel::Severity)
 Q_DECLARE_METATYPE(SecurityEvaluationModel::SecurityLevel)
-
-- 
GitLab