~ubuntu-branches/ubuntu/oneiric/psi/oneiric

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2005-01-10 17:41:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110174143-ltocv5zapl6blf5d
Tags: 0.9.3-1
* New upstream release
* Cleaned up debian/rules (some things are done by upstream Makefiles now)
* Fixed some lintian warnings:
  - removed executable bit from some .png files
  - moved psi.desktop to /usr/share/applications
* Updated menu files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * connector.cpp - establish a connection to an XMPP server
 
3
 * Copyright (C) 2003  Justin Karneges
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
/*
 
22
  TODO:
 
23
 
 
24
  - Test and analyze all possible branches
 
25
 
 
26
  XMPP::AdvancedConnector is "good for now."  The only real issue is that
 
27
  most of what it provides is just to work around the old Jabber/XMPP 0.9
 
28
  connection behavior.  When XMPP 1.0 has taken over the world, we can
 
29
  greatly simplify this class.  - Sep 3rd, 2003.
 
30
*/
 
31
 
 
32
#include"xmpp.h"
 
33
 
 
34
#include<qguardedptr.h>
 
35
#include<qca.h>
 
36
#include"safedelete.h"
 
37
 
 
38
#ifdef NO_NDNS
 
39
#include<qdns.h>
 
40
#else
 
41
#include"ndns.h"
 
42
#endif
 
43
 
 
44
#include"srvresolver.h"
 
45
#include"bsocket.h"
 
46
#include"httpconnect.h"
 
47
#include"httppoll.h"
 
48
#include"socks.h"
 
49
#include"hash.h"
 
50
 
 
51
//#define XMPP_DEBUG
 
52
 
 
53
using namespace XMPP;
 
54
 
 
55
//----------------------------------------------------------------------------
 
56
// Connector
 
57
//----------------------------------------------------------------------------
 
58
Connector::Connector(QObject *parent)
 
59
:QObject(parent)
 
60
{
 
61
        setUseSSL(false);
 
62
        setPeerAddressNone();
 
63
}
 
64
 
 
65
Connector::~Connector()
 
66
{
 
67
}
 
68
 
 
69
bool Connector::useSSL() const
 
70
{
 
71
        return ssl;
 
72
}
 
73
 
 
74
bool Connector::havePeerAddress() const
 
75
{
 
76
        return haveaddr;
 
77
}
 
78
 
 
79
QHostAddress Connector::peerAddress() const
 
80
{
 
81
        return addr;
 
82
}
 
83
 
 
84
Q_UINT16 Connector::peerPort() const
 
85
{
 
86
        return port;
 
87
}
 
88
 
 
89
void Connector::setUseSSL(bool b)
 
90
{
 
91
        ssl = b;
 
92
}
 
93
 
 
94
void Connector::setPeerAddressNone()
 
95
{
 
96
        haveaddr = false;
 
97
        addr = QHostAddress();
 
98
        port = 0;
 
99
}
 
100
 
 
101
void Connector::setPeerAddress(const QHostAddress &_addr, Q_UINT16 _port)
 
102
{
 
103
        haveaddr = true;
 
104
        addr = _addr;
 
105
        port = _port;
 
106
}
 
107
 
 
108
 
 
109
//----------------------------------------------------------------------------
 
110
// AdvancedConnector::Proxy
 
111
//----------------------------------------------------------------------------
 
112
AdvancedConnector::Proxy::Proxy()
 
113
{
 
114
        t = None;
 
115
        v_poll = 30;
 
116
}
 
117
 
 
118
AdvancedConnector::Proxy::~Proxy()
 
119
{
 
120
}
 
121
 
 
122
int AdvancedConnector::Proxy::type() const
 
123
{
 
124
        return t;
 
125
}
 
126
 
 
127
QString AdvancedConnector::Proxy::host() const
 
128
{
 
129
        return v_host;
 
130
}
 
131
 
 
132
Q_UINT16 AdvancedConnector::Proxy::port() const
 
133
{
 
134
        return v_port;
 
135
}
 
136
 
 
137
QString AdvancedConnector::Proxy::url() const
 
138
{
 
139
        return v_url;
 
140
}
 
141
 
 
142
QString AdvancedConnector::Proxy::user() const
 
143
{
 
144
        return v_user;
 
145
}
 
