Line data Source code
1 : // Copyright (C) 2012 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.mail; 16 : 17 : import com.google.gerrit.server.config.GerritServerConfig; 18 : import com.google.gerrit.server.mail.receive.Protocol; 19 : import com.google.inject.Inject; 20 : import com.google.inject.Singleton; 21 : import java.util.concurrent.TimeUnit; 22 : import org.eclipse.jgit.lib.Config; 23 : 24 : @Singleton 25 : public class EmailSettings { 26 : private static final String SEND_EMAL = "sendemail"; 27 : private static final String RECEIVE_EMAL = "receiveemail"; 28 : // Send 29 : public final boolean html; 30 : public final boolean includeDiff; 31 : public final int maximumDiffSize; 32 : // Receive 33 : public final Protocol protocol; 34 : public final String host; 35 : public final int port; 36 : public final String username; 37 : public final String password; 38 : public final Encryption encryption; 39 : public final long fetchInterval; // in milliseconds 40 : public final boolean sendNewPatchsetEmails; 41 : public final boolean isAttentionSetEnabled; 42 : 43 : @Inject 44 146 : EmailSettings(@GerritServerConfig Config cfg) { 45 : // Send 46 146 : html = cfg.getBoolean(SEND_EMAL, "html", true); 47 146 : includeDiff = cfg.getBoolean(SEND_EMAL, "includeDiff", false); 48 146 : maximumDiffSize = cfg.getInt(SEND_EMAL, "maximumDiffSize", 256 << 10); 49 : // Receive 50 146 : protocol = cfg.getEnum(RECEIVE_EMAL, null, "protocol", Protocol.NONE); 51 146 : host = cfg.getString(RECEIVE_EMAL, null, "host"); 52 146 : port = cfg.getInt(RECEIVE_EMAL, "port", 0); 53 146 : username = cfg.getString(RECEIVE_EMAL, null, "username"); 54 146 : password = cfg.getString(RECEIVE_EMAL, null, "password"); 55 146 : encryption = cfg.getEnum(RECEIVE_EMAL, null, "encryption", Encryption.NONE); 56 146 : fetchInterval = 57 146 : cfg.getTimeUnit( 58 : RECEIVE_EMAL, 59 : null, 60 : "fetchInterval", 61 146 : TimeUnit.MILLISECONDS.convert(60, TimeUnit.SECONDS), 62 : TimeUnit.MILLISECONDS); 63 146 : sendNewPatchsetEmails = cfg.getBoolean("change", null, "sendNewPatchsetEmails", true); 64 146 : isAttentionSetEnabled = cfg.getBoolean("change", null, "enableAttentionSet", true); 65 146 : } 66 : }