From 60926a6630404639243ef4c8a681f091941c52f5 Mon Sep 17 00:00:00 2001
From: agsantos <aline.gondimsantos@savoirfairelinux.com>
Date: Tue, 14 Jul 2020 09:54:35 -0400
Subject: [PATCH] modify enable_plugin usage

Change-Id: I0d41bd1a8e55371748d36a1b5c3654ec03f6fd5b
---
 src/archiver.cpp                 | 13 +++++++++----
 src/archiver.h                   |  2 --
 src/plugin/jamipluginmanager.cpp |  6 ++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/archiver.cpp b/src/archiver.cpp
index 8856a4eedf..42da971590 100644
--- a/src/archiver.cpp
+++ b/src/archiver.cpp
@@ -348,12 +348,13 @@ static ArchivePtr createArchiveDiskWriter() {
                 archive_write_free(a);
             }};
 }
-
+#endif
 //==========================
 
 std::vector<std::string> listArchiveContent(const std::string &archivePath)
 {
     std::vector<std::string> fileNames;
+#ifdef ENABLE_PLUGIN
     ArchivePtr archiveReader = createArchiveReader();
     struct archive_entry* entry;
     int r;
@@ -371,12 +372,13 @@ std::vector<std::string> listArchiveContent(const std::string &archivePath)
         std::string fileEntry = archive_entry_pathname(entry) ? archive_entry_pathname(entry) : "Undefined";
         fileNames.push_back(fileEntry);
     }
-
+#endif
     return fileNames;
 }
 
 void uncompressArchive(const std::string &archivePath, const std::string &dir, const FileMatchPair& f)
 {
+#ifdef ENABLE_PLUGIN
     int r;
 
     ArchivePtr archiveReader = createArchiveReader();
@@ -452,11 +454,14 @@ void uncompressArchive(const std::string &archivePath, const std::string &dir, c
             }
         }
     }
+#endif
 }
 
 std::vector<uint8_t> readFileFromArchive(const std::string &archivePath,
                                          const std::string &fileRelativePathName)
 {
+    std::vector<uint8_t> fileContent;
+#ifdef ENABLE_PLUGIN
     long r;
     ArchivePtr archiveReader = createArchiveReader();
     struct archive_entry* entry;
@@ -489,7 +494,6 @@ std::vector<uint8_t> readFileFromArchive(const std::string &archivePath,
         if(fileEntry == fileRelativePathName){
             // Copying the data content
             DataBlock db;
-            std::vector<uint8_t> fileContent;
 
             while(true) {
                 r = readDataBlock(archiveReader,db);
@@ -513,7 +517,8 @@ std::vector<uint8_t> readFileFromArchive(const std::string &archivePath,
         }
     }
     throw std::runtime_error("File " + fileRelativePathName + " not found in the archive");
+#endif
+    return fileContent;
 }
-#endif //ENABLE_PLUGIN
 
 }} // namespace jami::archiver
diff --git a/src/archiver.h b/src/archiver.h
index 0ff8ad1b79..6747934b1a 100644
--- a/src/archiver.h
+++ b/src/archiver.h
@@ -88,7 +88,6 @@ std::vector<uint8_t> decompressGzip(const std::string& path);
  */
 gzFile openGzip(const std::string& path, const char *mode);
 
-#ifdef ENABLE_PLUGIN
 /**
  * @brief listArchiveContent
  * @param archivePath
@@ -120,7 +119,6 @@ void uncompressArchive(const std::string& path, const std::string &dir, const Fi
  */
 std::vector<uint8_t> readFileFromArchive(const std::string &path,
                                  const std::string &fileRelativePathName);
-#endif //ENABLE_PLUGIN
 }
 
 } // namespace jami
diff --git a/src/plugin/jamipluginmanager.cpp b/src/plugin/jamipluginmanager.cpp
index 2b879a0158..e2f9eda6ae 100644
--- a/src/plugin/jamipluginmanager.cpp
+++ b/src/plugin/jamipluginmanager.cpp
@@ -265,6 +265,7 @@ int JamiPluginManager::uninstallPlugin(const std::string &rootPath)
 
 bool JamiPluginManager::loadPlugin(const std::string &rootPath)
 {
+#ifdef ENABLE_PLUGIN
     try
     {
         bool status = pm_.load(getPluginDetails(rootPath).at("soPath"));
@@ -279,10 +280,13 @@ bool JamiPluginManager::loadPlugin(const std::string &rootPath)
         JAMI_ERR() << e.what();
         return false;
     }
+#endif
+    return false;
 }
 
 bool JamiPluginManager::unloadPlugin(const std::string &rootPath)
 {
+#ifdef ENABLE_PLUGIN
     try
     {
         bool status = pm_.unload(getPluginDetails(rootPath).at("soPath"));
@@ -297,6 +301,8 @@ bool JamiPluginManager::unloadPlugin(const std::string &rootPath)
         JAMI_ERR() << e.what();
         return false;
     }
+#endif
+    return false;
 }
 
 void JamiPluginManager::togglePlugin(const std::string &rootPath, bool toggle)
-- 
GitLab