146
 
 
147
QString AdvancedConnector::Proxy::pass() const
 
148
{
 
149
        return v_pass;
 
150
}
 
151
 
 
152
int AdvancedConnector::Proxy::pollInterval() const
 
153
{
 
154
        return v_poll;
 
155
}
 
156
 
 
157
void AdvancedConnector::Proxy::setHttpConnect(const QString &host, Q_UINT16 port)
 
158
{
 
159
        t = HttpConnect;
 
160
        v_host = host;
 
161
        v_port = port;
 
162
}
 
163
 
 
164
void AdvancedConnector::Proxy::setHttpPoll(const QString &host, Q_UINT16 port, const QString &url)
 
165
{
 
166
        t = HttpPoll;
 
167
        v_host = host;
 
168
        v_port = port;
 
169
        v_url = url;
 
170
}
 
171
 
 
172
void AdvancedConnector::Proxy::setSocks(const QString &host, Q_UINT16 port)
 
173
{
 
174
        t = Socks;
 
175
        v_host = host;
 
176
        v_port = port;
 
177
}
 
178
 
 
179
void AdvancedConnector::Proxy::setUserPass(const QString &user, const QString &pass)
 
180
{
 
181
        v_user = user;
 
182
        v_pass = pass;
 
183
}
 
184
 
 
185
void AdvancedConnector::Proxy::setPollInterval(int secs)
 
186
{
 
187
        v_poll = secs;
 
188
}
 
189
 
 
190
 
 
191
//----------------------------------------------------------------------------
 
192
// AdvancedConnector
 
193
//----------------------------------------------------------------------------
 
194
enum { Idle, Connecting, Connected };
 
195
class AdvancedConnector::Private
 
196
{
 
197
public:
 
198
        int mode;
 
199
        ByteStream *bs;
 
200
#ifdef NO_NDNS
 
201
        QDns *qdns;
 
202
#else
 
203
        NDns dns;
 
204
#endif
 
205
        SrvResolver srv;
 
206
 
 
207
        QString server;
 
208
        QString opt_host;
 
209
        int opt_port;
 
210
        bool opt_probe, opt_ssl;
 
211
        Proxy proxy;
 
212
 
 
213
        QString host;
 
214
        int port;
 
215
        QValueList<QDns::Server> servers;
 
216
        int errorCode;
 
217
 
 
218
        bool multi, using_srv;
 
219
        bool will_be_ssl;
 
220
        int probe_mode;
 
221
 
 
222
        bool aaaa;
 
223
        SafeDelete sd;
 
224
};
 
225
 
 
226
AdvancedConnector::AdvancedConnector(QObject *parent)
 
227
:Connector(parent)
 
228
{
 
229
        d = new Private;
 
230
        d->bs = 0;
 
231
#ifdef NO_NDNS
 
232
        d->qdns = 0;
 
233
#else
 
234
        connect(&d->dns, SIGNAL(resultsReady()), SLOT(dns_done()));
 
235
#endif
 
236
        connect(&d->srv, SIGNAL(resultsReady()), SLOT(srv_done()));
 
237
        d->opt_probe = false;
 
238
        d->opt_ssl = false;
 
239
        cleanup();
 
240
        d->errorCode = 0;
 
241
}
 
242
 
 
243
AdvancedConnector::~AdvancedConnector()
 
244
{
 
245
        cleanup();
 
246
        delete d;
 
247
}
 
248
 
 
249
void AdvancedConnector::cleanup()
 
250
{
 
251
        d->mode = Idle;
 
252
 
 
253
        // stop any dns
 
254
#ifdef NO_NDNS
 
255
        if(d->qdns) {
 
256
                d->qdns->disconnect(this);
 
257
                d->qdns->deleteLater();
 
258
                //d->sd.deleteLater(d->qdns);
 
259
                d->qdns = 0;
 
260
        }
 
261
#else
 
262
        if(d->dns.isBusy())
 
263
                d->dns.stop();
 
264
#endif
 
265
        if(d->srv.isBusy())
 
266
                d->srv.stop();
 
267
 
 
268
        // destroy the bytestream, if there is one
 
269
        delete d->bs;
 
270
        d->bs = 0;
 
271
 
 
272
        d->multi = false;
 
273
        d->using_srv = false;
 
274
        d->will_be_ssl = false;
 
275
        d->probe_mode = -1;
 
276
 
 
277
        setUseSSL(false);
 
278
        setPeerAddressNone();
 
279
}
 
