00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file exitpolicy.h 00024 * \version $Id: exitpolicy.h 1238 2006-09-25 17:50:57Z edmanm $ 00025 * \brief Collection of Policy objects representing an exit policy 00026 */ 00027 00028 #ifndef _EXITPOLICY_H 00029 #define _EXITPOLICY_H 00030 00031 #include <QString> 00032 #include <QList> 00033 00034 #include "policy.h" 00035 00036 00037 class ExitPolicy 00038 { 00039 public: 00040 /** Special exit policy types. */ 00041 enum SpecialExitPolicy { 00042 Default, /**< Specifies the default exit policy. */ 00043 Middleman /**< Specifies a middleman-only exit policy. */ 00044 }; 00045 00046 /** Default constructor. */ 00047 ExitPolicy(); 00048 /** Creates an exit policy of the given special type. */ 00049 ExitPolicy(SpecialExitPolicy exitPolicy); 00050 /** Creates an exit policy from the given comma-delimited list of policies. */ 00051 ExitPolicy(QString exitPolicy); 00052 00053 /** Adds a rule to the exit policy. */ 00054 void addPolicy(Policy policy); 00055 /** Removes a rule from the exit policy. */ 00056 void removePolicy(Policy policy); 00057 /** Checks if the current exit policy contains the given rule. */ 00058 bool contains(Policy policy); 00059 00060 /** Returns the list of policies for this exit policy. */ 00061 QList<Policy> policyList() { return _exitPolicy; } 00062 00063 /** Converts the exit policy to a format Tor understands. */ 00064 QString toString(); 00065 00066 private: 00067 /** A collection of policies forming the exit policy. */ 00068 QList<Policy> _exitPolicy; 00069 }; 00070 00071 #endif 00072