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

« back to all changes in this revision

Viewing changes to src/ahcservermanager.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:
37
37
 
38
38
#define AHC_NS "http://jabber.org/protocol/commands"
39
39
 
40
 
// -------------------------------------------------------------------------- 
 
40
// --------------------------------------------------------------------------
41
41
// JT_AHCServer: Task to handle ad-hoc command requests
42
 
// -------------------------------------------------------------------------- 
 
42
// --------------------------------------------------------------------------
43
43
 
44
44
class JT_AHCServer : public Task
45
45
{
76
76
bool JT_AHCServer::commandListQuery(const QDomElement& e)
77
77
{
78
78
        if (e.attribute("type") == "get") {
79
 
                bool found;
80
 
                QDomElement q = findSubTag(e, "query", &found);
81
 
                if (!found)
 
79
                QDomElement q = e.firstChildElement("query");
 
80
                if (q.isNull())
82
81
                        return false;
83
 
                        
 
82
 
84
83
                // Disco replies to the AdHoc node
85
84
                if (q.attribute("xmlns") == "http://jabber.org/protocol/disco#items" && q.attribute("node") == AHC_NS) {
86
85
                        sendCommandList(e.attribute("from"),e.attribute("to"),e.attribute("id"));
130
129
                }
131
130
 
132
131
        }
133
 
        
 
132
 
134
133
        return false;
135
134
}
136
135
 
137
136
bool JT_AHCServer::commandExecuteQuery(const QDomElement& e)
138
137
{
139
138
        if (e.attribute("type") == "set") {
140
 
                bool found;
141
 
                QDomElement q = findSubTag(e, "command", &found);
142
 
                if (found && q.attribute("xmlns") == AHC_NS && manager_->hasServer(q.attribute("node"), Jid(e.attribute("from")))) {
 
139
                QDomElement q = e.firstChildElement("command");
 
140
                if (!q.isNull() && q.attribute("xmlns") == AHC_NS && manager_->hasServer(q.attribute("node"), Jid(e.attribute("from")))) {
143
141
                        AHCommand command(q);
144
142
                        manager_->execute(command, Jid(e.attribute("from")), e.attribute("id"));
145
143
                        return true;
146
 
                } 
147
 
                else 
 
144
                }
 
145
                else
148
146
                        return false;
149
147
        }
150
148
        return false;
151
149
}
152
150
 
153
 
void JT_AHCServer::sendCommandList(const QString& to, const QString& from, const QString& id) 
 
151
void JT_AHCServer::sendCommandList(const QString& to, const QString& from, const QString& id)
154
152
{
155
 
        // Create query element 
 
153
        // Create query element
156
154
        QDomElement iq = createIQ(doc(), "result", to, id);
157
155
        QDomElement query = doc()->createElement("query");
158
156
        query.setAttribute("xmlns", "http://jabber.org/protocol/disco#items");
171
169
        // Send the message
172
170
        send(iq);
173
171
}
174
 
        
 
172
 
175
173
void JT_AHCServer::sendReply(const AHCommand& c, const Jid& to, const QString& id)
176
174
{
177
175
        // if (c.error().type() != AHCError::None) {
184
182
        // }
185
183
}
186
184
 
187
 
// -------------------------------------------------------------------------- 
 
185
// --------------------------------------------------------------------------
188
186
 
189
187
AHCServerManager::AHCServerManager(PsiAccount *pa) : pa_(pa)
190
188
{
201
199
        servers_.removeAll(server);
202
200
}
203
201
 
204
 
AHCServerManager::ServerList AHCServerManager::commands(const Jid& j) const 
 
202
AHCServerManager::ServerList AHCServerManager::commands(const Jid& j) const
205
203
{
206
204
        ServerList list;
207
205
        for (ServerList::ConstIterator it = servers_.begin(); it != servers_.end(); ++it) {
208
 
                if ((*it)->isAllowed(j)) 
 
206
                if ((*it)->isAllowed(j))
209
207
                        list.append(*it);
210
208
        }
211
209
        return list;
248
246
AHCommandServer* AHCServerManager::findServer(const QString& node) const
249
247
{
250
248
        for (ServerList::ConstIterator it = servers_.begin(); it != servers_.end(); ++it) {
251
 
                if ((*it)->node() == node) 
 
249
                if ((*it)->node() == node)
252
250
                        return (*it);
253
251
        }
254
252
        return 0;