280
 
 
281
void AdvancedConnector::setProxy(const Proxy &proxy)
 
282
{
 
283
        if(d->mode != Idle)
 
284
                return;
 
285
        d->proxy = proxy;
 
286
}
 
287
 
 
288
void AdvancedConnector::setOptHostPort(const QString &host, Q_UINT16 _port)
 
289
{
 
290
        if(d->mode != Idle)
 
291
                return;
 
292
        d->opt_host = host;
 
293
        d->opt_port = _port;
 
294
}
 
295
 
 
296
void AdvancedConnector::setOptProbe(bool b)
 
297
{
 
298
        if(d->mode != Idle)
 
299
                return;
 
300
        d->opt_probe = b;
 
301
}
 
302
 
 
303
void AdvancedConnector::setOptSSL(bool b)
 
304
{
 
305
        if(d->mode != Idle)
 
306
                return;
 
307
        d->opt_ssl = b;
 
308
}
 
309
 
 
310
void AdvancedConnector::connectToServer(const QString &server)
 
311
{
 
312
        if(d->mode != Idle)
 
313
                return;
 
314
        if(server.isEmpty())
 
315
                return;
 
316
 
 
317
        d->errorCode = 0;
 
318
        d->server = server;
 
319
        d->mode = Connecting;
 
320
        d->aaaa = true;
 
321
 
 
322
        if(d->proxy.type() == Proxy::HttpPoll) {
 
323
                // need SHA1 here
 
324
                if(!QCA::isSupported(QCA::CAP_SHA1))
 
325
                        QCA::insertProvider(createProviderHash());
 
326
 
 
327
                HttpPoll *s = new HttpPoll;
 
328
                d->bs = s;
 
329
                connect(s, SIGNAL(connected()), SLOT(bs_connected()));
 
330
                connect(s, SIGNAL(syncStarted()), SLOT(http_syncStarted()));
 
331
                connect(s, SIGNAL(syncFinished()), SLOT(http_syncFinished()));
 
332
                connect(s, SIGNAL(error(int)), SLOT(bs_error(int)));
 
333
                if(!d->proxy.user().isEmpty())
 
334
                        s->setAuth(d->proxy.user(), d->proxy.pass());
 
335
                s->setPollInterval(d->proxy.pollInterval());
 
336
 
 
337
                if(d->proxy.host().isEmpty())
 
338
                        s->connectToUrl(d->proxy.url());
 
339
                else
 
340
                        s->connectToHost(d->proxy.host(), d->proxy.port(), d->proxy.url());
 
341
        }
 
342
        else {
 
343
                if(!d->opt_host.isEmpty()) {
 
344
                        d->host = d->opt_host;
 
345
                        d->port = d->opt_port;
 
346
                        do_resolve();
 
347
                }
 
348
                else {
 
349
                        d->multi = true;
 
350
 
 
351
                        QGuardedPtr<QObject> self = this;
 
352
                        srvLookup(d->server);
 
353
                        if(!self)
 
354
                                return;
 
355
 
 
356
                        d->srv.resolveSrvOnly(d->server, "xmpp-client", "tcp");
 
357
                }
 
358
        }
 
359
}
 
360
 
 
361
void AdvancedConnector::changePollInterval(int secs)
 
362
{
 
363
        if(d->bs && (d->bs->inherits("XMPP::HttpPoll") || d->bs->inherits("HttpPoll"))) {
 
364
                HttpPoll *s = static_cast<HttpPoll*>(d->bs);
 
365
                s->setPollInterval(secs);
 
366
        }
 
367
}
 
368
 
 
369
ByteStream *AdvancedConnector::stream() const
 
370
{
 
371
        if(d->mode == Connected)
 
372
                return d->bs;
 
373
        else
 
374
                return 0;
 
375
}
 
376
 
 
377
void AdvancedConnector::done()
 
378
{
 
379
        cleanup();
 
380
}
 
381
 
 
382
int AdvancedConnector::errorCode() const
 
383
{
 
384
        return d->errorCode;
 
385
}
 
386
 
 
387
void AdvancedConnector::do_resolve()
 
