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

« back to all changes in this revision

Viewing changes to iris/src/xmpp/xmpp-im/xmpp_xmlcommon.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:
159
159
 
160
160
 
161
161
/**
162
 
 * \brief find an direct child element by name
163
 
 * \param e parent element
164
 
 * \param name name of element to find
165
 
 * \param found (optional/out) found?
166
 
 * \return the element (or a null QDomElemnt if not found)
167
 
 */
168
 
QDomElement findSubTag(const QDomElement &e, const QString &name, bool *found)
169
 
{
170
 
        if(found)
171
 
                *found = false;
172
 
 
173
 
        for(QDomNode n = e.firstChild(); !n.isNull(); n = n.nextSibling()) {
174
 
                QDomElement i = n.toElement();
175
 
                if(i.isNull())
176
 
                        continue;
177
 
                if(i.tagName() == name) {
178
 
                        if(found)
179
 
                                *found = true;
180
 
                        return i;
181
 
                }
182
 
        }
183
 
 
184
 
        QDomElement tmp;
185
 
        return tmp;
186
 
}
187
 
 
188
 
 
189
 
/**
190
162
 * \brief obtain direct child elements of a certain kind.  unlike
191
163
 *        elementsByTagNameNS, this function does not descend beyond the first
192
164
 *        level of children.
211
183
 
212
184
/**
213
185
 * \brief create a new IQ stanza
214
 
 * \param doc 
215
 
 * \param type 
 
186
 * \param doc
 
187
 * \param type
216
188
 * \param to destination jid
217
189
 * \param id stanza id
218
190
 * \return the created stanza
235
207
*/
236
208
QDomElement queryTag(const QDomElement &e)
237
209
{
238
 
        bool found;
239
 
        QDomElement q = findSubTag(e, "query", &found);
240
 
        return q;
 
210
        return e.firstChildElement("query");
241
211
}
242
212
 
243
213
QString queryNS(const QDomElement &e)
244
214
{
245
 
        bool found;
246
 
        QDomElement q = findSubTag(e, "query", &found);
247
 
        if(found)
248
 
                return q.attribute("xmlns");
249
 
 
250
 
        return "";
251
 
}
252
 
 
253
 
QDomElement queryTag(const QDomElement &e, const QString &element)
254
 
{
255
 
        bool found;
256
 
        QDomElement q = findSubTag(e, element, &found);
257
 
        return q;
258
 
}
259
 
 
260
 
QString queryNS(const QDomElement &e, const QString &element)
261
 
{
262
 
        bool found;
263
 
        QDomElement q = findSubTag(e, element, &found);
264
 
        if(found)
265
 
                return q.attribute("xmlns");
266
 
 
267
 
        return "";
 
215
        return e.firstChildElement("query").attribute("xmlns");
268
216
}
269
217
 
270
218
/**
290
238
 
291
239
void getErrorFromElement(const QDomElement &e, const QString &baseNS, int *code, QString *str)
292
240
{
293
 
        bool found;
294
 
        QDomElement tag = findSubTag(e, "error", &found);
295
 
        if(!found)
 
241
        QDomElement tag = e.firstChildElement("error");
 
242
        if(tag.isNull())
296
243
                return;
297
244
 
298
245
        XMPP::Stanza::Error err;
326
273
                n = n.parentNode();
327
274
        QString ns;
328
275
        if(n.isNull() || !n.toElement().hasAttribute("xmlns")){
329
 
                if (n.toElement().namespaceURI () == ""){               
 
276
                if (n.toElement().namespaceURI () == ""){
330
277
                        ns = "jabber:client";
331
278
                } else {
332
279
                        ns = n.toElement().namespaceURI();
374
321
 
375
322
bool hasSubTag(const QDomElement &e, const QString &name)
376
323
{
377
 
        bool found;
378
 
        findSubTag(e, name, &found);
379
 
        return found;
 
324
        return !e.firstChildElement(name).isNull();
380
325
}
381
326
 
382
327
QString subTagText(const QDomElement &e, const QString &name)
383
328
{
384
 
        bool found;
385
 
        QDomElement i = findSubTag(e, name, &found);
386
 
        if ( found )
 
329
        QDomElement i = e.firstChildElement(name);
 
330
        if ( !i.isNull() )
387
331
                return i.text();
388
332
        return QString::null;
389
333
}
483
427
 
484
428
void readEntry(const QDomElement &e, const QString &name, QString *v)
485
429
{
486
 
        bool found = false;
487
 
        QDomElement tag = findSubTag(e, name, &found);
488
 
        if(!found)
 
430
        QDomElement tag = e.firstChildElement(name);
 
431
        if(tag.isNull())
489
432
                return;
490
433
        *v = tagContent(tag);
491
434
}
492
435
 
493
436
void readNumEntry(const QDomElement &e, const QString &name, int *v)
494
437
{
495
 
        bool found = false;
496
 
        QDomElement tag = findSubTag(e, name, &found);
497
 
        if(!found)
 
438
        QDomElement tag = e.firstChildElement(name);
 
439
        if(tag.isNull())
498
440
                return;
499
441
        *v = tagContent(tag).toInt();
500
442
}
501
443
 
502
444
void readBoolEntry(const QDomElement &e, const QString &name, bool *v)
503
445
{
504
 
        bool found = false;
505
 
        QDomElement tag = findSubTag(e, name, &found);
506
 
        if(!found)
 
446
        QDomElement tag = e.firstChildElement(name);
 
447
        if(tag.isNull())
507
448
                return;
508
449
        *v = (tagContent(tag) == "true") ? true: false;
509
450
}
510
451
 
511
452
void readSizeEntry(const QDomElement &e, const QString &name, QSize *v)
512
453
{
513
 
        bool found = false;
514
 
        QDomElement tag = findSubTag(e, name, &found);
515
 
        if(!found)
 
454
        QDomElement tag = e.firstChildElement(name);
 
455
        if(tag.isNull())
516
456
                return;
517
457
        QStringList list = tagContent(tag).split(',');
518
458
        if(list.count() != 2)
525
465
 
526
466
void readRectEntry(const QDomElement &e, const QString &name, QRect *v)
527
467
{
528
 
        bool found = false;
529
 
        QDomElement tag = findSubTag(e, name, &found);
530
 
        if(!found)
 
468
        QDomElement tag = e.firstChildElement(name);
 
469
        if(tag.isNull())
531
470
                return;
532
471
        QStringList list = tagContent(tag).split(',');
533
472
        if(list.count() != 4)
542
481
 
543
482
void readColorEntry(const QDomElement &e, const QString &name, QColor *v)
544
483
{
545
 
        bool found = false;
546
 
        QDomElement tag = findSubTag(e, name, &found);
547
 
        if(!found)
 
484
        QDomElement tag = e.firstChildElement(name);
 
485
        if(tag.isNull())
548
486
                return;
549
487
        QColor c;
550
488
        c.setNamedColor(tagContent(tag));
554
492
 
555
493
void xmlToStringList(const QDomElement &e, const QString &name, QStringList *v)
556
494
{
557
 
        bool found = false;
558
 
        QDomElement tag = findSubTag(e, name, &found);
559
 
        if(!found)
 
495
        QDomElement tag = e.firstChildElement(name);
 
496
        if(tag.isNull())
560
497
                return;
561
498
        QStringList list;
562
499
        for(QDomNode n = tag.firstChild(); !n.isNull(); n = n.nextSibling()) {