~ubuntu-branches/debian/stretch/psi-plus/stretch

« back to all changes in this revision

Viewing changes to src/privacy/privacylistitem.cpp

  • Committer: Package Import Robot
  • Author(s): Boris Pek
  • Date: 2013-10-23 02:42:20 UTC
  • mfrom: (1.4.7)
  • Revision ID: package-import@ubuntu.com-20131023024220-bk2hyoenqkwfhpgw
Tags: 0.16.242-1
* New upstream release:
  fixed the problem of initialization of private conversation when both
  sides use libotr 4.0.x. (Closes: #724880)
* Update debian/watch: sources were moved.
* Delete psi-plus-content-downloader package and update all related files.
  This plugin is in psi-plus-plugins package now.
* Update debian/control:
  - remove all currently unneeded Replaces and Breaks fields
  - add build dependency on libidn11-dev
* Update debian/rules: simplify get-orig-source section.
* Update debian/copyright:
  - update Source field due to changes in sources location
  - remove copyright holders whose code was deleted from source tree
    (bundled libidn library was removed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 *
19
19
 */
20
 
 
 
20
 
21
21
#include <QDomElement>
22
22
#include <QObject>
23
23
 
27
27
 
28
28
 
29
29
PrivacyListItem::PrivacyListItem() : message_(true), presenceIn_(true), presenceOut_(true), iq_(true)
30
 
 
30
{
31
31
}
32
32
 
33
 
PrivacyListItem::PrivacyListItem(const QDomElement& e) 
 
33
PrivacyListItem::PrivacyListItem(const QDomElement& e)
34
34
{
35
35
        fromXml(e);
36
36
}
39
39
{
40
40
        return (type() == JidType && action() == Deny && all());
41
41
}
42
 
        
 
42
 
43
43
QString PrivacyListItem::toString() const
44
44
{
45
45
        QString act;
46
 
        if (action() == PrivacyListItem::Deny) 
 
46
        if (action() == PrivacyListItem::Deny)
47
47
                act = QObject::tr("Deny");
48
 
        else 
 
48
        else
49
49
                act = QObject::tr("Allow");
50
 
        
 
50
 
51
51
        QString what;
52
 
        if (all()) 
 
52
        if (all())
53
53
                what = QObject::tr("All");
54
54
        else {
55
 
                if (message()) 
 
55
                if (message())
56
56
                        what += QObject::tr("Messages,");
57
 
                if (presenceIn()) 
 
57
                if (presenceIn())
58
58
                        what += QObject::tr("Presence-In,");
59
 
                if (presenceOut()) 
 
59
                if (presenceOut())
60
60
                        what += QObject::tr("Presence-Out,");
61
 
                if (iq()) 
 
61
                if (iq())
62
62
                        what += QObject::tr("Queries,");
63
63
                what.truncate(what.length()-1);
64
64
        }
65
 
        
 
65
 
66
66
        QString txt;
67
67
        if (type() == PrivacyListItem::FallthroughType) {
68
68
                txt = QString(QObject::tr("Else %1 %2")).arg(act).arg(what);
85
85
QDomElement PrivacyListItem::toXml(QDomDocument& doc) const
86
86
{
87
87
        QDomElement item = doc.createElement("item");
88
 
        
89
 
        if (type_ == JidType) 
 
88
 
 
89
        if (type_ == JidType)
90
90
                item.setAttribute("type","jid");
91
91
        else if (type_ == GroupType)
92
92
                item.setAttribute("type","group");
93
93
        else if (type_ == SubscriptionType)
94
94
                item.setAttribute("type","subscription");
95
 
        
 
95
 
96
96
        if (type_ != FallthroughType)
97
97
                item.setAttribute("value",value_);
98
 
        
99
 
        if (action_ == Allow) 
 
98
 
 
99
        if (action_ == Allow)
100
100
                item.setAttribute("action","allow");
101
101
        else
102
102
                item.setAttribute("action","deny");
103
103
 
104
104
        item.setAttribute("order", order_);
105
 
        
 
105
 
106
106
        if (!(message_ && presenceIn_ && presenceOut_ && iq_)) {
107
107
                if (message_)
108
108
                        item.appendChild(doc.createElement("message"));
125
125
                return;
126
126
        }
127
127
 
128
 
        QString type = el.attribute("type"); 
 
128
        QString type = el.attribute("type");
129
129
        if (type == "jid")
130
130
                type_ = JidType;
131
131
        else if (type == "group")
134
134
                type_ = SubscriptionType;
135
135
        else
136
136
                type_ = FallthroughType;
137
 
        
 
137
 
138
138
        QString value = el.attribute("value");
139
139
        value_ = value;
140
 
        if (type_ == JidType && XMPP::Jid(value_).isEmpty()) 
 
140
        if (type_ == JidType && XMPP::Jid(value_).isEmpty())
141
141
                qWarning("privacy.cpp: Invalid value for item of type 'jid'.");
142
 
        else if (type_ == GroupType && value_.isEmpty()) 
 
142
        else if (type_ == GroupType && value_.isEmpty())
143
143
                qWarning("privacy.cpp: Empty value for item of type 'group'.");
144
144
        else if (type_ == SubscriptionType && value_ != "from" && value != "to" && value_ != "both" && value_ != "none")
145
145
                qWarning("privacy.cpp: Invalid value for item of type 'subscription'.");
146
 
        else if (type_ == FallthroughType && !value_.isEmpty()) 
 
146
        else if (type_ == FallthroughType && !value_.isEmpty())
147
147
                qWarning("privacy.cpp: Value given for item of fallthrough type.");
148
 
                
 
148
 
149
149
        QString action = el.attribute("action");
150
 
        if (action == "allow") 
 
150
        if (action == "allow")
151
151
                action_ = Allow;
152
152
        else if (action == "deny")
153
153
                action_ = Deny;
160
160
                qWarning("privacy.cpp: Invalid order value for item.");
161
161
 
162
162
        if (el.hasChildNodes()) {
163
 
                findSubTag(el, "message", &message_);
164
 
                findSubTag(el, "presence-in", &presenceIn_);
165
 
                findSubTag(el, "presence-out", &presenceOut_);
166
 
                findSubTag(el, "iq", &iq_);
 
163
                message_ = !el.firstChildElement("message").isNull();
 
164
                presenceIn_ = !el.firstChildElement("presence-in").isNull();
 
165
                presenceOut_ = !el.firstChildElement("presence-out").isNull();
 
166
                iq_ = !el.firstChildElement("iq").isNull();
167
167
        }
168
168
        else {
169
169
                message_ = presenceIn_ = presenceOut_ = iq_ = true;