388
{
 
389
#ifdef NO_NDNS
 
390
        printf("resolving (aaaa=%d)\n", d->aaaa);
 
391
        d->qdns = new QDns;
 
392
        connect(d->qdns, SIGNAL(resultsReady()), SLOT(dns_done()));
 
393
        if(d->aaaa)
 
394
                d->qdns->setRecordType(QDns::Aaaa); // IPv6
 
395
        else
 
396
                d->qdns->setRecordType(QDns::A); // IPv4
 
397
        d->qdns->setLabel(d->host);
 
398
#else
 
399
        d->dns.resolve(d->host);
 
400
#endif
 
401
}
 
402
 
 
403
void AdvancedConnector::dns_done()
 
404
{
 
405
        bool failed = false;
 
406
        QHostAddress addr;
 
407
 
 
408
#ifdef NO_NDNS
 
409
        //if(!d->qdns)
 
410
        //      return;
 
411
 
 
412
        // apparently we sometimes get this signal even though the results aren' t ready
 
413
        //if(d->qdns->isWorking())
 
414
        //      return;
 
415
 
 
416
        //SafeDeleteLock s(&d->sd);
 
417
 
 
418
        // grab the address list and destroy the qdns object
 
419
        QValueList<QHostAddress> list = d->qdns->addresses();
 
420
        d->qdns->disconnect(this);
 
421
        d->qdns->deleteLater();
 
422
        //d->sd.deleteLater(d->qdns);
 
423
        d->qdns = 0;
 
424
 
 
425
        if(list.isEmpty()) {
 
426
                if(d->aaaa) {
 
427
                        d->aaaa = false;
 
428
                        do_resolve();
 
429
                        return;
 
430
                }
 
431
                //do_resolve();
 
432
                //return;
 
433
                failed = true;
 
434
        }
 
435
        else
 
436
                addr = list.first();
 
437
#else
 
438
        if(d->dns.result() == 0)
 
439
                failed = true;
 
440
        else
 
441
                addr = QHostAddress(d->dns.result());
 
442
#endif
 
443
 
 
444
        if(failed) {
 
445
#ifdef XMPP_DEBUG
 
446
                printf("dns1\n");
 
447
#endif
 
448
                // using proxy?  then try the unresolved host through the proxy
 
449
                if(d->proxy.type() != Proxy::None) {
 
450
#ifdef XMPP_DEBUG
 
451
                        printf("dns1.1\n");
 
452
#endif
 
453
                        do_connect();
 
454
                }
 
455
                else if(d->using_srv) {
 
456
#ifdef XMPP_DEBUG
 
457
                        printf("dns1.2\n");
 
458
#endif
 
459
                        if(d->servers.isEmpty()) {
 
460
#ifdef XMPP_DEBUG
 
461
                                printf("dns1.2.1\n");
 
462
#endif
 
463
                                cleanup();
 
464
                                d->errorCode = ErrConnectionRefused;
 
465
                                error();
 
466
                        }
 
467
                        else {
 
468
#ifdef XMPP_DEBUG
 
469
                                printf("dns1.2.2\n");
 
470
#endif
 
471
                                tryNextSrv();
 
472
                                return;
 
473
                        }
 
474
                }
 
475
                else {
 
476
#ifdef XMPP_DEBUG
 
477
                        printf("dns1.3\n");
 
478
#endif
 
479
                        cleanup();
 
480
                        d->errorCode = ErrHostNotFound;
 
481
                        error();
 
482
                }
 
483
        }
 
484
        else {
 
485
#ifdef XMPP_DEBUG
 
486
                printf("dns2\n");
 
487
#endif
 
488
                d->host = addr.toString();
 
489
                do_connect();
 
490
        }
 
491
}
 
492
 
 
493
void AdvancedConnector::do_connect()
 
