/*
 * This file is part of Bisq.
 *
 * Bisq is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or (at
 * your option) any later version.
 *
 * Bisq 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 Affero General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Bisq. If not, see <http://www.gnu.org/licenses/>.
 */

package bisq.core.setup;

import bisq.core.app.BisqEnvironment;
import bisq.core.dao.DaoOptionKeys;

import bisq.common.app.Capabilities;
import bisq.common.app.Capability;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CoreNetworkCapabilities {
    public static void setSupportedCapabilities(BisqEnvironment bisqEnvironment) {
        Capabilities.app.addAll(Capability.TRADE_STATISTICS, Capability.TRADE_STATISTICS_2, Capability.ACCOUNT_AGE_WITNESS, Capability.ACK_MSG);
        Capabilities.app.addAll(Capability.BUNDLE_OF_ENVELOPES,Capability.SIGNED_ACCOUNT_AGE_WITNESS);

        if (BisqEnvironment.isDaoActivated(bisqEnvironment)) {
            Capabilities.app.addAll(Capability.PROPOSAL, Capability.BLIND_VOTE, Capability.BSQ_BLOCK, Capability.DAO_STATE);

            maybeApplyDaoFullMode(bisqEnvironment);
        }
    }

    public static void maybeApplyDaoFullMode(BisqEnvironment bisqEnvironment) {
        // If we set dao full mode at the preferences view we add the capability there. We read the preferences a
        // bit later than we call that method so we have to add DAO_FULL_NODE Capability at preferences as well to
        // be sure it is set in both cases.
        String isFullDaoNode = bisqEnvironment.getProperty(DaoOptionKeys.FULL_DAO_NODE, String.class, "false");
        if (isFullDaoNode != null && !isFullDaoNode.isEmpty() && isFullDaoNode.toLowerCase().equals("true")) {
            log.info("Set Capability.DAO_FULL_NODE");
            Capabilities.app.addAll(Capability.DAO_FULL_NODE);
        }
    }
}

@@ -1037,32 +1037,49 @@
 ties.app.addAll(
+%0A                
 Capability.TRADE
@@ -1090,16 +1090,32 @@
 TISTICS,
+%0A               
  Capabil
@@ -1137,16 +1137,32 @@
 STICS_2,
+%0A               
  Capabil
@@ -1185,16 +1185,32 @@
 WITNESS,
+%0A               
  Capabil
@@ -1220,18 +1220,17 @@
 .ACK_MSG
-);
+,
 %0A       
@@ -1234,32 +1234,16 @@
     
-Capabilities.app.addAll(
+        
 Capa
@@ -1272,46 +1272,17 @@
 OPES
-,Capability.SIGNED_ACCOUNT_AGE_WITNESS
+%0A        
 );%0A%0A
@@ -1384,28 +1384,69 @@
 All(
-Capability.PROPOSAL,
+%0A                    Capability.PROPOSAL,%0A                   
  Cap
@@ -1464,16 +1464,36 @@
 ND_VOTE,
+%0A                   
  Capabil
@@ -1506,16 +1506,36 @@
 Q_BLOCK,
+%0A                   
  Capabil
@@ -1547,16 +1547,29 @@
 AO_STATE
+%0A            
 );%0A%0A    

Remove Capability.SIGNED_ACCOUNT_AGE_WITNESS