From be939a4d30fecb5eaa5a035e45da6e41e18d50b4 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 27 May 2017 04:59:44 +1000
Subject: Fix build for haiku


diff --git a/dooble.qt5.pro b/dooble.qt5.pro
index fc800d3..fd01093 100644
--- a/dooble.qt5.pro
+++ b/dooble.qt5.pro
@@ -28,12 +28,12 @@ DEFINES         += DOOBLE_LINKED_WITH_LIBSPOTON \
 
 QMAKE_CLEAN     += Dooble libSpotOn/*.o libSpotOn/*.so libSpotOn/test
 QMAKE_CXXFLAGS_RELEASE -= -O2
-QMAKE_CXXFLAGS_RELEASE += -fPIE -fstack-protector-all -fwrapv \
+QMAKE_CXXFLAGS_RELEASE += -fPIE -fwrapv \
 			  -mtune=generic -pie -Os \
 			  -Wall -Wcast-align -Wcast-qual \
 			  -Werror -Wextra \
 			  -Woverloaded-virtual -Wpointer-arith \
-			  -Wstack-protector -Wstrict-overflow=5
+			  -Wstrict-overflow=5
 QMAKE_DISTCLEAN += -r temp .qmake.cache .qmake.stash
 QMAKE_EXTRA_TARGETS = libspoton purge
 QMAKE_LFLAGS_RELEASE += -Wl,-rpath,/usr/local/dooble/Lib
diff --git a/libSpotOn/Makefile b/libSpotOn/Makefile
index c818b90..168d18e 100644
--- a/libSpotOn/Makefile
+++ b/libSpotOn/Makefile
@@ -4,6 +4,8 @@ ifeq ($(UNAME), Darwin)
 	MAKEFILE=Makefile.osx
 else ifeq ($(UNAME), FreeBSD)
 	MAKEFILE=Makefile.freebsd
+else ifeq ($(UNAME), Haiku)
+	MAKEFILE=Makefile.haiku
 else ifeq ($(UNAME), Linux)
 	MAKEFILE=Makefile.linux
 else ifeq ($(UNAME), OS/2)
diff --git a/libSpotOn/Makefile.haiku b/libSpotOn/Makefile.haiku
new file mode 100644
index 0000000..873983a
--- /dev/null
+++ b/libSpotOn/Makefile.haiku
@@ -0,0 +1,32 @@
+all:	libspoton.o
+	$(CC) $(LDFLAGS) -shared -Wl,-soname,libspoton.so \
+	-o libspoton.so $? -lgcrypt -lsqlite3 -lroot
+	$(CC) $(CFLAGS) -Wall -Werror -Wextra \
+	test.c -o test -L. -lspoton -Wl,-rpath,.
+
+libspoton.o:	libspoton.c libspoton.h
+	$(CC) $(CFLAGS) -ansi -fPIC \
+	-pedantic -Waggregate-return \
+	-Wall -Wconversion -Werror -Wextra -Wformat=2 -Wpointer-arith \
+	-Wshadow -Wsign-conversion \
+	-Wstack-protector -Wstrict-overflow=5 -Wstrict-prototypes \
+	-c -o libspoton.o libspoton.c
+
+clean:
+	rm -f libspoton.o libspoton.so
+	rm -f shared.db
+	rm -f test
+
+install: all
+	install -o root -g root -d /usr/local/lib
+	install -o root -g root libspoton.so /usr/local/lib
+
+library: libspoton.o
+	$(CC) $(LDFLAGS) -shared -Wl,-soname,libspoton.so \
+	-o libspoton.so $? -lgcrypt -lpthread -lsqlite3
+
+purge:
+	rm -f *~*
+
+uninstall:
+	rm -f /usr/local/lib/libspoton.so
diff --git a/libSpotOn/libspoton.c b/libSpotOn/libspoton.c
index 0be7be8..a005adf 100644
--- a/libSpotOn/libspoton.c
+++ b/libSpotOn/libspoton.c
@@ -77,6 +77,17 @@ static pthread_mutex_t sqlite_mutex = PTHREAD_MUTEX_INITIALIZER;
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
 #endif
 
+extern void __stack_chk_fail (void);
+
+#ifdef __HAIKU
+void
+__attribute__((visibility ("hidden")))
+__stack_chk_fail_local (void)
+{
+	__stack_chk_fail();
+}
+#endif
+
 static libspoton_error_t initialize_libgcrypt
 (const int secure_memory_pool_size)
 {
-- 
2.26.0


From 1f9b9f31e8267e11411f0d68bf823d7ac7204c63 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sat, 10 Jun 2017 21:00:42 +1000
Subject: Change current directory to application path


diff --git a/Source/dooble.cc b/Source/dooble.cc
index f2ff75f..7b13e94 100644
--- a/Source/dooble.cc
+++ b/Source/dooble.cc
@@ -309,6 +309,11 @@ int main(int argc, char *argv[])
 #endif
 
   QApplication qapp(argc, argv);
+
+#if defined(Q_OS_HAIKU)
+  QString appdir = QCoreApplication::applicationDirPath();
+  QDir::setCurrent(appdir);
+#endif
   QSplashScreen splash(QPixmap(":/AxB/splash.png"));
 
   splash.show();
-- 
2.26.0


From e867d951bd761029b5570576c2eb4e9d82573855 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Thu, 3 Aug 2017 11:06:11 +1000
Subject: Fix path for settings dir


diff --git a/Source/dooble.cc b/Source/dooble.cc
index 7b13e94..44e5f35 100644
--- a/Source/dooble.cc
+++ b/Source/dooble.cc
@@ -433,6 +433,13 @@ int main(int argc, char *argv[])
   else
     dooble::s_homePath = homeDir.absolutePath() + QDir::separator() +
       username + QDir::separator() + ".dooble";
+#elif defined(Q_OS_HAIKU)
+  QDir homeDir(QDir::home().absolutePath() + QDir::separator() +
+	"config" + QDir::separator() + "settings");
+
+  homeDir.mkdir("Dooble");
+  dooble::s_homePath = homeDir.absolutePath() +
+    QDir::separator() + "Dooble";
 #else
   QDir homeDir(QDir::home());
 
-- 
2.26.0


From 5b20823962dc941a89c39645e974029ae7e1f47e Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 27 May 2018 19:14:13 +1000
Subject: Default fonts for Haiku (Noto)


diff --git a/Source/dooble.cc b/Source/dooble.cc
index 44e5f35..8a9e82c 100644
--- a/Source/dooble.cc
+++ b/Source/dooble.cc
@@ -761,6 +761,8 @@ int main(int argc, char *argv[])
     font = QFont("Times", 16);
 #elif defined(Q_OS_WIN32)
     font = QFont("Serif", 10);
+#elif defined(Q_OS_HAIKU)
+    font = QFont("Noto Serif", 14);
 #else
     font = QFont("Serif", 16);
 #endif
@@ -781,8 +783,11 @@ int main(int argc, char *argv[])
   if(!font.fromString(dooble::s_settings.value
 		      ("settingsWindow/cursiveWebFont", "").
 		      toString()) || font.family().isEmpty())
+#if defined(Q_OS_HAIKU)
+    font = QFont("Noto Serif");
+#else
     font = QFont("Serif");
-
+#endif
   font.setWeight(QFont::Normal);
   QWebSettings::globalSettings()->setFontFamily
     (QWebSettings::CursiveFont,
@@ -791,8 +796,11 @@ int main(int argc, char *argv[])
   if(!font.fromString(dooble::s_settings.value
 		      ("settingsWindow/fantasyWebFont", "").
 		      toString()) || font.family().isEmpty())
+#if defined(Q_OS_HAIKU)
+    font = QFont("Noto Serif");
+#else
     font = QFont("Serif");
-
+#endif
   font.setWeight(QFont::Normal);
   QWebSettings::globalSettings()->setFontFamily
     (QWebSettings::FantasyFont,
@@ -805,6 +813,8 @@ int main(int argc, char *argv[])
     font = QFont("Courier", 13);
 #elif defined(Q_OS_WIN32)
     font = QFont("Courier New", 10);
+#elif defined(Q_OS_HAIKU)
+    font = QFont("Noto Mono", 12);
 #else
     font = QFont("Courier", 10);
 #endif
@@ -814,6 +824,8 @@ int main(int argc, char *argv[])
     font.setPointSize(13);
 #elif defined(Q_OS_WIN32)
     font.setPointSize(10);
+#elif defined(Q_OS_HAIKU)
+    font.setPointSize(12);
 #else
     font.setPointSize(10);
 #endif
@@ -833,6 +845,8 @@ int main(int argc, char *argv[])
     font = QFont("Helvetica");
 #elif defined(Q_OS_WIN32)
     font = QFont("Arial");
+#elif defined(Q_OS_HAIKU)
+    font = QFont("Noto Sans");
 #else
     font = QFont("Sans Serif");
 #endif
@@ -849,6 +863,8 @@ int main(int argc, char *argv[])
     font = QFont("Times");
 #elif defined(Q_OS_WIN32)
     font = QFont("Times New Roman");
+#elif defined(Q_OS_HAIKU)
+    font = QFont("Noto Serif");
 #else
     font = QFont("Serif");
 #endif
diff --git a/Source/dsettings.cc b/Source/dsettings.cc
index a18c5de..f3f6a7e 100644
--- a/Source/dsettings.cc
+++ b/Source/dsettings.cc
@@ -945,6 +945,9 @@ void dsettings::exec(dooble *parent)
 #elif defined(Q_OS_WIN32)
       text = "Serif";
       fontSize = "10";
+#elif defined(Q_OS_HAIKU)
+      text = "Noto Serif";
+      fontSize = "12";
 #else
       text = "Serif";
       fontSize = "16";
@@ -979,10 +982,18 @@ void dsettings::exec(dooble *parent)
   else
     {
       if(ui.cursiveFontCombinationBox->
+#ifdef Q_OS_HAIKU
+	 findText("Noto Serif") > -1)
+#else
 	 findText("Serif") > -1)
+#endif
 	ui.cursiveFontCombinationBox->setCurrentIndex
 	  (ui.cursiveFontCombinationBox->
+#ifdef Q_OS_HAIKU
+	   findText("Noto Serif"));
+#else
 	   findText("Serif"));
+#endif
       else
 	ui.cursiveFontCombinationBox->setCurrentIndex(0);
     }
@@ -1000,10 +1011,18 @@ void dsettings::exec(dooble *parent)
   else
     {
       if(ui.fantasyFontCombinationBox->
+#ifdef Q_OS_HAIKU
+	 findText("Noto Serif") > -1)
+#else
 	 findText("Serif") > -1)
+#endif
 	ui.fantasyFontCombinationBox->setCurrentIndex
 	  (ui.fantasyFontCombinationBox->
+#ifdef Q_OS_HAIKU
+	   findText("Noto Serif"));
+#else
 	   findText("Serif"));
+#endif
       else
 	ui.fantasyFontCombinationBox->setCurrentIndex(0);
     }
@@ -1040,6 +1059,9 @@ void dsettings::exec(dooble *parent)
 #elif defined(Q_OS_WIN32)
       text = "Courier New";
       fontSize = "10";
+#elif defined(Q_OS_HAIKU)
+      text = "Noto Mono";
+      fontSize = "12";
 #else
       text = "Courier";
       fontSize = "10";
@@ -1079,6 +1101,8 @@ void dsettings::exec(dooble *parent)
       text = "Helvetica";
 #elif defined(Q_OS_WIN32)
       text = "Arial";
+#elif defined(Q_OS_HAIKU)
+      text = "Noto Sans";
 #else
       text = "Sans Serif";
 #endif
@@ -1110,6 +1134,8 @@ void dsettings::exec(dooble *parent)
       text = "Times";
 #elif defined(Q_OS_WIN32)
       text = "Times New Roman";
+#elif defined(Q_OS_HAIKU)
+      text = "Noto Serif";
 #else
       text = "Serif";
 #endif
-- 
2.26.0


From 3e7adce69b40031b0f69c236fac986665804401d Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Sun, 27 May 2018 19:37:48 +1000
Subject: Set Haiku theme by default


diff --git a/Source/dooble.cc b/Source/dooble.cc
index 8a9e82c..09d5b25 100644
--- a/Source/dooble.cc
+++ b/Source/dooble.cc
@@ -615,12 +615,20 @@ int main(int argc, char *argv[])
   if(!settings.contains("iconSet"))
     settings.setValue("iconSet",
 		      QString("%1/%2").arg(QDir::currentPath()).
+#ifdef Q_OS_HAIKU
+		      arg("Icons/haiku/configuration.cfg"));
+#else
 		      arg("Icons/nuovext/configuration.cfg"));
+#endif
 
   if(!QFileInfo(settings.value("iconSet").toString()).exists())
     settings.setValue("iconSet",
 		      QString("%1/%2").arg(QDir::currentPath()).
+#ifdef Q_OS_HAIKU
+		      arg("Icons/haiku/configuration.cfg"));
+#else
 		      arg("Icons/nuovext/configuration.cfg"));
+#endif
 
   if(!settings.contains("settingsWindow/iconSet1"))
     settings.setValue("settingsWindow/iconSet1", settings.value("iconSet"));
@@ -628,7 +636,11 @@ int main(int argc, char *argv[])
   if(!QFileInfo(settings.value("settingsWindow/iconSet1").toString()).exists())
     settings.setValue("settingsWindow/iconSet1",
 		      QString("%1/%2").arg(QDir::currentPath()).
+#ifdef Q_OS_HAIKU
+		      arg("Icons/haiku/configuration.cfg"));
+#else
 		      arg("Icons/nuovext/configuration.cfg"));
+#endif
 
   if(!settings.value("v156a_automatic_changes_performed", false).toBool())
     {
diff --git a/Source/dsettings.cc b/Source/dsettings.cc
index f3f6a7e..11d3a45 100644
--- a/Source/dsettings.cc
+++ b/Source/dsettings.cc
@@ -120,12 +120,21 @@ dsettings::dsettings():QMainWindow()
 
   if(dooble::s_settings.value("iconSet", "").toString().trimmed().isEmpty())
     {
+#ifdef Q_OS_HAIKU
+      settings.setValue("iconSet",
+			QString("%1/%2").arg(QDir::currentPath()).
+			arg("Icons/haiku/configuration.cfg"));
+      dooble::s_settings["iconSet"] =
+	QString("%1/%2").arg(QDir::currentPath()).
+	arg("Icons/haiku/configuration.cfg");
+#else
       settings.setValue("iconSet",
 			QString("%1/%2").arg(QDir::currentPath()).
 			arg("Icons/nuovext/configuration.cfg"));
       dooble::s_settings["iconSet"] =
 	QString("%1/%2").arg(QDir::currentPath()).
 	arg("Icons/nuovext/configuration.cfg");
+#endif
     }
 
   if(dooble::s_settings.value("settingsWindow/iconSet1", "").toString().
-- 
2.26.0


From 6d21fcba51db50f9e4ec3519969eac56a7ce32db Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 10 Jun 2020 16:48:59 +1000
Subject: Fix build for Qt 5.15


diff --git a/Include/dtypes.h b/Include/dtypes.h
index 88227fc..bb1e081 100644
--- a/Include/dtypes.h
+++ b/Include/dtypes.h
@@ -36,7 +36,7 @@ namespace DoobleDownloadType
       Http
     };
 
-  Q_ENUMS(DoobleDownloadTypeEnum)
+//  Q_ENUMS(DoobleDownloadTypeEnum)
 }
 
 #endif
diff --git a/dooble.qt5.pro b/dooble.qt5.pro
index fd01093..375b4d9 100644
--- a/dooble.qt5.pro
+++ b/dooble.qt5.pro
@@ -33,7 +33,8 @@ QMAKE_CXXFLAGS_RELEASE += -fPIE -fwrapv \
 			  -Wall -Wcast-align -Wcast-qual \
 			  -Werror -Wextra \
 			  -Woverloaded-virtual -Wpointer-arith \
-			  -Wstrict-overflow=5
+			  -Wstrict-overflow=5 \
+			  -Wno-deprecated-declarations
 QMAKE_DISTCLEAN += -r temp .qmake.cache .qmake.stash
 QMAKE_EXTRA_TARGETS = libspoton purge
 QMAKE_LFLAGS_RELEASE += -Wl,-rpath,/usr/local/dooble/Lib
-- 
2.26.0