494
{
 
495
#ifdef XMPP_DEBUG
 
496
        printf("trying %s:%d\n", d->host.latin1(), d->port);
 
497
#endif
 
498
        int t = d->proxy.type();
 
499
        if(t == Proxy::None) {
 
500
#ifdef XMPP_DEBUG
 
501
                printf("do_connect1\n");
 
502
#endif
 
503
                BSocket *s = new BSocket;
 
504
                d->bs = s;
 
505
                connect(s, SIGNAL(connected()), SLOT(bs_connected()));
 
506
                connect(s, SIGNAL(error(int)), SLOT(bs_error(int)));
 
507
                s->connectToHost(d->host, d->port);
 
508
        }
 
509
        else if(t == Proxy::HttpConnect) {
 
510
#ifdef XMPP_DEBUG
 
511
                printf("do_connect2\n");
 
512
#endif
 
513
                HttpConnect *s = new HttpConnect;
 
514
                d->bs = s;
 
515
                connect(s, SIGNAL(connected()), SLOT(bs_connected()));
 
516
                connect(s, SIGNAL(error(int)), SLOT(bs_error(int)));
 
517
                if(!d->proxy.user().isEmpty())
 
518
                        s->setAuth(d->proxy.user(), d->proxy.pass());
 
519
                s->connectToHost(d->proxy.host(), d->proxy.port(), d->host, d->port);
 
520
        }
 
521
        else if(t == Proxy::Socks) {
 
522
#ifdef XMPP_DEBUG
 
523
                printf("do_connect3\n");
 
524
#endif
 
525
                SocksClient *s = new SocksClient;
 
526
                d->bs = s;
 
527
                connect(s, SIGNAL(connected()), SLOT(bs_connected()));
 
528
                connect(s, SIGNAL(error(int)), SLOT(bs_error(int)));
 
529
                if(!d->proxy.user().isEmpty())
 
530
                        s->setAuth(d->proxy.user(), d->proxy.pass());
 
531
                s->connectToHost(d->proxy.host(), d->proxy.port(), d->host, d->port);
 
532
        }
 
533
}
 
534
 
 
535
void AdvancedConnector::tryNextSrv()
 
536
{
 
537
#ifdef XMPP_DEBUG
 
538
        printf("trying next srv\n");
 
539
#endif
 
540
        d->host = d->servers.first().name;
 
541
        d->port = d->servers.first().port;
 
542
        d->servers.remove(d->servers.begin());
 
543
        do_resolve();
 
544
}
 
545
 
 
546
void AdvancedConnector::srv_done()
 
547
{
 
548
        QGuardedPtr<QObject> self = this;
 
549
#ifdef XMPP_DEBUG
 
550
        printf("srv_done1\n");
 
551
#endif
 
552
        d->servers = d->srv.servers();
 
553
        if(d->servers.isEmpty()) {
 
554
                srvResult(false);
 
555
                if(!self)
 
556
                        return;
 
557
 
 
558
#ifdef XMPP_DEBUG
 
559
                printf("srv_done1.1\n");
 
560
#endif
 
561
                // fall back to A record
 
562
                d->using_srv = false;
 
563
                d->host = d->server;
 
564
                if(d->opt_probe) {
 
565
#ifdef XMPP_DEBUG
 
566
                        printf("srv_done1.1.1\n");
 
567
#endif
 
568
                        d->probe_mode = 0;
 
569
                        d->port = 5223;
 
570
                        d->will_be_ssl = true;
 
571
                }
 
572
                else {
 
573
#ifdef XMPP_DEBUG
 
574
                        printf("srv_done1.1.2\n");
 
575
#endif
 
576
                        d->probe_mode = 1;
 
577
                        d->port = 5222;
 
578
                }
 
579
                do_resolve();
 
580
                return;
 
581
        }
 
582
 
 
583
        srvResult(true);
 
584
        if(!self)
 
585
                return;
 
586
 
 
587
        d->using_srv = true;
 
588
        tryNextSrv();
 
589
}
 
590
 
 
591
void AdvancedConnector::bs_connected()
 
592
{
 
593
        if(d->proxy.type() == Proxy::None) {
 
594
                QHostAddress h = (static_cast<BSocket*>(d->bs))->peerAddress();
 
595
                int p = (static_cast<BSocket*>(d->bs))->peerPort();
 
596
                setPeerAddress(h, p);
 
597
        }
 
598
 
 
599
        // only allow ssl override if proxy==poll or host:port
 
600
        if((d->proxy.type() == Proxy::HttpPoll || !d->opt_host.isEmpty()) && d->opt_ssl)
 
601
                setUseSSL(true);
 
602
        else if(d->will_be_ssl)
 
603
                setUseSSL(true);
 
604
 
 
605
        d->mode = Connected;
 
606
        connected();
 
607
}
 
