QXmpp  Version:0.8.0
 All Classes Functions Variables Enumerations Enumerator Properties Groups
QXmppOutgoingClient.h
1 /*
2  * Copyright (C) 2008-2014 The QXmpp developers
3  *
4  * Authors:
5  * Manjeet Dahiya
6  * Jeremy LainĂ©
7  *
8  * Source:
9  * http://code.google.com/p/qxmpp
10  *
11  * This file is a part of QXmpp library.
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Lesser General Public
15  * License as published by the Free Software Foundation; either
16  * version 2.1 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  * Lesser General Public License for more details.
22  *
23  */
24 
25 
26 #ifndef QXMPPOUTGOINGCLIENT_H
27 #define QXMPPOUTGOINGCLIENT_H
28 
29 #include "QXmppClient.h"
30 #include "QXmppStanza.h"
31 #include "QXmppStream.h"
32 
33 class QDomElement;
34 class QSslError;
35 
36 class QXmppConfiguration;
37 class QXmppPresence;
38 class QXmppIq;
39 class QXmppMessage;
40 
41 class QXmppOutgoingClientPrivate;
42 
46 
47 class QXMPP_EXPORT QXmppOutgoingClient : public QXmppStream
48 {
49  Q_OBJECT
50 
51 public:
52  QXmppOutgoingClient(QObject *parent);
54 
55  void connectToHost();
56  bool isAuthenticated() const;
57  bool isConnected() const;
58 
59  QSslSocket *socket() const { return QXmppStream::socket(); };
60  QXmppStanza::Error::Condition xmppStreamError();
61 
62  QXmppConfiguration& configuration();
63 
64 signals:
66  void error(QXmppClient::Error);
67 
69  void elementReceived(const QDomElement &element, bool &handled);
70 
72  void presenceReceived(const QXmppPresence&);
73 
75  void messageReceived(const QXmppMessage&);
76 
78  void iqReceived(const QXmppIq&);
79 
80 protected:
82  // Overridable methods
83  virtual void handleStart();
84  virtual void handleStanza(const QDomElement &element);
85  virtual void handleStream(const QDomElement &element);
87 
88 private slots:
89  void _q_dnsLookupFinished();
90  void _q_socketDisconnected();
91  void socketError(QAbstractSocket::SocketError);
92  void socketSslErrors(const QList<QSslError>&);
93 
94  void pingStart();
95  void pingStop();
96  void pingSend();
97  void pingTimeout();
98 
99 private:
100  void sendNonSASLAuth(bool plaintext);
101  void sendNonSASLAuthQuery();
102 
103  friend class QXmppOutgoingClientPrivate;
104  QXmppOutgoingClientPrivate * const d;
105 };
106 
107 #endif // QXMPPOUTGOINGCLIENT_H