~ubuntu-branches/ubuntu/karmic/psi/karmic

« back to all changes in this revision

Viewing changes to iris/xmpp-core/connector.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-04-14 18:57:30 UTC
  • mfrom: (2.1.9 hardy)
  • Revision ID: james.westby@ubuntu.com-20080414185730-528re3zp0m2hdlhi
Tags: 0.11-8
* added CONFIG -= link_prl to .pro files and removed dependencies
  which are made unnecessary by this change
* Fix segfault when closing last chat tab with qt4.4
  (This is from upstream svn, rev. 1101) (Closes: Bug#476122)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
  greatly simplify this class.  - Sep 3rd, 2003.
30
30
*/
31
31
 
32
 
#include"xmpp.h"
 
32
#include "xmpp.h"
33
33
 
34
 
#include<qguardedptr.h>
35
 
#include<qca.h>
36
 
#include"safedelete.h"
 
34
#include <qpointer.h>
 
35
#include <qca.h>
 
36
#include <QList>
 
37
#include <QUrl>
 
38
#include "safedelete.h"
 
39
#include <libidn/idna.h>
37
40
 
38
41
#ifdef NO_NDNS
39
 
#include<qdns.h>
 
42
#include <q3dns.h>
40
43
#else
41
 
#include"ndns.h"
 
44
#include "ndns.h"
42
45
#endif
43
46
 
44
 
#include"srvresolver.h"
45
 
#include"bsocket.h"
46
 
#include"httpconnect.h"
47
 
#include"httppoll.h"
48
 
#include"socks.h"
49
 
#include"hash.h"
 
47
#include "bsocket.h"
 
48
#include "httpconnect.h"
 
49
#include "httppoll.h"
 
50
#include "socks.h"
 
51
#include "srvresolver.h"
50
52
 
51
53
//#define XMPP_DEBUG
52
54
 
198
200
        int mode;
199
201
        ByteStream *bs;
200
202
#ifdef NO_NDNS
201
 
        QDns *qdns;
 
203
        Q3Dns *qdns;
202
204
#else
203
205
        NDns dns;
204
206
#endif
212
214
 
213
215
        QString host;
214
216
        int port;
215
 
        QValueList<QDns::Server> servers;
 
217
        QList<Q3Dns::Server> servers;
216
218
        int errorCode;
217
219
 
218
220
        bool multi, using_srv;
315
317
                return;
316
318
 
317
319
        d->errorCode = 0;
318
 
        d->server = server;
319
320
        d->mode = Connecting;
320
321
        d->aaaa = true;
321
322
 
 
323
        // Encode the servername
 
324
        d->server = QUrl::toAce(server);
 
325
        //char* server_encoded;
 
326
        //if (!idna_to_ascii_8z(server.utf8().data(), &server_encoded, 0)) {
 
327
        //      d->server = QString(server_encoded);
 
328
        //      free(server_encoded);
 
329
        //}
 
330
        //else {
 
331
        //      d->server = server;
 
332
        //}
 
333
 
322
334
        if(d->proxy.type() == Proxy::HttpPoll) {
323
335
                // need SHA1 here
324
 
                if(!QCA::isSupported(QCA::CAP_SHA1))
325
 
                        QCA::insertProvider(createProviderHash());
 
336
                //if(!QCA::isSupported(QCA::CAP_SHA1))
 
337
                //      QCA::insertProvider(createProviderHash());
326
338
 
327
339
                HttpPoll *s = new HttpPoll;
328
340
                d->bs = s;
339
351
                else
340
352
                        s->connectToHost(d->proxy.host(), d->proxy.port(), d->proxy.url());
341
353
        }
342
 
        else {
 
354
        else if (d->proxy.type() == Proxy::HttpConnect) {
343
355
                if(!d->opt_host.isEmpty()) {
344
356
                        d->host = d->opt_host;
345
357
                        d->port = d->opt_port;
 
358
                }
 
359
                else {
 
360
                        d->host = server;
 
361
                        d->port = 5222;
 
362
                }
 
363
                do_connect();
 
364
        }
 
365
        else {
 
366
                if(!d->opt_host.isEmpty()) {
 
367
                        d->host = d->opt_host.trimmed();
 
368
                        d->port = d->opt_port;
346
369
                        do_resolve();
347
370
                }
348
371
                else {
349
372
                        d->multi = true;
350
373
 
351
 
                        QGuardedPtr<QObject> self = this;
 
374
                        QPointer<QObject> self = this;
352
375
                        srvLookup(d->server);
353
376
                        if(!self)
354
377
                                return;
388
411
{
389
412
#ifdef NO_NDNS
390
413
        printf("resolving (aaaa=%d)\n", d->aaaa);
391
 
        d->qdns = new QDns;
 
414
        d->qdns = new Q3Dns;
392
415
        connect(d->qdns, SIGNAL(resultsReady()), SLOT(dns_done()));
393
416
        if(d->aaaa)
394
 
                d->qdns->setRecordType(QDns::Aaaa); // IPv6
 
417
                d->qdns->setRecordType(Q3Dns::Aaaa); // IPv6
395
418
        else
396
 
                d->qdns->setRecordType(QDns::A); // IPv4
 
419
                d->qdns->setRecordType(Q3Dns::A); // IPv4
397
420
        d->qdns->setLabel(d->host);
398
421
#else
399
422
        d->dns.resolve(d->host);
416
439
        //SafeDeleteLock s(&d->sd);
417
440
 
418
441
        // grab the address list and destroy the qdns object
419
 
        QValueList<QHostAddress> list = d->qdns->addresses();
 
442
        QList<QHostAddress> list = d->qdns->addresses();
420
443
        d->qdns->disconnect(this);
421
444
        d->qdns->deleteLater();
422
445
        //d->sd.deleteLater(d->qdns);
435
458
        else
436
459
                addr = list.first();
437
460
#else
438
 
        if(d->dns.result() == 0)
 
461
        if(d->dns.result().isNull ())
439
462
                failed = true;
440
463
        else
441
464
                addr = QHostAddress(d->dns.result());
545
568
 
546
569
void AdvancedConnector::srv_done()
547
570
{
548
 
        QGuardedPtr<QObject> self = this;
 
571
        QPointer<QObject> self = this;
549
572
#ifdef XMPP_DEBUG
550
573
        printf("srv_done1\n");
551
574
#endif