608
 
 
609
void AdvancedConnector::bs_error(int x)
 
610
{
 
611
        if(d->mode == Connected) {
 
612
                d->errorCode = ErrStream;
 
613
                error();
 
614
                return;
 
615
        }
 
616
 
 
617
        bool proxyError = false;
 
618
        int err = ErrConnectionRefused;
 
619
        int t = d->proxy.type();
 
620
 
 
621
#ifdef XMPP_DEBUG
 
622
        printf("bse1\n");
 
623
#endif
 
624
 
 
625
        // figure out the error
 
626
        if(t == Proxy::None) {
 
627
                if(x == BSocket::ErrHostNotFound)
 
628
                        err = ErrHostNotFound;
 
629
                else
 
630
                        err = ErrConnectionRefused;
 
631
        }
 
632
        else if(t == Proxy::HttpConnect) {
 
633
                if(x == HttpConnect::ErrConnectionRefused)
 
634
                        err = ErrConnectionRefused;
 
635
                else if(x == HttpConnect::ErrHostNotFound)
 
636
                        err = ErrHostNotFound;
 
637
                else {
 
638
                        proxyError = true;
 
639
                        if(x == HttpConnect::ErrProxyAuth)
 
640
                                err = ErrProxyAuth;
 
641
                        else if(x == HttpConnect::ErrProxyNeg)
 
642
                                err = ErrProxyNeg;
 
643
                        else
 
644
                                err = ErrProxyConnect;
 
645
                }
 
646
        }
 
647
        else if(t == Proxy::HttpPoll) {
 
648
                if(x == HttpPoll::ErrConnectionRefused)
 
649
                        err = ErrConnectionRefused;
 
650
                else if(x == HttpPoll::ErrHostNotFound)
 
651
                        err = ErrHostNotFound;
 
652
                else {
 
653
                        proxyError = true;
 
654
                        if(x == HttpPoll::ErrProxyAuth)
 
655
                                err = ErrProxyAuth;
 
656
                        else if(x == HttpPoll::ErrProxyNeg)
 
657
                                err = ErrProxyNeg;
 
658
                        else
 
659
                                err = ErrProxyConnect;
 
660
                }
 
661
        }
 
662
        else if(t == Proxy::Socks) {
 
663
                if(x == SocksClient::ErrConnectionRefused)
 
664
                        err = ErrConnectionRefused;
 
665
                else if(x == SocksClient::ErrHostNotFound)
 
666
                        err = ErrHostNotFound;
 
667
                else {
 
668
                        proxyError = true;
 
669
                        if(x == SocksClient::ErrProxyAuth)
 
670
                                err = ErrProxyAuth;
 
671
                        else if(x == SocksClient::ErrProxyNeg)
 
672
                                err = ErrProxyNeg;
 
673
                        else
 
674
                                err = ErrProxyConnect;
 
675
                }
 
676
        }
 
677
 
 
678
        // no-multi or proxy error means we quit
 
679
        if(!d->multi || proxyError) {
 
680
                cleanup();
 
681
                d->errorCode = err;
 
682
                error();
 
683
                return;
 
684
        }
 
685
 
 
686
        if(d->using_srv && !d->servers.isEmpty()) {
 
687
#ifdef XMPP_DEBUG
 
688
                printf("bse1.1\n");
 
689
#endif
 
690
                tryNextSrv();
 
691
        }
 
692
        else if(!d->using_srv && d->opt_probe && d->probe_mode == 0) {
 
693
#ifdef XMPP_DEBUG
 
694
                printf("bse1.2\n");
 
695
#endif
 
696
                d->probe_mode = 1;
 
697
                d->port = 5222;
 
698
                d->will_be_ssl = false;
 
699
                do_connect();
 
700
        }
 
701
        else {
 
702
#ifdef XMPP_DEBUG
 
703
                printf("bse1.3\n");
 
704
#endif
 
705
                cleanup();
 
706
                d->errorCode = ErrConnectionRefused;
 
707
                error();
 
708
        }
 
709
}
 
710
 
 
711
void AdvancedConnector::http_syncStarted()
 
712
{
 
713
        httpSyncStarted();
 
714
}
 
715
 
 
716
void AdvancedConnector::http_syncFinished()
 
717
{
 
718
        httpSyncFinished();
 
719
}