File indexing completed on 2024-04-21 04:04:44
0001 /* 0002 * privacylistitem.h 0003 * Copyright (C) 2006 Remko Troncon 0004 * 0005 * This program is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU General Public License 0007 * as published by the Free Software Foundation; either version 2 0008 * of the License, or (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this library; if not, write to the Free Software 0017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0018 * 02110-1301, USA 0019 * 0020 */ 0021 0022 #ifndef PRIVACYLISTITEM_H 0023 #define PRIVACYLISTITEM_H 0024 0025 #include <QString> 0026 0027 class QDomElement; 0028 class QDomDocument; 0029 0030 class PrivacyListItem 0031 { 0032 public: 0033 typedef enum { FallthroughType, JidType, GroupType, SubscriptionType } Type; 0034 typedef enum { Allow, Deny } Action; 0035 0036 PrivacyListItem(); 0037 PrivacyListItem(const QDomElement& e); 0038 0039 Type type() const { return type_; } 0040 Action action() const { return action_; } 0041 bool message() const { return message_; } 0042 bool presenceIn() const { return presenceIn_; } 0043 bool presenceOut() const { return presenceOut_; } 0044 bool iq() const { return iq_; } 0045 bool all() const { return iq_ && presenceIn_ && presenceOut_ && message_; } 0046 const QString& value() const { return value_; } 0047 unsigned int order() const { return order_; } 0048 0049 void setType(Type type) { type_ = type; } 0050 void setAction(Action action) { action_ = action; } 0051 void setMessage(bool b) { message_ = b; } 0052 void setPresenceIn(bool b) { presenceIn_ = b; } 0053 void setPresenceOut(bool b) { presenceOut_ = b; } 0054 void setIQ(bool b) { iq_ = b; } 0055 void setAll() { iq_ = presenceIn_ = presenceOut_ = message_ = true; } 0056 void setValue(const QString& value) { value_ = value; } 0057 void setOrder(unsigned int order) { order_ = order; } 0058 0059 bool isBlock() const; 0060 QString toString() const; 0061 QDomElement toXml(QDomDocument&) const; 0062 void fromXml(const QDomElement& e); 0063 0064 bool operator<(const PrivacyListItem& it) const { return order() < it.order(); } 0065 0066 static PrivacyListItem blockItem(const QString& jid); 0067 0068 private: 0069 Type type_; 0070 Action action_; 0071 bool message_, presenceIn_, presenceOut_, iq_; 0072 unsigned int order_; 0073 QString value_; 0074 }; 0075 0076 #endif